dorkos 0.131.0 → 0.133.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 (344) hide show
  1. package/dist/bin/cli.js +499 -314
  2. package/dist/browser/fresh-verifier.mjs +13 -13
  3. package/dist/browser/native/darwin-supervisor-worker.mjs +3 -3
  4. package/dist/browser/native/package-manifest.json +1 -1
  5. package/dist/browser/source-manifest.json +1 -1
  6. package/dist/client/assets/{AboutPage-BZ2LLJ0k.js → AboutPage-D-EHHVPa.js} +1 -1
  7. package/dist/client/assets/{ActivityErrorState-BnqAwUiy.js → ActivityErrorState-BTHnE1vP.js} +1 -1
  8. package/dist/client/assets/{ActivityPage-BlZKrSVo.js → ActivityPage-BfSLPIdR.js} +1 -1
  9. package/dist/client/assets/{ActivityRow-Ch8HxQ2m.js → ActivityRow-PwUBjQw8.js} +1 -1
  10. package/dist/client/assets/{AdapterIcon-CfocFMw-.js → AdapterIcon-DgkNN6bi.js} +1 -1
  11. package/dist/client/assets/{AdapterSetupWizard-Dtjx1Oad.js → AdapterSetupWizard-DX0dzp7q.js} +2 -2
  12. package/dist/client/assets/{AgentOptionRow-BGRvUeF7.js → AgentOptionRow-ApuDEKqq.js} +1 -1
  13. package/dist/client/assets/{AgentPicker-BcURPZQp.js → AgentPicker-BDci-9aL.js} +1 -1
  14. package/dist/client/assets/{AgentRequestCard-kNq5A_IN.js → AgentRequestCard-B2gxCMGi.js} +3 -3
  15. package/dist/client/assets/{AppearancePage-Cd-k7dcc.js → AppearancePage-8SVnFe0k.js} +1 -1
  16. package/dist/client/assets/ApplyToOverridesDialog-CnL1ubxL.js +1 -0
  17. package/dist/client/assets/{AttentionSignalRow-QY8AIjf9.js → AttentionSignalRow-CCKhUtil.js} +1 -1
  18. package/dist/client/assets/{BaseTanStackRouterDevtoolsPanel-B-iktbLX-Cgkvajbw.js → BaseTanStackRouterDevtoolsPanel-B-iktbLX-B7wFPzG4.js} +3 -3
  19. package/dist/client/assets/BindingDialog-C4BHVXno.js +1 -0
  20. package/dist/client/assets/{BlintzCanvas-CMzZnmWK.js → BlintzCanvas-7E5uwVms.js} +3 -3
  21. package/dist/client/assets/{CanvasCsvContent-uxMaHePf.js → CanvasCsvContent-l7lfyDGn.js} +4 -4
  22. package/dist/client/assets/CanvasFileContent-Bqd0IEfK.js +2 -0
  23. package/dist/client/assets/CanvasModel3dContent-DqL0Sy4r.js +2 -0
  24. package/dist/client/assets/{ChannelComposer-BAg0a29Q.js → ChannelComposer-CAYvz_ZB.js} +12 -17
  25. package/dist/client/assets/{ChatAppsOff-DD28V0vX.js → ChatAppsOff-CNeKBVNz.js} +2 -2
  26. package/dist/client/assets/{CodeMirrorDiff-CyoduBgM.js → CodeMirrorDiff-BZRcNFsS.js} +1 -1
  27. package/dist/client/assets/{CodeMirrorEditor-DGccoZ8Q.js → CodeMirrorEditor-DD5tArRn.js} +1 -1
  28. package/dist/client/assets/{ComputerResourceView-Dk98shko.js → ComputerResourceView-BUmsVssG.js} +1 -1
  29. package/dist/client/assets/{ComputerViewer-Broprz4q.js → ComputerViewer-BKMR5LkF.js} +1 -1
  30. package/dist/client/assets/{ConnectionAccessLists-C_qLz8GJ.js → ConnectionAccessLists-DYUiFmPY.js} +1 -1
  31. package/dist/client/assets/{ConnectionsPage-CmGgGmDO.js → ConnectionsPage-DR2Kfm9Q.js} +2 -2
  32. package/dist/client/assets/{ConventionPage-BxWLIUUC.js → ConventionPage-Do6q8873.js} +2 -2
  33. package/dist/client/assets/{ExtensionPageRoute-CyfIRaGs.js → ExtensionPageRoute-CP7NM7fw.js} +2 -2
  34. package/dist/client/assets/{FeatureDisabledState-By2dhVpu.js → FeatureDisabledState-Bi23k3rg.js} +1 -1
  35. package/dist/client/assets/{FloatingTanStackRouterDevtools-CqogiFob-B6wKQpLR.js → FloatingTanStackRouterDevtools-CqogiFob-lRlmDXYz.js} +1 -1
  36. package/dist/client/assets/{ForwardConsentHost-kDdpyBgA.js → ForwardConsentHost-DSR1pEEK.js} +1 -1
  37. package/dist/client/assets/HandlePage-aHId3bYX.js +1 -0
  38. package/dist/client/assets/HeartbeatPage-BTNVcHOI.js +1 -0
  39. package/dist/client/assets/{KeyEntry-Ctc1zp2J.js → KeyEntry-67acsEG2.js} +1 -1
  40. package/dist/client/assets/{LexicalField-7zd4B8f1.js → LexicalField-Cb68LIar.js} +2 -2
  41. package/dist/client/assets/{ManagesPage-BG1TIMP3.js → ManagesPage-ChPlBF42.js} +1 -1
  42. package/dist/client/assets/{Marketplace-C9r4jRJf.js → Marketplace-CzPhJEE1.js} +4 -4
  43. package/dist/client/assets/{MarketplaceSourcesView-C01Cdrge.js → MarketplaceSourcesView-CmQgxQmU.js} +1 -1
  44. package/dist/client/assets/{McpAppFrame-Dm7MqOhc.js → McpAppFrame-z5JUaCSA.js} +2 -2
  45. package/dist/client/assets/{McpSigninBody-CsXP_7lE.js → McpSigninBody-ZrnzwrOH.js} +1 -1
  46. package/dist/client/assets/{Model3dViewer-DOl8ZkrU.js → Model3dViewer-HJpWK-JI.js} +1 -1
  47. package/dist/client/assets/NamePage-C7F-SotG.js +1 -0
  48. package/dist/client/assets/{NewDirectMessageMenu-Dj-Qw8zA.js → NewDirectMessageMenu-CjBjzsDe.js} +1 -1
  49. package/dist/client/assets/{NotificationsPage-UExs4YE2.js → NotificationsPage-DwNUI0Z3.js} +1 -1
  50. package/dist/client/assets/{OpenMeshSwitch-Dx3M3wwS.js → OpenMeshSwitch-RNAZY1vn.js} +2 -2
  51. package/dist/client/assets/{OperatorIdentityForm-Bz5570RF.js → OperatorIdentityForm-B7S2C_eT.js} +1 -1
  52. package/dist/client/assets/PermissionHistory-D0chstxf.js +1 -0
  53. package/dist/client/assets/PermissionsPage-ToK0DZVV.js +1 -0
  54. package/dist/client/assets/{PersonalityPopover-Do-k_Hhw.js → PersonalityPopover-BvMtUQRM.js} +1 -1
  55. package/dist/client/assets/PhotoPage-Cqo3PNO_.js +1 -0
  56. package/dist/client/assets/{PreviewRefusedNotice-B-yyzQZP.js → PreviewRefusedNotice-DzbkMrUo.js} +1 -1
  57. package/dist/client/assets/{ProfileFields-DiarOK2y.js → ProfileFields-DU8dTGHT.js} +1 -1
  58. package/dist/client/assets/{ProfilePanelContainer-33Xkwoc3.js → ProfilePanelContainer-BfT-ufV7.js} +1 -1
  59. package/dist/client/assets/{ProfileRolePicker-BI6T4hj8.js → ProfileRolePicker-DrOtV-0N.js} +1 -1
  60. package/dist/client/assets/{PromptSuggestionChips-v5MScpZF.js → PromptSuggestionChips-CEnhme_V.js} +1 -1
  61. package/dist/client/assets/{ReportsToPopover-BALADuTO.js → ReportsToPopover-CwjpR1Tw.js} +1 -1
  62. package/dist/client/assets/{RoomSurface-BatV7gf5.js → RoomSurface-CChzNJKw.js} +1 -1
  63. package/dist/client/assets/{RoomsPage-DCCC3Dst.js → RoomsPage-Dbf6ijKr.js} +1 -1
  64. package/dist/client/assets/{RunsOnPopover-C7hMPyrb.js → RunsOnPopover-Bh5sSsSC.js} +1 -1
  65. package/dist/client/assets/{RuntimeConnectFlow-Dc5a8dlJ.js → RuntimeConnectFlow-BYQnY5vv.js} +1 -1
  66. package/dist/client/assets/{RuntimeSetupDialog-w90VGjJ4.js → RuntimeSetupDialog-DTO5v0dP.js} +1 -1
  67. package/dist/client/assets/{SeenDevices-BIMmbMWC.js → SeenDevices-cuY7ASEy.js} +3 -3
  68. package/dist/client/assets/{SessionsPage-0lwvSYHB.js → SessionsPage-BrqpVx-t.js} +1 -1
  69. package/dist/client/assets/{SettingsDialog-CrP6JzPg.js → SettingsDialog-DCAZX_1d.js} +4 -4
  70. package/dist/client/assets/{SkillsPage-BDgKWTfe.js → SkillsPage-D5who_ZH.js} +1 -1
  71. package/dist/client/assets/TaskDialogWrapper-BJ6XtOC5.js +1 -0
  72. package/dist/client/assets/TasksEmptyState-B3SjsxQa.js +3 -0
  73. package/dist/client/assets/{TasksPage-DjGbMGvn.js → TasksPage-B72w7J87.js} +1 -1
  74. package/dist/client/assets/{TeamComputerEntry-B_sM9Fik.js → TeamComputerEntry-B9ma5j-X.js} +1 -1
  75. package/dist/client/assets/TodoPromiseList-DDKWAfmv.js +1 -0
  76. package/dist/client/assets/TodoPromisesPage-BNXpvXzS.js +1 -0
  77. package/dist/client/assets/{ToolsPage-CeETRCd8.js → ToolsPage-DbJykCG3.js} +2 -2
  78. package/dist/client/assets/{TopologyGraph-CnpH2NjE.js → TopologyGraph-DKZS3nlr.js} +3 -3
  79. package/dist/client/assets/{TourHost-BQHrS47S.js → TourHost-Bw3Uoea5.js} +1 -1
  80. package/dist/client/assets/{UnlinkDialog-DOQLeNx4.js → UnlinkDialog-B-XCFNSd.js} +1 -1
  81. package/dist/client/assets/{UnreadDivider-DhyK6uGG.js → UnreadDivider-1aPVzwd7.js} +1 -1
  82. package/dist/client/assets/{WidgetErrorCard-Bwlfu514.js → WidgetErrorCard-C5ieVv_9.js} +6 -6
  83. package/dist/client/assets/{WithheldExtensionsNotice-BDc-CM2t.js → WithheldExtensionsNotice-CCO4ClRZ.js} +1 -1
  84. package/dist/client/assets/{WorkQueuePage-iO_DO1YK.js → WorkQueuePage-BbPKNwDg.js} +1 -1
  85. package/dist/client/assets/WorkView-BRcytACJ.js +51 -0
  86. package/dist/client/assets/_shell-EwFeSIGp.js +80 -0
  87. package/dist/client/assets/{_shell._home-BWi5YPaR.js → _shell._home-DD2mg-iK.js} +1 -1
  88. package/dist/client/assets/{_shell._home.activity-BU1NIGb7.js → _shell._home.activity-Z1QuU2M4.js} +1 -1
  89. package/dist/client/assets/_shell._home.index-BzTYr8Bw.js +3 -0
  90. package/dist/client/assets/_shell._home.tasks-BtC85Iut.js +1 -0
  91. package/dist/client/assets/{_shell._home.workspaces-wbnqJ58w.js → _shell._home.workspaces-qMG5OJYR.js} +1 -1
  92. package/dist/client/assets/{_shell.channels-D1KdvWZF.js → _shell.channels-BE4EK-iM.js} +2 -2
  93. package/dist/client/assets/_shell.connections-CBx0ogzx.js +1 -0
  94. package/dist/client/assets/{_shell.feedback-requests-DzHWC1fJ.js → _shell.feedback-requests-CwKSkkuD.js} +2 -2
  95. package/dist/client/assets/_shell.marketplace-CgWBUKSA.js +1 -0
  96. package/dist/client/assets/_shell.marketplace_.sources-8HZpKFDI.js +1 -0
  97. package/dist/client/assets/_shell.session-D6HcVbnm.js +1 -0
  98. package/dist/client/assets/{_shell.team-BMNSUpQQ.js → _shell.team-Dm5a4f8_.js} +4 -4
  99. package/dist/client/assets/_shell.threads-BavVtQOE.js +1 -0
  100. package/dist/client/assets/_shell.todos-B6uWr0zA.js +6 -0
  101. package/dist/client/assets/_shell.x._extensionId-DaELdkCH.js +1 -0
  102. package/dist/client/assets/_shell.x._extensionId_._-DaELdkCH.js +1 -0
  103. package/dist/client/assets/{abnfDiagram-WEYOIA3C-Co2k29JX.js → abnfDiagram-WEYOIA3C-Bu2T3jVw.js} +1 -1
  104. package/dist/client/assets/{access-copy-D6BUySpp.js → access-copy-tkiFMhRf.js} +1 -1
  105. package/dist/client/assets/{arc-DLZZpkuJ.js → arc-5q4SfXO9.js} +1 -1
  106. package/dist/client/assets/{architectureDiagram-ZHVYKT53-ClS9xqK5.js → architectureDiagram-ZHVYKT53-BnDMOBhV.js} +1 -1
  107. package/dist/client/assets/{banner-B8iMuXCP.js → banner-CSKUrrI0.js} +2 -2
  108. package/dist/client/assets/{blockDiagram-RJAE7QA3-DheoOELu.js → blockDiagram-RJAE7QA3-CtushlEs.js} +1 -1
  109. package/dist/client/assets/{c4Diagram-XDPPPE54-VWWZJ5x4.js → c4Diagram-XDPPPE54-7L-qYwKH.js} +1 -1
  110. package/dist/client/assets/channel-A3XT7_2L.js +1 -0
  111. package/dist/client/assets/{chunk-2E7WHVMD-BqPLJVkv.js → chunk-2E7WHVMD-ksBVyqQ3.js} +1 -1
  112. package/dist/client/assets/{chunk-2Q5K7J3B-DZn6OnKe.js → chunk-2Q5K7J3B-Bfqdkihb.js} +1 -1
  113. package/dist/client/assets/{chunk-4EMNKR2T-Dl9Poajp.js → chunk-4EMNKR2T-Brf2dH9x.js} +1 -1
  114. package/dist/client/assets/{chunk-55XCU76K-RoKuZPUc.js → chunk-55XCU76K-BlE7Cq40.js} +1 -1
  115. package/dist/client/assets/{chunk-5VM5RSS4-DV_1XHtU.js → chunk-5VM5RSS4-Bkgg3j7L.js} +1 -1
  116. package/dist/client/assets/{chunk-JWPE2WC7-B_IuS45y.js → chunk-JWPE2WC7-B9TRpN4O.js} +1 -1
  117. package/dist/client/assets/{chunk-VQ5W62QI-DkLNi45x.js → chunk-VQ5W62QI-ZoILnIYi.js} +1 -1
  118. package/dist/client/assets/{chunk-XXDRQBXY-ISM-1Dpw.js → chunk-XXDRQBXY-r2xNhaKz.js} +1 -1
  119. package/dist/client/assets/{chunk-ZCHMQSOR-MKaLMW8o.js → chunk-ZCHMQSOR-DfV3cF7d.js} +2 -2
  120. package/dist/client/assets/{classDiagram-v2-4MYWR3UA-CIWuu4ht.js → classDiagram-v2-4MYWR3UA-VOVqMNNP.js} +1 -1
  121. package/dist/client/assets/{command-CxGYZKco.js → command-CaUEAy3b.js} +1 -1
  122. package/dist/client/assets/{copy-button-DjAoGwds.js → copy-button-BOznikwM.js} +1 -1
  123. package/dist/client/assets/{cose-bilkent-JH36ORCC-HiCifRyi.js → cose-bilkent-JH36ORCC-CAdBvyLz.js} +1 -1
  124. package/dist/client/assets/{cpu-DHHTTvp_.js → cpu-j9vX9Wfk.js} +1 -1
  125. package/dist/client/assets/{cynefin-EF2NZ3EQ-DjJGZrPz.js → cynefin-EF2NZ3EQ-DcH1A9Oo.js} +1 -1
  126. package/dist/client/assets/{cynefinDiagram-WF24UDRP-DE2NdiJ2.js → cynefinDiagram-WF24UDRP-DJuKBXHi.js} +1 -1
  127. package/dist/client/assets/{dagre-NK4GIZVX-C6gDOD26.js → dagre-NK4GIZVX-D099H_0S.js} +1 -1
  128. package/dist/client/assets/{detail-row-CjwI1iuc.js → detail-row-Crl89jnh.js} +1 -1
  129. package/dist/client/assets/{diagram-CBK3MWTC-38LckcsL.js → diagram-CBK3MWTC-Cd_4W9XO.js} +1 -1
  130. package/dist/client/assets/{diagram-I5XIIV2D--8L6D9Ra.js → diagram-I5XIIV2D-Bc7aQKt3.js} +1 -1
  131. package/dist/client/assets/{diagram-ODIL2UCW-DGC2Inhd.js → diagram-ODIL2UCW-awVJZ4Bg.js} +1 -1
  132. package/dist/client/assets/{diagram-PFBEJUXE-BDHp0AyR.js → diagram-PFBEJUXE-dhsj9aeU.js} +1 -1
  133. package/dist/client/assets/{diagram-RJA3I4VV-uBatJYPi.js → diagram-RJA3I4VV-Dm59CbiV.js} +1 -1
  134. package/dist/client/assets/{diagram-TYUNFSNR-C8e1EH9X.js → diagram-TYUNFSNR-BhvcIjA9.js} +1 -1
  135. package/dist/client/assets/{ebnfDiagram-V4P3TTPT-DimRzU5B.js → ebnfDiagram-V4P3TTPT-C4wT_MTC.js} +1 -1
  136. package/dist/client/assets/{elk-QONTBCTQ-Dz6_Y2-G.js → elk-QONTBCTQ-CPI0zjmW.js} +1 -1
  137. package/dist/client/assets/{empty-state-saV209Il.js → empty-state-BHcmkSzu.js} +1 -1
  138. package/dist/client/assets/{erDiagram-KYQIGQAA-JeuTF8w6.js → erDiagram-KYQIGQAA-C_vGcbOB.js} +1 -1
  139. package/dist/client/assets/{execution-config-ClQZyDs9.js → execution-config-BS5rtvTZ.js} +1 -1
  140. package/dist/client/assets/{file-BIF-4ARS.js → file-CQGljfDT.js} +1 -1
  141. package/dist/client/assets/{file-exclamation-point-DxadH2b-.js → file-exclamation-point-B0a55VME.js} +1 -1
  142. package/dist/client/assets/{file-text-C_NPIQr4.js → file-text-Cycq_S0e.js} +1 -1
  143. package/dist/client/assets/{find-latest-widget-fence-CXai_zs0.js → find-latest-widget-fence-B6sJdG3Q.js} +4 -4
  144. package/dist/client/assets/{flowDiagram-IUGLLWBU-9FHDdK4j.js → flowDiagram-IUGLLWBU-_VNfmnxx.js} +1 -1
  145. package/dist/client/assets/{form-D3VdAYl4.js → form-BL14vwyB.js} +1 -1
  146. package/dist/client/assets/{format-cron-BqRDcFZM.js → format-cron-meJMgYNe.js} +1 -1
  147. package/dist/client/assets/{ganttDiagram-R7GPNTJY-CLMuXlHt.js → ganttDiagram-R7GPNTJY-o0gGU7X_.js} +1 -1
  148. package/dist/client/assets/{git-branch-Df7a5_fb.js → git-branch-CsLE6G0Y.js} +1 -1
  149. package/dist/client/assets/{gitGraphDiagram-PDYL7XHY-sE7Rlpr6.js → gitGraphDiagram-PDYL7XHY-DjXjUpJo.js} +1 -1
  150. package/dist/client/assets/{graph-iNVyFhBQ.js → graph-BMYee_VK.js} +1 -1
  151. package/dist/client/assets/{heart-BHMhDZ0K.js → heart-Cn3a-UQI.js} +1 -1
  152. package/dist/client/assets/{highlighted-body-KPVGNVTW-VvvsrJbu.js → highlighted-body-KPVGNVTW-DsX5yCC0.js} +1 -1
  153. package/dist/client/assets/{image-lightbox-CGEIRguA.js → image-lightbox-BZ_eBZgA.js} +1 -1
  154. package/dist/client/assets/{image-off-C5-TmSq8.js → image-off-DjR7LI5G.js} +1 -1
  155. package/dist/client/assets/{index-C3zS0ghJ.js → index-1MwES_vb.js} +1 -1
  156. package/dist/client/assets/{index-ClyRhxV_.js → index-47--OGKJ.js} +1 -1
  157. package/dist/client/assets/{index-CTgUh4p3.js → index-4rSR8lau.js} +1 -1
  158. package/dist/client/assets/{index-D9bEy8X-.js → index-B4TxpTKD.js} +1 -1
  159. package/dist/client/assets/{index-Dw-4S640.js → index-B8LqLhq7.js} +1 -1
  160. package/dist/client/assets/index-BJRgbiEd.js +1 -0
  161. package/dist/client/assets/{index-DWZ5M321.js → index-BOCclWF3.js} +1 -1
  162. package/dist/client/assets/index-BR1m9FON.js +1066 -0
  163. package/dist/client/assets/index-BcFn_S6b.js +1 -0
  164. package/dist/client/assets/{index-DRtg_sGG.js → index-BcnwvTnt.js} +1 -1
  165. package/dist/client/assets/index-BdVQOlVQ.css +1 -0
  166. package/dist/client/assets/{index-DEvpdTo6.js → index-BmKHO-FD.js} +1 -1
  167. package/dist/client/assets/{index-Bd0PAkxf.js → index-BsZkXHsH.js} +1 -1
  168. package/dist/client/assets/{index-Cudi8rs6.js → index-BxWr8Mrf.js} +1 -1
  169. package/dist/client/assets/index-C5EvpXcq.js +1 -0
  170. package/dist/client/assets/{index-CExh9cKN.js → index-Cb_p_ynP.js} +1 -1
  171. package/dist/client/assets/{index-YZbu9tke.js → index-CczLBUKI.js} +1 -1
  172. package/dist/client/assets/{index-264YDu-W.js → index-Cf4Gtxf9.js} +1 -1
  173. package/dist/client/assets/{index-Dpu2CORc.js → index-CfKSlYjb.js} +1 -1
  174. package/dist/client/assets/{index-Bzm9YMbr.js → index-Cgjq7a-8.js} +1 -1
  175. package/dist/client/assets/{index-Ci_J5Q-6.js → index-CpWxcN5D.js} +1 -1
  176. package/dist/client/assets/{index-BK5QrGfQ.js → index-Cv67OXfk.js} +1 -1
  177. package/dist/client/assets/{index-Di-MIFQG.js → index-D5Qmx1JR.js} +3 -3
  178. package/dist/client/assets/{index-LPrq0pOA.js → index-DARchye_.js} +1 -1
  179. package/dist/client/assets/{index-DMwivStD.js → index-DFb4kOjm.js} +2 -2
  180. package/dist/client/assets/{index-WeLoaNzW.js → index-DLN0kcME.js} +1 -1
  181. package/dist/client/assets/{index-BMLCfTba.js → index-DMSSN08i.js} +1 -1
  182. package/dist/client/assets/{index-Y6BDhuGt.js → index-DQ8uADJF.js} +1 -1
  183. package/dist/client/assets/index-DZhMvc9m.js +1 -0
  184. package/dist/client/assets/{index-CLsoFUml.js → index-Dfko0tSp.js} +1 -1
  185. package/dist/client/assets/{index-BgdYXP8E.js → index-DiM3QX-4.js} +3 -3
  186. package/dist/client/assets/{index-BxFLHNLg.js → index-DlvUENo4.js} +1 -1
  187. package/dist/client/assets/{index-BLUUshO9.js → index-DqZmnJED.js} +1 -1
  188. package/dist/client/assets/{index-D_bAtIJZ.js → index-DrlB9RSk.js} +1 -1
  189. package/dist/client/assets/{index-CgWzzIbx.js → index-H4e5Wpmi.js} +1 -1
  190. package/dist/client/assets/{index-k67dvyau.js → index-Joav7LQU.js} +1 -1
  191. package/dist/client/assets/{index-B0FHRkHM.js → index-KganLhU1.js} +2 -2
  192. package/dist/client/assets/{index-DFkofTx1.js → index-Kt6r3DQg.js} +1 -1
  193. package/dist/client/assets/{index-B8I1k-z9.js → index-Z2ApBQt4.js} +1 -1
  194. package/dist/client/assets/index-dY7IFpet.js +1 -0
  195. package/dist/client/assets/{index-DYVNSRDk.js → index-faSyUc2q.js} +1 -1
  196. package/dist/client/assets/{index-BgRYuqWs.js → index-gmyiXkmr.js} +1 -1
  197. package/dist/client/assets/{index-BZTLFzJp.js → index-o6kGmVGx.js} +1 -1
  198. package/dist/client/assets/{index-C_0JoCV6.js → index-vHKVYcH7.js} +1 -1
  199. package/dist/client/assets/{index.esm-CYmalBux.js → index.esm-CJIDYBqd.js} +1 -1
  200. package/dist/client/assets/{infoDiagram-MVDRKAX5-0aR9wjgO.js → infoDiagram-MVDRKAX5-B1mMyUlp.js} +1 -1
  201. package/dist/client/assets/{inline-code-DyTKSC5b.js → inline-code-mh48Uhbi.js} +1 -1
  202. package/dist/client/assets/{ishikawaDiagram-HPEHV2GE-D1lN8x2t.js → ishikawaDiagram-HPEHV2GE-efEMQ0_X.js} +1 -1
  203. package/dist/client/assets/{journeyDiagram-BOSHW7O7-CkXITXiJ.js → journeyDiagram-BOSHW7O7-DSAywiVk.js} +1 -1
  204. package/dist/client/assets/{kanban-definition-FNSA4HC5-ge33IiSq.js → kanban-definition-FNSA4HC5-B9pbU4zK.js} +1 -1
  205. package/dist/client/assets/{layers-Bx3K7OUm.js → layers-B0Z5Od3N.js} +1 -1
  206. package/dist/client/assets/{lightbulb-C5LvXkvM.js → lightbulb-Cfb5ecEd.js} +1 -1
  207. package/dist/client/assets/{link-2-Bj0_Zkvr.js → link-2-Dzy5BUL3.js} +1 -1
  208. package/dist/client/assets/{list-runtime-types-VNj1C8TB.js → list-runtime-types-DLmjtBMq.js} +1 -1
  209. package/dist/client/assets/{markdown-content-BRaPEOC7.js → markdown-content-DhAtZOfj.js} +1 -1
  210. package/dist/client/assets/{mention-pill-B_MiJWfo.js → mention-pill-DmA8FxL4.js} +1 -1
  211. package/dist/client/assets/{mermaid.core-B2hil_4a.js → mermaid.core-DUIkdbeL.js} +4 -4
  212. package/dist/client/assets/{message-square-off-T33FHpr7.js → message-square-off-BowIzJUV.js} +1 -1
  213. package/dist/client/assets/{mindmap-definition-6OY57UG3-Bu_Ia4Xz.js → mindmap-definition-6OY57UG3-Dz7ZOR4C.js} +1 -1
  214. package/dist/client/assets/{more-details-oDazWBxm.js → more-details-DV7LmY0E.js} +1 -1
  215. package/dist/client/assets/{owner-notice-VepbAQhj.js → owner-notice-DdFc2P8z.js} +1 -1
  216. package/dist/client/assets/{package-DBsl3ao5.js → package-BhKXbvU_.js} +1 -1
  217. package/dist/client/assets/{page-container-Bkarym6m.js → page-container-0sWZ3xh9.js} +1 -1
  218. package/dist/client/assets/{pane-resize-handle-gBlb5k1v.js → pane-resize-handle-Bjy4udre.js} +1 -1
  219. package/dist/client/assets/{paperclip-BeFttiUK.js → paperclip-C-7LhBfl.js} +1 -1
  220. package/dist/client/assets/{path-input-NY_yCBHb.js → path-input-BPVyI72G.js} +1 -1
  221. package/dist/client/assets/{pegDiagram-ECIUJNBX-0KmJlW0E.js → pegDiagram-ECIUJNBX-C4EOP-Fa.js} +1 -1
  222. package/dist/client/assets/{pieDiagram-GNMPY74T-IjeZXicv.js → pieDiagram-GNMPY74T-CQ1OxRkv.js} +1 -1
  223. package/dist/client/assets/{plug-CTqOZ7cA.js → plug-CIZ-wWL8.js} +1 -1
  224. package/dist/client/assets/{primer-trigger-CjaGrT2u.js → primer-trigger-XA5fLzR5.js} +2 -2
  225. package/dist/client/assets/{profile-errors-B8XkL2Rp.js → profile-errors-C1XACbc9.js} +1 -1
  226. package/dist/client/assets/{progress-Cr-4myw6.js → progress-BA2JPtb6.js} +1 -1
  227. package/dist/client/assets/{quadrantDiagram-D57K4MC3-CP6kLJKa.js → quadrantDiagram-D57K4MC3-Cw4BdkpS.js} +1 -1
  228. package/dist/client/assets/{query-error-state-DvhY-YKM.js → query-error-state-Cm-Lozlb.js} +1 -1
  229. package/dist/client/assets/{radio-CmDmmJy6.js → radio-DQ29H26H.js} +1 -1
  230. package/dist/client/assets/{railroadDiagram-Y72NRBL7-Bcto__oE.js → railroadDiagram-Y72NRBL7-CSKtYLmm.js} +1 -1
  231. package/dist/client/assets/registry-Tbt9pcZl.js +39 -0
  232. package/dist/client/assets/registry-jD9zw538.js +1 -0
  233. package/dist/client/assets/{relay-trace-schemas-ZLR1S8ft.js → relay-trace-schemas-4AAUf-Zl.js} +2 -2
  234. package/dist/client/assets/{repeat-DVTM8et8.js → repeat-B8g-x-Sc.js} +1 -1
  235. package/dist/client/assets/{requirementDiagram-EQYSW5RA-DNJrds3m.js → requirementDiagram-EQYSW5RA-BPSBZr7X.js} +1 -1
  236. package/dist/client/assets/{room-files-source-9Wdtc-bG.js → room-files-source-BkiK4-ZI.js} +2 -2
  237. package/dist/client/assets/{rotate-ccw-clock-qJSWqifh.js → rotate-ccw-clock-DRtL-2nr.js} +1 -1
  238. package/dist/client/assets/{rotate-cw-uoeBxIeM.js → rotate-cw-BbHkWN-J.js} +1 -1
  239. package/dist/client/assets/{sankeyDiagram-SY24JHO5-DNlU7xGI.js → sankeyDiagram-SY24JHO5-DVlHablQ.js} +1 -1
  240. package/dist/client/assets/{scroll-area-B1d3NfEn.js → scroll-area-DAC7NrVU.js} +1 -1
  241. package/dist/client/assets/{sequenceDiagram-BLEHNHQU-CRk71coF.js → sequenceDiagram-BLEHNHQU--wZkN8xk.js} +1 -1
  242. package/dist/client/assets/{shield-x-BpQmg1qz.js → shield-x-CEWfkzDN.js} +1 -1
  243. package/dist/client/assets/{signed-in-CTmJ3OqM.js → signed-in-CMhCR-m8.js} +1 -1
  244. package/dist/client/assets/{sizeCapture-INFHLROL-cihX3QNq.js → sizeCapture-INFHLROL-CLXc7d3S.js} +1 -1
  245. package/dist/client/assets/{soul-file-BwiyiI5v.js → soul-file-CbX7rNqz.js} +1 -1
  246. package/dist/client/assets/{stateDiagram-v2-A6IESKWZ-BAwwRsnH.js → stateDiagram-v2-A6IESKWZ-5xa1FM_X.js} +1 -1
  247. package/dist/client/assets/{swimlanes-B3ENRKFQ-CpDB6CUC.js → swimlanes-B3ENRKFQ-DKgxJxjE.js} +1 -1
  248. package/dist/client/assets/swimlanesDiagram-AYQRV4AK-f6MOc3pl.js +8 -0
  249. package/dist/client/assets/{table-dWrfPeX-.js → table-D0EJT0uP.js} +1 -1
  250. package/dist/client/assets/{tabs-D4txthOi.js → tabs-Ctjzrm8t.js} +1 -1
  251. package/dist/client/assets/{timeline-definition-JXYKGLGB-RDrKgCoU.js → timeline-definition-JXYKGLGB-B9P7ituI.js} +1 -1
  252. package/dist/client/assets/trust-dial-D__tIhzt.js +11 -0
  253. package/dist/client/assets/{trust-posture-atZIh8tf.js → trust-posture-DaHHtOZn.js} +1 -1
  254. package/dist/client/assets/{unplug-CnevV4yX.js → unplug-B-ipHefz.js} +1 -1
  255. package/dist/client/assets/{unverified-catalog-notice-BQwT36FA.js → unverified-catalog-notice-C8swqaTn.js} +1 -1
  256. package/dist/client/assets/{use-bindings-CltfjAWW.js → use-bindings-gLHRNAFU.js} +1 -1
  257. package/dist/client/assets/{use-composer-prefs-D-Zlt6z2.js → use-composer-prefs-CjpxcBIe.js} +1 -1
  258. package/dist/client/assets/{use-connector-management-C3CLnOOt.js → use-connector-management-BLiCJMgU.js} +1 -1
  259. package/dist/client/assets/{use-deep-link-scroll-DQlz-scx.js → use-deep-link-scroll-r2nKjzA-.js} +1 -1
  260. package/dist/client/assets/{use-delete-binding-D73CLm_7.js → use-delete-binding-BSiOik_K.js} +1 -1
  261. package/dist/client/assets/{use-dev-links-BqVFsMKU.js → use-dev-links-DXcIlMf-.js} +1 -1
  262. package/dist/client/assets/use-direct-message-panel-BbH8N4mE.js +1 -0
  263. package/dist/client/assets/{use-external-adapter-catalog-DrnksH0t.js → use-external-adapter-catalog-mmKni5ui.js} +1 -1
  264. package/dist/client/assets/{use-filter-state-D4i-hDOk.js → use-filter-state-CiPZ0AIH.js} +2 -2
  265. package/dist/client/assets/{use-full-activity-feed-DdDsRg8s.js → use-full-activity-feed-DXroUzfN.js} +1 -1
  266. package/dist/client/assets/use-is-below-desktop-LUZL5z5t.js +1 -0
  267. package/dist/client/assets/{use-mesh-topology-B7aLtPkZ.js → use-mesh-topology-upehQ5Cv.js} +1 -1
  268. package/dist/client/assets/{use-mounted-ref-DSSTCJfY.js → use-mounted-ref-IHwyriaF.js} +1 -1
  269. package/dist/client/assets/{use-notification-prefs-DaF3kwmq.js → use-notification-prefs-BHOK2P2l.js} +1 -1
  270. package/dist/client/assets/use-pending-read-mVsOBTzn.js +1 -0
  271. package/dist/client/assets/{use-personality-commit-D5b90JPX.js → use-personality-commit-Chf3UX8P.js} +1 -1
  272. package/dist/client/assets/{use-promo-activation-CPAOQpfe.js → use-promo-activation-Dlw6bg7G.js} +2 -2
  273. package/dist/client/assets/{use-promo-dismissals-Bx1gz1R1.js → use-promo-dismissals-Dx_fli7I.js} +1 -1
  274. package/dist/client/assets/{use-pulse-freshness-DeulB37O.js → use-pulse-freshness-CG_I6a-O.js} +1 -1
  275. package/dist/client/assets/{use-room-follow-claim-Dwke6RFQ.js → use-room-follow-claim-Bgrpr3bO.js} +1 -1
  276. package/dist/client/assets/{use-room-sessions-iepVrIMm.js → use-room-sessions-DecGrP3E.js} +1 -1
  277. package/dist/client/assets/{use-roving-tab-list-pCPKNQKv.js → use-roving-tab-list-CDkh-Ujm.js} +1 -1
  278. package/dist/client/assets/{use-session-canvas-BvvO-_V1.js → use-session-canvas-tvLLPQcm.js} +6 -6
  279. package/dist/client/assets/{use-status-budget-Bs7MMriS.js → use-status-budget-BBl2yxLR.js} +2 -2
  280. package/dist/client/assets/{use-todos-C-eREuDS.js → use-todos-BzRauzdQ.js} +1 -1
  281. package/dist/client/assets/{use-transform-lj3TkjYO.js → use-transform-DzJeHpxm.js} +1 -1
  282. package/dist/client/assets/{use-unclaimed-chats-BF3-0jHC.js → use-unclaimed-chats--HZdmq4F.js} +1 -1
  283. package/dist/client/assets/use-update-config-DjL7-nUR.js +1 -0
  284. package/dist/client/assets/{useMutationState-B_x_4f2K.js → useMutationState-DIywUTDG.js} +1 -1
  285. package/dist/client/assets/{usecaseDiagram-WPOLBNNX-DBsRYa4J.js → usecaseDiagram-WPOLBNNX-C9aLJ03F.js} +1 -1
  286. package/dist/client/assets/{vennDiagram-Q3Y3IDCW-rFAXvcQI.js → vennDiagram-Q3Y3IDCW-ChBIWbL0.js} +1 -1
  287. package/dist/client/assets/{wardleyDiagram-IVAIDKWA-bI0JZkO3.js → wardleyDiagram-IVAIDKWA-DvQDOaTm.js} +1 -1
  288. package/dist/client/assets/{xychartDiagram-4URNHDU4-DZUd8iln.js → xychartDiagram-4URNHDU4-8FxLPP2c.js} +1 -1
  289. package/dist/client/assets/zap-DSllMMHe.js +6 -0
  290. package/dist/client/index.html +2 -2
  291. package/dist/drizzle/20261104060919_package_approval_request.sql +1 -0
  292. package/dist/drizzle/20261104081935_hook_decline_review.sql +3 -0
  293. package/dist/drizzle/20261107183323_dor3933_todos_rename.sql +64 -0
  294. package/dist/drizzle/20261108014418_dor3938_cross_agent_writer.sql +4 -0
  295. package/dist/drizzle/meta/20261104060919_snapshot.json +14889 -0
  296. package/dist/drizzle/meta/20261104081935_snapshot.json +14910 -0
  297. package/dist/drizzle/meta/20261107183323_snapshot.json +14910 -0
  298. package/dist/drizzle/meta/20261108014418_snapshot.json +14938 -0
  299. package/dist/drizzle/meta/_journal.json +28 -0
  300. package/dist/server/index.js +24875 -21931
  301. package/dist/server/index.js.map +2 -2
  302. package/package.json +5 -5
  303. package/dist/client/assets/ApplyToOverridesDialog-DE9VVQCA.js +0 -1
  304. package/dist/client/assets/BindingDialog-C_yflKOE.js +0 -1
  305. package/dist/client/assets/CanvasFileContent-C3ZKszxn.js +0 -2
  306. package/dist/client/assets/CanvasModel3dContent-CsNUuaj6.js +0 -2
  307. package/dist/client/assets/CommitmentList-DOvfnyDA.js +0 -1
  308. package/dist/client/assets/CommitmentsPage-D81vxHUk.js +0 -1
  309. package/dist/client/assets/HandlePage-vsG04kBg.js +0 -1
  310. package/dist/client/assets/HeartbeatPage-CMj1SS30.js +0 -1
  311. package/dist/client/assets/NamePage-DdX2yQ5f.js +0 -1
  312. package/dist/client/assets/PermissionHistory-Bhl2kr1R.js +0 -1
  313. package/dist/client/assets/PermissionsPage-DUbenFkt.js +0 -1
  314. package/dist/client/assets/PhotoPage-CExABoHA.js +0 -1
  315. package/dist/client/assets/TaskDialogWrapper-BVb8gAr0.js +0 -1
  316. package/dist/client/assets/TasksEmptyState-RkUEEU2r.js +0 -3
  317. package/dist/client/assets/WorkView-BDk_vwu3.js +0 -51
  318. package/dist/client/assets/_shell-CMNFxZKJ.js +0 -80
  319. package/dist/client/assets/_shell._home.index-BjR-d3_s.js +0 -3
  320. package/dist/client/assets/_shell._home.tasks-CqURPMQD.js +0 -1
  321. package/dist/client/assets/_shell.connections-D3gJrBTQ.js +0 -1
  322. package/dist/client/assets/_shell.marketplace-HdefWdN_.js +0 -1
  323. package/dist/client/assets/_shell.marketplace_.sources-wAZKfDQF.js +0 -1
  324. package/dist/client/assets/_shell.session-C0utZeSI.js +0 -1
  325. package/dist/client/assets/_shell.threads-TvzYRNMt.js +0 -1
  326. package/dist/client/assets/_shell.todos-sOFmsIPE.js +0 -6
  327. package/dist/client/assets/_shell.x._extensionId-DiEQZIvl.js +0 -1
  328. package/dist/client/assets/_shell.x._extensionId_._-DiEQZIvl.js +0 -1
  329. package/dist/client/assets/channel-B0WiEIVe.js +0 -1
  330. package/dist/client/assets/index-BwTGkJbK.js +0 -1071
  331. package/dist/client/assets/index-CCHGVclj.js +0 -1
  332. package/dist/client/assets/index-CiUmx-i3.js +0 -1
  333. package/dist/client/assets/index-Dd4JoHFP.js +0 -1
  334. package/dist/client/assets/index-DlmGvYpy.js +0 -1
  335. package/dist/client/assets/index-EXJsA5kw.js +0 -1
  336. package/dist/client/assets/index-MpS13vhQ.css +0 -1
  337. package/dist/client/assets/registry-BQTcAm5U.js +0 -39
  338. package/dist/client/assets/registry-HencHRXy.js +0 -1
  339. package/dist/client/assets/swimlanesDiagram-AYQRV4AK-nJfOIWYW.js +0 -8
  340. package/dist/client/assets/use-direct-message-panel-B3qfpDjY.js +0 -1
  341. package/dist/client/assets/use-is-below-desktop-BXHT3oPL.js +0 -1
  342. package/dist/client/assets/use-local-browser-DDWknHZE.js +0 -1
  343. package/dist/client/assets/use-pending-read-uvmEJ7H9.js +0 -1
  344. package/dist/client/assets/use-update-config-D-OGlXGR.js +0 -1
@@ -1,80 +0,0 @@
1
- var Sm=Object.defineProperty;var Cm=(e,t,s)=>t in e?Sm(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s;var wn=(e,t,s)=>Cm(e,typeof t!="symbol"?t+"":t,s);import{O as We,sI as Nm,r as u,fs as sa,sJ as Am,fq as so,j as n,sK as Em,sL as hc,ft as Im,kI as ro,a5 as ie,a6 as Ee,aJ as Fe,fo as De,g1 as Dn,sM as Xs,kF as ms,sN as Rm,sO as Tm,a7 as le,ar as fe,kq as ra,sP as Dm,eJ as Es,_ as re,B as F,X as Be,G as K,k3 as fc,sQ as Om,x as Oe,a4 as pc,by as gc,bg as Is,dV as $e,a$ as Mm,sR as oa,sS as _m,bY as Pm,aI as xc,cA as Pe,aO as Me,s as Rt,k_ as Lm,k$ as bc,dS as ce,m2 as Bn,m3 as At,m4 as yc,a_ as L,sj as Fm,f9 as rt,ea as hs,ju as un,sT as $m,a8 as Qt,eW as vc,fN as oo,dd as ao,av as Xt,sU as aa,kp as Bm,ku as wc,ko as zm,qy as io,Y as zn,J as Jt,$ as co,eI as an,l as Ne,aK as jc,f6 as kc,eq as Sc,er as Cc,f7 as Um,sV as Km,ev as dt,bz as mn,bA as hn,U as Zt,bB as fn,bD as pn,C as gn,eE as He,eF as Hm,nn as Nc,lH as Ac,aQ as Ue,sW as Wm,gU as Ec,bZ as ia,sX as Gm,g as fs,kE as Ar,z as lo,ek as ht,hS as ct,gk as uo,fT as Rs,kT as mo,f as Dt,bb as Ic,eV as Ts,sY as Rc,eC as qm,ao as ho,a2 as On,dp as xn,dq as bn,dr as yn,am as Le,as as Ds,oq as Tc,sZ as Ym,s_ as Vm,d0 as Qm,e9 as ps,Z as Ye,l5 as Os,l4 as rn,d3 as vt,d4 as wt,d6 as gt,d7 as ot,d8 as xt,eT as Et,e0 as on,d_ as Xm,cu as Un,eP as Dc,s$ as Jm,cs as Oc,gC as Mc,he as ca,t0 as Zm,iR as gs,kP as eh,kR as th,hc as _c,t1 as nh,g7 as fo,g8 as po,ga as go,ir as Pc,gb as qe,t2 as Kn,gd as os,h as Ms,t3 as xo,t4 as sh,g9 as rh,rw as oh,t5 as Lc,kf as ah,t6 as ih,t7 as ch,t8 as lh,hv as Fc,t9 as dh,ta as $c,jt as Bc,tb as zc,tc as uh,ay as mh,gt as Uc,af as _e,ht as _s,td as hh,te as fh,gu as ph,sC as la,ia as gh,nk as xh,ic as bh,id as yh,ie as vh,jV as Kc,tf as wh,tg as ue,th as jh,ti as Hc,tj as bo,iG as Er,iB as Wc,tk as yo,tl as Ir,tm as vo,ba as Hn,tn as Ps,to as kh,tp as Sh,tq as Ch,tr as Nh,ts as Ah,tt as Eh,tu as Ih,tv as Lt,kG as Rh,k8 as Th,oN as Dh,tw as da,bf as Oh,i2 as Gc,tx as Wt,ty as cn,tz as Mh,tA as _h,tB as Ph,ip as Lh,fS as qc,cc as $t,iy as Yc,iz as xs,iH as Vc,iI as Qc,iA as Xc,iC as Fh,tC as $h,tD as Bh,tE as zh,ij as Jc,ik as Zc,tF as Gt,tG as Uh,tH as Kh,eL as Hh,tI as Mn,tJ as Wh,b1 as el,tK as Gh,tL as qh,tM as Yh,tN as Vh,tO as Qh,tP as tl,tQ as Bt,fQ as It,dx as ut,dv as Wn,dw as me,dA as Gn,dz as Ut,dy as be,I as yt,pV as nl,q3 as sl,nV as qt,nU as _n,cw as Ls,lz as Xh,nT as rl,fa as ol,st as al,pf as il,nS as Jh,tR as Zh,tS as ua,tT as ef,tU as ln,tV as cl,c4 as qn,iS as ll,tW as tf,qR as nf,tX as sf,tY as dl,tZ as rf,t_ as of,gD as af,b0 as wo,nW as jo,t$ as cf,gw as Fs,u0 as An,u1 as ko,q as bs,m7 as ul,u2 as lf,o as ml,u3 as df,l0 as ma,mO as uf,pw as mf,u4 as hf,ci as ff,u5 as pf,al as $s,ak as Bs,o1 as So,o0 as Co,u6 as gf,dT as zs,ou as Us,u7 as Js,u8 as as,lk as hl,u9 as xf,ua as bf,ub as yf,uc as vf,ud as wf,ue as jf,uf as kf,hp as Ks,qx as Sf,ug as fl,ot as Cf,iQ as Nf,jI as ha,uh as Af,ui as dn,lF as Rr,em as Ef,uj as No,nY as Hs,uk as Ws,ul as If,nX as Rf,iW as Ao,nZ as pl,um as gl,un as Tf,rq as Df,uo as Of,up as Mf,uq as fa,ur as _f,us as Pf,ut as Lf,uu as Ff,uv as pa,uw as xl,ux as $f,uy as Bf,uz as zf,uA as ga,e as mt,uB as Uf,uC as Kf,lD as Gs,c1 as bl,uD as yl,uE as vl,uF as wl,uG as Hf,mj as jl,uH as Wf,uI as Gf,H as Eo,gy as qf,uJ as Yf,me as Vf,mq as Qf,uK as Xf,uL as Jf,uM as Zf,b8 as ep,kg as tp,uN as np,uO as ys,mz as kl,uP as Sl,uQ as sp,uR as rp,uS as Cl,uT as xa,uU as ba,uV as Nl,b7 as op,uW as ap,uX as ip,uY as Al,uZ as El,u_ as Jn,u$ as cp,v0 as lp,v1 as dp,v2 as Il,kJ as Rl,kK as Tl,kL as Dl,kM as Tr,v3 as Dr,v4 as up,cG as jn,aX as mp,v5 as Ol,gv as Io,f8 as ya,kV as Ro,bl as hp,t as fp,j4 as Or,i9 as pp,aR as To,iO as Ml,v6 as gp,dB as xp,dC as bp,pZ as yp,lC as vp,v7 as wp,lE as va,mr as _l,bP as jp,bQ as kp,bR as Sp,bS as Cp,bT as Np,bU as Ap,bV as Ep,v8 as Ip,v9 as Mr,va as Rp,vb as Zs,vc as Tp,vd as Dp,ve as Pn,vf as Op,vg as wa,nx as Mp,mk as _p,vh as Pp,bc as vs,mX as ja,mV as Lp,mW as ka,vi as Fp,my as $p,vj as Sa,vk as Bp,fB as zp,vl as Up,vm as Kp,vn as Hp,c7 as Wp,vo as Gp,vp as Pl,vq as Ll,Q as Do,T as Oo,V as Mo,vr as qp,vs as Yp,g5 as Vp,vt as er,hi as Qp,gH as Xp,vu as Jp,vv as Zp,vw as eg,vx as tg,vy as ng,vz as sg,vA as Ca,vB as rg,vC as og,vD as ag,vE as Fl,ke as ig,c0 as cg,vF as $l,vG as lg,fU as dg,vH as Na,dD as ug,vI as mg,vJ as hg,p_ as fg,vK as pg,vL as gg,cr as xg,vM as bg,vN as Aa,vO as yg,vP as vg,vQ as wg,vR as jg,iK as kg,vS as qs,bk as Bl,a3 as zl,vT as Ul,qA as Sg,bi as Cg,bj as Ng,fd as Ea,bh as Ag,gW as tr,h2 as nr,eG as Eg,vU as _o,n as Ig,hx as Rg,hy as Ia,aU as Ra,pY as Tg,bC as Kl,vV as Hl,vW as Wl,qL as Dg,vX as Og,pU as Mg,qb as _g,ky as Pg,et as Lg,vY as Fg,ab as Gl,vZ as $g,ks as Bg,kt as zg,ll as Ug,fH as ql,fI as Yl,fJ as Vl,fK as Ql,dW as Kg,eH as Hg,fF as Wg,fG as Gg,jJ as qg,jQ as Yg,lp as Vg,jK as Qg,v_ as Xg,eN as Jg,lq as Zg,v$ as Xl,w0 as ex,w1 as tx,lo as nx,ln as sx,jL as rx,eQ as ox,kD as ax,jx as ix,w2 as cx,w3 as Jl,w4 as lx,w5 as dx,w6 as sn,dG as ux,w7 as Ta,o8 as mx,oa as Zl,d$ as hx,kn as fx,pv as px,w8 as _r,g6 as gx,j3 as xx,ol as ft,on as bx,si as yx,oH as Da,cX as vx,w9 as wx,wa as jx,wb as kx,wc as Sx,wd as Cx,we as Nx,wf as Ax,wg as Ex,wh as Ix,sH as Rx,le as Tx,hg as Dx,wi as Ox,wj as Mx,wk as _x,wl as Px,wm as Lx,wn as Fx,cD as $x,wo as Bx,jU as zx,dc as Ux}from"./index-BwTGkJbK.js";import{u as Kx,g as Hx}from"./use-connector-management-C3CLnOOt.js";import{D as Tt,a as Wx}from"./TourHost-BQHrS47S.js";import{C as Po,o as ed,O as td,p as lt,H as Gx,q as Nt,I as at,t as ws,s as Yn,v as nd,x as qx,y as sd,z as Yx,u as rd,r as Vx,w as Qx,b as Xx,j as Jx,D as Pr,P as Zx,B as eb,e as od,E as ad,F as id,G as tb,J as nb,h as sb,S as Oa,A as rb,T as ob,a as ab,n as ib,L as cb}from"./SeenDevices-BIMmbMWC.js";import{I as Ma,t as lb}from"./trust-posture-atZIh8tf.js";import{u as Vn}from"./use-update-config-D-OGlXGR.js";import{b as db,u as ub,O as mb,c as hb}from"./OpenMeshSwitch-Dx3M3wwS.js";import{u as fb,S as pb,s as gb,b as xb,P as bb,a as yb}from"./ApplyToOverridesDialog-DE9VVQCA.js";import{B as vb,u as wb}from"./use-bindings-CltfjAWW.js";import{a as cd,C as jb}from"./cpu-DHHTTvp_.js";import{r as kb,f as Sb,b as Cb,K as Nb}from"./RuntimeConnectFlow-Dc5a8dlJ.js";import{O as Ab,B as ld}from"./banner-B8iMuXCP.js";import{u as Ys,P as dd,a as Eb}from"./ProfileRolePicker-BI6T4hj8.js";import{u as Ib}from"./use-dev-links-BqVFsMKU.js";import{d as Rb}from"./untrusted-text-BDygHCRk.js";import{S as En}from"./scroll-area-B1d3NfEn.js";import{T as ud,a as md,b as is,c as sr}from"./tabs-D4txthOi.js";import{P as Tb}from"./paperclip-BeFttiUK.js";import{L as Db}from"./lightbulb-C5LvXkvM.js";import{r as hd,s as _a,e as Ob}from"./access-copy-D6BUySpp.js";import{a as Mb}from"./use-pulse-freshness-DeulB37O.js";import{c as _b,B as Pb,w as Lb,b as Fb,a as $b,e as Bb}from"./primer-trigger-CjaGrT2u.js";import{u as zb,s as Ub,P as Kb,a as Hb}from"./use-promo-activation-CPAOQpfe.js";import{u as fd}from"./use-promo-dismissals-Bx1gz1R1.js";import{u as pd}from"./use-pending-read-uvmEJ7H9.js";import{a as bt}from"./dorkbot-templates-8Yu9POWJ.js";import{i as Wb,O as gd,c as Gb,b as qb}from"./OperatorIdentityForm-Bz5570RF.js";import{A as xd}from"./repeat-DVTM8et8.js";import{S as bd,P as Yb}from"./progress-Cr-4myw6.js";import{P as Vb,M as Qb}from"./plug-CTqOZ7cA.js";import{i as Lo,a as Xb,u as Jb}from"./use-notification-prefs-DaF3kwmq.js";import{R as Zb}from"./rotate-cw-uoeBxIeM.js";import{b as ey}from"./use-todos-C-eREuDS.js";import{u as ty,a as ny,C as sy,N as ry}from"./NewDirectMessageMenu-Dj-Qw8zA.js";import{P as oy,C as ay,f as iy,a as cy}from"./find-latest-widget-fence-CXai_zs0.js";import{o as ly}from"./owner-notice-VepbAQhj.js";import{U as dy}from"./unplug-CnevV4yX.js";import{c as uy,H as yd,a as vd,b as wd}from"./RuntimeSetupDialog-w90VGjJ4.js";import{u as jd}from"./use-is-below-desktop-BXHT3oPL.js";import{P as my,u as hy}from"./pane-resize-handle-gBlb5k1v.js";import{a as fy,u as py,F as gy}from"./ForwardConsentHost-kDdpyBgA.js";import{W as xy}from"./WithheldExtensionsNotice-BDc-CM2t.js";import{u as by}from"./use-direct-message-panel-B3qfpDjY.js";import{u as yy}from"./ComputerViewer-Broprz4q.js";import{a as vy}from"./use-local-browser-DDWknHZE.js";import{F as wy}from"./file-text-C_NPIQr4.js";import{P as Pa}from"./page-container-Bkarym6m.js";import{A as jy}from"./AttentionSignalRow-QY8AIjf9.js";import{u as ky}from"./use-roving-tab-list-pCPKNQKv.js";import{R as kd}from"./rotate-ccw-clock-qJSWqifh.js";import{d as st,e as Ae,f as La,g as Sd,C as Cd,a as Nd,b as Ad,c as Sy}from"./command-CxGYZKco.js";import{A as Cy,M as Ny}from"./McpAppFrame-Dm7MqOhc.js";import{L as Ay}from"./layers-Bx3K7OUm.js";import{A as Ey}from"./AgentOptionRow-BGRvUeF7.js";import{R as Iy}from"./radio-CmDmmJy6.js";import{a as Ry}from"./sound-D3r8dGFH.js";import{d as Ty}from"./connection-copy--MA7AN04.js";import{u as Dy,i as Oy,d as My,P as Ed}from"./PreviewRefusedNotice-B-yyzQZP.js";import{P as _y}from"./path-input-NY_yCBHb.js";import"./WidgetErrorCard-Bwlfu514.js";import{a as Py}from"./ComputerResourceView-Dk98shko.js";import"./use-external-adapter-catalog-DrnksH0t.js";import"./execution-config-ClQZyDs9.js";import"./settings-for-runtime-BoOa-ZFG.js";import"./use-mesh-topology-B7aLtPkZ.js";import"./copy-button-DjAoGwds.js";import"./inline-code-DyTKSC5b.js";import"./useMutationState-B_x_4f2K.js";import"./runtime-connect-Dn0T5YWv.js";import"./use-full-activity-feed-DdDsRg8s.js";import"./profile-errors-B8XkL2Rp.js";import"./use-mounted-ref-DSSTCJfY.js";import"./ProfileFields-DiarOK2y.js";import"./list-runtime-types-VNj1C8TB.js";import"./more-details-oDazWBxm.js";import"./shield-x-BpQmg1qz.js";import"./index-Ci_J5Q-6.js";import"./markdown-content-BRaPEOC7.js";import"./table-dWrfPeX-.js";import"./package-DBsl3ao5.js";import"./heart-BHMhDZ0K.js";import"./git-branch-Df7a5_fb.js";import"./file-BIF-4ARS.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 Id={name:"building-complex",size:24,node:[["path",{d:"M10 12h4",key:"a56b0p"}],["path",{d:"M10 8h4",key:"1sr2af"}],["path",{d:"M14 21v-3a2 2 0 0 0-4 0v3",key:"1rgiei"}],["path",{d:"M6 10H4a2 2 0 0 0-2 2v7a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2h-2",key:"secmi2"}],["path",{d:"M6 21V5a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v16",key:"16ra0t"}]],aliases:["building-2"]};Id.node;const Ly=We(Id);/**
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 Rd={name:"camera",size:24,node:[["path",{d:"M13.997 4a2 2 0 0 1 1.76 1.05l.486.9A2 2 0 0 0 18.003 7H20a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2h1.997a2 2 0 0 0 1.759-1.048l.489-.904A2 2 0 0 1 10.004 4z",key:"18u6gg"}],["circle",{cx:"12",cy:"13",r:"3",key:"1vg3eu"}]]};Rd.node;const Fy=We(Rd);/**
12
- * @license lucide-react v1.48.0 - ISC
13
- *
14
- * This source code is licensed under the ISC license.
15
- * See the LICENSE file in the root directory of this source tree.
16
- */const Td={name:"chevron-up",size:24,node:[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]]};Td.node;const $y=We(Td);/**
17
- * @license lucide-react v1.48.0 - ISC
18
- *
19
- * This source code is licensed under the ISC license.
20
- * See the LICENSE file in the root directory of this source tree.
21
- */const Dd={name:"circle-plus",size:24,node:[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 12h8",key:"1wcyev"}],["path",{d:"M12 8v8",key:"napkw2"}]],aliases:["plus-circle"]};Dd.node;const By=We(Dd);/**
22
- * @license lucide-react v1.48.0 - ISC
23
- *
24
- * This source code is licensed under the ISC license.
25
- * See the LICENSE file in the root directory of this source tree.
26
- */const Od={name:"coffee",size:24,node:[["path",{d:"M10 2v2",key:"7u0qdc"}],["path",{d:"M14 2v2",key:"6buw04"}],["path",{d:"M16 8a1 1 0 0 1 1 1v8a4 4 0 0 1-4 4H7a4 4 0 0 1-4-4V9a1 1 0 0 1 1-1h14a4 4 0 1 1 0 8h-1",key:"pwadti"}],["path",{d:"M6 2v2",key:"colzsn"}]]};Od.node;const Md=We(Od);/**
27
- * @license lucide-react v1.48.0 - ISC
28
- *
29
- * This source code is licensed under the ISC license.
30
- * See the LICENSE file in the root directory of this source tree.
31
- */const _d={name:"compass",size:24,node:[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m16.24 7.76-1.804 5.411a2 2 0 0 1-1.265 1.265L7.76 16.24l1.804-5.411a2 2 0 0 1 1.265-1.265z",key:"9ktpf1"}]]};_d.node;const zy=We(_d);/**
32
- * @license lucide-react v1.48.0 - ISC
33
- *
34
- * This source code is licensed under the ISC license.
35
- * See the LICENSE file in the root directory of this source tree.
36
- */const Pd={name:"copy-plus",size:24,node:[["line",{x1:"15",x2:"15",y1:"12",y2:"18",key:"1p7wdc"}],["line",{x1:"12",x2:"18",y1:"15",y2:"15",key:"1nscbv"}],["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]};Pd.node;const Uy=We(Pd);/**
37
- * @license lucide-react v1.48.0 - ISC
38
- *
39
- * This source code is licensed under the ISC license.
40
- * See the LICENSE file in the root directory of this source tree.
41
- */const Ld={name:"crosshair",size:24,node:[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"22",x2:"18",y1:"12",y2:"12",key:"l9bcsi"}],["line",{x1:"6",x2:"2",y1:"12",y2:"12",key:"13hhkx"}],["line",{x1:"12",x2:"12",y1:"6",y2:"2",key:"10w3f3"}],["line",{x1:"12",x2:"12",y1:"22",y2:"18",key:"15g9kq"}]]};Ld.node;const js=We(Ld);/**
42
- * @license lucide-react v1.48.0 - ISC
43
- *
44
- * This source code is licensed under the ISC license.
45
- * See the LICENSE file in the root directory of this source tree.
46
- */const Fd={name:"folder-search",size:24,node:[["path",{d:"M10.7 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v4.1",key:"1bw5m7"}],["path",{d:"m21 21-1.9-1.9",key:"1g2n9r"}],["circle",{cx:"17",cy:"17",r:"3",key:"18b49y"}]]};Fd.node;const Ky=We(Fd);/**
47
- * @license lucide-react v1.48.0 - ISC
48
- *
49
- * This source code is licensed under the ISC license.
50
- * See the LICENSE file in the root directory of this source tree.
51
- */const $d={name:"hard-drive",size:24,node:[["path",{d:"M10 16h.01",key:"1bzywj"}],["path",{d:"M2.212 11.577a2 2 0 0 0-.212.896V18a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-5.527a2 2 0 0 0-.212-.896L18.55 5.11A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z",key:"18tbho"}],["path",{d:"M21.946 12.013H2.054",key:"zqlbp7"}],["path",{d:"M6 16h.01",key:"1pmjb7"}]]};$d.node;const Hy=We($d);/**
52
- * @license lucide-react v1.48.0 - ISC
53
- *
54
- * This source code is licensed under the ISC license.
55
- * See the LICENSE file in the root directory of this source tree.
56
- */const Bd={name:"message-square-text",size:24,node:[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}],["path",{d:"M7 11h10",key:"1twpyw"}],["path",{d:"M7 15h6",key:"d9of3u"}],["path",{d:"M7 7h8",key:"af5zfr"}]]};Bd.node;const Wy=We(Bd);/**
57
- * @license lucide-react v1.48.0 - ISC
58
- *
59
- * This source code is licensed under the ISC license.
60
- * See the LICENSE file in the root directory of this source tree.
61
- */const zd={name:"square-arrow-out-up-right",size:24,node:[["path",{d:"M21 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h6",key:"y09zxi"}],["path",{d:"m21 3-9 9",key:"mpx6sq"}],["path",{d:"M15 3h6v6",key:"1q9fwt"}]],aliases:["arrow-up-right-from-square"]};zd.node;const Gy=We(zd);/**
62
- * @license lucide-react v1.48.0 - ISC
63
- *
64
- * This source code is licensed under the ISC license.
65
- * See the LICENSE file in the root directory of this source tree.
66
- */const Ud={name:"venetian-mask",size:24,node:[["path",{d:"M18 11c-1.5 0-2.5.5-3 2",key:"1fod00"}],["path",{d:"M4 6a2 2 0 0 0-2 2v4a5 5 0 0 0 5 5 8 8 0 0 1 5 2 8 8 0 0 1 5-2 5 5 0 0 0 5-5V8a2 2 0 0 0-2-2h-3a8 8 0 0 0-5 2 8 8 0 0 0-5-2z",key:"d70hit"}],["path",{d:"M6 11c1.5 0 2.5.5 3 2",key:"136fht"}]]};Ud.node;const qy=We(Ud);function Yy({children:e,isValidProp:t,...s}){t&&Nm(t);const r=u.useContext(sa);s={...r,...s},s.transition=Am(s.transition,r.transition),s.isStatic=so(()=>s.isStatic);const o=u.useMemo(()=>s,[JSON.stringify(s.transition),s.transformPagePoint,s.reducedMotion,s.skipAnimations]);return n.jsx(sa.Provider,{value:o,children:e})}function Vy(e){e.values.forEach(t=>t.stop())}function Lr(e,t){[...t].reverse().forEach(r=>{const o=e.getVariant(r);o&&hc(e,o),e.variantChildren&&e.variantChildren.forEach(a=>{Lr(a,t)})})}function Qy(e,t){if(Array.isArray(t))return Lr(e,t);if(typeof t=="string")return Lr(e,[t]);hc(e,t)}function Xy(){const e=new Set,t={subscribe(s){return e.add(s),()=>void e.delete(s)},start(s,r){const o=[];return e.forEach(a=>{o.push(Em(a,s,{transitionOverride:r}))}),Promise.all(o)},set(s){return e.forEach(r=>{Qy(r,s)})},stop(){e.forEach(s=>{Vy(s)})},mount(){return()=>{t.stop()}}};return t}function Jy(){const e=so(Xy);return Im(e.mount,[]),e}class Zy{constructor(){this.componentControls=new Set}subscribe(t){return this.componentControls.add(t),()=>this.componentControls.delete(t)}start(t,s){this.componentControls.forEach(r=>{r.start(t.nativeEvent||t,s)})}cancel(){this.componentControls.forEach(t=>{t.cancel()})}stop(){this.componentControls.forEach(t=>{t.stop()})}}const ev=()=>new Zy;function tv(){return so(ev)}const nv=`${ro.repo}/issues/new`,sv={"tunnel.enabled":"boolean","tasks.enabled":"boolean","relay.enabled":"boolean","scheduler.enabled":"boolean","mesh.enabled":"boolean","mcp.enabled":"boolean","telemetry.install":"boolean","telemetry.heartbeat":"boolean","telemetry.errorReporting":"boolean","auth.enabled":"boolean","workspace.enabled":"boolean","harness.autoSync":"boolean","harness.autoAdopt":"boolean","runtimes.codex.enabled":"boolean","runtimes.opencode.enabled":"boolean","runtimes.default":"enum","logging.level":"enum","ui.theme":"enum"},rv={"runtimes.default":["claude-code","codex","opencode","doe"],"logging.level":["fatal","error","warn","info","debug","trace"],"ui.theme":["light","dark","system"]},ov=/^[a-z0-9][a-z0-9._-]{0,31}$/,av={bug:["bug"],feature:["enhancement"],runtime:["bug"]},iv={bug:"Bug: (describe what went wrong)",feature:"Feature: (describe what you want)",runtime:"Runtime issue: (describe what went wrong)"};function cv(e){return e.replace(/\b(?:sk-|pk-|rk-|ghp_|gho_|ghu_|ghs_|github_pat_|glpat-|npm_|xox[baprsc]-)[A-Za-z0-9._-]+/g,"[redacted]").replace(/\b(?:AKIA|ASIA|AGPA|AIDA|AROA|ANPA)[0-9A-Z]{16}\b/g,"[redacted]").replace(/\bBearer\s+[A-Za-z0-9._-]+/gi,"[redacted]")}function Fo(e){return cv(e).replace(/[^\s/@]+@[^\s/@]+\.[^\s/@]+/g,"[email]").replace(/\b\d{1,3}(?:\.\d{1,3}){3}\b/g,"[ip]").replace(/\b(?:[A-Fa-f0-9]{1,4}:){2,7}[A-Fa-f0-9]{1,4}\b/g,"[ip]").replace(new RegExp("(?<![\\w:.])(?:[A-Fa-f0-9]{1,4})?(?::[A-Fa-f0-9]{0,4}){2,}(?![\\w:.])","g"),"[ip]").replace(/\\\\[^\s\\]+(?:\\[^\s\\]+)+/g,"[path]").replace(/(^|[\s"'`(<[{])\/\/[^\s"'`)>\]}/]+\/[^\s"'`)>\]}]+/g,"$1[path]").replace(/\b[A-Za-z]:\\[^\r\n]*/g,"[path]").replace(/(^|[\s"'`(<[{/:])(~|\/(?:Users|home))\/[^\s"'`)>\]}]+/g,"$1[home]").replace(/(^|[\s"'`(<[{])\/[\w.-]+(?:\/[\w.-]*)+/g,"$1[path]").replace(/\b(?=[A-Za-z0-9_-]*\d)[A-Za-z0-9_-]{24,}\b/g,"[redacted]")}function lv(e,t){const s=rv[e];return s?s.includes(t):ov.test(t)&&Fo(t)===t}function dv(e){const t={};for(const[s,r]of Object.entries(sv)){const o=e[s];o!=null&&(r==="boolean"&&typeof o=="boolean"||r==="number"&&typeof o=="number"&&Number.isFinite(o)||r==="enum"&&typeof o=="string"&&lv(s,o))&&(t[s]=o)}return t}const uv=["details","summary"];function $o(e){return Rb(Fo(e),uv)}function mv(e){const t=e.runtimes.length>0?e.runtimes.join(", "):"none configured",s=Object.entries(e.flags).map(([o,a])=>`- ${o}: ${String(a)}`).join(`
67
- `),r=[`- DorkOS version: ${e.version}`,`- OS / arch: ${e.platform}`,`- Runtimes configured: ${t}`,`- Reported from: ${e.surface}`,"","Settings (on/off values only, no secrets or file paths):",s.length>0?s:"- (none available)"];return Fo(r.join(`
68
- `))}function hv(e){var s;const t=(s=e.body)==null?void 0:s.trim();return t?[$o(t)]:e.kind==="feature"?["## What do you want DorkOS to do?","","","## Why would it help?","",""]:["## What happened?","","","## What did you expect?","","","## Steps to reproduce","","1. ","2. ","3. "]}function fv(e){return["<details><summary>Environment</summary>","",mv(e),"","</details>","","DorkOS filled in the details above. Please check them and remove anything you do not want to share.","","---","",...hv(e)].join(`
69
- `)}function rr(e){var r;const t=(r=e.title)==null?void 0:r.trim(),s=new URLSearchParams({title:$o(t||iv[e.kind]),body:fv(e),labels:av[e.kind].join(",")});return`${nv}?${s.toString()}`}const pv=6e3,Fa=`
70
-
71
- … (shortened to fit the link; paste the rest yourself)`;function $a(e){return new TextEncoder().encode(e).length}function Ba(e,t){return Array.from(e).slice(0,t).join("")}function gv(e,t=pv){var d;const s=rr(e);if($a(s)<=t)return{url:s,truncated:!1};const r=((d=e.body)==null?void 0:d.trim())??"";if(!r)return{url:s,truncated:!1};const o=Array.from(r).length;let a=0,i=o;for(;a<i;){const l=Math.ceil((a+i)/2),m={...e,body:Ba(r,l)+Fa};$a(rr(m))<=t?a=l:i=l-1}const c={...e,body:Ba(r,a)+Fa};return{url:rr(c),truncated:!0,fullBody:$o(r)}}function xv(e){return gv(e).url}function bv(e){var t,s,r,o,a,i,c,d,l,m;return{"tunnel.enabled":(t=e.tunnel)==null?void 0:t.enabled,"tasks.enabled":(s=e.tasks)==null?void 0:s.enabled,"relay.enabled":(r=e.relay)==null?void 0:r.enabled,"mesh.enabled":(o=e.mesh)==null?void 0:o.enabled,"mcp.enabled":(a=e.mcp)==null?void 0:a.enabled,"telemetry.install":(i=e.telemetry)==null?void 0:i.install,"telemetry.heartbeat":(c=e.telemetry)==null?void 0:c.heartbeat,"telemetry.errorReporting":(d=e.telemetry)==null?void 0:d.errorReporting,"auth.enabled":(l=e.auth)==null?void 0:l.enabled,"logging.level":(m=e.logging)==null?void 0:m.level}}function Kd(e,t,s){return{kind:e,version:(t==null?void 0:t.version)??"unknown",platform:(t==null?void 0:t.platform)??"unknown",runtimes:(t==null?void 0:t.runtimes)??[],surface:`web ${s}`.trim(),flags:t?dv(bv(t)):{}}}function yv(){const e=ie(),{data:t}=Ee({queryKey:Fe.current(),queryFn:()=>e.getConfig(),staleTime:300*1e3}),s=De({select:r=>r.location.pathname});return u.useCallback(r=>{const o=xv(Kd(r,t,s));Dn(o)},[t,s])}const vv=100;function wv({cwd:e,isStreaming:t,color:s}){const r=u.useRef(""),o=u.useRef([]),a=u.useRef(null),i=u.useRef(0),c=u.useRef(t);u.useEffect(()=>{c.current=t},[t]);const d=u.useCallback(()=>{a.current&&(clearInterval(a.current),a.current=null),o.current.length!==0&&(i.current=0,a.current=window.setInterval(()=>{const m=o.current;m.length!==0&&(Xs(m[i.current]),i.current=(i.current+1)%m.length)},vv))},[]),l=u.useCallback(()=>{a.current&&(clearInterval(a.current),a.current=null),r.current&&Xs(r.current)},[]);u.useEffect(()=>{if(!e)return;const m=s??ms(e),h=Rm(m);r.current=h,o.current=[],Xs(h);let p=!1;return Tm(h).then(f=>{p||(o.current=f,c.current&&d())}).catch(()=>{}),()=>{p=!0}},[e,s,d]),u.useEffect(()=>(t?d():l(),l),[t,d,l])}function jv(e,t){const[s,r]=u.useState(()=>document.hidden),[o,a]=u.useState(!1);u.useEffect(()=>{const d=()=>{r(document.hidden),document.hidden||a(!1)};return document.addEventListener("visibilitychange",d),()=>document.removeEventListener("visibilitychange",d)},[]);const i=u.useRef(t);u.useEffect(()=>{i.current&&!t&&document.hidden&&a(!0),i.current=t},[t]);const c=e({hidden:s,unseenReply:o});u.useEffect(()=>{document.title=c},[c])}function kv(){const e=le();fe("notification",t=>{(t==null?void 0:t.kind)==="signin.required"&&e.invalidateQueries({queryKey:ra.all})}),fe("account_usage",t=>{const s=t;!s||typeof s.runtime!="string"||e.getQueryData(ra.usage(s.runtime))!==void 0&&Dm(e,s.runtime,[s])})}function Sv(e,t,s,r){let o;switch(e){case"ArrowRight":o=t+1;break;case"ArrowLeft":o=t-1;break;case"ArrowDown":o=t+s;break;case"ArrowUp":o=t-s;break;case"Home":o=0;break;case"End":o=r-1;break;default:return null}return Math.max(0,Math.min(r-1,o))}function Cv(e){const[t,s]=u.useState(0),r=u.useRef([]);function o(){const l=r.current.slice(0,e).filter(Boolean);if(l.length===0)return 1;const m=l[0].offsetTop;return Math.max(1,l.filter(h=>h.offsetTop===m).length)}function a(l){var h;const m=Math.max(0,Math.min(e-1,l));s(m),(h=r.current[m])==null||h.focus()}function i(l){return m=>{r.current[l]=m}}function c(l){return t===l?0:-1}function d(l,m){const h=Sv(l.key,m,o(),e);h!==null&&(l.preventDefault(),a(h))}return{focusIndex:t,setRef:i,tabIndexFor:c,handleKeyDown:d,moveFocus:a}}function Hd(){const[e,t]=u.useState(za);return u.useEffect(()=>{const s=window.visualViewport,r=()=>{const o=za();t(a=>a.top===o.top&&a.height===o.height?a:o)};return window.addEventListener("resize",r),s==null||s.addEventListener("resize",r),s==null||s.addEventListener("scroll",r),()=>{window.removeEventListener("resize",r),s==null||s.removeEventListener("resize",r),s==null||s.removeEventListener("scroll",r)}},[]),e}function za(){if(typeof window>"u")return{top:0,height:0};const e=window.visualViewport;return e&&e.scale<=1?{top:Math.max(0,e.offsetTop),height:e.height}:{top:0,height:window.innerHeight}}const Ua=16,Nv=280,Av=180;function Ka(e,t,s){const r=Math.max(t,window.innerWidth-Ua),o=Math.max(s,window.innerHeight-Ua),a=Math.min(Math.max(e.width,t),r),i=Math.min(Math.max(e.height,s),o),c=Math.min(Math.max(e.x,0),Math.max(0,window.innerWidth-a)),d=Math.min(Math.max(e.y,0),Math.max(0,window.innerHeight-i));return{x:c,y:d,width:a,height:i}}function Ev(e,t){return e.x!==t.x||e.y!==t.y||e.width!==t.width||e.height!==t.height}function Iv(e){const{title:t,geometry:s,onGeometryChange:r,onClose:o,onRestore:a,minWidth:i,minHeight:c,children:d,className:l}=e,m=u.useRef(null),h=i??Nv,p=c??Av;u.useEffect(()=>{const b=()=>{const C=Ka(s,h,p);Ev(C,s)&&r(C)};return b(),window.addEventListener("resize",b),()=>window.removeEventListener("resize",b)},[s,h,p,r]);const f=u.useRef(null);u.useEffect(()=>()=>{var b;return(b=f.current)==null?void 0:b.call(f)},[]);const g=u.useCallback((b,C)=>{var N;b.preventDefault();const k=m.current;if(!k)return;const I=k;(N=f.current)==null||N.call(f);const v=b.clientX,E=b.clientY,R=s;let _=R,D=0;function P(){D=0,I.style.left=`${_.x}px`,I.style.top=`${_.y}px`,I.style.width=`${_.width}px`,I.style.height=`${_.height}px`}function T(S){_=C(S.clientX-v,S.clientY-E,R),D||(D=requestAnimationFrame(P))}function j(){D&&cancelAnimationFrame(D),D=0,document.removeEventListener("pointermove",T),document.removeEventListener("pointerup",w),document.removeEventListener("pointercancel",w),f.current=null}function w(){j(),r(Ka(_,h,p))}document.addEventListener("pointermove",T),document.addEventListener("pointerup",w),document.addEventListener("pointercancel",w),f.current=j},[s,h,p,r]),x=u.useCallback(b=>{b.target.closest("button")||g(b,(C,k,I)=>({...I,x:I.x+C,y:I.y+k}))},[g]),y=u.useCallback(b=>{b.stopPropagation(),g(b,(C,k,I)=>({...I,width:Math.max(h,I.width+C),height:Math.max(p,I.height+k)}))},[g,h,p]);return Es.createPortal(n.jsxs(re.div,{ref:m,"data-slot":"floating-panel",role:"complementary","aria-label":t,initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.95},transition:{duration:.15,ease:[0,0,.2,1]},style:{left:s.x,top:s.y,width:s.width,height:s.height},className:K("bg-card border-border shadow-floating fixed z-40 flex flex-col overflow-hidden rounded-lg border",l),children:[n.jsxs("div",{onPointerDown:x,className:"border-border flex cursor-grab items-center gap-1 border-b px-3 py-2 select-none active:cursor-grabbing",children:[n.jsx("span",{className:"min-w-0 flex-1 truncate text-sm font-medium",children:t}),a?n.jsx(F,{variant:"ghost",size:"icon-sm","aria-label":"Restore",onClick:a,className:"text-muted-foreground hover:text-foreground",children:n.jsx(oy,{})}):null,n.jsx(F,{variant:"ghost",size:"icon-sm","aria-label":"Close",onClick:o,className:"text-muted-foreground hover:text-foreground",children:n.jsx(Be,{})})]}),n.jsx("div",{className:"min-h-0 flex-1 overflow-auto",children:d}),n.jsx("div",{"aria-hidden":!0,onPointerDown:y,className:"absolute right-0 bottom-0 size-4 cursor-nwse-resize"})]}),document.body)}function Rv({...e}){const{theme:t}=fc();return n.jsx(Om,{theme:t,className:"toaster group",icons:{success:n.jsx(Is,{className:"size-4"}),info:n.jsx(gc,{className:"size-4"}),warning:n.jsx(pc,{className:"size-4"}),error:n.jsx(Ab,{className:"size-4"}),loading:n.jsx(Oe,{})},style:{"--normal-bg":"var(--color-popover)","--normal-text":"var(--color-popover-foreground)","--normal-border":"var(--color-border)","--border-radius":"var(--radius)"},...e})}async function Tv(){var t;if(!$e())return;const e=(t=window.electronAPI)==null?void 0:t.getShellLogExcerpt;if(typeof e=="function")try{const s=await e();return s&&s.length>0?s:void 0}catch{return}}const Wd="root";function Gd(){return document.getElementById(Wd)??document.body}const Ha=2e4;class it extends Error{constructor(s,r){super(r);wn(this,"reason");this.name="AppCaptureError",this.reason=s}}function Dv(){const e=typeof window<"u"?window.electronAPI:void 0;if(typeof(e==null?void 0:e.captureAppView)!="function")return null;const{captureAppView:t}=e;return()=>t()}function Ov(){return new Promise(e=>{requestAnimationFrame(()=>requestAnimationFrame(()=>e()))})}function Mv(){const e=[];for(const t of Array.from(document.body.children)){if(!(t instanceof HTMLElement)||t.id===Wd)continue;const s=t.style.opacity;t.style.opacity="0",e.push(()=>{t.style.opacity=s})}return()=>{for(const t of e)t()}}async function _v(e){const t=await e().catch(s=>{throw new it("failed",`The desktop bridge threw: ${String(s)}`)});if(!t.ok)throw new it("failed",t.message);return{dataUrl:t.dataUrl,region:{left:0,top:0,width:window.innerWidth,height:window.innerHeight}}}async function Pv(){let e;try{({snapdom:e}=await Mm(()=>import("./snapdom-SRLjr6oU.js"),[]))}catch(r){const o=r instanceof Error?r.message:String(r);throw new it("unsupported",`Loading the screenshot library failed: ${o}`)}const t=Gd(),s=getComputedStyle(document.body).backgroundColor;try{const r=t.getBoundingClientRect();return{dataUrl:(await e.toPng(t,{backgroundColor:s})).src,region:{left:r.left,top:r.top,width:r.width,height:r.height}}}catch(r){const o=r instanceof Error?r.message:String(r);throw new it("failed",`Rendering the app to an image failed: ${o}`)}}async function Lv(e){let t;const s=new Promise((r,o)=>{t=setTimeout(()=>{o(new it("failed",`The capture did not finish in ${Ha}ms.`))},Ha)});try{return await Promise.race([e,s])}finally{clearTimeout(t),e.catch(()=>{})}}async function Fv(){const e=Dv(),t=Mv();try{return await Ov(),await Lv(e?_v(e):Pv())}finally{t()}}let kn=null;function qd(){if(kn)return kn;const e=Fv();kn=e;const t=()=>{kn===e&&(kn=null)};return e.then(t,t),e}function $v(){return qd().then(e=>e.dataUrl)}function Bv(){if(typeof window>"u")return;const{innerWidth:e,innerHeight:t,devicePixelRatio:s}=window;if(!(typeof e!="number"||typeof t!="number"))return{width:Math.round(e),height:Math.round(t),devicePixelRatio:typeof s=="number"?s:1}}function zv(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone||void 0}catch{return}}function Uv(e){const t=Bv(),s=typeof navigator<"u"?navigator.userAgent:void 0,r=typeof navigator<"u"?navigator.language:void 0,o=zv();return{theme:e,shell:$e()?"desktop-app":"browser",...t?{viewport:t}:{},...s?{browser:s.slice(0,_m)}:{},...r?{locale:r.slice(0,oa)}:{},...o?{timezone:o.slice(0,oa)}:{}}}function Vs(e){return t=>()=>{e(),t()}}const Kv=2e3,Hv=.8,Wv=1400,Gv=.6,cs=6e5,ks=1e4,qv=["image/webp","image/jpeg","image/png"],Yv=/^data:image\/(webp|png|jpeg);base64,/;class Yt extends Error{constructor(s,r){super(r);wn(this,"reason");this.name="ImageCompressError",this.reason=s}}function Vv(e){return Yv.test(e)&&e.length<=cs}function Qv(e){return new Promise((t,s)=>{const r=new Image,o=setTimeout(()=>{s(new Yt("unreadable",`Decoding timed out after ${ks}ms.`))},ks);r.onload=()=>{clearTimeout(o),t(r)},r.onerror=()=>{clearTimeout(o),s(new Yt("unreadable",`Could not decode the image at ${e.slice(0,32)}…`))},r.src=e})}function Xv(e,t){for(const s of qv){const r=e.toDataURL(s,t);if(r.startsWith(`data:${s};base64,`))return r}throw new Yt("unsupported","This canvas produced no usable image encoding.")}function Wa(e,t,s=Kv){const r=Math.min(1,s/Math.max(e,t));return{width:Math.max(1,Math.round(e*r)),height:Math.max(1,Math.round(t*r))}}function Ga(e,t,s){const r=document.createElement("canvas");r.width=t.width,r.height=t.height;const o=r.getContext("2d");if(!o)throw new Yt("unsupported","This browser gave no 2d canvas context.");return o.drawImage(e,0,0,t.width,t.height),Xv(r,s)}async function Fr(e){const t=typeof e=="string"?null:URL.createObjectURL(e);let s;try{s=await Qv(t??e)}finally{t&&URL.revokeObjectURL(t)}const r=s.naturalWidth||s.width,o=s.naturalHeight||s.height;if(r<=0||o<=0)throw new Yt("unreadable","The image decoded to zero pixels.");let a=Ga(s,Wa(r,o),Hv);if(a.length>cs&&(a=Ga(s,Wa(r,o,Wv),Gv)),a.length>cs)throw new Yt("too-large",`Compressed to ${a.length} characters, over the ${cs} cap.`);return a}const Jv=500;function Zv(e=Jv){const t=le(),s=Pm({coalesceMs:e,shouldFlush:()=>t.isMutating({mutationKey:xc})===0});fe("config_changed",()=>{const r={queryKey:Fe.current()};s([r])})}const Yd="dorkbot",ew=["mesh","agent-paths"];function tw(e){var r,o;const t=(r=e==null?void 0:e.agents)==null?void 0:r.defaultDirectory;if(!t)return"";const s=((o=e==null?void 0:e.agents)==null?void 0:o.defaultAgent)||Yd;return`${t}/${s}`}function nw(){var d;const e=Pe(),t=ie(),{data:s}=Me(),{data:r}=Ee({queryKey:[...ew],queryFn:()=>t.listMeshAgentPaths(),staleTime:3e4}),o=((d=s==null?void 0:s.agents)==null?void 0:d.defaultAgent)||Yd,a=r==null?void 0:r.agents.find(l=>l.name===o),i=(a==null?void 0:a.projectPath)??tw(s);return{startSession:u.useCallback(()=>{a?e(Rt({agentId:a.id})):i&&Lm(t,i).then(l=>e(l)).catch(l=>{bc(t,l),ce.error("Couldn’t open the chat. Try again.")})},[e,i,a,t]),defaultAgentDir:i}}function sw(e){return{pinned:e.pinned??[],groups:e.groups??[],muted:e.muted??[],sections:e.sections??{}}}function rw(){const e=le(),t=Bn();fe("community_connections_changed",()=>{t&&e.invalidateQueries({queryKey:At.connections(t),exact:!0})})}function Vd(e){const t=ie(),s=e!==null&&e.status!=="pending",r=Bn(s),o=(e==null?void 0:e.ref)??"";return Ee({queryKey:r?At.disconnectImpact(r,o):[...At.all,"owner","unresolved",o,"disconnect-impact"],queryFn:()=>yc(r,()=>t.getCommunityDisconnectImpact(o)),enabled:s&&r!==null,staleTime:0,refetchOnMount:"always"})}function Qd(e){const t=e.flatMap(r=>r.displayName?[r.displayName]:[]),s=e.length-t.length;return s>0&&t.push(s===1?"an unnamed agent":`${s} unnamed agents`),t.length<=1?t[0]??"":`${t.slice(0,-1).join(", ")} and ${t[t.length-1]}`}function Xd(e,t){return t.length===0?null:t.length===1?t[0].displayName?`The agent you added from here, ${t[0].displayName}, will be removed from ${e}.`:`The agent you added from here will be removed from ${e}.`:`The ${t.length} agents you added from here will be removed from ${e}: ${Qd(t)}.`}function Jd(e){return`Any agents you added from here will be removed from ${e}.`}function Zd(e,{remoteRevoked:t,agentsNotRemoved:s}){const r=Qd(s);return s.length===0?t?{tone:"success",message:`${e} is disconnected.`}:{tone:"warning",message:ow(e)}:t?{tone:"warning",message:`Disconnected, but ${r} couldn’t be removed. Remove ${s.length===1?"it":"them"} under Agents on ${e}.`}:{tone:"warning",message:`Disconnected here, but ${e} couldn’t be reached. Remove ${r} and this DorkOS there.`}}function ow(e){return`Disconnected here, but ${e} couldn’t be reached. Finish under Connected installations on ${e}.`}function aw(){const e=ie(),t=L(o=>o.selectedCwd),s=L(o=>o.setSelectedCwd),{data:r}=Ee({queryKey:["defaultCwd"],queryFn:()=>e.getDefaultCwd(),enabled:t===null,staleTime:1/0,refetchOnMount:!1,refetchOnReconnect:!1,networkMode:"always"});u.useEffect(()=>{r!=null&&r.path&&L.getState().selectedCwd===null&&s(r.path)},[r,t,s])}function qa(e){e.invalidateQueries({queryKey:un.recentRoot})}const iw=5e3;function cw(e,t=iw){let s=-1/0,r=null;const o=()=>{r=null,s=Date.now(),e()};return{request(){if(r!==null)return;const a=s+t-Date.now();a<=0?o():r=setTimeout(o,a)},dispose(){r!==null&&clearTimeout(r),r=null}}}function Ya(e){e.invalidateQueries({queryKey:un.dailyCountsRoot})}function lw(e,t){const s=Object.keys(e);return s.length!==Object.keys(t).length?!0:s.some(r=>!(r in t))}function dw(e,t){e.setQueryData(un.list(t.cwd??null),s=>{const r=s??[];return(r.some(a=>a.id===t.id)?r.map(a=>a.id===t.id?t:a):[t,...r]).sort((a,i)=>i.updatedAt.localeCompare(a.updatedAt))})}function uw(e,t,s){e.setQueryData(un.list(s),r=>r&&r.filter(o=>o.id!==t))}function Va(e,t,s){const r=new Set(Object.keys(t).filter(o=>!(o in s)));r.size!==0&&e.setQueriesData({queryKey:un.listRoot},o=>o!=null&&o.some(a=>r.has(a.id))?o.flatMap(a=>{if(!r.has(a.id))return[a];const i=t[a.id];return o.some(d=>d.id===i)?[]:[{...a,id:i}]}):o)}function Qa(e,t,s){const r=Date.now(),o=[];for(const[a,i]of Object.entries(t))s[a]!==i&&(dw(e,i),o.push(i));$m(e,o,r);for(const[a,i]of Object.entries(s))t[a]||uw(e,a,i.cwd??null)}function mw(){const e=le();u.useEffect(()=>{Fm();let t={},s={};const r=cw(()=>qa(e)),o=rt.subscribe(c=>{c.sessions!==t&&(Qa(e,c.sessions,t),r.request(),lw(c.sessions,t)&&Ya(e),t=c.sessions),c.rekeys!==s&&(Va(e,c.rekeys,s),s=c.rekeys)}),a=hs.subscribeEvent("session_list_invalidated",()=>{rt.getState().dropSessions(),e.invalidateQueries({queryKey:un.listRoot}),qa(e),Ya(e)}),i=rt.getState();return Object.keys(i.sessions).length>0&&(Qa(e,i.sessions,t),t=i.sessions),Object.keys(i.rekeys).length>0&&(Va(e,i.rekeys,s),s=i.rekeys),hs.connectList(),()=>{o(),a(),r.dispose()}},[e])}function en(){const e=ie(),t=le(),{data:s,isLoading:r}=Ee({queryKey:Fe.current(),queryFn:()=>e.getConfig(),staleTime:vc}),o=pd(r),a={completedSteps:[],skippedSteps:[],startedAt:null,dismissedAt:null,completedAt:null,runtimeDefaultSetAt:null,firstRunPath:null,welcomeEntryId:null,priorRuntime:null},i=s!=null&&s.onboarding?{completedSteps:s.onboarding.completedSteps,skippedSteps:s.onboarding.skippedSteps,startedAt:s.onboarding.startedAt,dismissedAt:s.onboarding.dismissedAt,completedAt:s.onboarding.completedAt??null,runtimeDefaultSetAt:s.onboarding.runtimeDefaultSetAt,firstRunPath:s.onboarding.firstRunPath??null,welcomeEntryId:s.onboarding.welcomeEntryId??null,priorRuntime:s.onboarding.priorRuntime??null}:a,c=i.completedAt!==null,d=i.dismissedAt!==null,m=!o&&s!==void 0&&!c&&!d,h=!o&&c&&!d,p=Qt({mutationFn:y=>e.updateConfig({onboarding:y}),onSuccess:()=>{t.invalidateQueries({queryKey:Fe.all})},onError:(y,b)=>{console.error("[onboarding] could not save progress",{fields:Object.keys(b),error:y}),ce.error("Couldn’t save your setup progress",{description:"Keep going. DorkOS tries again."})},meta:{suppressErrorToast:!0}});function f(){return p.mutateAsync({dismissedAt:new Date().toISOString()})}function g(){i.completedAt||p.mutate({completedAt:new Date().toISOString()})}function x(){i.startedAt||p.mutate({startedAt:new Date().toISOString()})}return{state:i,config:s,isLoading:o,isOnboardingComplete:c,isOnboardingDismissed:d,shouldShowOnboarding:m,shouldShowGettingStarted:h,dismiss:f,completeOnboarding:g,startOnboarding:x}}function hw(e){const{shouldShowOnboarding:t,onboardingHiddenForSession:s}=e,r=t&&!s,[o,a]=u.useState(!1);return r&&!o&&a(!0),o&&!s}function fw(){const e=oo(),t=Xt(),s=ao({strict:!1}).onboarding,r=aa(s)?s:"welcome",o=u.useRef(!1),a=De({select:l=>l.status==="idle"}),i=u.useRef(!1);u.useEffect(()=>{if(i.current||!a||(i.current=!0,aa(s)))return;const l=m=>({...m,onboarding:"welcome"});e==null||e({search:l,replace:!0})},[a,s,e]);const c=u.useCallback(l=>{const m=h=>({...h,onboarding:l});o.current=!0,e==null||e({search:m})},[e]),d=u.useCallback(l=>{if(o.current){t.history.back();return}const m=h=>({...h,onboarding:l});e==null||e({search:m})},[t,e]);return{stage:r,goToStage:c,goBack:d}}function pw(e){const{done:t,overlayVisible:s}=e,r=oo(),o=ao({strict:!1}).onboarding;u.useEffect(()=>{if(!o||!t||s)return;const a=i=>({...i,onboarding:void 0});r==null||r({search:a,replace:!0})},[o,t,s,r])}function eu(e){try{if(e.verificationUriComplete){const s=new URL(e.verificationUriComplete);if(s.protocol==="https:"||s.protocol==="http:")return s.href}const t=new URL(e.verificationUri);return t.protocol!=="https:"&&t.protocol!=="http:"?null:(t.searchParams.set("code",e.userCode),t.href)}catch{return null}}const gw=2500,xw="Couldn’t finish setup. Try again.";function Ln(e){return e instanceof Error&&e.message&&!/^HTTP \d+$/.test(e.message)?e.message:xw}function Bo(){const e=ie(),t=le();return Qt({mutationFn:s=>e.chooseFirstRunPath(s),onSettled:()=>{for(const s of[Fe.all,Bm,wc.status()])t.invalidateQueries({queryKey:s});t.invalidateQueries({queryKey:zm})},meta:{suppressErrorToast:!0}})}function bw(e){const t=ie(),{data:s}=Ee({queryKey:wc.status(),queryFn:()=>t.getCloudCredits(),enabled:e,refetchInterval:e?gw:!1,refetchIntervalInBackground:e,staleTime:0});if(s)return s.readiness??(s.linked?"linked":"unlinked")}function yw(){const e=ie(),t=le();return Qt({mutationFn:()=>e.postOnboardingWelcome(),onSettled:()=>void t.invalidateQueries({queryKey:Fe.all}),meta:{suppressErrorToast:!0}})}function vw({link:e,waitingWindowRef:t,onReady:s}){const r=Bo(),[o,a]=u.useState(null),[i,c]=u.useState(!1),d=bw(i),l=i?d:void 0,m=u.useRef(e),h=u.useRef(r.mutateAsync),p=u.useRef(s);u.useEffect(()=>{m.current=e,h.current=r.mutateAsync,p.current=s});const f=u.useCallback(()=>{var k;(k=t.current)==null||k.close(),t.current=null},[t]),g=u.useCallback(async()=>{a(null);try{await h.current({path:"dorkos"})}catch(v){f(),a(Ln(v));return}c(!0);const k=m.current;if(k.state==="linked"){f();return}if(k.state==="pending")return;await k.start()===null&&(f(),a(m.current.startError??"Couldn’t reach DorkOS. Try again."))},[f]),x=u.useRef(!1);u.useEffect(()=>{x.current||e.state==="loading"||(x.current=!0,g())},[e.state,g]);const y=e.state==="pending"?e.pending:null;u.useEffect(()=>{if(!y||!t.current)return;const k=eu(y);k?t.current.go(k):t.current.close(),t.current=null},[y,t]);const b=u.useRef(!1);u.useEffect(()=>{l!=="ready"||b.current||(b.current=!0,p.current())},[l]);const C=u.useCallback(()=>{var k;if((k=t.current)==null||k.close(),t.current=io(),m.current.state==="expired"||m.current.state==="denied"){a(null),m.current.start();return}g()},[g,t]);return{phase:ww(o,i,e,y,l),retry:C}}function ww(e,t,s,r,o){return e!==null?{kind:"failed",message:e}:o==="refused"?{kind:"refused"}:o==="needs-card"?{kind:"needs-card"}:s.state==="expired"||s.state==="denied"?{kind:"expired"}:s.state==="linked"&&t?{kind:"finishing"}:r?{kind:"waiting",pending:r}:{kind:"starting"}}function zo(){const e=u.useRef(null);return u.useEffect(()=>{var t;(t=e.current)==null||t.focus({preventScroll:!0})},[]),e}function tu({phase:e,link:t,onRetry:s,onCancel:r,onUseOwnAi:o}){const a=zo();return n.jsxs("div",{ref:a,tabIndex:-1,className:"mx-auto flex w-full max-w-sm flex-col items-center px-4 text-center outline-none",role:"region","aria-labelledby":"onboarding-connecting-heading","data-testid":"onboarding-connecting","data-phase":e.kind,children:[n.jsx(Tt,{size:72,className:"mb-6 opacity-90 dark:hidden"}),n.jsx(Tt,{variant:"white",size:72,className:"mb-6 hidden opacity-90 dark:block"}),n.jsx(jw,{phase:e,link:t,onRetry:s,onUseOwnAi:o}),n.jsx(F,{variant:"ghost",size:"sm",className:"text-muted-foreground mt-8",onClick:r,children:"Cancel"})]})}function jw({phase:e,link:t,onRetry:s,onUseOwnAi:r}){switch(e.kind){case"starting":return n.jsx(Xa,{heading:"Finish in your browser.",line:"Opening the DorkOS page…"});case"waiting":return n.jsxs(n.Fragment,{children:[n.jsx(nn,{children:"Finish in your browser."}),n.jsx(Zn,{children:"Sign in, then come back. This screen moves on by itself."}),n.jsx(kw,{pending:e.pending})]});case"finishing":return n.jsx(Xa,{heading:"Signed in.",line:"Getting your account ready…"});case"needs-card":return n.jsxs(n.Fragment,{children:[n.jsx(nn,{children:"Add a card to finish."}),n.jsx(Zn,{children:"Your agents start once a card is saved."}),n.jsxs(F,{className:"mt-6",onClick:()=>t==null?void 0:t.openBilling(),disabled:!t||t.billingPending,children:[(t==null?void 0:t.billingPending)&&n.jsx(Oe,{size:"xs"}),"Add a card"]}),(t==null?void 0:t.billingNotice)&&n.jsx($r,{children:t.billingNotice})]});case"refused":return n.jsxs(n.Fragment,{children:[n.jsx(nn,{children:"Paid plans are US only."}),n.jsx(Zn,{children:"Use your own AI instead."}),n.jsx(F,{className:"mt-6",onClick:r,children:"Use my own AI"})]});case"expired":return n.jsxs(n.Fragment,{children:[n.jsx(nn,{children:"Your code expired."}),n.jsx(Zn,{children:"Get a new one to finish signing in."}),n.jsx(F,{className:"mt-6",onClick:s,children:"Get a new code"})]});case"failed":return n.jsxs(n.Fragment,{children:[n.jsx(nn,{children:"Couldn’t start signing in."}),n.jsx($r,{children:e.message}),n.jsx(F,{className:"mt-6",onClick:s,children:"Try again"})]})}}function Xa({heading:e,line:t}){return n.jsxs(n.Fragment,{children:[n.jsx(nn,{children:e}),n.jsxs("p",{className:"text-muted-foreground mt-3 flex items-center gap-2 text-sm",role:"status",children:[n.jsx(Oe,{size:"xs"}),t]})]})}function nn({children:e}){return n.jsx("h1",{id:"onboarding-connecting-heading",className:"text-2xl font-semibold tracking-tight text-balance",children:e})}function Zn({children:e}){return n.jsx("p",{className:"text-muted-foreground mt-3 text-sm text-balance",children:e})}function $r({children:e}){return n.jsx("p",{className:"text-destructive mt-3 text-sm text-balance",role:"alert",children:e})}function kw({pending:e}){const{copied:t,failed:s,copy:r}=zn(),[o,a]=u.useState(!1),i=eu(e);return n.jsxs("div",{className:"mt-8 w-full space-y-4","data-testid":"onboarding-link-code",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("code",{className:"bg-muted min-w-0 flex-1 rounded-md px-3 py-3 text-center font-mono text-lg font-semibold tracking-[0.15em] whitespace-nowrap tabular-nums sm:text-xl",children:e.userCode}),n.jsx(F,{variant:"ghost",size:"icon-md",onClick:()=>void r(e.userCode),"aria-label":s?"Couldn’t copy code. Try again":"Copy code",children:t?n.jsx(Jt,{className:"text-status-success size-4"}):s?n.jsx(Be,{className:"text-destructive size-4"}):n.jsx(co,{className:"size-4"})})]}),n.jsxs(F,{variant:"outline",className:"w-full",disabled:i===null,onClick:()=>a(i===null||!Dn(i)),children:[n.jsx(an,{className:"size-4"}),"Open the page again"]}),n.jsx("p",{className:"text-muted-foreground text-xs break-all",children:e.verificationUri}),o&&n.jsx($r,{children:"Couldn’t open the page. Copy the code instead."}),n.jsxs("p",{className:"text-muted-foreground flex items-center justify-center gap-2 text-sm",children:[n.jsx(Oe,{size:"xs"}),n.jsx("span",{role:"status",children:"Waiting for you to approve."})]})]})}function Sw({onComplete:e}){const t=yw(),{completeOnboarding:s}=en(),r=Pe(),[o,a]=u.useState(null),i=u.useCallback(()=>{s(),r({...Ne.home(),search:{}}),e()},[s,r,e]),c=u.useCallback(async()=>{a(null);try{await t.mutateAsync()}catch(l){a(Ln(l));return}i()},[t,i]),d=u.useRef(!1);return u.useEffect(()=>{d.current||(d.current=!0,c())},[c]),n.jsx("div",{className:"mx-auto flex w-full max-w-sm flex-col items-center px-4 text-center","data-testid":"onboarding-landing",children:o?n.jsxs(n.Fragment,{children:[n.jsx("p",{className:"text-destructive text-sm",role:"alert",children:o}),n.jsxs("div",{className:"mt-4 flex flex-wrap justify-center gap-2",children:[n.jsx(F,{onClick:()=>void c(),children:"Try again"}),n.jsx(F,{variant:"outline",onClick:i,children:"Go to #team"})]})]}):n.jsxs("p",{className:"text-muted-foreground flex items-center gap-2 text-sm",role:"status",children:[n.jsx(Oe,{size:"xs"}),"Opening #team…"]})})}const Cw="claude-code";function nu(e,t){return e.length===0?null:e.includes(t)?t:jc.find(r=>e.includes(r))??e[0]}function Nw({readyTypes:e,settled:t,settleToken:s}){var y,b;const{data:r}=Me(),o=Vn(),a=le(),[i,c]=u.useState(null),[d,l]=u.useState(null),m=u.useRef(null),h=((y=r==null?void 0:r.executionDefaults)==null?void 0:y.runtime)??Cw,p=!!((b=r==null?void 0:r.onboarding)!=null&&b.runtimeDefaultSetAt),f=u.useCallback((C,k)=>{c(null),l(k),o.mutate(C,{onSuccess:()=>void a.invalidateQueries({queryKey:Fe.all}),onError:I=>{l(null),c(I.message||"Couldn’t save that. Try again.")}})},[o,a]);u.useEffect(()=>{if(!t||e.length===0||!r||p)return;const C=nu(e,h);C&&m.current!==s&&(m.current=s,f({onboarding:{runtimeDefaultSetAt:new Date().toISOString()},...C===h?{}:{runtimes:{default:C}}},C))},[t,s,e,r,p,h,f]);const g=u.useCallback(C=>{C!==(d??h)&&f({runtimes:{default:C},...p?{}:{onboarding:{runtimeDefaultSetAt:new Date().toISOString()}}},C)},[f,d,h,p]);return{runtime:d??((p||d!==null)&&r?h:null),current:d??h,choose:g,error:i}}function Aw({onContinue:e,renderConnect:t,simulated:s}){const r=kc(),{data:o}=Sc(),{data:a}=Cc(),i=(s==null?void 0:s.requirements)??r.data,c=s!==void 0||r.isSuccess,d=o?Object.keys(o.capabilities):void 0,l=u.useMemo(()=>jc.filter(y=>(i==null?void 0:i.runtimes[y])!==void 0),[i]),m=u.useMemo(()=>i?l.filter(y=>Um(i,y,!0).state==="ready"||s===void 0&&Km(a,y)):[],[l,i,a,s]),h=Nw({readyTypes:m,settled:c&&s===void 0,settleToken:r.dataUpdatedAt}),[p,f]=u.useState(null),g=s!=null&&s.defaultRuntime?{runtime:p??s.defaultRuntime,current:p??s.defaultRuntime,choose:f,error:null}:h;if(!c)return n.jsxs("p",{className:"text-muted-foreground flex items-center gap-2 text-sm",role:"status",children:[n.jsx(Oe,{size:"xs"}),"Looking for AI apps…"]});if(s===void 0&&r.isError)return n.jsxs("div",{className:"space-y-2",role:"alert",children:[n.jsx("p",{className:"text-muted-foreground text-sm",children:"Couldn’t check for AI apps."}),n.jsx(F,{variant:"outline",size:"sm",onClick:()=>void r.refetch(),children:"Try again"})]});const x=m.length>0;return n.jsxs("div",{className:"space-y-4","data-testid":"onboarding-ai-apps",children:[x&&n.jsxs("div",{className:"space-y-1",children:[n.jsx("p",{className:"text-sm",children:Iw(m,g.runtime)}),n.jsx(Ew,{chosen:g.current,readyTypes:m,otherTypes:l.filter(y=>!m.includes(y)),onChoose:g.choose}),g.error&&n.jsx("p",{className:"text-destructive text-xs","data-testid":"default-runtime-error",children:g.error})]}),n.jsx(uy,{types:l,requirements:i,registeredTypes:d,renderConnect:t,onRecheck:s?void 0:()=>void r.refetch(),isRechecking:r.isFetching}),x&&n.jsx(F,{className:"w-full",onClick:e,"data-testid":"onboarding-ai-app-continue",children:"Continue"})]})}function Ew({chosen:e,readyTypes:t,otherTypes:s,onChoose:r}){const[o,a]=u.useState(!1),i=[...t,...s];return i.includes(e)||i.unshift(e),n.jsxs(mn,{open:o,onOpenChange:a,children:[n.jsxs(hn,{className:"text-muted-foreground hover:text-foreground inline-flex items-center gap-1 text-xs underline-offset-2 transition-colors hover:underline","data-testid":"default-runtime-change",children:["Change",n.jsx(Zt,{className:"size-3"})]}),n.jsxs(fn,{align:"start",className:"p-1",children:[n.jsx(pn,{children:"Start new chats with"}),n.jsx("div",{className:"flex flex-col",role:"listbox","aria-label":"Start new chats with",children:i.map(c=>{const d=c===e;return n.jsxs("button",{type:"button",role:"option","aria-selected":d,onClick:()=>{r(c),a(!1)},className:"hover:bg-accent flex items-center justify-between gap-3 rounded-md px-3 py-2.5 text-left text-sm transition-colors","data-testid":`default-runtime-option-${c}`,children:[n.jsxs("span",{className:"flex flex-col",children:[n.jsx("span",{children:dt(c).label}),!t.includes(c)&&n.jsx("span",{className:"text-muted-foreground text-xs",children:"Not signed in yet"})]}),d&&n.jsx(Jt,{className:"size-3.5 shrink-0","aria-hidden":!0})]},c)})})]})]})}function Iw(e,t){const s=e.map(c=>dt(c).label),r=s.length===1?`${s[0]} is signed in.`:s.length===2?`${s[0]} and ${s[1]} are signed in.`:`${s.slice(0,-1).join(", ")}, and ${s[s.length-1]} are signed in.`;if(!t)return r;if(e.length===1&&e[0]===t)return`${r} New chats start with it.`;const o=dt(t).label;if(e.includes(t))return`${r} New chats start with ${o}.`;const a=nu(e,t),i=a?dt(a).label:null;return i?`${r} New chats use ${i} until ${o} is signed in.`:`${r} New chats start with ${o} once it’s signed in.`}const Rw=[{id:"openai",title:"An OpenAI API key",line:"Paste a key. DorkOS picks the model."},{id:"anthropic",title:"An Anthropic API key",line:"Paste a key. DorkOS picks the model."},{id:"openrouter",title:"An OpenRouter key",line:"Paste a key. DorkOS picks the model."},{id:"local",title:"A model on this computer",line:"Uses Ollama on this computer. No key."},{id:"agent-app",title:"An AI app you sign in to",line:"Claude Code, Codex or OpenCode, on your own sign-in."},{id:"custom",title:"Other service",line:"Set the address, format, model and key."}],Tw={openai:"OpenAI API key",anthropic:"Anthropic API key",openrouter:"OpenRouter key"};function Dw({onSaved:e,beforePick:t,slots:s,initialRow:r,simulatedApps:o}){const[a,i]=u.useState(r??null),c=Bo(),[d,l]=u.useState(null),m=async(p,f=!1)=>{l(null);try{return await(t==null?void 0:t()),(await c.mutateAsync({path:"own",choice:p})).modelListed===!1&&ce("Using a default model. Change it in Settings."),!0}catch(g){if(f)throw new Error(Ln(g),{cause:g});return l(Ln(g)),!1}},h=p=>{l(null);const f=a===p?null:p;i(f),f==="agent-app"&&!o&&m({kind:"agent-app"})};return n.jsx("div",{className:"divide-border border-border w-full divide-y rounded-lg border text-left",children:Rw.map(p=>n.jsxs("section",{"data-testid":`own-ai-row-${p.id}`,children:[n.jsxs("button",{type:"button","aria-expanded":a===p.id,onClick:()=>h(p.id),className:"hover:bg-muted/60 focus-visible:ring-ring flex w-full items-center gap-3 px-4 py-3 text-left transition-colors focus-visible:ring-2 focus-visible:outline-none",children:[n.jsxs("span",{className:"min-w-0 flex-1",children:[n.jsx("span",{className:"block text-sm font-medium",children:p.title}),n.jsx("span",{className:"text-muted-foreground block text-xs",children:p.line})]}),n.jsx(gn,{"aria-hidden":!0,className:K("text-muted-foreground size-4 shrink-0 transition-transform",a===p.id&&"rotate-90")})]}),a===p.id&&n.jsxs("div",{className:"px-4 pt-1 pb-4",children:[n.jsx(Ow,{row:p.id,busy:c.isPending,save:m,onSaved:e,slots:s,simulatedApps:o}),d&&n.jsx("p",{className:"text-destructive mt-3 text-sm",role:"alert",children:d})]})]},p.id))})}function Ow({row:e,busy:t,save:s,onSaved:r,slots:o,simulatedApps:a}){switch(e){case"local":return n.jsxs(F,{onClick:async()=>{await s({kind:"local"})&&r()},disabled:t,children:[t&&n.jsx(Oe,{size:"xs"}),"Use this computer’s model"]});case"agent-app":return n.jsx(Aw,{onContinue:r,renderConnect:o==null?void 0:o.renderRuntimeConnect,simulated:a});case"custom":return o!=null&&o.renderOtherService?o.renderOtherService({onSave:async(i,c)=>{await s({kind:"custom",inference:i,...c?{apiKey:c}:{}},!0),r()}}):n.jsx("p",{className:"text-muted-foreground text-sm",children:"Set this up later in Settings."});default:return n.jsx(Mw,{service:e,busy:t,save:s,onSaved:r})}}function Mw({service:e,busy:t,save:s,onSaved:r}){const o=u.useId(),[a,i]=u.useState(""),[c,d]=u.useState(null),l=async m=>{m.preventDefault();const h=a.trim();if(d(null),!h){d("Enter a key.");return}if(e==="anthropic"&&h.startsWith("sk-ant-oat")){d("Subscription tokens can’t run agents. Use an API key.");return}await s({kind:e,apiKey:h})&&(i(""),r())};return n.jsxs("form",{onSubmit:m=>void l(m),className:"space-y-3",children:[n.jsxs("div",{className:"space-y-1.5",children:[n.jsx(He,{htmlFor:`${o}-key`,children:Tw[e]}),n.jsx(Hm,{id:`${o}-key`,value:a,onChange:m=>i(m.target.value),autoComplete:"off"})]}),c&&n.jsx("p",{className:"text-destructive text-sm",role:"alert",children:c}),n.jsxs(F,{type:"submit",disabled:t,children:[t&&n.jsx(Oe,{size:"xs"}),"Save"]})]})}function _w({onBack:e,...t}){const s=zo();return n.jsxs("div",{className:"mx-auto flex w-full max-w-md flex-col px-4","data-testid":"onboarding-own-ai",children:[n.jsx("h1",{ref:s,tabIndex:-1,className:"text-2xl font-semibold tracking-tight outline-none",children:"Use my own AI"}),n.jsx("p",{className:"text-muted-foreground mt-2 mb-6 text-sm",children:"Your agents run on a key, a local model or an AI app."}),n.jsx(Dw,{...t}),n.jsx(F,{variant:"ghost",size:"sm",className:"text-muted-foreground mt-6 self-start",onClick:e,children:"Back"})]})}function Pw({agentName:e,className:t}){var c;const s=hd(),r=e.trim()||"This agent";if(s.isPending)return n.jsx("p",{className:K("text-muted-foreground text-center text-xs",t),"data-testid":"every-agent-access-checking",children:"Checking apps every agent can use…"});if(s.isError)return n.jsxs("p",{className:K("text-muted-foreground text-xs",t),"data-testid":"every-agent-access-unknown",children:["Couldn’t check apps shared with every agent. ",r," gets them too."]});const o=((c=s.data)==null?void 0:c.connections)??[];if(o.length===0)return null;const a=new Map;for(const d of o)a.set(d.toolkit,(a.get(d.toolkit)??0)+1);const i=o.map(d=>{const l=(a.get(d.toolkit)??0)>1?`${_a(d.toolkit)} · ${d.label}`:_a(d.toolkit),m=Ty(d.access.classifications);return`${l} (${d.lifecycle==="paused"?`${m}, paused`:m})`});return n.jsxs("div",{className:K("bg-muted/40 flex items-start gap-3 rounded-xl px-4 py-3 text-sm",t),"data-testid":"every-agent-access-notice",children:[n.jsx(Nc,{className:"text-muted-foreground mt-0.5 size-4 shrink-0","aria-hidden":!0}),n.jsxs("p",{className:"min-w-0 flex-1",children:[n.jsxs("span",{className:"font-medium",children:[r," will get:"]})," ",i.join(", "),"."," ",n.jsx("span",{className:"text-muted-foreground",children:"You can change this in Connections."})]})]})}function Lw({onContinueWithDorkos:e,onUseOwnAi:t,onContinueWithout:s,busy:r=null,error:o=null}){const a=Ac(),i=zo();return n.jsxs("div",{className:"mx-auto flex w-full max-w-md flex-col items-center px-4 text-center","data-testid":"onboarding-welcome",children:[n.jsx(Tt,{size:120,className:"mb-8 opacity-90 dark:hidden"}),n.jsx(Tt,{variant:"white",size:120,className:"mb-8 hidden opacity-90 dark:block"}),n.jsx("h1",{ref:i,tabIndex:-1,className:"text-3xl font-semibold tracking-tight text-balance outline-none sm:text-4xl",children:"You, Multiplied."}),n.jsx("p",{className:"text-muted-foreground mt-3 text-balance",children:"Build and run your business with an agent team."}),n.jsxs("div",{className:"mt-10 flex w-full max-w-xs flex-col items-center gap-3",children:[n.jsxs(F,{size:"lg",className:"w-full",onClick:e,disabled:r!==null,"data-testid":"onboarding-continue-dorkos",children:[r==="dorkos"&&n.jsx(Oe,{size:"xs"}),"Continue with DorkOS"]}),n.jsx(Po,{withSpaces:a,className:"text-balance"}),o&&n.jsx("p",{className:"text-destructive text-sm",role:"alert",children:o})]}),n.jsxs("div",{className:"mt-8 flex flex-col items-center gap-1 sm:flex-row sm:gap-2",children:[n.jsx(F,{variant:"ghost",size:"sm",className:"text-muted-foreground",onClick:t,disabled:r!==null,children:"Use my own AI"}),n.jsx("span",{"aria-hidden":!0,className:"text-muted-foreground/50 hidden sm:inline",children:"·"}),n.jsxs(F,{variant:"ghost",size:"sm",className:"text-muted-foreground",onClick:s,disabled:r!==null,children:[r==="none"&&n.jsx(Oe,{size:"xs"}),"Continue without an account"]})]})]})}function Fw({onComplete:e,slots:t}){const s=t==null?void 0:t.renderAccountLink,r=o=>n.jsx($w,{link:o,slots:t,onComplete:e});return n.jsx("div",{className:"bg-background h-full w-full overflow-y-auto",children:n.jsx("div",{className:"flex min-h-full w-full items-center justify-center p-4 py-10",children:s?s(r):r(null)})})}function $w({link:e,slots:t,onComplete:s}){var I;const{stage:r,goToStage:o,goBack:a}=fw(),{startOnboarding:i}=en(),c=Bo(),[d,l]=u.useState(null),m=u.useRef(null),h=u.useRef(!1);u.useEffect(()=>{h.current||(h.current=!0,i())},[i]),u.useEffect(()=>{var v;r!=="connecting"&&((v=m.current)==null||v.close(),m.current=null)},[r]);const p=u.useRef(e);u.useEffect(()=>{p.current=e});const f=u.useCallback(async()=>{var v;((v=p.current)==null?void 0:v.state)==="pending"&&await p.current.cancel()},[]),g=u.useCallback(()=>{m.current!==null||r==="connecting"||(l(null),m.current=e&&e.state!=="linked"?io():null,o("connecting"))},[o,e,r]),x=u.useCallback(async()=>{l(null);try{await f(),await c.mutateAsync({path:"none"}),o("landing")}catch(v){l(Ln(v))}},[c,o,f]),y=u.useCallback(()=>o("landing"),[o]),b=u.useCallback(()=>o("own-ai"),[o]),C=u.useCallback(()=>a("welcome"),[a]);let k;return r==="connecting"?k=e?n.jsx(Bw,{link:e,waitingWindowRef:m,onReady:y,onCancel:()=>{f(),C()},onUseOwnAi:()=>{f(),b()}}):n.jsx(tu,{phase:{kind:"failed",message:"Signing in isn’t available here."},link:null,onRetry:C,onCancel:C,onUseOwnAi:b}):r==="own-ai"?k=n.jsx(_w,{onBack:C,onSaved:y,beforePick:f,slots:t}):r==="landing"?k=n.jsx(Sw,{onComplete:s}):k=n.jsx(Lw,{onContinueWithDorkos:g,onUseOwnAi:b,onContinueWithout:()=>void x(),busy:c.isPending&&((I=c.variables)==null?void 0:I.path)==="none"?"none":null,error:d}),k}function Bw({link:e,waitingWindowRef:t,onReady:s,onCancel:r,onUseOwnAi:o}){const{phase:a,retry:i}=vw({link:e,waitingWindowRef:t,onReady:s});return n.jsx(tu,{phase:a,link:e,onRetry:i,onCancel:r,onUseOwnAi:o})}function zw(){var l;const e=ie(),t=le(),{data:s}=Ee({queryKey:Fe.current(),queryFn:()=>e.getConfig(),staleTime:300*1e3}),r=((l=s==null?void 0:s.mesh)==null?void 0:l.scanRoots)??[],o=(s==null?void 0:s.boundary)??"",a=r.length>0?r:o?[o]:[],{mutate:i,isPending:c}=Qt({mutationKey:xc,mutationFn:async m=>{await e.updateConfig({mesh:{scanRoots:m}})},onSuccess:()=>{t.invalidateQueries({queryKey:Fe.all})}}),d=u.useCallback(m=>i(m),[i]);return{roots:a,boundary:o,isSaving:c,setScanRoots:d}}const Uw=50,Sn=["room_created","room_updated","room_member_added","room_member_removed","room_activity"];function Ja(e){if(typeof e!="object"||e===null)return!1;const{roomId:t}=e;return typeof t=="string"&&t.length>0}function Kw(e){if(typeof e!="object"||e===null)return!1;const{userId:t,threadKind:s,threadId:r,lastReadSeq:o,unreadCount:a}=e;return s==="room"&&typeof t=="string"&&t.length>0&&typeof r=="string"&&r.length>0&&typeof o=="number"&&typeof a=="number"}function Hw(e,t){const s=e.getQueryData(Ue.detail(t.threadId));return s===void 0||s.viewerAuthorId===t.userId}function Ww(e,t){const s=e.isFetching({queryKey:Ue.lists()})>0;e.cancelQueries({queryKey:Ue.lists()}),e.setQueriesData({queryKey:Ue.lists()},o=>Array.isArray(o)?o.map(a=>{if(a.id!==t.threadId||a.unreadCount===null)return a;const i=Math.min(a.unreadCount,t.unreadCount);return a.mentionCount===void 0?{...a,unreadCount:i}:{...a,unreadCount:i,mentionCount:Math.min(a.mentionCount,i)}}):o),e.setQueryData(Ue.detail(t.threadId),o=>o&&{...o,members:o.members.map(a=>a.authorId===t.userId?{...a,lastReadSeq:Math.max(a.lastReadSeq,t.lastReadSeq)}:a)});const r=e.getQueryData(Ue.threads());r!=null&&r.some(o=>o.roomId===t.threadId&&o.unreadCount>0)&&e.invalidateQueries({queryKey:Ue.threads()}),s&&e.invalidateQueries({queryKey:Ue.lists()})}function Gw(){const e=le(),t=()=>{e.invalidateQueries({queryKey:Ue.lists()}),e.invalidateQueries({queryKey:Ue.wellKnowns()}),e.invalidateQueries({queryKey:Ue.threads()})};fe(Sn[0],t),fe(Sn[1],t),fe(Sn[2],t),fe(Sn[3],t),fe(Sn[4],t),fe("room_awaiting",t),fe("room_updated",o=>{Ja(o)&&e.invalidateQueries({queryKey:Ue.detail(o.roomId)})});const s=u.useRef(new Set),r=o=>{if(!Ja(o))return;const a=s.current;if(a.has(o.roomId))return;a.add(o.roomId);const i=o.roomId;setTimeout(()=>{a.delete(i),e.invalidateQueries({queryKey:Ue.detail(i)})},Uw)};fe("room_member_added",r),fe("room_member_removed",r),fe("room_presence",o=>Wm.getState().observe(o)),fe("read_cursor",o=>{!Kw(o)||!Hw(e,o)||Ww(e,o)})}function qw(){const e=le();fe("capabilities_changed",()=>{e.invalidateQueries({queryKey:Ec.all})})}function Yw(){const e=ie(),t=le();return Qt({mutationFn:({agentId:s,key:r,surface:o})=>e.patchAgentPermissions(s,{...r.kind==="area"?{areas:{[r.area]:null}}:{},...r.kind==="action"?{actions:{[r.action]:null}}:{},...r.kind==="files"?{filesAndCommands:null}:{},surface:o}),onSettled:()=>{t.invalidateQueries({queryKey:Ec.all}),t.invalidateQueries({queryKey:["mesh","agents"]})}})}function Vw(){const e=le(),t=()=>{e.invalidateQueries({queryKey:[...Gm],exact:!0})};fe("tasks_changed",t),fe("task_run_finished",()=>{t(),e.invalidateQueries({queryKey:[...ia]})});const s=()=>{e.invalidateQueries({queryKey:[...ia]})};fe("task_run_failed",s),fe("task_run_updated",s)}function Qw(e){const t=new Set,s=[],r=[];for(const o of e){if(o.status==="running"){s.includes(o.scheduleId)||s.push(o.scheduleId),t.add(o.scheduleId);continue}t.has(o.scheduleId)||o.status==="skipped"||o.status==="cancelled"||(t.add(o.scheduleId),(o.status==="failed"||o.status==="needs_attention")&&r.push(o.scheduleId))}return{running:s,failed:r}}function Xw({members:e}){var d;const t=L(l=>l.explicitAgentPath),s=L(l=>l.setExplicitAgentPath),r=e.some(l=>l.agentPath===t),o=((d=e[0])==null?void 0:d.agentPath)??null;u.useEffect(()=>{!r&&o!==null&&s(o)},[r,o,s]);const a=u.useRef([]);if(e.length===0)return null;const i=Math.max(0,e.findIndex(l=>l.agentPath===t)),c=l=>{var p;const m=e.length-1,h=l.key==="ArrowRight"||l.key==="ArrowDown"?i===m?0:i+1:l.key==="ArrowLeft"||l.key==="ArrowUp"?i===0?m:i-1:l.key==="Home"?0:l.key==="End"?m:null;h!==null&&(l.preventDefault(),s(e[h].agentPath),(p=a.current[h])==null||p.focus())};return n.jsx("div",{role:"radiogroup","aria-label":"Show the panel for","data-testid":"group-dm-member-picker",onKeyDown:c,className:"flex shrink-0 flex-wrap gap-1.5 border-b px-3 py-2",children:e.map((l,m)=>{const h=l.agentPath===t;return n.jsxs("button",{type:"button",ref:p=>{a.current[m]=p},role:"radio","aria-checked":h,tabIndex:m===i?0:-1,onClick:()=>s(l.agentPath),className:K("focus-ring flex h-7 max-w-40 items-center gap-1.5 rounded-full border px-2 text-xs transition-colors",h?"bg-accent text-foreground border-transparent":"text-muted-foreground hover:bg-accent/60 hover:text-foreground"),children:[n.jsx(fs,{"aria-hidden":!0,size:"xs",className:"size-4 shrink-0 text-[9px]",kind:"agent",color:l.color??ms(l.authorId),emoji:l.emoji,badge:null,fallback:Ar(l.displayName)}),n.jsx("span",{className:"truncate",children:l.displayName})]},l.authorId)})})}const Jw=4e3;function su(){var o;const e=lo(),{identityPromptDismissedAt:t,isLoading:s}=Ys();if(s||e.isPending)return"pending";if(t!==null)return"settled";const r=(o=e.data)==null?void 0:o.members.find(a=>a.isSelf);return r&&Wb(r)?"ask":"settled"}function Zw(){const{state:e,isLoading:t,shouldShowGettingStarted:s}=en(),r=su(),{dismissIdentityPrompt:o}=Ys(),[a,i]=u.useState("ask");u.useEffect(()=>{if(a!=="saved")return;const m=setTimeout(()=>i("done"),Jw);return()=>clearTimeout(m)},[a]);const c=e.completedAt!==null||e.dismissedAt!==null,d=!t&&c&&r==="ask"&&!s,l=()=>{o().catch(()=>{})};return{visible:a!=="done"&&(d||a==="saved"),phase:a,markSaved:()=>{i("saved"),l()},skip:()=>{i("done"),l()}}}function ru(){const{firstRunPath:e}=en().state,{offered:t,pending:s}=ed(),r=e==="dorkos"||e==="own";return{due:r&&t,pending:r&&s}}const ej=4e3,or="Tell DorkBot your name",Za="Tell DorkBot about your work";function tj({onDismiss:e}){const t=ht(),s=Pe(),{open:r}=ct(),o=uo(),a=L(D=>D.requestTour),{startSession:i}=nw(),{roles:c,rolePromptDismissedAt:d,isLoading:l,saveRoles:m,dismissIdentityPrompt:h}=Ys(),p=su(),f=ru().due,[g,x]=u.useState("closed"),[y,b]=u.useState("closed"),[C,k]=u.useState([]),I=!l&&c.length===0&&d===null;u.useEffect(()=>{if(g!=="saved")return;const D=setTimeout(()=>x("closed"),ej);return()=>clearTimeout(D)},[g]);const v=()=>{x("saved"),h().catch(()=>{})},E=()=>{b("saving"),m(C).then(()=>b("closed")).catch(()=>b("error"))};let R="Save";y==="saving"?R="Saving…":y==="error"&&(R="Try again");const _=[{icon:Rs,label:"Talk to DorkBot",onClick:i},...p==="ask"||g==="saved"?[{icon:xd,label:or,onClick:()=>x(D=>D==="saved"?D:D==="closed"?"open":"closed"),expanded:g!=="closed"}]:[],...I?[{icon:mo,label:Za,onClick:()=>b(D=>D==="closed"?"open":"closed"),expanded:y!=="closed"}]:[],{icon:zy,label:"Show me around",onClick:()=>a("general")},{icon:Dt,label:"Create an agent",onClick:()=>Ts.getState().open("new")},{icon:Ic,label:"Schedule a task",onClick:()=>s({...Ne.tasks()})},{icon:bd,label:"Connect more runtimes",onClick:()=>r("runtimes")},{icon:Vb,label:"Connect a service",onClick:()=>o()}];return n.jsxs(re.div,{initial:t?!1:{opacity:0,y:8},animate:{opacity:1,y:0},transition:{duration:.3},className:"border-border bg-card relative rounded-lg border p-3",children:[n.jsx("button",{onClick:e,className:"text-muted-foreground/50 hover:text-muted-foreground absolute top-1.5 right-1.5 rounded-md p-0.5 transition-colors duration-150","aria-label":"Dismiss getting started",children:n.jsx(Be,{className:"size-3.5"})}),n.jsx("h3",{className:"mb-2 text-xs font-medium",children:"Getting started"}),n.jsx("ul",{className:"space-y-0.5",children:_.map(({icon:D,label:P,onClick:T,expanded:j})=>n.jsxs("li",{children:[n.jsxs("button",{onClick:T,className:"hover:bg-accent group flex w-full items-center gap-2 rounded-md px-1.5 py-1 text-left transition-colors duration-150","aria-expanded":j,children:[n.jsx(D,{className:"text-muted-foreground size-3.5 shrink-0"}),n.jsx("span",{className:"text-foreground flex-1 text-xs",children:P}),n.jsx(gn,{className:"text-muted-foreground/40 group-hover:text-muted-foreground size-3.5 shrink-0 transition-colors"})]}),P===or&&g==="open"&&n.jsx("div",{className:"px-1.5 py-2","data-testid":"progress-card-identity-form",children:n.jsx(gd,{onSaved:v})}),P===or&&g==="saved"&&n.jsx("p",{role:"status",className:"text-muted-foreground px-1.5 py-2 text-xs",children:bt.identityCardSaved}),P===Za&&y!=="closed"&&n.jsx("div",{className:"px-1.5 py-2","data-testid":"progress-card-profile-picker",children:n.jsx(dd,{selected:C,onChange:k,onConfirm:E,confirmLabel:R,busy:y==="saving",error:y==="error"?bt.saveError:null})})]},P))}),f&&n.jsx(td,{compact:!0,className:"border-border mt-2 border-t px-1.5 pt-2"})]})}const ei=72;function ou({title:e,description:t,titleIsStatus:s}){return n.jsxs("div",{className:"flex flex-col gap-2",children:[n.jsxs("div",{children:[n.jsx(Tt,{size:ei,className:"block dark:hidden"}),n.jsx(Tt,{variant:"white",size:ei,className:"hidden dark:block"})]}),n.jsxs("div",{className:"flex flex-col gap-0.5",children:[n.jsx("p",{className:"text-sm leading-relaxed",role:s?"status":void 0,children:e}),t!==void 0&&n.jsx("p",{className:"text-muted-foreground text-xs leading-relaxed",children:t})]})]})}function nj({prompt:e}){const t=ht(),{open:s}=ct(),{phase:r,selected:o,setSelected:a,confirmLabel:i,errorMessage:c}=e;return n.jsxs(re.div,{initial:t?!1:{opacity:0,y:8},animate:{opacity:1,y:0},transition:{duration:.2},role:"group","aria-label":"DorkBot suggestion","data-testid":"profile-prompt-card",className:"bg-secondary/60 flex flex-col gap-2 rounded-lg border p-3",children:[n.jsx(ou,{title:r==="saved"?bt.profileSaved:bt.profileCardPrompt[0],description:n.jsxs(n.Fragment,{children:[bt.profileCardPrompt[1]," ",n.jsx("button",{type:"button",onClick:()=>s("profile"),className:"focus-visible:ring-ring hover:text-foreground rounded-sm underline underline-offset-2 focus-visible:ring-2 focus-visible:outline-none",children:"Change it in Settings"}),"."]})}),r!=="saved"&&n.jsx(dd,{selected:o,onChange:a,onConfirm:e.save,confirmLabel:i,onSkip:e.skip,skipLabel:"Don’t ask again",busy:r==="saving",error:c})]})}const sj=4e3;function rj(){const{state:e,isLoading:t,shouldShowGettingStarted:s}=en(),{roles:r,rolePromptDismissedAt:o,isLoading:a,saveRoles:i,dismissRolePrompt:c}=Ys(),[d,l]=u.useState([]),[m,h]=u.useState("ask");u.useEffect(()=>{if(m!=="saved")return;const y=setTimeout(()=>h("done"),sj);return()=>clearTimeout(y)},[m]);const p=e.completedAt!==null||e.dismissedAt!==null,f=!e.completedSteps.includes("profile")&&!e.skippedSteps.includes("profile"),g=!t&&!a&&p&&r.length===0&&f&&o===null&&!s;let x="Save";return m==="saving"?x="Saving…":m==="error"&&(x="Try again"),{visible:m!=="done"&&(g||m==="saved"),phase:m,selected:d,setSelected:l,confirmLabel:x,errorMessage:m==="error"?bt.saveError:null,save:()=>{h("saving"),i(d).then(()=>h("saved")).catch(()=>h("error"))},skip:()=>{h("done"),c().catch(()=>{})}}}function oj({prompt:e}){const t=ht(),s=e.phase==="saved";return n.jsxs(re.div,{initial:t?!1:{opacity:0,y:8},animate:{opacity:1,y:0},transition:{duration:.2},role:"group","aria-label":"DorkBot suggestion","data-testid":"identity-prompt-card",className:"bg-secondary/60 flex flex-col gap-3 rounded-lg border p-3",children:[n.jsx(ou,{title:s?bt.identityCardSaved:bt.identityCardPrompt[0],description:s?void 0:bt.identityCardPrompt[1],titleIsStatus:s}),!s&&n.jsx(gd,{onSaved:e.markSaved,onSkip:e.skip,skipLabel:"Don’t ask again"})]})}function aj(){const e=ie(),t=u.useRef(null),{startScan:s,addCandidate:r,addExistingAgent:o,setProgress:a,completeScan:i,setError:c}=Rc(),d=u.useCallback((m={roots:[]})=>{var p;(p=t.current)==null||p.abort();const h=new AbortController;t.current=h,s(),e.scan(m,f=>{switch(f.type){case"candidate":r(f.data);break;case"existing-agent":o(f.data);break;case"progress":a(f.data);break;case"complete":i(f.data);break;case"error":c(f.data.error);break}},h.signal).catch(f=>{f instanceof Error&&f.name!=="AbortError"&&c(f.message)})},[e,s,r,o,a,i,c]),l=u.useCallback(()=>{var m;(m=t.current)==null||m.abort(),t.current=null},[]);return{startScan:d,stopScan:l}}function ij(){const[e,t]=u.useState(new Set),s=u.useCallback(o=>{t(a=>new Set(a).add(o))},[]),r=u.useCallback(()=>{t(new Set)},[]);return{actedPaths:e,markActed:s,resetActed:r}}function cj({register:e,onSuccess:t}){const s=u.useRef(new Set),[r,o]=u.useState(new Set),[a,i]=u.useState(new Set),c=u.useCallback(async l=>{if(!s.current.has(l.path)){s.current.add(l.path),o(m=>new Set(m).add(l.path)),i(m=>{const h=new Set(m);return h.delete(l.path),h});try{await e(l),t(l)}catch{i(m=>new Set(m).add(l.path))}finally{s.current.delete(l.path),o(m=>{const h=new Set(m);return h.delete(l.path),h})}}},[t,e]),d=u.useCallback(()=>i(new Set),[]);return{failedPaths:a,pendingPaths:r,registerCandidate:c,resetFailures:d}}function lj(e){return{name:e.hints.suggestedName,runtime:e.hints.detectedRuntime,...e.hints.inferredCapabilities?{capabilities:e.hints.inferredCapabilities}:{},...e.hints.description?{description:e.hints.description}:{}}}function dj(e){return[...e].sort((t,s)=>{const r=t.strategy==="dork-manifest",o=s.strategy==="dork-manifest";return r!==o?r?-1:1:t.path.localeCompare(s.path)})}const uj={"claude-code":"Has an AGENTS.md file, so it’s a Claude Code project.",cursor:"Has a .cursor folder, so it’s a Cursor project.",codex:"Has a .codex folder, so it’s a Codex project.","dork-manifest":"Has a .dork/agent.json file, so it’s already a DorkOS agent."};function mj(e){return uj[e]??`Found by the “${e}” check.`}const hj={"code-review":"Reviews code for bugs, style issues, and correctness.",summarize:"Summarizes documents, chats, or code.","file-ops":"Reads and writes files on the filesystem.",test:"Generates and runs tests for a codebase.",search:"Searches code, files, or the web for relevant information.",refactor:"Refactors code while preserving existing behavior.",analyze:"Analyzes data, logs, or codebases for patterns and insights.",generate:"Generates code, content, or structured output.",debug:"Diagnoses and fixes bugs in code.",deploy:"Manages deployment pipelines and infrastructure changes."};function fj(e){return hj[e]??"Found in the project’s files."}function pj({candidate:e,onApprove:t,onDeny:s,onSkip:r,registrationFailed:o=!1,registrationPending:a=!1,className:i,ref:c}){const{path:d,strategy:l,hints:m}=e;return n.jsxs(re.div,{ref:c,"data-slot":"candidate-card","aria-busy":a,layout:!0,initial:{opacity:0,y:6},animate:{opacity:1,y:0},exit:{opacity:0,y:-6},transition:{duration:.15,ease:"easeOut"},className:K("flex items-start justify-between rounded-xl border p-4",i),children:[n.jsxs("div",{className:"min-w-0 flex-1 space-y-2",children:[n.jsx("p",{className:"truncate text-sm leading-tight font-semibold",title:m.suggestedName||d.split("/").pop()||d,children:m.suggestedName||d.split("/").pop()||d}),n.jsxs("div",{className:"text-muted-foreground flex items-center gap-1.5 text-xs",children:[n.jsx(qm,{className:"size-3 shrink-0"}),n.jsx("span",{className:"truncate font-mono",title:d,children:ho(d)})]}),n.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[n.jsxs(yd,{openDelay:300,children:[n.jsx(vd,{asChild:!0,children:n.jsx(On,{variant:"secondary",className:"hover:bg-secondary/80 cursor-default",children:m.detectedRuntime})}),n.jsxs(wd,{className:"w-56 space-y-1.5 p-3",side:"top",align:"start",children:[n.jsx("p",{className:"text-xs font-medium",children:"How DorkOS knows"}),n.jsx("p",{className:"text-muted-foreground text-xs",children:mj(l)})]})]}),m.inferredCapabilities&&m.inferredCapabilities.length>0&&m.inferredCapabilities.map(h=>n.jsxs(xn,{children:[n.jsx(bn,{asChild:!0,children:n.jsx(On,{size:"xs",variant:"outline",className:"cursor-default",children:h})}),n.jsx(yn,{side:"top",className:"max-w-48 text-center",children:fj(h)})]},h))]}),o&&n.jsx("p",{role:"alert",className:"text-destructive text-xs",children:"Couldn’t add this project. Try again."})]}),n.jsxs("div",{className:"ml-4 flex shrink-0 items-center gap-1.5",children:[n.jsx("button",{type:"button",onClick:()=>t(e),disabled:a,className:"focus-visible:ring-ring rounded-md bg-green-600/10 px-2.5 py-1 text-xs font-medium text-green-700 hover:bg-green-600/20 focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50 dark:text-green-400",children:a?"Adding…":o?"Try again":"Add"}),r&&n.jsx("button",{type:"button",onClick:()=>r(e),disabled:a,className:"text-muted-foreground hover:bg-muted focus-visible:ring-ring rounded-md px-2.5 py-1 text-xs font-medium focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50",children:"Skip"}),s&&n.jsx("button",{type:"button",onClick:()=>s(e),disabled:a,className:"focus-visible:ring-ring rounded-md bg-red-600/10 px-2.5 py-1 text-xs font-medium text-red-700 hover:bg-red-600/20 focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50 dark:text-red-400",children:"Deny"})]})]})}function gj({agent:e}){return n.jsxs("div",{className:"bg-muted/50 flex items-center gap-3 rounded-lg border px-4 py-3",children:[n.jsx(Is,{className:"text-muted-foreground size-4 shrink-0"}),n.jsxs("div",{className:"min-w-0 flex-1",children:[n.jsx("p",{className:"truncate text-sm font-medium",children:Le(e)}),n.jsx("p",{className:"text-muted-foreground truncate text-xs",children:e.path})]}),n.jsx("span",{className:"text-muted-foreground shrink-0 text-xs",children:"Imported"})]})}const xj=2;function bj({agents:e}){const[t,s]=u.useState(e.length<=xj);return e.length===0?null:n.jsxs("div",{children:[n.jsxs("button",{type:"button",onClick:()=>s(r=>!r),className:"text-muted-foreground hover:text-foreground flex w-full items-center gap-1.5 py-1.5 text-xs transition-colors",children:[n.jsx(gn,{className:K("size-3 transition-transform",t&&"rotate-90")}),e.length," project",e.length===1?"":"s"," already in DorkOS"]}),t&&n.jsx("div",{className:"mt-2 space-y-2",children:e.map(r=>n.jsx(gj,{agent:r},r.path))})]})}function yj({count:e,onAddAll:t,disabled:s}){return e===0?null:n.jsxs("div",{className:"flex items-center justify-between py-1",children:[n.jsxs("span",{className:"text-muted-foreground text-sm font-medium",children:[e," new project",e===1?"":"s"]}),n.jsx(F,{variant:"outline",size:"sm",onClick:t,disabled:s,children:"Add all"})]})}function vj({roots:e,onChange:t}){const[s,r]=u.useState(""),[o,a]=u.useState(!1),i=u.useCallback(m=>{const h=m.trim();h&&!e.includes(h)&&t([...e,h])},[e,t]),c=u.useCallback(m=>{t(e.filter(h=>h!==m))},[e,t]),d=u.useCallback(m=>{(m.key==="Enter"||m.key===",")&&(m.preventDefault(),s.trim()&&(i(s),r(""))),m.key==="Backspace"&&s===""&&e.length>0&&c(e[e.length-1])},[s,e,i,c]),l=u.useCallback(m=>{i(m)},[i]);return n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"focus-within:ring-ring flex min-h-[40px] flex-wrap items-center gap-1.5 rounded-md border bg-transparent px-3 py-1.5 focus-within:ring-2",children:[e.map(m=>n.jsxs(On,{variant:"secondary",className:"gap-1 py-0.5 font-mono",children:[m,n.jsx("button",{type:"button",onClick:()=>c(m),className:"hover:bg-muted-foreground/20 ml-0.5 rounded-sm","aria-label":`Remove ${m}`,children:n.jsx(Be,{className:"size-3"})})]},m)),n.jsx("input",{type:"text",value:s,onChange:m=>r(m.target.value),onKeyDown:d,placeholder:e.length===0?"Type a folder, then press Enter":"Add more…",className:"placeholder:text-muted-foreground min-w-[120px] flex-1 bg-transparent text-sm focus-visible:outline-none"}),n.jsx("button",{type:"button",onClick:()=>a(!0),className:"text-muted-foreground hover:bg-accent hover:text-foreground shrink-0 rounded p-1","aria-label":"Browse for a folder",children:n.jsx(Ds,{className:"size-4"})})]}),n.jsx(Tc,{open:o,onOpenChange:a,onSelect:l})]})}function wj(e,t){let s;for(const r of t){const o=r.endsWith("/")?r.slice(0,-1):r;(e===o||e.startsWith(o+"/"))&&(!s||o.length>s.length)&&(s=o)}return s}function jj(){return n.jsxs("svg",{viewBox:"0 0 240 120",className:"mx-auto h-24 w-48","aria-hidden":"true",children:[n.jsx("path",{d:"M15 25 L33 25 L37 33 L60 33 L60 77 L15 77 Z",className:"fill-none stroke-current",strokeWidth:"1.5"}),n.jsx("rect",{x:"23",y:"44",width:"16",height:"2",rx:"1",className:"fill-current opacity-40"}),n.jsx("rect",{x:"23",y:"50",width:"26",height:"2",rx:"1",className:"fill-current opacity-20"}),n.jsx("rect",{x:"23",y:"56",width:"20",height:"2",rx:"1",className:"fill-current opacity-20"}),n.jsx("path",{d:"M180 25 L198 25 L202 33 L225 33 L225 77 L180 77 Z",className:"fill-none stroke-current",strokeWidth:"1.5"}),n.jsx("rect",{x:"188",y:"44",width:"20",height:"2",rx:"1",className:"fill-current opacity-40"}),n.jsx("rect",{x:"188",y:"50",width:"14",height:"2",rx:"1",className:"fill-current opacity-20"}),n.jsx("rect",{x:"188",y:"56",width:"24",height:"2",rx:"1",className:"fill-current opacity-20"}),n.jsx("circle",{cx:"120",cy:"48",r:"18",className:"fill-none stroke-current",strokeWidth:"2"}),n.jsx("line",{x1:"133",y1:"61",x2:"148",y2:"76",className:"stroke-current",strokeWidth:"3",strokeLinecap:"round"}),n.jsx("path",{d:"M110 38 Q114 33 120 32",className:"fill-none stroke-current opacity-30",strokeWidth:"1.5",strokeLinecap:"round"}),n.jsx("line",{x1:"63",y1:"55",x2:"102",y2:"50",className:"stroke-current opacity-40",strokeWidth:"1.5",strokeDasharray:"4 3"}),n.jsx("line",{x1:"138",y1:"50",x2:"177",y2:"55",className:"stroke-current opacity-40",strokeWidth:"1.5",strokeDasharray:"4 3"})]})}const kj=[{name:"claude-code",signal:"AGENTS.md",label:"Claude Code project"},{name:"cursor",signal:".cursor/",label:"Cursor project"},{name:"codex",signal:".codex/",label:"Codex project"},{name:"dork",signal:".dork/agent.json",label:"DorkOS agent (auto-imported)"}];function Sj({fullBleed:e=!1,onRegistered:t}){var Q;const{roots:s,setScanRoots:r}=zw(),[o,a]=u.useState(null),[i,c]=u.useState(!1),[d,l]=u.useState(3),{startScan:m}=aj(),{candidates:h,existingAgents:p,isScanning:f,progress:g,error:x,lastScanAt:y}=Rc(),{mutateAsync:b}=Ym(),{mutate:C}=Vm(),{data:k}=Qm(),{actedPaths:I,markActed:v,resetActed:E}=ij(),R=o??s,_=u.useCallback(q=>b({path:q.path,overrides:lj(q),scanRoot:wj(q.path,R)}),[R,b]),D=u.useCallback(q=>{v(q.path),t==null||t()},[v,t]),{failedPaths:P,pendingPaths:T,registerCandidate:j,resetFailures:w}=cj({register:_,onSuccess:D});function N(q){a(q),r(q)}function S(){R.length>0&&(E(),w(),m({roots:R,maxDepth:d}))}const B=u.useMemo(()=>f?h:dj(h),[h,f]).filter(q=>!I.has(q.path)),O=(((Q=k==null?void 0:k.agents)==null?void 0:Q.length)??0)>0,$=p.length>0,G=h.length>0,ee=$||G,z=!f&&y!==null,V=!f&&y===null;function ae(){for(const q of B)j(q)}const pe=n.jsxs("div",{children:[n.jsxs("button",{type:"button",onClick:()=>c(!i),className:"text-muted-foreground hover:text-foreground flex items-center gap-1 text-xs",children:[n.jsx(Zt,{className:`size-3 transition-transform ${i?"":"-rotate-90"}`}),"Advanced"]}),i&&n.jsxs("div",{className:"bg-muted/30 mt-2 space-y-3 rounded-lg border p-3",children:[n.jsx(vj,{roots:R,onChange:N}),n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsx("label",{htmlFor:"scan-depth",className:"text-muted-foreground text-xs",children:"Scan depth"}),n.jsx("input",{id:"scan-depth",type:"range",min:1,max:5,value:d,onChange:q=>l(Number(q.target.value)),className:"flex-1"}),n.jsx("span",{className:"min-w-[1.5rem] text-center text-xs font-medium",children:d})]}),n.jsxs("div",{className:"space-y-1.5",children:[n.jsxs("p",{className:"text-muted-foreground flex items-center gap-1 text-xs",children:[n.jsx(Ky,{className:"size-3"}),"What it looks for"]}),n.jsx("ul",{className:"space-y-1 pl-4",children:kj.map(q=>n.jsxs("li",{className:"flex items-baseline gap-1.5",children:[n.jsx("code",{className:"text-foreground/70 text-3xs",children:q.signal}),n.jsxs("span",{className:"text-muted-foreground text-3xs",children:["→ ",q.label]})]},q.name))})]})]})]});return n.jsx("div",{className:e?"flex h-full flex-col p-6":"space-y-4 p-4",children:V?n.jsx("div",{className:e?"flex flex-1 items-center justify-center":"",children:n.jsxs("div",{className:e?"w-full max-w-sm space-y-5":"space-y-5",children:[n.jsx(jj,{}),n.jsxs("div",{className:"text-center",children:[n.jsx("p",{className:"text-foreground text-sm font-medium",children:"Find your existing projects"}),n.jsx("p",{className:"text-muted-foreground mx-auto mt-1 max-w-[300px] text-xs leading-relaxed",children:"Find Claude Code, Cursor, Codex and other AI projects on this computer."})]}),x&&n.jsx("div",{className:"border-destructive/30 bg-destructive/5 text-destructive rounded-lg border px-4 py-3 text-sm",children:x}),n.jsxs(F,{onClick:S,disabled:R.length===0,className:"w-full",children:[n.jsx(ps,{className:"size-4"}),"Search for projects"]}),n.jsx("p",{className:"text-muted-foreground/60 text-center text-xs",children:"Read-only scan. Nothing changes until you approve"}),pe]})}):n.jsxs(n.Fragment,{children:[e&&n.jsxs("div",{className:"mb-4 space-y-1",children:[n.jsx("h2",{className:"text-lg font-semibold",children:"Bring in existing projects"}),n.jsx("p",{className:"text-muted-foreground text-sm",children:"Search for existing projects to bring into DorkOS."})]}),n.jsxs("div",{className:"space-y-3",children:[pe,n.jsxs(F,{onClick:S,disabled:f||R.length===0,children:[f?n.jsx(Oe,{}):n.jsx(ps,{className:"size-4"}),"Search for projects"]})]}),n.jsxs("div",{className:e?"mt-4 flex-1 overflow-y-auto":"",children:[f&&n.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 p-8",children:[n.jsx(Oe,{size:"md",className:"text-muted-foreground",label:"Searching for projects"}),g&&n.jsxs("div",{className:"text-muted-foreground space-y-0.5 text-center text-xs",children:[n.jsxs("p",{children:["Scanned ",g.scannedDirs," directories"]}),n.jsxs("p",{children:["Found ",g.foundAgents," project",g.foundAgents===1?"":"s"]})]})]}),x&&n.jsx("div",{className:"border-destructive/30 bg-destructive/5 text-destructive mb-3 rounded-lg border px-4 py-3 text-sm",children:x}),z&&!G&&$&&n.jsxs("div",{className:"rounded-xl border border-dashed p-8 text-center",children:[n.jsx("p",{className:"text-sm font-medium",children:"All projects already added"}),n.jsx("p",{className:"text-muted-foreground mt-1 text-xs",children:"See them on the Agents tab."})]}),z&&!ee&&n.jsxs("div",{className:"rounded-xl border border-dashed p-8 text-center",children:[n.jsx("p",{className:"text-sm font-medium",children:O?"No new projects found":"No projects found"}),n.jsx("p",{className:"text-muted-foreground mt-1 text-xs",children:O?"They’re already added. See the Agents tab.":"Try a deeper scan or other folders."})]}),z&&B.length>0&&n.jsxs(n.Fragment,{children:[n.jsx(yj,{count:B.length,onAddAll:ae,disabled:T.size>0}),n.jsx(Ye,{mode:"popLayout",children:B.map(q=>n.jsx(pj,{candidate:q,className:"mb-2",registrationFailed:P.has(q.path),registrationPending:T.has(q.path),onApprove:ne=>void j(ne),onSkip:ne=>v(ne.path),onDeny:ne=>C({path:ne.path},{onSuccess:()=>v(ne.path)})},q.path))})]}),z&&$&&n.jsx("div",{className:"mt-3",children:n.jsx(bj,{agents:p})})]})]})})}function Cj(){const e=Os(),t=rn(f=>f.isOpen)&&!e,s=rn(f=>f.close);u.useEffect(()=>{e&&rn.getState().isOpen&&s()},[e,s]);const r=Pe(),[o,a]=u.useState(0),[i,c]=u.useState(!1),[d,l]=u.useState(!1);t!==d&&(l(t),t&&(a(0),c(!1)));function m(f){f||s()}function h(){if(o>0&&!i){c(!0);return}s(),o>0&&r({...Ne.team()})}const p=`${o} project${o===1?"":"s"} joined`;return n.jsx(vt,{open:t,onOpenChange:m,children:n.jsxs(wt,{className:"max-h-[85vh] !min-h-0 sm:max-w-2xl",children:[n.jsxs(gt,{className:"shrink-0",children:[n.jsx(ot,{children:"Bring in existing projects"}),n.jsx(xt,{children:i?"Your projects are ready in DorkOS.":"Find projects on this computer to add."})]}),i?n.jsx(Et,{className:"mt-2",children:n.jsxs("div",{className:"flex flex-col items-center justify-center gap-3 py-10 text-center","data-testid":"import-complete",children:[n.jsx(Is,{className:"text-primary size-12","aria-hidden":!0}),n.jsx("p",{className:"text-lg font-semibold","data-testid":"import-joined-summary",children:p}),n.jsx("p",{className:"text-muted-foreground text-sm",children:"Manage agents, tasks and chat apps from the Team page."})]})}):n.jsx(Et,{className:"mt-2 overflow-y-auto",children:n.jsx(Sj,{onRegistered:()=>a(f=>f+1)})}),n.jsxs(on,{className:"shrink-0 sm:justify-between",children:[!i&&o>0?n.jsx("span",{className:"text-muted-foreground text-sm","data-testid":"import-joined-count",children:p}):n.jsx("span",{}),n.jsx(F,{onClick:h,"data-testid":"import-done",children:"Done"})]})]})})}function Nj(e){if(typeof e!="object"||e===null)return!1;const t=e;return typeof t.name=="string"&&(t.scope==="global"||t.scope==="project")&&typeof t.at=="string"&&Array.isArray(t.actions)&&(t.errors===void 0||Array.isArray(t.errors)&&t.errors.every(s=>typeof s=="string"))}function Aj(){const e=Xm(s=>s.record),t=Ib();fe("marketplace_dev_link_reloaded",s=>{Nj(s)&&(e(s),t())})}function Ej(){const e=le();fe("relay_bindings_changed",()=>{e.invalidateQueries({queryKey:[...vb]})})}const ti="inbox",Ij="open";function Rj({blocked:e=!1}={}){const t=Un()[ti],s=oo(),r=t!==void 0,o=t==null?"":String(t).trim();u.useEffect(()=>{!r||!s||(o&&!e&&Dc(void 0,o===Ij?void 0:{focus:o}),s({search:a=>({...a,[ti]:void 0}),replace:!0}))},[r,o,e,s]),u.useEffect(()=>{e&&Jm()},[e])}class ni extends u.Component{constructor(){super(...arguments);wn(this,"state",{hasError:!1})}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(s,r){console.error("[RightPanel] Tab component error:",s,r)}componentDidUpdate(s){s.tabId!==this.props.tabId&&this.state.hasError&&this.setState({hasError:!1})}render(){return this.state.hasError?n.jsx("div",{className:"flex h-full items-center justify-center p-4",children:n.jsx("p",{className:"text-muted-foreground text-sm",children:"This panel stopped working. Switch tabs to try again."})}):this.props.children}}const si=new Set(["agent-profile","profile","files","room","computer"]),ri=new Set(["pulse","session","canvas","browser","local-browser","terminal"]),Tj={};function Dj(e,t){var Pt,U,ke;const s=L(A=>A.activeRightPanelTab),r=L(A=>A.setActiveRightPanelTab),o=L(A=>A.rightPanelLayoutKey),a=L(A=>A.selectedCwd),i=L(A=>A.explicitAgentPath),c=L(A=>A.sessionId),[d]=Oc(),l=t==="/session"?d:null,m=l?`chat/${encodeURIComponent(l)}`:"human",{data:h}=vy(e.some(A=>A.id==="local-browser")),p=(h==null?void 0:h.status)==="connected"&&h.connectionId&&h.sessionId===l?h:null,f=p?`resource/browser/${m}/${encodeURIComponent(p.connectionId)}`:"local-browser",g=L(A=>A.roomCanvasLiveRoomId),x=L(A=>A.openDocuments),y=L(A=>g?A.roomCanvasDocuments[g]:void 0),b=L(A=>g?A.roomCanvasUnread[g]:void 0),C=L(A=>g?A.roomCanvasPresence[g]:void 0),k=Mc(g),I=ie(),v=L(A=>{var W;return g?(W=A.roomCanvasActive[g])==null?void 0:W.canvas:A.activeCanvasDocumentId}),E=L(A=>{var W;return g?(W=A.roomCanvasActive[g])==null?void 0:W.browser:A.activeBrowserDocumentId}),R=L(A=>A.activateCanvasDocument),_=L(A=>A.activateRoomCanvasDocument),D=ca(A=>A.chrome),P=`${c??""}:${a}`,T=(D==null?void 0:D.scope)===P?D:null,[j,w]=u.useState(null);u.useEffect(()=>{if((j==null?void 0:j.scope)!==P||!T)return;const A=j.id?T.tabs.find(W=>`resource/terminal/${W.id}`===j.id):T.tabs.find(W=>W.id===T.activeId);A&&!A.closed&&w(null)},[T,j,P]);const N=yy(),S=g?`room:${g}`:i??o??a??t,M=L(A=>A.canvasSessionId),B=L(A=>A.canvasSessionCwd),O=B!==void 0?M:M??c,$=B!==void 0?B:a,G=g?`room:${g}`:Zm(O,$),ee=g?`room:${g}`:nh(O,$),z=L(A=>A.panelViewPreferences)??Tj,V=L(A=>A.updatePanelViewPreference),ae=L(A=>A.reopenPanelResourceView),pe=u.useMemo(()=>new Set(Object.values(z).flatMap(A=>A.closed)),[z]),Q=z[S]??{opened:[],closed:[]},q=((Pt=N.data)==null?void 0:Pt.cwd)!=null&&(i?N.data.cwd.replace(/\/workspace\/?$/,"")===i:N.data.cwd===a)&&N.data.phase!=="disabled"&&N.data.phase!=="unsupported",ne=u.useMemo(()=>e.filter(A=>A.id!=="computer"||q),[e,q]),ve=A=>V==null?void 0:V(S,A),se=A=>{var W;return((W=Re.find(Z=>Z.id===A))==null?void 0:W.resource)==="browser"},Y=A=>{var W;return se(A)?A:(W=Re.find(Z=>Z.id===A))!=null&&W.resource?`${G}:${A}`:A},he=A=>{var W;return((W=Re.find(Z=>Z.id===A))==null?void 0:W.resource)==="document"?[Y(A),`${ee}:${A}`]:[Y(A)]},ge=A=>{var W;return((W=Re.find(Z=>Z.id===A))==null?void 0:W.resource)==="document"},Ve=A=>A==="profile"&&t==="/session",Qe=A=>!Ve(A)&&he(A).some(W=>ge(A)||se(A)?pe.has(W):Q.closed.includes(W)),Re=ne.flatMap(A=>{const W=A.id;if(W==="local-browser"){if(!p)return[{...A,category:W,title:"Browser"}];const Z=p.tabs.find(xe=>xe.id===p.selectedTabId),oe=p.mode==="embedded"?"DorkOS browser":"New browser window";return[{...A,category:W,resource:"browser",id:f,title:(Z==null?void 0:Z.title)||oe,icon:gs}]}if(W==="browser"||W==="canvas"){const Z=g?eh(y??[],W):th(x??[],W);if(Z.length)return Z.map(oe=>{var xe,et,Se;return{...A,category:W,resource:"document",id:`resource/${oe.id}`,title:"title"in oe&&oe.title||oe.sourceLabel||A.title,icon:W==="browser"?gs:wy,activate:()=>{g?_(g,oe.id):R(oe.id)},..."authorId"in oe?{author:(et=(xe=k.data)==null?void 0:xe.members.find(ze=>ze.author.id===oe.authorId))==null?void 0:et.author,unread:(Se=b==null?void 0:b[W])==null?void 0:Se.includes(oe.id),pinned:oe.pinned,watchers:Object.entries(C??{}).filter(([ze,J])=>{var Ce;return J===oe.id&&ze!==((Ce=k.data)==null?void 0:Ce.viewerAuthorId)}).flatMap(([ze])=>{var J,Ce;return((Ce=(J=k.data)==null?void 0:J.members.find(St=>St.author.id===ze))==null?void 0:Ce.author)??[]})}:{}}})}return W==="terminal"&&(T!=null&&T.tabs.length)?T.tabs.map(Z=>({...A,category:W,resource:"terminal",id:`resource/terminal/${Z.id}`,title:Z.title,closed:Z.closed,icon:_c,activate:oe=>T.activate(Z.id,oe)})):[{...A,category:W,...W==="browser"?{title:"Page previews"}:{},...Ve(W)?{permanent:!0}:{}}]}),Xe=new Set;if(!g){const A=(x??[]).filter(W=>W.id.startsWith("pending:")&&Qe(`resource/${W.id}`));for(const W of x??[])W.id.startsWith("pending:")||W.openedHere||A.some(Z=>{var oe;return(oe=Z.pendingCandidateIds)==null?void 0:oe.includes(W.id)})&&Xe.add(`resource/${W.id}`)}const te=Re.some(A=>si.has(A.category)||!ri.has(A.category)&&!A.isGlobal),ye=Re.filter(A=>(!A.closed||(j==null?void 0:j.scope)===P&&j.id===A.id)&&!Qe(A.id)&&!Xe.has(A.id)&&(si.has(A.category)||!ri.has(A.category)||A.resource||A.extensionId||Q.opened.includes(A.category)||A.category===s||!te&&A.isGlobal&&A.category!=="local-browser"));if(s==="terminal"&&(j==null?void 0:j.scope)===P&&j.id===null&&!ye.some(A=>A.category==="terminal")){const A=ne.find(W=>W.id==="terminal");A&&ye.push({...A,category:"terminal"})}const we=s==="terminal"?`resource/terminal/${T==null?void 0:T.activeId}`:s==="local-browser"?f:s==="browser"?`resource/${E}`:s==="canvas"?`resource/${v}`:s,jt=((U=ye.find(A=>A.id===we))==null?void 0:U.id)??((ke=ye.find(A=>A.category===s))==null?void 0:ke.id)??null,Ge=g?y==null?void 0:y.find(A=>`resource/${A.id}`===we):x==null?void 0:x.find(A=>`resource/${A.id}`===we),H=Ge?`${Ge.rev}:${Ge.lastActiveAt}`:null,de=L(A=>A.requestedRightPanel),je=(A,W="pointer")=>{var oe;const Z=Re.find(xe=>xe.id===A);Z&&(ve(xe=>({opened:[...new Set([...xe.opened,Z.category])].slice(-100),closed:xe.closed.filter(et=>!he(A).includes(et))})),(Z.resource==="document"||Z.resource==="browser")&&(ae==null||ae(he(A))),w(Z.resource==="terminal"?{scope:P,id:Z.id}:null),(oe=Z.activate)==null||oe.call(Z,W),r(Z.category))},Je=A=>{var et;if(Ve(A))return;const W=x==null?void 0:x.find(Se=>Se.id.startsWith("pending:")&&`resource/${Se.id}`===A),Z=W?ye.filter(Se=>{var ze;return!((ze=W.pendingCandidateIds)!=null&&ze.some(J=>{var Ce;return`resource/${J}`===Se.id&&!((Ce=x==null?void 0:x.find(St=>St.id===J))!=null&&Ce.openedHere)}))}):ye,oe=Z[Z.findIndex(Se=>Se.id===A)+1]??Z[Z.findIndex(Se=>Se.id===A)-1],xe=Re.find(Se=>Se.id===A);if(w(null),(xe==null?void 0:xe.resource)==="terminal"&&(T!=null&&T.hide))T.hide(A.slice(18));else{const Se=ze=>({...ze,closed:[...new Set([...ze.closed,Y(A)])].slice(-100)});(xe==null?void 0:xe.resource)==="document"?V==null||V(`documents:${G}`,Se):(xe==null?void 0:xe.resource)==="browser"?V==null||V(`browsers:${m}`,Se):ve(Se)}A===jt&&((et=oe==null?void 0:oe.activate)==null||et.call(oe,"keyboard"),r((oe==null?void 0:oe.category)??null))};u.useEffect(()=>{if(!s)return;const A=we?he(we):[];!Q.closed.includes(s)&&(!we||!Qe(we))||(ve(W=>({...W,closed:W.closed.filter(Z=>Z!==s&&!A.includes(Z))})),we&&(ge(we)||se(we))&&(ae==null||ae(A)))},[s,we,H,de,G,m,S]);const Ze=s==="browser"?E:s==="canvas"?v:null,Ie=g?y==null?void 0:y.find(A=>A.id===Ze):x==null?void 0:x.find(A=>A.id===Ze),kt=async A=>{try{await A()}catch{ce.error("Couldn’t update the canvas.")}},_t=A=>{kt(()=>g?I.openRoomCanvasDocument(g,A):L.getState().openCanvasDocument(A)),r(A.type==="url"?"browser":"canvas")};return{available:ne,allViews:Re,visible:ye,activeId:jt,activate:je,closeView:Je,terminal:T,createTerminal:ne.some(A=>A.id==="terminal")?()=>{w({scope:P,id:null}),ve(A=>({opened:[...new Set([...A.opened,"terminal"])].slice(-100),closed:A.closed.filter(W=>W!=="terminal")})),T?T.create():ca.getState().requestCreate(P),r("terminal")}:void 0,createBrowser:ne.some(A=>A.id==="browser")?()=>_t({type:"url",url:ro.site,title:"Web Page"}):void 0,createDocument:ne.some(A=>A.id==="canvas")?()=>_t({type:"markdown",content:`# Untitled
72
-
73
- Start writing…`,title:"Document"}):void 0,removeDocument:Ie?()=>void kt(()=>g?I.closeRoomCanvasDocument(g,Ie.id):L.getState().closeCanvasDocument(Ie.id)):void 0,pinDocument:g&&Ie?()=>void kt(()=>I.updateRoomCanvasDocument(g,Ie.id,{pinned:!Ie.pinned})):void 0,documentPinned:(Ie==null?void 0:Ie.pinned)??!1}}function Oj({views:e,activeId:t,onActivate:s,onCreateTerminal:r,onStopTerminal:o,onCreateBrowser:a,onCreateDocument:i,onRemoveDocument:c,onPinDocument:d,documentPinned:l}){const m=e.find(p=>p.resource==="browser")??e.find(p=>p.category==="local-browser"),h=e.filter(p=>p.category!=="local-browser"||p===m);return n.jsxs(fo,{children:[n.jsx(po,{asChild:!0,children:n.jsx(F,{variant:"ghost",size:"icon-md","aria-label":"Add view",className:"size-11 shrink-0 lg:size-7",children:n.jsx(Dt,{className:"size-3.5"})})}),n.jsxs(go,{align:"end",className:"max-h-[70dvh] min-w-48 overflow-y-auto [&_[role=menuitem]]:min-h-11 lg:[&_[role=menuitem]]:min-h-0",children:[n.jsx(Pc,{children:"Views"}),h.map(p=>n.jsxs(qe,{"aria-current":p.id===t?"true":void 0,"data-view-category":p.category,"aria-label":p.category==="local-browser"?"Browser":void 0,onSelect:()=>s(p.id),children:[n.jsx(Kn,{icon:p.icon}),n.jsx("span",{className:"max-w-64 truncate",children:p.category==="local-browser"?"Browser":p.title}),p.category==="local-browser"&&p.resource==="browser"&&n.jsx("span",{"aria-hidden":"true",className:"text-muted-foreground max-w-40 truncate",children:p.title}),p.id===t&&n.jsx("span",{"aria-hidden":"true",className:"ml-auto",children:"✓"})]},p.id)),r&&n.jsxs(n.Fragment,{children:[n.jsx(os,{}),n.jsxs(qe,{onSelect:r,children:[n.jsx(_c,{}),"New terminal"]})]}),a&&n.jsx(qe,{onSelect:a,children:"New page preview"}),i&&n.jsx(qe,{onSelect:i,children:"New document"}),d&&n.jsxs(n.Fragment,{children:[n.jsx(os,{}),n.jsx(qe,{onSelect:d,children:l?"Unpin document":"Pin document"})]}),c&&n.jsx(qe,{onSelect:c,children:"Remove document"}),o&&n.jsxs(n.Fragment,{children:[n.jsx(os,{}),n.jsx(qe,{onSelect:o,children:"Stop terminal"})]})]})]})}function Mj({active:e,hidden:t,here:s,saved:r}){const{setPlacement:o}=fy(),a=L(x=>x.setActiveRightPanelTab),i=ct(),c=Ms(),d=jd(),l=L(x=>x.setRightPanelOpen),m=xo(),h=sh(s)!==null,p=x=>Fc(r.get(x.id),x.declaredPlacement),f=(e==null?void 0:e.extensionId)!=null?m.find(x=>x.extensionId===e.extensionId&&x.path==="")??m.find(x=>x.extensionId===e.extensionId)??null:null,g=h?t:[];return!e&&g.length===0?null:n.jsxs(fo,{children:[n.jsx(po,{asChild:!0,children:n.jsx(F,{variant:"ghost",size:"icon-md","aria-label":"Add-on tab options",className:"size-11 shrink-0 lg:size-7","data-testid":"mini-app-tab-menu",children:n.jsx(rh,{className:"size-3.5"})})}),n.jsxs(go,{align:"end",className:"max-h-[70dvh] min-w-48 overflow-y-auto [&_[role=menuitem]]:min-h-11 lg:[&_[role=menuitem]]:min-h-0",children:[e&&n.jsxs(n.Fragment,{children:[f&&c&&n.jsxs(qe,{onSelect:()=>{d&&l(!1),c({href:Lc(f.extensionId,f.path)})},children:[n.jsx(oh,{}),"Open full page"]}),h&&n.jsxs(qe,{onSelect:()=>o(e.id,ih(p(e),s)),children:[n.jsx(ah,{}),"Hide here"]}),n.jsxs(qe,{onSelect:()=>i.open("extensions",e.extensionId),children:[n.jsx(ch,{}),"Where it shows…"]})]}),e&&g.length>0&&n.jsx(os,{}),g.length>0&&n.jsxs(n.Fragment,{children:[n.jsx(Pc,{className:"text-muted-foreground text-xs font-normal",children:"Show here"}),g.map(x=>n.jsxs(qe,{onSelect:()=>{o(x.id,lh(p(x),s)),a(x.id)},children:[x.icon?n.jsx(Kn,{icon:x.icon}):n.jsx(Dt,{}),x.title]},x.id))]})]})]})}const _j={canvas:"canvas",browser:"browser"};function Pj(e,t){return t==="attention"?`${e}, something needs you`:e}function Lj({contributionId:e}){const t=_j[e],s=L(o=>{var i;const a=o.roomCanvasLiveRoomId;return a===null||t===void 0?!1:(((i=o.roomCanvasUnread[a])==null?void 0:i[t].length)??0)>0});return dh(e)==="attention"?n.jsx("span",{"data-slot":"right-panel-tab-marker","aria-hidden":!0,className:"bg-status-warning-dot size-1.5 shrink-0 rounded-full"}):s?n.jsx("span",{"data-slot":"right-panel-tab-unread","aria-hidden":!0,className:"bg-primary size-1.5 shrink-0 rounded-full"}):null}const Uo="right-panel-content";function ls(e){return`right-panel-tab-${e}`}function Fj({contributions:e,actions:t,activeId:s,onActivate:r,onCloseView:o}){const a=L(d=>d.setRightPanelOpen),i=L(d=>d.activeRightPanelTab),c=L(d=>d.setActiveRightPanelTab);return n.jsxs("div",{className:"flex w-full items-center justify-between px-3 py-2","data-slot":"right-panel-header",children:[e.length>1||r?n.jsx($j,{contributions:e,activeTab:s===void 0?i:s,onActivate:r??c,onCloseView:o}):e.length===1?n.jsxs("div",{className:"text-foreground flex items-center gap-1.5 px-1 text-xs font-medium",children:[n.jsx(Kn,{icon:e[0].icon,className:"text-muted-foreground size-3.5"}),n.jsx("span",{children:e[0].title})]}):n.jsx("div",{}),n.jsxs("div",{className:"flex shrink-0 items-center gap-1 pl-1",children:[t,n.jsx(F,{variant:"ghost",size:"icon-md","aria-label":"Close panel",className:"size-11 shrink-0 lg:size-7",onClick:()=>a(!1),children:n.jsx(Be,{className:"size-3.5"})})]})]})}function $j({contributions:e,activeTab:t,onActivate:s,onCloseView:r}){const o=u.useRef(null),a=u.useRef("keyboard"),i=u.useRef(null),c=$c(p=>p.tabMarkers),d=Bc(o,"horizontal"),l=u.useCallback(()=>{const p=o.current;return!p||!t?null:p.querySelector(`#${CSS.escape(ls(t))}`)},[t]),m=u.useCallback(()=>{const p=o.current,f=l();!p||!f||zc(p,f)},[l]),h=e.map(p=>p.id).join(",");return u.useEffect(()=>{if(m(),typeof ResizeObserver>"u")return;const p=new ResizeObserver(m);for(const f of[o.current,i.current,l()])f&&p.observe(f);return()=>p.disconnect()},[m,l,h]),n.jsx(ud,{asChild:!0,value:t??"",onValueChange:p=>{s(p,a.current),a.current="keyboard"},children:n.jsxs("div",{className:"relative min-w-0 flex-1",children:[n.jsx("div",{ref:o,onScroll:d.onScroll,"data-testid":"right-panel-tabs-scroller",className:"-my-1 overflow-x-auto overflow-y-hidden py-1 max-lg:snap-x max-lg:snap-proximity max-lg:scroll-px-6 max-lg:pe-6",children:n.jsx(md,{ref:i,responsive:!1,"aria-label":"Right panel tabs",className:"bg-accent/60 h-auto justify-start gap-0.5 rounded-lg p-0.5",children:e.map(p=>{var g,x;const f=p.id===t;return n.jsxs("div",{className:"group/view relative flex shrink-0 items-center py-2 max-lg:snap-start md:py-0",children:[n.jsxs(xn,{children:[n.jsx(bn,{asChild:!0,children:n.jsxs(is,{value:p.id,"data-view-category":p.category??p.id,onPointerDown:()=>{a.current="pointer"},onKeyDown:y=>{var b;if(a.current="keyboard",y.key==="Delete"&&r&&!p.permanent){y.preventDefault();const C=e.findIndex(v=>v.id===p.id),k=e[C+1]??e[C-1],I=(b=y.currentTarget.closest('[data-slot="right-panel-header"]'))==null?void 0:b.querySelector('[aria-label="Add view"]');r(p.id),requestAnimationFrame(()=>{var v;k?(v=document.getElementById(ls(k.id)))==null||v.focus():I==null||I.focus()})}},"aria-label":[Pj(p.title,c[p.id]??null),p.author&&`Posted by ${p.author.displayName}`,p.unread&&"Unread",((g=p.watchers)==null?void 0:g.length)&&`${p.watchers.map(y=>y.displayName).join(", ")} ${p.watchers.length===1?"is":"are"} looking at this.`].filter(Boolean).join(", "),id:ls(p.id),"aria-controls":f?Uo:void 0,className:K("text-muted-foreground hover:text-foreground text-3xs shrink-0 gap-1.5 rounded-md px-2.5 py-1",f&&"bg-background text-foreground shadow-sm"),children:[n.jsx(Kn,{icon:p.icon,className:"size-3.5"}),p.author&&n.jsx("span",{title:`Posted by ${p.author.displayName}`,children:n.jsx(fs,{size:"xs",kind:p.author.kind,color:p.author.color??ms(p.author.id),emoji:p.author.emoji,imageUrl:p.author.imageUrl,fallback:Ar(p.author.displayName)})}),n.jsx("span",{className:"max-w-28 truncate",children:p.title}),p.pinned&&n.jsx("span",{"aria-label":"Pinned",children:"·"}),p.unread&&n.jsx("span",{"data-testid":"canvas-tab-unread","data-slot":"canvas-tab-unread","aria-label":"Unread",className:"bg-primary size-1.5 rounded-full"}),!!((x=p.watchers)!=null&&x.length)&&n.jsxs(n.Fragment,{children:[n.jsxs("span",{"data-slot":"canvas-tab-watchers","aria-hidden":!0,className:"flex shrink-0 -space-x-1",children:[p.watchers.slice(0,3).map(y=>n.jsx(fs,{size:"xs",className:"ring-background text-3xs size-3.5 ring-1",kind:y.kind,color:y.color??ms(y.id),emoji:y.emoji,imageUrl:y.imageUrl,badge:null,fallback:Ar(y.displayName)},y.id)),p.watchers.length>3&&n.jsxs("span",{className:"text-3xs",children:["+",p.watchers.length-3]})]}),n.jsxs("span",{className:"sr-only",children:[p.watchers.map(y=>y.displayName).join(", ")," ",p.watchers.length===1?"is":"are"," looking at this."]})]}),n.jsx(Lj,{contributionId:p.id})]})}),n.jsx(yn,{side:"bottom",children:p.title})]}),r&&f&&!p.permanent&&n.jsx(F,{variant:"ghost",size:"icon-sm",tabIndex:-1,"aria-label":`Close ${p.title} view`,className:"relative size-6 after:absolute after:inset-x-0 after:-inset-y-2 md:after:hidden",onClick:()=>r(p.id),children:n.jsx(Be,{className:"size-3"})})]},p.id)})})}),d.start&&n.jsx("div",{"aria-hidden":!0,"data-testid":"right-panel-tabs-fade-start",className:"from-sidebar via-sidebar/70 pointer-events-none absolute inset-y-0 left-0 w-6 bg-gradient-to-r to-transparent"}),d.end&&n.jsx("div",{"aria-hidden":!0,"data-testid":"right-panel-tabs-fade-end",className:"from-sidebar via-sidebar/70 pointer-events-none absolute inset-y-0 right-0 w-6 bg-gradient-to-l to-transparent"})]})})}const Br="app-shell-right-panel",Bj=40,zj=320,au=20,Uj=50;function Kj(e){if(e<=0)return au;const t=zj/e*100;return Math.min(Math.round(t*10)/10,Uj)}function Hj(){const[e,t]=u.useState(au);return u.useLayoutEffect(()=>{const s=document.querySelector(`[data-panel-group-id="${Br}"]`);if(!(s instanceof HTMLElement))return;const r=()=>t(Kj(s.offsetWidth));r();const o=new ResizeObserver(r);return o.observe(s),()=>o.disconnect()},[]),{minPct:e,defaultPct:Math.max(Bj,e)}}function Wj(e,t){var f;const s=uh(e),r=mh(),o=L(g=>g.selectedCwd),a=s==="session",i=Uc(a?o:null),c=r.status==="loading"||a&&o!==null&&i.isPending,d=r.status==="ready"&&!t?r.roomId:null,l=a?((f=i.data)==null?void 0:f.id)??null:null,m=u.useMemo(()=>Gj(s,d,l,a),[s,d,l,a]),[h,p]=u.useState(null);return!c&&h!==m&&p(m),c?{status:"pending",last:h}:{status:"ready",here:m}}function Gj(e,t,s,r){const o={page:e};return t&&(o.roomId=t),r&&(o.agentId=s),o}const qj="cubic-bezier(0, 0, 0.2, 1)",Yj="cubic-bezier(0.4, 0, 1, 1)";function oi(e,t){return`${e} 300ms ${t?qj:Yj}`}const Vj=new Set(["pulse","files"]);function Qj(e){e.preventDefault();const t=document.getElementById(Uo);t&&!t.contains(document.activeElement)&&t.focus({preventScroll:!0})}function Xj({pathname:e,isRemoteCommunityRoom:t=!1}){var se;const s=L(Y=>Y.rightPanelOpen),r=L(Y=>Y.setRightPanelOpen),o=L(Y=>Y.activeRightPanelTab),a=L(Y=>Y.setActiveRightPanelTabView),i=jd(),c=_e(),d=Hd(),l=u.useRef(null),[m,h]=u.useState(!1),[p,f]=u.useState(!1);u.useEffect(()=>{const Y=requestAnimationFrame(()=>f(!0));return()=>cancelAnimationFrame(Y)},[]);const g=ie(),x=L(Y=>Y.currentAgentId),y=L(Y=>Y.selectedCwd),b=L(Y=>Y.explicitAgentPath),C=by(),k=(C==null?void 0:C.kind)??null,I=(C==null?void 0:C.showSessions)??!1,v=u.useMemo(()=>k===null?null:{kind:k,showSessions:I},[k,I]),E=_s("right-panel"),R=u.useMemo(()=>E.filter(Y=>!Y.visibleWhen||Y.visibleWhen({pathname:e,transport:g,agentId:x,cwd:y,explicitAgentPath:b,isRemoteCommunityRoom:t,directMessage:v})),[E,e,g,x,y,b,t,v]),_=Wj(e,t),D=_.status==="ready"?_.here:_.last,P=py(),T=Me().data!==void 0,j=u.useMemo(()=>new Map(P.map(Y=>[Y.tab,Y])),[P]),{visibleContributions:w,hiddenMiniAppTabs:N}=u.useMemo(()=>{const Y=[],he=[];for(const ge of R)ge.extensionId?D&&hh(Fc(j.get(ge.id),ge.declaredPlacement),D)?Y.push(ge):he.push(ge):Y.push(ge);return{visibleContributions:Y,hiddenMiniAppTabs:he}},[R,D,j]),S=Dj(w,e),M=S.visible,O=`${L(Y=>Y.sessionId)??""}:${y}`;u.useEffect(()=>{if(_.status!=="pending"&&M.length>0&&!M.some(he=>he.category===o)){const he=M.find(ge=>!ge.isGlobal);a((he??M[0]).category)}},[M,o,a,_.status]);const $=s,{minPct:G,defaultPct:ee}=Hj();u.useEffect(()=>{const Y=l.current;Y&&($&&Y.isCollapsed()?Y.expand(ee):!$&&Y.isExpanded()&&Y.collapse())},[$,ee]);const z=S.available.find(Y=>Y.id===o&&M.some(he=>he.category===Y.id)),V=S.available.find(Y=>Y.id==="terminal"),ae=V==null?void 0:V.component,pe=S.terminal!==null||o==="terminal",Q=z==null?void 0:z.component,q=z==null?void 0:z.headerActions,ne=n.jsxs(n.Fragment,{children:[n.jsx(Fj,{contributions:M,activeId:S.activeId,onActivate:S.activate,onCloseView:S.closeView,actions:n.jsxs(n.Fragment,{children:[n.jsx(Oj,{views:S.allViews,activeId:S.activeId,onActivate:S.activate,onCreateBrowser:S.createBrowser,onCreateDocument:S.createDocument,onRemoveDocument:S.removeDocument,onPinDocument:S.pinDocument,documentPinned:S.documentPinned,onCreateTerminal:S.createTerminal,onStopTerminal:o==="terminal"&&((se=S.terminal)!=null&&se.activeId)?()=>{var Y;return(Y=S.terminal)==null?void 0:Y.stop(S.terminal.activeId,"pointer")}:void 0}),q?n.jsx(u.Suspense,{fallback:null,children:n.jsx(q,{})}):null,_.status==="ready"&&T&&n.jsx(Mj,{active:z!=null&&z.extensionId?z:null,hidden:N,here:_.here,saved:j})]})}),(C==null?void 0:C.kind)==="group"&&s&&n.jsx(Xw,{members:C.members}),n.jsx(xy,{slot:"right-panel",onReview:()=>Dc(),className:"border-b px-2 py-1.5"}),n.jsx("div",{className:"min-h-0 flex-1 overflow-hidden outline-none",...o===la?{tabIndex:-1}:{},...S.activeId&&M.some(Y=>Y.category===o)?{id:Uo,role:"tabpanel","aria-labelledby":ls(S.activeId)}:{},children:n.jsx(ni,{tabId:o,children:n.jsx(u.Suspense,{fallback:null,children:n.jsxs(fh,{value:!0,children:[s&&o!=="terminal"&&Q?n.jsx(Q,{}):null,ae&&pe&&n.jsx("div",{hidden:o!=="terminal"||!s||!z,className:"h-full",children:n.jsx(ph,{value:o==="terminal"&&s&&!!z,children:n.jsx(ni,{tabId:o,children:n.jsx(ae,{})})})},O),!z&&n.jsx("div",{className:"text-muted-foreground flex h-full items-center justify-center p-6 text-sm",children:"Add a view to this panel."})]})})})})]});if(i)return $?n.jsx(gh,{open:!0,onOpenChange:Y=>!Y&&r(!1),children:n.jsxs(xh,{showCloseButton:!1,...o===la?{onOpenAutoFocus:Qj}:{},style:{top:d.top,bottom:"auto",height:d.height,maxHeight:d.height},className:K("bg-sidebar text-sidebar-foreground flex w-full flex-col gap-0 pt-[env(safe-area-inset-top)] pr-[env(safe-area-inset-right)] pb-[env(safe-area-inset-bottom)] pl-[env(safe-area-inset-left)]",c&&"sm:max-w-full",c&&o&&Vj.has(o)&&"!bottom-auto !h-auto max-h-dvh overflow-y-auto"),children:[n.jsxs(bh,{className:"sr-only",children:[n.jsx(yh,{children:"Panel"}),n.jsx(vh,{children:"Right panel content."})]}),ne]})}):null;const ve=p&&!m;return n.jsxs(n.Fragment,{children:[n.jsx(my,{"aria-label":"Resize right panel",disabled:!$,onDragging:h,gripStyle:{opacity:$?1:0,pointerEvents:$?"auto":"none",...ve&&{transition:oi("opacity",$)}}}),n.jsx(Kc,{ref:l,id:"right-panel",order:2,defaultSize:$?ee:0,minSize:G,collapsible:!0,collapsedSize:0,onCollapse:()=>{p&&r(!1)},onExpand:()=>{s||r(!0)},style:ve?{transition:oi("flex-grow",$)}:void 0,children:n.jsx("div",{inert:!$,className:"bg-sidebar text-sidebar-foreground flex h-full flex-col overflow-hidden border-l",children:ne})})]})}function Jj(){const e=L(t=>t.toggleRightPanel);u.useEffect(()=>{const t=s=>{(s.metaKey||s.ctrlKey)&&s.key==="."&&(s.preventDefault(),e())};return document.addEventListener("keydown",t),()=>document.removeEventListener("keydown",t)},[e])}const ai=new WeakMap;let Zj=0;function ek(e){const t=ai.get(e);if(t!==void 0)return t;const s=`bar-${Zj++}`;return ai.set(e,s),s}function tk(e){var t;for(let s=e.length-1;s>=0;s--){const r=(t=e[s].staticData)==null?void 0:t.header;if(r)return{key:ek(r),Header:r}}return null}function nk(e){const t=e.startsWith("/")?e:`/${e}`;if($e()){const s=t.slice(1);if(s.length>0&&!s.startsWith("?")&&!s.startsWith("#"))return`dorkos://${s}`}return`${window.location.origin}${t}`}const sk="/";function Ko(){const e=Xt();return u.useMemo(()=>{const t=()=>bo(e),s=a=>{ue.getState().selectTab(a),t()},r=a=>{const i=ue.getState().tabs;a(),Hc(i,ue.getState().tabs)},o=a=>{const{tabs:i}=ue.getState(),c=i[a];c&&s(c.id)};return{activate:s,activateIndex:o,activateLast:()=>o(ue.getState().tabs.length-1),activateRelative:a=>{const{tabs:i,activeTabId:c}=ue.getState();if(i.length<2)return;const d=i.findIndex(h=>h.id===c),m=(((d===-1?0:d)+a)%i.length+i.length)%i.length;s(i[m].id)},close:a=>{r(()=>ue.getState().closeTab(a)),t()},closeActive:()=>{const{tabs:a,activeTabId:i}=ue.getState();if(!i)return!1;const c=a.length;r(()=>ue.getState().closeTab(i));const d=ue.getState().tabs.length<c;if(d)try{t()}catch(l){console.error("[dorkos:tabs] could not follow a closed tab",l)}return d},create:()=>jh(e,sk),togglePin:a=>{const i=ue.getState().tabs.find(c=>c.id===a);i&&ue.getState().setTabPinned(a,!i.pinned)},duplicate:a=>{ue.getState().duplicateTab(a),t()},closeOthers:a=>{r(()=>ue.getState().closeOtherTabs(a)),t()},reorder:(a,i)=>ue.getState().moveTab(a,i),reopenClosed:a=>{wh(e,a).catch(i=>{console.error("[dorkos:tabs] could not reopen a closed tab",i)})}}},[e])}const rk={start:["Space"],cancel:["Escape"],end:["Space","Enter","Tab"]},ok=4,ak={draggable:"Press Space to move this tab. Arrows move it, Space drops it, Escape cancels."};function ik(e){return t=>{const s=e(String(t.active.id));return Wc({...t,droppableContainers:t.droppableContainers.filter(r=>e(String(r.id))===s)})}}class ck extends Map{getEnabled(){return[...this.values()].filter(t=>!t.disabled)}toArray(){return[...this.values()]}}function lk(e){return(t,s)=>{const{context:r}=s;if(!r.active)return Er(t,s);const o=e(String(r.active.id)),a=new ck;for(const i of r.droppableContainers.toArray())e(String(i.id))===o&&a.set(i.id,i);return Er(t,{...s,context:{...r,droppableContainers:a}})}}function dk(e){return e.length===0?null:{left:Math.min(...e.map(t=>t.left)),right:Math.max(...e.map(t=>t.right))}}function uk(e){return({transform:t,activeNodeRect:s})=>{const r=e();if(!r||!s)return t;const o=r.left-s.left,a=r.right-s.right;return{...t,x:Math.min(Math.max(t.x,o),a)}}}function mk(e,t,s){if(s==null)return null;const r=e.indexOf(String(t)),o=e.indexOf(String(s));return r===-1||o===-1||r===o?null:[r,o]}function hk(e){const{nameOf:t,indexOf:s,count:r}=e,o=a=>`position ${s(a)+1} of ${r()}`;return{onDragStart:({active:a})=>`Picked up ${t(String(a.id))}.`,onDragOver:({active:a,over:i})=>i?`${t(String(a.id))} is over ${o(String(i.id))}.`:void 0,onDragEnd:({active:a,over:i})=>i?`${t(String(a.id))} dropped at ${o(String(i.id))}.`:`${t(String(a.id))} put back.`,onDragCancel:({active:a})=>`Move cancelled. ${t(String(a.id))} put back.`}}const fk=500;function pk(e){const t=Hn(new Date(e).toISOString());return`Last active ${t==="Just now"?"just now":t}`}function gk({identity:e,className:t}){return n.jsxs("div",{className:K("flex min-w-0 flex-col gap-1.5 text-xs",t),children:[n.jsxs("div",{className:"flex min-w-0 items-start gap-2",children:[n.jsx(yo,{icon:e.icon,className:"mt-px"}),n.jsxs("p",{className:"min-w-0 font-medium break-words",children:[Ir(e)===e.primary?e.primary:n.jsxs(n.Fragment,{children:[n.jsx("span",{"aria-hidden":"true",children:Ir(e)}),n.jsx("span",{className:"sr-only",children:e.primary})]}),e.secondary&&n.jsxs("span",{className:"text-muted-foreground font-normal",children:[" · ",e.secondary]})]})]}),e.origin&&n.jsx("p",{className:"text-muted-foreground",children:e.origin}),e.statusSentence&&n.jsxs("p",{className:"flex items-start gap-1.5",children:[n.jsx(vo,{identity:e,className:"mt-[5px]"}),n.jsx("span",{children:e.statusSentence})]}),e.lastActiveAt!==void 0&&!Number.isNaN(e.lastActiveAt)&&n.jsx("p",{className:"text-muted-foreground",children:pk(e.lastActiveAt)})]})}function xk({identity:e,children:t}){return n.jsxs(yd,{openDelay:fk,closeDelay:0,children:[n.jsx(vd,{asChild:!0,children:t}),n.jsx(wd,{side:"bottom",align:"start",sideOffset:6,className:"w-64 p-3",children:n.jsx(gk,{identity:e})})]})}const iu="app-tab-panel";function bk({identity:e,isActive:t,canClose:s,collapseAgent:r=!1,pinned:o=!1,tabProps:a,onClose:i}){const c=Sh(e,{collapseAgent:r}),d=e.emphasized===!0&&!t,l=s&&!o;return n.jsxs("div",{role:"presentation",className:"group relative flex shrink-0",children:[n.jsx(xk,{identity:e,children:n.jsxs("button",{type:"button",role:"tab","aria-selected":t,"aria-controls":t?iu:void 0,"aria-label":Ch(e,{collapseAgent:r}),...a,className:K("focus-ring flex min-w-0 items-center gap-1.5 rounded-md py-1 text-xs transition-colors",o?"px-2":t?"max-w-72 pl-2":"max-w-52 pl-2",!o&&(l?"pr-7":"pr-2"),t?"bg-secondary text-foreground contrast-more:ring-foreground/40 contrast-more:ring-1":d?"text-foreground hover:bg-secondary/50":"text-muted-foreground/80 hover:bg-secondary/50 hover:text-foreground contrast-more:text-muted-foreground"),"data-emphasized":d||void 0,children:[n.jsx(yo,{icon:e.icon}),!o&&n.jsxs("span",{className:"min-w-0 truncate",children:[n.jsx("span",{className:d?"font-semibold":"font-medium",children:c.lead}),c.trail&&n.jsxs("span",{className:"opacity-70",children:[" · ",c.trail]})]}),n.jsx(vo,{identity:e})]})}),l&&i&&n.jsx("button",{type:"button",tabIndex:-1,onClick:()=>i("pointer"),"aria-label":`Close ${e.primary}`,className:K("focus-ring hover:bg-muted absolute top-1/2 right-1 -translate-y-1/2 rounded-sm p-0.5","opacity-0 transition-opacity group-hover:opacity-70 hover:opacity-100",t&&"opacity-70"),children:n.jsx(Be,{className:"size-3"})})]})}function yk({tab:e,isActive:t,canClose:s,pinned:r,tabProps:o,onClose:a}){const i=Ps(e.href),c=kh(i.agentKey);return n.jsx(bk,{identity:i,isActive:t,canClose:s,collapseAgent:c,pinned:r??e.pinned??!1,tabProps:o,onClose:d=>a(e.id,d)})}function vk({href:e,onSelect:t}){const s=Ps(e);return n.jsxs(Lt,{onSelect:t,children:[n.jsx("span",{className:"truncate",children:s.primary}),s.secondary&&n.jsx("span",{className:"text-muted-foreground ml-1.5 truncate",children:s.secondary})]})}function wk({tabId:e,pinned:t,hasOthersToClose:s,canClose:r,actions:o,onClosed:a,children:i}){const c=Nh(),{reopenClosed:d}=o;return n.jsxs(Ah,{children:[n.jsx(Eh,{asChild:!0,children:i}),n.jsxs(Ih,{className:"w-56",onCloseAutoFocus:a?l=>{l.preventDefault(),a()}:void 0,children:[n.jsxs(Lt,{onSelect:()=>o.togglePin(e),children:[t?n.jsx(Rh,{className:"mr-2 size-4"}):n.jsx(Th,{className:"mr-2 size-4"}),t?"Unpin":"Pin"]}),n.jsxs(Lt,{onSelect:()=>o.duplicate(e),children:[n.jsx(Uy,{className:"mr-2 size-4"}),"Duplicate"]}),n.jsxs(Lt,{onSelect:()=>o.copyLink(e),children:[n.jsx(Dh,{className:"mr-2 size-4"}),"Copy link"]}),n.jsx(da,{}),n.jsxs(Lt,{disabled:!s,onSelect:()=>o.closeOthers(e),children:[n.jsx(Oh,{className:"mr-2 size-4"}),"Close others"]}),n.jsxs(Lt,{disabled:!r,onSelect:()=>o.close(e),children:[n.jsx(Be,{className:"mr-2 size-4"}),"Close"]}),d&&n.jsxs(n.Fragment,{children:[n.jsx(da,{}),n.jsxs(Lt,{disabled:c.length===0,onSelect:()=>d(),children:[n.jsx(Gc,{className:"mr-2 size-4"}),"Reopen closed tab",n.jsx("kbd",{className:"text-muted-foreground ml-auto pl-4 text-xs",children:Wt(cn.REOPEN_CLOSED_TAB)})]}),n.jsxs(Mh,{children:[n.jsxs(_h,{disabled:c.length===0,children:[n.jsx(kd,{className:"mr-2 size-4"}),"Recently closed"]}),n.jsx(Ph,{className:"max-h-96 w-64 overflow-y-auto",children:c.map(l=>n.jsx(vk,{href:l.tab.href,onSelect:()=>d({tabId:l.tab.id,closedAt:l.closedAt})},`${l.tab.id}-${l.closedAt}`))})]})]})]})]})}const Ft="data-app-tab-id";function jk({tab:e,isActive:t,canClose:s,tabProps:r,onClose:o,sortable:a,dragActive:i,menu:c,hasOthersToClose:d,onMenuClosed:l}){const m=e.pinned??!1,{setNodeRef:h,setActivatorNodeRef:p,attributes:f,listeners:g,transform:x,transition:y,isDragging:b}=Lh({id:e.id,disabled:!a}),C=g==null?void 0:g.onPointerDown,k=g==null?void 0:g.onKeyDown,I={transform:x?`translate3d(${Math.round(x.x)}px, 0, 0)`:void 0,transition:y??void 0},{ref:v,onKeyDown:E}=r,R=u.useCallback(T=>{v(T),p(T)},[v,p]),_=u.useCallback(T=>{if(c&&(T.key==="ContextMenu"||T.shiftKey&&T.key==="F10")){T.preventDefault();const j=T.currentTarget,w=j.getBoundingClientRect();j.dispatchEvent(new MouseEvent("contextmenu",{bubbles:!0,cancelable:!0,clientX:w.left,clientY:w.bottom}));return}k==null||k(T),!(T.defaultPrevented||i)&&E(T)},[c,k,i,E]),D=u.useMemo(()=>({...r,ref:R,onKeyDown:_,...a?{"aria-describedby":f["aria-describedby"]}:{}}),[r,R,_,a,f]),P=n.jsx("div",{ref:h,role:"presentation",[Ft]:e.id,style:I,onPointerDown:C,className:K("flex shrink-0",b&&"bg-background shadow-soft relative z-10 rounded-md"),children:n.jsx(yk,{tab:e,isActive:t,canClose:s,tabProps:D,onClose:o,pinned:m})});return c?n.jsx(wk,{tabId:e.id,pinned:m,hasOthersToClose:d,canClose:s,actions:c,onClosed:l,children:P}):P}const kk=32;function Sk({tabs:e,activeId:t,onActivate:s,onClose:r,onCreate:o,menu:a,onReorder:i,className:c}){const d=u.useRef(null),l=u.useRef(null),m=u.useRef(null),h=qc(null),p=e.length>1,[f,g]=u.useState(!1),x=u.useMemo(()=>e.map(w=>w.id),[e]),y=$t(e),{collisionDetection:b,coordinateGetter:C,modifiers:k,announcements:I}=u.useMemo(()=>{const w=S=>y.read().findIndex(M=>M.id===S),N=S=>{var M;return((M=y.read().find(B=>B.id===S))==null?void 0:M.pinned)??!1};return{collisionDetection:ik(N),coordinateGetter:lk(N),modifiers:[uk(h.read)],announcements:hk({nameOf:S=>{var M,B,O;return((O=(B=(M=Array.from(document.querySelectorAll(`[${Ft}]`)).find($=>$.getAttribute(Ft)===S))==null?void 0:M.querySelector('[role="tab"]'))==null?void 0:B.textContent)==null?void 0:O.trim())||"Tab"},indexOf:w,count:()=>y.read().length})}},[y,h]);u.useEffect(()=>{const w=m.current;if(!w)return;const N=S=>{Math.abs(S.deltaY)<=Math.abs(S.deltaX)||w.scrollWidth<=w.clientWidth||(S.preventDefault(),w.scrollLeft+=S.deltaY)};return w.addEventListener("wheel",N,{passive:!1}),()=>w.removeEventListener("wheel",N)},[]);const v=Bc(m,"horizontal"),E=u.useCallback(()=>{const w=m.current;if(!w||t===null)return;const N=Array.from(w.querySelectorAll(`[${Ft}]`)).find(S=>S.getAttribute(Ft)===t);N&&zc(w,N,kk)},[t]);u.useEffect(()=>{if(E(),typeof ResizeObserver>"u")return;const w=m.current;if(!w)return;const N=new ResizeObserver(E);return N.observe(w),l.current&&N.observe(l.current),()=>N.disconnect()},[E]);const R=Yc(xs(Qc,{activationConstraint:{distance:ok}}),xs(Vc,{coordinateGetter:C,keyboardCodes:rk})),_=({active:w})=>{var M,B;g(!0);const N=((M=e.find(O=>O.id===w.id))==null?void 0:M.pinned)??!1,S=Array.from(((B=l.current)==null?void 0:B.querySelectorAll(`[${Ft}]`))??[]).filter(O=>{var G;const $=O.getAttribute(Ft);return(((G=e.find(ee=>ee.id===$))==null?void 0:G.pinned)??!1)===N}).map(O=>O.getBoundingClientRect());h.write(dk(S))},D=()=>{g(!1),h.write(null)},P=({active:w,over:N})=>{D();const S=mk(x,w.id,N==null?void 0:N.id);S&&i&&i(...S)},T=()=>{setTimeout(()=>{var w,N;(N=(w=l.current)==null?void 0:w.querySelector('[role="tab"][aria-selected="true"]'))==null||N.focus()},0)},{getTabProps:j}=ky({orderedIds:e.map(w=>w.id),activeId:t,onActivate:s,onClose:p?r:void 0,getFallbackFocus:()=>d.current});return n.jsxs("div",{className:K("bg-muted/40 flex shrink-0 items-stretch border-b px-2 py-1",c),children:[n.jsx("div",{ref:m,"data-slot":"app-tab-strip","data-fade-start":v.start||void 0,"data-fade-end":v.end||void 0,onScroll:v.onScroll,className:"flex min-w-0 flex-1 items-stretch overflow-x-auto",children:n.jsx(Xc,{sensors:R,collisionDetection:b,modifiers:k,accessibility:{announcements:I,screenReaderInstructions:ak},onDragStart:_,onDragEnd:P,onDragCancel:D,children:n.jsx(Fh,{items:x,strategy:$h,children:n.jsx("div",{ref:l,role:"tablist","aria-label":"Open tabs",className:"flex items-stretch gap-1",children:e.map(w=>n.jsx(jk,{tab:w,isActive:w.id===t,canClose:p,tabProps:j(w.id),onClose:r,sortable:i!==void 0,dragActive:f,menu:a,onMenuClosed:T,hasOthersToClose:e.some(N=>N.id!==w.id&&!N.pinned)},w.id))})})})}),n.jsx("button",{ref:d,type:"button",onClick:o,"aria-label":"New tab",title:`New tab (${Wt(cn.NEW_TAB)})`,className:"focus-ring text-muted-foreground hover:bg-background/60 hover:text-foreground ml-1 flex shrink-0 items-center rounded-md px-1.5 transition-colors",children:n.jsx(Dt,{className:"size-3.5"})})]})}function Ck({className:e}){const t=Bh(),s=ue(f=>f.activeTabId),{activate:r,close:o,create:a,togglePin:i,duplicate:c,closeOthers:d,reorder:l,reopenClosed:m}=Ko(),{copy:h}=zn({toastOnSettle:!0}),p=u.useMemo(()=>({togglePin:i,duplicate:c,closeOthers:d,close:o,reopenClosed:m,copyLink:f=>{const g=ue.getState().tabs.find(x=>x.id===f);g&&h(nk(g.href))}}),[i,c,d,o,m,h]);return n.jsx(Sk,{tabs:t,activeId:s,onActivate:r,onClose:o,onCreate:a,menu:p,onReorder:l,className:e})}function Ss(){var s;const{tabs:e,activeTabId:t}=ue.getState();return((s=e.find(r=>r.id===t))==null?void 0:s.cursor)??null}function Ho(e,t){const s=Ss();s!==null&&(ue.getState().goToHistoryIndex(t),Ss()!==s&&bo(e))}function cu(e){const t=Ss();t!==null&&Ho(e,t-1)}function lu(e){const t=Ss();t!==null&&Ho(e,t+1)}function Nk(e,t){Ho(e,t)}function ii(e,t){const s=Wt(e);return Gt?s:`${s} or ${Wt(`alt+${t}`)}`}const ar="size-7";function Ak({href:e,isCurrent:t,onSelect:s}){const r=Ps(e);return n.jsxs(qe,{disabled:t,"aria-current":t?"page":void 0,onSelect:s,"aria-label":r.accessibleName,className:"data-[disabled]:opacity-100",children:[n.jsx(yo,{icon:r.icon}),n.jsxs("span",{className:"min-w-0 flex-1 truncate",children:[Ir(r),r.secondary&&n.jsxs("span",{className:"text-muted-foreground",children:[" · ",r.secondary]})]}),n.jsx(vo,{identity:r}),n.jsx(Jt,{className:K("size-3.5 shrink-0",!t&&"invisible")})]})}function ir({label:e,keys:t,children:s}){return n.jsxs(xn,{children:[n.jsx(bn,{asChild:!0,children:s}),n.jsx(yn,{side:"bottom",className:"text-xs",children:t?`${e} (${t})`:e})]})}function Ek(){const e=Xt(),{entries:t,cursor:s,canGoBack:r,canGoForward:o}=zh();if(!$e())return null;const a=t.map((i,c)=>({href:i,index:c})).reverse();return n.jsxs("div",{className:"flex items-center",children:[n.jsx(ir,{label:"Back",keys:ii(cn.HISTORY_BACK.key,"←"),children:n.jsx(F,{variant:"ghost",size:"icon-md",className:ar,"aria-label":"Back",disabled:!r,onClick:()=>cu(e),children:n.jsx(Jc,{})})}),n.jsx(ir,{label:"Forward",keys:ii(cn.HISTORY_FORWARD.key,"→"),children:n.jsx(F,{variant:"ghost",size:"icon-md",className:ar,"aria-label":"Forward",disabled:!o,onClick:()=>lu(e),children:n.jsx(Zc,{})})}),n.jsxs(fo,{children:[n.jsx(ir,{label:"History",children:n.jsx(po,{asChild:!0,children:n.jsx(F,{variant:"ghost",size:"icon-md",className:ar,"aria-label":"History",children:n.jsx(kd,{})})})}),n.jsx(go,{align:"start",className:"max-w-72 min-w-48",children:a.map(({href:i,index:c})=>n.jsx(Ak,{href:i,isCurrent:c===s,onSelect:()=>Nk(e,c)},c))})]})]})}function Ik(){const e=Xt(),t=De({select:o=>o.location.href}),s=u.useRef(!1),r=u.useRef(!0);u.useEffect(()=>{if($e())return e.history.subscribe(({action:o})=>{s.current=o.type!=="PUSH"&&o.type!=="REPLACE",r.current=o.type==="REPLACE"})},[e]),u.useEffect(()=>{if(!$e())return;const o=s.current,a=r.current;s.current=!1,r.current=!1,ue.getState().syncLocation(t,{traversal:o,replace:a})},[t])}const ci=9;function Rk(){const e=Ko();u.useEffect(()=>{if(!$e())return;const t=s=>{if(!(s.metaKey||s.ctrlKey)||s.altKey)return;if(s.shiftKey){s.code==="BracketLeft"?(s.preventDefault(),e.activateRelative(-1)):s.code==="BracketRight"?(s.preventDefault(),e.activateRelative(1)):s.key.toLowerCase()==="t"&&(s.preventDefault(),e.reopenClosed());return}if(s.key==="t"||s.key==="T"){s.preventDefault(),e.create();return}if(!s.code.startsWith("Digit"))return;const r=Number(s.code.slice(5));!Number.isInteger(r)||r<1||r>ci||(s.preventDefault(),r===ci?e.activateLast():e.activateIndex(r-1))};return document.addEventListener("keydown",t),()=>document.removeEventListener("keydown",t)},[e])}const li=3,Tk=4;function Dk(e){return e instanceof Element?e.closest("input, textarea, select")?!0:e.closest('[contenteditable]:not([contenteditable="false"])')!==null:!1}function di(e){return e instanceof Element&&e.closest('[role="dialog"], [role="alertdialog"], [role="menu"]')!==null}function Ok(e){if(e.shiftKey)return null;if((Gt?e.metaKey&&!e.ctrlKey:e.ctrlKey&&!e.metaKey)&&!e.altKey)return e.code==="BracketLeft"?"back":e.code==="BracketRight"?"forward":null;if(!Gt&&e.altKey&&!e.ctrlKey&&!e.metaKey){if(Dk(e.target))return null;if(e.key==="ArrowLeft")return"back";if(e.key==="ArrowRight")return"forward"}return null}function Mk(){const e=Xt();u.useEffect(()=>{if(!$e())return;const t=i=>i==="back"?cu(e):lu(e),s=i=>{if(i.defaultPrevented||i.isComposing||di(i.target))return;const c=Ok(i);c&&(i.preventDefault(),t(c))},r=i=>i.button===li||i.button===Tk,o=i=>{r(i)&&i.preventDefault()},a=i=>{r(i)&&(i.preventDefault(),!di(i.target)&&t(i.button===li?"back":"forward"))};return document.addEventListener("keydown",s),document.addEventListener("mousedown",o),document.addEventListener("mouseup",a),()=>{document.removeEventListener("keydown",s),document.removeEventListener("mousedown",o),document.removeEventListener("mouseup",a)}},[e])}function _k(e){return typeof e=="object"&&e!==null&&e.status===404}async function Pk(e){try{return await e(),!1}catch(t){return _k(t)}}async function Lk(e,t){const s=new Map,r=(a,i)=>{let c=s.get(a);return c||(c=Pk(i),s.set(a,c)),c},o=await Promise.all(e.map(async a=>{const i=Uh(a.href);if(i.pathname==="/session"&&i.sessionId&&!i.draft){const c=i.sessionId;return await r(`session:${c}`,()=>t.getSession(c))?a.id:null}if(i.pathname==="/channels"&&i.roomId&&!i.community){const c=i.roomId;return await r(`room:${c}`,()=>t.getRoom(c))?a.id:null}return null}));return new Set(o.filter(a=>a!==null))}function Fk(){const e=ie(),t=Xt();u.useEffect(()=>{if(!$e())return;let s=!1;const r=ue.getState().tabs;return Lk(r,{getSession:o=>e.getSession(o),getRoom:o=>e.getRoom(o)}).then(o=>{if(s||o.size===0)return;const{tabs:a,activeTabId:i}=ue.getState();ue.getState().dropTabs(o),Hc(a,ue.getState().tabs),ue.getState().activeTabId!==i&&bo(t)}).catch(o=>{console.error("[dorkos:tabs] could not check restored tabs",o)}),()=>{s=!0}},[])}function $k(){Ik(),Rk(),Kh(),Fk(),Mk()}function Bk(e){return e.displayName||e.name}function Wo(e,t){const s=Mn(r=>r.setRouteBadge);u.useEffect(()=>{s(e,t)},[e,t,s])}const zk=5*6e4;function Uk(e){return e.status==="active"&&e.enabled}function Kk(e){const{enabled:t}=Wh(),{data:s}=el(t),{data:r}=Gh(t),o=Mn(c=>c.setSchedulesWaitingCount),a=u.useMemo(()=>{const c=Qw(t?r??[]:[]),d=new Map((s??[]).filter(Uk).map(l=>[l.id,l]));return{waiting:e,failed:c.failed.filter(l=>d.has(l)).length,running:c.running.flatMap(l=>{const m=d.get(l);return m?[Bk(m)]:[]})}},[t,r,s,e]),i=u.useMemo(()=>qh(a),[a]);Wo("/tasks",i),u.useEffect(()=>{o(e)},[e,o])}function Hk(){const{count:e,more:t}=Yh(),s=u.useMemo(()=>Vh(e,t),[e,t]);Wo("/activity",s)}function Wk(){const{data:e,isSuccess:t}=Kx("pending"),{data:s}=Hx("pending",{enabled:t,refetchInterval:zk}),r=((e==null?void 0:e.length)??0)+((s==null?void 0:s.length)??0),o=u.useMemo(()=>Qh(r),[r]);Wo("/connections",o)}function Gk(){const{items:e,schedules:t}=Hh(),s=Mn(r=>r.setNeedsYouCount);u.useEffect(()=>{s(e.length)},[e.length,s]),Kk(t.length),Hk(),Wk()}function Kt(e){return"problem"in e?{problem:e.problem}:{message:e.message}}const Ht={message:"Couldn’t reach your DorkOS account. Try again."},qk={message:"Finish signing in in your browser, then try again."},Yk={message:"Your browser blocked the window. Allow pop-ups, then try again."},cr={message:"Couldn’t connect this DorkOS to the space. Try again."},Vk={message:"The approval ran out. Connect again."};function Go(e,t,s){var D,P;const r=ie(),o=le(),a=Bn(e!==null),{signsInWithAccount:i,linkFor:c}=tl(e!==null),[d,l]=u.useState({opened:!1,busy:!1,notice:null}),[m,h]=u.useState(null),p=u.useRef(null),f=Ee({queryKey:lt.list(),queryFn:()=>r.listHostedCommunities(),enabled:e!==null&&m===null,refetchInterval:T=>{const j=T.state.data,w=(j==null?void 0:j.available)===!0?j.communities.find(N=>N.communityId===(e==null?void 0:e.communityId)):void 0;return(w==null?void 0:w.state)==="provisioning"?2e3:!1}}),g=((D=f.data)==null?void 0:D.available)===!0?f.data.communities.find(T=>T.communityId===(e==null?void 0:e.communityId)):void 0,x=(g==null?void 0:g.state)==="provisioning",y=u.useCallback(()=>{if(!e||d.busy)return;const T=io();if(T===null){l(j=>({...j,notice:Yk}));return}l(j=>({...j,busy:!0,notice:null})),r.getHostedCommunityClaimLink(e.communityId).then(j=>{if(!j.ok){T.close(),l(N=>({...N,busy:!1,notice:Kt(j)}));return}const w=T.go(c(j.claimUrl));l(N=>({opened:N.opened||w,busy:!1,notice:null}))}).catch(()=>{T.close(),l(j=>({...j,busy:!1,notice:Ht}))})},[e,d.busy,r,c]),b=u.useCallback(async()=>{if(e){if(!a||!Bt(a)){h({ref:null,approvalUrl:null,busy:!1,notice:cr});return}h({ref:null,approvalUrl:null,busy:!0,notice:null});try{const T=await r.startCommunityConnection({url:e.communityUrl,installName:t});h({ref:T.connection.ref,approvalUrl:T.approvalUrl,busy:!1,notice:null}),await o.invalidateQueries({queryKey:At.connections(a)})}catch{h({ref:null,approvalUrl:null,busy:!1,notice:cr})}}},[e,a,r,t,o]),C=u.useCallback(()=>{!e||d.busy||(l(T=>({...T,busy:!0,notice:null})),r.listHostedCommunities().then(T=>{o.setQueryData(lt.list(),T);const j=T.available===!0?T.communities.find(w=>w.communityId===e.communityId):void 0;if(!j||j.state==="pending_owner"||j.state==="provisioning"){l(w=>({...w,busy:!1,notice:qk}));return}l(w=>({...w,busy:!1})),b()}).catch(()=>l(T=>({...T,busy:!1,notice:Ht}))))},[e,d.busy,r,o,b]),k=(m==null?void 0:m.ref)??null,I=Ee({queryKey:a&&k?At.approval(a,k):["cloud","no-approval"],queryFn:()=>yc(a,()=>r.pollCommunityConnection(k)),enabled:a!==null&&k!==null,retry:!1,refetchInterval:T=>!T.state.error&&(!T.state.data||T.state.data.status==="pending")?2e3:!1}),v=k!==null?((P=I.data)==null?void 0:P.status)??"pending":"pending",E=v==="connected"?k:null;u.useEffect(()=>{E===null||p.current===E||(p.current=E,a&&o.invalidateQueries({queryKey:At.connections(a)}),o.invalidateQueries({queryKey:lt.all}),s(E))},[E,a,o,s]);const R=v==="expired"||v==="cancelled";return{state:E!==null?{kind:"done",ref:E}:m!==null?{kind:"connecting",approvalUrl:m.approvalUrl,busy:m.busy,notice:m.notice??(R?Vk:I.error?cr:null)}:x?{kind:"preparing"}:{kind:"claim",...d,withAccount:e!==null&&i(e.communityUrl)},openClaim:y,confirmClaimed:C,openApproval:()=>{m!=null&&m.approvalUrl&&It(c(m.approvalUrl))},retryConnect:()=>void b()}}const vn=ut().regex(/^[a-z](?:[a-z0-9]|-(?=[a-z0-9])){2,31}$/,"must be lower-case letters, digits and single hyphens, start with a letter, and not end with a hyphen").describe("A community short name: lower case, 3 to 32 characters, letters, digits and single hyphens, starting with a letter and not ending with a hyphen."),du=ut().trim().min(1).max(80).describe("The community`s display name. Trimmed, 1 to 80 characters."),uu=ut().min(1).max(200).describe("A key the caller chooses, scoped to the caller. Sending it again returns the same community or move instead of making a second one.");function Qk(e){return Yn.meta({description:e,[sd]:!0})}const Xk=Wn(["provisioning","pending_owner","active","archived","held","suspended","deletion_pending"]).describe("Where a hosted community is in its lifecycle. The Community server`s own lifecycle names, plus provisioning while the server confirms a start."),Jk=Wn(["over_limit","inactive","host"]).describe("Why a hosted community is on hold: the account holds more than its allowance covers, nobody has posted in a long time, or the host placed the hold itself."),Zk=me({title:ut().min(1).max(120).describe("A short summary, safe to show a person."),detail:ut().max(2e3).describe("The explanation, safe to show a person."),actionUrl:Gx.optional().catch(void 0).describe("A page where the owner can act on the notice. Open it as given. A malformed value is dropped."),actionLabel:ut().min(1).max(60).optional().catch(void 0).describe("The text for a button that opens `actionUrl`. A malformed value is dropped.")}).describe("What the service wants the owner to read about this community, in its own words."),eS=me({allowed:Ut().describe("The owner may choose this community as one to keep open."),wouldHold:Gn(at).describe("The caller`s other communities that keeping this one would put on hold.")}).describe("Whether the owner may keep this community open, and which others it would hold."),qo=me({communityId:at.describe("The community`s permanent identifier on its Community server. Never changes, even across a rename."),orgId:at.describe("The organization whose account this community belongs to."),name:ut().min(1).max(80).describe("The community`s display name."),shortName:vn.nullable().describe("The community`s current short name, or null when it has none."),communityUrl:Yn.describe("The community`s canonical link on its Community server, built on its permanent identifier. A runtime value; pair a DorkOS installation with this."),state:ws(Xk).describe("Where the community is in its lifecycle. A state this release does not know reads as unrecognised."),hold:me({reason:ws(Jk).describe("Why the community is on hold. A reason this release does not know reads as unrecognised."),since:Nt,deletionNoticeAt:Nt.nullable().describe("When the host may delete the community if the hold is not lifted, or null when no deletion is planned. The owner can export until then.")}).nullable().describe("Why and since when the community is on hold. Always set when the state is held."),deletionAt:Nt.nullable().describe("When the Community server will delete the community for good. Always set when the state is deletion_pending."),notice:Zk.nullable().describe("What the service wants the owner to read about this community, or null when there is nothing."),kept:Ut().describe("True when the owner chose this community to stay open while the account holds more communities than its allowance covers."),moveId:at.nullable().describe("The move filling this community from an owner export, while that move is unfinished. Null otherwise. Lets the app pick up a move after a restart."),limits:me({maxActiveMembers:be().int().positive().nullable().describe("The most people who may be active members at once. Null means no limit."),maxStorageBytes:be().int().nonnegative().nullable().describe("The most bytes of files the community may store. Null means no per-community limit.")}).describe("The limits the host enforces on this community. Agents and history never count."),usage:me({activeMembers:be().int().nonnegative(),storageBytes:be().int().nonnegative().describe("The bytes that count against the storage limit. Owner exports never count."),measuredAt:Nt}).nullable().describe("The community`s last measured usage, or null before the first measurement."),actions:me({claimLink:Ut().describe("The service will issue a fresh owner-claim link for this community."),keep:eS,restore:Ut().describe("The owner may ask for this held community to reopen.")}).describe("What the caller may do next. Render an action only when it is allowed; the service applies the rule, the app never re-derives it."),createdAt:Nt}).superRefine((e,t)=>{e.state==="held"&&e.hold===null&&t.addIssue({code:"custom",path:["hold"],message:"a held community says why"}),e.state==="deletion_pending"&&e.deletionAt===null&&t.addIssue({code:"custom",path:["deletionAt"],message:"a community pending deletion says when"})}).describe("One community the caller has hosted, with its state, limits and usage. Numbers only.");nd(qo,"A page of the communities the caller has hosted.");me({name:vn}).describe("The short name to check.");const tS=Wn(["taken","reserved"]).describe("Why a short name cannot be used: another community has it, or the host reserves it.");me({name:vn,available:Ut(),reason:tS.nullable().describe("Why the name cannot be used. Null exactly when it is available.")}).superRefine((e,t)=>{e.available!==(e.reason===null)&&t.addIssue({code:"custom",path:["reason"],message:"reason is null exactly when the name is available"})}).describe("Whether a short name is free right now. Advisory; starting a community checks again.");me({idempotencyKey:uu,name:du,shortName:vn.optional().describe("The short name to give the community. Omitted means none."),orgId:at.optional().describe("The organization whose account the community belongs to. Omitted means the caller`s personal one.")}).describe("Start a hosted community. Idempotent on the caller`s key.");const nS=me({communityId:at,claimUrl:Qk("The owner-claim link. A single-use credential: open it in the person`s own browser and never log it."),expiresAt:Nt.describe("When the link stops working.")}).describe("A one-time link that makes a person the owner of a new community. Returned once.");me({community:qo,claim:nS.nullable().describe("The owner-claim link, or null when this answer repeats an earlier request or the community is still provisioning."),replayed:Ut().describe("True when this answer repeats an earlier request with the same key.")}).superRefine((e,t)=>{e.claim!==null&&(e.replayed||e.community.state!=="pending_owner")&&t.addIssue({code:"custom",path:["claim"],message:"a claim link comes only on the first answer, for a pending_owner community"})}).describe("The started community and, the first time only, its owner-claim link.");me({expectedHeldCommunityIds:Gn(at).describe("The communities the owner was told this choice would hold, in any order.")}).describe("Keep this community open, confirming which others the owner agreed to hold.");me({community:qo,heldCommunityIds:Gn(at).describe("Other communities of the caller`s that this choice put on hold. Often empty.")}).describe("The kept community, and every other community the choice put on hold.");const sS=Wn(["awaiting_upload","importing","ready","failed","cancelled","claimed"]).describe("Where a move is: waiting for the export, importing it, ready to claim, or finished."),rS=Wn(["not_owner_export","archive_invalid","checksum_mismatch","version_unsupported","too_large","storage_limit_reached","upload_expired","storage_unavailable"]).describe("Why a move failed, in terms a person can act on."),oS=me({channels:be().int().nonnegative(),entries:be().int().nonnegative().describe("Messages and replies."),attachments:be().int().nonnegative(),historicalMembers:be().int().nonnegative().describe("People whose messages move. They join again by invitation."),historicalAgents:be().int().nonnegative().describe("Agents whose messages move. Their owners pair them again."),attachmentBytes:be().int().nonnegative(),countedBytes:be().int().nonnegative().describe("The bytes that will count against the community`s storage limit.")}).describe("What an owner export holds, in counts and sizes only."),mu=me({moveId:at,communityId:at.describe("The new community the export fills. It no longer exists once a move has failed or been cancelled."),communityUrl:Yn.describe("The new community`s canonical link. A runtime value."),name:ut().min(1).max(80).describe("The name the new community was given."),state:ws(sS).describe("Where the move is. A state this release does not know reads as unrecognised."),failureCode:ws(rS).nullable().describe("Why the move failed. Always set when the state is failed. A code this release does not know reads as unrecognised."),report:oS.nullable().describe("What the export holds, once it has been read. Null before then."),pollAfterMs:be().int().nonnegative().nullable().describe("How long to wait before reading the move again. Null once it has finished."),updatedAt:Nt}).superRefine((e,t)=>{e.state==="failed"&&e.failureCode===null&&t.addIssue({code:"custom",path:["failureCode"],message:"a failed move says why"})}).describe("One move of a community into hosting, from an owner export.");nd(mu,"A page of the caller`s moves: every unfinished one, and those that finished within the last 7 days, newest first.");me({idempotencyKey:uu,name:du,shortName:vn.optional().describe("The short name to give the new community. Omitted means none."),orgId:at.optional().describe("The organization whose account the community belongs to. Omitted means the caller`s personal one."),archiveBytes:be().int().positive().describe("The size of the export file, in bytes."),archiveSha256:ut().regex(/^[a-f0-9]{64}$/,"must be a lower-case hex SHA-256 digest").describe("The SHA-256 of the export file, as lower-case hex.")}).describe("Start moving a community in from an owner export. Idempotent on the caller`s key.");const aS=me({url:Yn.describe("Where to send the export. A runtime value."),token:qx.meta({description:"The upload bearer credential. Returned once; never log it.",[sd]:!0}),expiresAt:Nt.describe("When the upload window closes."),maxBytes:be().int().positive().describe("The largest file the upload accepts."),parts:me({partBytes:be().int().positive().describe("The largest part the upload accepts."),maxBytes:be().int().positive().describe("The largest file a parted upload accepts.")}).optional().describe("Present when the Community server accepts the file in parts.")}).describe("Where and how to send the export file. The token is returned once."),hu=ut().regex(/^[a-f0-9]{64}$/,"must be a lower-case hex SHA-256 digest"),Yo=1e4,iS=me({partNumber:be().int().positive().max(Yo).describe("The number of the part, counting up from one."),byteSize:be().int().positive().describe("The size of the part, in bytes."),sha256:hu.describe("The SHA-256 of the part, as lower-case hex.")}).describe("One part the Community server has received.");me({parts:Gn(iS).max(Yo).describe("The parts received, in part order."),maxPartBytes:be().int().positive().describe("The largest part the upload accepts."),maxArchiveBytes:be().int().positive().describe("The largest file a parted upload accepts.")}).describe("The parts of a parted upload received so far.");me({parts:be().int().positive().max(Yo).describe("How many parts make up the file."),archiveBytes:be().int().positive().describe("The size of the whole file, in bytes."),archiveSha256:hu.describe("The SHA-256 of the whole file, as lower-case hex.")}).describe("Put the uploaded parts together into the declared file.");me({move:mu,upload:aS.nullable().describe("Where to send the export, or null when this answer repeats an earlier request."),replayed:Ut().describe("True when this answer repeats an earlier request with the same key.")}).superRefine((e,t)=>{e.replayed!==(e.upload===null)&&t.addIssue({code:"custom",path:["upload"],message:"upload is null exactly when the answer is replayed"})}).describe("The started move and, the first time only, where to send the export.");const cS=Yn.regex(/^https?:\/\/[^/?#]+$/,"must be an origin: no path, query or fragment").refine(e=>new URL(e).origin===e,{message:"must be written as the URL standard writes an origin"}).describe("A Community server`s origin: scheme, host and port, written as the URL standard writes it. A runtime value."),lS=me({origin:cS}).describe("A Community server whose single sign-on is this account.");me({servers:Gn(lS).max(100).describe("Every Community server whose single sign-on is this account. Often one.")}).describe("The Community servers where this account signs a person in.");function fu(e){switch(e){case"not_owner_export":return{title:"This is a personal export, not an owner export.",next:"Sign in to the old space as its owner, export it from Settings, then try again."};case"archive_invalid":return{title:"This file is damaged, or it isn’t a space export.",next:"Export the old space again, then try again."};case"checksum_mismatch":return{title:"Part of this export is damaged.",next:"Export the old space again, then try again."};case"version_unsupported":return{title:"This export comes from a version DorkOS can’t read yet.",next:"Update the old space, export it again, then try again."};case"too_large":return{title:"This export is too large to move.",next:"Delete some large files in the old space, export it again, then try again."};case"storage_limit_reached":return{title:"The files don’t fit in the new space’s storage.",next:"Delete some files in the old space, export it again, then try again."};case"upload_expired":return{title:"The file didn’t arrive in time.",next:"Start the move again."};case"storage_unavailable":return{title:"DorkOS couldn’t store the files just now.",next:"Wait a little while, then start the move again."};default:return{title:"The move stopped for an unknown reason.",next:"Update DorkOS to see more, or start the move again."}}}function dS(e){switch(e){case"provisioning":return"Being set up";case"pending_owner":return"Waiting for its owner";case"active":return"Open";case"archived":return"Archived";case"held":return"On hold";case"suspended":return"Suspended";case"deletion_pending":return"Being deleted";default:return"Unknown state"}}function uS(e){switch(e){case"over_limit":return"Your account has more spaces than it allows. Choose which ones stay open.";case"inactive":return"Nobody has posted here in a long time. You can reopen it.";case"host":return"DorkOS put this space on hold. People can still read it.";default:return"This space is on hold. Update DorkOS to see why."}}function lr(e){const t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleDateString(void 0,{year:"numeric",month:"long",day:"numeric",timeZone:"UTC"})}function Fn(e){const t=["bytes","KB","MB","GB","TB"];let s=e,r=0;for(;s>=1e3&&r<t.length-1;)s/=1e3,r++;return`${r===0||s>=10?Math.round(s):Math.round(s*10)/10} ${t[r]}`}function pu(e){if((e==null?void 0:e.maxCommunities)==null||e.usedCommunities==null)return null;const t=e.maxCommunities-e.usedCommunities;return t<=0?"Your account has no room for another space right now.":`You can start ${t} more ${t===1?"space":"spaces"}.`}const gu="Lower-case letters, numbers and single hyphens. 3 to 32 characters, starting with a letter.";function Qn(e){const t=e.trim().toLowerCase();return t===""?{value:t,valid:!0}:{value:t,valid:vn.safeParse(t).success}}const mS=80,xu="That web address is taken.",bu="That web address can’t be used.";function yu(e){const t=ie(),{value:s,valid:r}=Qn(e),[o,a]=u.useState(s);u.useEffect(()=>{const d=setTimeout(()=>a(s),400);return()=>clearTimeout(d)},[s]);const i=Ee({queryKey:lt.name(o),queryFn:()=>t.checkHostedCommunityName(o),enabled:r&&o!==""&&o===s,staleTime:1e4,retry:!1});if(s==="")return{kind:"none"};if(!r)return{kind:"invalid"};if(o!==s||i.isPending)return{kind:"checking"};const c=i.data;return!c||c.available===!1?{kind:"none"}:c.check.available?{kind:"available"}:{kind:c.check.reason==="reserved"?"reserved":"taken"}}function hS(){const e=u.useRef(null);return t=>{var r;const s=JSON.stringify(t);return((r=e.current)==null?void 0:r.body)!==s&&(e.current={body:s,key:crypto.randomUUID()}),e.current.key}}function fS(){const e=ie(),t=le(),s=hS(),[r,o]=u.useState(!1),[a,i]=u.useState({field:null,notice:null});async function c(d){const l={name:d.name.trim(),...d.shortName?{shortName:d.shortName}:{}};o(!0),i({field:null,notice:null});try{const m=await e.startHostedCommunity({...l,idempotencyKey:s(l)});return m.ok?(t.invalidateQueries({queryKey:lt.list()}),{community:m.community}):("problem"in m&&m.problem.code==="community_name_taken"?i({field:xu,notice:null}):"problem"in m&&m.problem.code==="community_name_reserved"?i({field:bu,notice:null}):i({field:null,notice:Kt(m)}),null)}catch{return i({field:null,notice:Ht}),null}finally{o(!1)}}return{submitting:r,failure:a,clearFieldFailure:()=>i(d=>({...d,field:null})),submit:c}}function pS(e){switch(e.state){case"awaiting_upload":{const t=e.upload;if((t==null?void 0:t.state)==="sending")return{kind:"uploading",move:e};if((t==null?void 0:t.state)==="sent")return{kind:"importing",move:e};const s=t===null?"restarted":t.failure==="interrupted"?"interrupted":t.failure==="rejected"?"refused":"expired";return{kind:"upload-failed",move:e,why:s}}case"importing":return{kind:"importing",move:e};case"ready":case"claimed":return{kind:"ready",move:e};case"failed":return{kind:"failed",move:e};case"cancelled":return{kind:"cancelled",move:e};default:return{kind:"unrecognised",move:e}}}function gS(e){return e.state==="awaiting_upload"||e.state==="importing"||e.state==="ready"}function xS(e){var I;const t=ie(),s=le(),[r,o]=u.useState(e),[a,i]=u.useState(null),[c,d]=u.useState({field:null,notice:null}),[l,m]=u.useState(!1),h=u.useRef(null),p=u.useRef(null),f=Ee({queryKey:lt.move(r??""),queryFn:()=>t.getHostedCommunityMove(r),enabled:r!==null,refetchInterval:v=>{var R;const E=v.state.data;return(E==null?void 0:E.available)!==!0?!1:((R=E.move.upload)==null?void 0:R.state)==="sending"?1e3:E.move.pollAfterMs===null?!1:Math.max(1e3,E.move.pollAfterMs)}}),g=((I=f.data)==null?void 0:I.available)===!0?f.data.move:null,x=g?pS(g):null,y=u.useCallback(v=>{s.setQueryData(lt.move(v.moveId),{available:!0,move:v})},[s]);async function b(v){var P;const E={name:v.name.trim(),...v.shortName?{shortName:v.shortName}:{},file:[v.file.name,v.file.size,v.file.lastModified]},R=JSON.stringify(E);((P=p.current)==null?void 0:P.body)!==R&&(p.current={body:R,key:crypto.randomUUID()});const _=p.current.key,D=new AbortController;h.current=D,d({field:null,notice:null}),i({loaded:0,total:v.file.size});try{const T=await t.checkHostedCommunityMoveRoom(v.file.size,D.signal);if(D.signal.aborted)return;const j=T.ok?await t.startHostedCommunityMove(v.file,{idempotencyKey:_,name:E.name,...v.shortName?{shortName:v.shortName}:{}},w=>i(w),D.signal):T;(j.ok||j.mayExist!==!0)&&(p.current=null),j.ok?(y(j.move),o(j.move.moveId),s.invalidateQueries({queryKey:lt.list()})):"problem"in j&&j.problem.code==="community_name_taken"?d({field:xu,notice:null}):"problem"in j&&j.problem.code==="community_name_reserved"?d({field:bu,notice:null}):d({field:null,notice:Kt(j)})}catch{D.signal.aborted?p.current=null:d({field:null,notice:Ht})}finally{h.current=null,i(null)}}async function C(){if(h.current){h.current.abort();return}if(r){m(!0);try{const v=await t.cancelHostedCommunityMove(r);v.ok?y(v.move):d({field:null,notice:Kt(v)}),s.invalidateQueries({queryKey:lt.list()})}catch{d({field:null,notice:Ht})}finally{m(!1)}}}async function k(){if(r){m(!0),d({field:null,notice:null});try{const v=await t.retryHostedCommunityMoveUpload(r);v.ok?y(v.move):d({field:null,notice:Kt(v)})}catch{d({field:null,notice:Ht})}finally{m(!1)}}}return{step:x,sending:a,failure:c,clearFieldFailure:()=>d(v=>({...v,field:null})),busy:l,start:b,cancel:C,sendAgain:k,startOver:()=>{o(null),d({field:null,notice:null})}}}function bS(){var a,i,c;const e=Ac(),t=Yx(),s=rd(t);if(!e||!t||s.isPending||((a=s.data)==null?void 0:a.available)===!1)return null;const r=((i=s.data)==null?void 0:i.available)===!0?s.data:null,o=(r==null?void 0:r.moves)??[];return{allowance:(r==null?void 0:r.allowance)??null,unfinishedMoveId:((c=o.find(gS))==null?void 0:c.moveId)??null}}const yS={message:"Your spaces changed. Check the list again."};function vS(){const e=ie(),t=le(),[s,r]=u.useState(null),[o,a]=u.useState(null),[i,c]=u.useState({});function d(m,h){c(p=>{const f={...p};return h?f[m]=h:delete f[m],f})}async function l(m,h){a(m),d(m,null);try{d(m,await h())}catch{d(m,Ht)}finally{a(null),await t.invalidateQueries({queryKey:lt.list()})}}return{confirmingKeep:s,busyId:o,notices:i,askKeep:r,cancelKeep:()=>r(null),keep:m=>l(m.communityId,async()=>{r(null);const h=await e.keepHostedCommunity(m.communityId,m.actions.keep.wouldHold);return h.ok?null:"problem"in h&&h.problem.code==="conflict"?yS:Kt(h)}),restore:m=>l(m.communityId,async()=>{const h=await e.restoreHostedCommunity(m.communityId);return h.ok?null:Kt(h)})}}function Vo({open:e,onOpenChange:t,step:s,locked:r}){return n.jsx(vt,{open:e,onOpenChange:o=>r&&!o?void 0:t(o),children:n.jsxs(wt,{className:"!min-h-0 sm:max-w-lg",children:[n.jsxs(gt,{children:[n.jsx(ot,{children:s.title}),s.description!==void 0&&n.jsx(xt,{children:s.description})]}),s.body!==void 0&&n.jsx(Et,{className:"space-y-4 py-2",children:s.body}),n.jsx(on,{className:"gap-2 sm:gap-2",children:s.actions})]})})}function Vt({notice:e}){if("message"in e)return n.jsx("p",{role:"alert",className:"text-destructive text-sm",children:e.message});const{title:t,detail:s,actionUrl:r,actionLabel:o}=e.problem;return n.jsxs("div",{role:"alert",className:"border-status-warning-border bg-status-warning-bg text-status-warning-fg space-y-2 rounded-md border p-3 text-sm",children:[n.jsx("p",{className:"font-medium break-words",children:t}),s&&n.jsx("p",{className:"break-words",children:s}),r&&n.jsxs(F,{type:"button",size:"sm",variant:"outline",onClick:()=>It(r),children:[o??"Open your account",n.jsx(an,{className:"size-3.5","aria-hidden":!0})]})]})}function Qo(e){const{state:t,name:s}=e;switch(t.kind){case"preparing":return{title:`Setting up ${s}`,description:"Keep this open, or come back later.",body:n.jsxs("p",{role:"status",className:"text-muted-foreground flex items-center gap-2 text-sm",children:[n.jsx(Oe,{className:"size-4"})," Setting up…"]}),actions:n.jsx(F,{variant:"outline",onClick:e.onClose,children:"Close"})};case"claim":return{title:`Make ${s} yours`,description:t.withAccount?"Sign in with your DorkOS account in your browser, then come back.":"Sign in or create an account in your browser, then come back.",body:t.notice?n.jsx(Vt,{notice:t.notice}):void 0,actions:n.jsxs(n.Fragment,{children:[n.jsxs(F,{variant:t.opened?"outline":"default",disabled:t.busy,onClick:e.onOpenClaim,children:[t.opened?"Open it again":"Open in your browser",n.jsx(an,{className:"size-3.5","aria-hidden":!0})]}),n.jsx(F,{variant:t.opened?"default":"outline",disabled:t.busy,onClick:e.onConfirmClaimed,children:t.busy?"Checking…":"I’ve finished"})]})};case"connecting":return{title:`Connect this DorkOS to ${s}`,description:t.approvalUrl?`Approve this DorkOS on ${s}. This page then moves on.`:"Getting the approval page ready…",body:n.jsxs(n.Fragment,{children:[t.approvalUrl&&!t.notice&&n.jsxs("p",{role:"status",className:"text-muted-foreground flex items-center gap-2 text-sm",children:[n.jsx(Oe,{className:"size-4"})," Waiting for your approval"]}),t.notice&&n.jsx(Vt,{notice:t.notice})]}),actions:t.notice?n.jsx(F,{disabled:t.busy,onClick:e.onRetryConnect,children:"Connect again"}):n.jsxs(F,{disabled:t.busy||!t.approvalUrl,onClick:e.onOpenApproval,children:["Open approval page",n.jsx(an,{className:"size-3.5","aria-hidden":!0})]})};case"done":return{title:`${s} is ready`,description:e.doneDetail,body:n.jsxs("p",{className:"flex items-center gap-2 text-sm",children:[n.jsx(Is,{className:"text-status-success-fg size-4","aria-hidden":!0}),"It’s selected in your spaces."]}),actions:n.jsx(F,{onClick:e.onClose,children:"Done"})}}}function wS(e){const t=e.usage;if(!t)return null;const{maxActiveMembers:s,maxStorageBytes:r}=e.limits,o=`${t.activeMembers.toLocaleString()}${s!==null?` of ${s.toLocaleString()}`:""} ${t.activeMembers===1&&s===null?"person":"people"}`,a=`${Fn(t.storageBytes)}${r!==null?` of ${Fn(r)}`:""} of files`;return`${o} · ${a}`}function jS({community:e,names:t,actions:s,onFinishSetup:r,onOpenMove:o}){const a=s.busyId===e.communityId,i=s.confirmingKeep===e.communityId,c=s.notices[e.communityId],d=wS(e),l=e.actions.keep.wouldHold.map(h=>t.get(h)??"another space"),m=e.state==="held"||e.state==="deletion_pending"||e.state==="suspended";return n.jsxs("li",{className:"space-y-2 rounded-lg border p-3",children:[n.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-2",children:[n.jsxs("div",{className:"min-w-0",children:[n.jsx("p",{className:"truncate text-sm font-medium",children:e.name}),e.shortName&&n.jsx("p",{className:"text-muted-foreground truncate font-mono text-xs",children:e.shortName})]}),n.jsx(On,{variant:m?"outline":"secondary",className:m?"border-status-warning-border text-status-warning-fg shrink-0":"shrink-0",children:dS(e.state)})]}),e.state==="unrecognised"&&n.jsx("p",{className:"text-muted-foreground text-sm",children:"Update DorkOS to see this space’s state."}),e.hold&&n.jsxs("div",{className:"space-y-1 text-sm",children:[n.jsx("p",{children:uS(e.hold.reason)}),n.jsxs("p",{className:"text-muted-foreground",children:["On hold since ",lr(e.hold.since),"."]}),e.hold.deletionNoticeAt&&n.jsxs("p",{className:"text-destructive",children:["DorkOS may delete it after ",lr(e.hold.deletionNoticeAt),". You can export it until then."]})]}),e.deletionAt&&n.jsxs("p",{className:"text-destructive text-sm",children:["It will be deleted for good on ",lr(e.deletionAt),"."]}),e.notice&&n.jsxs("div",{className:"bg-muted/50 space-y-1 rounded-md p-2 text-sm",children:[n.jsx("p",{className:"font-medium break-words",children:e.notice.title}),e.notice.detail&&n.jsx("p",{className:"break-words",children:e.notice.detail}),e.notice.actionUrl&&n.jsxs(F,{size:"sm",variant:"outline",onClick:()=>It(e.notice.actionUrl),children:[e.notice.actionLabel??"Learn more",n.jsx(an,{className:"size-3.5","aria-hidden":!0})]})]}),d&&n.jsx("p",{className:"text-muted-foreground text-xs tabular-nums",children:d}),i&&n.jsxs("div",{role:"group","aria-label":`Keep ${e.name} open`,className:"space-y-2 text-sm",children:[n.jsx("p",{children:l.length===0?`Keep ${e.name} open? Nothing else changes.`:`Keeping ${e.name} open puts ${l.length===1?"this one":"these"} on hold: ${l.join(", ")}. People can still read ${l.length===1?"it":"them"}.`}),n.jsxs("div",{className:"flex flex-wrap gap-2",children:[n.jsx(F,{size:"sm",variant:"outline",onClick:s.cancelKeep,children:"Cancel"}),n.jsx(F,{size:"sm",disabled:a,onClick:()=>void s.keep(e),children:"Keep it open"})]})]}),c&&n.jsx(Vt,{notice:c}),!i&&n.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.actions.claimLink&&n.jsx(F,{size:"sm",onClick:()=>r(e),children:"Finish setting up"}),e.moveId&&n.jsx(F,{size:"sm",variant:"outline",onClick:()=>o(e.moveId),children:"See the move"}),e.actions.keep.allowed&&n.jsx(F,{size:"sm",variant:"outline",disabled:a,onClick:()=>s.askKeep(e.communityId),children:"Keep this one open"}),e.actions.restore&&n.jsx(F,{size:"sm",variant:"outline",disabled:a,onClick:()=>void s.restore(e),children:a?"Reopening…":"Reopen"})]})]})}function kS(e){switch(e.state){case"awaiting_upload":return{text:"Uploading the export"};case"importing":return{text:"Moving the history"};case"ready":return{text:"Ready to make yours"};case"claimed":return{text:"Moved"};case"cancelled":return{text:"Cancelled"};case"failed":{const t=fu(e.failureCode??"unrecognised");return{text:t.title,next:t.next}}default:return{text:"Unknown state. Update DorkOS to see more."}}}function SS(e){const t=new Map(e.communities.map(s=>[s.communityId,s.name]));return n.jsxs("div",{className:"space-y-4",children:[e.allowanceText&&n.jsx("p",{className:"text-muted-foreground text-sm",children:e.allowanceText}),e.communities.length>0?n.jsx("ul",{className:"space-y-2",children:e.communities.map(s=>n.jsx(jS,{community:s,names:t,actions:e.actions,onFinishSetup:e.onFinishSetup,onOpenMove:e.onOpenMove},s.communityId))}):n.jsx("p",{className:"text-muted-foreground text-sm",children:"No spaces yet."}),e.moves.length>0&&n.jsxs("section",{"aria-labelledby":"hosted-moves",className:"space-y-2",children:[n.jsx("h4",{id:"hosted-moves",className:"text-sm font-medium",children:"Recent moves"}),n.jsx("ul",{className:"space-y-2",children:e.moves.map(s=>{const r=kS(s),o=s.state==="awaiting_upload"||s.state==="importing"||s.state==="ready";return n.jsxs("li",{className:"flex flex-wrap items-start justify-between gap-2 rounded-lg border p-3",children:[n.jsxs("div",{className:"min-w-0 space-y-0.5 text-sm",children:[n.jsx("p",{className:"truncate font-medium",children:s.name}),n.jsx("p",{className:s.state==="failed"?"text-destructive":"text-muted-foreground",children:r.text}),r.next&&n.jsx("p",{className:"text-muted-foreground",children:r.next})]}),o&&n.jsx(F,{size:"sm",variant:"outline",onClick:()=>e.onOpenMove(s.moveId),children:"Continue"})]},s.moveId)})})]})]})}function CS(e){return e.open?n.jsx(NS,{...e}):null}function NS({open:e,onOpenChange:t,installName:s,onOpenMove:r,onMoveHere:o,onConnected:a}){var f;const i=rd(!0),c=vS(),[d,l]=u.useState(null),m=Go(d,s,a),h=()=>t(!1);let p;if(d)p=Qo({state:m.state,name:d.name,doneDetail:"Invite people from the space’s own settings when you’re ready.",onOpenClaim:m.openClaim,onConfirmClaimed:m.confirmClaimed,onOpenApproval:m.openApproval,onRetryConnect:m.retryConnect,onClose:h});else{const g=((f=i.data)==null?void 0:f.available)===!0?i.data:null;p={title:"Your spaces",description:"Spaces hosted under your DorkOS account.",body:i.isPending?n.jsx("p",{className:"text-muted-foreground text-sm",children:"Loading…"}):g?n.jsx(SS,{communities:g.communities,moves:g.moves,allowanceText:pu(g.allowance),actions:c,onFinishSetup:l,onOpenMove:x=>{h(),r(x)}}):n.jsx(Vt,{notice:{message:"Couldn’t reach your DorkOS account. Try again."}}),actions:n.jsxs(n.Fragment,{children:[n.jsx(F,{variant:"outline",onClick:h,children:"Close"}),n.jsx(F,{variant:"outline",onClick:()=>{h(),o()},children:"Move one here"})]})}}return n.jsx(Vo,{open:e,onOpenChange:t,step:p})}function AS(e){switch(e.kind){case"invalid":return{text:gu,error:!0};case"checking":return{text:"Checking…",error:!1};case"available":return{text:"That web address is free.",error:!1};case"taken":return{text:"That web address is taken.",error:!0};case"reserved":return{text:"That web address can’t be used.",error:!0};default:return null}}function vu(e){const t=u.useId(),s=e.webAddressError?{text:e.webAddressError,error:!0}:AS(e.webAddressStatus);return n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{className:"space-y-1.5",children:[n.jsx(He,{htmlFor:`${t}-name`,children:"Space name"}),n.jsx(yt,{id:`${t}-name`,required:!0,maxLength:mS,autoComplete:"off",value:e.name,disabled:e.disabled,onChange:r=>e.onNameChange(r.target.value)})]}),n.jsxs("div",{className:"space-y-1.5",children:[n.jsxs(He,{htmlFor:`${t}-address`,children:["Web address ",n.jsx("span",{className:"text-muted-foreground font-normal",children:"(optional)"})]}),n.jsx(yt,{id:`${t}-address`,autoComplete:"off",autoCapitalize:"none",spellCheck:!1,maxLength:32,placeholder:"book-club",value:e.webAddress,disabled:e.disabled,"aria-invalid":(s==null?void 0:s.error)||void 0,"aria-describedby":`${t}-address-hint`,onChange:r=>e.onWebAddressChange(r.target.value)}),n.jsx("p",{id:`${t}-address-hint`,"aria-live":"polite",className:s!=null&&s.error?"text-destructive text-sm":"text-muted-foreground text-sm",children:(s==null?void 0:s.text)??gu})]})]})}const ES="Your history is here. Send invitations so people can join again.";function IS(e,t){return{title:"Move a space here",description:"This copies your space’s history and files to DorkOS.",body:n.jsxs("div",{className:"space-y-2 text-sm",children:[n.jsx("p",{children:"Everyone joins again and reconnects their DorkOS."}),n.jsx("p",{className:"text-muted-foreground",children:"Your old space keeps running until you delete it."}),n.jsx("p",{className:"font-medium",children:"First, export the old space:"}),n.jsxs("ol",{className:"text-muted-foreground list-decimal space-y-1 pl-5",children:[n.jsx("li",{children:"Sign in to the old space as its owner."}),n.jsx("li",{children:"Open its Settings."}),n.jsx("li",{children:"Choose Export."}),n.jsx("li",{children:"Enter your password."}),n.jsx("li",{children:"Save the .zip file."})]})]}),actions:n.jsxs(n.Fragment,{children:[n.jsx(F,{variant:"outline",onClick:t,children:"Cancel"}),n.jsx(F,{onClick:e,children:"I have the file"})]})}}function RS({file:e,onFileChange:t}){const s=u.useId();return n.jsxs("div",{className:"space-y-1.5",children:[n.jsx(He,{htmlFor:s,children:"Export file"}),n.jsx(yt,{id:s,type:"file",accept:".zip,application/zip",onChange:r=>{var o;return t(((o=r.target.files)==null?void 0:o[0])??null)},className:"cursor-pointer"}),e&&n.jsxs("p",{className:"text-muted-foreground text-sm break-all",children:[e.name,", ",Fn(e.size)]})]})}function TS(e){const t=Qn(e.webAddress),s=e.file===null||e.name.trim()===""||!t.valid||e.webAddressStatus.kind==="taken"||e.webAddressStatus.kind==="reserved";return{title:"Choose the export",description:"Pick the .zip file, then name the space.",body:n.jsxs("form",{id:e.formId,onSubmit:e.onSubmit,className:"space-y-4",noValidate:!0,children:[n.jsx(RS,{file:e.file,onFileChange:e.onFileChange}),n.jsx(vu,{name:e.name,onNameChange:e.onNameChange,webAddress:e.webAddress,onWebAddressChange:e.onWebAddressChange,webAddressStatus:e.webAddressStatus,webAddressError:e.failure.field,disabled:!1}),e.failure.notice&&n.jsx(Vt,{notice:e.failure.notice}),n.jsx(Po,{})]}),actions:n.jsxs(n.Fragment,{children:[n.jsx(F,{type:"button",variant:"outline",onClick:e.onBack,children:"Back"}),n.jsx(F,{type:"submit",form:e.formId,disabled:s,children:"Start moving"})]})}}function wu({label:e,loaded:t,total:s}){const r=s>0?Math.round(t/s*100):0;return n.jsxs("div",{className:"space-y-2",children:[n.jsx(Yb,{value:r,"aria-label":e}),n.jsxs("p",{className:"text-muted-foreground text-sm tabular-nums",children:[Fn(t)," of ",Fn(s)]})]})}function DS(e,t){return{title:"Getting the file ready",description:"Keep this open. The upload then starts on its own.",body:n.jsx(wu,{label:"Getting the file ready",...e}),actions:n.jsx(F,{variant:"outline",onClick:t,children:"Cancel"})}}function OS(e){const t=e.report;if(!t)return null;const s=r=>r.toLocaleString();return`${s(t.channels)} ${t.channels===1?"channel":"channels"}, ${s(t.entries)} ${t.entries===1?"message":"messages"} and ${s(t.attachments)} ${t.attachments===1?"file":"files"}.`}function MS(e,t){const{move:s}=e,r=t.notice?n.jsx(Vt,{notice:t.notice}):null,o=n.jsx(F,{variant:"outline",disabled:t.busy,onClick:t.onCancelMove,children:"Cancel move"}),a=n.jsx(F,{onClick:t.onStartOver,children:"Start again"}),i=n.jsx(F,{variant:"outline",onClick:t.onClose,children:"Close"});switch(e.kind){case"uploading":{const c=s.upload;return{title:`Uploading ${s.name}`,description:"You can close this window. Keep DorkOS running until it finishes.",body:n.jsxs(n.Fragment,{children:[n.jsx(wu,{label:`Uploading ${s.name}`,loaded:c.sentBytes,total:c.totalBytes}),r]}),actions:o}}case"upload-failed":return e.why==="interrupted"?{title:"The upload didn’t finish",description:"DorkOS still has the file. Send it again to continue.",body:r,actions:n.jsxs(n.Fragment,{children:[o,n.jsx(F,{disabled:t.busy,onClick:t.onSendAgain,children:"Send again"})]})}:e.why==="refused"?{title:"DorkOS didn’t accept the file",description:"The file arrived changed or incomplete.",body:n.jsxs(n.Fragment,{children:[n.jsx("p",{className:"text-muted-foreground text-sm",children:"Cancel the move, export the old space again, then start again."}),r]}),actions:o}:e.why==="restarted"?{title:"This move has to start again",description:"DorkOS restarted, or the move began on another computer.",body:n.jsxs(n.Fragment,{children:[n.jsx("p",{className:"text-muted-foreground text-sm",children:"Cancel the move and start again with the same export."}),n.jsx("p",{className:"text-muted-foreground text-sm",children:"Or finish it on the computer that started it."}),n.jsx("p",{className:"text-muted-foreground text-sm",children:"For safety, uploads only work while DorkOS stays running."}),r]}),actions:o}:{title:"The time to upload ran out",description:"Cancel the move, then start again with the same export.",body:r,actions:o};case"importing":{const c=OS(s);return{title:`Moving ${s.name}`,description:"You can close this window or quit. The move keeps going.",body:n.jsxs(n.Fragment,{children:[n.jsxs("p",{role:"status",className:"text-muted-foreground flex items-center gap-2 text-sm",children:[n.jsx(Oe,{className:"size-4"})," Moving your history…"]}),c&&n.jsx("p",{className:"text-sm",children:c}),r]}),actions:n.jsxs(n.Fragment,{children:[o,n.jsx(F,{onClick:t.onClose,children:"Close"})]})}}case"failed":{const c=fu(s.failureCode??"unrecognised");return{title:c.title,description:c.next,body:n.jsx("p",{className:"text-muted-foreground text-sm",children:"Nothing was kept. Your old space is unchanged."}),actions:n.jsxs(n.Fragment,{children:[i,a]})}}case"cancelled":return{title:"Move cancelled",description:"Nothing was kept. Your old space is unchanged.",actions:n.jsxs(n.Fragment,{children:[i,a]})};case"unrecognised":return{title:`Moving ${s.name}`,description:"Update DorkOS to see where this move is.",body:r,actions:i}}}function _S(e){return e.open?n.jsx(PS,{...e}):null}function PS({open:e,onOpenChange:t,installName:s,resumeMoveId:r,onConnected:o}){var I,v;const[a,i]=u.useState("explain"),[c,d]=u.useState(null),[l,m]=u.useState(""),[h,p]=u.useState(""),f=xS(r),g=yu(a==="choose"&&!f.step?h:""),x=((I=f.step)==null?void 0:I.kind)==="ready"?f.step.move:null,y=Go(x?{communityId:x.communityId,name:x.name,communityUrl:x.communityUrl}:null,s,o),b=()=>t(!1);function C(E){E.preventDefault();const R=Qn(h);!c||l.trim()===""||!R.valid||f.start({file:c,name:l,shortName:R.value})}let k;return f.sending?k=DS(f.sending,()=>void f.cancel()):((v=f.step)==null?void 0:v.kind)==="ready"?k=Qo({state:y.state,name:f.step.move.name,doneDetail:ES,onOpenClaim:y.openClaim,onConfirmClaimed:y.confirmClaimed,onOpenApproval:y.openApproval,onRetryConnect:y.retryConnect,onClose:b}):f.step?k=MS(f.step,{busy:f.busy,notice:f.failure.notice,onCancelMove:()=>void f.cancel(),onSendAgain:()=>void f.sendAgain(),onStartOver:()=>{f.startOver(),i("choose")},onClose:b}):a==="explain"?k=IS(()=>i("choose"),b):k=TS({file:c,onFileChange:d,name:l,onNameChange:m,webAddress:h,onWebAddressChange:E=>{p(E),f.clearFieldFailure()},webAddressStatus:g,failure:f.failure,formId:"move-community-form",onSubmit:C,onBack:()=>i("explain")}),n.jsx(Vo,{open:e,onOpenChange:t,step:k,locked:f.sending!==null})}function LS(e){const t=Qn(e.webAddress),s=e.name.trim()===""||!t.valid||e.webAddressStatus.kind==="taken"||e.webAddressStatus.kind==="reserved",r=pu(e.allowance);return{title:"Start a space",description:"Share channels with people and agents. You own it.",body:n.jsxs("form",{id:e.formId,onSubmit:e.onSubmit,className:"space-y-4",noValidate:!0,children:[n.jsx(vu,{name:e.name,onNameChange:e.onNameChange,webAddress:e.webAddress,onWebAddressChange:e.onWebAddressChange,webAddressStatus:e.webAddressStatus,webAddressError:e.failure.field,disabled:e.submitting}),r&&n.jsx("p",{className:"text-muted-foreground text-sm",children:r}),e.failure.notice&&n.jsx(Vt,{notice:e.failure.notice}),n.jsx(Po,{})]}),actions:n.jsxs(n.Fragment,{children:[n.jsx(F,{type:"button",variant:"outline",onClick:e.onCancel,children:"Cancel"}),n.jsx(F,{type:"submit",form:e.formId,disabled:s||e.submitting,children:e.submitting?"Starting…":"Start space"})]})}}function FS(e){return e.open?n.jsx($S,{...e}):null}function $S({open:e,onOpenChange:t,installName:s,allowance:r,onConnected:o}){const[a,i]=u.useState(""),[c,d]=u.useState(""),[l,m]=u.useState(null),h=fS(),p=yu(l?"":c),f=Go(l,s,o),g=()=>t(!1);async function x(b){b.preventDefault();const C=Qn(c);if(a.trim()===""||!C.valid||h.submitting)return;const k=await h.submit({name:a,shortName:C.value});k&&m({communityId:k.community.communityId,name:k.community.name,communityUrl:k.community.communityUrl})}const y=l?Qo({state:f.state,name:l.name,doneDetail:"Invite people from the space’s own settings when you’re ready.",onOpenClaim:f.openClaim,onConfirmClaimed:f.confirmClaimed,onOpenApproval:f.openApproval,onRetryConnect:f.retryConnect,onClose:g}):LS({name:a,webAddress:c,onNameChange:i,onWebAddressChange:b=>{d(b),h.clearFieldFailure()},webAddressStatus:p,submitting:h.submitting,failure:h.failure,allowance:r,formId:"start-community-form",onSubmit:b=>void x(b),onCancel:g});return n.jsx(Vo,{open:e,onOpenChange:t,step:y,locked:h.submitting})}function BS({entry:e,dialog:t,onDialogChange:s,installName:r,onConnected:o}){if(e===null)return null;const a=i=>{i||s(null)};return n.jsxs(n.Fragment,{children:[n.jsx(FS,{open:(t==null?void 0:t.kind)==="start",onOpenChange:a,installName:r,allowance:e.allowance,onConnected:o}),n.jsx(_S,{open:(t==null?void 0:t.kind)==="move",onOpenChange:a,installName:r,resumeMoveId:(t==null?void 0:t.kind)==="move"?t.moveId:null,onConnected:o},(t==null?void 0:t.kind)==="move"?t.moveId??"new":"closed"),n.jsx(CS,{open:(t==null?void 0:t.kind)==="hosted",onOpenChange:a,installName:r,onOpenMove:i=>s({kind:"move",moveId:i}),onMoveHere:()=>s({kind:"move",moveId:e.unfinishedMoveId}),onConnected:o})]})}const zS=.1;function US(e){if(!(e!=null&&e.available)||e.balance===null)return null;const{allowance:t,purchased:s,denomination:r}=e.balance,o=Vx(t.remainingMicro,t.grantedMicro);if(o===null||o>=zS||!/^\d+$/.test(t.remainingMicro)||!/^\d+$/.test(s.remainingMicro)||BigInt(s.remainingMicro)>0n)return null;const a=Qx(Xx(t.remainingMicro,r));return a===null?null:`${a} left`}function KS(e){if(e.state!=="loading")return e.state==="signed-out"?"Not signed in":["Signed in",e.label,e.lowCredits].filter(Boolean).join(" · ")}function HS(){var r;const e=nl(),t=((r=e.data)==null?void 0:r.linked)===!0,s=sl({enabled:t});return e.data===void 0?{state:"loading"}:t?{state:"signed-in",label:e.data.accountLabel,lowCredits:US(s.data)}:{state:"signed-out"}}function WS(){const e=le();fe("commands_changed",()=>{e.invalidateQueries({queryKey:["commands"]})})}function ju(e){return e.kind==="agent"?qt("agent",e.agent.projectPath):qt("room",e.room.id)}function zr(e){return e.kind==="agent"?Le(e.agent):e.room.kind==="channel"&&e.room.slug?`#${e.room.slug}`:e.room.title}function ui(e){return`Chats ${e.kind==="agent"?"with":"in"} ${zr(e)}`}function GS(e){return e.kind==="agent"?`No chats with ${zr(e)} yet.`:`No chats came from ${zr(e)}.`}function qS(e){return e.kind==="channel"&&e.slug?`#${e.slug}`:e.title}function YS(e){const t=new Map,s=[...e].sort((r,o)=>{const a=+(r.kind==="dm")-+(o.kind==="dm");return a!==0?a:Number(r.archived)-Number(o.archived)});for(const r of s){const o=qS(r);t.has(o)||t.set(o,r.id)}return t}function VS(e,t){const s=[];e.cwd!==null&&s.push(qt("agent",e.cwd));const r=QS(e,t);return r!==void 0&&s.push(qt("room",r)),s}function QS(e,t){if(e.origin==="room"){if(e.originRoomId!==void 0)return e.originRoomId;if(e.originLabel!==void 0)return t.get(e.originLabel)}}function XS(e,t){const s=Number(e.archived)-Number(t.archived);if(s!==0)return s;const r=Number(_n(t))-Number(_n(e));return r!==0?r:t.lastActivityAt.localeCompare(e.lastActivityAt)||t.id.localeCompare(e.id)}function dr(e){return[...e].sort(XS)}function Ur(e){const t=[e.title];e.slug&&t.push(e.slug);for(const s of e.participants??[])t.push(s.displayName);return t}function JS(){const{data:e,isLoading:t,isError:s}=Ls({includeArchived:!0});return u.useMemo(()=>{const r=e??[],o=dr(r.filter(i=>i.kind==="channel")),a=dr(r.filter(i=>i.kind==="dm"));return{channels:o,dms:a,unread:dr([...o,...a].filter(i=>!i.archived&&_n(i))),isLoading:t,isError:s}},[e,t,s])}const ZS=8;function e0(e,t){const s=new Set(Xh(Object.keys(e),t)),r=[];for(const[o,a]of Object.entries(e))a&&s.has(o)&&(a.lifecycle!=="streaming"&&a.lifecycle!=="blocked"||r.push({sessionId:o,lifecycle:a.lifecycle,activity:a.activity??null}));return r.sort((o,a)=>o.lifecycle!==a.lifecycle?o.lifecycle==="blocked"?-1:1:o.sessionId.localeCompare(a.sessionId))}function mi(e){const t=Date.parse(e.lastActivityAt);return Number.isNaN(t)?Number.NEGATIVE_INFINITY:t}function t0(e){return!(e.unreadCount===null||e.archived||e.lastActivityAt===e.createdAt)}function n0({sessions:e,rooms:t,unreadRoomIds:s,agents:r,agentActivity:o,excludeSessionIds:a=new Set,limit:i=ZS}){const c=e.filter(g=>!a.has(g.id)).map(g=>({kind:"session",key:`session:${g.id}`,lastActivityAt:g.lastActivityAt,session:g})),d=new Set(e.flatMap(g=>g.cwd?[g.cwd]:[])),l=t.filter(t0).map(g=>({kind:"room",key:`room:${g.id}`,lastActivityAt:g.lastActivityAt,room:g})),m=r.flatMap(g=>{if(d.has(g.projectPath))return[];const x=o[g.projectPath];return x?[{kind:"agent",key:`agent:${g.projectPath}`,lastActivityAt:x,agent:g}]:[]}),h=[],p=[];for(const g of[...c,...l,...m])g.kind==="room"&&s.has(g.room.id)?h.push(g):p.push(g);const f=(g,x)=>mi(x)-mi(g)||x.key.localeCompare(g.key);return[...h.sort(f),...p.sort(f)].slice(0,i)}const s0=50;function ku(e){const t=[e.id];return e.who&&t.push(e.who),e.cwd&&t.push(e.cwd),t}function r0(e){return e?e.split("/").filter(Boolean).pop()??null:null}function hi(e,t,s){const r=new Map(t.map(o=>[o.projectPath,o]));return e.map(o=>{const a=o.cwd??null,i=a?r.get(a)??null:null,c=Date.parse(o.updatedAt);return{id:o.id,who:i?Le(i):r0(a),title:rl(o.title),cwd:a,agent:i,origin:o.origin,originLabel:o.originLabel,originRoomId:o.originRoomId,lastActivityAt:o.updatedAt,archived:!Number.isNaN(c)&&c<s}})}function o0(e,t,s,r){const{data:o}=ol(s0),a=rt(p=>p.statuses),i=rt(al(p=>Object.values(p.sessions))),c=u.useMemo(()=>hi((o==null?void 0:o.sessions)??[],e,r),[o==null?void 0:o.sessions,e,r]),d=u.useMemo(()=>hi(i,e,r),[i,e,r]),l=u.useMemo(()=>[...i,...(o==null?void 0:o.sessions)??[]],[i,o]),m=u.useMemo(()=>{const p=new Map;for(const f of d)p.set(f.id,f);for(const f of c)p.has(f.id)||p.set(f.id,f);return e0(a,l).flatMap(f=>{const g=p.get(f.sessionId);return g?[{session:g,verb:il(f.lifecycle,f.activity),signal:f.lifecycle==="blocked"?"needs-you":"working"}]:[]})},[a,d,c,l]),h=u.useMemo(()=>{const p=new Set(Jh((o==null?void 0:o.sessions)??[]).yours.map(f=>f.id));return n0({sessions:c.filter(f=>p.has(f.id)),rooms:t,unreadRoomIds:s,agents:e,agentActivity:(o==null?void 0:o.agentActivity)??{},excludeSessionIds:new Set(m.map(f=>f.session.id))})},[o,c,t,s,e,m]);return{sessions:c,continueRows:m,recent:h,agentActivity:(o==null?void 0:o.agentActivity)??a0}}const a0=Object.freeze({});function i0(){const{data:e,dataUpdatedAt:t}=Me(),s=e!==void 0&&t>ln,{status:r,url:o}=Zh(e==null?void 0:e.tunnel),a=u.useRef(void 0);u.useEffect(()=>{if(!s)return;const i=a.current;a.current=r,!(i===void 0||i===r)&&(ua.getState().consumeSuppression()||ef(ua.getState().report)||(r==="reconnecting"?ce.warning("Remote access is reconnecting",{id:"tunnel-status",description:"Your other devices can’t reach DorkOS until then."}):r==="off"?ce.error("Remote access turned off",{id:"tunnel-status",description:"Your other devices can’t reach DorkOS now."}):o&&ce.success("Remote access is on",{id:"tunnel-status",description:o})))},[s,r,o])}const pt={copyLink:"copyRemoteLink",showQr:"showRemoteQr",turnOn:"turnRemoteAccessOn",turnOff:"turnRemoteAccessOff"},Cn={copyLink:11,showQr:12,turnOff:13,turnOn:11};function c0(e,t,s){return(e==="connected"||e==="reconnecting"||e==="asleep")&&t?[{id:"remote-access-copy",label:"Copy remote link",icon:"Copy",action:pt.copyLink,category:"quick-action",priority:Cn.copyLink,keywords:["remote","tunnel","url","address","phone","share"]},{id:"remote-access-qr",label:"Show QR code",icon:"QrCode",action:pt.showQr,category:"quick-action",priority:Cn.showQr,keywords:["remote","tunnel","scan","phone"]},{id:"remote-access-off",label:"Turn remote access off",icon:"Globe",action:pt.turnOff,category:"quick-action",priority:Cn.turnOff,keywords:["remote","tunnel","ngrok","stop","disconnect"]}]:e==="asleep"||e==="blocked"?[{id:"remote-access-off",label:"Turn remote access off",icon:"Globe",action:pt.turnOff,category:"quick-action",priority:Cn.turnOff,keywords:["remote","tunnel","ngrok","stop","disconnect"]}]:s&&(e==="off"||e==="error")?[{id:"remote-access-on",label:"Turn remote access on",icon:"Globe",action:pt.turnOn,category:"quick-action",priority:Cn.turnOn,keywords:["remote","tunnel","ngrok","phone","start"]}]:[]}function l0(){const{state:e,url:t,isSetUp:s}=cl();return u.useMemo(()=>c0(e,t,s),[e,t,s])}const d0=new Set(["discover","browse"]),es={usageKey:null,lastActivityAt:null,waiting:!1,demoted:!1,scopes:[]};function fi(e){return{usageKey:qt("room",e.id),lastActivityAt:e.lastActivityAt,waiting:_n(e),demoted:e.archived,scopes:[]}}const u0=[];function m0(e,t){const{data:s,isLoading:r}=qn(),o=JS(),{sessions:a}=ll(),i=u.useMemo(()=>!a||!e?null:tf(a,e)[0]??null,[a,e]),{data:c}=_b(e,i==null?void 0:i.id,i==null?void 0:i.runtime),d=_s("command-palette.items"),l=xo(),m=u.useMemo(()=>l.map(j=>({id:j.id,label:j.title,href:Lc(j.extensionId,j.path),icon:j.icon})),[l]),h=Os(),p=u.useMemo(()=>{const j=new Set(nf(h).map(N=>N.id)),w=new Set(sf.map(N=>N.id).filter(N=>!j.has(N)));return d.filter(N=>{if(N.category!=="feature")return!1;const S=dl(N.action);return S===null||!w.has(S)})},[d,h]),f=l0(),g=h?u0:f,x=u.useMemo(()=>[...d.filter(j=>j.category==="quick-action"&&!(h&&d0.has(j.id))),...g],[d,g,h]),y=u.useMemo(()=>rf.flatMap(j=>{const w=x.find(N=>N.id===j);return w?[w]:[]}),[x]),b=u.useMemo(()=>(s==null?void 0:s.agents)??[],[s]),C=u.useMemo(()=>new Set(o.unread.map(j=>j.id)),[o.unread]),k=u.useMemo(()=>[...o.channels,...o.dms],[o.channels,o.dms]),I=u.useMemo(()=>of(t),[t]),{sessions:v,continueRows:E,recent:R,agentActivity:_}=o0(b,k,C,I),D=u.useMemo(()=>YS(k),[k]),P=u.useMemo(()=>c?c.commands.map(j=>({name:j.fullCommand,description:j.description})):[],[c]),T=u.useMemo(()=>{const j=[];for(const w of b)j.push({id:w.id,name:w.name,type:"agent",keywords:[w.projectPath,w.id],usageKey:qt("agent",w.projectPath),lastActivityAt:_[w.projectPath]??null,waiting:!1,demoted:!1,scopes:[],data:w});for(const w of v)j.push({id:w.id,name:w.title,type:"session",keywords:ku(w),usageKey:qt("session",w.id),lastActivityAt:w.lastActivityAt,waiting:!1,demoted:!1,scopes:VS(w,D),data:w});for(const w of p)j.push({id:w.id,name:w.label,type:"feature",keywords:w.keywords,...es,data:w});for(const w of P)j.push({id:`cmd-${w.name}`,name:w.name,type:"command",keywords:w.description?[w.description]:void 0,...es,data:w});for(const w of x)j.push({id:w.id,name:w.label,type:"quick-action",keywords:w.keywords,...es,data:w});for(const w of o.channels)j.push({id:w.id,name:af(w),type:"room",keywords:Ur(w),...fi(w),data:w});for(const w of o.dms)j.push({id:w.id,name:w.title,type:"dm",keywords:Ur(w),...fi(w),data:w});for(const w of m)j.push({id:w.id,name:w.label,type:"page",keywords:["add-on","extension"],...es,data:w});return j},[b,_,v,P,p,x,o.channels,o.dms,D,m]);return{allAgents:b,newActions:y,rooms:o,sessions:v,continueRows:E,recent:R,searchableItems:T,isLoading:r}}function h0(){const e=L(a=>a.toggleGlobalPalette),t=L(a=>a.setGlobalPaletteOpen),s=L(a=>a.globalPaletteOpen),{close:r}=ct(),{close:o}=wo();return u.useEffect(()=>{const a=i=>{(i.metaKey||i.ctrlKey)&&i.key==="k"&&(i.preventDefault(),s||(r(),o()),e())};return document.addEventListener("keydown",a),()=>document.removeEventListener("keydown",a)},[e,r,o,s]),{globalPaletteOpen:s,setGlobalPaletteOpen:t,toggleGlobalPalette:e}}function Ot(e){return Array.isArray?Array.isArray(e):Cu(e)==="[object Array]"}function f0(e){if(typeof e=="string")return e;if(typeof e=="bigint")return e.toString();const t=e+"";return t=="0"&&1/e==-1/0?"-0":t}function Kr(e){return e==null?"":f0(e)}function Te(e){return typeof e=="string"}function ds(e){return typeof e=="number"}function p0(e){return e===!0||e===!1||g0(e)&&Cu(e)=="[object Boolean]"}function Su(e){return typeof e=="object"}function g0(e){return Su(e)&&e!==null}function Ke(e){return e!=null}function ts(e){return!e.trim().length}function Cu(e){return e==null?e===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(e)}const x0="Incorrect 'index' type",Hr="Invalid doc index: must be a non-negative integer within the bounds of the docs array",b0=e=>`Invalid value for key ${e}`,y0=e=>`Pattern length exceeds max of ${e}.`,v0=e=>`Missing ${e} property in key`,w0=e=>`Property 'weight' in key '${e}' must be a positive integer`,j0="Fuse.match does not support useTokenSearch: token search requires corpus-level statistics (df, fieldCount) that a one-off string comparison does not have. Use new Fuse(...).search(...) instead.",pi=Object.prototype.hasOwnProperty;var k0=class{constructor(e){this._keys=[],this._keyMap={};let t=0;e.forEach(s=>{const r=Nu(s);this._keys.push(r),this._keyMap[r.id]=r,t+=r.weight}),this._keys.forEach(s=>{s.weight/=t})}get(e){return this._keyMap[e]}keys(){return this._keys}toJSON(){return JSON.stringify(this._keys)}};function Nu(e){let t=null,s=null,r=null,o=1,a=null;if(Te(e)||Ot(e))r=e,t=gi(e),s=us(e);else{if(!pi.call(e,"name"))throw new Error(v0("name"));const i=e.name;if(r=i,pi.call(e,"weight")&&e.weight!==void 0&&(o=e.weight,o<=0))throw new Error(w0(us(i)));t=gi(i),s=us(i),a=e.getFn??null}return{path:t,id:s,weight:o,src:r,getFn:a}}function gi(e){return Ot(e)?e:e.split(".")}function us(e){return Ot(e)?e.join("."):e}function S0(e,t){const s=[];let r=!1;const o=(a,i,c,d)=>{if(Ke(a))if(!i[c])s.push(d!==void 0?{v:a,i:d}:a);else{const l=a[i[c]];if(!Ke(l))return;if(c===i.length-1&&(Te(l)||ds(l)||p0(l)||typeof l=="bigint"))s.push(d!==void 0?{v:Kr(l),i:d}:Kr(l));else if(Ot(l)){r=!0;for(let m=0,h=l.length;m<h;m+=1)o(l[m],i,c+1,m)}else i.length&&o(l,i,c+1,d)}};return o(e,Te(t)?t.split("."):t,0),r?s:s[0]}const C0={includeMatches:!1,findAllMatches:!1,minMatchCharLength:1},N0={isCaseSensitive:!1,ignoreDiacritics:!1,includeScore:!1,keys:[],shouldSort:!0,sortFn:(e,t)=>e.score===t.score?e.idx<t.idx?-1:1:e.score<t.score?-1:1},A0={location:0,threshold:.6,distance:100},E0={useExtendedSearch:!1,useTokenSearch:!1,tokenize:void 0,tokenMatch:"any",getFn:S0,ignoreLocation:!1,ignoreFieldNorm:!1,fieldNormWeight:1},X=Object.freeze({...N0,...C0,...A0,...E0});function I0(e){return e>=9&&e<=13||e===32||e===160}function R0(e=1,t=3){const s=new Map,r=Math.pow(10,t);return{get(o){let a=0,i=!1;for(let d=0;d<o.length;d++)I0(o.charCodeAt(d))?i=!1:i||(a++,i=!0);if(a===0&&(a=1),s.has(a))return s.get(a);const c=Math.round(r/Math.pow(a,.5*e))/r;return s.set(a,c),c},clear(){s.clear()}}}var Xo=class{constructor({getFn:e=X.getFn,fieldNormWeight:t=X.fieldNormWeight}={}){this.norm=R0(t,3),this.getFn=e,this.isCreated=!1,this.docs=[],this.keys=[],this._keysMap={},this.setIndexRecords()}setSources(e=[]){this.docs=e}setIndexRecords(e=[]){this.records=e}setKeys(e=[]){this.keys=e,this._keysMap={},e.forEach((t,s)=>{this._keysMap[t.id]=s})}create(){if(this.isCreated||!this.docs.length)return;this.isCreated=!0;const e=this.docs.length;this.records=new Array(e);let t=0;if(Te(this.docs[0]))for(let s=0;s<e;s++){const r=this._createStringRecord(this.docs[s],s);r&&(this.records[t++]=r)}else for(let s=0;s<e;s++)this.records[t++]=this._createObjectRecord(this.docs[s],s);this.records.length=t,this.norm.clear()}add(e,t){if(!Number.isInteger(t)||t<0)throw new Error(Hr);if(Te(e)){const r=this._createStringRecord(e,t);return r&&this.records.push(r),r}const s=this._createObjectRecord(e,t);return this.records.push(s),s}removeAt(e){if(!Number.isInteger(e)||e<0)throw new Error(Hr);for(let t=0,s=this.records.length;t<s;t+=1)if(this.records[t].i===e){this.records.splice(t,1);break}for(let t=0,s=this.records.length;t<s;t+=1)this.records[t].i>e&&(this.records[t].i-=1)}removeAll(e){const t=new Set;for(const r of e)Number.isInteger(r)&&r>=0&&t.add(r);if(t.size===0)return;this.records=this.records.filter(r=>!t.has(r.i));const s=Array.from(t).sort((r,o)=>r-o);for(const r of this.records){let o=0,a=s.length;for(;o<a;){const i=o+a>>>1;s[i]<r.i?o=i+1:a=i}r.i-=o}}getValueForItemAtKeyId(e,t){return e[this._keysMap[t]]}size(){return this.records.length}_createStringRecord(e,t){return!Ke(e)||ts(e)?null:{v:e,i:t,n:this.norm.get(e)}}_createObjectRecord(e,t){const s={i:t,$:{}};for(let r=0,o=this.keys.length;r<o;r++){const a=this.keys[r],i=a.getFn?a.getFn(e):this.getFn(e,a.path);if(Ke(i)){if(Ot(i)){const c=[];for(let d=0,l=i.length;d<l;d+=1){const m=i[d];if(Ke(m)){if(Te(m)){if(!ts(m)){const h={v:m,i:d,n:this.norm.get(m)};c.push(h)}}else if(Ke(m.v)){const h=Te(m.v)?m.v:Kr(m.v);if(!ts(h)){const p={v:h,i:m.i,n:this.norm.get(h)};c.push(p)}}}}s.$[r]=c}else if(Te(i)&&!ts(i)){const c={v:i,n:this.norm.get(i)};s.$[r]=c}}}return s}toJSON(){return{keys:this.keys.map(({getFn:e,...t})=>t),records:this.records}}};function Au(e,t,{getFn:s=X.getFn,fieldNormWeight:r=X.fieldNormWeight}={}){const o=new Xo({getFn:s,fieldNormWeight:r});return o.setKeys(e.map(Nu)),o.setSources(t),o.create(),o}function T0(e,{getFn:t=X.getFn,fieldNormWeight:s=X.fieldNormWeight}={}){const{keys:r,records:o}=e,a=new Xo({getFn:t,fieldNormWeight:s});return a.setKeys(r),a.setIndexRecords(o),a}function D0(e=[],t=X.minMatchCharLength){const s=[];let r=-1,o=-1,a=0;for(let i=e.length;a<i;a+=1){const c=e[a];c&&r===-1?r=a:!c&&r!==-1&&(o=a-1,o-r+1>=t&&s.push([r,o]),r=-1)}return e[a-1]&&a-r>=t&&s.push([r,a-1]),s}function O0(e,t,s,{location:r=X.location,distance:o=X.distance,threshold:a=X.threshold,findAllMatches:i=X.findAllMatches,minMatchCharLength:c=X.minMatchCharLength,includeMatches:d=X.includeMatches,ignoreLocation:l=X.ignoreLocation}={}){if(t.length>32)throw new Error(y0(32));const m=t.length,h=e.length,p=Math.max(0,Math.min(r,h));let f=a,g=p;const x=(D,P)=>{const T=D/m;if(l)return T;const j=Math.abs(p-P);return o?T+j/o:j?1:T},y=c>1||d,b=y?Array(h):[];let C;for(;(C=e.indexOf(t,g))>-1;){const D=x(0,C);if(f=Math.min(D,f),g=C+m,y){let P=0;for(;P<m;)b[C+P]=1,P+=1}}g=-1;let k=[],I=1,v=0,E=m+h;const R=1<<m-1;for(let D=0;D<m;D+=1){let P=0,T=E;for(;P<T;)x(D,p+T)<=f?P=T:E=T,T=Math.floor((E-P)/2+P);E=T;let j=Math.max(1,p-T+1);const w=i?h:Math.min(p+T,h)+m,N=Array(w+2);N[w+1]=(1<<D)-1;for(let S=w;S>=j;S-=1){const M=S-1,B=s[e[M]];if(N[S]=(N[S+1]<<1|1)&B,D&&(N[S]|=(k[S+1]|k[S])<<1|1|k[S+1]),N[S]&R&&(I=x(D,M),I<=f)){if(f=I,g=M,v=D,g<=p)break;j=Math.max(1,2*p-g)}}if(x(D+1,p)>f)break;k=N}if(y&&g>=0){const D=Math.min(h-1,g+m-1+v);for(let P=g;P<=D;P+=1)s[e[P]]&&(b[P]=1)}const _={isMatch:g>=0,score:Math.max(.001,I)};if(y){const D=D0(b,c);D.length?d&&(_.indices=D):_.isMatch=!1}return _}function M0(e){const t={};for(let s=0,r=e.length;s<r;s+=1){const o=e.charAt(s);t[o]=(t[o]||0)|1<<r-s-1}return t}function Jo(e){if(e.length<=1)return e;e.sort((s,r)=>s[0]-r[0]||s[1]-r[1]);const t=[e[0]];for(let s=1,r=e.length;s<r;s+=1){const o=t[t.length-1],a=e[s];a[0]<=o[1]+1?o[1]=Math.max(o[1],a[1]):t.push(a)}return t}const Eu={ł:"l",Ł:"L",đ:"d",Đ:"D",ø:"o",Ø:"O",ħ:"h",Ħ:"H",ŧ:"t",Ŧ:"T",ı:"i",ß:"ss"},_0=new RegExp("["+Object.keys(Eu).join("")+"]","g"),$n=typeof String.prototype.normalize=="function"?e=>e.normalize("NFD").replace(/[\u0300-\u036F\u0483-\u0489\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u0711\u0730-\u074A\u07A6-\u07B0\u07EB-\u07F3\u07FD\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u08D3-\u08E1\u08E3-\u0903\u093A-\u093C\u093E-\u094F\u0951-\u0957\u0962\u0963\u0981-\u0983\u09BC\u09BE-\u09C4\u09C7\u09C8\u09CB-\u09CD\u09D7\u09E2\u09E3\u09FE\u0A01-\u0A03\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A70\u0A71\u0A75\u0A81-\u0A83\u0ABC\u0ABE-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AE2\u0AE3\u0AFA-\u0AFF\u0B01-\u0B03\u0B3C\u0B3E-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B62\u0B63\u0B82\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD7\u0C00-\u0C04\u0C3E-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C81-\u0C83\u0CBC\u0CBE-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0D00-\u0D03\u0D3B\u0D3C\u0D3E-\u0D44\u0D46-\u0D48\u0D4A-\u0D4D\u0D57\u0D62\u0D63\u0D82\u0D83\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DF2\u0DF3\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0EB1\u0EB4-\u0EB9\u0EBB\u0EBC\u0EC8-\u0ECD\u0F18\u0F19\u0F35\u0F37\u0F39\u0F3E\u0F3F\u0F71-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102B-\u103E\u1056-\u1059\u105E-\u1060\u1062-\u1064\u1067-\u106D\u1071-\u1074\u1082-\u108D\u108F\u109A-\u109D\u135D-\u135F\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17B4-\u17D3\u17DD\u180B-\u180D\u1885\u1886\u18A9\u1920-\u192B\u1930-\u193B\u1A17-\u1A1B\u1A55-\u1A5E\u1A60-\u1A7C\u1A7F\u1AB0-\u1ABE\u1B00-\u1B04\u1B34-\u1B44\u1B6B-\u1B73\u1B80-\u1B82\u1BA1-\u1BAD\u1BE6-\u1BF3\u1C24-\u1C37\u1CD0-\u1CD2\u1CD4-\u1CE8\u1CED\u1CF2-\u1CF4\u1CF7-\u1CF9\u1DC0-\u1DF9\u1DFB-\u1DFF\u20D0-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\uA66F-\uA672\uA674-\uA67D\uA69E\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA823-\uA827\uA880\uA881\uA8B4-\uA8C5\uA8E0-\uA8F1\uA8FF\uA926-\uA92D\uA947-\uA953\uA980-\uA983\uA9B3-\uA9C0\uA9E5\uAA29-\uAA36\uAA43\uAA4C\uAA4D\uAA7B-\uAA7D\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEB-\uAAEF\uAAF5\uAAF6\uABE3-\uABEA\uABEC\uABED\uFB1E\uFE00-\uFE0F\uFE20-\uFE2F]/g,"").replace(_0,t=>Eu[t]):e=>e;var Zo=class{constructor(e,{location:t=X.location,threshold:s=X.threshold,distance:r=X.distance,includeMatches:o=X.includeMatches,findAllMatches:a=X.findAllMatches,minMatchCharLength:i=X.minMatchCharLength,isCaseSensitive:c=X.isCaseSensitive,ignoreDiacritics:d=X.ignoreDiacritics,ignoreLocation:l=X.ignoreLocation}={}){if(this.options={location:t,threshold:s,distance:r,includeMatches:o,findAllMatches:a,minMatchCharLength:i,isCaseSensitive:c,ignoreDiacritics:d,ignoreLocation:l},e=c?e:e.toLowerCase(),e=d?$n(e):e,this.pattern=e,this.chunks=[],!this.pattern.length)return;const m=(p,f)=>{this.chunks.push({pattern:p,alphabet:M0(p),startIndex:f})},h=this.pattern.length;if(h>32){let p=0;const f=h%32,g=h-f;for(;p<g;)m(this.pattern.substr(p,32),p),p+=32;if(f){const x=h-32;m(this.pattern.substr(x),x)}}else m(this.pattern,0)}searchIn(e){const{isCaseSensitive:t,ignoreDiacritics:s,includeMatches:r}=this.options;if(e=t?e:e.toLowerCase(),e=s?$n(e):e,this.pattern===e){if(e.length<this.options.minMatchCharLength)return{isMatch:!1,score:1};const g={isMatch:!0,score:0};return r&&(g.indices=[[0,e.length-1]]),g}const{location:o,distance:a,threshold:i,findAllMatches:c,minMatchCharLength:d,ignoreLocation:l}=this.options,m=[];let h=0,p=!1;this.chunks.forEach(({pattern:g,alphabet:x,startIndex:y})=>{const{isMatch:b,score:C,indices:k}=O0(e,g,x,{location:o+y,distance:a,threshold:i,findAllMatches:c,minMatchCharLength:d,includeMatches:r,ignoreLocation:l});b&&(p=!0),h+=C,b&&k&&m.push(...k)});const f={isMatch:p,score:p?h/this.chunks.length:1};return p&&r&&(f.indices=Jo(m)),f}};const P0=new Set(["fuzzy","include"]);function L0(e){return e.startsWith("inverse")}const Wr=[{type:"exact",multiRegex:/^="(.*)"$/,singleRegex:/^=(.*)$/,create:e=>({type:"exact",search(t){const s=t===e;return{isMatch:s,score:s?0:1,indices:[0,e.length-1]}}})},{type:"include",multiRegex:/^'"(.*)"$/,singleRegex:/^'(.*)$/,create:e=>({type:"include",search(t){let s=0,r;const o=[],a=e.length;for(;(r=t.indexOf(e,s))>-1;)s=r+a,o.push([r,s-1]);const i=!!o.length;return{isMatch:i,score:i?0:1,indices:o}}})},{type:"prefix-exact",multiRegex:/^\^"(.*)"$/,singleRegex:/^\^(.*)$/,create:e=>({type:"prefix-exact",search(t){const s=t.startsWith(e);return{isMatch:s,score:s?0:1,indices:[0,e.length-1]}}})},{type:"inverse-prefix-exact",multiRegex:/^!\^"(.*)"$/,singleRegex:/^!\^(.*)$/,create:e=>({type:"inverse-prefix-exact",search(t){const s=!t.startsWith(e);return{isMatch:s,score:s?0:1,indices:[0,t.length-1]}}})},{type:"inverse-suffix-exact",multiRegex:/^!"(.*)"\$$/,singleRegex:/^!(.*)\$$/,create:e=>({type:"inverse-suffix-exact",search(t){const s=!t.endsWith(e);return{isMatch:s,score:s?0:1,indices:[0,t.length-1]}}})},{type:"suffix-exact",multiRegex:/^"(.*)"\$$/,singleRegex:/^(.*)\$$/,create:e=>({type:"suffix-exact",search(t){const s=t.endsWith(e);return{isMatch:s,score:s?0:1,indices:[t.length-e.length,t.length-1]}}})},{type:"inverse-exact",multiRegex:/^!"(.*)"$/,singleRegex:/^!(.*)$/,create:e=>({type:"inverse-exact",search(t){const s=t.indexOf(e)===-1;return{isMatch:s,score:s?0:1,indices:[0,t.length-1]}}})},{type:"fuzzy",multiRegex:/^"(.*)"$/,singleRegex:/^(.*)$/,create:(e,t={})=>{const s=new Zo(e,{location:t.location??X.location,threshold:t.threshold??X.threshold,distance:t.distance??X.distance,includeMatches:t.includeMatches??X.includeMatches,findAllMatches:t.findAllMatches??X.findAllMatches,minMatchCharLength:t.minMatchCharLength??X.minMatchCharLength,isCaseSensitive:t.isCaseSensitive??X.isCaseSensitive,ignoreDiacritics:t.ignoreDiacritics??X.ignoreDiacritics,ignoreLocation:t.ignoreLocation??X.ignoreLocation});return{type:"fuzzy",search(r){return s.searchIn(r)}}}}],xi=Wr.length,F0="\0",$0="|";function B0(e){const t=[],s=e.length;let r=0;for(;r<s;){for(;r<s&&e[r]===" ";)r++;if(r>=s)break;let o=r;for(;o<s&&e[o]!==" "&&e[o]!=='"';)o++;if(o<s&&e[o]==='"'){for(o++;o<s;){if(e[o]==='"'){const a=o+1;if(a>=s||e[a]===" "){o++;break}if(e[a]==="$"&&(a+1>=s||e[a+1]===" ")){o+=2;break}}o++}t.push(e.substring(r,o)),r=o}else{for(;o<s&&e[o]!==" ";)o++;t.push(e.substring(r,o)),r=o}}return t}function bi(e,t){const s=e.match(t);return s?s[1]:null}function z0(e,t={}){return e.replace(/\\\|/g,F0).split($0).map(s=>{const r=B0(s.replace(/\u0000/g,"|").trim()).filter(a=>a&&!!a.trim()),o=[];for(let a=0,i=r.length;a<i;a+=1){const c=r[a];let d=!1,l=-1;for(;!d&&++l<xi;){const m=Wr[l],h=bi(c,m.multiRegex);h&&(o.push(m.create(h,t)),d=!0)}if(!d)for(l=-1;++l<xi;){const m=Wr[l],h=bi(c,m.singleRegex);if(h){o.push(m.create(h,t));break}}}return o})}var U0=class{constructor(e,{isCaseSensitive:t=X.isCaseSensitive,ignoreDiacritics:s=X.ignoreDiacritics,includeMatches:r=X.includeMatches,minMatchCharLength:o=X.minMatchCharLength,ignoreLocation:a=X.ignoreLocation,findAllMatches:i=X.findAllMatches,location:c=X.location,threshold:d=X.threshold,distance:l=X.distance}={}){this.query=null,this.options={isCaseSensitive:t,ignoreDiacritics:s,includeMatches:r,minMatchCharLength:o,findAllMatches:i,ignoreLocation:a,location:c,threshold:d,distance:l},e=t?e:e.toLowerCase(),e=s?$n(e):e,this.pattern=e,this.query=z0(this.pattern,this.options)}static condition(e,t){return t.useExtendedSearch}searchIn(e){const t=this.query;if(!t)return{isMatch:!1,score:1};const{includeMatches:s,isCaseSensitive:r,ignoreDiacritics:o}=this.options;e=r?e:e.toLowerCase(),e=o?$n(e):e;let a=0;const i=[];let c=0,d=!1;for(let l=0,m=t.length;l<m;l+=1){const h=t[l];i.length=0,a=0,d=!1;for(let p=0,f=h.length;p<f;p+=1){const g=h[p],{isMatch:x,indices:y,score:b}=g.search(e);if(x)a+=1,c+=b,L0(g.type)&&(d=!0),s&&(P0.has(g.type)?i.push(...y):i.push(y));else{c=0,a=0,i.length=0,d=!1;break}}if(a){const p={isMatch:!0,score:c/a};return d&&(p.hasInverse=!0),s&&(p.indices=Jo(i)),p}}return{isMatch:!1,score:1}}};const Gr=[];function ea(...e){Gr.push(...e)}function Cs(e,t){for(let s=0,r=Gr.length;s<r;s+=1){const o=Gr[s];if(o.condition(e,t))return new o(e,t)}return new Zo(e,t)}const Ns={AND:"$and",OR:"$or"},qr={PATH:"$path",PATTERN:"$val"},Yr=e=>!!(e[Ns.AND]||e[Ns.OR]),K0=e=>!!e[qr.PATH],H0=e=>!Ot(e)&&Su(e)&&!Yr(e),yi=e=>({[Ns.AND]:Object.keys(e).map(t=>({[t]:e[t]}))});function Iu(e,t,{auto:s=!0}={}){const r=o=>{if(Te(o)){const d={keyId:null,pattern:o};return s&&(d.searcher=Cs(o,t)),d}const a=Object.keys(o),i=K0(o);if(!i&&a.length>1&&!Yr(o))return r(yi(o));if(H0(o)){const d=i?o[qr.PATH]:a[0],l=i?o[qr.PATTERN]:o[d];if(!Te(l))throw new Error(b0(d));const m={keyId:us(d),pattern:l};return s&&(m.searcher=Cs(l,t)),m}const c={children:[],operator:a[0]};return a.forEach(d=>{const l=o[d];Ot(l)&&l.forEach(m=>{c.children.push(r(m))})}),c};return Yr(e)||(e=yi(e)),r(e)}function Vr(e,{ignoreFieldNorm:t=X.ignoreFieldNorm}){let s=1;return e.forEach(({key:r,norm:o,score:a})=>{const i=r?r.weight:null;s*=Math.pow(a===0&&i?Number.EPSILON:a,(i||1)*(t?1:o))}),s}function W0(e,{ignoreFieldNorm:t=X.ignoreFieldNorm}){e.forEach(s=>{s.score=Vr(s.matches,{ignoreFieldNorm:t})})}var G0=class{constructor(e,t){this.limit=e,this.heap=[],this.comparator=t}get size(){return this.heap.length}insert(e){this.size<this.limit?(this.heap.push(e),this._bubbleUp(this.size-1)):this.comparator(e,this.heap[0])<0&&(this.heap[0]=e,this._sinkDown(0))}extractSorted(){return this.heap.sort(this.comparator)}_bubbleUp(e){const t=this.heap;for(;e>0;){const s=e-1>>1;if(this.comparator(t[e],t[s])<=0)break;const r=t[e];t[e]=t[s],t[s]=r,e=s}}_sinkDown(e){const t=this.heap,s=t.length;let r=e;do{e=r;const o=2*e+1,a=2*e+2;if(o<s&&this.comparator(t[o],t[r])>0&&(r=o),a<s&&this.comparator(t[a],t[r])>0&&(r=a),r!==e){const i=t[e];t[e]=t[r],t[r]=i}}while(r!==e)}};function q0(e){const t=[];return e.matches.forEach(s=>{if(!Ke(s.indices)||!s.indices.length)return;const r={indices:s.indices,value:s.value};s.key&&(r.key=s.key.id),s.idx>-1&&(r.refIndex=s.idx),t.push(r)}),t}function Y0(e,t,{includeMatches:s=X.includeMatches,includeScore:r=X.includeScore}={}){return e.map(o=>{const{idx:a}=o,i={item:t[a],refIndex:a};return s&&(i.matches=q0(o)),r&&(i.score=o.score),i})}const V0=/[\p{L}\p{M}\p{N}_]+/gu,vi=new WeakSet;function Q0(e){vi.has(e)||(vi.add(e),console.warn(`[Fuse] tokenize regex ${e} lacks the global flag; only the first match per text will be returned. Add the 'g' flag.`))}function X0(e){if(typeof e=="function"){let t=!1;return s=>{const r=e(s);if(!t&&(t=!0,!Array.isArray(r)||r.some(o=>typeof o!="string")))throw new Error(`[Fuse] tokenize function must return string[]; received ${Array.isArray(r)?"array containing non-strings":typeof r}.`);return r}}return e instanceof RegExp?(e.global||Q0(e),t=>t.match(e)||[]):t=>t.match(V0)||[]}function Qr({isCaseSensitive:e=!1,ignoreDiacritics:t=!1,tokenize:s}={}){const r=X0(s);return{tokenize(o){return e||(o=o.toLowerCase()),t&&(o=$n(o)),r(o)}}}var J0=class{static condition(e,t){return t.useTokenSearch}constructor(e,t){this.options=t,this.analyzer=Qr({isCaseSensitive:t.isCaseSensitive,ignoreDiacritics:t.ignoreDiacritics,tokenize:t.tokenize});const s=this.analyzer.tokenize(e),{df:r,fieldCount:o}=t._invertedIndex;this.termSearchers=[],this.idfWeights=[];for(const a of s){this.termSearchers.push(new Zo(a,{location:t.location,threshold:t.threshold,distance:t.distance,includeMatches:t.includeMatches,findAllMatches:t.findAllMatches,minMatchCharLength:t.minMatchCharLength,isCaseSensitive:t.isCaseSensitive,ignoreDiacritics:t.ignoreDiacritics,ignoreLocation:!0}));const i=r.get(a)||0,c=Math.log(1+(o-i+.5)/(i+.5));this.idfWeights.push(c)}this.combineAll=t.tokenMatch==="all",this.numTerms=this.termSearchers.length,this.useMask=this.numTerms<=31}searchIn(e){if(!this.termSearchers.length)return{isMatch:!1,score:1};const t=[];let s=0,r=0,o=0,a=0;const i=this.combineAll&&!this.useMask?new Set:null;for(let l=0;l<this.termSearchers.length;l++){const m=this.termSearchers[l].searchIn(e),h=this.idfWeights[l];r+=h,m.isMatch&&(o++,s+=h*(1-m.score),m.indices&&t.push(...m.indices),this.combineAll&&(this.useMask?a|=1<<l:i.add(l)))}if(o===0)return{isMatch:!1,score:1};const c=r>0?1-s/r:0,d={isMatch:!0,score:Math.max(.001,c)};return this.options.includeMatches&&t.length&&(d.indices=Jo(t)),this.combineAll&&(this.useMask?d.matchedMask=a:d.matchedTerms=i,d.termCount=this.numTerms),d}};function ur(e,t,s,r){const o=r.tokenize(t);if(!o.length)return;e.fieldCount++,e.docFieldCount.set(s,(e.docFieldCount.get(s)||0)+1);const a=new Set(o);let i=e.docTermFieldHits.get(s);i||(i=new Map,e.docTermFieldHits.set(s,i));for(const c of a)i.set(c,(i.get(c)||0)+1),e.df.set(c,(e.df.get(c)||0)+1)}function Ru(e,t,s,r){const{i:o,v:a,$:i}=t;if(a!==void 0){ur(e,a,o,r);return}if(i)for(let c=0;c<s;c++){const d=i[c];if(d)if(Array.isArray(d))for(const l of d)ur(e,l.v,o,r);else ur(e,d.v,o,r)}}function Z0(e,t,s){const r={fieldCount:0,df:new Map,docFieldCount:new Map,docTermFieldHits:new Map};for(const o of e)Ru(r,o,t,s);return r}function eC(e,t,s,r){Ru(e,t,s,r)}function tC(e,t){const s=e.docFieldCount.get(t);if(s===void 0)return;e.fieldCount-=s,e.docFieldCount.delete(t);const r=e.docTermFieldHits.get(t);if(r){for(const[o,a]of r){const i=(e.df.get(o)||0)-a;i<=0?e.df.delete(o):e.df.set(o,i)}e.docTermFieldHits.delete(t)}}function wi(e,t){if(t.length===0)return;const s=Array.from(new Set(t)).sort((c,d)=>c-d);for(const c of s)tC(e,c);const r=c=>{let d=0,l=s.length;for(;d<l;){const m=d+l>>>1;s[m]<c?d=m+1:l=m}return c-d},o=s[0],a=new Map;for(const[c,d]of e.docFieldCount)a.set(c>o?r(c):c,d);e.docFieldCount=a;const i=new Map;for(const[c,d]of e.docTermFieldHits)i.set(c>o?r(c):c,d);e.docTermFieldHits=i}var Mt=class{constructor(e,t,s){this.options={...X,...t},this.options.useExtendedSearch,this.options.useTokenSearch,this._keyStore=new k0(this.options.keys),this._docs=e,this._myIndex=null,this._invertedIndex=null,this.setCollection(e,s),this._lastQuery=null,this._lastSearcher=null}_getSearcher(e){if(this._lastQuery===e)return this._lastSearcher;const t=Cs(e,this._invertedIndex?{...this.options,_invertedIndex:this._invertedIndex}:this.options);return this._lastQuery=e,this._lastSearcher=t,t}setCollection(e,t){if(this._docs=e,t&&!(t instanceof Xo))throw new Error(x0);if(this._myIndex=t||Au(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight}),this.options.useTokenSearch){const s=Qr({isCaseSensitive:this.options.isCaseSensitive,ignoreDiacritics:this.options.ignoreDiacritics,tokenize:this.options.tokenize});this._invertedIndex=Z0(this._myIndex.records,this._myIndex.keys.length,s)}this._invalidateSearcherCache()}add(e){if(!Ke(e))return;this._docs.push(e);const t=this._myIndex.add(e,this._docs.length-1);if(this._invertedIndex&&t){const s=Qr({isCaseSensitive:this.options.isCaseSensitive,ignoreDiacritics:this.options.ignoreDiacritics,tokenize:this.options.tokenize});eC(this._invertedIndex,t,this._myIndex.keys.length,s)}this._invalidateSearcherCache()}remove(e=()=>!1){const t=[],s=[];for(let r=0,o=this._docs.length;r<o;r+=1)e(this._docs[r],r)&&(t.push(this._docs[r]),s.push(r));if(s.length){this._invertedIndex&&wi(this._invertedIndex,s);const r=new Set(s);this._docs=this._docs.filter((o,a)=>!r.has(a)),this._myIndex.removeAll(s),this._invalidateSearcherCache()}return t}removeAt(e){if(!Number.isInteger(e)||e<0||e>=this._docs.length)throw new Error(Hr);this._invertedIndex&&wi(this._invertedIndex,[e]);const t=this._docs.splice(e,1)[0];return this._myIndex.removeAt(e),this._invalidateSearcherCache(),t}_invalidateSearcherCache(){this._lastQuery=null,this._lastSearcher=null}getIndex(){return this._myIndex}_normalizedKeys(){return this._myIndex.keys.map(e=>this._keyStore.get(e.id)||e)}search(e,t){const{limit:s=-1}=t||{},{includeMatches:r,includeScore:o,shouldSort:a,sortFn:i,ignoreFieldNorm:c}=this.options;if(Te(e)&&!e.trim()){let p=this._docs.map((f,g)=>({item:f,refIndex:g}));return ds(s)&&s>-1&&(p=p.slice(0,s)),p}const d=a&&ds(s)&&s>0&&Te(e),l=i,m=(p,f)=>l(p,f)||p.idx-f.idx;let h;if(d){const p=new G0(s,m);Te(this._docs[0])?this._searchStringList(e,{heap:p,ignoreFieldNorm:c}):this._searchObjectList(e,{heap:p,ignoreFieldNorm:c}),h=p.extractSorted()}else h=Te(e)?Te(this._docs[0])?this._searchStringList(e):this._searchObjectList(e):this._searchLogical(e),W0(h,{ignoreFieldNorm:c}),a&&h.sort(Te(e)?m:l),ds(s)&&s>-1&&(h=h.slice(0,s));return Y0(h,this._docs,{includeMatches:r,includeScore:o})}_searchStringList(e,{heap:t,ignoreFieldNorm:s}={}){const r=this._getSearcher(e),o=this.options.useTokenSearch&&this.options.tokenMatch==="all",{records:a}=this._myIndex,i=t?null:[];return a.forEach(({v:c,i:d,n:l})=>{if(!Ke(c))return;const m=r.searchIn(c);if(m.isMatch){const h={score:m.score,value:c,norm:l,indices:m.indices};o&&(h.matchedMask=m.matchedMask,h.matchedTerms=m.matchedTerms,h.termCount=m.termCount);const p=[h];if(!o||this._coversAllTokens(p)){const f={item:c,idx:d,matches:p};t?(f.score=Vr(f.matches,{ignoreFieldNorm:s}),t.insert(f)):i.push(f)}}}),i}_searchLogical(e){const t=Iu(e,this.options),s=this._normalizedKeys(),r=(c,d,l)=>{if(!("children"in c)){const{keyId:f,searcher:g}=c;let x;return f===null?(x=[],s.forEach((y,b)=>{x.push(...this._findMatches({key:y,value:d[b],searcher:g}))})):x=this._findMatches({key:this._keyStore.get(f),value:this._myIndex.getValueForItemAtKeyId(d,f),searcher:g}),x&&x.length?[{idx:l,item:d,matches:x}]:[]}const{children:m,operator:h}=c,p=[];for(let f=0,g=m.length;f<g;f+=1){const x=m[f],y=r(x,d,l);if(y.length)p.push(...y);else if(h===Ns.AND)return[]}return p},o=this._myIndex.records,a=new Map,i=[];return o.forEach(({$:c,i:d})=>{if(Ke(c)){const l=r(t,c,d);l.length&&(a.has(d)||(a.set(d,{idx:d,item:c,matches:[]}),i.push(a.get(d))),l.forEach(({matches:m})=>{a.get(d).matches.push(...m)}))}}),i}_searchObjectList(e,{heap:t,ignoreFieldNorm:s}={}){const r=this._getSearcher(e),o=this.options.useTokenSearch&&this.options.tokenMatch==="all",{records:a}=this._myIndex,i=this._normalizedKeys(),c=t?null:[];return a.forEach(({$:d,i:l})=>{if(!Ke(d))return;const m=[];let h=!1,p=!1;if(i.forEach((f,g)=>{const x=this._findMatches({key:f,value:d[g],searcher:r});x.length?(m.push(...x),x[0].hasInverse&&(p=!0)):h=!0}),!(p&&h)&&m.length&&(!o||this._coversAllTokens(m))){const f={idx:l,item:d,matches:m};t?(f.score=Vr(f.matches,{ignoreFieldNorm:s}),t.insert(f)):c.push(f)}}),c}_findMatches({key:e,value:t,searcher:s}){if(!Ke(t))return[];const r=[];if(Ot(t))t.forEach(({v:o,i:a,n:i})=>{if(!Ke(o))return;const c=s.searchIn(o);if(c.isMatch){const d={score:c.score,key:e,value:o,idx:a,norm:i,indices:c.indices,hasInverse:c.hasInverse};c.termCount!==void 0&&(d.matchedMask=c.matchedMask,d.matchedTerms=c.matchedTerms,d.termCount=c.termCount),r.push(d)}});else{const{v:o,n:a}=t,i=s.searchIn(o);if(i.isMatch){const c={score:i.score,key:e,value:o,norm:a,indices:i.indices,hasInverse:i.hasInverse};i.termCount!==void 0&&(c.matchedMask=i.matchedMask,c.matchedTerms=i.matchedTerms,c.termCount=i.termCount),r.push(c)}}return r}_coversAllTokens(e){const t=e.length?e[0].termCount:void 0;if(t===void 0)return!0;if(t<=31){let r=0;for(let o=0;o<e.length;o++)r|=e[o].matchedMask||0;return r===2**t-1}const s=new Set;for(let r=0;r<e.length;r++){const o=e[r].matchedTerms;if(o)for(const a of o)s.add(a)}return s.size===t}};Mt.version="7.5.0";Mt.createIndex=Au;Mt.parseIndex=T0;Mt.config=X;Mt.match=function(e,t,s){if(s&&s.useTokenSearch)throw new Error(j0);return Cs(e,{...X,...s}).searchIn(t)};Mt.parseQuery=Iu;ea(U0);ea(J0);Mt.use=function(...e){e.forEach(t=>ea(t))};var nC=Mt;const sC=.02,Tu=.5,Du=.35,Ou=.15,rC=1+Tu+Du+Ou,oC=4320*60*1e3,aC=3,iC=1440*60*1e3,cC=.15,lC={lastUsedAt:null,useCount:0};function ta(e){return!Number.isFinite(e)||e<0?0:e>1?1:e}function Mu(e,t){return!Number.isFinite(e)||e<=0?1:ta(Math.pow(2,-e/t))}function dC(e,t){const s=e.lastUsedAt===null?0:Mu(t-e.lastUsedAt,oC),r=Math.max(0,e.useCount),o=r===0?0:r/(r+aC);return ta((s+o)/2)}function uC(e,t){const s=e.distance===null?1:ta(Math.pow(2,-Math.max(0,e.distance)/sC)),r=dC(e.usage,t),o=e.lastActivityAt===null?0:Mu(t-e.lastActivityAt,iC),a=1+(e.waiting?Tu:0)+Du*r+Ou*o;return{score:s*a/rC,signals:{relevance:s,frecency:r,recency:o}}}function mC(e,t){return e.map(s=>{const{score:r,signals:o}=uC(s,t);return{key:s.key,item:s.item,score:r,signals:o,demoted:s.demoted}}).sort((s,r)=>Number(s.demoted)-Number(r.demoted)||r.score-s.score||s.key.localeCompare(r.key))}function hC(e,t){const s=[...e],r=e[0],o=e[1];return t.queried?!r||!o?{best:null,rest:s}:r.demoted||r.score<=0?{best:null,rest:s}:(r.score-o.score)/r.score<cC?{best:null,rest:s}:{best:r,rest:s.slice(1)}:{best:null,rest:s}}function fC(e,t){const s=[];for(const r of e){const o=t(r),a=s[s.length-1];a&&a.label===o?a.rows.push(r):s.push({label:o,rows:[r]})}return s}const pC={keys:["name","keywords"],includeMatches:!0,includeScore:!0,threshold:.3,distance:100,minMatchCharLength:1};function gC(e,t,s){const{usage:r,now:o,scope:a}=s,{prefix:i,term:c}=u.useMemo(()=>a===null?xC(t):{prefix:null,term:t},[t,a]),d=u.useMemo(()=>{if(a===null)return e;const x=ju(a);return e.filter(y=>y.scopes.includes(x))},[e,a]),l=u.useMemo(()=>i==="#"?d.filter(x=>x.type==="room"):i==="@"?d.filter(x=>x.type==="agent"||x.type==="dm"):i===">"?d.filter(x=>x.type==="command"):d,[d,i]),m=u.useMemo(()=>new nC(l,pC),[l]),h=u.useMemo(()=>{const x=(y,b,C)=>{const k=y.lastActivityAt===null?NaN:Date.parse(y.lastActivityAt);return{key:`${y.type}:${y.id}`,item:{item:y,matches:b},distance:C,usage:(y.usageKey===null?void 0:r[y.usageKey])??lC,lastActivityAt:Number.isNaN(k)?null:k,waiting:y.waiting,demoted:y.demoted}};return c?m.search(c).map(y=>x(y.item,y.matches,y.score??0)):l.map(y=>x(y,void 0,null))},[m,c,l,r]),p=u.useMemo(()=>mC(h,o),[h,o]),{best:f,rest:g}=u.useMemo(()=>hC(p,{queried:c.length>0}),[p,c]);return{bestMatch:f,rows:g,prefix:i,term:c}}function xC(e){return e.startsWith("#")?{prefix:"#",term:e.slice(1)}:e.startsWith("@")?{prefix:"@",term:e.slice(1)}:e.startsWith(">")?{prefix:">",term:e.slice(1)}:{prefix:null,term:e}}function bC(){const e=jo(),t=cf();return u.useMemo(()=>{const s={};for(const[r,o]of Object.entries(e)){const a=Date.parse(o);s[r]={lastUsedAt:Number.isNaN(a)?null:a,useCount:t[r]??0}}return s},[e,t])}const yC=/^\/([A-Za-z0-9][\w.-]*(?::[\w.-]+)*)(?=\s|$)\s*/;function vC(e,t){const s=t.trim().replace(yC,"").trim();return s?`${e} ${s}`:`${e} `}function wC(e){const[t,s]=Fs(),{setTheme:r,theme:o}=fc(),a=Pe(),i=le(),c=ie(),d=An(N=>N.openFeedback),l=ko(),{url:m}=cl(),{copy:h}=zn({toastOnSettle:!0}),{open:p}=ct(),{open:f}=wo(),g=uo(),x=L(N=>N.setPickerOpen),y=L(N=>N.setCanvasOpen),b=L(N=>N.setRightPanelOpen),C=L(N=>N.setActiveRightPanelTab),k=u.useCallback(N=>{bs.getState().recordOpened("agent",N)},[]),I=ul(),v=u.useCallback(N=>{if(lf(i,pf)){e(),I({agentPath:N.projectPath}).then(S=>{S&&k(N.projectPath)});return}s(N.projectPath,{onOpened:()=>{k(N.projectPath)}}),e()},[i,I,k,s,e]),E=ml(),R=u.useCallback(N=>{bs.getState().recordOpened("room",N.id),e(),a({...Ne.channels(),search:{id:N.id}})},[e,a]),_=u.useCallback((N,S)=>{S&&k(S),e(),a(Rt({session:N,dir:S??void 0}))},[e,a,k]),D=u.useCallback(N=>{e(),df({queryClient:i,transport:c},t).then(async S=>{if(S===null){ma(t);return}t&&k(t);const M=uf.getState(),B=M.getSession(S.sessionId).input;M.updateSession(S.sessionId,{input:vC(N,B)}),a(S.isNew?await mf(c,{session:S.sessionId,dir:t??void 0}):Rt({session:S.sessionId}))}).catch(S=>{bc(c,S),ma(t)})},[e,a,i,c,t,k]),P=u.useCallback(N=>{e(),a({href:N})},[e,a]),T=u.useCallback(N=>{hf(N)||console.warn(`[command-palette] no handler registered for action "${N}"`)},[]),j=u.useCallback(N=>{switch(e(),N){case"openTasks":f();return;case"openRelay":g();return;case"openMesh":a({...Ne.team()});return;case"openSettings":p();return;case"discoverAgents":rn.getState().open();return;case"browseFilesystem":x(!0);return;case"openAgentProfile":C(ff),b(!0);return;default:{const S=dl(N);if(S){p(S);return}T(N);return}}},[e,a,f,g,p,x,C,b,T]),w=u.useCallback(N=>{switch(e(),N){case"navigateDashboard":a({...Ne.home()});return;case"newSession":E();return;case"openDevPlayground":Dn("/dev");return;case"toggleDevtools":L.getState().toggleDevtools();return;case"toggleRouterDevtools":L.getState().toggleRouterDevtools();return;case"createAgent":Ts.getState().open();return;case"switchShape":L.getState().setShapeSwitcherOpen(!0);return;case"openControlCenter":L.getState().setControlCenterOpen(!0);return;case"toggleCanvas":y(!L.getState().canvasOpen);return;case"toggleTheme":r(o==="dark"?"light":"dark");return;case"openFeedback":d();return;case"openYourReports":a({...Ne.feedbackRequests()});return;case"openTasks":f();return;case"openRelay":g();return;case"openMesh":a({...Ne.team()});return;case"discoverAgents":rn.getState().open();return;case"openSettings":p();return;case"browseFilesystem":x(!0);return;case pt.copyLink:m&&h(m);return;case pt.showQr:L.getState().setRemoteAccessBeaconOpen(!0);return;case pt.turnOn:l.start();return;case pt.turnOff:l.stop();return;default:T(N);return}},[e,a,T,r,o,y,x,f,g,p,d,h,l,m,E]);return{handleAgentSelect:v,startNewSession:E,handleFeatureAction:j,handleQuickAction:w,handleRoomSelect:R,handleSessionSelect:_,handleCommandSelect:D,handlePageSelect:P,recordAgentOpened:k,setDir:s,selectedCwd:t}}const ji='[cmdk-item=""]:not([aria-disabled="true"])',jC=new Set(["ArrowUp","ArrowDown","Home","End"]),kC=new Set(["n","p","j","k"]);function SC({rootRef:e,activePage:t,onPin:s,resetKey:r}){const o=u.useRef(!1);u.useLayoutEffect(()=>{o.current=!1},[r]),u.useLayoutEffect(()=>{var l;if(o.current)return;const c=(l=e.current)==null?void 0:l.querySelector(`[data-palette-page="${CSS.escape(t)}"] ${ji}`);if(!c||c.getAttribute("aria-selected")==="true")return;const d=c.getAttribute("data-value");d&&s(d)});const a=u.useCallback(c=>{c.nativeEvent.isComposing||c.keyCode===229||(jC.has(c.key)||c.ctrlKey&&kC.has(c.key))&&(o.current=!0)},[]),i=u.useCallback(c=>{c.target instanceof Element&&c.target.closest(ji)&&(o.current=!0)},[]);return{onKeyDown:a,onPointerMove:i}}function CC({scope:e,className:t}){return n.jsx("span",{"data-testid":"palette-scope-chip",className:K("bg-accent text-accent-foreground inline-flex shrink-0 items-center gap-1.5 rounded-md px-1.5 py-0.5 text-xs font-medium",t),children:e.kind==="agent"?n.jsxs(n.Fragment,{children:[n.jsx($s,{...Bs(e.agent),size:"xs",badge:null}),Le(e.agent)]}):n.jsxs(n.Fragment,{children:[n.jsx(So,{room:e.room,participants:e.room.participants,size:"xs"}),n.jsx(Co,{room:e.room})]})})}function NC(e){const t=e.trim();return t.length===0?null:t}function _u(e,t){const s=u.useDeferredValue(e),{sessions:r}=gf(t),{data:o}=db(s||null),a=u.useMemo(()=>r.slice(0,3).map(i=>({id:i.id,title:rl(i.title),lastActive:i.updatedAt})),[r]);return{sessionCount:r.length,recentSessions:a,health:o??null}}function AC({agent:e}){const{sessionCount:t,recentSessions:s,health:r}=_u(e.id,e.projectPath),{color:o,emoji:a}=Bs(e);return n.jsx(re.div,{initial:{opacity:0,width:0},animate:{opacity:1,width:240},exit:{opacity:0,width:0},transition:{duration:.2,ease:[0,0,.2,1]},className:"flex-shrink-0 overflow-hidden border-l will-change-[width]",children:n.jsxs("div",{className:"w-[240px] space-y-3 p-4",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx($s,{color:o,emoji:a,size:"sm",className:"shrink-0"}),n.jsx("span",{className:"truncate text-sm font-semibold",children:Le(e)})]}),n.jsx("p",{className:"text-muted-foreground truncate text-xs",children:ho(e.projectPath)}),n.jsxs("div",{className:"flex items-center gap-3 text-xs",children:[r&&n.jsx(On,{size:"xs",variant:r.status==="active"?"default":"secondary",children:r.status}),n.jsxs("span",{className:"text-muted-foreground",children:[t," ",t===1?"chat":"chats"]})]}),s.length>0&&n.jsxs("div",{className:"space-y-1 pt-1",children:[n.jsx("p",{className:"text-muted-foreground text-3xs font-medium tracking-wider uppercase",children:"Recent"}),n.jsx("ul",{className:"space-y-0.5",children:s.map(i=>n.jsx("li",{className:"text-muted-foreground truncate text-xs",children:i.title},i.id))})]})]})})}function EC({agent:e,onOpenHere:t,onOpenNewTab:s,onOpenNewWindow:r,onNewSession:o,onBrowseSessions:a,onEditSettings:i,recentSessions:c,onSelectSession:d}){const l=Gt?"⌘":"Ctrl+";return n.jsxs(n.Fragment,{children:[n.jsxs(st,{heading:`${Le(e)} actions`,children:[n.jsxs(Ae,{value:"open-here",onSelect:t,children:[n.jsx(Ds,{className:"size-4"}),n.jsx("span",{children:"Open here"}),n.jsx(La,{children:"Enter"})]}),n.jsxs(Ae,{value:"open-new-tab",onSelect:s,children:[n.jsx(Cy,{className:"size-4"}),n.jsx("span",{children:"Open in a new tab"}),n.jsxs(La,{children:[l,"Enter"]})]}),r&&n.jsxs(Ae,{value:"open-new-window",onSelect:r,children:[n.jsx(Gy,{className:"size-4"}),n.jsx("span",{children:"Open in a new window"})]}),n.jsxs(Ae,{value:"new-session",onSelect:o,children:[n.jsx(Dt,{className:"size-4"}),n.jsx("span",{children:"New chat"})]}),a&&n.jsxs(Ae,{value:"browse-sessions",onSelect:a,children:[n.jsx(Ay,{className:"size-4"}),n.jsx("span",{children:"Browse chats…"})]}),n.jsxs(Ae,{value:"edit-settings",onSelect:i,children:[n.jsx(zs,{className:"size-4"}),n.jsxs("span",{children:["Edit ",Le(e)," settings"]})]})]}),c.length>0&&n.jsx(st,{heading:"Recent chats",children:c.map(m=>n.jsxs(Ae,{value:m.id,onSelect:()=>d(m.id),children:[n.jsx(Rs,{className:"size-4"}),n.jsx("span",{className:"truncate",children:m.title}),n.jsx("span",{className:"text-muted-foreground ml-auto text-xs",children:IC(m.lastActive)})]},m.id))})]})}function IC(e){const t=Date.now(),s=new Date(e).getTime(),r=t-s,o=Math.floor(r/6e4);if(o<1)return"just now";if(o<60)return`${o}m ago`;const a=Math.floor(o/60);if(a<24)return`${a}h ago`;const i=Math.floor(a/24);return i<7?`${i}d ago`:`${Math.floor(i/7)}w ago`}const Ct="bg-muted rounded px-1 py-0.5 font-mono text-3xs";function RC({page:e,hasAgentSelected:t,canScope:s,isScoped:r}){const o=Gt?"⌘":"Ctrl";return n.jsxs("div",{className:"text-muted-foreground flex flex-shrink-0 items-center gap-3 border-t px-3 py-1.5 text-xs",children:[n.jsxs("span",{className:"inline-flex items-center gap-1",children:[n.jsx("kbd",{className:Ct,children:"↑↓"}),"Navigate"]}),!e&&t&&n.jsxs("span",{className:"inline-flex items-center gap-1",children:[n.jsx("kbd",{className:Ct,children:"Enter"}),"Open"]}),(!e&&t||e==="agent-actions")&&n.jsxs("span",{className:"inline-flex items-center gap-1",children:[n.jsxs("kbd",{className:Ct,children:[o,"Enter"]}),"New tab"]}),e==="agent-actions"&&n.jsxs("span",{className:"inline-flex items-center gap-1",children:[n.jsx("kbd",{className:Ct,children:"Enter"}),"Select"]}),e&&n.jsxs("span",{className:"inline-flex items-center gap-1",children:[n.jsx("kbd",{className:Ct,children:"Backspace"}),"Back"]}),s&&n.jsxs("span",{className:"inline-flex items-center gap-1",children:[n.jsx("kbd",{className:Ct,children:"Tab"}),"Search inside"]}),r&&n.jsxs("span",{className:"inline-flex items-center gap-1",children:[n.jsx("kbd",{className:Ct,children:"Backspace"}),"Clear scope, at the start"]}),n.jsxs("span",{className:"ml-auto inline-flex items-center gap-1",children:[n.jsx("kbd",{className:Ct,children:"esc"}),"Close"]})]})}const TC=[{key:"#",means:"channels"},{key:"@",means:"agents and DMs"},{key:">",means:"commands"}];function Pu({className:e}){return n.jsx("div",{className:K("text-muted-foreground flex flex-wrap items-center gap-x-3 gap-y-1 px-3 py-2 text-xs",e),children:TC.map(({key:t,means:s})=>n.jsxs("span",{className:"inline-flex items-center gap-1",children:[n.jsx("kbd",{className:"bg-muted text-3xs rounded px-1 py-0.5 font-mono",children:t}),s]},t))})}function DC({text:e,indices:t,className:s}){if(!t||t.length===0)return n.jsx("span",{className:s,children:e});const r=[];let o=0;for(let a=0;a<t.length;a++){const[i,c]=t[a],d=c+1;o<i&&r.push(n.jsx("span",{children:e.slice(o,i)},`p-${a}`)),r.push(n.jsx("mark",{className:"text-foreground bg-transparent font-semibold",children:e.slice(i,d)},`m-${a}`)),o=d}return o<e.length&&r.push(n.jsx("span",{children:e.slice(o)},"tail")),n.jsx("span",{className:s,children:r})}function Lu({agent:e,isActive:t,onSelect:s,nameIndices:r,isSelected:o}){return n.jsxs(Ae,{value:Le(e),keywords:[e.name,e.projectPath,e.id],onSelect:()=>s(),className:"relative py-2",forceMount:t?!0:void 0,children:[o&&n.jsx(re.div,{layoutId:"cmd-palette-selection",className:"bg-accent absolute inset-0 rounded-sm",transition:{duration:.15,ease:[0,0,.2,1]}}),n.jsx("div",{className:"relative z-10 w-full",children:n.jsx(Ey,{agent:e,name:r?n.jsx(DC,{text:Le(e),indices:r,className:"truncate text-sm font-semibold"}):n.jsx("span",{className:"truncate text-sm font-semibold",children:Le(e)}),secondary:ho(e.projectPath),selected:t})})]})}function Fu(){return n.jsx("span",{"data-testid":"palette-archived-mark",className:"text-muted-foreground border-border text-3xs shrink-0 rounded-full border px-1.5 py-0.5 font-medium",children:"Archived"})}function OC(e){if(e.kind==="dm"){const r=e.unreadCount??0;if(r<=0)return null;const o=r>Js?`More than ${Js}`:String(r);return{count:r,cap:Js,label:r===1?"1 new message":`${o} new messages`}}const t=e.mentionCount??0;if(t<=0||e.unreadCount===null)return null;const s=t>as?`More than ${as}`:String(t);return{count:t,cap:as,label:t===1?"1 mention":`${s} mentions`}}function $u({room:e,onSelect:t}){const s=OC(e);return n.jsxs(Ae,{value:e.id,keywords:Ur(e),onSelect:t,className:"flex items-center gap-2 py-2",children:[n.jsx(So,{room:e,participants:e.participants,className:"shrink-0"}),e.kind==="dm"?n.jsxs("span",{className:"min-w-0 flex-1 truncate text-sm",children:["Open DM with ",e.title]}):n.jsx(Co,{room:e,className:"min-w-0 flex-1 text-sm"}),e.archived&&n.jsx(Fu,{}),s&&n.jsx(Us,{solid:!0,count:s.count,cap:s.cap,label:s.label})]})}const MC=6e4;function _C({lastActivityAt:e}){const t=Ks(MC),s=u.useMemo(()=>Number.isNaN(Date.parse(e))?null:Hn(e),[e,t]);return s===null?null:n.jsx("span",{className:"text-muted-foreground text-2xs font-normal",children:s})}function Xr({item:e,live:t,isSelected:s=!1,onSelect:r}){const o=hl(e.agent,e.cwd??e.id),a=xf(e.who,e.title),i=(t==null?void 0:t.verb)??null;return n.jsxs(Ae,{value:e.id,keywords:ku(e),onSelect:r,title:a,className:K("flex gap-2 py-1.5",i!==null?"items-start":"items-center"),children:[n.jsx($s,{color:o.color,emoji:o.emoji,size:"xs",className:K("shrink-0",i!==null&&"mt-px")}),n.jsxs("span",{className:"flex min-w-0 flex-1 flex-col",children:[n.jsxs("span",{"data-slot":"palette-session-line",className:"flex w-full items-center gap-1.5 text-sm",children:[e.who?n.jsxs(n.Fragment,{children:[n.jsx("span",{"data-slot":"palette-session-who",className:bf,children:e.who}),n.jsx("span",{"aria-hidden":!0,className:"text-muted-foreground/60 flex-none",children:yf})]}):null,n.jsx("span",{"data-slot":"palette-session-title",className:vf,children:e.title}),n.jsxs("span",{className:K("flex items-center gap-1.5",jf),children:[e.archived&&t===void 0&&n.jsx(Fu,{}),n.jsx(wf,{origin:e.origin,label:e.originLabel,className:"text-muted-foreground"}),n.jsx(_C,{lastActivityAt:e.lastActivityAt}),s&&n.jsx(PC,{canStartNewSession:e.cwd!==null})]})]}),i!==null&&n.jsxs("span",{className:"text-muted-foreground text-2xs flex items-center gap-1.5 font-normal",children:[t!==void 0&&n.jsx("span",{"aria-hidden":!0,className:K("size-1.5 shrink-0 rounded-full",kf(t.signal))}),i]})]})]})}function PC({canStartNewSession:e}){return n.jsxs("span",{"aria-hidden":!0,className:"text-muted-foreground flex items-center gap-1",children:[n.jsx("kbd",{className:"bg-accent text-3xs rounded px-1 py-0.5 font-mono",children:"↵"}),e&&n.jsx("kbd",{className:"bg-accent text-3xs rounded px-1 py-0.5 font-mono",children:"⌘↵"})]})}const LC={session:"Conversations",agent:"Agents",room:"Channels",dm:"Direct messages",command:"Commands",feature:"Actions","quick-action":"Actions",page:"Add-ons"},FC="Best match",Jr={Clock:Ic,Radio:Iy,Globe:gs,Settings:zs,Plus:Dt,Search:ps,FolderOpen:Ds,Moon:Nf,Shapes:Cf,MessageSquarePlus:fl,Inbox:Sf},zt=[0,0,.2,1],$C=[.4,0,1,1],Bu={hidden:{opacity:0,scale:.96,y:-8},visible:{opacity:1,scale:1,y:0,transition:{duration:.2,ease:zt}},exit:{opacity:0,scale:.96,y:-8,transition:{duration:.12,ease:$C}}},BC={hidden:{},visible:{transition:{staggerChildren:.035,delayChildren:.04}}},In={hidden:{opacity:0,y:-4},visible:{opacity:1,y:0,transition:{duration:.15,ease:zt}}},mr=8;function zC({continueRows:e,recent:t,newActions:s,selectedCwd:r,selectedValue:o,onSessionSelect:a,onRoomSelect:i,onGoToAgentActions:c,onQuickAction:d}){return n.jsxs(n.Fragment,{children:[e.length>0&&n.jsx(st,{heading:"Continue",children:e.map((l,m)=>n.jsx(re.div,{variants:m<mr?In:void 0,children:n.jsx(Xr,{item:l.session,live:{verb:l.verb,signal:l.signal},isSelected:o===l.session.id,onSelect:()=>a(l.session)})},l.session.id))}),t.length>0&&n.jsx(st,{heading:"Recent",children:t.map((l,m)=>n.jsxs(re.div,{variants:m<mr?In:void 0,children:[l.kind==="session"&&n.jsx(Xr,{item:l.session,isSelected:o===l.session.id,onSelect:()=>a(l.session)}),l.kind==="room"&&n.jsx($u,{room:l.room,onSelect:()=>i(l.room)}),l.kind==="agent"&&n.jsx(Lu,{agent:l.agent,isActive:l.agent.projectPath===r,isSelected:o===Le(l.agent),onSelect:()=>c(l.agent)})]},l.key))}),s.length>0&&n.jsxs(n.Fragment,{children:[(e.length>0||t.length>0)&&n.jsx(Sd,{}),n.jsx(st,{heading:"New",children:s.map((l,m)=>{const h=Jr[l.icon];return n.jsx(re.div,{variants:m<mr?In:void 0,children:n.jsx(Ae,{value:l.label,onSelect:()=>d(l.action),children:n.jsxs(re.div,{whileHover:{x:2},transition:{duration:.1,ease:zt},className:"flex w-full items-center gap-2",children:[h&&n.jsx(h,{className:"size-4"}),n.jsx("span",{children:l.label})]})})},l.id)})})]})]})}function ki({row:e,selectedCwd:t,selectedValue:s,onFeatureAction:r,onQuickAction:o,onGoToAgentActions:a,onRoomSelect:i,onSessionSelect:c,onCommandSelect:d,onPageSelect:l}){var p;const{item:m,matches:h}=e.item;switch(m.type){case"session":return n.jsx(Xr,{item:m.data,isSelected:s===m.data.id,onSelect:()=>c(m.data)});case"agent":return n.jsx(Lu,{agent:m.data,isActive:m.data.projectPath===t,isSelected:s===Le(m.data),onSelect:()=>a(m.data),nameIndices:(p=h==null?void 0:h.find(f=>f.key==="name"))==null?void 0:p.indices});case"room":case"dm":return n.jsx($u,{room:m.data,onSelect:()=>i(m.data)});case"command":return n.jsx(Ae,{value:m.data.name,onSelect:()=>d(m.data.name),children:n.jsxs(re.div,{whileHover:{x:2},transition:{duration:.1,ease:zt},className:"flex w-full items-center gap-2",children:[n.jsx("span",{className:"font-mono text-xs",children:m.data.name}),m.data.description&&n.jsx("span",{className:"text-muted-foreground ml-2 text-xs",children:m.data.description})]})});case"feature":{const f=Jr[m.data.icon];return n.jsx(Ae,{value:m.data.label,onSelect:()=>r(m.data.action),children:n.jsxs(re.div,{whileHover:{x:2},transition:{duration:.1,ease:zt},className:"flex w-full items-center gap-2",children:[f&&n.jsx(f,{className:"size-4"}),n.jsx("span",{children:m.data.label}),m.data.shortcut&&n.jsx("span",{className:"text-muted-foreground ml-auto text-xs",children:m.data.shortcut})]})})}case"page":return n.jsx(Ae,{value:m.data.id,onSelect:()=>l(m.data.href),children:n.jsxs(re.div,{whileHover:{x:2},transition:{duration:.1,ease:zt},className:"flex w-full items-center gap-2",children:[n.jsx(Kn,{icon:m.data.icon,className:"size-4"}),n.jsx("span",{children:m.data.label})]})});case"quick-action":{const f=Jr[m.data.icon];return n.jsx(Ae,{value:m.data.label,onSelect:()=>o(m.data.action),children:n.jsxs(re.div,{whileHover:{x:2},transition:{duration:.1,ease:zt},className:"flex w-full items-center gap-2",children:[f&&n.jsx(f,{className:"size-4"}),n.jsx("span",{children:m.data.label})]})})}}}function UC({term:e,isScoped:t=!1,onSelect:s}){return n.jsxs(Ae,{value:"search-messages-handoff",onSelect:s,className:"flex items-center gap-2 py-2",children:[n.jsx(Rs,{className:"text-muted-foreground size-4 shrink-0"}),n.jsxs("span",{className:"min-w-0 flex-1 truncate text-sm",children:["Search ",t?"all messages":"messages"," for"," ",n.jsxs("mark",{className:"text-foreground bg-transparent font-semibold",children:["“",e,"”"]}),"…"]}),n.jsx("kbd",{className:"bg-muted text-muted-foreground text-3xs shrink-0 rounded px-1 py-0.5 font-mono",children:Gt?"⌘⇧F":"Ctrl⇧F"})]})}const Si=8;function KC({staggerKey:e,isZeroQuery:t,isRoomMode:s,scope:r,hasQuery:o,selectedCwd:a,selectedValue:i,continueRows:c,recent:d,newActions:l,bestMatch:m,rows:h,rooms:p,searchHandoff:f,onFeatureAction:g,onQuickAction:x,onGoToAgentActions:y,onRoomSelect:b,onSessionSelect:C,onCommandSelect:k,onPageSelect:I}){const v=s?p.isError?"Couldn’t load your channels.":p.isLoading?"Loading channels…":p.channels.length===0?"No channels yet.":null:null,E=fC(h,P=>r?ui(r):LC[P.item.item.type]),R=r&&!o&&h.length===0&&!m?GS(r):null,_=new Set(h.slice(0,m?Si-1:Si).map(P=>P.key)),D={selectedCwd:a,selectedValue:i,onFeatureAction:g,onQuickAction:x,onGoToAgentActions:y,onRoomSelect:b,onSessionSelect:C,onCommandSelect:k,onPageSelect:I};return n.jsxs(re.div,{variants:BC,initial:"hidden",animate:"visible",children:[t&&n.jsx(zC,{continueRows:c,recent:d,newActions:l,selectedCwd:a,selectedValue:i,onSessionSelect:C,onRoomSelect:b,onGoToAgentActions:y,onQuickAction:x}),!t&&m&&n.jsx(st,{heading:FC,children:n.jsx(re.div,{variants:In,children:n.jsx(ki,{row:m,...D})})}),!t&&E.map((P,T)=>n.jsx(st,{heading:P.label,children:P.rows.map(j=>n.jsx(re.div,{variants:_.has(j.key)?In:void 0,children:n.jsx(ki,{row:j,...D})},j.key))},`${P.label}-${T}`)),R&&n.jsx(st,{heading:r?ui(r):void 0,children:n.jsx(Ae,{disabled:!0,value:"scope-status",className:"text-muted-foreground text-sm",children:R})}),v&&n.jsx(st,{heading:"Channels",children:n.jsx(Ae,{disabled:!0,value:"rooms-status",className:"text-muted-foreground text-sm",children:v})}),f&&n.jsx(st,{children:n.jsx(UC,{term:f.term,isScoped:f.isScoped,onSelect:f.onSelect})}),t&&n.jsxs(n.Fragment,{children:[n.jsx(Sd,{}),n.jsx(Pu,{})]})]},e)}function HC(e,t){const s=zb(),{dismissedIds:r}=fd(),o=L(a=>a.promoEnabled);return u.useMemo(()=>o?Ub(Kb.filter(a=>a.placements.includes(e)),s,r,t):[],[e,t,s,r,o])}const WC={initial:{opacity:0},animate:{opacity:1,transition:{duration:ha.fast}},exit:{opacity:0,transition:{duration:ha.fast}}};function GC({promo:e}){const{activate:t,dialog:s}=Hb(e),{dismissPromo:r}=fd(),o=ht(),a=e.content.icon;return n.jsxs(re.div,{variants:o?void 0:WC,className:"relative",children:[n.jsxs("button",{"data-slot":"promo-card-compact",onClick:t,className:"bg-sidebar-accent/40 text-sidebar-foreground/70 hover:bg-sidebar-accent/70 hover:text-sidebar-foreground focus-ring flex w-full items-center gap-2 rounded-md py-1.5 pr-8 pl-2 text-left transition-colors duration-(--dur-fast) max-md:min-h-15 max-md:pr-12",children:[n.jsx(a,{className:`${Af} shrink-0`}),n.jsxs("span",{className:"min-w-0 flex-1",children:[n.jsx("span",{className:"text-sidebar-foreground/90 text-control block truncate font-medium",children:e.content.title}),n.jsx("span",{className:"text-2xs block truncate",children:e.content.shortDescription})]}),n.jsx(Zc,{className:`${dn} shrink-0`})]}),n.jsx(F,{variant:"ghost",size:"icon-xs",onClick:()=>r(e.id),"aria-label":"Dismiss",className:"text-sidebar-foreground/70 hover:text-sidebar-foreground hover:bg-sidebar-accent/70 focus-ring absolute top-1/2 right-1 -translate-y-1/2 max-md:right-0",children:n.jsx(Be,{className:dn})}),s]})}const qC=1;function YC(e){const[t]=HC(e,qC);return u.useMemo(()=>t===void 0?{id:"promo",show:!1,render:()=>null}:{id:`promo:${t.id}`,show:!0,render:()=>n.jsx(GC,{promo:t})},[t])}const VC=new Set(["downloading","downloaded","install-failed"]);function Ci(e,t){return(e==null?void 0:e.state)==="install-failed"?t.state==="downloaded"&&Lo(t.version,e.version)?t:e:VC.has(t.state)||t.state==="error"?t:e&&(e.state==="downloading"||e.state==="downloaded")?e:t}function QC(){var o;const e=typeof window<"u"&&!!((o=window.electronAPI)!=null&&o.onUpdateStatus),[t,s]=u.useState(null);u.useEffect(()=>{var c;const a=window.electronAPI;if(!(a!=null&&a.onUpdateStatus))return;const i=a.onUpdateStatus(d=>{s(l=>Ci(l,d))});return(c=a.getUpdateStatus)==null||c.call(a).then(d=>{d&&s(l=>Ci(l,d))}),i},[]);const r=u.useCallback(()=>{var a,i;(i=(a=window.electronAPI)==null?void 0:a.restartToUpdate)==null||i.call(a)},[]);return{isDesktop:e,status:t,restart:r}}const XC={darwin:Rr("/download/mac"),win32:Rr("/download/windows")},JC=ro.site;function ZC(){var t;const e=typeof window>"u"||(t=window.electronAPI)==null?void 0:t.platform;It((e&&XC[e])??JC)}function eN(){const{data:e}=Me(),{isDesktop:t,status:s,restart:r}=QC(),o=Vn(),a=e==null?void 0:e.version,i=(e==null?void 0:e.latestVersion)??null,c=u.useMemo(()=>(e==null?void 0:e.dismissedUpgradeVersions)??[],[e==null?void 0:e.dismissedUpgradeVersions]),d=u.useCallback(m=>{o.mutate({ui:{dismissedUpgradeVersions:[...c,m]}})},[c,o]),l=(e==null?void 0:e.serverRole)==="hub";return u.useMemo(()=>l?{kind:"none"}:t?(s==null?void 0:s.state)==="install-failed"?{kind:"desktop-install-failed",downloadFresh:ZC}:(s==null?void 0:s.state)!=="downloaded"?{kind:"none"}:{kind:"desktop-restart",restart:r}:i!==null&&a!==void 0&&Lo(i,a)&&!c.includes(i)?{kind:"command",latestVersion:i,dismiss:()=>d(i)}:{kind:"none"},[l,t,s,r,i,a,c,d])}const tN="npm update -g dorkos",nN="The update couldn’t install itself. Download a fresh copy. Your settings and agents stay put.",hr="focus-ring inline-flex items-center gap-1 rounded-full bg-amber-500/15 px-2 py-0.5 text-2xs font-medium text-amber-700 transition-colors duration-150 hover:bg-amber-500/25 dark:text-amber-300";function sN(e,t,s){return t?"Command copied":s?"Couldn’t copy":`Update ready: v${e}`}function rN({update:e}){const{copied:t,failed:s,copy:r}=zn(),o=u.useCallback(()=>{r(tN)},[r]);return e.kind==="none"?null:e.kind==="desktop-restart"?n.jsx("div",{className:"flex items-center px-0.5",children:n.jsxs("button",{type:"button",onClick:e.restart,"aria-label":"Restart to install the update",className:hr,children:[n.jsx(Zb,{className:"size-(--size-icon-xs)"}),"Restart to update"]})}):e.kind==="desktop-install-failed"?n.jsxs("div",{role:"group","aria-label":"Update didn’t install",className:"flex flex-col gap-1.5 px-0.5",children:[n.jsx("p",{className:"text-sidebar-foreground/70 text-2xs leading-snug",children:nN}),n.jsxs("button",{type:"button",onClick:e.downloadFresh,"aria-label":"Download a fresh copy of DorkOS",className:K(hr,"self-start"),children:[n.jsx(Ef,{className:"size-(--size-icon-xs)"}),"Download fresh copy"]})]}):n.jsxs("div",{className:"flex items-center gap-1 px-0.5",children:[n.jsxs("button",{type:"button",onClick:o,"aria-label":`Copy the update command for v${e.latestVersion}`,className:hr,children:[t?n.jsx(Jt,{className:"size-(--size-icon-xs)"}):n.jsx(co,{className:"size-(--size-icon-xs)"}),sN(e.latestVersion,t,s)]}),n.jsx("button",{type:"button",onClick:e.dismiss,"aria-label":"Dismiss update notification",className:"text-sidebar-foreground/70 hover:text-sidebar-foreground focus-ring rounded-md p-0.5 transition-colors duration-150",children:n.jsx(Be,{className:"size-(--size-icon-xs)"})})]})}function zu(){const{shouldShowGettingStarted:e,dismiss:t}=en(),s=eN(),r=Zw(),o=rj(),a=ru(),i=YC("dashboard-sidebar"),c=No(),d=[{id:"getting-started",show:e,render:()=>n.jsx(tj,{onDismiss:t})},{id:"update",show:s.kind!=="none",render:()=>n.jsx(rN,{update:s})},{id:"identity-prompt",show:r.visible,render:()=>n.jsx(oj,{prompt:r})},{id:"profile-prompt",show:o.visible,render:()=>n.jsx(nj,{prompt:o})},{id:"official-space-offer",show:a.due&&!e,render:()=>n.jsx(td,{className:"bg-secondary/60 rounded-lg"})},{...i,show:i.show&&!a.pending}];return n.jsx(Pb,{candidates:d,ready:c.settled})}const Ni="dorkos-pinned-agents";function Uu(){const{data:e}=Me(),t=Hs(),{update:s}=Ws(),r=t.pinned.length,o=u.useRef(!1);u.useEffect(()=>{if(o.current||e===void 0)return;const a=localStorage.getItem(Ni);if(a===null){o.current=!0;return}o.current=!0;let i=[];try{const c=JSON.parse(a);Array.isArray(c)&&(i=c.filter(d=>typeof d=="string"))}catch{i=[]}r===0&&i.length>0&&s(c=>({...c,pinned:i.map(d=>({kind:"agent",path:d}))})),localStorage.removeItem(Ni)},[e,r,s])}function Ku(e){return u.useMemo(()=>If(e),[e])}const oN=6e4,aN=[];function Hu(e,t){const s=qc(e),r=s.read();return r!==e&&!t(r,e)?(s.write(e),e):r}function iN(e,t){const s=Object.keys(e),r=Object.keys(t);return s.length===r.length&&r.every(o=>Object.is(e[o],t[o]))}function cN(e,t){return e.length===t.length&&t.every((s,r)=>e[r]===s)}function fr(e){return Hu(e,iN)}function lN(e){return Hu(e,cN)}function dN(e,t){const s=De({select:p=>p.location.pathname}),r=Tf(t,s),o=(r==null?void 0:r.extensionId)??null,a=(r==null?void 0:r.path)??null,i=ao({strict:!1}),c=s==="/session"?i.session??null:null,d=Df(c),l=s==="/session"?(d==null?void 0:d.cwd)??i.dir??null:null,m=s==="/channels"?i.id??null:null,h=m===null?null:e(m);return u.useMemo(()=>c!==null?{kind:"session",sessionId:c,agentPath:l??"",cwd:l}:s==="/threads"?{kind:"command",commandId:"open-threads"}:s==="/todos"?{kind:"command",commandId:"open-todos"}:s==="/team"?{kind:"command",commandId:"open-directory"}:o!==null&&a!==null?{kind:"add-on",extensionId:o,path:a}:m===null||h===null?null:{kind:"room",roomId:m,roomKind:h},[c,l,s,o,a,m,h])}function Wu(){const e=Ks(oN),t=No(),s=ol(Rf),r=u.useMemo(()=>{var O;return((O=s.data)==null?void 0:O.sessions)??[]},[s.data]),o=rt(al(O=>{const $={};for(const[G,ee]of Object.entries(O.statuses))$[G]=ee.lifecycle;return $})),a=u.useMemo(()=>Object.entries(o).filter(([,O])=>O==="streaming").map(([O])=>O),[o]),i=u.useMemo(()=>Object.entries(o).filter(([,O])=>O==="blocked").map(([O])=>O),[o]),c=rt(u.useCallback(O=>O.statusCwds,[])),d=Ls(),l=u.useMemo(()=>{const O=d.data??[];return t.fleetKnown?O:O.filter($=>$.kind!=="dm")},[d.data,t.fleetKnown]),m=fr(u.useMemo(()=>{const O={};for(const $ of d.data??[]){const G=$.mentionCount??0;G>0&&(O[$.id]=G)}return O},[d.data])),h=jo(),p=fr(u.useMemo(()=>{const O={};for(const[$,G]of Object.entries(h)){if(!$.startsWith("agent:"))continue;const ee=Date.parse(G);Number.isNaN(ee)||(O[$.slice(6)]=ee)}return O},[h])),g=qn().data,x=lN(u.useMemo(()=>((g==null?void 0:g.agents)??[]).map(O=>O.projectPath),[g])),b=Ao(x).data,{brokenPaths:C}=Jx(),k=fr(ub(x,C,p)),I=u.useMemo(()=>{var O;return((O=s.data)==null?void 0:O.agentActivity)??{}},[s.data]),v=t.fleetKnown?x:aN,E=u.useMemo(()=>v.map(O=>{const $=(b==null?void 0:b[O])??null,G=I[O],ee=G===void 0?NaN:Date.parse(G);return{path:O,runtime:($==null?void 0:$.runtime)??"claude-code",namespace:($==null?void 0:$.namespace)??null,isSystem:($==null?void 0:$.isSystem)??!1,lastActivityAt:Number.isNaN(ee)?null:ee,attention:k[O]??"inactive"}}),[v,b,I,k]),R=u.useMemo(()=>pl(v,b??{}),[v,b]),_=Hs(),D=u.useMemo(()=>sw(_),[_]),P=u.useMemo(()=>{const O=new Map;for(const $ of l)O.set($.id,$.kind==="dm"?"dm":"channel");return O},[l]),T=u.useMemo(()=>O=>P.get(O)??"channel",[P]),j=xo(),w=u.useMemo(()=>j.map(({id:O,extensionId:$,path:G,title:ee})=>({id:O,extensionId:$,path:G,title:ee})),[j]),N=dN(T,w),S=gl(),M=ey({enabled:S}),B=u.useMemo(()=>S?{badge:M}:null,[S,M]);return u.useMemo(()=>({now:e,sessions:r,workingSessionIds:a,blockedSessionIds:i,liveSessionCwds:c,rooms:l,agents:E,displayNames:R,prefs:D,mentions:m,addOns:w,todos:B,activeTarget:N}),[e,r,a,i,c,l,E,R,D,m,w,B,N])}const uN="Threads and Directory are pages. Drop it in a section.",mN="Add-ons lists extension pages only.";function Gu(e){return e==="addons"?mN:uN}const qu={channels:"Channels",dms:"Direct messages"};function Ai(e){if(typeof e!="object"||e===null)return!1;const t=e.kind;if(t==="ungrouped"){const s=e.section;return s===void 0||typeof s=="string"&&s in qu}if(t==="computed"){const s=e.section;return s==="top"||s==="addons"}return t==="group"&&typeof e.groupId=="string"}function hN(e){if(typeof e!="object"||e===null)return!1;const t=e.kind;return t==="agent"?typeof e.path=="string":t==="room"&&typeof e.roomId=="string"}function Rn(e){if(typeof e!="object"||e===null)return null;const t=e.type;if(t==="item"){const s=e.ref,r=e.container;return hN(s)&&Ai(r)?{type:"item",ref:s,container:r}:null}if(t==="group"){const s=e.groupId;return typeof s=="string"?{type:"group",groupId:s}:null}if(t==="container"){const s=e.container;return Ai(s)?{type:"container",container:s}:null}return null}function Yu(e){return e===null?null:e.type==="item"?{type:"item",ref:e.ref,from:e.container}:e.type==="group"?{type:"group",groupId:e.groupId}:null}function Vu(e){if(e===null)return null;switch(e.type){case"item":return{type:"item",ref:e.ref,container:e.container};case"group":return{type:"group-header",groupId:e.groupId};case"container":return{type:"container",container:e.container}}}function Qu(e){switch(e.type){case"container":return{container:e.container};case"item":return{container:e.container,overRef:e.ref};case"group-header":return{container:{kind:"group",groupId:e.groupId}}}}function Zr(e,t){return e.findIndex(s=>Of(s,t))}function Ei(e,t,s,r){const o=e.groups.find(i=>i.id===s);if(!o)return{kind:"none"};if(o.kind==="smart")return{kind:"reject-smart-group",groupId:s,ref:t};let a=null;if(o.sortMode==="manual"&&r!==void 0){const i=Zr(o.items,r);i>=0&&(a=i)}return{kind:"move-to-group",ref:t,groupId:s,toIndex:a}}function na(e,t,s){if(s===null)return{kind:"none"};if(t.type==="group"){if(s.type!=="group-header")return{kind:"none"};const c=e.groups.findIndex(l=>l.id===t.groupId),d=e.groups.findIndex(l=>l.id===s.groupId);return c<0||d<0||c===d?{kind:"none"}:{kind:"reorder-group",groupId:t.groupId,from:c,to:d}}const{ref:r,from:o}=t,{container:a,overRef:i}=Qu(s);if(a.kind==="computed")return{kind:"reject-computed-section",ref:r,section:a.section};if(o.kind==="group"){if(a.kind==="ungrouped")return{kind:"remove-from-group",ref:r};if(a.groupId!==o.groupId)return Ei(e,r,a.groupId,i);const c=e.groups.find(m=>m.id===o.groupId);if(!c||c.sortMode!=="manual"||i===void 0)return{kind:"none"};const d=Zr(c.items,r),l=Zr(c.items,i);return d<0||l<0||d===l?{kind:"none"}:{kind:"reorder-within-group",groupId:o.groupId,ref:r,from:d,to:l}}return a.kind==="group"?Ei(e,r,a.groupId,i):{kind:"none"}}function fN(e,t,s){switch(t.kind){case"none":case"reject-smart-group":case"reject-computed-section":return e;case"reorder-group":return Pf(e,t.from,t.to);case"remove-from-group":return _f(e,{kind:"item",ref:t.ref},s);case"reorder-within-group":return fa(e,t.groupId,t.from,t.to);case"move-to-group":{const r=Mf(e,t.ref,t.groupId);if(t.toIndex===null)return r;const o=r.groups.find(a=>a.id===t.groupId);return o?fa(r,t.groupId,o.items.length-1,t.toIndex):r}}}function pN(e,t,s,r){return fN(e,na(e,t,s),r)}function gN(e,t){return e.type==="group"?`Picked up section ${t.groupName(e.groupId)}.`:`Picked up ${t.itemName(e.ref)}.`}function xN(e,t){switch(e.kind){case"reorder-group":return`Moved section ${t.groupName(e.groupId)}.`;case"move-to-group":return`Moved ${t.itemName(e.ref)} to ${t.groupName(e.groupId)}.`;case"remove-from-group":return`Moved ${t.itemName(e.ref)} out of its section.`;case"reorder-within-group":return`Reordered ${t.itemName(e.ref)} in ${t.groupName(e.groupId)}.`;case"reject-smart-group":return`Can’t move ${t.itemName(e.ref)} into ${t.groupName(e.groupId)}. Membership is rule-based. Edit rules instead.`;case"reject-computed-section":return`Can’t move ${t.itemName(e.ref)} there. ${Gu(e.section)}`;case"none":return""}}function bN(e,t){if(e===null)return"";const{container:s}=Qu(e);switch(s.kind){case"ungrouped":return`Over ${qu[s.section??"dms"]}.`;case"computed":return s.section==="addons"?"Over Add-ons.":"Over Threads and Directory.";case"group":return`Over ${t.groupName(s.groupId)}.`}}function yN(e){const t=r=>Yu(Rn(r.active.data.current)),s=r=>{var o;return Vu(Rn((o=r.over)==null?void 0:o.data.current))};return{onDragStart:r=>{const o=t(r);return o?gN(o,e()):void 0},onDragOver:r=>{if(t(r))return bN(s(r),e())||void 0},onDragEnd:r=>{const o=t(r);if(!o)return;const a=e(),i=na(a.prefs,o,s(r));return i.kind==="none"?"Movement cancelled. Item returned to its place.":xN(i,a)},onDragCancel:r=>{const o=t(r);if(!o)return;const a=e();return`Movement cancelled. ${o.type==="group"?a.groupName(o.groupId):a.itemName(o.ref)} returned to its place.`}}}function vN({label:e}){const t=ht();return n.jsx(re.div,{initial:{scale:1},animate:{scale:t===!0?1:Ff},transition:{duration:t===!0?0:Lf},className:"bg-sidebar border-sidebar-border text-sidebar-foreground shadow-floating flex items-center rounded-md border px-2.5 py-1.5 text-xs font-medium",children:e})}function wN(e){const t=e.defaultView;if(t===null)return;const s=[],r=a=>{a.preventDefault(),a.stopImmediatePropagation(),s.push(a)};t.addEventListener("keydown",r,!0);const o=()=>{const a=s.shift();if(a===void 0)return;(a.target instanceof t.Node?a.target:e).dispatchEvent(new t.KeyboardEvent("keydown",{key:a.key,code:a.code,altKey:a.altKey,ctrlKey:a.ctrlKey,metaKey:a.metaKey,shiftKey:a.shiftKey,repeat:a.repeat,bubbles:!0,cancelable:!0,composed:!0})),s.length>0&&t.setTimeout(o)};t.setTimeout(()=>{t.setTimeout(()=>{t.removeEventListener("keydown",r,!0),o()})})}const jN=60;function kN(e){const t=document.querySelectorAll(`[${pa}]`);for(const s of t)if(s.getAttribute(pa)===e)return s.querySelector(`[${xl}]`);return null}function SN(e,t=jN){let s=t;const r=()=>{const o=kN(e);if(o!==null){o.focus();return}s-- >0&&requestAnimationFrame(r)};requestAnimationFrame(r)}const CN={start:["Space"],cancel:["Escape"],end:["Space","Enter","Tab"]};function NN(e){switch(e.kind){case"move-to-group":return ga(e.groupId,e.ref);case"remove-from-group":return ga("ungrouped",e.ref);default:return null}}function AN({data:e,itemName:t,groupName:s}){const r=e.type==="group"?s(e.groupId):e.type==="item"?t(e.ref):"";return n.jsx(vN,{label:r})}function EN({children:e,displayNames:t,rooms:s}){const r=_e(),o=Hs(),{update:a}=Ws(),[i,c]=u.useState(null),d=$t(o),l=$t(t),m=u.useMemo(()=>Object.fromEntries(s.map(I=>[I.id,I.slug??I.title])),[s]),h=$t(m),p=u.useMemo(()=>$f(s),[s]),f=$t(p),g=Yc(xs(Qc,{activationConstraint:{distance:8}}),xs(Vc,{coordinateGetter:Er,keyboardCodes:CN}));if(r)return n.jsx(n.Fragment,{children:e});const x=I=>{var v;return((v=d.read().groups.find(E=>E.id===I))==null?void 0:v.name)??"group"},y=I=>I.kind==="agent"?l.read()[I.path]??I.path.split("/").pop()??"Agent":h.read()[I.roomId]??"room",b=yN(()=>({prefs:d.read(),itemName:y,groupName:x})),C=I=>{if(I.activatorEvent instanceof KeyboardEvent&&I.activatorEvent.target instanceof Node){const v=I.activatorEvent.target.ownerDocument;v!==null&&wN(v)}c(Rn(I.active.data.current))},k=I=>{var D;c(null);const v=Yu(Rn(I.active.data.current));if(v===null)return;const E=Vu(Rn((D=I.over)==null?void 0:D.data.current)),R=na(d.read(),v,E);if(R.kind==="reject-smart-group"){ce.info("Membership is rule-based. Edit rules instead.",{description:x(R.groupId)});return}if(R.kind==="reject-computed-section"){ce.info(Gu(R.section),{description:y(R.ref)});return}if(R.kind==="none"||(a(P=>pN(P,v,E,f.read())),!(I.activatorEvent instanceof KeyboardEvent)))return;const _=NN(R);_!==null&&SN(_)};return n.jsx(Bf,{value:!0,children:n.jsxs(Xc,{sensors:g,collisionDetection:Wc,accessibility:{announcements:b},onDragStart:C,onDragEnd:k,onDragCancel:()=>c(null),children:[e,n.jsx(zf,{children:i?n.jsx(AN,{data:i,itemName:y,groupName:x}):null})]})})}const IN='[aria-current="page"]';function RN(e,t,s){const r=ht(),o=u.useRef(null);u.useLayoutEffect(()=>{var l,m;if(!s)return;const a=o.current===null,i=((l=o.current)==null?void 0:l.key)??null;if(o.current={key:t},!a&&(i===t||t===null)||t===null)return;const c=(m=e.current)==null?void 0:m.querySelector(IN);if(!(c instanceof HTMLElement))return;const d=!a&&r!==!0;c.scrollIntoView({block:"nearest",behavior:d?"smooth":"auto"})},[t,e,s])}function TN(e){const t=new Map;for(const s of e)s.rows.forEach((r,o)=>{t.set(r.key,{sectionId:s.id,index:o,row:r})});return t}function DN(e,t){const s=new Set(e.map(c=>c.id)),r=new Map,o=new Map;for(const c of e)for(const d of c.rows)r.set(d.key,d),o.set(d.key,c.id);const a=new Map;for(const[c,d]of t){if(d.row.target.kind==="command"||o.get(c)===d.sectionId||!s.has(d.sectionId))continue;const l=a.get(d.sectionId)??[];l.push({index:d.index,row:r.get(c)??d.row}),a.set(d.sectionId,l)}const i=new Set([...a.values()].flat().map(c=>c.row.key));return i.size===0?e:e.map(c=>{const d=a.get(c.id)??[],l=c.rows.filter(h=>!i.has(h.key));if(d.length===0&&l.length===c.rows.length)return c;const m=[...l];for(const h of[...d].sort((p,f)=>p.index-f.index))m.splice(Math.min(h.index,m.length),0,h.row);return{...c,rows:m}})}function ON(){const[e,t]=u.useState(!1),[s,r]=u.useState(!1),o=u.useCallback(()=>t(!0),[]),a=u.useCallback(()=>t(!1),[]),i=u.useCallback(()=>r(!0),[]),c=u.useCallback(d=>{const l=d.relatedTarget;(l===null||!d.currentTarget.contains(l))&&r(!1)},[]);return{inside:e||s,handlers:{onPointerEnter:o,onPointerLeave:a,onFocus:i,onBlur:c}}}function MN(e,t,s){const[r,o]=u.useState(null);!t&&r!==null&&o(null),t&&(r===null||r.key!==s)&&o({held:TN(e),key:s});const a=t?(r==null?void 0:r.held)??null:null;return u.useMemo(()=>a===null?e:DN(e,a),[e,a])}const _N=[2,3,3],Ii=["w-14","w-10","w-16"];function PN(){return n.jsx("div",{className:"flex flex-col gap-1","data-testid":"sidebar-skeleton","aria-hidden":!0,children:_N.map((e,t)=>n.jsxs("div",{className:"flex flex-col",children:[n.jsx("div",{className:K("flex h-7 items-center",Uf),children:n.jsx(mt,{className:K("h-2.5 rounded-sm",Ii[t])})}),Array.from({length:e},(s,r)=>n.jsx(Kf,{showIcon:!0},r))]},Ii[t]))})}const LN=.16,FN=4,$N=.03,BN={hidden:{},shown:{transition:{staggerChildren:$N}}},zN={hidden:{opacity:0,y:FN},shown:{opacity:1,y:0}};function Ri(e){return{duration:e===!0?0:LN}}const Xu="text-muted-foreground flex min-h-7 items-center px-1 text-xs font-medium max-md:min-h-11";function Ju({link:e,active:t,emphasized:s,glyph:r,children:o,trailing:a}){const i=_e()?"coarse":"fine";return n.jsxs(qf,{...Ne.channels(),search:e,"aria-current":t?"page":void 0,[xl]:"","data-row-state":t?"active":s?"emphasized":"quiet",className:Yf({pointer:i,state:t?"active":s?"emphasized":"quiet"}),children:[n.jsx("span",{className:K("flex shrink-0 items-center",vl),children:r}),n.jsxs("span",{className:K("flex min-w-0 flex-1 items-center gap-1.5",wl),children:[n.jsx("span",{className:"min-w-0 flex-1 truncate",children:o}),a]})]})}function nt({children:e,failed:t=!1,onRetry:s,live:r=!0}){return n.jsxs("div",{...r?{role:"status"}:{},"data-slot":"space-status-row",className:K("text-sidebar-foreground/70 text-control flex min-h-7 items-center rounded-md py-1 max-md:min-h-11",Hf),children:[n.jsx("span",{className:K("flex shrink-0 items-center",vl),children:t&&n.jsx(bl,{"aria-hidden":!0,className:K(yl,"text-status-error-fg")})}),n.jsx("span",{className:K("min-w-0 flex-1 truncate",wl),children:e}),s&&n.jsx(F,{variant:"ghost",size:"xs",onClick:s,className:"text-sidebar-foreground hover:bg-sidebar-accent/70 ml-2 shrink-0",children:"Try again"})]})}function UN(){var r;const e=Gs(!0),t=Un();if(!t.community)return null;if(e.isPending)return n.jsx(nt,{children:"Loading space…"});if(e.isError)return n.jsx(nt,{failed:!0,onRetry:()=>void e.refetch(),children:"Spaces could not be loaded."});const s=(r=e.data)==null?void 0:r.find(({ref:o})=>o===t.community);return s?s.status!=="connected"?n.jsx(nt,{children:"Reconnect this space to open its channels."}):n.jsx(KN,{connection:s}):n.jsx(nt,{children:"This space is no longer connected."})}function KN({connection:e}){var c,d,l;const t=jl(e.access),s=Wf(e.ref,t.capabilities.read,t.fingerprint),r=Un(),{ref:o,onKeyDown:a}=Gf(),i={ref:o,onKeyDown:a};return n.jsxs("section",{"aria-label":e.label,className:"py-2 max-md:py-3",...i,children:[n.jsx("h3",{className:Xu,children:e.label}),!t.cacheReadable&&n.jsx(nt,{children:e.status==="reconnect-required"?"Reconnect to view channels.":"Channels aren’t available."}),t.cacheReadable&&!t.verified&&n.jsx(nt,{children:"Saved channels"}),t.verified&&s.isPending&&n.jsx(nt,{children:"Loading channels…"}),t.verified&&s.isError&&n.jsx(nt,{failed:!0,onRetry:()=>void s.refetch(),children:"Space unavailable."}),((c=s.data)==null?void 0:c.stale)&&n.jsx(nt,{live:!1,children:"Saved channels · offline"}),(d=s.data)==null?void 0:d.rooms.filter(m=>!m.archived).map(m=>{const h=m.unreadCount!==null&&m.unreadCount>0;return n.jsxs(Ju,{link:{community:e.ref,id:m.roomId},active:r.community===e.ref&&r.id===m.roomId,emphasized:h,glyph:n.jsx(Eo,{"aria-hidden":!0,className:yl}),children:[n.jsx(Co,{room:{kind:m.kind,title:m.title,slug:m.slug??m.title}}),h&&n.jsx("span",{className:"sr-only",children:", new messages"})]},m.roomId)}),((l=s.data)==null?void 0:l.rooms.length)===0&&n.jsx(nt,{live:!1,children:"No channels available."}),t.verified&&n.jsx(HN,{connection:e})]})}function HN({connection:e}){var o;const t=jl(e.access),s=Vf(e.ref,t.capabilities.read,t.fingerprint),r=Un();return!((o=s.data)!=null&&o.available)||s.data.dms.length===0&&!s.data.incomplete?null:n.jsxs("section",{className:"mt-4","aria-label":"Direct messages",children:[n.jsx("h4",{className:Xu,children:"Direct messages"}),s.data.dms.map(a=>{const i=!a.readOnly&&a.unreadCount>0;return n.jsxs(Ju,{link:{community:e.ref,id:a.roomId},active:r.community===e.ref&&r.id===a.roomId,emphasized:i,glyph:n.jsx(So,{room:{id:a.roomId,kind:"dm",title:a.agent.displayName},participants:[{id:a.agent.memberId,kind:"agent",displayName:a.agent.displayName,handle:null}],className:Jf}),trailing:i?n.jsx(Us,{count:a.unreadCount,label:Xf(a.unreadCount,"messages")}):void 0,children:[Qf(a),a.readOnly&&n.jsx("span",{className:"text-sidebar-foreground/70",children:" · read-only"})]},a.roomId)}),s.data.incomplete&&n.jsx(nt,{failed:!0,children:"Some direct messages couldn’t load."})]})}const WN=1,Ti=40;function GN({onCommit:e,onCancel:t}){const[s,r]=u.useState(""),o=u.useRef(null),a=u.useRef(!1),i=Zf(o);u.useEffect(()=>{var l;(l=o.current)==null||l.focus()},[]);const c=()=>{if(a.current)return;a.current=!0;const l=s.trim();if(l.length<WN||l.length>Ti){t();return}e(l)},d=l=>{l.key==="Enter"?(l.preventDefault(),c()):l.key==="Escape"&&(l.preventDefault(),a.current=!0,t())};return n.jsx(ep,{children:n.jsxs("div",{className:"flex w-full items-center gap-2 rounded-md px-2 py-1.5",children:[n.jsx(tp,{className:"text-muted-foreground size-(--size-icon-sm) shrink-0"}),n.jsx("input",{ref:o,value:s,maxLength:Ti,placeholder:"Section name","aria-label":"New section name",onChange:l=>r(l.target.value),onKeyDown:d,onBlur:l=>{i.shouldHandleBlur(l)&&(a.current||t())},className:K("bg-background text-foreground placeholder:text-muted-foreground/50","focus-visible:ring-ring min-w-0 flex-1 rounded border px-1.5 py-0.5 text-xs outline-none focus-visible:ring-1")})]})})}function qN(e){return e.collapsible?e.id.startsWith("group:")||Cl(e.id)!==null:!1}function Zu({model:e}){const{update:t}=Ws(),s=Hs(),{inside:r,handlers:o}=ON(),a=MN(e.sections,r,s),i=np(),c=ys(i.destination),l=kl(c??void 0).visible?c:null,m=No(),h=ht(),p=Sl(),f=u.useRef(null),g=p.activeTarget===null?null:sp(p.activeTarget);RN(f,g,m.settled);const x=e.sections.filter(qN),y=u.useCallback(()=>{if(x.length===0)return;const v=x.some(E=>!E.collapsed);t(E=>{let R=E;for(const _ of x){if(_.id.startsWith("group:")){R=rp(R,_.id.slice(6),v);continue}const D=Cl(_.id);D!==null&&(R=xa(R,D,v))}return R})},[x,t]),b=e.sections.find(v=>v.id==="addons"),C=(b==null?void 0:b.collapsed)??!1,k=u.useCallback(()=>t(v=>xa(v,"addons",!C)),[C,t]),I={variants:zN,transition:Ri(h)};return l?n.jsxs("div",{className:"flex min-h-0 flex-col","data-community-context":l,children:[n.jsx(UN,{}),b!==void 0&&n.jsx(ba,{section:b,onToggleAll:k})]}):n.jsx("div",{ref:f,className:"flex flex-col gap-1",...o,children:n.jsx(Ye,{mode:"wait",initial:!1,children:m.phase==="cold"?n.jsx(re.div,{exit:{opacity:0},transition:Ri(h),children:n.jsx(PN,{})},"skeleton"):n.jsx(re.div,{className:"flex flex-col gap-1",variants:BN,initial:m.startedWarm?!1:"hidden",animate:"shown",children:n.jsx(Nl,{id:"sidebar-sections",children:a.map(v=>n.jsxs(re.div,{...I,children:[n.jsx(ba,{section:v,onToggleAll:y}),v.id==="top"&&n.jsx(YN,{})]},v.id))})},"sections")})})}function YN(){const e=Sl();return e.groupCreation===null?null:n.jsx(op,{children:n.jsx(GN,{onCommit:e.commitNewGroup,onCancel:e.cancelNewGroup})})}const Di="flex min-h-0 flex-1 flex-col";function VN(){Uu();const e=Wu(),t=Ku(e),s=ap(),r=n.jsxs(n.Fragment,{children:[n.jsx(ip,{className:"sidebar-scroll-edges px-2 py-3",children:n.jsx(Al,{activeTarget:e.activeTarget,children:n.jsx(EN,{displayNames:e.displayNames,rooms:e.rooms,children:n.jsx(Zu,{model:t})})})}),n.jsx(zu,{})]});return s?n.jsx("div",{className:Di,children:r}):n.jsx(El,{className:Di,children:r})}const QN=2;function XN(){return{label:"Active now",rules:{statuses:["needs-attention","active"]}}}function JN(e){const t=new Map;for(const s of e)t.set(s.runtime,(t.get(s.runtime)??0)+1);return Array.from(t.entries()).filter(([,s])=>s>=QN).map(([s,r])=>({runtime:s,count:r,label:dt(s).label})).sort((s,r)=>r.count-s.count||s.label.localeCompare(r.label)).map(({runtime:s,label:r})=>({label:`Runs on ${r}`,rules:{runtimes:[s]}}))}const Oi="agent:";function ZN(){const[e]=Fs(),t=jo(),{data:s}=qn(),r=u.useMemo(()=>((s==null?void 0:s.agents)??[]).map(i=>i.projectPath),[s]),{data:o}=Ao(r),a=u.useMemo(()=>pl(r,o??{}),[r,o]);return u.useMemo(()=>{const i=new Set(r);let c=null,d=-1/0;for(const[m,h]of Object.entries(t)){if(!m.startsWith(Oi))continue;const p=m.slice(Oi.length);if(!i.has(p))continue;const f=Date.parse(h);Number.isNaN(f)||f<=d||(d=f,c=p)}const l=e!==null&&i.has(e)?e:c;return l===null?null:{path:l,displayName:a[l]??l}},[a,t,r,e])}function eA(e){u.useEffect(()=>{if(!$e())return;const t=s=>{!(s.metaKey||s.ctrlKey)||s.shiftKey||s.altKey||s.key.toLowerCase()==="n"&&(s.preventDefault(),e())};return document.addEventListener("keydown",t),()=>document.removeEventListener("keydown",t)},[e])}function tA(e){const t=e.smartGroupPresets.length===0?[]:[{kind:"separator",id:"sep-smart"},...e.smartGroupPresets.map(r=>({kind:"action",id:`new-group-preset:${r.label}`,label:r.label,icon:jn,opensInput:!1,run:()=>e.onCreatePresetSmartGroup(r)})),{kind:"action",id:"new-group-custom",label:"Custom rules",icon:jn,opensInput:!0,run:e.onOpenSmartGroupDialog}],s=[t.length===0?{kind:"action",id:"new-group",label:"Section",icon:jn,opensInput:!0,run:e.onNewGroup}:{kind:"submenu",id:"new-group",label:"Section",icon:jn,items:[{kind:"action",id:"new-group-empty",label:"Empty section",icon:jn,opensInput:!0,run:e.onNewGroup},...t]}];return[{kind:"action",id:"new-session",label:"Chat",icon:fl,opensInput:!1,...e.showSessionShortcut?{hint:Wt(cn.NEW_SESSION)}:{},run:e.onNewSession},...e.lastUsedAgentName===null?[]:[{kind:"note",id:"new-session-note",icon:ay,text:`Starts with ${e.lastUsedAgentName} (last used)`}],{kind:"separator",id:"sep-rooms"},{kind:"action",id:"new-channel",label:"Channel",icon:Eo,opensInput:!0,run:e.onNewChannel},{kind:"action",id:"new-message",label:"Group message",icon:xd,opensInput:!0,run:e.onNewMessage},{kind:"separator",id:"sep-agents"},{kind:"action",id:"new-agent",label:"Agent",icon:mp,opensInput:!0,run:e.onNewAgent},...s]}function Mi(){const e=_e(),t=Jn(M=>M.menuOpen),s=Jn(M=>M.preselect),r=Jn(M=>M.setMenuOpen),o=Jn(M=>M.requestNewGroup),a=Pe(),i=ml(),c=ty(),d=ul(),l=ZN(),{update:m}=Ws(),[h,p]=u.useState(!1),[f,g]=u.useState(!1),[x,y]=u.useState(!1),{data:b}=qn(),C=u.useMemo(()=>((b==null?void 0:b.agents)??[]).map(M=>M.projectPath),[b]),{data:k}=Ao(C),I=u.useMemo(()=>C.map(M=>{var B,O;return{projectPath:M,runtime:((B=k==null?void 0:k[M])==null?void 0:B.runtime)??"claude-code",namespace:((O=k==null?void 0:k[M])==null?void 0:O.namespace)??null,attention:"inactive",lastActivityAt:null}}),[C,k]),v=cp(I),E=u.useMemo(()=>v?[XN(),...JN(I)]:[],[I,v]),R=u.useMemo(()=>{const M=new Map;for(const B of I)M.has(B.runtime)||M.set(B.runtime,dt(B.runtime).label);return Array.from(M,([B,O])=>({value:B,label:O})).sort((B,O)=>B.label.localeCompare(O.label))},[I]),_=u.useMemo(()=>{const M=new Set;for(const B of I)B.namespace&&M.add(B.namespace);return Array.from(M).sort()},[I]),D=u.useCallback((M,B)=>m(O=>lp(O,M,B).next),[m]),P=u.useCallback(M=>{bs.getState().recordOpened("room",M.id),a({...Ne.channels(),search:{id:M.id}})},[a]),T=u.useCallback(()=>i(l==null?void 0:l.path),[l,i]);eA(T);const j=u.useCallback(M=>{const[B]=M;if(B!==void 0&&ny(M)){bs.getState().recordOpened("agent",B.agentPath),d({agentPath:B.agentPath});return}const O=dp(M.map($=>$.displayName));c.mutate({agentPaths:M.map($=>$.agentPath),title:O},{onSuccess:P})},[d,P,c]),w=tA({onNewSession:T,lastUsedAgentName:(l==null?void 0:l.displayName)??null,onNewChannel:()=>p(!0),onNewMessage:()=>g(!0),onNewAgent:()=>Ts.getState().open(),onNewGroup:()=>o(),smartGroupPresets:E,onCreatePresetSmartGroup:M=>D(M.label,M.rules),onOpenSmartGroupDialog:()=>y(!0),showSessionShortcut:$e()}),N=Il(w),S=u.useRef(null);return u.useEffect(()=>{if(!t||s===null)return;const M=requestAnimationFrame(()=>{var B,O;(O=(B=S.current)==null?void 0:B.querySelector(`[data-menu-item-id="${s}"]`))==null||O.focus()});return()=>cancelAnimationFrame(M)},[t,s]),n.jsxs(n.Fragment,{children:[n.jsxs(Rl,{open:t,onOpenChange:r,children:[n.jsx(Tl,{asChild:!0,children:n.jsxs(F,{variant:"secondary",size:"xs","data-testid":"sidebar-new-button",className:"bg-sidebar-accent text-sidebar-accent-foreground hover:bg-sidebar-accent/70 data-[state=open]:bg-sidebar-accent/70 max-md:has-[>svg]:px-3",children:[n.jsx(Dt,{className:dn}),"New"]})}),n.jsxs(Dl,{align:"end",className:"w-56",onCloseAutoFocus:N.onCloseAutoFocus,children:[e&&n.jsx(Tr,{children:"New"}),n.jsx("div",{ref:S,...e?{role:"menu","aria-label":"New"}:{className:"contents"},children:n.jsx(Dr,{variant:e?"sheet":"dropdown",nodes:N.nodes,onSheetClose:()=>r(!1)})})]})]}),h&&n.jsx(sy,{open:!0,onOpenChange:M=>!M&&p(!1),onCreated:P}),n.jsx(ry,{open:f,onOpenChange:g,onStart:j,hideTrigger:!0}),n.jsx(up,{open:x,onOpenChange:y,mode:"create",runtimeOptions:R,namespaceOptions:_,onSubmit:({name:M,rules:B})=>D(M,B)})]})}function _i({className:e}={}){const t=L(r=>r.setGlobalPaletteOpen),s=_e();return n.jsxs("button",{type:"button","data-testid":"sidebar-search-pill",onClick:()=>t(!0),className:K("bg-sidebar-accent/40 text-sidebar-foreground/70 hover:bg-sidebar-accent/70 hover:text-sidebar-foreground focus-ring text-control flex w-full items-center gap-1.5 rounded-md px-2 py-1.5 transition-colors duration-(--dur-fast)",s&&Io,e),children:[n.jsx(ps,{className:"size-(--size-icon-sm) shrink-0"}),n.jsx("span",{className:"truncate",children:"Find a conversation…"}),n.jsx(Ol,{className:"bg-sidebar-accent text-sidebar-foreground/70 ml-auto shrink-0 border-transparent",children:Wt(cn.COMMAND_PALETTE)})]})}function nA(e){const t=[];return e.you!==null&&t.push({kind:"action",id:"you",label:e.you.name,description:"View profile",icon:mo,leading:e.you.face,guardsFocus:!0,run:e.you.onOpen}),t.push({kind:"action",id:"dorkos-account",label:"DorkOS account",description:e.accountStatus,icon:cd,guardsFocus:!0,run:e.onOpenAccount},{kind:"action",id:"settings",label:"Settings",icon:zs,guardsFocus:!0,run:e.onOpenSettings}),t}function sA(e){return e.isDevMode?[{kind:"separator",id:"sep-version"},{kind:"note",id:"version",icon:ya,text:"Development build"}]:e.version===null?[]:[{kind:"separator",id:"sep-version"},{kind:"action",id:"version",label:`v${e.version} beta`,icon:ya,opensInput:!1,hint:"Check for updates",run:e.onCheckForUpdates}]}function rA(e){const t=(e==null?void 0:e.trim())??"";return t.length===0||t===hp?"Your team":t.endsWith("s")?`${t}’ team`:`${t}’s team`}function oA(e,t){const s=fp(e);return u.createElement(fs,{size:t,kind:s.kind,color:s.color,emoji:s.emoji,imageUrl:s.imageUrl,fallback:s.fallback,origin:s.origin})}function em(e="xs"){var i;const t=lo(),{open:s}=ct(),{open:r}=Ro(),o=HS(),a=((i=t.data)==null?void 0:i.members.find(c=>c.isSelf))??null;return{you:a===null?null:{name:a.displayName,face:oA(a,e),onOpen:()=>r(a.id)},accountStatus:KS(o),onOpenAccount:()=>s("account"),onOpenSettings:()=>s()}}function aA(e=[]){var l;const t=lo(),s=ie(),r=le(),o=em(),a=((l=t.data)==null?void 0:l.members.find(m=>m.isSelf))??null,{data:i,refetch:c}=Ee({queryKey:Fe.current(),queryFn:()=>s.getConfig(),staleTime:vc}),d=u.useCallback(async()=>{var f,g;await r.invalidateQueries({queryKey:Fe.all});const m=await c(),h=(f=m.data)==null?void 0:f.version,p=((g=m.data)==null?void 0:g.latestVersion)??null;if(h===void 0){ce.error("Couldn’t check for updates");return}if(p!==null&&Lo(p,h)){ce.success(`Version ${p} is available`);return}ce.success("You’re up to date")},[r,c]);return{teamName:rA((a==null?void 0:a.displayName)??null),nameUnknown:t.isPending,identityNodes:nA(o),nodes:[...e,...sA({version:(i==null?void 0:i.version)??null,isDevMode:(i==null?void 0:i.isDevMode)??!1,onCheckForUpdates:()=>void d()})]}}const iA=Ml("/self-hosting/space-server");function cA(e){const t=[];for(const s of e)s.hostOperator===!0&&!t.includes(s.pinnedOrigin)&&t.push(s.pinnedOrigin);return t}function lA(e){var o,a,i;const t=e.status!=="pending"&&((o=e.access)==null?void 0:o.state)!=="unverified",s=((i=(a=e.access)==null?void 0:a.lastKnown)==null?void 0:i.lifecycle)??null,r=e.status==="connected";return{hostReachable:t,canInvite:t&&r&&s==="active",canOpenSettings:t,canLeave:t&&r}}function ns(e){try{return new URL(e).host}catch{return e}}function dA(e){const t=[],s=e.selected;if(s){const{connection:i,availability:c}=s,d=[],l={host:ns(i.pinnedOrigin)};c.canInvite&&d.push({kind:"action",id:"community-invite",label:"Invite people",icon:gp,external:l,run:e.onInvite}),c.canOpenSettings&&d.push({kind:"action",id:"community-settings",label:"Space settings",icon:zs,external:l,run:e.onOpenSettings}),s.canMoveUp&&d.push({kind:"action",id:"community-move-up",label:"Move up",icon:xp,run:()=>e.onMove("up")}),s.canMoveDown&&d.push({kind:"action",id:"community-move-down",label:"Move down",icon:bp,run:()=>e.onMove("down")}),d.push({kind:"separator",id:"community-sep-end"}),d.push({kind:"action",id:"community-disconnect",label:"Disconnect",icon:dy,opensInput:!0,destructive:!0,run:e.onDisconnect}),c.canLeave&&d.push({kind:"action",id:"community-leave",label:"Leave space",icon:yp,opensInput:!0,external:l,run:e.onLeave}),t.push({kind:"submenu",id:"community-actions",label:`Manage ${i.label}`,icon:Pr,items:d})}e.onJoinOfficial&&t.push({kind:"action",id:"join-official-space",label:"Join the DorkOS community",icon:Or,opensInput:!0,run:e.onJoinOfficial});const r=e.onJoin;if(!r)return t;const o=[...e.creationOrigins.map(i=>({kind:"action",id:e.creationOrigins.length===1?"add-community-create":`add-community-create-${ns(i)}`,label:e.creationOrigins.length===1?"Create a space on your server":`Create a space on ${ns(i)}`,icon:By,opensInput:!0,external:{host:ns(i)},run:()=>e.onCreate(i)})),{kind:"action",id:"add-community-deploy",label:"Run your own space server",icon:pp,run:e.onDeploy}],a=[];return e.hosting&&a.push({kind:"action",id:"add-community-start",label:"Start a space",icon:To,opensInput:!0,run:e.hosting.onStart}),a.push({kind:"action",id:"add-community-join",label:"Join a space",icon:Or,opensInput:!0,run:r}),e.hosting&&a.push({kind:"action",id:"add-community-yours",label:"Your spaces",icon:Ly,guardsFocus:!0,run:e.hosting.onOpenYourSpaces}),a.push({kind:"separator",id:"add-community-sep-advanced"},{kind:"submenu",id:"add-community-advanced",label:"Advanced",icon:bd,items:o}),t.push({kind:"submenu",id:"add-community",label:"Add a space",icon:Dt,items:a}),t}function tm(e){var s,r,o,a,i,c;const t=(r=(s=e.access)==null?void 0:s.lastKnown)==null?void 0:r.lifecycle;return{kind:"community",key:`community:${e.ref}`,ref:e.ref,remoteCommunityId:e.remoteCommunityId,label:e.label,icon:{kind:"community",ref:e.ref},pinnedOrigin:e.pinnedOrigin,membershipState:t==="deletion_pending"?"deletion-pending":t==="taken_down"?"taken-down":t??(e.status==="pending"?"pending":"active"),connectionState:e.status,availability:((o=e.access)==null?void 0:o.state)==="verified"?"online":((a=e.access)==null?void 0:a.state)==="unverified"?"offline":"unknown",unreadCount:((i=e.attention)==null?void 0:i.unreadCount)??null,mentionCount:((c=e.attention)==null?void 0:c.mentionCount)??null}}function uA(e){var r,o;if(e.status==="reconnect-required")return"Reconnect required";const t=(o=(r=e.access)==null?void 0:r.lastKnown)==null?void 0:o.lifecycle;if(e.seemsGoneSince&&t!=="deleted"&&t!=="taken_down")return"Seems to be gone";const s=tm(e);if(s.membershipState!=="active")return s.membershipState.replace("-"," ");if(s.availability!=="online")return s.availability}function mA(e,t){const s=new Map(t.map((r,o)=>[r,o]));return[...e].sort((r,o)=>{const a=s.get(r.ref)??Number.MAX_SAFE_INTEGER,i=s.get(o.ref)??Number.MAX_SAFE_INTEGER;return a-i||r.label.localeCompare(o.label)||r.ref.localeCompare(o.ref)})}function hA(e){return e.charAt(0).toLowerCase()+e.slice(1)}function fA(e,t){const s=vp(),r=kl(e),o=ed();return{spaces:s.enabled,anySpace:s.anySpace,selectedRef:r.visible?e:void 0,visible:(t??[]).filter(a=>wp(a,s.enabled)),joinOfficial:o.link!==null&&!o.joined?o.join:null}}function pA(e){const t=va(r=>r.url),s=va(r=>r.take);u.useEffect(()=>{if(t===null)return;const r=s();r!==null&&e(r)},[t,s])}function gA({connection:e,onOpenChange:t,onDisconnected:s}){var p;const r=_l(),o=Vd(e),[a,i]=u.useState(e);e!==null&&e!==a&&i(e);const c=(a==null?void 0:a.label)??"this space",d=(a==null?void 0:a.status)==="pending"?[]:(p=o.data)==null?void 0:p.agents,l=d===void 0&&o.fetchStatus==="fetching",m=d?Xd(c,d):l?null:Jd(c);function h(){e&&r.mutate(e,{onSuccess:f=>{t(!1);const g=Zd(e.label,f);g.tone==="success"?ce.success(g.message):ce.warning(g.message,{duration:15e3}),s(e)}})}return n.jsx(jp,{open:e!==null,onOpenChange:f=>{f||r.reset(),t(f)},children:n.jsxs(kp,{children:[n.jsxs(Sp,{children:[n.jsxs(Cp,{children:["Disconnect this DorkOS from ",c,"?"]}),n.jsx(Np,{asChild:!0,children:n.jsxs("div",{className:"space-y-2",children:[n.jsxs("p",{children:["Its channels leave this app. You stay a member of ",c,"."]}),n.jsx("p",{children:"You can connect again later."}),m&&n.jsx("p",{className:"text-foreground",children:m}),l&&n.jsx("p",{children:"Checking for agents you added from here…"})]})})]}),o.isError&&d===void 0&&!l&&n.jsxs("div",{role:"alert",className:"flex flex-col items-start gap-2 text-sm sm:flex-row sm:items-center sm:justify-between sm:gap-3",children:[n.jsxs("p",{className:"text-destructive",children:["Couldn’t check which of your agents are on ",c,"."]}),n.jsx(F,{size:"sm",variant:"outline",onClick:()=>void o.refetch(),children:"Check again"})]}),r.isError&&n.jsx("p",{role:"alert",className:"text-destructive text-sm",children:"Couldn’t disconnect. Check DorkOS is running and try again."}),n.jsxs(Ap,{children:[n.jsx(Ep,{disabled:r.isPending,children:"Keep connected"}),n.jsx(F,{variant:"destructive",disabled:r.isPending||l,onClick:h,children:r.isPending?"Disconnecting…":"Disconnect"})]})]})})}function xA(e,t){var r;const s=typeof e=="object"&&e!==null?e:{};switch(s.code){case"COMMUNITY_SELECTION_REQUIRED":return`That address has several spaces. Use one space’s own link, like ${yA(t)}.`;case"COMMUNITY_NAME_NOT_FOUND":return"No space uses that address. Check the spelling, or ask for its full link.";case"COMMUNITY_RATE_LIMITED":return`Too many tries. Your address may be fine. Wait ${Ip((r=s.body)==null?void 0:r.retryAfterSeconds)}, then try again.`;case"COMMUNITY_UPGRADE_REQUIRED":return"This space’s server is too old for this DorkOS. Ask its owner to update it.";default:return"Couldn’t connect. Check the space’s address and try again."}}function bA(e){const t=typeof e=="object"&&e!==null?e.code:"";return t!=="COMMUNITY_RATE_LIMITED"&&t!=="COMMUNITY_UPGRADE_REQUIRED"}function yA(e){try{return`${new URL(e??"").origin}/your-space`}catch{return"https://example.com/acme"}}const vA="That invitation link is incomplete or isn’t secure. Copy the whole link again.";function wA(e){let t;try{t=new URL(e.trim())}catch{return!1}return/^\/(?:c\/[^/]+\/)?join\/?$/u.test(t.pathname)&&!Mr(e)}function jA(e){const t=new URL(e.trim()),s=/^(\/c\/[^/]+)\/join\/?$/u.exec(t.pathname);return s?`${t.origin}${s[1]}`:t.origin}function kA({request:e,onOpenChange:t,installName:s,onConnected:r}){var B;const o=Bn(!0),a=Gs(!0),i=Rp(o),c=e!==null,d=Zs(O=>O.links),l=Zs(O=>O.rememberLink),m=Zs(O=>O.ending),h=(o==null?void 0:o.ownerKey)??null,[p,f]=u.useState(null),g=O=>f(O===null?null:{owner:h,ref:O}),[x,y]=u.useState(null),[b,C]=u.useState(null),[k,I]=u.useState((m==null?void 0:m.id)??0),[v,E]=u.useState(null),[R,_]=u.useState(null);e!==R&&(_(e),e&&(g(e.ref),y(null))),p!==null&&h!==null&&p.owner!==h&&(p.owner===null?f({owner:h,ref:p.ref}):(f(null),y(null),E(null)));const D=p!==null&&p.owner===h?p.ref:null,P=D===null||(B=a.data)==null?void 0:B.find(O=>O.ref===D),T=!P&&b!==null&&!b.settled&&b.address===i&&b.connection.ref===D?b.connection:null,j=P??T;if(j&&h!==null&&((v==null?void 0:v.owner)!==h||v.ref!==j.ref||v.label!==j.label)&&E({owner:h,ref:j.ref,label:j.label}),m&&m.id!==k)I(m.id),m.ref===D&&m.outcome!=="connected"&&(g(null),y({address:i,value:m.outcome==="expired"?`Approval for ${m.label} expired. Connect again to continue.`:`Approval for ${m.label} was cancelled.`}));else if(c&&D!==null&&!j&&a.isSuccess){const O=(v==null?void 0:v.owner)===h&&v.ref===D?v.label:"this space";g(null),y({address:i,value:`Approval for ${O} ended somewhere else. Connect again to continue.`})}Tp(c&&(j==null?void 0:j.status)==="pending"?j.ref:null);const w=Dp((j==null?void 0:j.status)==="pending"?j:null),N=c&&(j==null?void 0:j.status)==="connected"?j.ref:null,S=u.useRef(r),M=u.useRef(t);return u.useEffect(()=>{S.current=r,M.current=t}),u.useEffect(()=>{N===null||!j||(ce.success(`${j.label} is connected.`,{id:`community-approval-${N}`}),M.current(!1),S.current(N))},[N]),n.jsx(vt,{open:c,onOpenChange:t,children:n.jsx(wt,{className:"!min-h-0 sm:max-w-md",children:n.jsx(SA,{authority:o,connection:j,check:w,approvalUrl:j&&(d==null?void 0:d.address)===i?d.urls[j.ref]:void 0,notice:(x==null?void 0:x.address)===i?x.value:"",installName:s,initialUrl:R==null?void 0:R.url,onStarted:O=>{l(i,O.connection.ref,O.approvalUrl),C({address:i,connection:O.connection,settled:!1}),g(O.connection.ref),y({address:i,value:`Next, approve this DorkOS on ${O.connection.label}.`})},onStartSettled:O=>C($=>($==null?void 0:$.connection.ref)===O?{...$,settled:!0}:$),onEnded:O=>{g(null),y({address:i,value:O})},onCancelled:O=>{t(!1),ce.success(`Approval for ${O} was cancelled.`)},onClose:()=>t(!1)})})})}function SA({authority:e,connection:t,check:s,approvalUrl:r,notice:o,installName:a,initialUrl:i,onStarted:c,onStartSettled:d,onEnded:l,onCancelled:m,onClose:h}){const p=ie(),f=le(),g=tl(),x=u.useId(),[y,b]=u.useState(i??""),[C,k]=u.useState(null),[I,v]=u.useState(!1),[E,R]=u.useState(a),_=u.useRef(null),D=u.useRef(null),P=t===null?"form":t.status,T=u.useRef(P);u.useEffect(()=>{var V,ae;const z=T.current;T.current=P,z!==P&&(P==="form"?(V=_.current)==null||V.focus():P==="pending"&&((ae=D.current)==null||ae.focus()))},[P]);const j=Qt({mutationFn:async z=>{if(!e||!Bt(e))throw new Error("Community owner is still loading.");const V=await p.startCommunityConnection({url:z,installName:E.trim()});if(!Bt(e))throw new Error("Community owner changed.");return V},onSuccess:async z=>{b(""),c(z),e&&await f.invalidateQueries({queryKey:At.connections(e)}),d(z.connection.ref)}}),w=_l(),N=Vd((t==null?void 0:t.status)==="reconnect-required"?t:null),S=j.error;u.useEffect(()=>{var z;(S||I)&&((z=_.current)==null||z.focus())},[S,I]);const M=Mr(y),B=I?vA:j.error?xA(j.error,j.variables):null;function O(z){if(z.preventDefault(),!(!y.trim()||j.isPending)){if(wA(y)){j.reset(),v(!0);return}if(Mr(y)){if(!It(g.linkFor(y.trim())))return;b(jA(y)),k({host:new URL(y.trim()).host,withAccount:g.signsInWithAccount(y)}),j.reset();return}E.trim()&&j.mutate(y.trim())}}function $(z){w.mutate(z,{onSuccess:V=>{if(z.status==="pending")m(z.label);else{const ae=Zd(z.label,V);l(ae.tone==="success"?`${z.label} is disconnected. Connect again to continue.`:ae.message)}},onSettled:()=>{e&&f.invalidateQueries({queryKey:At.connections(e)})}})}const G=n.jsx("p",{role:"status","aria-live":"polite",className:o?"text-muted-foreground text-sm":"sr-only",children:o});if(t===null)return n.jsxs("form",{onSubmit:O,children:[n.jsxs(gt,{children:[n.jsx(ot,{children:"Join a space"}),n.jsx(xt,{children:"Bring a space’s channels here. You approve it on the space’s site."})]}),n.jsxs(Et,{className:"space-y-4 py-4",children:[G,n.jsxs("div",{className:"space-y-1.5",children:[n.jsx(He,{htmlFor:`${x}-url`,children:"Space address or invitation link"}),n.jsx(yt,{ref:_,id:`${x}-url`,type:"url",inputMode:"url",placeholder:"https://example.com/acme","aria-describedby":B?`${x}-url-hint ${x}-url-error`:`${x}-url-hint`,"aria-invalid":I||j.error&&bA(j.error)?!0:void 0,required:!0,autoComplete:"off",value:y,onChange:z=>{b(z.target.value),k(null),v(!1)},disabled:j.isPending||!e}),n.jsx("p",{id:`${x}-url-hint`,"aria-live":"polite",className:"text-muted-foreground text-xs",children:C?C.withAccount?`Join on ${C.host} with your DorkOS account in the new tab, then connect.`:`Finish joining on ${C.host} in the new tab, then connect.`:"Its link, short address or an invitation link."})]}),n.jsxs("div",{className:"space-y-1.5",children:[n.jsx(He,{htmlFor:`${x}-name`,children:"Name for this installation"}),n.jsx(yt,{id:`${x}-name`,required:!0,maxLength:120,"aria-describedby":`${x}-name-hint`,value:E,onChange:z=>R(z.target.value),disabled:j.isPending||!e}),n.jsx("p",{id:`${x}-name-hint`,className:"text-muted-foreground text-xs",children:"What the space calls this DorkOS."})]}),B&&n.jsx("p",{id:`${x}-url-error`,role:"alert",className:"text-destructive text-sm",children:B})]}),n.jsxs(on,{children:[n.jsx(F,{type:"button",variant:"outline",onClick:h,children:"Cancel"}),n.jsx(F,{type:"submit",disabled:j.isPending||!y.trim()||!M&&(!e||!E.trim()),children:j.isPending?"Connecting…":M?"Open invitation":"Connect"})]})]});const ee=n.jsx("p",{className:"text-muted-foreground text-xs break-all",children:t.pinnedOrigin});if(t.status==="reconnect-required"){const z=!N.data&&N.fetchStatus==="fetching",V=N.data?Xd(t.label,N.data.agents):z?null:Jd(t.label);return n.jsxs(n.Fragment,{children:[n.jsxs(gt,{children:[n.jsxs(ot,{children:["Reconnect ",t.label]}),n.jsxs(xt,{children:["DorkOS can’t reach ",t.label,"’s channels. Disconnect, then connect again."]})]}),n.jsxs(Et,{className:"space-y-3 py-4",children:[ee,V&&n.jsx("p",{className:"text-sm",children:V}),N.isError&&!N.data&&!z&&n.jsxs("div",{role:"alert",className:"flex flex-col items-start gap-2 text-sm sm:flex-row sm:items-center sm:justify-between sm:gap-3",children:[n.jsxs("p",{className:"text-destructive",children:["Couldn’t check which of your agents are on ",t.label,"."]}),n.jsx(F,{size:"sm",variant:"outline",onClick:()=>void N.refetch(),children:"Check again"})]}),w.isError&&n.jsx("p",{role:"alert",className:"text-destructive text-sm",children:"Couldn’t disconnect. Check DorkOS is running and try again."})]}),n.jsxs(on,{children:[n.jsx(F,{type:"button",variant:"outline",onClick:h,children:"Close"}),n.jsx(F,{disabled:w.isPending||z,onClick:()=>$(t),children:w.isPending?"Disconnecting…":"Disconnect"})]})]})}return n.jsxs(n.Fragment,{children:[n.jsxs(gt,{children:[n.jsxs(ot,{children:["Approve on ",t.label]}),n.jsx(xt,{asChild:!0,children:n.jsxs("div",{className:"space-y-1",children:[n.jsxs("p",{children:["Approve this DorkOS on ",t.label,"’s site."]}),r&&g.signsInWithAccount(r)&&n.jsx("p",{children:"Sign in there with your DorkOS account."}),n.jsx("p",{children:"This screen moves on once you do."})]})})]}),n.jsxs(Et,{className:"space-y-3 py-4",children:[ee,G,n.jsxs("p",{className:"flex items-center gap-2 text-sm",children:[n.jsx(Oe,{})," Waiting for your approval"]}),r?n.jsx(F,{asChild:!0,children:n.jsxs("a",{ref:D,href:g.linkFor(r),target:"_blank",rel:"noopener noreferrer",children:["Open ",t.label," to approve",n.jsx(an,{className:"size-(--size-icon-xs)","aria-hidden":!0})]})}):n.jsx("p",{className:"text-muted-foreground text-sm",children:"Approve in the tab that opened. Closed it? Cancel and connect again."}),(w.isError||!!s.error)&&n.jsxs("div",{role:"alert",className:"space-y-2 text-sm",children:[n.jsx("p",{children:w.isError?"Couldn’t confirm it was cancelled. Refresh to check.":"Couldn’t check approval. Try again."}),!w.isError&&n.jsx(F,{size:"sm",variant:"outline",onClick:s.retry,disabled:s.isFetching,children:"Check approval"})]})]}),n.jsxs(on,{children:[n.jsx(F,{type:"button",variant:"outline",onClick:h,children:"Close"}),n.jsx(F,{variant:"outline",disabled:w.isPending,onClick:()=>$(t),children:w.isPending?"Cancelling…":"Cancel approval"})]})]})}function CA(e){if(!["ArrowDown","ArrowUp","Home","End"].includes(e.key))return;const t=[...e.currentTarget.querySelectorAll('[role^="menuitem"]:not(:disabled):not([aria-disabled="true"])')];if(t.length===0)return;e.preventDefault();const s=t.indexOf(document.activeElement),r=t.length-1;let o;e.key==="Home"?o=0:e.key==="End"?o=r:e.key==="ArrowDown"?o=s<0||s===r?0:s+1:o=s<=0?r:s-1,t[o].focus()}function Pi({sheet:e,label:t="Actions",children:s}){return e?n.jsx("div",{role:"menu","aria-label":t,tabIndex:-1,onKeyDown:CA,children:s}):n.jsx(n.Fragment,{children:s})}function pr(){let e=!1;const t=()=>{e=!0};return document.addEventListener("pointerdown",t,!0),document.addEventListener("keydown",t,!0),{acted:()=>e,stop:()=>{document.removeEventListener("pointerdown",t,!0),document.removeEventListener("keydown",t,!0)}}}function NA({trigger:e,selectedRef:t}){const s=ie(),r=_e(),o=Pe(),a=De({select:f=>f.location}),i=u.useRef(!1),c=u.useRef(!1),[d,l]=u.useState(null);function m(f,g){var y;if(!r||(f||(c.current=!1),g))return;if(f){const b=pr();Mp({cancelled:b.acted}).finally(b.stop);return}const x=document.activeElement;(x===null||x===document.body)&&((y=e.current)==null||y.focus())}async function h(f){if(f.ref===t||i.current||f.status!=="connected")return;const g=wa();if(g.ownerKey===null)return;const x={epoch:g.epoch,ownerKey:g.ownerKey},y={pathname:a.pathname,search:a.search};c.current=r;const b=pr();i.current=!0,l(f.ref);let C=!1,k=null;try{await o({...Ne.channels(),search:{community:f.ref}}),C=!0,k=Pn();const I=await s.resolveCommunityNavigation(f.ref),v=I?null:(await s.listRemoteCommunityRooms(f.ref)).rooms.find(R=>R.readable&&!R.archived)??null,E=(I==null?void 0:I.roomId)??(v==null?void 0:v.roomId);if(!Bt(x)||!k.isCurrent()){m(!1,b.acted());return}E&&await o({...Ne.channels(),search:{community:f.ref,...E?{id:E}:{},...I!=null&&I.threadId?{thread:I.threadId}:{}}}),m(!0,b.acted())}catch{m(!1,b.acted()),C&&(k==null?void 0:k.isCurrent())===!0&&Bt(x)&&await o({to:y.pathname,search:y.search,replace:!0}).then(()=>!0,()=>!1)&&ce.error(`Couldn’t open ${f.label}.`,{description:"You’re still where you were. Try again in a moment."})}finally{b.stop(),i.current=!1,l(null)}}async function p(){if(t===void 0||i.current)return;const f=wa();if(f.ownerKey===null)return;const g={epoch:f.epoch,ownerKey:f.ownerKey},x=Pn();c.current=r;const y=pr();i.current=!0;try{const b=await s.getCommunityNavigation();if(b.ownerKey!==g.ownerKey||!Bt(g)||!x.isCurrent()){m(!1,y.acted());return}const C=Op.safeParse(b.installationDestination);await o(C.success?{to:C.data.path,search:C.data.search}:{...Ne.home()}),m(!0,y.acted())}catch{const b=Bt(g)&&x.isCurrent();b&&await o({...Ne.home()}),m(b,y.acted())}finally{y.stop(),i.current=!1}}return{pendingRef:d,isSelecting:()=>i.current,holdCloseFocus:()=>{c.current=!0},takeCloseFocusHold:()=>{const f=c.current;return c.current=!1,f},selectCommunity:h,selectInstallation:p}}function AA(e){const t=u.useRef(e);u.useEffect(()=>{t.current=e},[e]),u.useEffect(()=>{const s=r=>{if(r.isComposing||!(r.metaKey||r.ctrlKey)||!r.shiftKey||r.altKey||r.key.toLowerCase()!=="k")return;r.preventDefault();const o=document.activeElement;t.current(o instanceof HTMLElement&&o!==document.body?o:null)};return window.addEventListener("keydown",s),()=>window.removeEventListener("keydown",s)},[])}function nm({triggerClassName:e,compact:t=!1}){var Ge;const s=_e(),r=Pe(),o=De({select:H=>H.location.search.community}),a=_p(),i=Pp(),c=Gs(),{spaces:d,anySpace:l,selectedRef:m,visible:h,joinOfficial:p}=fA(o,c.data),f=u.useMemo(()=>{var H;return mA(h,((H=a.data)==null?void 0:H.order)??[])},[h,(Ge=a.data)==null?void 0:Ge.order]),g=f.find(H=>H.ref===m)??null,x=u.useRef(null),y=u.useRef(null),b=u.useRef(null),{pendingRef:C,isSelecting:k,holdCloseFocus:I,takeCloseFocusHold:v,selectCommunity:E,selectInstallation:R}=NA({trigger:b,selectedRef:m}),[_,D]=u.useState(""),[P,T]=u.useState(!1),[j,w]=u.useState(null),[N,S]=u.useState(null),M=bS(),[B,O]=u.useState(null),$=m?f.findIndex(H=>H.ref===m):-1;function G(H,de){It(new URL($p(H.remoteCommunityId,de),H.pinnedOrigin).toString())}const ee=dA({selected:g?{connection:g,availability:lA(g),canMoveUp:$>0,canMoveDown:$>=0&&$<f.length-1}:null,onMove:H=>{g&&i.mutate({ref:g.ref,direction:H})},onInvite:()=>g&&G(g,"community"),onOpenSettings:()=>g&&G(g),onLeave:()=>g&&G(g,"account"),onDisconnect:()=>S(g),onJoin:d?()=>w({ref:null}):null,onJoinOfficial:p,creationOrigins:d?cA(f):[],onCreate:H=>It(new URL(Fp,H).toString()),onDeploy:()=>It(iA),hosting:d&&M?{onStart:()=>O({kind:"start"}),onOpenYourSpaces:()=>O({kind:"hosted"})}:null}),z=l?ee:[];pA(H=>w({ref:null,url:H}));const V=aA(z),ae=Il([...V.identityNodes,...V.nodes]),pe=ae.nodes.slice(0,V.identityNodes.length),Q=ae.nodes.slice(V.identityNodes.length),q=Me().data,ne=(q==null?void 0:q.serverRole)==="hub",ve=ne?"Private":V.teamName,se=q===void 0||!ne&&V.nameUnknown,Y=ne?vs:Hy,he=V.nameUnknown?"My DorkOS":V.teamName,ge=m!==void 0&&c.data===void 0,Ve=m===void 0?se:ge,Qe=m===void 0?ve:(g==null?void 0:g.label)??"Space",Re=s&&f.length>=8&&_.trim().length>0?f.filter(H=>H.label.toLocaleLowerCase().includes(_.trim().toLocaleLowerCase())):f;AA(H=>{y.current=H,T(!0)});function Xe(H){if(k())return;if(y.current=null,H==="installation"){R();return}const de=f.find(je=>`community:${je.ref}`===H);if(de){if(de.status==="connected"){E(de);return}I(),w({ref:de.ref})}}function te(H){T(H),H||D("")}function ye(H){if(ae.onCloseAutoFocus(H),v()){H.preventDefault();return}const de=y.current;y.current=null,!(H.defaultPrevented||!(de!=null&&de.isConnected))&&(H.preventDefault(),de.focus())}u.useEffect(()=>{if(!P)return;const H=requestAnimationFrame(()=>{var de;return(de=x.current)==null?void 0:de.focus()});return()=>cancelAnimationFrame(H)},[P]);async function we(H){var Je;const je=(Je=(await c.refetch()).data)==null?void 0:Je.find(Ze=>Ze.ref===H&&Ze.status==="connected");je&&await E(je)}function jt(H){ys(Pn().destination)===H.ref&&r({...Ne.home(),replace:!0})}return n.jsxs(n.Fragment,{children:[n.jsxs(Rl,{open:P,onOpenChange:te,children:[n.jsx(Tl,{asChild:!0,children:n.jsxs("button",{ref:b,type:"button","data-testid":"sidebar-header-block","aria-label":Ve?"Context menu":`${Qe} menu`,"aria-busy":C!==null||void 0,title:ne&&m===void 0?"Just you and your agents":void 0,className:e,children:[t?m===void 0?n.jsx(Y,{className:"size-(--size-icon-sm) shrink-0","aria-hidden":!0}):n.jsx(Pr,{className:"size-(--size-icon-sm) shrink-0","aria-hidden":!0}):Ve?n.jsx(mt,{className:"my-[3px] h-3.5 w-24 rounded-sm","data-testid":"sidebar-team-name-skeleton"}):n.jsxs(n.Fragment,{children:[ne&&m===void 0&&n.jsx(vs,{className:K(dn,"shrink-0"),"aria-hidden":!0}),n.jsx("span",{className:"truncate",children:Qe})]}),n.jsx(Zt,{className:K(t?"size-2.5":dn,"shrink-0 opacity-50"),"aria-hidden":!0}),n.jsx("span",{className:"sr-only",children:"Choose context"})]})}),n.jsxs(Dl,{align:"start",className:"max-h-(--radix-dropdown-menu-content-available-height) w-64 overflow-y-auto",onCloseAutoFocus:ye,children:[s&&n.jsx(Tr,{children:l?"Switch context":"Menu"}),n.jsx(Pi,{sheet:s,label:"You",children:n.jsx(Dr,{variant:s?"sheet":"dropdown",nodes:pe,onSheetClose:()=>te(!1)})}),l&&n.jsx(ja,{}),l&&!s&&n.jsx(Tr,{children:"Switch context"}),l&&s&&f.length>=8&&n.jsx("div",{className:"px-4 pb-2",children:n.jsx(yt,{type:"search",value:_,onChange:H=>D(H.target.value),placeholder:"Find a space","aria-label":"Find a space"})}),l&&n.jsxs(Lp,{value:m?`community:${m}`:"installation",onValueChange:Xe,children:[n.jsx(ka,{value:"installation",icon:Y,disabled:C!==null,itemRef:m===void 0?x:void 0,className:C!==null?"opacity-50":void 0,children:n.jsxs("span",{className:"min-w-0 flex-1 truncate",children:[ve,ne&&n.jsx("span",{className:"text-muted-foreground block truncate text-xs",children:"Just you and your agents"})]})}),Re.map(H=>{var Ie;const de=tm(H),je=de.mentionCount??0,Je=Math.max(0,(de.unreadCount??0)-je),Ze=[je>0?`${je} ${je===1?"mention":"mentions"}`:null,Je>0?`${Je} other unread`:null,((Ie=H.attention)==null?void 0:Ie.state)==="stale"?`last checked ${hA(Hn(H.attention.verifiedAt))}`:null].filter(Boolean).join(", ");return n.jsx(ka,{value:`community:${H.ref}`,icon:Pr,disabled:C!==null,itemRef:H.ref===m?x:void 0,description:[uA(H),Ze].filter(Boolean).join(" · ")||void 0,className:C!==null?"opacity-50":void 0,children:n.jsxs("span",{className:"flex min-w-0 items-center gap-1.5",children:[n.jsx("span",{className:"min-w-0 truncate",children:H.label}),ly(H)&&n.jsx("span",{role:"img",className:"bg-status-warning-dot size-2 shrink-0 rounded-full","aria-label":"Someone asked to take over this space",title:"Someone asked to take over this space"}),n.jsx(Us,{count:je,cap:as})]})},H.ref)})]}),Q.length>0&&n.jsxs(n.Fragment,{children:[n.jsx(ja,{}),n.jsx(Pi,{sheet:s,children:n.jsx(Dr,{variant:s?"sheet":"dropdown",nodes:Q,onSheetClose:()=>te(!1)})})]})]})]}),n.jsx(kA,{request:j,onOpenChange:H=>{H||w(null)},installName:he,onConnected:H=>void we(H)}),n.jsx(BS,{entry:M,dialog:B,onDialogChange:O,installName:he,onConnected:H=>void we(H)}),n.jsx(gA,{connection:N,onOpenChange:H=>{H||S(null)},onDisconnected:jt})]})}function EA(){return n.jsx(nm,{compact:!0,triggerClassName:K("hover:bg-foreground/7 data-[state=open]:bg-foreground/7 focus-ring text-foreground flex shrink-0 items-center rounded-md px-1 py-1.5 transition-colors duration-(--dur-fast)",Io)})}const IA="text-sidebar-foreground hover:bg-sidebar-accent/70 data-[state=open]:bg-sidebar-accent/70 focus-ring flex min-w-0 flex-1 items-center gap-1.5 rounded-md px-2 py-1 text-left text-control font-semibold transition-colors duration-(--dur-fast)";function sm(){return _e()?n.jsxs(Sa,{className:"flex-row items-center gap-2 px-2 pt-3 pb-1",children:[n.jsx(_i,{className:"min-w-0 flex-1"}),n.jsx(Mi,{})]}):n.jsxs(Sa,{className:"gap-2 px-2 pt-3 pb-1",children:[n.jsxs("div",{className:"flex items-center gap-1",children:[n.jsx(nm,{triggerClassName:IA}),n.jsx(Mi,{})]}),n.jsx(_i,{})]})}function RA(){const e=em("sm");return n.jsxs("div",{className:"space-y-1 pb-2",children:[e.you!==null&&n.jsx(Li,{leading:e.you.face,label:e.you.name,description:"View profile",onClick:e.you.onOpen}),n.jsx(Li,{leading:n.jsx(cd,{className:"text-muted-foreground size-7 p-0.5","aria-hidden":!0}),label:"DorkOS account",description:e.accountStatus,onClick:e.onOpenAccount})]})}function Li({leading:e,label:t,description:s,onClick:r}){return n.jsxs("button",{type:"button",onClick:r,className:K("hover:bg-sidebar-accent/70 active:bg-sidebar-accent focus-ring flex w-full items-center gap-3 rounded-md px-2 py-2 text-left transition-colors duration-(--dur-fast)",Io),children:[n.jsx("span",{className:"flex shrink-0",children:e}),n.jsxs("span",{className:"min-w-0 flex-1",children:[n.jsx("span",{className:"text-foreground block truncate text-sm font-medium",children:t}),s!==void 0&&n.jsx("span",{className:"text-muted-foreground block truncate text-xs",children:s})]}),n.jsx(gn,{className:K("text-muted-foreground shrink-0",dn),"aria-hidden":!0})]})}const TA=6e4;function DA(e){return e===null?!0:(e.selectionStart??0)===0&&(e.selectionEnd??0)===0}function OA(e,t,s){if(!e)return null;const r=t===null?s:[t,...s];for(const o of r){const{item:a}=o.item;if(a.type==="agent"&&Le(a.data)===e)return{kind:"agent",agent:a.data};if((a.type==="room"||a.type==="dm")&&a.id===e)return{kind:"room",room:a.data}}return null}function MA(){const{globalPaletteOpen:e,setGlobalPaletteOpen:t}=h0(),s=L(U=>U.openMessageSearch),[r,o]=u.useState(""),a=u.useRef(null),[i,c]=u.useState(""),d=u.useRef(null),[l,m]=u.useState([]),[h,p]=u.useState(null),[f,g]=u.useState(null),[x,y]=u.useState(null),b=l[l.length-1],[C,k]=u.useState(0),I=_e(),v=L(U=>U.globalPaletteInitialSearch),E=L(U=>U.clearGlobalPaletteInitialSearch),R=u.useCallback(()=>{t(!1),E(),o(""),c(""),m([]),p(null),y(null)},[t,E]),{handleAgentSelect:_,startNewSession:D,handleFeatureAction:P,handleQuickAction:T,handleRoomSelect:j,handleSessionSelect:w,handleCommandSelect:N,handlePageSelect:S,recordAgentOpened:M,selectedCwd:B}=wC(R),O=le(),$=u.useCallback(U=>{const ke=Bp(O,U.projectPath);return zp(ke?{session:ke}:{agentId:U.id})},[O]),G=u.useCallback(U=>{if(!Up()){_(U);return}Dn($(U),{target:"tab"}),M(U.projectPath),R()},[$,_,M,R]),ee=u.useCallback(U=>{Dn($(U),{target:"window"}),M(U.projectPath),R()},[$,M,R]),z=Kp(),V=bC(),ae=Ks(TA),{allAgents:pe,newActions:Q,rooms:q,sessions:ne,continueRows:ve,recent:se,searchableItems:Y}=m0(B,ae);Hp(pe);const{bestMatch:he,rows:ge,prefix:Ve,term:Qe}=gC(Y,r,{usage:V,now:ae,scope:x}),Re=Ve==="#",Xe=NC(Qe),te=Xe?{term:Xe,isScoped:x!==null,onSelect:()=>{R(),s(Xe)}}:null,ye=u.useMemo(()=>i?pe.find(U=>U.name===i)??null:null,[i,pe]),we=OA(i,he,ge),jt=u.useCallback(U=>{y(U),o(""),c("")},[]),Ge=!I&&ye!==null,H=u.useMemo(()=>{var U;return i?ne.find(ke=>ke.id===i)??((U=ve.find(ke=>ke.session.id===i))==null?void 0:U.session)??null:null},[i,ne,ve]),de=_u((h==null?void 0:h.id)??"",(h==null?void 0:h.projectPath)??""),je=u.useCallback(()=>{m(U=>U.slice(0,-1)),p(U=>l.length<=1?null:U),c("")},[l.length]),Je=u.useCallback(U=>{p(U),m(ke=>[...ke,"agent-actions"]),o(""),c(""),k(ke=>ke+1)},[]);u.useEffect(()=>{e&&v!=null&&(o(v),E(),requestAnimationFrame(()=>{const U=a.current;if(U){const ke=v.length;U.setSelectionRange(ke,ke)}}))},[e,v,E]);const Ze=u.useCallback(U=>{t(U),U?k(ke=>ke+1):(o(""),c(""),m([]),p(null),y(null))},[t]),Ie=SC({rootRef:d,activePage:b??"root",onPin:c,resetKey:JSON.stringify([e,b??null,r,x&&ju(x)])}),kt=!r&&x===null,_t=u.useId(),Pt=n.jsx(vt,{open:e,onOpenChange:Ze,children:n.jsx(wt,{className:K("!min-h-0 overflow-hidden p-0 transition-[max-width] duration-200","[&>button:last-child]:top-2 [&>button:last-child]:right-2.5",Ge?"max-w-[640px]":"max-w-[480px]",I&&"h-[85vh]"),children:n.jsxs(re.div,{variants:Bu,initial:"hidden",animate:"visible",exit:"exit",className:K("flex overflow-hidden",I&&"h-full flex-col"),children:[n.jsxs(Cd,{ref:d,loop:!0,shouldFilter:!1,value:i,onValueChange:c,onPointerMove:Ie.onPointerMove,className:K("min-w-0 flex-1",I&&"flex flex-col [&_[cmdk-list]]:max-h-none [&_[cmdk-list]]:flex-1 [&_[cmdk-list]]:overflow-y-auto"),onKeyDown:U=>{if(Ie.onKeyDown(U),U.key==="Enter"&&(U.metaKey||U.ctrlKey)&&!b&&(H==null?void 0:H.cwd)!=null){U.preventDefault(),D(H.cwd),R();return}if(U.key==="Enter"&&(U.metaKey||U.ctrlKey)&&!b&&ye){U.preventDefault(),G(ye);return}if(U.key==="Enter"&&(U.metaKey||U.ctrlKey)&&b==="agent-actions"&&h){U.preventDefault(),G(h);return}if(U.key==="Tab"&&!U.shiftKey&&!b&&we){U.preventDefault(),U.stopPropagation(),jt(we);return}if(U.key==="Backspace"&&x&&!b&&DA(a.current)){U.preventDefault(),y(null);return}U.key==="Backspace"&&!r&&l.length>0&&(U.preventDefault(),je()),U.key==="Escape"&&l.length>0&&(U.preventDefault(),U.stopPropagation(),je())},children:[l.length>0&&n.jsxs("div",{className:"text-muted-foreground flex items-center gap-1 border-b px-3 py-1.5 text-xs",children:[n.jsx("button",{onClick:()=>{m([]),p(null),k(U=>U+1)},className:"hover:text-foreground transition-colors",children:"All"}),n.jsx("span",{children:"/"}),n.jsxs("span",{children:["Agent: ",h==null?void 0:h.name]})]}),n.jsx(Nd,{ref:a,"data-testid":"command-palette-input",leading:x&&!b?n.jsx(CC,{scope:x}):void 0,placeholder:b==="agent-actions"?`${(h==null?void 0:h.name)??"Agent"} actions…`:x&&!b?"Search within…":"Search rooms, agents, commands…",value:r,onValueChange:o}),n.jsx(Ad,{children:n.jsxs(En,{className:"h-full",children:[n.jsxs(Sy,{children:[n.jsx("p",{children:"No results found."}),n.jsx(Pu,{className:"justify-center pb-0"})]}),n.jsx(Ye,{mode:"wait",initial:!1,children:n.jsxs(re.div,{"data-palette-page":b??"root",initial:{opacity:0,x:b?16:-16},animate:{opacity:1,x:0},exit:{opacity:0,x:b?-16:16},transition:{duration:.15,ease:"easeOut"},children:[!b&&n.jsx(KC,{staggerKey:C,isZeroQuery:kt,isRoomMode:Re,scope:x,hasQuery:Qe.length>0,selectedCwd:B,selectedValue:i,continueRows:ve,recent:se,newActions:Q,bestMatch:he,rows:ge,rooms:q,searchHandoff:te,onFeatureAction:P,onQuickAction:T,onGoToAgentActions:Je,onRoomSelect:j,onSessionSelect:U=>w(U.id,U.cwd),onCommandSelect:N,onPageSelect:S}),b==="agent-actions"&&h&&n.jsx(EC,{agent:h,onOpenHere:()=>_(h),onOpenNewTab:()=>G(h),onOpenNewWindow:z?()=>ee(h):void 0,onNewSession:()=>{D(h.projectPath),M(h.projectPath),R()},onEditSettings:()=>{Wp.getState().openProfileDocked(h.projectPath),R()},onBrowseSessions:de.sessionCount>0?()=>{g(h),M(h.projectPath),R()}:void 0,recentSessions:de.recentSessions,onSelectSession:U=>w(U,h.projectPath)})]},b??"root")})]})}),n.jsx(RC,{page:b,hasAgentSelected:Ge,canScope:!b&&we!==null,isScoped:x!==null})]}),n.jsx(Ye,{children:Ge&&ye&&n.jsx(AC,{agent:ye},ye.id)})]})})});return n.jsxs(n.Fragment,{children:[n.jsx(Nl,{id:_t,children:Pt}),f!==null&&n.jsx(Gp,{agentPath:f.projectPath,agentName:f.displayName??f.name,agentVisual:Bs(f),open:!0,onOpenChange:U=>{U||g(null)},onSelectSession:U=>w(U,f.projectPath),onNewSession:()=>D(f.projectPath)})]})}const _A="",PA="";function LA(e){const t=[];let s=e,r=!1;for(;s.length>0;){const o=r?PA:_A,a=s.indexOf(o);if(a===-1){t.push({text:s,matched:r});break}a>0&&t.push({text:s.slice(0,a),matched:r}),s=s.slice(a+o.length),r=!r}return t}function FA({excerpt:e,className:t}){const s=LA(e);return n.jsx("span",{className:t,children:s.map((r,o)=>r.matched?n.jsx("mark",{className:"text-foreground bg-transparent font-semibold",children:r.text},o):n.jsx("span",{children:r.text},o))})}const rm="rooms",$A=["claude-code","opencode"];function BA(e){if(e.source===rm)return{kind:"room",...Ne.channels(),search:{id:e.container,entry:e.ordinal}};if(e.sessionId===void 0)return{kind:"unopenable"};const t=e.messageId!==void 0&&$A.includes(e.source);return{kind:"session",...Rt({session:e.sessionId,dir:e.containerPath??void 0,...t?{message:e.messageId}:{}})}}function zA(e,t){return e.source===rm?t.get(e.container)??"Channel":e.containerPath===null?"Conversation":Pl(e.containerPath)}function UA(e){return e==="user"?"You":"Agent"}function KA({hit:e,containerLabel:t,value:s,onSelect:r,openable:o}){const a=e.source==="rooms"?Eo:Wy;return n.jsxs(Ae,{value:s,onSelect:r,className:"flex flex-col items-start gap-1 py-2",children:[n.jsxs("div",{className:"text-muted-foreground flex w-full min-w-0 items-center gap-1.5 text-xs",children:[n.jsx(a,{className:"size-3.5 shrink-0","aria-hidden":"true"}),n.jsx("span",{className:"min-w-0 truncate",children:t}),n.jsx("span",{"aria-hidden":"true",children:"·"}),n.jsx("span",{className:"shrink-0",children:UA(e.role)}),!o&&n.jsxs(n.Fragment,{children:[n.jsx("span",{"aria-hidden":"true",children:"·"}),n.jsx("span",{className:"shrink-0",children:"Ran outside DorkOS"})]}),e.createdAt!==null&&n.jsx("span",{className:"ml-auto shrink-0 tabular-nums",children:Hn(e.createdAt)})]}),n.jsx(FA,{excerpt:e.excerpt,className:"text-foreground line-clamp-2 w-full text-sm break-words"}),e.containerPath!==null&&n.jsx("span",{dir:"rtl",className:"text-muted-foreground/70 text-3xs w-full truncate text-left",children:n.jsx("bdi",{dir:"ltr",children:e.containerPath})})]})}const HA=["Your channels and direct messages, as soon as they’re posted.","DorkOS chats can lag five minutes.","Claude Code, Codex and OpenCode chats, even outside DorkOS. These can lag five minutes."],WA=["Tool output is never searched: no errors, stack traces, file contents or diffs.","Matches whole words: “ogs” won’t find “dogs”. Type “dog*” to match word starts."],GA="Searches channels, direct messages, and DorkOS, Claude Code, Codex and OpenCode chats. Not tool output.",qA=`Type at least ${Ll} letters to search.`,YA="Search what was said…";function VA({detailOpen:e=!1,className:t}){const[s,r]=u.useState(null),o=s??e,a=WA;return n.jsxs(Do,{open:o,onOpenChange:r,className:K("px-3 py-2",t),children:[n.jsxs(Oo,{className:K("text-muted-foreground/80 hover:text-foreground focus-ring text-2xs","flex w-full items-start gap-2 rounded-sm py-1 text-left leading-relaxed transition-colors"),children:[n.jsx("span",{className:"min-w-0 flex-1",children:GA}),n.jsx(Zt,{className:K("mt-0.5 size-3 shrink-0 transition-transform",!o&&"-rotate-90"),"aria-hidden":"true"})]}),n.jsx(Mo,{children:n.jsxs("ul",{className:"mt-2 space-y-1.5",children:[HA.map(i=>n.jsxs("li",{className:"text-muted-foreground flex gap-2 text-xs leading-relaxed",children:[n.jsx(Jt,{className:"text-brand mt-0.5 size-3.5 shrink-0","aria-hidden":"true"}),n.jsx("span",{children:i})]},i)),a.map(i=>n.jsxs("li",{className:"text-muted-foreground flex gap-2 text-xs leading-relaxed",children:[n.jsx(Qb,{className:"mt-0.5 size-3.5 shrink-0 opacity-60","aria-hidden":"true"}),n.jsx("span",{children:i})]},i))]})})]})}const QA=3e4,XA=e=>["message-search",e];function gr(e){return qp(e).some(t=>t.length>=Ll)}function JA(e,t){const s=ie(),r=ZA(e,Yp),o=t&&gr(e)&&gr(r),{data:a,isFetching:i,error:c}=Ee({queryKey:XA(r),queryFn:()=>s.search({q:r}),enabled:o,staleTime:QA,placeholderData:l=>l,retry:!1});return{submitted:o?r:"",tooShort:t&&r.trim().length>0&&!gr(r),results:o?(a==null?void 0:a.results)??[]:[],warnings:o?(a==null?void 0:a.warnings)??[]:[],isSearching:o&&i,error:o&&c instanceof Error?c:null}}function ZA(e,t){const[s,r]=u.useState(e);return u.useEffect(()=>{const o=setTimeout(()=>r(e),t);return()=>clearTimeout(o)},[e,t]),s}function e1(){const e=L(t=>t.toggleMessageSearch);u.useEffect(()=>{const t=s=>{(s.metaKey||s.ctrlKey)&&s.shiftKey&&s.code==="KeyF"&&(s.preventDefault(),e())};return document.addEventListener("keydown",t),()=>document.removeEventListener("keydown",t)},[e])}const xr="bg-muted rounded px-1 py-0.5 font-mono text-3xs";function t1(){e1();const e=L(v=>v.messageSearchOpen),t=L(v=>v.messageSearchQuery),s=L(v=>v.setMessageSearchOpen),r=_e(),o=Pe(),a=ie(),[i,c]=u.useState("");u.useEffect(()=>{e&&c(t??"")},[e,t]);const{results:d,warnings:l,tooShort:m,isSearching:h,error:p,submitted:f}=JA(i,e),{data:g}=Ls({includeArchived:!0}),x=u.useMemo(()=>{const v=new Map;for(const E of g??[])v.set(E.id,E.kind==="channel"&&E.slug?`#${E.slug}`:E.title);return v},[g]),y=u.useCallback(()=>s(!1),[s]),b=u.useCallback((v,E)=>{if(E.kind!=="unopenable"&&(y(),o({to:E.to,search:E.search}),E.kind==="session"&&v.containerPath!==null)){const R=v.containerPath;a.browseDirectory(R).catch(_=>{if((_==null?void 0:_.status)===404){ce.info("That folder is gone",{description:`${R} is gone, so nothing new can run there. You can still read it.`});return}ce.info("Couldn’t open that folder",{description:`DorkOS couldn’t read ${R}. The chat may not open.`})})}},[y,o,a]),C=d.length>0,k=!C&&!m&&!h&&f.trim().length>0&&p===null,I=!C&&!m&&f.trim().length>0&&p===null;return n.jsx(vt,{open:e,onOpenChange:s,children:n.jsxs(wt,{"data-testid":"message-search-dialog",className:K("!min-h-0 max-w-[560px] overflow-hidden p-0","[&>button:last-child]:top-2 [&>button:last-child]:right-2.5",r&&"h-[85vh]"),children:[n.jsx(ot,{className:"sr-only",children:"Search your messages"}),n.jsx(re.div,{variants:Bu,initial:"hidden",animate:"visible",exit:"exit",className:K("flex overflow-hidden",r&&"h-full flex-col"),children:n.jsxs(Cd,{loop:!0,shouldFilter:!1,className:K("min-w-0 flex-1",r&&"flex flex-col [&_[cmdk-list]]:max-h-none [&_[cmdk-list]]:flex-1 [&_[cmdk-list]]:overflow-y-auto"),children:[n.jsx(Nd,{"data-testid":"message-search-input",placeholder:YA,value:i,onValueChange:c}),p!==null&&n.jsxs("p",{className:"text-destructive flex items-start gap-2 px-3 py-3 text-xs leading-relaxed",children:[n.jsx(bl,{className:"mt-0.5 size-3.5 shrink-0","aria-hidden":"true"}),n.jsx("span",{children:p.message})]}),l.map(v=>n.jsxs("p",{role:"status",className:"text-muted-foreground text-2xs flex items-start gap-2 px-3 pt-2 leading-relaxed",children:[n.jsx(gc,{className:"mt-0.5 size-3 shrink-0","aria-hidden":"true"}),n.jsx("span",{children:v.message})]},v.source)),n.jsx(Ad,{children:n.jsx(En,{className:"h-full",children:C&&n.jsx(st,{className:K("transition-opacity duration-150",h&&"opacity-60"),children:d.map(v=>{const E=`${v.source}:${v.container}:${v.ordinal}`,R=BA(v);return n.jsx(KA,{value:E,hit:v,containerLabel:zA(v,x),openable:R.kind!=="unopenable",onSelect:()=>b(v,R)},E)})})})}),p===null&&n.jsxs("div",{className:"max-h-[45vh] min-h-0 shrink-0 overflow-y-auto",children:[m&&n.jsx("p",{className:"text-muted-foreground px-3 pt-3 text-xs",children:qA}),k&&n.jsxs("p",{className:"text-muted-foreground px-3 pt-3 text-xs",children:["No messages match “",f.trim(),"”."]}),n.jsx(VA,{detailOpen:I})]}),n.jsxs("div",{className:"text-muted-foreground flex flex-shrink-0 items-center gap-3 border-t px-3 py-1.5 text-xs",children:[n.jsxs("span",{className:"inline-flex items-center gap-1",children:[n.jsx("kbd",{className:xr,children:"↑↓"}),"Navigate"]}),n.jsxs("span",{className:"inline-flex items-center gap-1",children:[n.jsx("kbd",{className:xr,children:"Enter"}),"Open"]}),n.jsxs("span",{className:"ml-auto inline-flex items-center gap-1",children:[n.jsx("kbd",{className:xr,children:"esc"}),"Close"]})]})]})})]})})}function n1(e){return`set${e.charAt(0).toUpperCase()}${e.slice(1)}`}function s1(e){const t=ct(),s=wo(),r=Ro();switch(e){case"settings":return{isOpen:t.isOpen,close:t.close};case"tasks":return{isOpen:s.isOpen,close:s.close};case"profile":return{isOpen:r.isOpen,close:r.close};default:return{isOpen:!1,close:()=>{}}}}function r1({contribution:e,openStateKey:t}){const s=L(m=>m[t]),r=L(m=>m[n1(t)]),o=s1(e.urlParam),a=o.isOpen,i=o.close,c=s||a,d=u.useCallback(m=>{r(m),!m&&a&&i()},[r,a,i]),l=e.component;return n.jsx(l,{open:c,onOpenChange:d})}function o1({contribution:e,openState:t}){const s=u.useSyncExternalStore(t.subscribe,t.getSnapshot),r=e.component;return s?n.jsx(Vp,{fallback:null,onError:o=>{console.error(`[extensions] Dialog ${e.id} crashed and was closed:`,o),t.set(!1)},children:n.jsx(r,{open:!0,onOpenChange:t.set})}):null}function a1({contribution:e}){return e.openState?n.jsx(o1,{contribution:e,openState:e.openState}):n.jsx(r1,{contribution:e,openStateKey:e.openStateKey})}function i1(){const e=_s("dialog");return n.jsx(n.Fragment,{children:e.map(t=>n.jsx(a1,{contribution:t},t.id))})}const c1=["session","id","thread","entry","itemId","agent","profile","continuedFrom","pkg","view","region","detail","panel"];function l1(e,t){if(e.length>=er)return e.slice(0,er);const s=new URLSearchParams(t);let r="";for(const o of c1)for(const a of s.getAll(o)){const i=new URLSearchParams([[o,a]]).toString(),c=r?`${r}&${i}`:i;e.length+1+c.length<=er&&(r=c)}return r?`${e}?${r}`:e}const d1=6e4,u1={bug:"when it’s fixed",idea:"when it ships",feedback:"when the team acts on it"};function m1(e,t){var s;return JSON.stringify([e.kind,t,e.screenshotDataUrl??null,((s=e.element)==null?void 0:s.selector)??null])}function Fi(e,t,s,r){const o=Kd("bug",e,t),a=[...eg()];r&&a.push({at:new Date().toISOString(),kind:"console_error",message:Jp(r).slice(0,Zp)});const i=a.slice(-tg);return{clientReport:{version:o.version,platform:o.platform,runtimes:o.runtimes,flags:Object.fromEntries(Object.entries(o.flags).map(([c,d])=>[c,typeof d=="number"?String(d):d])),...Uv(s)},...i.length>0?{breadcrumbs:i}:{}}}function h1(){const e=ie(),t=De({select:b=>b.location.pathname}),s=De({select:b=>b.location.searchStr}),r=Qp(),o=l1(t,s),a=De({select:b=>{const C=b.location.search;return typeof(C==null?void 0:C.session)=="string"?C.session:void 0}}),i=De({select:b=>{if(b.location.pathname!=="/channels")return;const C=b.location.search;return typeof(C==null?void 0:C.id)=="string"?C.id:void 0}}),c=Xp(),d=t==="/"&&c.status==="ready"?c.room.id:void 0,l=a?void 0:i??d,{data:m}=Ee({queryKey:Fe.current(),queryFn:()=>e.getConfig(),staleTime:300*1e3}),[h,p]=u.useState(!1),f=Pe(),g=u.useRef(null),x=u.useCallback(b=>m?Fi(m,t,r,b==null?void 0:b.crashStack):void 0,[m,t,r]),y=u.useCallback(async b=>{var P;const C=b.message.trim();if(!C)return!1;const k=(P=b.contact)==null?void 0:P.trim(),I=m1(b,C),v=g.current;if(v&&v.fingerprint===I&&Date.now()-v.at<d1)return ce.info("Already sent a moment ago."),!0;const E=b.includeDiagnostics?Fi(m,t,r,b.crashStack):void 0,R=b.includeDiagnostics&&b.kind==="bug",_=!!(b.includeConversation&&a),D=!!(b.includeConversation&&l);p(!0);try{const T=E&&R?await Tv():void 0,{ok:j}=await e.sendFeedback({kind:b.kind,message:C,...k?{contact:k}:{},...o?{route:o}:{},...E?{diagnostics:{...E,...T?{shellLogExcerpt:T}:{}}}:{},...R?{includeServerLogs:!0}:{},..._?{sessionId:a,includeTranscript:!0}:{},...D?{roomId:l,includeTranscript:!0,...b.roomThroughSeq?{roomThroughSeq:b.roomThroughSeq}:{}}:{},...b.screenshotDataUrl?{screenshot:{dataUrl:b.screenshotDataUrl}}:{},...b.anonymous?{anonymous:!0}:{},...b.element?{element:b.element}:{}});return j?(g.current={fingerprint:I,at:Date.now()},ce.success("Sent. Thank you.",{...b.notifyEmail?{description:`DorkOS emails ${b.notifyEmail} ${u1[b.kind]}.`}:{},action:{label:"Your reports",onClick:()=>f(Ne.feedbackRequests())}})):ce.error("Couldn’t send. Your words are still here. Try again or open a GitHub issue."),j}finally{p(!1)}},[e,t,o,a,l,m,r,f]);return{isSubmitting:h,sessionId:a,roomId:l,route:o,buildDiagnostics:x,send:y}}const $i=500;function Bi(e){const t=e.trim();return t.length>$i?`${t.slice(0,$i)}… [trimmed]`:t}function f1(e){const t=[`${e.role}: ${e.content.trim()}`.trim()];for(const s of e.toolCalls??[])t.push(` [tool: ${s.toolName}]`),s.input&&t.push(` input: ${Bi(s.input)}`),s.result&&t.push(` result: ${Bi(s.result)}`);return t.join(`
74
- `)}function p1(e){const t=e.slice(-20),s=ng(sg(t.map(f1).join(`
75
-
76
- `))).trim();return s.length>Ca?`${s.slice(0,Ca-1)}…`:s}function g1(e,t){const s=ie(),[r]=Fs(),{data:o,isLoading:a,isError:i}=Ee({queryKey:["feedback-transcript-preview",e,r],queryFn:async()=>{const{messages:c}=await s.getMessages(e,r??void 0);return p1(c)},enabled:t&&!!e,staleTime:30*1e3});return{text:o??"",isLoading:a,isError:i}}function om(e,t){const s=ie(),{data:r,isLoading:o,isError:a}=Ee({queryKey:["feedback-room-transcript-preview",e],queryFn:()=>s.previewRoomTranscript(e),enabled:t&&!!e,staleTime:30*1e3});return{text:(r==null?void 0:r.text)??"",throughSeq:(r==null?void 0:r.throughSeq)??void 0,isLoading:o,isError:a}}const x1=24;function zi(e,t){const s=Math.max(e.left,t.left),r=Math.max(e.top,t.top),o=Math.min(e.left+e.width,t.left+t.width),a=Math.min(e.top+e.height,t.top+t.height);return o<=s||a<=r?null:{left:s,top:r,width:o-s,height:a-r}}function b1(e){const{element:t,viewport:s,region:r,image:o}=e,a=e.padding??x1;if(o.width<=0||o.height<=0)return null;const i={left:t.left-a,top:t.top-a,width:t.width+a*2,height:t.height+a*2},c=zi(i,{left:0,top:0,width:s.width,height:s.height});if(!c)return null;const d=zi(c,r);if(!d)return null;const l=o.width/r.width,m=o.height/r.height,h=Math.round((d.left-r.left)*l),p=Math.round((d.top-r.top)*m),f=Math.round((d.left+d.width-r.left)*l),g=Math.round((d.top+d.height-r.top)*m),x=Math.min(Math.max(0,h),Math.max(0,o.width-1)),y=Math.min(Math.max(0,p),Math.max(0,o.height-1));return{sx:x,sy:y,sw:Math.max(1,f-x),sh:Math.max(1,g-y)}}function y1(e){return new Promise((t,s)=>{const r=new Image,o=i=>{clearTimeout(a),s(new it("failed",i))},a=setTimeout(()=>o(`The capture did not decode within ${ks}ms.`),ks);r.onload=()=>{clearTimeout(a),t(r)},r.onerror=()=>o("The capture did not decode, so it cannot be cropped."),r.src=e})}function v1(e,t){const s=document.createElement("canvas");s.width=t.sw,s.height=t.sh;const r=s.getContext("2d");if(!r)throw new it("failed","This browser gave no 2d canvas context to crop with.");return r.drawImage(e,t.sx,t.sy,t.sw,t.sh,0,0,t.sw,t.sh),s.toDataURL("image/png")}async function w1(e,t){const s=t.getBoundingClientRect();if(s.width===0&&s.height===0)throw new it("failed","That element has no size to crop to.");if(!Gd().contains(t))throw new it("failed","That element is not part of the app that was captured.");const r=await y1(e.dataUrl),o=b1({element:{left:s.left,top:s.top,width:s.width,height:s.height},viewport:{width:window.innerWidth,height:window.innerHeight},region:e.region,image:{width:r.naturalWidth||r.width,height:r.naturalHeight||r.height}});if(!o)throw new it("failed","That element is no longer inside the captured picture.");return Fr(v1(r,o))}const Ui={"too-large":"That image is too big to send. Crop it to the part that matters.",unreadable:"Couldn’t read that image. Try a PNG or JPEG.",unsupported:"This browser can’t prepare images to send."},j1={failed:"Couldn’t capture the app view. You can still add a screenshot yourself.",unsupported:"Couldn’t start the app capture. Reload, or add a screenshot yourself."};function k1(e){return e instanceof it?j1[e.reason]:e instanceof Yt?Ui[e.reason]:Ui.unreadable}const br="Only images can be attached.",S1="Files";function Nn(e){return e?Array.from(e.types).includes(S1):!1}function Ki(e){return e.find(t=>t.type.startsWith("image/"))}function C1(e={}){const{enabled:t=!1}=e,[s,r]=u.useState(null),[o,a]=u.useState(!1),[i,c]=u.useState(!1),d=u.useRef(0),l=u.useRef(0),m=u.useCallback(async v=>{const E=++l.current;a(!0);try{const R=await v();return E!==l.current?null:(r(R),R)}catch(R){return E!==l.current||ce.error(k1(R)),null}finally{E===l.current&&a(!1)}},[]),h=u.useCallback(async v=>{if(!v.type.startsWith("image/")){ce.error(br);return}await m(()=>Fr(v))},[m]),p=u.useCallback(async()=>{await m(async()=>Fr(await $v()))},[m]),f=u.useCallback(v=>m(async()=>w1(await qd(),v)),[m]),g=u.useCallback(()=>{l.current+=1,r(null),a(!1)},[]),x=u.useCallback(v=>{l.current+=1,d.current=0,v!==void 0&&!Vv(v)?(console.warn("[feedback] Ignoring an initial screenshot that is not a bounded image data URL."),r(null)):r(v??null),a(!1),c(!1)},[]);u.useEffect(()=>{if(!t)return;const v=E=>{Nn(E.dataTransfer)&&E.preventDefault()};return window.addEventListener("dragover",v),window.addEventListener("drop",v),()=>{window.removeEventListener("dragover",v),window.removeEventListener("drop",v)}},[t]);const y=u.useCallback(v=>{var _;const E=Array.from(((_=v.clipboardData)==null?void 0:_.items)??[]).map(D=>D.getAsFile()).filter(D=>D!==null);if(E.length===0)return;const R=Ki(E);if(!R){ce.error(br);return}v.preventDefault(),h(R)},[h]),b=u.useCallback(v=>{Nn(v.dataTransfer)&&(v.preventDefault(),d.current+=1,c(!0))},[]),C=u.useCallback(v=>{Nn(v.dataTransfer)&&(v.preventDefault(),v.dataTransfer.dropEffect="copy")},[]),k=u.useCallback(v=>{Nn(v.dataTransfer)&&(d.current=Math.max(0,d.current-1),d.current===0&&c(!1))},[]),I=u.useCallback(v=>{if(!Nn(v.dataTransfer))return;v.preventDefault(),d.current=0,c(!1);const E=Ki(Array.from(v.dataTransfer.files));if(!E){ce.error(br);return}h(E)},[h]);return{dataUrl:s,isPreparing:o,isDraggingOver:i,attach:h,capture:p,captureElement:f,clear:g,reset:x,handlers:{onPaste:y,onDragEnter:b,onDragOver:C,onDragLeave:k,onDrop:I}}}const Hi=ag,N1="root";function am(e){return typeof CSS<"u"&&typeof CSS.escape=="function"?CSS.escape(e):e.replace(/["'\\[\]]/g,t=>`\\${t}`)}function Wi(e,t){try{const s=t.ownerDocument.querySelectorAll(e);return s.length===1&&s[0]===t}catch{return!1}}function im(e){return e.id?`#${am(e.id)}`:null}function eo(e,t){const s=e.getAttribute(t);return s?`[${t}="${am(s)}"]`:null}function A1(e){const t=e.tagName;let s=1,r=e.previousElementSibling;for(;r;)r.tagName===t&&(s+=1),r=r.previousElementSibling;return s}function E1(e){const t=e.tagName.toLowerCase(),s=im(e);if(s)return s;const r=eo(e,"data-testid")??eo(e,"data-slot"),o=`:nth-of-type(${A1(e)})`;if(!r)return`${t}${o}`;const a=`${t}${r}`;return(e.parentElement?Array.from(e.parentElement.children).filter(c=>c.matches(a)):[e]).length===1?a:`${a}${o}`}function I1(e){for(const r of[im(e),eo(e,"data-testid")])if(r&&r.length<=Hi&&Wi(r,e))return r;const t=[];let s=e;for(;s&&s.id!==N1&&s.tagName!=="BODY";){t.unshift(E1(s));const r=t.join(" > ");if(r.length>Hi){t.shift();break}if(Wi(r,e))return r;s=s.parentElement}return t.join(" > ")||e.tagName.toLowerCase()}function Gi(e,t){var r;const s=(r=e.closest(`[${t}]`))==null?void 0:r.getAttribute(t);if(!(!s||s.length>rg))return s}const R1=8;function cm(e,t){const s=(t==null?void 0:t.closest("[data-testid]"))??null;if(!s||s===e)return s;const r=e.getBoundingClientRect().height;return r<=0||s.getBoundingClientRect().height<=r*R1?s:null}function T1(e){const t=Gi(e,"data-slot"),s=cm(e,e),r=s?Gi(s,"data-testid"):void 0,o=lm(e);return{selector:I1(e),...t?{slot:t}:{},...r?{testId:r}:{},...o?{label:o}:{}}}const yr=40,D1=["button","a[href]","summary","input","select","textarea",'[role="button"]','[role="link"]','[role="menuitem"]','[role="tab"]','[role="option"]','[role="checkbox"]','[role="switch"]'].join(", "),O1=new Set(["INPUT","SELECT","TEXTAREA"]),M1=['[contenteditable]:not([contenteditable="false"])','[role="textbox"]','[role="searchbox"]','[role="combobox"]'].join(", "),_1=["h1","h2","h3","h4","h5","h6",'[role="heading"]',"label","legend","th","dt"].join(", ");function P1(e){if(typeof Intl<"u"&&"Segmenter"in Intl){const t=new Intl.Segmenter(void 0,{granularity:"grapheme"});return Array.from(t.segment(e),s=>s.segment)}return Array.from(e)}function Tn(e){const t=(e??"").replace(/\s+/g," ").trim();if(!t)return;const s=P1(t);if(s.length<=yr)return t;const r=s.slice(0,yr-1),o=r.lastIndexOf(" ");return`${(o>yr/2?r.slice(0,o):r).join("").trimEnd()}…`}function L1(e){var r;const s=(((r=e.getAttribute("aria-labelledby"))==null?void 0:r.split(/\s+/).filter(Boolean))??[]).map(o=>{var a;return((a=e.ownerDocument.getElementById(o))==null?void 0:a.textContent)??""}).join(" ");return Tn(s)}function ss(e){return Tn(e.getAttribute("aria-label"))??L1(e)}function lm(e){const t=F1(e);return t&&t.length<=og?t:void 0}function F1(e){var a,i;const t=e.closest(M1);if(t)return ss(t);const s=e.closest(D1);if(s){if(O1.has(s.tagName)){const c=s;return ss(s)??Tn((i=(a=c.labels)==null?void 0:a[0])==null?void 0:i.textContent)}return ss(s)??Tn(s.textContent)}const r=ss(e);if(r)return r;const o=e.closest(_1);return o?Tn(o.textContent):void 0}function qi(e){const t=e.replace(/([a-z0-9])([A-Z])/g,"$1 $2").split(/[-_\s]+/).filter(Boolean).map(r=>r.toLowerCase());if(t.length===0)return null;const s=t.join(" ");return s.charAt(0).toUpperCase()+s.slice(1)}function $1(e){var d;const t=lm(e);if(t)return{text:t,onScreen:!0};const s=e.getAttribute("data-testid")??e.getAttribute("data-slot"),r=s?qi(s):null;if(r)return{text:r,onScreen:!1};const o=(d=e.parentElement)==null?void 0:d.closest("[data-testid], [data-slot]"),i=(o&&cm(e,o)===o?o.getAttribute("data-testid"):null)??(o==null?void 0:o.getAttribute("data-slot")),c=i?qi(i):null;return c?{text:c,onScreen:!1}:null}const B1="This part";function dm(e){return(e==null?void 0:e.text)??B1}function z1(e){return e?e.onScreen?`What’s wrong with “${e.text}”?`:`What’s wrong with the ${e.text.toLowerCase()}?`:"What’s wrong with this part?"}function U1(e){return e!=null&&e.onScreen?`Remove “${e.text}”`:`Remove ${dm(e).toLowerCase()}`}function K1(){return n.jsx("div",{"data-slot":"feedback-preview-footer",className:"bg-background relative -mx-4 -mb-4 shrink-0 border-t px-4 py-3 sm:mx-0 sm:px-0",children:n.jsxs("p",{className:"text-muted-foreground flex items-center gap-1.5 text-xs",children:[n.jsx(vs,{className:"size-3 shrink-0","aria-hidden":!0}),"Private. Only the DorkOS team sees these. Never public."]})})}function tt({label:e,value:t}){return n.jsxs("div",{className:"flex items-baseline justify-between gap-4 py-1",children:[n.jsx("span",{className:"text-muted-foreground shrink-0 text-xs",children:e}),n.jsx("span",{className:"text-foreground text-right font-mono text-xs break-all",children:t})]})}function H1({diagnostics:e,kind:t,route:s}){if(!e)return n.jsx("p",{className:"text-muted-foreground text-xs",children:"Gathering diagnostics…"});const{clientReport:r,breadcrumbs:o}=e,{viewport:a,browser:i,shell:c,theme:d,locale:l,timezone:m}=r;return n.jsxs("div",{className:"flex flex-col gap-3",children:[n.jsxs("div",{className:"rounded-md border p-3",children:[n.jsx(tt,{label:"Page",value:s}),n.jsx(tt,{label:"Version",value:r.version}),n.jsx(tt,{label:"Platform",value:r.platform}),n.jsx(tt,{label:"Runtimes",value:r.runtimes.length?r.runtimes.join(", "):"none"}),a&&n.jsx(tt,{label:"Window",value:`${a.width}×${a.height}${a.devicePixelRatio&&a.devicePixelRatio!==1?` @${a.devicePixelRatio}x`:""}`}),c&&n.jsx(tt,{label:"Shell",value:c}),d&&n.jsx(tt,{label:"Theme",value:d}),l&&n.jsx(tt,{label:"Locale",value:l}),m&&n.jsx(tt,{label:"Timezone",value:m}),i&&n.jsx(tt,{label:"Browser",value:i}),Object.entries(r.flags).map(([h,p])=>n.jsx(tt,{label:h,value:String(p)},h))]}),n.jsxs("div",{className:"flex flex-col gap-1.5",children:[n.jsxs("span",{className:"text-muted-foreground text-xs font-medium",children:["Recent events (",(o==null?void 0:o.length)??0,")"]}),o&&o.length>0?n.jsx("ul",{className:"flex flex-col gap-1",children:o.map((h,p)=>n.jsxs("li",{className:"text-foreground font-mono text-xs break-all",children:[n.jsx("span",{className:"text-muted-foreground",children:h.kind})," ",h.message]},p))}):n.jsx("p",{className:"text-muted-foreground text-xs",children:"No recent errors or warnings."})]}),t==="bug"&&n.jsxs("div",{className:"text-muted-foreground space-y-1 text-xs",children:[n.jsx("p",{children:$e()?"Recent server and app log excerpts are added when you send.":"An excerpt of recent server logs is added when you send."}),n.jsx("p",{children:"Scrubbed first: home paths shown as ~, tokens removed, web addresses cut to the page."})]})]})}function W1({sessionId:e,active:t}){const{text:s,isLoading:r,isError:o}=g1(e,t);return r?n.jsxs("div",{className:"flex flex-col gap-2",children:[n.jsx(mt,{className:"h-4 w-3/4"}),n.jsx(mt,{className:"h-4 w-full"}),n.jsx(mt,{className:"h-4 w-2/3"})]}):o?n.jsx("p",{className:"text-muted-foreground text-xs",children:"Couldn’t load the chat preview."}):s?n.jsxs("div",{className:"flex flex-col gap-2",children:[n.jsxs("div",{className:"text-muted-foreground space-y-1 text-xs",children:[n.jsx("p",{children:"The last ~10 turns, gathered and scrubbed when you send."}),n.jsx("p",{children:"Home paths shown as ~, tokens removed, long tool output trimmed."})]}),n.jsx("pre",{className:"text-foreground bg-muted/40 rounded-md p-3 font-mono text-xs break-words whitespace-pre-wrap",children:s})]}):n.jsx("p",{className:"text-muted-foreground text-xs",children:"No recent chat to attach."})}function G1({roomId:e,active:t}){const{text:s,isLoading:r,isError:o}=om(e,t);return r?n.jsxs("div",{className:"flex flex-col gap-2",children:[n.jsx(mt,{className:"h-4 w-3/4"}),n.jsx(mt,{className:"h-4 w-full"}),n.jsx(mt,{className:"h-4 w-2/3"})]}):o?n.jsx("p",{className:"text-muted-foreground text-xs",children:"Couldn’t load the room preview."}):s?n.jsxs("div",{className:"flex flex-col gap-2",children:[n.jsxs("div",{className:"text-muted-foreground space-y-1 text-xs",children:[n.jsxs("p",{children:["The last ",Fl," messages in this room, without threads."]}),n.jsx("p",{children:"Home paths shown as ~, tokens removed, file names left out."})]}),n.jsx("pre",{className:"text-foreground bg-muted/40 rounded-md p-3 font-mono text-xs break-words whitespace-pre-wrap",children:s})]}):n.jsx("p",{className:"text-muted-foreground text-xs",children:"No recent messages to attach."})}function q1({dataUrl:e}){return n.jsxs("div",{className:"flex flex-col gap-2",children:[n.jsx("p",{className:"text-muted-foreground text-xs",children:"Sent exactly as shown, shrunk to keep the message small."}),n.jsx("img",{src:e,alt:"The screenshot you attached",className:"bg-muted/30 w-full rounded-md border object-contain"})]})}function Y1({open:e,onOpenChange:t,initialTab:s,diagnostics:r,kind:o,route:a,showConversation:i,sessionId:c,roomId:d,screenshotDataUrl:l}){const m=!_e(),h=["diagnostics",...i?["conversation"]:[],...l?["screenshot"]:[]],p=h.includes(s)?s:"diagnostics";return n.jsx(vt,{open:e,onOpenChange:t,children:n.jsxs(wt,{className:K("max-h-[85vh]",m&&"max-w-lg"),children:[n.jsxs(gt,{children:[n.jsx(ot,{className:"text-sm font-medium",children:"What will be sent"}),n.jsx(xt,{className:"text-muted-foreground text-xs",children:"Each part is sent only if its toggle is on."})]}),n.jsxs(ud,{defaultValue:p,className:"flex min-h-0 flex-col gap-3 px-4 pb-4 sm:px-0",children:[n.jsxs(md,{className:K("grid shrink-0",h.length===3&&"grid-cols-3",h.length===2&&"grid-cols-2",h.length===1&&"grid-cols-1"),children:[n.jsx(is,{value:"diagnostics",children:"Diagnostics"}),i&&n.jsx(is,{value:"conversation",children:d?"Room":"Chat"}),l&&n.jsx(is,{value:"screenshot",children:"Screenshot"})]}),n.jsx(sr,{value:"diagnostics",className:"min-h-0",children:n.jsx(En,{className:"max-h-[45vh]",children:n.jsx(H1,{diagnostics:r,kind:o,route:a})})}),i&&n.jsx(sr,{value:"conversation",className:"min-h-0",children:n.jsx(En,{className:"max-h-[45vh]",children:d?n.jsx(G1,{roomId:d,active:e}):n.jsx(W1,{sessionId:c,active:e})})}),l&&n.jsx(sr,{value:"screenshot",className:"min-h-0",children:n.jsx(En,{className:"max-h-[45vh]",children:n.jsx(q1,{dataUrl:l})})}),n.jsx(K1,{})]},p)]})})}const V1="0 0 0 9999px var(--scrim)";function Q1(e){var r,o;const t=(r=e.closest("[data-slot]"))==null?void 0:r.getAttribute("data-slot");return((o=e.closest("[data-testid]"))==null?void 0:o.getAttribute("data-testid"))??t??e.tagName.toLowerCase()}function X1(e){let t=e;for(;t;){if(/^(auto|scroll|overlay)$/.test(getComputedStyle(t).overflowY)&&t.scrollHeight>t.clientHeight)return t;t=t.parentElement}return null}function J1({phase:e,onSelect:t,onCancel:s}){const r=u.useRef(null),o=u.useRef(null),[a,i]=u.useState(null),c=e==="picking",d=u.useCallback((x,y)=>{const b=r.current;if(!b)return null;const C=b.style.pointerEvents;b.style.pointerEvents="none";try{return document.elementFromPoint(x,y)}finally{b.style.pointerEvents=C}},[]),l=u.useCallback(x=>{var y;return x instanceof Node&&!!((y=o.current)!=null&&y.contains(x))},[]),m=u.useCallback(x=>{if(!c)return;if(l(x.target)){i(null);return}const y=d(x.clientX,x.clientY);if(!y){i(null);return}const b=y.getBoundingClientRect();i({element:y,box:{left:b.left,top:b.top,width:b.width,height:b.height},label:Q1(y)})},[c,d,l]),h=u.useCallback(x=>{if(!c||l(x.target))return;const y=d(x.clientX,x.clientY)??(a==null?void 0:a.element);y&&t(y)},[c,d,l,t,a]),p=u.useCallback(x=>{if(!c)return;const y=X1(d(x.clientX,x.clientY));y==null||y.scrollBy({left:x.deltaX,top:x.deltaY})},[c,d]);u.useEffect(()=>{if(!c)return;const x=y=>{y.preventDefault(),y.stopImmediatePropagation(),y.key==="Escape"&&s()};return window.addEventListener("keydown",x,!0),()=>window.removeEventListener("keydown",x,!0)},[c,s]),u.useEffect(()=>{var y;const x=document.activeElement;return(y=r.current)==null||y.focus(),()=>{x instanceof HTMLElement&&x.focus()}},[]),u.useEffect(()=>{if(!c)return;const x=()=>{i(y=>{if(!y)return y;const b=y.element.getBoundingClientRect();return{...y,box:{left:b.left,top:b.top,width:b.width,height:b.height}}})};return window.addEventListener("scroll",x,!0),()=>window.removeEventListener("scroll",x,!0)},[c]);const f=c?a:null,g=f!==null&&f.box.top<28;return Es.createPortal(n.jsxs("div",{ref:r,role:"dialog","aria-modal":"true","aria-label":"Point at the part of the app that looks wrong",tabIndex:-1,className:K("fixed inset-0 z-50 focus:outline-none",c?"cursor-crosshair":"cursor-wait"),onPointerMove:m,onPointerLeave:()=>i(null),onClick:h,onWheel:p,onContextMenu:x=>{x.preventDefault(),c&&s()},children:[c&&(f?n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"border-primary pointer-events-none absolute rounded-sm border-2",style:{left:f.box.left,top:f.box.top,width:f.box.width,height:f.box.height,boxShadow:V1}}),n.jsx("div",{className:"bg-primary text-primary-foreground text-2xs pointer-events-none absolute max-w-[60vw] truncate rounded-sm px-1.5 py-0.5 font-mono leading-tight",style:{left:Math.max(4,f.box.left),top:g?f.box.top+f.box.height+4:f.box.top-22},children:f.label})]}):n.jsx("div",{className:"bg-scrim absolute inset-0"})),c&&n.jsxs("div",{ref:o,className:"bg-popover text-popover-foreground absolute bottom-6 left-1/2 flex -translate-x-1/2 items-center gap-3 rounded-lg border px-3 py-2 shadow-lg",children:[n.jsxs("span",{className:"flex items-center gap-2 text-xs",children:[n.jsx(js,{className:"size-3.5 shrink-0","aria-hidden":!0}),"Click the part that looks wrong. Esc to cancel."]}),n.jsx("button",{type:"button",onClick:s,className:"text-muted-foreground hover:text-foreground focus-visible:ring-ring rounded-sm text-xs underline underline-offset-2 transition-colors duration-150 focus-visible:ring-2 focus-visible:outline-none",children:"Cancel"})]})]}),document.body)}const Yi="text-muted-foreground hover:text-foreground h-8 px-2 text-xs aria-disabled:pointer-events-none aria-disabled:opacity-50";function vr({tip:e,children:t}){return n.jsxs(xn,{children:[n.jsx(bn,{asChild:!0,children:t}),n.jsx(yn,{className:"max-w-60 text-center",children:e})]})}function Z1({showPictureTools:e,isPreparing:t,hasPointed:s,hasWords:r,isMobile:o,onCapture:a,onPointAtElement:i,onPick:c}){const d=u.useId(),l=u.useId(),m=u.useId(),h=u.useId();function p(C){var I;const k=(I=C.target.files)==null?void 0:I[0];C.target.value="",k&&c(k)}const f=r&&!o;if(!e&&!f)return null;const g=o?"Add a photo":"Add an image",x=o?"Add a photo from your library.":"Add an image from your files, or paste or drop one here.",y="Take a picture of this app. Never the rest of your screen.",b="Click the part that looks wrong. DorkOS crops the picture to it.";return n.jsxs("div",{className:"flex flex-wrap items-center gap-1 border-t px-1.5 py-1.5",children:[e&&n.jsxs(n.Fragment,{children:[n.jsx("span",{id:l,className:"sr-only",children:y}),n.jsx(vr,{tip:y,children:n.jsxs(F,{"aria-describedby":l,type:"button",variant:"ghost",size:"sm",onClick:()=>{t||a()},"aria-disabled":t||void 0,className:Yi,children:[n.jsx(Fy,{className:"size-3.5","aria-hidden":!0}),"Capture app"]})}),!o&&n.jsx(vr,{tip:b,children:n.jsxs(F,{"aria-describedby":m,type:"button",variant:"ghost",size:"sm",onClick:()=>{t||i()},"aria-disabled":t||void 0,className:Yi,children:[n.jsx(js,{className:"size-3.5","aria-hidden":!0}),s?"Point again":"Point at it"]})}),!o&&n.jsx("span",{id:m,className:"sr-only",children:b}),n.jsx("span",{id:h,className:"sr-only",children:x}),n.jsx(vr,{tip:x,children:n.jsxs("label",{htmlFor:d,"aria-disabled":t||void 0,className:"text-muted-foreground hover:text-foreground hover:bg-accent focus-within:ring-ring flex size-8 cursor-pointer items-center justify-center rounded-md transition-colors duration-150 focus-within:ring-2 aria-disabled:pointer-events-none aria-disabled:opacity-50",children:[n.jsx(Tb,{className:"size-3.5","aria-hidden":!0}),n.jsx("input",{id:d,type:"file",accept:"image/*","aria-label":g,"aria-describedby":h,disabled:t,className:"sr-only",onChange:p})]})})]}),f&&n.jsxs("span",{className:"text-muted-foreground ml-auto pr-1.5 text-xs","aria-hidden":!0,children:[Gt?"⌘↵":"Ctrl+↵"," to send"]})]})}function Vi({imageUrl:e,alt:t,caption:s,pointed:r=!1,detail:o,onOpen:a,onRemove:i,removeLabel:c}){const d=n.jsxs(n.Fragment,{children:[e?n.jsx("img",{src:e,alt:t,className:"size-full object-cover"}):n.jsx("span",{className:"text-muted-foreground flex size-full items-center justify-center",children:n.jsx(js,{className:"size-4","aria-hidden":!0})}),s&&n.jsxs("span",{className:"bg-background/85 text-2xs absolute inset-x-0 bottom-0 flex items-center gap-1 truncate px-1.5 py-0.5 text-left leading-tight",children:[r&&n.jsx(js,{className:"size-3 shrink-0","aria-hidden":!0}),n.jsx("span",{className:"truncate",children:s})]})]}),l=a?n.jsx("button",{type:"button",onClick:a,"aria-label":`Open ${t.charAt(0).toLowerCase()}${t.slice(1)}`,className:"focus-visible:ring-ring relative block size-full overflow-hidden rounded-[inherit] focus-visible:ring-2 focus-visible:outline-none",children:d}):n.jsx("div",{role:"img","aria-label":t,className:"relative size-full overflow-hidden rounded-[inherit]",children:d});return n.jsxs("div",{className:"bg-muted/40 relative h-16 w-28 shrink-0 rounded-md border",children:[o&&a?n.jsxs(xn,{children:[n.jsx(bn,{asChild:!0,children:l}),n.jsx(yn,{className:"text-2xs max-w-72 font-mono break-all",children:o})]}):l,n.jsx("button",{type:"button",onClick:i,"aria-label":c,className:"bg-background/90 text-muted-foreground hover:text-foreground focus-visible:ring-ring absolute top-1 right-1 flex size-5 items-center justify-center rounded-full border transition-colors duration-150 focus-visible:ring-2 focus-visible:outline-none",children:n.jsx(Be,{className:"size-3","aria-hidden":!0})})]})}function Qi({label:e,summary:t,pressed:s,onPressedChange:r,onPreview:o}){return n.jsxs("span",{className:K("inline-flex items-center rounded-full border text-xs transition-colors duration-150",s?"bg-muted/60 text-foreground":"text-muted-foreground"),children:[n.jsxs(xn,{children:[n.jsx(bn,{asChild:!0,children:n.jsxs("button",{type:"button","aria-pressed":s,onClick:()=>r(!s),className:"hover:text-foreground focus-ring-inset flex items-center gap-1 rounded-full py-1 pr-1.5 pl-2.5",children:[s&&n.jsx(Jt,{className:"size-3","aria-hidden":!0}),e]})}),n.jsx(yn,{className:"max-w-60",children:t})]}),n.jsx("button",{type:"button",onClick:o,"aria-label":`Preview ${e.toLowerCase()}`,className:"text-muted-foreground hover:text-foreground focus-ring-inset flex items-center justify-center rounded-full py-1 pr-2.5 pl-1 max-sm:min-h-11 max-sm:min-w-11 max-sm:px-0",children:n.jsx(ig,{className:"size-3.5","aria-hidden":!0})})]})}function eE({currentUser:e,anonymous:t,onToggleAnonymous:s,contact:r,onContactChange:o}){const a=u.useId(),i=u.useId();if(e)return n.jsxs("div",{className:"flex flex-col gap-1",children:[n.jsxs("div",{className:"text-muted-foreground flex items-center gap-1.5 text-xs",children:[t?n.jsx(qy,{className:"size-3.5 shrink-0","aria-hidden":!0}):n.jsx(cg,{className:"size-3.5 shrink-0","aria-hidden":!0}),n.jsx("span",{className:"min-w-0 flex-1 truncate",children:t?"Sending anonymously":`Replying to ${e.email}`}),n.jsx("button",{type:"button",onClick:s,className:"text-muted-foreground hover:text-foreground focus-visible:ring-ring shrink-0 rounded-sm underline underline-offset-2 transition-colors duration-150 focus-visible:ring-2 focus-visible:outline-none",children:t?"Use my account":"Send anonymously"})]}),t&&n.jsx("p",{className:"text-muted-foreground text-xs",children:"Without your name or email, the team can’t reply. Track it in Your reports."})]});const c=r.trim().length>0&&!$l(r);return n.jsxs("div",{className:"flex flex-col gap-1.5",children:[n.jsx(He,{htmlFor:a,className:"text-xs",children:"Your email"}),n.jsx(yt,{id:a,type:"email",inputMode:"email",autoComplete:"email",value:r,onChange:d=>o(d.target.value),placeholder:"you@example.com",maxLength:lg,"aria-describedby":i,onKeyDown:d=>{d.key==="Enter"&&!d.metaKey&&!d.ctrlKey&&d.preventDefault()},"aria-invalid":c||void 0}),n.jsx("p",{id:i,className:"text-muted-foreground text-xs",children:c?"Not an email yet, so no reply can reach you.":"Get a note when it’s fixed. DorkOS remembers it."})]})}const tE=[{value:"feedback",label:"Feedback",icon:Rs},{value:"bug",label:"Bug",icon:dg},{value:"idea",label:"Idea",icon:Db}];function nE({kind:e,onChange:t}){return n.jsx("div",{role:"radiogroup","aria-label":"What kind of feedback",className:"flex gap-1.5",children:tE.map(({value:s,label:r,icon:o})=>{const a=e===s;return n.jsxs("button",{type:"button",role:"radio","aria-checked":a,onClick:()=>t(s),className:K("focus-visible:ring-ring flex items-center gap-1.5 rounded-full border px-3 py-1 text-xs font-medium transition-colors duration-150 focus-visible:ring-2 focus-visible:outline-none",a?"border-foreground/60 text-foreground bg-muted/60":"text-muted-foreground hover:text-foreground"),children:[n.jsx(o,{className:"size-3.5","aria-hidden":!0}),r]},s)})})}function sE({needsWords:e,canSend:t,isSubmitting:s,onOpenGitHubIssue:r}){const o=u.useId();return n.jsxs(on,{className:"shrink-0 flex-col gap-2 sm:flex-col sm:justify-start sm:space-x-0",children:[n.jsxs("div",{className:"flex items-center gap-3",children:[e?n.jsx("p",{id:o,"aria-live":"polite",className:"text-status-warning min-w-0 flex-1 text-xs",children:"Add a few words about what to look for."}):n.jsxs("p",{className:"text-muted-foreground flex min-w-0 flex-1 items-center gap-1.5 text-xs",children:[n.jsx(vs,{className:"size-3 shrink-0","aria-hidden":!0}),"Only the DorkOS team sees this"]}),n.jsx(F,{type:"submit",disabled:!t,"aria-keyshortcuts":"Meta+Enter Control+Enter","aria-describedby":e?o:void 0,className:"shrink-0",children:s?"Sending…":"Send"})]}),n.jsxs("p",{className:"text-muted-foreground text-center text-xs",children:["Prefer a public GitHub issue?"," ",n.jsx("button",{type:"button",onClick:r,className:"hover:text-foreground focus-visible:ring-ring rounded-sm underline underline-offset-2 transition-colors duration-150 focus-visible:ring-2 focus-visible:outline-none",children:"Open one instead"})]})]})}const rE={feedback:"What works, what does not, what you wish it did…",bug:"What happened, and what did you expect instead?",idea:"What would you like DorkOS to do?"};function Xi(e,t,s){return{diagnostics:e==="bug"||s,conversation:e==="bug"&&t}}function oE({open:e,onOpenChange:t,initialKind:s,prefillMessage:r,crashStack:o,currentUser:a,initialScreenshotDataUrl:i}){const c=!_e(),{isSubmitting:d,sessionId:l,roomId:m,route:h,buildDiagnostics:p,send:f}=h1(),g=yv(),x=!!(l||m),y=l?`session:${l}`:m?`room:${m}`:void 0,{throughSeq:b}=om(m,!1),C=!!a,k=u.useId(),[I,v]=u.useState(s??"feedback"),[E,R]=u.useState(r??""),[_,D]=u.useState(Na),[P,T]=u.useState(!1),[j,w]=u.useState(!1),[N,S]=u.useState(!1),[M,B]=u.useState(!1),[O,$]=u.useState("diagnostics"),[G,ee]=u.useState(null),[z,V]=u.useState(null),[ae,pe]=u.useState(null),[Q,q]=u.useState(null),[ne,ve]=u.useState(0),se=u.useRef(ne);u.useEffect(()=>{se.current=ne},[ne]);const[Y,he]=u.useState(!1),[ge,Ve]=u.useState(o),[Qe,Re]=u.useState(y),Xe=u.useRef(null),te=C1({enabled:e}),ye=E.trim().length>0,we=ye||te.dataUrl!==null||G!==null,[jt,Ge]=u.useState(e);if(e!==jt&&(Ge(e),e)){B(!1),q(null);const J=i;if(!!(r||o||J)||!we){const St=s??"feedback",Xn=Xi(St,!!l,!!o);v(St),R(r??""),D(Na()),T(!1),w(Xn.diagnostics),S(Xn.conversation),he(!1),ee(null),V(null),Ve(o),Re(y),te.reset(J),ve(Qs=>Qs+1)}else y!==Qe&&(S(!1),Re(y))}function H(J){const Ce=Xi(J,!!l,!!ge);w(Ce.diagnostics),S(Ce.conversation)}function de(J){v(J),H(J)}function je(J){$(J),B(!0)}async function Je(J){const Ce=se.current,St=T1(J),Xn=$1(J);z&&te.dataUrl===z&&te.clear(),V(null),q("capturing");const Qs=await te.captureElement(J);Ce===se.current&&(q(null),ee(St),pe(Xn),V(Qs),v("bug"),Y||H("bug"))}function Ze(){z&&te.dataUrl===z&&te.clear(),ee(null),V(null)}function Ie(){R(""),ee(null),V(null),he(!1),Ve(void 0),te.clear()}const kt=ye&&!d&&!te.isPreparing,_t=C?P||a==null?void 0:a.email:$l(_)?_.trim():void 0;async function Pt(){!kt||!await f({kind:I,message:E,...C?{}:{contact:_},includeDiagnostics:j,includeConversation:N,...m&&b?{roomThroughSeq:b}:{},anonymous:P,...ge?{crashStack:ge}:{},...te.dataUrl?{screenshotDataUrl:te.dataUrl}:{},...G?{element:G}:{},..._t?{notifyEmail:_t}:{}})||(C||hg(_),Ie(),t(!1))}function U(J){J.preventDefault(),Pt()}function ke(J){const Ce=Xe.current;Ce&&(J.preventDefault(),Ce.focus(),Ce.setSelectionRange(Ce.value.length,Ce.value.length))}function A(J){J.key!=="Enter"||!(J.metaKey||J.ctrlKey)||J.nativeEvent.isComposing||M||(J.preventDefault(),Pt())}const W=te.handlers,Z=Q!==null,oe=G?ae:null,xe=dm(oe),et=!!(G&&z&&te.dataUrl===z),Se=!!te.dataUrl&&!et,ze=!ye&&(!!te.dataUrl||G!==null);return n.jsxs(n.Fragment,{children:[Z&&n.jsx(J1,{phase:Q,onSelect:J=>void Je(J),onCancel:()=>q(null)}),n.jsx(vt,{open:e&&!Z,onOpenChange:t,children:n.jsxs(wt,{...W,onKeyDown:A,desktopProps:{className:"max-w-md",onOpenAutoFocus:ke},className:K("max-h-[85vh] !min-h-0",te.isDraggingOver&&"ring-primary ring-2"),children:[n.jsxs(gt,{children:[n.jsx(ot,{className:"text-sm font-medium",children:"Send feedback"}),n.jsx(xt,{className:"text-muted-foreground text-xs",children:"Straight to the DorkOS team. Private."})]}),n.jsxs("form",{onSubmit:U,noValidate:!0,className:"flex min-h-0 flex-1 flex-col gap-4",children:[n.jsxs(Et,{alignWithHeader:!0,className:"flex flex-col gap-4",children:[n.jsx(nE,{kind:I,onChange:de}),n.jsxs("div",{className:K("dark:bg-input/30 flex flex-col rounded-lg border transition-[border-color,box-shadow] duration-150","focus-within:border-ring focus-within:ring-ring focus-within:ring-[3px]",te.isDraggingOver&&"border-primary"),children:[n.jsx(He,{htmlFor:k,className:"sr-only",children:"Your message"}),n.jsx(ug,{ref:Xe,id:k,value:E,onChange:J=>R(J.target.value),placeholder:G?z1(oe):rE[I],rows:4,maxLength:mg,className:"min-h-24 resize-none rounded-lg border-0 bg-transparent shadow-none focus-visible:ring-0 dark:bg-transparent"}),(G||Se||te.isPreparing||te.isDraggingOver)&&n.jsxs("div",{className:"flex flex-wrap items-center gap-2 px-2.5 pb-2.5",children:[G&&n.jsx(Vi,{imageUrl:et?z??void 0:void 0,alt:`The part you pointed at: ${xe}`,caption:xe,pointed:!0,detail:G.selector,...et?{onOpen:()=>je("screenshot")}:{},onRemove:Ze,removeLabel:U1(oe)}),Se&&te.dataUrl&&n.jsx(Vi,{imageUrl:te.dataUrl,alt:"The screenshot you attached",onOpen:()=>je("screenshot"),onRemove:te.clear,removeLabel:"Remove screenshot"}),(te.isPreparing||te.isDraggingOver)&&n.jsx("p",{role:"status","aria-live":"polite",className:"text-muted-foreground text-xs",children:te.isDraggingOver?"Drop to attach":"Getting it ready…"})]}),n.jsx(Z1,{showPictureTools:!0,isPreparing:te.isPreparing,hasPointed:G!==null,hasWords:ye,isMobile:!c,onCapture:()=>void te.capture(),onPointAtElement:()=>q("picking"),onPick:J=>void te.attach(J)})]}),n.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[n.jsx("span",{className:"text-muted-foreground mr-0.5 text-xs",children:"Also send"}),n.jsx(Qi,{label:"Diagnostics",summary:"Version, window size, browser, and recent errors.",pressed:j,onPressedChange:J=>{he(!0),w(J)},onPreview:()=>je("diagnostics")}),x&&n.jsx(Qi,{label:m?"This room":"This chat",summary:m?`The last ${Fl} messages in this room.`:"Shows what led to the bug.",pressed:N,onPressedChange:J=>{he(!0),S(J)},onPreview:()=>je("conversation")})]}),n.jsx(eE,{currentUser:a??null,anonymous:P,onToggleAnonymous:()=>T(J=>!J),contact:_,onContactChange:D})]}),n.jsx(sE,{needsWords:ze,canSend:kt,isSubmitting:d,onOpenGitHubIssue:()=>g(I==="idea"?"feature":"bug")})]}),n.jsx(Y1,{open:M,onOpenChange:B,initialTab:O,diagnostics:p(ge?{crashStack:ge}:void 0),kind:I,route:h,showConversation:x,sessionId:l,roomId:m,...te.dataUrl?{screenshotDataUrl:te.dataUrl}:{}})]})})]})}function aE(){const e=An(a=>a.open),t=An(a=>a.prefill),s=An(a=>a.openFeedback),r=An(a=>a.setOpen),o=fg();return u.useEffect(()=>{const a=pg();a&&s(a)},[s]),n.jsx(oE,{open:e,onOpenChange:r,initialKind:t.kind,prefillMessage:t.message,crashStack:t.crashStack,currentUser:o?{email:o.email,name:o.name}:null})}function iE(){const e=Pe();u.useEffect(()=>{var s,r,o;if(!((s=window.electronAPI)!=null&&s.onNavigate))return;const t=window.electronAPI.onNavigate(a=>{e({href:a})});return(o=(r=window.electronAPI).getPendingNavigate)==null||o.call(r).then(a=>{a&&e({href:a})}),t},[e])}function cE(){const{closeActive:e}=Ko();u.useEffect(()=>{const t=window.electronAPI;if(t!=null&&t.onCloseTab)return t.onCloseTab(()=>e())},[e])}function lE(){const[e,t]=u.useState(!1);return u.useEffect(()=>{var a,i,c;if(!((a=window.electronAPI)!=null&&a.onFullscreenChange))return;let s=!0,r=!1;const o=window.electronAPI.onFullscreenChange(d=>{r=!0,t(d)});return(c=(i=window.electronAPI).getFullscreenState)==null||c.call(i).then(d=>{s&&!r&&t(d)}),()=>{s=!1,o()}},[]),e}const Ji="window-blurred";function dE(){u.useEffect(()=>{var a,i,c;if(!gg||!((a=window.electronAPI)!=null&&a.onFocusChange))return;const e=document.documentElement,t=d=>{e.classList.toggle(Ji,!d)};let s=!0,r=!1;const o=window.electronAPI.onFocusChange(d=>{r=!0,t(d)});return(c=(i=window.electronAPI).getFocusState)==null||c.call(i).then(d=>{s&&!r&&t(d)}),()=>{s=!1,o(),e.classList.remove(Ji)}},[])}const uE="/channels";function mE(){Gw();const e=xg(),t=Un(),s=e===uE&&!t.community?t.id??null:null,{data:r}=Mc(s),{data:o}=Ls(),a=u.useMemo(()=>(o??[]).filter(_n).length,[o]);return{room:s&&r?r:null,unreadRoomCount:a}}function hE({unreadRoomCount:e}){Gk();const t=L(c=>c.isStreaming),s=L(c=>c.isWaitingForUser),r=Mn(c=>c.schedulesWaitingCount),o=Mn(c=>c.needsYouCount),a=De({select:c=>c.location.href}),i=Ps(a);return jv(c=>bg(i,{...c,badgeCount:e+r,needsYou:s||o>0}),t),null}function fE(){const e=Bn(),t=Gs(),s=le(),r=Pe(),o=u.useRef(null);u.useEffect(()=>{var d;if(!e||!t.data)return;const a=JSON.stringify([e.ownerKey,e.epoch]),i=((d=o.current)==null?void 0:d.owner)===a?o.current.rows:null,c=new Map(t.data.map(l=>[l.ref,{status:l.status,label:l.label,generation:Aa(l.ref)}]));if(o.current={owner:a,rows:c},!!i)for(const[l,m]of i){if(m.status!=="connected")continue;const h=c.get(l);if((h==null?void 0:h.status)==="connected")continue;const p=ys(Pn().destination)===l,f=Aa(l)>m.generation,g=h===void 0?"removed":"revoked";(f?Promise.resolve():yg(s,e,l,g)).then(()=>{p&&ys(Pn().destination)===l&&r({...Ne.home(),replace:!0})}),g==="revoked"&&ce(`This DorkOS can no longer reach ${m.label}.`,{description:"Still a member? Pick it in the sidebar switcher to reconnect."})}},[e,t.data,r,s])}function pE(){fE(),rw(),vg()}const wr="newTodo";function gE(){const e=gl();u.useEffect(()=>{if(!e)return;wg(wr,kg);const t=$c.getState().register("command-palette.items",{id:"new-todo",label:"New to-do",icon:"Plus",action:wr,category:"quick-action",keywords:["todo","to do","remind"]});return()=>{t(),jg(wr)}},[e])}function xE({isFullscreen:e}){return n.jsx("div",{className:K("desktop-darwin:block app-drag-region hidden shrink-0",!e&&"desktop-darwin:h-11"),"aria-hidden":"true"})}class bE extends u.Component{constructor(){super(...arguments);wn(this,"state",{hasError:!1})}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(s,r){console.error("[Sidebar] Body contribution error:",s,r)}componentDidUpdate(s){s.contributionId!==this.props.contributionId&&this.state.hasError&&this.setState({hasError:!1})}render(){return this.state.hasError?n.jsx("div",{"data-testid":"sidebar-body-error",className:"flex h-full items-center justify-center p-4",children:n.jsx("p",{className:"text-muted-foreground text-center text-sm",children:"This panel couldn’t load. Reload the page."})}):this.props.children}}const yE=5e3;function um({testId:e,headline:t,detail:s}){const{isFetching:r,refetch:o}=Me({refetchInterval:yE});return n.jsx("div",{"data-testid":e,className:"bg-background text-foreground flex h-dvh flex-col items-center justify-center px-6",children:n.jsxs("div",{className:"flex w-full max-w-md flex-col items-center text-center",children:[n.jsx(Tt,{size:120,className:"mb-8 opacity-80 dark:hidden"}),n.jsx(Tt,{variant:"white",size:120,className:"mb-8 hidden opacity-80 dark:block"}),n.jsx("h1",{className:"text-xl font-semibold tracking-tight",children:t}),n.jsx("p",{className:"text-muted-foreground mt-3 text-sm",children:s}),n.jsx(F,{variant:"outline",className:"mt-6",onClick:()=>void o(),disabled:r,children:r?"Trying…":"Try again"})]})})}function vE(){return n.jsx(um,{testId:"server-unreachable",headline:"DorkOS can’t reach its server",detail:"It may still be starting up. DorkOS keeps checking."})}function wE(){const{open:e}=ct(),t=L(r=>r.setControlCenterOpen),s=Vs(()=>t(!1));return n.jsxs("section",{className:"@container flex flex-col gap-2","data-testid":"control-center-dial",children:[n.jsxs("div",{children:[n.jsx("p",{className:"text-sm font-medium",children:"Power"}),n.jsx("p",{className:"text-muted-foreground text-xs",children:"What agents may do without asking you."})]}),n.jsx(Zx,{surface:"control-center"}),n.jsxs(F,{variant:"ghost",size:"sm",className:"text-muted-foreground h-7 self-start px-2 text-xs",onClick:s(()=>e("permissions")),children:["Edit permissions",n.jsx(gn,{className:"size-3.5","aria-hidden":!0})]})]})}const tn={unconfigured:"Use DorkOS from your phone. One-time setup.",off:"Use DorkOS from your phone or another computer.",starting:"Connecting…",stopping:"Turning off…",draining:"Closing…"};function jE(){var m,h;const e=qs(),t=ko(),s=L(p=>p.setRemoteAccessOpen),r=L(p=>p.setControlCenterOpen),a=Vs(()=>r(!1))(()=>s(!0)),i=e.isSetUp,c=e.state==="starting"||e.state==="stopping",d=e.hasServerReport;let l;return d?i?e.error!==null?l=n.jsxs("span",{className:"flex min-w-0 items-baseline gap-1.5",children:[n.jsx("span",{className:"text-destructive truncate",children:Ul(e.error)}),n.jsx("button",{type:"button",onClick:a,className:"focus-ring text-foreground shrink-0 rounded-sm underline underline-offset-2",children:"Fix…"})]}):e.state==="blocked"?l=n.jsxs("span",{className:"flex min-w-0 items-baseline gap-1.5",children:[n.jsx("span",{className:"text-status-warning-fg truncate",children:((m=e.managed)==null?void 0:m.reason)??"Needs attention"}),n.jsx("button",{type:"button",onClick:a,className:"focus-ring text-foreground shrink-0 rounded-sm underline underline-offset-2",children:"Fix…"})]}):e.state==="connected"?l=`On · ${e.host??"connected"}`:e.state==="asleep"?l=e.host?`Closed for now · ${e.host}`:"Closed for now":e.state==="draining"?l=tn.draining:e.state==="reconnecting"?l=e.host?`On · ${e.host} · reconnecting…`:"Reconnecting…":e.state==="starting"?l=tn.starting:e.state==="stopping"?l=tn.stopping:l=tn.off:l=tn.unconfigured:l=tn.off,d&&((h=e.managed)!=null&&h.cloudStale)&&typeof l=="string"&&(l=`${l} · Can’t reach DorkOS Cloud`),n.jsx(Bl,{label:"Remote access",description:n.jsx("span",{"data-testid":"remote-access-row-description",className:K("block min-w-0",c&&"motion-safe:animate-breath"),children:l}),children:n.jsx(zl,{checked:i&&e.isChecked,disabled:!d||i&&e.isTransitioning,"aria-label":"Remote access",onCheckedChange:p=>{if(!i){a();return}t.toggle(p)}})})}const kE=1,SE=10,CE=4;function NE(){var l,m;const{data:e}=Me(),t=Vn(),s=le(),{limits:r,setLimits:o}=Sg(),a=Os(),i=()=>void s.invalidateQueries({queryKey:Fe.all}),c=((l=e==null?void 0:e.claudeCode)==null?void 0:l.persistentSession)??!0,d=((m=e==null?void 0:e.scheduler)==null?void 0:m.maxConcurrentRuns)??CE;return n.jsx(Cg,{children:n.jsxs(Ng,{children:[!a&&n.jsx(jE,{}),n.jsx(mb,{}),n.jsx(Ea,{label:"Limit automatic replies",description:(r==null?void 0:r.turnLimitsEnabled)===!1?"Agents reply to each other without limit until you press Stop.":n.jsxs(n.Fragment,{children:["Agents pause after a long back-and-forth."," ",n.jsxs(Ma,{label:"About reply limits",children:[n.jsx("p",{children:"Your next message starts the count over."}),n.jsx("p",{children:"Set the numbers in Settings → Advanced → Room limits."})]})]}),checked:(r==null?void 0:r.turnLimitsEnabled)??!0,disabled:r===null,onCheckedChange:h=>o({turnLimitsEnabled:h})}),!a&&n.jsx(Ea,{label:"Warm agents",description:n.jsxs(n.Fragment,{children:["Replies start about 4× faster. Each warm agent uses up to about 1 GB."," ",n.jsxs(Ma,{label:"About warm agents",children:[n.jsx("p",{children:"Your agent stays running between messages."}),n.jsx("p",{children:"At most twelve agents stay warm at once."})]})]}),checked:c,disabled:t.isPending,onCheckedChange:h=>t.mutate({runtimes:{claudeCode:{persistentSession:h}}},{onSuccess:i})}),n.jsx(Bl,{label:"Scheduled runs at once",description:"How many scheduled tasks run together.",children:n.jsx(eb,{value:d,min:kE,max:SE,"aria-label":"Scheduled runs at once",onCommit:h=>t.mutate({scheduler:{maxConcurrentRuns:h}},{onSuccess:i})})})]})})}const Zi="claude-code";function AE(){var R,_,D,P,T;const{data:e}=Me(),{data:t}=Sc(),{sessions:s}=ll(),r=Ag(),{data:o}=el(r),{data:a}=wb(),i=fb(),c=i.data,d=Yw(),l=Ms(),{open:m}=ct(),{open:h}=Ro(),p=uo(),f=L(j=>j.setControlCenterOpen),g=Vs(()=>f(!1)),x=i.isError,y=t===void 0||e===void 0||c===void 0&&!x,b=e==null?void 0:e.executionDefaults,C=(b==null?void 0:b.runtime)??Zi,k=(R=t==null?void 0:t.capabilities[C])==null?void 0:R.permissionModes,I=((_=k==null?void 0:k.values.find(j=>j.id===k.default))==null?void 0:_.stop)??"ask",v=(b==null?void 0:b.trustStop)??I,E=[];if(!y){for(const w of(b==null?void 0:b.perRuntime)??[])w.trustStop===null||w.trustStop===v||E.push({key:`runtime:${w.runtime}`,kind:"runtime",name:dt(w.runtime).label,detail:tr(w.trustStop),onOpen:l?g(()=>m("runtimes")):null});for(const w of s){const N=(D=t==null?void 0:t.capabilities[w.runtime])==null?void 0:D.permissionModes,S=N==null?void 0:N.values.find(B=>B.id===w.permissionMode),M=S==null?void 0:S.stop;!M||M===v||E.push({key:`session:${w.id}`,kind:"session",name:w.title||"Untitled chat",detail:(S==null?void 0:S.label)??nr(w.permissionMode),onOpen:l?g(()=>l(Rt({session:w.id,dir:w.cwd}))):null})}const j=((T=(P=t==null?void 0:t.capabilities[Zi])==null?void 0:P.permissionModes)==null?void 0:T.values)??[];for(const w of o??[]){const N=j.find(M=>M.id===w.permissionMode),S=N==null?void 0:N.stop;!S||S===v||E.push({key:`task:${w.id}`,kind:"task",name:w.displayName??w.name,detail:(N==null?void 0:N.label)??nr(w.permissionMode),onOpen:l?g(()=>l({...Ne.tasks()})):null})}for(const w of a??[]){const N=j.find(M=>M.id===w.permissionMode),S=N==null?void 0:N.stop;!S||S===v||E.push({key:`binding:${w.id}`,kind:"binding",name:w.label||w.adapterId,detail:(N==null?void 0:N.label)??nr(w.permissionMode),onOpen:l?g(()=>p({app:w.adapterId})):null})}}if(c){const j=new Map(c.areas.map(S=>[S.id,S.label])),w=new Map(c.areas.flatMap(S=>S.actions.map(M=>[M.id,M.title]))),N=S=>g(()=>h(S,"permissions"));for(const S of c.exceptions){const M=S.action?w.get(S.action)??S.action:j.get(S.area),B=pb[S.state];E.push({key:`agent-permission:${S.agentId}:${S.action??S.area}`,kind:"agent-permission",name:S.agentName,detail:`${M??S.area} ${B}`,why:{question:`Why is ${M??S.area} set to ${B} for ${S.agentName}?`,sentence:gb({state:S.state,source:S.action?"agent-action":"agent-area",preset:c.preset,agentName:S.agentName}),...S.lastChange?{lastChange:S.lastChange}:{}},onOpen:N(S.agentId),onReset:()=>d.mutate({agentId:S.agentId,key:S.action?{kind:"action",action:S.action}:{kind:"area",area:S.area},surface:"control-center"}),resetting:d.isPending})}for(const S of c.filesAndCommands.exceptions)E.push({key:`agent-permission:${S.agentId}:files`,kind:"agent-permission",name:S.agentName,detail:`Files & commands ${tr(S.stop)}`,why:{question:`Why is Files & commands set to ${tr(S.stop)} for ${S.agentName}?`,sentence:xb(S.stop,"agent",S.agentName),...S.lastChange?{lastChange:S.lastChange}:{}},onOpen:N(S.agentId),onReset:()=>d.mutate({agentId:S.agentId,key:{kind:"files"},surface:"control-center"}),resetting:d.isPending})}return{rows:E,isEmpty:!y&&!x&&E.length===0,isResolving:y,permissionsUnreadable:x}}const EE={runtime:jb,session:Ig,task:_o,binding:Nc,"agent-permission":Eg};function IE(){const{rows:e,isEmpty:t,isResolving:s,permissionsUnreadable:r}=AE();return n.jsxs("section",{className:"flex flex-col gap-2","data-testid":"control-center-overrides",children:[n.jsxs("div",{children:[n.jsx("p",{className:"text-sm font-medium",children:"Exceptions"}),n.jsx("p",{className:"text-muted-foreground text-xs",children:"These skip the preset. Changing the preset leaves them alone."})]}),s?n.jsx("p",{className:"text-muted-foreground px-1 text-xs",children:"Checking…"}):t?n.jsx("p",{"data-testid":"overrides-ledger-empty",className:"text-muted-foreground px-1 text-xs",children:"Everything follows your preset. Chats open in other projects aren’t counted."}):n.jsx("ul",{className:"flex flex-col gap-0.5",children:e.map(o=>{const a=EE[o.kind];return n.jsxs("li",{className:"flex items-center gap-1",children:[n.jsxs("button",{type:"button","data-testid":`override-row-${o.kind}`,onClick:()=>{var i;return(i=o.onOpen)==null?void 0:i.call(o)},disabled:!o.onOpen,"aria-label":`${o.name}: ${o.detail}. Open.`,className:"focus-ring hover:bg-accent/60 flex min-w-0 flex-1 items-center gap-2 rounded-md px-2 py-1.5 text-left text-xs transition-colors disabled:pointer-events-none disabled:opacity-60",children:[n.jsx(a,{className:"text-muted-foreground size-3.5 shrink-0","aria-hidden":!0}),n.jsx("span",{className:"min-w-16 flex-1 truncate",children:o.name}),n.jsx("span",{className:"text-muted-foreground min-w-0 truncate",children:o.detail}),n.jsx(gn,{className:"text-muted-foreground/60 size-3.5 shrink-0","aria-hidden":!0})]}),o.why?n.jsx(bb,{question:o.why.question,sentence:o.why.sentence,...o.why.lastChange?{lastChange:o.why.lastChange}:{},className:"shrink-0 px-1"}):null,o.onReset?n.jsxs(F,{variant:"ghost",size:"sm",className:"h-7 shrink-0 px-2 text-xs",disabled:o.resetting,"aria-label":`Reset ${o.name}: ${o.detail}`,onClick:o.onReset,children:[n.jsx(Gc,{className:"size-3.5","aria-hidden":!0}),"Reset"]}):null]},o.key)})}),r?n.jsx("p",{"data-testid":"overrides-ledger-permissions-error",className:"text-muted-foreground px-1 text-xs",children:"Couldn’t load agents with their own permissions. See Settings → Permissions."}):null]})}const ec=16,tc=20*1024**3;function RE(e,t){return e.map(r=>{const o=t.filter(i=>i.cwd===r.projectPath),a=o.filter(i=>i.waiting).length;return{agent:r,running:o.length-a,waiting:a,chats:mm(o)}}).sort((r,o)=>nc(r)-nc(o)||r.agent.name.localeCompare(o.agent.name))}function TE(e,t){const s=new Set(e.map(r=>r.projectPath));return mm(t.filter(r=>!s.has(r.cwd)))}function mm(e){return[...e].sort((t,s)=>Number(s.waiting)-Number(t.waiting)||t.title.localeCompare(s.title))}function nc(e){return e.waiting>0?0:e.running>0?1:2}function DE(e,t){const{maxAgentChats:s,loadAverage:r,freeDiskBytes:o}=t,a=[];if(s===null)a.push({key:"chats",text:`${e} chats running`,over:!1});else{const i=e>=s,c=`${e} of ${s} chats running`;a.push({key:"chats",text:i?`${c}, at the limit`:c,over:i})}if(r!==null){const i=Math.round(r),c=r>=ec;a.push({key:"load",text:c?`load ${i}, limit ${ec}`:`load ${i}`,over:c})}if(o!==null){const i=Math.floor(o/1073741824),c=o<tc,d=tc/1024**3;a.push({key:"disk",text:c?`${i} GB free, limit ${d} GB`:`${i} GB free`,over:c})}return a}function OE(e){const t=[];return e.running>0&&t.push(`${e.running} running`),e.waiting>0&&t.push(`${e.waiting} waiting on you`),t.length>0?t.join(" · "):"Idle"}function ME(e){const t=Math.floor(e/6e4);return t<1?`${Math.max(0,Math.floor(e/1e3))}s`:t<60?`${t}m`:`${Math.floor(t/60)}h ${t%60}m`}const _E=15e3;function PE(){const{data:e}=qn(),{data:t}=Me({refetchInterval:_E}),s=rt(d=>d.sessions),r=rt(d=>d.statuses),o=rt(d=>d.statusCwds),a=u.useMemo(()=>{var l,m;const d=[];for(const[h,p]of Object.entries(r)){const f=o[h]??((l=s[h])==null?void 0:l.cwd);if(f===void 0)continue;const{lifecycle:g,activity:x}=p;g!=="streaming"&&g!=="blocked"||d.push({id:h,cwd:f,title:((m=s[h])==null?void 0:m.title)||"Untitled chat",activity:il(g,x),waiting:g==="blocked",startedAt:null})}return d},[s,r,o]),i=u.useMemo(()=>((e==null?void 0:e.agents)??[]).map(d=>({id:d.id,name:d.displayName??d.name,projectPath:d.projectPath,...Bs(d)})),[e]),c=t==null?void 0:t.capacity;return u.useMemo(()=>{const d=(c==null?void 0:c.maxAgentChats)??null;return{figures:DE(a.length,{maxAgentChats:d,loadAverage:(c==null?void 0:c.loadAverage)??null,freeDiskBytes:(c==null?void 0:c.freeDiskBytes)??null}),atCap:d!==null&&a.length>=d,rows:RE(i,a),otherChats:TE(i,a),isEmpty:a.length===0}},[i,a,c])}function hm({text:e,className:t}){return n.jsx("span",{className:K("grid min-w-0",t),children:n.jsx(Ye,{initial:!1,children:n.jsx(re.span,{className:"col-start-1 row-start-1 truncate",initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.15},children:e},e)})})}function fm({chat:e,now:t,onOpen:s}){return n.jsx("li",{children:n.jsxs("button",{type:"button","data-testid":"team-chat-row",onClick:s,"aria-label":`${e.title}: ${e.activity}. Open.`,className:"focus-ring hover:bg-accent/60 flex h-11 w-full min-w-0 items-center gap-2 rounded-md pr-2 pl-9 text-left text-xs transition-colors",children:[n.jsxs("span",{className:"flex min-w-0 flex-1 flex-col",children:[n.jsx("span",{className:"truncate",children:e.title}),e.waiting?n.jsxs("span",{className:"text-status-warning-fg flex items-center gap-1.5",children:[n.jsx("span",{className:"bg-status-warning-fg size-1.5 shrink-0 rounded-full","aria-hidden":!0}),"Waiting"]}):n.jsx(hm,{text:e.activity,className:"text-muted-foreground"})]}),e.startedAt!==null?n.jsx("span",{className:"text-muted-foreground shrink-0 tabular-nums",children:ME(t-e.startedAt)}):null]})})}function LE({row:e,now:t,onOpenChat:s}){return n.jsxs("li",{"data-testid":"team-agent-row",children:[n.jsxs("div",{className:"flex h-11 min-w-0 items-center gap-2 px-2 text-xs",children:[n.jsx($s,{color:e.agent.color,emoji:e.agent.emoji,size:"xs",badge:null}),n.jsxs("span",{className:"flex min-w-0 flex-1 flex-col",children:[n.jsx("span",{className:"truncate font-medium",children:e.agent.name}),n.jsx(hm,{text:OE(e),className:"text-muted-foreground"})]})]}),e.chats.length>0?n.jsx("ul",{className:"flex flex-col",children:e.chats.map(r=>n.jsx(fm,{chat:r,now:t,onOpen:()=>s(r)},r.id))}):null]})}function FE(){const e=PE(),t=Ks(3e4),s=Ms(),r=L(o=>o.setControlCenterOpen);return n.jsx($E,{board:e,now:t,onOpenChat:o=>{r(!1),s==null||s(Rt({session:o.id,dir:o.cwd}))}})}function $E({board:e,now:t,onOpenChat:s}){return n.jsxs("section",{className:"flex flex-col gap-2","data-testid":"control-center-team",children:[n.jsx("p",{"data-testid":"team-figures",className:"flex flex-wrap gap-x-1.5 gap-y-0.5 px-1 text-xs tabular-nums",children:e.figures.map((r,o)=>n.jsxs("span",{className:"flex gap-1.5",children:[n.jsx("span",{"data-over":r.over||void 0,className:K(r.over&&"text-status-warning-fg",o===0&&"font-medium"),children:r.text}),o<e.figures.length-1?n.jsx("span",{className:"text-muted-foreground","aria-hidden":!0,children:"·"}):null]},r.key))}),e.atCap?n.jsx("p",{"data-testid":"team-cap",className:"text-status-warning-fg px-1 text-xs",children:"New spin-off chats wait until one finishes."}):null,e.isEmpty?n.jsx("p",{"data-testid":"team-empty",className:"text-muted-foreground px-1 text-xs",children:"Nothing running. Agents start their next item when a slot frees."}):n.jsxs("ul",{className:"flex max-h-[60dvh] flex-col overflow-y-auto",children:[e.rows.map(r=>n.jsx(LE,{row:r,now:t,onOpenChat:s},r.agent.id)),e.otherChats.length>0?n.jsxs("li",{"data-testid":"team-other-chats",children:[n.jsx("p",{className:"text-muted-foreground flex h-11 items-center px-2 text-xs",children:"Other chats"}),n.jsx("ul",{className:"flex flex-col",children:e.otherChats.map(r=>n.jsx(fm,{chat:r,now:t,onOpen:()=>s(r)},r.id))})]}):null]})]})}function BE(){const e=od();return ad(e)?n.jsxs("p",{"data-testid":"control-center-keep-awake",className:"text-muted-foreground flex items-start gap-1.5 px-1 text-xs",children:[n.jsx(Md,{className:"mt-px size-3 shrink-0","aria-hidden":!0}),n.jsxs("span",{children:["Keeping this computer awake: ",id(e.working),"."]})]}):null}function zE(){const[e,t]=u.useState("power");return n.jsxs("div",{className:"flex flex-col gap-4","data-testid":"control-center-body",children:[n.jsxs(Rg,{"aria-label":"Control Center view",value:e,onValueChange:s=>t(s),children:[n.jsx(Ia,{value:"power",children:"Power"}),n.jsx(Ia,{value:"team",children:"Team"})]}),e==="team"?n.jsx(FE,{}):n.jsxs(n.Fragment,{children:[n.jsx(wE,{}),n.jsx(NE,{}),n.jsx(IE,{}),n.jsx(BE,{})]})]})}function UE(e){const t=e.currentTarget;if(!(t instanceof HTMLElement))return;const s=t.querySelector('[role="radiogroup"][aria-label="Preset"]'),r=(s==null?void 0:s.querySelector('[role="radio"][aria-checked="true"]'))??(s==null?void 0:s.querySelector('[role="radio"]'));r&&(e.preventDefault(),r.focus())}function KE(){const e=L(r=>r.controlCenterOpen),t=L(r=>r.setControlCenterOpen),s=_e();return n.jsxs(mn,{open:e,onOpenChange:t,modal:!0,autoFocus:!0,children:[n.jsx(hn,{asChild:!0,children:n.jsx("button",{type:"button","data-testid":"control-center-trigger","aria-label":"Control Center",className:"focus-ring text-muted-foreground hover:text-foreground inline-flex size-11 shrink-0 items-center justify-center rounded-md transition-colors md:size-7",children:n.jsx(Ra,{className:"size-(--size-icon-sm)","aria-hidden":!0})})}),n.jsxs(fn,{side:"bottom",align:"end","aria-label":"Control Center",onOpenAutoFocus:UE,className:"w-96 max-w-[calc(100vw-1.5rem)] p-3",children:[!s&&n.jsxs("header",{className:"mb-3 flex items-center gap-2",children:[n.jsx(Ra,{className:"text-status-success size-4 shrink-0","aria-hidden":!0}),n.jsx("h2",{className:"text-sm font-semibold",children:"Control Center"})]}),n.jsx(pn,{children:"Control Center"}),n.jsx(zE,{})]})]})}function HE(){const e=L(t=>t.toggleControlCenter);u.useEffect(()=>{const t=s=>{(s.metaKey||s.ctrlKey)&&s.shiftKey&&(s.key==="l"||s.key==="L")&&(s.preventDefault(),e())};return document.addEventListener("keydown",t),()=>document.removeEventListener("keydown",t)},[e])}function WE(){const{isDesktop:e}=Kl(),t="In use from the web";return e?n.jsx("p",{className:"text-sm font-medium",children:t}):n.jsx(pn,{className:"text-sm font-medium",children:t})}function GE(){const{presence:e,canEnd:t,end:s,ending:r,error:o}=tb(),[a,i]=u.useState(!1);return e!=null&&e.active?n.jsxs(mn,{open:a,onOpenChange:i,children:[n.jsx(hn,{asChild:!0,children:n.jsx("button",{type:"button","data-testid":"remote-session-indicator","aria-label":"In use from the web. Show details",className:"focus-ring text-muted-foreground hover:text-foreground inline-flex size-7 shrink-0 items-center justify-center rounded-md transition-colors",children:n.jsx(Tg,{className:"size-4","aria-hidden":!0})})}),n.jsxs(fn,{side:"bottom",align:"end","aria-label":"In use from the web",className:"w-72 max-w-[calc(100vw-1.5rem)] space-y-3 p-3",children:[n.jsxs("div",{className:"space-y-0.5",children:[n.jsx(WE,{}),e.since&&n.jsxs("p",{className:"text-muted-foreground text-xs",children:["Someone is chatting here from the web. Started ",Hn(e.since),"."]})]}),e.devices.length>0?n.jsx(nb,{devices:e.devices}):n.jsx("p",{className:"text-muted-foreground text-xs",children:"No device named yet."}),t?n.jsxs("div",{className:"space-y-1",children:[n.jsx(F,{variant:"outline",size:"sm",disabled:r,onClick:s,children:"End now"}),n.jsx("p",{className:"text-muted-foreground text-xs",children:"This also pauses chat from the web."})]}):n.jsx("p",{className:"text-muted-foreground text-xs",children:"End it on the computer DorkOS runs on."}),o&&n.jsx("p",{className:"text-destructive text-xs",role:"alert",children:o})]})]}):null}function qE(e,t){const s=u.useRef(null),[r,o]=u.useState(0);return u.useEffect(()=>{if(!t)return;const a=s.current;s.current=e,a!==null&&a!=="connected"&&e==="connected"&&o(i=>i+1)},[e,t]),r}function YE({url:e}){const t=ht();return n.jsxs("div",{"data-testid":"remote-access-qr",children:[n.jsx(re.div,{initial:t?!1:{clipPath:"inset(0 100% 0 0)"},animate:{clipPath:"inset(0 0% 0 0)"},transition:{duration:.2,ease:[0,0,.2,1]},children:n.jsx(Dg,{url:e,size:168})}),n.jsx("p",{className:"text-muted-foreground mt-2 text-center text-xs",children:"Scan with your phone"})]})}function VE({url:e}){const{copied:t,failed:s,copy:r}=zn();let o,a;return t?(o=n.jsx(Jt,{className:"size-3.5"}),a="Copied"):s?(o=n.jsx(Be,{className:"text-destructive size-3.5"}),a="Couldn’t copy"):(o=n.jsx(co,{className:"size-3.5"}),a="Copy link"),n.jsxs("div",{className:"bg-muted/40 rounded-lg border p-2.5","data-testid":"remote-access-link",children:[n.jsx("p",{className:"text-foreground truncate font-mono text-xs",title:e,children:e}),n.jsxs(F,{variant:"outline",size:"sm",className:"mt-2 w-full gap-1.5",onClick:()=>void r(e),children:[o,a]})]})}function QE(){const e=qs(),t=e.managed;if(!t)return null;const s=[];return t.alwaysAvailable&&s.push("Always available"),e.state==="asleep"&&s.push("Your address stays the same."),t.reason&&s.push(t.reason),t.cloudStale&&s.push("Couldn’t reach DorkOS Cloud. Showing the last known state."),s.length===0?null:n.jsx("div",{className:"text-muted-foreground space-y-1 text-xs","data-testid":"remote-access-managed-note",children:s.map(r=>n.jsx("p",{children:r},r))})}function XE({onClose:e}){const t=qs(),s=ko(),r=_e(),o=L(h=>h.setRemoteAccessOpen),a=Vs(e),i=t.url,c=t.mode==="managed",d=i?n.jsx(VE,{url:i},"link"):null,l=i?n.jsx(YE,{url:i},"qr"):null,m=r?[d,l]:[l,d];return n.jsxs("div",{className:"flex flex-col gap-3","data-testid":"remote-access-panel",children:[!r&&n.jsxs("header",{className:"flex items-center gap-2",children:[n.jsx("span",{className:K("inline-block size-2 shrink-0 rounded-full",Hl(t.state)),"aria-hidden":!0}),n.jsx("h2",{className:"text-sm font-semibold",children:Wl(t.state)})]}),t.error!==null&&n.jsx("p",{role:"alert","data-testid":"remote-access-panel-error",className:"text-destructive text-xs",children:Ul(t.error)}),c&&n.jsx(QE,{}),i===null&&t.state!=="asleep"&&n.jsx("p",{className:"text-muted-foreground text-xs",children:"Your link appears here when it’s ready."}),m,n.jsxs("div",{className:"flex items-center justify-between gap-3 pt-1",children:[n.jsx("span",{className:"text-muted-foreground text-sm",children:"Remote access"}),n.jsx(zl,{checked:t.isChecked,disabled:t.isTransitioning,"aria-label":"Remote access",onCheckedChange:h=>void s.toggle(h)})]}),n.jsx(F,{variant:"ghost",size:"sm",className:"text-muted-foreground hover:text-foreground -mx-1 justify-start",onClick:a(()=>o(!0)),children:"Manage…"})]})}function pm(e,t){return e==="starting"?"Remote access is connecting":e==="reconnecting"?"Remote access is reconnecting":e==="stopping"?"Remote access is turning off":e==="draining"?"Remote access is closing":e==="asleep"?t?`Remote access is closed for now at ${t}`:"Remote access is closed for now":t?`Remote access is on at ${t}`:"Remote access is on"}function JE(e,t){const s=e==="starting"||e==="asleep"&&!t?"Open remote access":"Show link and QR code";return`${pm(e,t)}. ${s}`}function ZE(){const e=qs(),t=L(i=>i.remoteAccessBeaconOpen),s=L(i=>i.setRemoteAccessBeaconOpen),r=ht(),o=qE(e.state,e.hasServerReport);u.useEffect(()=>{!e.isLive&&t&&s(!1)},[e.isLive,t,s]);const a=e.isLive?pm(e.state,e.host):"";return n.jsxs(n.Fragment,{children:[n.jsx("span",{role:"status",className:"sr-only","data-testid":"remote-access-announcement",children:a}),e.isLive&&n.jsxs(mn,{open:t,onOpenChange:s,modal:!0,children:[n.jsx(hn,{asChild:!0,children:n.jsxs("button",{type:"button","data-testid":"remote-access-beacon","data-state-name":e.state,"aria-label":JE(e.state,e.host),className:K("focus-ring text-muted-foreground hover:text-foreground relative inline-flex size-11 shrink-0 items-center justify-center rounded-md transition-colors md:size-7",e.state==="reconnecting"&&"opacity-70"),children:[n.jsx(gs,{className:K("size-(--size-icon-sm)",e.state==="starting"&&"motion-safe:animate-breath"),"aria-hidden":!0}),n.jsx("span",{"aria-hidden":!0,"data-testid":"remote-access-beacon-dot",className:K("border-background absolute right-0.5 bottom-0.5 size-1.5 rounded-full border",Hl(e.state))}),o>0&&!r&&n.jsx("span",{"aria-hidden":!0,"data-testid":"remote-access-beacon-ripple",className:"animate-beacon-ripple border-status-success pointer-events-none absolute inset-0 rounded-full border"},o)]})}),n.jsxs(fn,{side:"bottom",align:"end","aria-label":"Remote access",className:"w-72 max-w-[calc(100vw-1.5rem)] p-3",children:[n.jsx(pn,{children:Wl(e.state)}),n.jsx(XE,{onClose:()=>s(!1)})]})]}),n.jsx(GE,{})]})}function eI({work:e}){const{isDesktop:t}=Kl();return t?n.jsxs("p",{className:"text-sm font-medium",children:["Keeping awake: ",e]}):n.jsxs(pn,{className:"text-sm font-medium",children:["Keeping awake: ",e]})}function tI(){const e=od(),{open:t}=ct(),[s,r]=u.useState(!1);if(!ad(e))return null;const o=id(e.working);return n.jsxs(mn,{open:s,onOpenChange:r,children:[n.jsx(hn,{asChild:!0,children:n.jsx("button",{type:"button","data-testid":"keep-awake-beacon","aria-label":`Keeping this computer awake: ${o}. Show details`,className:"focus-ring text-muted-foreground hover:text-foreground inline-flex size-11 shrink-0 items-center justify-center rounded-md transition-colors md:size-7",children:n.jsx(Md,{className:"size-(--size-icon-sm)","aria-hidden":!0})})}),n.jsxs(fn,{side:"bottom",align:"end","aria-label":"Keeping awake",className:"w-72 max-w-[calc(100vw-1.5rem)] space-y-2 p-3",children:[n.jsx(eI,{work:o}),n.jsx("p",{className:"text-muted-foreground text-xs",children:sb}),n.jsx(F,{variant:"outline",size:"sm",onClick:()=>{r(!1),t(Oa.tab,Oa.section)},children:"Sleep settings"})]})]})}function nI(){return n.jsxs("div",{"data-slot":"global-header-actions",className:"ml-auto flex h-11 items-center justify-end gap-1 md:h-auto md:shrink-0 lg:gap-2",children:[n.jsx(KE,{}),n.jsx(ZE,{}),n.jsx(tI,{}),n.jsx(Og,{})]})}const sI="onboarding";function rI({render:e}){const t=Mg(),s=_g(),{view:r}=t,o=s.notice;return e({state:r.kind,pending:r.kind==="pending"?{userCode:r.userCode,verificationUri:r.verificationUri,...r.verificationUriComplete?{verificationUriComplete:r.verificationUriComplete}:{}}:null,starting:t.starting,startError:t.startError,start:()=>t.start({origin:sI}),cancel:t.cancel,openBilling:()=>s.open({page:"portal"}),billingPending:s.pending!==null,billingNotice:o===null?null:"message"in o?o.message:o.problem.detail??o.problem.title})}const oI={renderAccountLink:e=>n.jsx(rI,{render:e}),renderRuntimeConnect:kb,renderOtherService:({onSave:e})=>n.jsx(Sb,{onSave:e})},aI="HOST_NOT_ALLOWED",sc=240;function iI({status:e,message:t,code:s}){const r=s===aI&&t?t:void 0,o=r===void 0?`Your settings didn’t load (HTTP ${e}). DorkOS keeps trying.`:r.length>sc?`${r.slice(0,sc).trimEnd()}…`:r;return n.jsx(um,{testId:"server-error",headline:"The server answered with an error",detail:o})}function cI(e){const t=e;return{...typeof(t==null?void 0:t.status)=="number"?{status:t.status}:{},...typeof(t==null?void 0:t.message)=="string"&&t.message.length>0?{message:t.message}:{},...typeof(t==null?void 0:t.code)=="string"&&t.code.length>0?{code:t.code}:{}}}let jr={at:0};function lI(e,t){return e>jr.at&&(jr=t==null?{at:e}:{at:e,...cI(t)}),e>ln?jr:void 0}function dI(e){return e.state.dataUpdatedAt>ln?!0:"always"}function uI(e){return!e}function mI(e){var t;return((t=e.at(-1))==null?void 0:t.pathname)??""}function hI({descriptors:e}){const t=e.reduce((s,r)=>s===null||r.priority>s.priority?r:s,null);return n.jsx(Ye,{mode:"wait",initial:!1,children:t&&n.jsx(re.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.2,ease:[0,0,.2,1]},className:"shrink-0 overflow-hidden",children:t.render()},t.id)})}const fI=["memory-provider-status"],pI=6e4;function gI(){const e=ie(),{data:t}=Ee({queryKey:[...fI],queryFn:()=>e.getMemoryProviderStatus(),staleTime:pI,refetchOnWindowFocus:!0});return t}function xI(e){const t=new Map;for(const s of e){if(s.kind!=="signin.required")continue;const r=t.get(s.subject.id);(r===void 0||bI(s,r))&&t.set(s.subject.id,s)}return[...t.entries()].filter(([,s])=>s.outcome!=="cleared").map(([s])=>s)}function bI(e,t){return e.createdAt!==t.createdAt?e.createdAt>t.createdAt:e.id>t.id}function yI({configuredId:e,benched:t}){return n.jsxs(ld,{variant:"warning",children:["The ",n.jsx("span",{className:"font-medium",children:e})," memory"," ",t?"stopped answering":"isn’t set up",". DorkOS uses its own memory until you restart."]})}const vI="runtimes",wI=3;function jI({runtimes:e}){const{open:t}=ct(),s=Pg(),{nameFor:r}=Lg();if(e.length===0)return null;const o=e.map(Fg),a=o.slice(0,wI).map(l=>l.accountRoot?r(l.accountRoot):Gl(l.runtime)),i=e.length-a.length,c=`${SI(a)}${i>0?` and ${i} more`:""}`,d=o.length===1&&o[0].runtime==="claude-code"?o[0].accountRoot:void 0;return n.jsxs(ld,{variant:"critical",icon:Or,actions:n.jsxs(n.Fragment,{children:[o.length===1&&s&&n.jsx(kI,{runtimes:o.map(l=>l.runtime),renderCreditsOffer:s}),d?n.jsx(rb,{accountRoot:d,name:r(d),state:"signed-out",showAccountName:!0,hideStatus:!0}):n.jsx(F,{variant:"outline",size:"sm",onClick:()=>t(vI),children:"Review sign-ins"})]}),children:[n.jsx("span",{className:"font-medium",children:c})," ",o.length===1?"is":"are"," signed out. ",o.length===1?"Its":"Their"," agents and tasks wait until you sign in."]})}function kI({runtimes:e,renderCreditsOffer:t}){var d;const s=kc(),{data:r}=Cc(),o=!Cb(),a=((d=nl().data)==null?void 0:d.linked)===!0,i=$g(a,sl({enabled:a}).data),c=e.find(l=>Bg(zg(s.data,l),r,l)==="lead");return c?n.jsxs(mn,{children:[n.jsx(hn,{asChild:!0,children:n.jsx(F,{size:"sm","data-testid":"signin-banner-credits",disabled:i===null,children:i===null?"DorkOS credits":`${i} DorkOS credits`})}),n.jsxs(fn,{align:"end",className:"w-80 p-4",children:[n.jsxs(pn,{children:["Run ",Gl(c)," on DorkOS credits"]}),n.jsxs("div",{className:"space-y-3",children:[t({runtime:c,origin:`signin-banner:${c}`,fullWidth:!0}),n.jsx(Nb,{remote:o})]})]})]}):null}function SI(e){return e.length<=1?e[0]??"":`${e.slice(0,-1).join(", ")} and ${e[e.length-1]}`}const gm={critical:40,warning:30};function CI(){const e=gI();return!e||e.configuredId===e.activeId?null:{id:"memory-provider-benched",variant:"warning",priority:gm.warning,render:()=>n.jsx(yI,{configuredId:e.configuredId,benched:e.benched})}}const NI={kinds:["signin.required"]};function AI(){const{notifications:e}=Ug(NI),t=u.useMemo(()=>xI(e),[e]);return t.length===0?null:{id:"runtime-signin",variant:"critical",priority:gm.critical,render:()=>n.jsx(jI,{runtimes:t})}}function EI(e){const t=CI(),s=AI();return[t,s].filter(r=>r!==null)}function II(){const e=Vn(),[t,s]=u.useState(!1),r=()=>{e.mutate({telemetry:{install:!1,heartbeat:!1,usage:!1,userHasDecided:!0}})},o=()=>{e.mutate({telemetry:{install:!0,heartbeat:!0,usage:!0,userHasDecided:!0}})};return n.jsxs(n.Fragment,{children:[n.jsxs(ql,{children:[n.jsx(Yl,{children:"Share anonymous usage data?"}),n.jsx(Vl,{children:"A daily ping, package installs and feature use. Never your prompts, code or files."})]}),n.jsxs("div",{className:"space-y-3",children:[n.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1",children:[n.jsx(ob,{open:t,onToggle:()=>s(a=>!a)}),n.jsx("a",{href:Rr("/telemetry"),target:"_blank",rel:"noopener noreferrer",className:"text-muted-foreground hover:text-foreground text-xs font-medium underline underline-offset-2",children:"Full contract"})]}),t&&n.jsx(ab,{})]}),n.jsxs(Ql,{className:"items-center gap-2 sm:justify-between",children:[e.isError?n.jsx("p",{role:"alert",className:"text-destructive text-xs",children:"Couldn’t save your choice. Try again."}):n.jsx("span",{"aria-hidden":!0}),n.jsxs("div",{className:"flex justify-end gap-2",children:[n.jsx(F,{variant:"outline",size:"sm",onClick:r,disabled:e.isPending,children:"Don’t share"}),n.jsx(F,{size:"sm",onClick:o,disabled:e.isPending,children:"Share anonymously"})]})]})]})}function RI(e){return e.everyAgentLevel!==void 0?e.everyAgentLevel!==null:e.everyAgent!==null}function TI(e){const{data:t}=Ob(),s=new Set(e),r=((t==null?void 0:t.connections)??[]).filter(a=>s.has(a.connectionId)&&RI(a)),o=new Map;for(const a of r)o.set(a.toolkit,(o.get(a.toolkit)??0)+1);return r.map(a=>{const i=Kg(a.toolkit);return{connectionId:a.connectionId,name:(o.get(a.toolkit)??0)>1?`${i} (${a.label})`:i}})}function DI({apps:e,onChooseAgents:t,disabled:s}){return n.jsxs("div",{className:"space-y-1 text-sm","data-testid":"trust-notice-shared-apps",children:[n.jsx("p",{className:"text-muted-foreground",children:"Shared with every agent:"}),n.jsx("ul",{className:"space-y-0.5",children:e.map(r=>n.jsxs("li",{className:"flex items-center justify-between gap-2",children:[n.jsx("span",{children:r.name}),n.jsx(F,{variant:"link",size:"sm",className:"h-auto p-0 text-xs",disabled:s,"aria-label":`Choose agents for ${r.name}`,onClick:()=>t(r.connectionId),children:"Choose agents"})]},r.connectionId))})]})}const OI=Ml("/guides/permissions#what-changed"),MI=["Everything they do is recorded in Activity. Anyone can pause an agent.","Messages and code from strangers still need your yes."],_I="Agents ask first again. Shared apps stay shared; change them in Connections.";function PI(e){return e instanceof Error&&e.message||"Couldn’t save that. Try again."}function LI({onClose:e,sharedConnectionIds:t=[]}){return t.length>0?n.jsx(FI,{onClose:e,connectionIds:t}):n.jsx(xm,{onClose:e,sharedApps:[]})}function FI({onClose:e,connectionIds:t}){return n.jsx(xm,{onClose:e,sharedApps:TI(t)})}function xm({onClose:e,sharedApps:t}){const s=Pe(),r=Vn(),o=yb({kind:"default"}),[a,i]=u.useState(!1),[c,d]=u.useState(null),l=a||r.isPending||o.isPending,m=async(f,g)=>{d(null),i(!0);try{f&&await o.mutateAsync({kind:"preset",preset:"careful",surface:"first-run"}),await r.mutateAsync({ui:{trustNoticeSeenAt:new Date().toISOString()}})}catch(x){d(PI(x)),i(!1);return}i(!1),f&&ce.success(t.length>0?_I:"Agents ask first again. Change it in Permissions."),e(),g==null||g()},h=f=>void s({...Ne.connections(),search:{app:f,who:"picked"}}),p=f=>{if(t.length>1){e(),h(f);return}m(!1,()=>h(f))};return n.jsxs(n.Fragment,{children:[n.jsxs(ql,{children:[n.jsx(Yl,{"data-testid":"trust-notice",children:"Agents now work without asking"}),n.jsx(Vl,{children:"They edit files, run commands, schedule work and use your connected apps on their own."})]}),n.jsx("div",{className:"text-muted-foreground space-y-2 text-sm",children:MI.map(f=>n.jsx("p",{children:f},f))}),t.length>0&&n.jsx(DI,{apps:t,onChooseAgents:p,disabled:l}),c&&n.jsx("p",{role:"alert",className:"text-destructive text-xs",children:c}),n.jsxs(Ql,{className:"items-center gap-2 sm:justify-between",children:[n.jsx(Hg,{href:OI,className:"text-muted-foreground hover:text-foreground text-xs font-medium underline underline-offset-2",children:"What changed"}),n.jsxs("div",{className:"flex flex-wrap justify-end gap-2",children:[n.jsx(F,{variant:"outline",size:"sm",onClick:()=>m(!0),disabled:l,children:"Keep asking me"}),n.jsx(F,{size:"sm",onClick:()=>m(!1),disabled:l,children:"Got it"})]})]})]})}function $I(e){var s,r,o,a;return!e||!(((s=e.onboarding)==null?void 0:s.completedAt)!=null||((r=e.onboarding)==null?void 0:r.dismissedAt)!=null)||((o=e.ui)==null?void 0:o.trustNoticeSeenAt)!=null||e.callerRoute==="wifi"?!1:lb((a=e.permissions)==null?void 0:a.preset)==="trusted"}const bm={high:30,low:10};function BI(){var t;const{data:e}=Me();return(t=e==null?void 0:e.telemetry)!=null&&t.userHasDecided?null:{id:"telemetry-consent",priority:bm.low,render:()=>n.jsx(II,{})}}function zI(){const{data:e}=Me();return $I(e)?{id:"trust-notice",priority:bm.high,render:({onClose:t})=>{var s;return n.jsx(LI,{onClose:t,sharedConnectionIds:((s=e==null?void 0:e.permissions)==null?void 0:s.sharedAtUpgrade)??[]})}}:null}function UI(){const e=zI(),t=BI();return L(r=>r.onboardingHiddenForSession)?[]:[e,t].filter(r=>r!==null)}function KI(e){return e.reduce((t,s)=>t===null||s.priority>t.priority?s:t,null)}function HI({onboardingOverlayVisible:e=!1}){const t=UI(),{data:s,dataUpdatedAt:r}=Me(),o=L(b=>b.momentShownThisLaunch),a=L(b=>b.markMomentShown),[i,c]=u.useState(null),[d,l]=u.useState(null),m=u.useRef(null),h=(s==null?void 0:s.onboarding)!=null&&(s.onboarding.completedAt!=null||s.onboarding.dismissedAt!=null),p=r>ln,f=e||!p||!h,g=f?null:KI(t);i===null&&g!==null&&!o&&(c(g.id),l(g)),u.useEffect(()=>{i!==null&&a()},[i,a]);const x=!f&&i!==null&&t.some(b=>b.id===i),y=()=>c(null);return n.jsx(Wg,{open:x,onOpenChange:b=>{b||y()},children:d!==null&&n.jsx(Gg,{ref:m,onOpenAutoFocus:b=>{var C;b.preventDefault(),(C=m.current)==null||C.focus()},children:d.render({onClose:y})},d.id)})}function WI({slotKey:e,direction:t,children:s}){return n.jsx("div",{className:"relative flex min-h-0 flex-1 flex-col overflow-hidden",children:n.jsx(Ye,{mode:"wait",initial:!1,custom:t,children:n.jsx(re.div,{"data-testid":"sidebar-body-swap",custom:t,initial:"enter",animate:"center",exit:"exit",variants:{enter:r=>({x:`${r*100}%`,opacity:0}),center:{x:0,opacity:1},exit:r=>({x:`${r*-100}%`,opacity:0})},transition:{duration:.2,ease:[.4,0,.2,1]},className:"flex min-h-0 flex-1 flex-col overflow-hidden",children:s},e)})})}function GI(){const{approvals:e,isError:t,retry:s}=qg(),{interactions:r}=Yg(),o=Vg(),a=Qg(e),{schedules:i}=Xg(),c=Jg(i),d=Zg(r),l=Xl(),m=Pe(),h=u.useMemo(()=>{const g=new Set([...e.map(x=>ex(x.approvalId)),...r.map(x=>tx(x.interaction.id))]);return l.filter(x=>x.kind!=="schedule-approval"&&!g.has(x.id))},[l,e,r]),p=e.length+r.length+i.length+h.length;return!t&&a.length===0&&r.length===0&&o.length===0&&c.length===0&&h.length===0?{slot:null,count:p}:{count:p,slot:n.jsxs("div",{"data-testid":"mobile-now-attention",className:"flex flex-col gap-2 px-2 pt-0.5 pb-1",children:[t&&n.jsx(nx,{onRetry:s}),(r.length>0||o.length>0)&&n.jsx(sx,{asks:r,agentNames:d,onOpenSession:g=>{m(Rt({session:g}))}}),a.length>0&&n.jsx(rx,{approvals:a}),n.jsx(Ye,{initial:!1,children:c.map(g=>n.jsx(ox,{task:g},g.id))}),h.length>0&&n.jsx("div",{"data-testid":"mobile-now-rows",className:"flex flex-col",children:h.map(g=>n.jsx(jy,{signal:g},g.id))})]})}}const ym=[{id:"home",label:"Home",icon:ax,badged:!0,kind:"panel"},{id:"dorkbot",label:"DorkBot",icon:To,badged:!1,kind:"action"},{id:"you",label:"You",icon:mo,badged:!1,kind:"panel"}],to="calc(3.5rem + env(safe-area-inset-bottom))",As=ix(e=>({panelUp:!1,raise:()=>e({panelUp:!0}),lower:()=>e({panelUp:!1})}));function rc(){As.getState().lower()}const qI=1e3;function YI(e){if(e!==0)return e===1?"1 agent needs you":`${e} agents need you`}function VI(e){const[t,s]=u.useState(""),r=u.useRef(t);return u.useEffect(()=>{const o=e??"";if(o===r.current)return;const a=setTimeout(()=>{r.current=o,s(o)},qI);return()=>clearTimeout(a)},[e]),t}function QI({current:e,needsYouCount:t,dorkBotReady:s,onSelect:r,label:o="Main"}){return n.jsx("nav",{"aria-label":o,"data-testid":"mobile-tab-bar",className:"bg-sidebar flex shrink-0 items-stretch",style:{height:to,paddingBottom:"env(safe-area-inset-bottom)"},children:ym.map(a=>{const i=a.icon,c=a.id===e,d=a.badged&&t>0?t:null,l=a.kind==="action"&&!s;return n.jsxs("button",{type:"button",onClick:()=>r(a.id),disabled:l,"aria-current":c?"page":void 0,"data-testid":`mobile-tab-${a.id}`,"data-mobile-tab":"",className:K("focus-ring text-2xs relative flex flex-1 flex-col items-center justify-center gap-0.5 transition-[color,background-color,scale] duration-150","active:bg-sidebar-accent motion-safe:active:scale-[0.96]",c?"text-sidebar-foreground font-semibold":"text-sidebar-foreground/70 hover:text-sidebar-foreground font-medium","disabled:pointer-events-none disabled:opacity-50"),children:[n.jsxs("span",{className:"relative",children:[n.jsx(i,{className:"size-5","aria-hidden":!0}),d!==null&&n.jsx(Us,{"data-testid":`mobile-tab-badge-${a.id}`,count:d,tone:"warning",placement:"corner",solid:!0,className:"-top-1.5 -right-2.5"})]}),a.label]},a.id)})})}function oc({id:e,active:t,children:s}){return n.jsx("div",{id:`mobile-tab-panel-${e}`,"data-testid":`mobile-tab-panel-${e}`,"data-active":t?"":void 0,inert:!t,className:K("absolute inset-0",!t&&"invisible"),children:s})}function XI({takeover:e}){Uu();const t=GI(),s=Wu(),r=Ku(s),{ask:o,ready:a}=cx(),[i,c]=u.useState("home"),d=As(g=>g.panelUp),l=As(g=>g.raise),m=Xt();u.useEffect(()=>m.subscribe("onBeforeLoad",rc),[m]),u.useEffect(()=>rc,[]),u.useEffect(()=>(document.documentElement.style.setProperty("--mobile-tab-dock",to),()=>{document.documentElement.style.removeProperty("--mobile-tab-dock")}),[]);const h=u.useCallback(g=>{const x=ym.find(y=>y.id===g);if(x!==void 0){if(x.kind==="action"){if(!a)return;c(g),o();return}c(g),l()}},[o,a,l]),p=t.count,f=VI(YI(p));return n.jsxs(Al,{activeTarget:s.activeTarget,children:[n.jsxs("div",{"data-testid":"mobile-tab-panels",inert:!d,className:K("bg-background fixed inset-x-0 top-0 z-30",!d&&"pointer-events-none invisible"),style:{bottom:`calc(${to} + var(--pip-dock, 0px))`},children:[n.jsx(oc,{id:"home",active:i==="home",children:n.jsxs(Pa,{width:"full",className:"px-2 py-2",children:[n.jsx(sm,{}),t.slot,e??n.jsx(Zu,{model:r}),n.jsx(zu,{})]})}),n.jsx(oc,{id:"you",active:i==="you",children:n.jsxs(Pa,{width:"full",className:"px-4 py-4",children:[n.jsx("h1",{className:"text-foreground px-2 pb-2 text-sm font-semibold",children:"You"}),n.jsx(RA,{}),n.jsx(Jl,{})]})})]}),n.jsx("span",{"data-testid":"mobile-needs-you-live-region","aria-live":"polite","aria-atomic":"true",className:"sr-only",children:f}),n.jsx(QI,{current:d?i:null,needsYouCount:p,dorkBotReady:a,onSelect:h})]})}function JI(){const e=ie(),t=le();return Qt({mutationFn:s=>e.createAgent(s),onSuccess:()=>{t.invalidateQueries({queryKey:["agents"]}),t.invalidateQueries({queryKey:["mesh","agents"]}),t.invalidateQueries({queryKey:["mesh","agent-paths"]}),t.invalidateQueries({queryKey:["team"]})},meta:{errorLabel:"Couldn’t create that agent",isShownInline:s=>{var r;return((r=s.body)==null?void 0:r.code)==="template_needs_review"}}})}async function ZI(e,t){try{return(await e.browseDirectory(t)).entries.some(r=>r.name===".dork")?"exists-has-dork":"exists-no-dork"}catch(s){const r=s instanceof Error?s.message:"";return r.includes("EACCES")||r.includes("permission")?"error":"no-path"}}function eR({step:e,templateName:t,seedDisplayName:s=null,faceSeed:r=null,runtimeSeed:o="claude-code"}){var pe;const a=ie(),{data:i}=Ee({queryKey:Fe.current(),queryFn:()=>a.getConfig(),staleTime:3e4}),c=((pe=i==null?void 0:i.agents)==null?void 0:pe.defaultDirectory)??"",[d,l]=u.useState(""),[m,h]=u.useState(!1),[p,f]=u.useState(""),[g,x]=u.useState(!1),[y,b]=u.useState(!1),[C,k]=u.useState(null),[I,v]=u.useState(""),[E,R]=u.useState(!1),[_,D]=u.useState(o),[P,T]=u.useState(s);s!==P&&(T(s),s&&(l(s),h(!1)));const[j,w]=u.useState(o);o!==j&&(w(o),D(o));const N=u.useMemo(()=>d?lx(d):"",[d]),S=u.useMemo(()=>N?dx(N):{valid:!1,error:void 0},[N]),M=d.length>0&&N.length>0&&!S.valid,B=p||(c&&N?`${c}/${N}`:""),O=e!=="naming"||!B?"idle":C!==null&&C.directory===B?C.status:"checking",$=d.length>0&&S.valid&&O!=="error",G=u.useRef(null);u.useEffect(()=>{if(e!=="naming")return;const Q=t?!d||m?t.replace(/^@[^/]+\//,""):null:m?"":null;if(Q===null)return;const q=`${e}|${t??""}`;G.current!==q&&(G.current=q,l(Q),h(!!t))},[e,t]);const ee=u.useRef(null);u.useEffect(()=>{if(e!=="naming"||E||!r)return;const Q=`${e}|${r}`;ee.current!==Q&&(ee.current=Q,v(r))},[e,r]),u.useEffect(()=>{if(e!=="naming"||!B)return;const Q=B,q=setTimeout(()=>{ZI(a,Q).then(ne=>{k({directory:Q,status:ne})})},500);return()=>clearTimeout(q)},[e,B,a]);function z(Q){l(Q),m&&h(!1)}function V(Q){v(Q),R(!0)}function ae(){G.current=null,ee.current=null,l(""),h(!1),f(""),x(!1),b(!1),k(null),v(""),R(!1),D(o)}return{displayName:d,slug:N,handleNameChange:z,nameAutoFilled:m,slugValidation:S,showSlugError:M,defaultDirectory:c,resolvedDirectory:B,directoryOverride:p,setDirectoryOverride:f,directoryOpen:g,setDirectoryOpen:x,directoryPickerOpen:y,setDirectoryPickerOpen:b,conflictStatus:O,canSubmit:$,icon:I,setIcon:V,runtime:_,setRuntime:D,reset:ae}}function tR(e){var a;const t=(e==null?void 0:e.packageName)??null,{data:s,isError:r,error:o}=Dy(t,e!=null&&e.marketplace?{marketplace:e.marketplace}:void 0);return{schedules:((a=s==null?void 0:s.preview)==null?void 0:a.schedules)??[],isChecking:t!==null&&s===void 0&&!r,failed:t!==null&&r,...t!==null&&r&&Oy(o)&&{refusal:o},...s!=null&&s.disclosed&&s.contentHash?{approval:{approvedDisclosure:s.disclosed,approvedContentHash:s.contentHash},packageAgentName:s.manifest.name}:{}}}const nR={gallery:{title:"New agent",description:"What will your agent do?"},naming:{title:"Name your agent",description:"Give it a name and a face."},arrival:{description:"Add a ready-made agent."}},kr={keeper:["Keeper","Warden","Steward","Curator","Archivist","Ledger","Tally","Sorter"],scout:["Scout","Ranger","Pathfinder","Lookout","Recon","Probe","Tracer","Radar"],guardian:["Sentinel","Guardian","Aegis","Bastion","Vigil","Auditor","Gatekeep","Warden"],builder:["Forge","Smith","Builder","Mason","Wright","Maker","Anvil","Crafter"],scribe:["Scribe","Quill","Muse","Author","Penn","Bard","Editor","Note"],default:["Scout","Sage","Pilot","Beacon","Atlas","Nova","Ranger","Echo","Vera","Onyx"]},sR=[["keeper",["board","organize","tidy","manage","linear","jira","project","backlog","task"]],["scout",["research","search","monitor","watch","discover","scan","find","intel","inbox","email","mail"]],["guardian",["review","security","audit","qa","test","lint","guard","protect","compliance"]],["builder",["build","code","scaffold","deploy","engineer","refactor","ci","release"]],["scribe",["doc","write","content","blog","summar","note","changelog","copy"]]];function rR(e){if(!e)return kr.default;const t=[e.name,e.description,e.category,...e.tags??[]].filter(Boolean).join(" ").toLowerCase();for(const[s,r]of sR)if(r.some(o=>t.includes(o)))return kr[s];return kr.default}function oR(e,t,s){if(e.length===0)return[];const r=Math.min(s,e.length),o=(t%e.length+e.length)%e.length;return Array.from({length:r},(a,i)=>e[(o+i)%e.length])}const aR=64,iR=16,ac=3;function cR(e){return e.map(t=>t.replace(/[\u0000-\u001f\u007f]/g," ").replace(/\s+/g," ").trim().slice(0,aR)).filter(t=>t.length>0).slice(0,iR)}function lR(e){const t=cR(e.capabilities??[]),s=t.length>0?`
77
-
78
- Your declared abilities include: ${t.join(", ")}. Draw your first-action offer from these when it fits.`:"";return["You have just been created. This is your first moment awake — greet the person who made you.","",`Read your ${sn.soul} to recall who you are, then, in 2 to 4 short sentences:`,"- Introduce yourself in your own voice, drawn from that persona.","- State plainly what your job is.","- Propose one concrete first action you could take — as an offer, and wait for their go-ahead.","",`Do NOT start any work yet — do not act on the project or change any files. (Reading your own ${sn.soul} so you can introduce yourself is fine; anything beyond that waits for their go-ahead.) Just make the offer and let them decide. Speak warmly and directly to the person.`+s].join(`
79
- `)}function dR(e){return[`You have just been created${e.displayName?` and named ${e.displayName}`:""}, and you do not have a job yet — the person who made you will define it with you, right now, in this conversation. This is your first moment awake, and by the end of it you will have written your own ${sn.soul}.`,"","Run a short interview to discover who you should be, then capture it:","","1. Say a brief, warm hello (1 to 2 sentences) and ask them what they would like you to take care of. Do not assume a role yet.","",`2. Hold a SHORT interview. Ask AT MOST ${ac} questions in total across this whole conversation — this is a hard limit. Only ask what you genuinely need to write a good soul (typically the scope of the work, how often you should do it, and anything you must never touch). If their first answer already tells you enough, ask fewer. For a one-word or vague answer, ask a single clarifying question and then proceed with a reasonable role rather than interrogating them. If they say something like "just figure it out," do not push — propose a sensible role from what you have and move on. Never trap them in endless back-and-forth: once you have asked ${ac} questions, stop asking and write your best soul from what you learned.`,"","3. Before you write, tell them in one line what you understood and that you are about to capture it as your soul — so they see it coming. Then write it.","",`4. Write your ${sn.soul} now, using your file-editing tools. It lives at \`.dork/${sn.soul}\` in your working directory and already contains a "Personality Traits" block fenced by \`${ux}\` and \`${Ta}\` — leave that fenced block exactly as it is. Replace only the prose BELOW the \`${Ta}\` marker with your persona: who you are in your own voice, what you take care of, how you go about it, and the boundaries you keep. Keep it concise.`,"","5. After the file is written, confirm it in one or two sentences and propose ONE concrete first action you could take — as an offer, and wait for their go-ahead.","",`Do not start the actual job yet — your own ${sn.soul} is the only file you touch now. Do not act on their project or run their work until they say go. Speak warmly and directly to the person throughout.`].join(`
80
- `)}const uR={template:lR,"design-your-own":dR};function mR(e,t){return uR[e](t)}function hR(e,t){return Lb(mR(e,t))}const vm="🤖",fR=["🤖","🦾","🧭","🛰️","📡","🔭","🗺️","🧠","🦉","🦊","🐝","🐙","🚀","⚡","🌟","🔮","🛠️","🔧","📊","📋","✅","🗂️","🔔","🛡️"];function ic({face:e,title:t,subtitle:s,chips:r,variant:o,tabIndex:a,onSelect:i,onKeyDown:c,ref:d,"data-testid":l}){return n.jsxs("button",{ref:d,type:"button",tabIndex:a,onClick:i,onKeyDown:c,"data-gallery-card":"","data-testid":l,className:K("card-interactive group flex h-full flex-col gap-2 rounded-xl border p-4 text-left","focus-visible:ring-ring focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none",o==="design"?"border-primary/40 bg-primary/5 hover:border-primary/60 border-dashed":"bg-card hover:border-border/80 hover:shadow-md"),children:[n.jsx("span",{className:"text-3xl leading-none","aria-hidden":!0,children:e}),n.jsxs("div",{className:"space-y-0.5",children:[n.jsx("p",{className:"text-sm font-semibold",children:t}),n.jsx("p",{className:"text-muted-foreground text-xs leading-relaxed",children:s})]}),r&&r.length>0&&n.jsx("div",{className:"mt-auto flex flex-wrap gap-1 pt-1",children:r.map(m=>n.jsx("span",{className:"bg-muted text-muted-foreground text-2xs rounded-full px-2 py-0.5",children:m},m))})]})}function pR(e){return{source:e.source,name:e.name,displayName:Zl(e),description:e.description,icon:e.icon,tags:e.tags,category:e.category,packageName:e.name,...e.marketplace?{marketplace:e.marketplace}:{}}}function gR(e){return e.tags&&e.tags.length>0?e.tags.slice(0,2):e.category?[e.category]:[]}function xR(e){const t=e.replace(/\/+$/,"");return t.split("/").pop()??t}function bR({onDesignYourOwn:e,onSelectTemplate:t,onImport:s}){const{data:r,error:o,isLoading:a}=mx(),i=pd(a),[c,d]=u.useState(""),[l,m]=u.useState(!1),h=u.useMemo(()=>(r??[]).filter(f=>f.type==="agent"),[r]),p=Cv(h.length+1);return n.jsxs("div",{className:"space-y-5",children:[n.jsxs("div",{role:"group","aria-label":"Choose what your agent will do",className:"grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4","data-testid":"agent-gallery",children:[n.jsx(ic,{ref:p.setRef(0),variant:"design",face:n.jsx(To,{className:"text-primary size-7"}),title:"Design your own",subtitle:"Describe the job in your own words.",tabIndex:p.tabIndexFor(0),onSelect:e,onKeyDown:f=>p.handleKeyDown(f,0),"data-testid":"gallery-design-your-own"}),h.map((f,g)=>{const x=g+1;return n.jsx(ic,{ref:p.setRef(x),variant:"template",face:f.icon??vm,title:Zl(f),subtitle:f.description??"A ready-made agent.",chips:gR(f),tabIndex:p.tabIndexFor(x),onSelect:()=>t(pR(f)),onKeyDown:y=>p.handleKeyDown(y,x),"data-testid":`gallery-template-${f.name}`},f.name)}),i&&h.length===0&&Array.from({length:2}).map((f,g)=>n.jsx(mt,{className:"h-28 rounded-xl","data-testid":"gallery-skeleton"},g))]}),!i&&h.length===0&&n.jsx("p",{className:"text-muted-foreground text-center text-xs","data-testid":"gallery-templates-note",children:o?"Couldn’t load ready-made agents. Check marketplace sources in Settings.":"No ready-made agents yet. Add a marketplace source in Settings."}),n.jsxs(Do,{open:l,onOpenChange:m,children:[n.jsx(Oo,{asChild:!0,children:n.jsxs("button",{type:"button",className:"text-muted-foreground hover:text-foreground flex items-center gap-1 text-xs transition-colors","data-testid":"advanced-toggle",children:[n.jsx(Zt,{className:K("size-3.5 transition-transform",l&&"rotate-180")}),"Build from a template URL"]})}),n.jsx(Mo,{children:n.jsxs("div",{className:"flex items-center gap-2 pt-2",children:[n.jsx(yt,{value:c,onChange:f=>d(f.target.value),placeholder:"github.com/org/repo","data-testid":"custom-url-input",className:"flex-1"}),n.jsx(F,{size:"sm",disabled:!c,onClick:()=>{const f=xR(c);t({source:c,name:f,displayName:hx(f)}),d("")},"data-testid":"custom-url-go",children:"Continue"})]})})]}),s&&n.jsx("div",{className:"border-t pt-3",children:n.jsxs("button",{type:"button",onClick:s,className:"text-muted-foreground hover:text-foreground inline-flex items-center gap-1.5 text-sm transition-colors","data-testid":"gallery-import-link",children:[n.jsx(fx,{className:"size-4"}),"Bring in an existing project folder",n.jsx("span",{"aria-hidden":!0,children:"→"})]})})]})}function yR({value:e,onChange:t}){return n.jsx("div",{role:"group","aria-label":"Choose a face",className:"flex flex-wrap gap-1.5","data-testid":"face-picker",children:fR.map(s=>{const r=s===e;return n.jsx("button",{type:"button","aria-label":`Face ${s}`,"aria-pressed":r,onClick:()=>t(s),className:K("flex size-9 items-center justify-center rounded-md border text-lg transition-colors","focus-visible:ring-ring focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none",r?"border-primary bg-primary/10":"hover:border-border hover:bg-accent border-transparent"),"data-testid":`face-${s}`,children:n.jsx("span",{"aria-hidden":!0,children:s})},s)})})}function vR({value:e,onChange:t}){return n.jsx("div",{role:"radiogroup","aria-label":"Runs on",className:"flex gap-1.5","data-testid":"runtime-picker",children:px.map(s=>{const r=dt(s),o=r.icon,a=e===s;return n.jsxs("button",{type:"button",role:"radio","aria-checked":a,onClick:()=>t(s),className:K("flex flex-1 items-center justify-center gap-1.5 rounded-md border px-2 py-1.5 text-xs transition-colors","focus-visible:ring-ring focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none",a?"border-primary bg-primary/10 font-medium":"hover:border-border hover:bg-accent border-transparent"),"data-testid":`runtime-${s}`,children:[n.jsx(o,{size:14}),r.label]},s)})})}function wR({face:e,name:t,jobLine:s,capabilities:r,className:o}){const a=t.trim()||"Your agent",i=t.trim().length===0;return n.jsxs("div",{className:K("bg-card shadow-soft flex flex-col items-center gap-3 rounded-lg border p-5",o),"data-testid":"agent-preview",children:[n.jsx("span",{className:"bg-primary/10 flex size-16 items-center justify-center rounded-full text-3xl","aria-hidden":!0,children:e}),n.jsxs("div",{className:"space-y-1 text-center",children:[n.jsx("p",{className:K("text-lg font-semibold",i&&"text-muted-foreground"),"data-testid":"preview-name",children:a}),n.jsx("p",{className:"text-muted-foreground text-sm leading-relaxed",children:s})]}),r.length>0&&n.jsx("div",{className:"flex flex-wrap justify-center gap-1.5","data-testid":"preview-capabilities",children:r.map(c=>n.jsx("span",{className:"bg-muted text-muted-foreground rounded-full px-2 py-0.5 text-xs",children:c},c))})]})}function wm({schedules:e,checkFailed:t,testIdPrefix:s}){return n.jsxs(n.Fragment,{children:[e.length>0&&n.jsxs("div",{className:"flex items-start gap-2","data-testid":`${s}-package-schedules`,children:[n.jsx(_o,{className:"text-muted-foreground mt-0.5 size-4 shrink-0"}),n.jsx("dt",{className:"text-muted-foreground shrink-0",children:"Brings a schedule"}),n.jsx("dd",{className:"min-w-0 space-y-1",children:e.map((r,o)=>n.jsxs("p",{children:[n.jsx("span",{className:"font-medium",children:r.name}),": ",My(r)]},`${r.name}-${o}`))})]}),t&&n.jsxs("div",{className:"flex items-start gap-2","data-testid":`${s}-offer-check-failed`,children:[n.jsx(pc,{className:"text-status-warning-dot mt-0.5 size-4 shrink-0"}),n.jsx("dt",{className:"text-muted-foreground shrink-0",children:"Not checked"}),n.jsx("dd",{className:"min-w-0",children:"Couldn’t check for scheduled work. Anything it brings still needs your approval."})]})]})}const cc=4;function jR({form:e,suggestionPool:t,jobLine:s,previewCapabilities:r,onBack:o,onImportInstead:a,onCreate:i,isCreating:c,packageSchedules:d=[],offerCheckFailed:l=!1,isCheckingOffer:m=!1,offerRefusal:h,packageDirectory:p,templateReview:f,inheritance:g,isCheckingInheritance:x=!1}){const y=u.useRef(null),[b,C]=u.useState(0),k=e.displayName.trim().toLowerCase(),I=t.filter(_=>_.toLowerCase()!==k),v=oR(I,b,cc);u.useEffect(()=>{const _=setTimeout(()=>{var D;return(D=y.current)==null?void 0:D.focus()},160);return()=>clearTimeout(_)},[]);const E=e.displayName.trim(),R=c?`Creating ${E||"your agent"}…`:`Create ${E||"agent"}`;return n.jsxs("div",{className:"grid gap-6 md:grid-cols-2",children:[n.jsxs("div",{className:"space-y-5",children:[n.jsxs("button",{type:"button",onClick:o,className:"text-muted-foreground hover:text-foreground -ml-1 inline-flex items-center gap-1 text-xs transition-colors","data-testid":"naming-back",children:[n.jsx(Jc,{className:"size-3.5"}),"Choose a different agent"]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(He,{htmlFor:"agent-name",className:"text-sm",children:"Name"}),n.jsx(yt,{ref:y,id:"agent-name",placeholder:"Name your agent",value:e.displayName,onChange:_=>e.handleNameChange(_.target.value),"aria-invalid":e.showSlugError,"aria-describedby":e.showSlugError?"agent-name-error":void 0,className:"h-11 text-base"}),e.showSlugError&&n.jsx("p",{id:"agent-name-error",className:"text-destructive text-xs",role:"alert",children:e.slugValidation.error}),e.conflictStatus==="exists-has-dork"&&n.jsxs("div",{"data-testid":"conflict-status",children:[n.jsx("p",{className:"text-status-warning-fg text-xs font-medium",children:"This folder has a project"}),a&&n.jsx("button",{type:"button",className:"text-primary text-xs hover:underline",onClick:a,"data-testid":"import-instead-link",children:"Import it instead"})]})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx("span",{className:"text-muted-foreground text-xs",children:"Need a name?"}),n.jsx("button",{type:"button",onClick:()=>C(_=>_+cc),"aria-label":"Show other names",className:"text-muted-foreground hover:text-foreground focus-visible:ring-ring rounded text-sm transition-colors focus-visible:ring-2 focus-visible:outline-none","data-testid":"suggestion-reroll",children:n.jsx("span",{"aria-hidden":!0,children:"🎲"})})]}),n.jsx("div",{className:"flex flex-wrap gap-1.5","data-testid":"name-suggestions",children:v.map(_=>n.jsx("button",{type:"button",onClick:()=>e.handleNameChange(_),className:"bg-muted hover:bg-accent focus-visible:ring-ring rounded-full px-2.5 py-1 text-xs transition-colors focus-visible:ring-2 focus-visible:outline-none","data-testid":`suggestion-${_}`,children:_},_))})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsxs("div",{className:"flex items-baseline gap-2",children:[n.jsx(He,{className:"text-sm",children:"Face"}),!e.icon&&n.jsx("span",{className:"text-muted-foreground text-xs",children:"Picked for you if skipped"})]}),n.jsx(yR,{value:e.icon,onChange:e.setIcon})]}),n.jsxs(Do,{open:e.directoryOpen,onOpenChange:e.setDirectoryOpen,children:[n.jsx(Oo,{asChild:!0,children:n.jsxs("button",{type:"button",className:"text-muted-foreground hover:text-foreground flex w-full items-center gap-1 text-sm transition-colors","data-testid":"details-toggle",children:[n.jsx(Zt,{className:K("size-4 transition-transform",e.directoryOpen&&"rotate-180")}),"Details",e.directoryOverride&&n.jsx("span",{className:"bg-primary/10 text-primary ml-1 rounded px-1.5 py-0.5 text-xs",children:"Custom"})]})}),n.jsx(Mo,{children:n.jsxs("div",{className:"space-y-4 pt-3",children:[n.jsxs("div",{className:"space-y-1.5",children:[n.jsx(He,{className:"text-muted-foreground text-xs",children:"Runs on"}),n.jsx(vR,{value:e.runtime,onChange:e.setRuntime})]}),p?n.jsxs("div",{className:"space-y-1.5","data-testid":"package-directory",children:[n.jsx(He,{className:"text-muted-foreground text-xs",children:"Directory"}),n.jsx("p",{className:"font-mono text-xs [overflow-wrap:anywhere]",children:p}),n.jsx("p",{className:"text-muted-foreground text-xs",children:"Kept in its package’s folder so updates reach it."})]}):n.jsxs("div",{className:"space-y-1.5",children:[n.jsx(He,{htmlFor:"agent-directory",className:"text-muted-foreground text-xs",children:"Directory"}),n.jsx(_y,{id:"agent-directory",placeholder:e.resolvedDirectory||(e.defaultDirectory?`${e.defaultDirectory}/…`:""),value:e.directoryOverride,onChange:e.setDirectoryOverride,onBrowse:()=>e.setDirectoryPickerOpen(!0),browseTestId:"browse-directory-button","data-testid":"directory-preview"}),e.conflictStatus==="no-path"&&n.jsx("p",{className:"text-muted-foreground text-xs","data-testid":"conflict-status",children:"Creates a new folder"}),e.conflictStatus==="exists-no-dork"&&n.jsx("p",{className:"text-muted-foreground text-xs","data-testid":"conflict-status",children:"That folder is already there. The project goes inside it."}),e.conflictStatus==="error"&&n.jsx("p",{className:"text-destructive text-xs","data-testid":"conflict-status",children:"Can’t open this folder. Pick another."})]}),!p&&e.slug&&!e.showSlugError&&n.jsxs("p",{className:"text-muted-foreground text-xs",children:["Folder name:"," ",n.jsx("code",{className:"bg-muted rounded px-1 py-0.5 font-mono text-xs",children:e.slug})]})]})})]})]}),n.jsxs("div",{className:"flex flex-col gap-4 self-start",children:[n.jsx(wR,{face:e.icon||vm,name:e.displayName,jobLine:s,capabilities:r}),(d.length>0||l)&&n.jsx("dl",{className:"bg-muted/30 space-y-2.5 rounded-lg border p-3.5 text-sm",children:n.jsx(wm,{schedules:d,checkFailed:l,testIdPrefix:"naming"})}),h!==void 0&&n.jsx(Ed,{error:h}),f,m&&n.jsx("p",{className:"text-muted-foreground text-center text-xs","data-testid":"naming-checking-offer",children:"Checking for scheduled work…"}),g,n.jsx(F,{size:"lg",onClick:i,disabled:!e.canSubmit||c||m||x||h!==void 0,"data-testid":"create-button",children:R})]})]})}function kR({seed:e,packageSchedules:t,isCheckingOffer:s,offerCheckFailed:r,offerRefusal:o,resolvedDirectory:a,canSubmit:i,isCreating:c,inheritance:d,isCheckingInheritance:l=!1,onCreate:m,onCustomize:h,onNotNow:p}){const{displayName:f,persona:g,runtime:x,capabilities:y,skills:b,schedule:C,icon:k}=e.template,I=dt(x??"claude-code").label,v=f.trim().charAt(0).toUpperCase()||"?",E=k&&_r(k)?k:v,R=e.sourceLabel?`Offered by ${e.sourceLabel}.`:"A ready-made agent.";return n.jsxs("div",{className:"mx-auto max-w-md space-y-6","data-testid":"arrival-confirm",children:[n.jsxs("div",{className:"flex flex-col items-center gap-3 text-center",children:[n.jsx("span",{className:"bg-primary/10 text-primary flex size-20 items-center justify-center rounded-full text-4xl font-semibold","aria-hidden":"true",children:E}),n.jsxs("div",{className:"space-y-1",children:[n.jsxs(ot,{className:"text-xl",children:["Meet ",f]}),n.jsx(xt,{children:R})]})]}),g&&n.jsx("p",{className:"text-foreground text-sm leading-relaxed whitespace-pre-line",children:g}),n.jsxs("dl",{className:"bg-muted/30 space-y-2.5 rounded-lg border p-3.5 text-sm",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(SR,{runtime:x}),n.jsx("dt",{className:"text-muted-foreground shrink-0",children:"Runs on"}),n.jsx("dd",{children:I})]}),n.jsxs("div",{className:"flex items-start gap-2",children:[n.jsx(Ds,{className:"text-muted-foreground mt-0.5 size-4 shrink-0"}),n.jsx("dt",{className:"text-muted-foreground shrink-0",children:"Lives in"}),n.jsx("dd",{className:"min-w-0",children:a?n.jsx("code",{className:"text-xs break-all",children:a}):n.jsx(mt,{className:"h-3.5 w-48 max-w-full rounded"})})]}),C&&n.jsxs("div",{className:"flex items-start gap-2","data-testid":"arrival-schedule",children:[n.jsx(_o,{className:"text-muted-foreground mt-0.5 size-4 shrink-0"}),n.jsx("dt",{className:"text-muted-foreground shrink-0",children:"Runs on a schedule"}),n.jsx("dd",{children:C})]}),n.jsx(wm,{schedules:t,checkFailed:r,testIdPrefix:"arrival"}),y&&y.length>0&&n.jsxs("div",{className:"flex items-start gap-2",children:[n.jsx(ib,{className:"text-muted-foreground mt-0.5 size-4 shrink-0"}),n.jsx("dt",{className:"text-muted-foreground shrink-0",children:"Can"}),n.jsx("dd",{children:y.join(", ")})]}),b&&b.length>0&&n.jsxs("div",{className:"flex items-start gap-2",children:[n.jsx(gx,{className:"text-muted-foreground mt-0.5 size-4 shrink-0"}),n.jsx("dt",{className:"text-muted-foreground shrink-0",children:"Uses skills"}),n.jsx("dd",{children:b.join(", ")})]})]}),o!==void 0&&n.jsx(Ed,{error:o}),n.jsxs("div",{className:"flex flex-col gap-2",children:[!i&&n.jsx("p",{className:"text-status-warning-fg text-center text-xs","data-testid":"arrival-needs-name",children:"Needs a name. Choose “Customize first” to add one."}),s&&n.jsx("p",{className:"text-muted-foreground text-center text-xs","data-testid":"arrival-checking-offer",children:"Checking for scheduled work…"}),d,n.jsx(F,{size:"lg",onClick:m,disabled:c||!i||s||l||o!==void 0,"data-testid":"arrival-create",children:c?"Creating…":`Create ${f}`}),n.jsxs("div",{className:"flex items-center justify-center gap-4",children:[n.jsx(F,{variant:"ghost",size:"sm",onClick:h,className:"text-muted-foreground","data-testid":"arrival-customize",children:"Customize first"}),n.jsx(F,{variant:"ghost",size:"sm",onClick:p,className:"text-muted-foreground","data-testid":"arrival-not-now",children:"Not now"})]})]})]})}function SR({runtime:e}){const t=dt(e??"claude-code").icon;return n.jsx(t,{size:16,className:"text-muted-foreground shrink-0"})}function CR(e){const t=e==null?void 0:e.body;return(t==null?void 0:t.code)==="template_needs_review"?t.template:void 0}function NR(e,t){const s=e.replace(/\/*$/,"/");return t.filter(r=>r.path===e||r.path.startsWith(s))}function AR(e){return e.omitted==="link"?"A link. It isn’t copied into the agent.":e.omitted==="not-text"?`Not text (${e.bytes} bytes).`:`Too long to show (${e.bytes} bytes). Read it in the template first.`}function ER(e){const t=(e.settings??[]).filter(s=>s.omitted==="too-long"||s.omitted==="not-text");return t.length===0?"Create with these":t.length===1?`Create without seeing ${t[0].path}`:`Create without seeing ${t.length} files`}function IR(e){const{disclosed:t}=e;return[...e.findings.map(s=>({key:`finding:${s.path}`,label:s.path,detail:"Settings the agent loads: hooks, permission rules or servers.",files:NR(s.path,e.settings??[])})),...t.hooks.map((s,r)=>({key:`hook:${r}`,label:ft(s.command),detail:`Runs on ${s.event}${s.source?`, while ${ft(s.source)} is in use`:""}.`})),...(t.skillCommands??[]).map((s,r)=>({key:`command:${s.source}:${r}`,label:ft(s.command),detail:`Runs when skill “${ft(s.skill)}” is used (${ft(s.source)})`+(s.usesArguments?". Reads the text typed after it.":".")})),...t.mcpServers.map(s=>({key:`mcp:${s.name}`,label:s.command?bx(s.command,s.args):ft(s.url??s.name),detail:`Starts the MCP server “${ft(s.name)}”.`})),...t.skillTools.map(s=>({key:`tools:${s.source}`,label:s.tools.map(ft).join(", "),detail:`Skill “${ft(s.skill)}” may use these without asking you.`}))]}function RR({template:e,onCreateAnyway:t,onCancel:s,isCreating:r}){return n.jsxs("div",{role:"alert",className:"space-y-3 rounded-md border border-amber-500/40 bg-amber-500/5 p-3 text-sm","data-testid":"template-review",children:[n.jsxs("p",{className:"flex items-center gap-2 font-medium text-amber-700 dark:text-amber-300",children:[n.jsx(xx,{className:"size-4 shrink-0","aria-hidden":!0}),"This template brings things that run in your agent’s chats"]}),n.jsxs("p",{className:"text-muted-foreground text-xs [overflow-wrap:anywhere]",children:["From ",e.source,". Check each before you create the agent."]}),n.jsx("ul",{className:"space-y-2",children:IR(e).map(o=>{var a;return n.jsxs("li",{className:"text-xs",children:[n.jsx("code",{className:"bg-muted text-foreground block rounded px-1.5 py-1 font-mono [overflow-wrap:anywhere] whitespace-pre-wrap",children:o.label}),n.jsx("span",{className:"text-muted-foreground",children:o.detail}),(a=o.files)==null?void 0:a.map(i=>n.jsxs("details",{className:"mt-1","data-testid":"template-settings-file",children:[n.jsx("summary",{className:"text-muted-foreground hover:text-foreground cursor-pointer",children:i.path===o.label?"Show what it contains":`Show ${i.path}`}),i.content!==void 0?n.jsx("pre",{className:"border-border/60 bg-muted/40 mt-1 max-h-[50dvh] overflow-auto rounded border p-2 font-mono text-xs break-words whitespace-pre-wrap md:max-h-56",children:i.content}):n.jsx("p",{className:"text-muted-foreground mt-1",children:AR(i)})]},i.path))]},o.key)})}),n.jsxs("div",{className:"flex flex-wrap justify-end gap-2",children:[n.jsx(F,{variant:"ghost",size:"sm",onClick:s,disabled:r,children:"Don’t create it"}),n.jsx(F,{size:"sm",onClick:t,disabled:r,className:"h-auto max-w-full py-1.5 text-left [overflow-wrap:anywhere] whitespace-normal",children:r?"Creating…":ER(e)})]})]})}function TR(){const{isOpen:e,seed:t,onCreated:s,close:r}=Ts(),o=rn(z=>z.open),a=JI(),i=Pe(),[c,d]=u.useState("gallery"),[l,m]=u.useState(null),[h,p]=u.useState(!1);e!==h&&(p(e),e&&(m(null),d(t?"arrival":"gallery")));const f=t!=null&&t.template.icon&&_r(t.template.icon)?t.template.icon:void 0,g=l!=null&&l.icon&&_r(l.icon)?l.icon:f??null,x=(t==null?void 0:t.template.runtime)??"claude-code",y=(t==null?void 0:t.packageName)!==void 0?t:(l==null?void 0:l.packageName)!==void 0?{packageName:l.packageName,marketplace:l.marketplace}:null,b=tR(y),{data:C}=Me(),k=Os()?void 0:S,I=y&&b.packageAgentName&&(C!=null&&C.dorkHome)?`${C.dorkHome}/agents/${b.packageAgentName}`:void 0,[v,E]=u.useState(null),R=eR({step:c,templateName:(l==null?void 0:l.displayName)??null,seedDisplayName:(t==null?void 0:t.template.displayName)??null,faceSeed:g,runtimeSeed:x}),_=rR(l?{name:l.name,description:l.description,category:l.category,tags:l.tags}:t?{name:t.template.displayName,description:t.template.persona}:void 0),D=l?l.description??"A ready-made agent.":t!=null&&t.template.persona?t.template.persona:"You’ll define the job together in your first chat.",P=l?l.tags??[]:(t==null?void 0:t.template.capabilities)??[];function T(){R.reset(),E(null),m(null),d("gallery")}const j=u.useCallback(z=>{m(z),d("naming")},[]),w=u.useCallback(()=>{m(null),d("naming")},[]);function N(){d(t?"arrival":"gallery")}function S(){r(),T(),o()}function M(z){var pe;if(!R.canSubmit||a.isPending)return;const V=(y==null?void 0:y.packageName)!==void 0&&b.approval?{package:{name:y.packageName,...y.marketplace?{marketplace:y.marketplace}:{},...b.approval}}:void 0,ae=V?void 0:(l==null?void 0:l.source)??(t==null?void 0:t.template.source);a.mutate({name:R.slug,displayName:R.displayName.trim()||void 0,runtime:R.runtime,...!V&&R.directoryOverride?{directory:R.directoryOverride}:{},...R.icon?{icon:R.icon}:{},...V??{},...ae?{template:ae}:{},...z?{approvedTemplateHash:z}:{},...t!=null&&t.template.persona?{persona:t.template.persona}:{},...(pe=t==null?void 0:t.template.capabilities)!=null&&pe.length?{capabilities:t.template.capabilities}:{}},{onSuccess:Q=>{const q=crypto.randomUUID(),ne=Q.displayName??Q.name,ve=l||t?"template":"design-your-own";yx.getState().register(q,{name:Q.name,displayName:ne,agentId:Q.id,icon:Q.icon,color:Q.color,bornAt:Q.registeredAt,path:Q._path,runtime:Q.runtime,kickoffMessage:hR(ve,{displayName:ne,capabilities:Q.capabilities})}),Ry();const se=s;if(r(),T(),se){se();return}i(Rt({agentId:Q.id,draft:"1",session:q,runtime:Q.runtime}))},onError:Q=>{const q=CR(Q);q&&E(q)}})}function B(z){z||(r(),T())}const O=hd(e),$=n.jsx(Pw,{agentName:R.displayName||(t==null?void 0:t.template.displayName)||""}),G=nR[c],ee=c==="gallery"?"max-w-6xl":c==="naming"?"max-w-5xl":"max-w-2xl";return n.jsx(vt,{open:e,onOpenChange:B,defaultFullscreen:!0,children:n.jsxs(wt,{className:"flex flex-col gap-0 p-0",children:["title"in G&&n.jsxs(gt,{className:"shrink-0 border-b px-5 py-4",children:[n.jsx(ot,{children:G.title}),n.jsx(xt,{children:G.description})]}),n.jsx("span",{className:"sr-only","aria-live":"polite","aria-atomic":"true",children:G.description}),n.jsx("div",{className:"flex min-h-0 flex-1 flex-col overflow-y-auto px-5 py-6 sm:px-8",children:n.jsxs("div",{className:`mx-auto my-auto w-full ${ee}`,children:[n.jsx(Ye,{mode:"wait",children:n.jsxs(re.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.15},children:[c==="gallery"&&n.jsx(bR,{onDesignYourOwn:w,onSelectTemplate:j,onImport:k}),c==="arrival"&&t&&n.jsx(kR,{seed:t,packageSchedules:b.schedules,isCheckingOffer:b.isChecking,offerCheckFailed:b.failed,offerRefusal:b.refusal,resolvedDirectory:I??R.resolvedDirectory,canSubmit:R.canSubmit,isCreating:a.isPending,inheritance:$,isCheckingInheritance:O.isPending,onCreate:()=>M(),onCustomize:()=>d("naming"),onNotNow:()=>B(!1)}),c==="naming"&&n.jsx(jR,{form:R,suggestionPool:_,jobLine:D,previewCapabilities:P,onBack:N,onImportInstead:k,onCreate:()=>M(),isCreating:a.isPending,packageSchedules:b.schedules,offerCheckFailed:b.failed,offerRefusal:b.refusal,isCheckingOffer:b.isChecking,packageDirectory:I,inheritance:$,isCheckingInheritance:O.isPending,templateReview:v?n.jsx(RR,{template:v,isCreating:a.isPending,onCreateAnyway:()=>M(v.contentHash),onCancel:()=>E(null)}):void 0})]},c)}),c!=="gallery"&&n.jsx(hb,{className:"mt-6"})]})}),n.jsx(Tc,{open:R.directoryPickerOpen,onOpenChange:R.setDirectoryPickerOpen,initialPath:R.directoryOverride||R.defaultDirectory,onSelect:z=>{R.setDirectoryOverride(z),R.directoryOpen||R.setDirectoryOpen(!0)}})]})})}function DR({sessionId:e}){u.useEffect(()=>{var a;const r=rt.getState(),o=((a=r.sessions[e])==null?void 0:a.cwd)??r.statusCwds[e]??null;return hs.pinSession(e,o),Da.getState().setPinnedSession(e),()=>{hs.unpinSession(),Da.getState().setPinnedSession(null)}},[e]);const t=vx(e),s=u.useMemo(()=>iy(t),[t]);return s===null?n.jsx("div",{className:"text-muted-foreground flex h-full items-center justify-center p-4 text-center text-sm",children:"No live widget in this chat"}):n.jsx(cy,{code:s.code,isIncomplete:s.isIncomplete,sessionId:e,isLatestMessage:s.isLatest,isStreaming:s.isStreaming},s.sourceMessageKey)}function OR({content:e}){return n.jsx("div",{className:"text-muted-foreground flex h-full items-center justify-center p-4 text-center text-sm",children:e.title})}const Sr=64,MR={type:"spring",stiffness:480,damping:44};function _R({content:e,onRestore:t,onClose:s}){u.useEffect(()=>(document.documentElement.style.setProperty("--pip-dock",`${Sr}px`),()=>{document.documentElement.style.removeProperty("--pip-dock")}),[]);const r=hy();return Es.createPortal(n.jsxs(re.div,{"data-slot":"pip-minibar",role:"complementary","aria-label":e.title,initial:{y:Sr},animate:{y:0},exit:{y:Sr},transition:MR,style:{bottom:`max(var(--mobile-tab-dock, 0px), ${r}px)`},className:"bg-background border-border shadow-elevated fixed inset-x-0 z-40 flex h-16 items-center border-t",children:[n.jsxs("button",{type:"button",onClick:t,className:"focus-ring flex h-full min-w-0 flex-1 items-center gap-3 px-4 text-left",children:[n.jsx("span",{className:"bg-primary size-2 shrink-0 animate-pulse rounded-full"}),n.jsx("span",{className:"min-w-0 flex-1 truncate text-sm font-medium",children:e.title}),n.jsx($y,{className:"text-muted-foreground size-4 shrink-0"})]}),n.jsx("button",{type:"button","aria-label":"Close",onClick:s,className:"text-muted-foreground hover:bg-muted hover:text-foreground focus-ring mr-3 flex size-11 shrink-0 items-center justify-center rounded-md transition-colors",children:n.jsx(Be,{className:"size-4"})})]}),document.body)}const rs={peek:.5,expanded:.94},PR=.4,LR=800,lc=500,Cr={type:"spring",stiffness:480,damping:44};function FR({content:e,onClose:t,onMinimize:s,children:r}){const o=tv(),a=Jy(),[i,c]=u.useState("peek"),d=Hd(),l=d.height,m=Math.max(0,window.innerHeight-d.top-d.height),h=rs.expanded*l,p=(rs.expanded-rs.peek)*l,f=i==="expanded"?0:p;u.useEffect(()=>{a.start({y:f,transition:Cr})},[a,f]);const g=(y,b)=>{const C=f+b.offset.y,k=b.velocity.y,I=C-p,v=rs.peek*l;if(I>PR*v||I>0&&k>LR){s();return}let E;k<-lc?E="expanded":k>lc?E="peek":E=C<p/2?"expanded":"peek",E===i?a.start({y:f,transition:Cr}):c(E)},x=y=>{y.target.closest("button")||o.start(y)};return Es.createPortal(n.jsxs(re.div,{"data-slot":"pip-sheet",role:"complementary","aria-label":e.title,initial:{y:h},animate:a,exit:{y:h},transition:Cr,drag:"y",dragListener:!1,dragControls:o,dragConstraints:{top:0,bottom:h},dragElastic:.1,dragMomentum:!1,onDragEnd:g,style:{height:h,bottom:m},className:"bg-background border-border shadow-modal fixed inset-x-0 z-40 flex flex-col rounded-t-lg border-t",children:[n.jsxs("div",{onPointerDown:x,className:"cursor-grab touch-none select-none active:cursor-grabbing",children:[n.jsx("div",{className:"bg-muted mx-auto mt-4 h-2 w-[100px] rounded-full"}),n.jsxs("div",{className:"flex items-center justify-between gap-2 border-b pt-1 pr-[max(1rem,env(safe-area-inset-right))] pb-2 pl-[max(1rem,env(safe-area-inset-left))]",children:[n.jsx("span",{className:"min-w-0 flex-1 truncate text-sm font-medium",children:e.title}),n.jsx("button",{type:"button","aria-label":"Minimize",onClick:s,className:"text-muted-foreground hover:bg-muted hover:text-foreground focus-ring flex size-11 shrink-0 items-center justify-center rounded-md transition-colors",children:n.jsx(Zt,{className:"size-4"})}),n.jsx("button",{type:"button","aria-label":"Close",onClick:t,className:"text-muted-foreground hover:bg-muted hover:text-foreground focus-ring flex size-11 shrink-0 items-center justify-center rounded-md transition-colors",children:n.jsx(Be,{className:"size-4"})})]})]}),n.jsx("div",{"data-slot":"pip-sheet-content",style:{marginBottom:f},className:"min-h-0 flex-1 overflow-y-auto pt-3 pr-[max(0.75rem,env(safe-area-inset-right))] pb-[max(0.75rem,env(safe-area-inset-bottom))] pl-[max(0.75rem,env(safe-area-inset-left))]",children:r})]}),document.body)}const dc=360,uc=240,no=16,Nr={demo:OR,mcp_app:$R,widget:BR};function $R({content:e}){return n.jsx(Ny,{sessionId:e.sessionId,serverName:e.serverName,uri:e.uri,title:e.title,className:"h-full"})}function BR({content:e}){return n.jsx(DR,{sessionId:e.sessionId})}function zR(e){u.useEffect(()=>{},[e])}function mc(){return{x:window.innerWidth-dc-no,y:window.innerHeight-uc-no,width:dc,height:uc}}function UR(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function jm(e){switch(e.kind){case"demo":{const t=Nr.demo;return n.jsx(t,{content:e})}case"mcp_app":{const t=Nr.mcp_app;return n.jsx(t,{content:e})}case"computer":return n.jsx(Py,{content:e});case"widget":{const t=Nr.widget;return n.jsx(t,{content:e})}default:return e}}function KR({content:e,onClose:t}){const s=L(c=>c.pipGeometry),r=L(c=>c.setPipGeometry),[o,a]=u.useState(mc);u.useEffect(()=>{if(s!==null)return;const c=()=>a(d=>{const l=mc();return UR(d,l)?d:l});return c(),window.addEventListener("resize",c),()=>window.removeEventListener("resize",c)},[s]);const i=u.useMemo(()=>s||((e==null?void 0:e.kind)!=="computer"?o:{...o,width:480,height:360,x:Math.max(0,window.innerWidth-480-no),y:Math.max(0,window.innerHeight-360-80)}),[s,o,e==null?void 0:e.kind]);return n.jsx(Ye,{children:e!==null&&n.jsx(Iv,{title:e.title,geometry:i,onGeometryChange:r,onClose:t,minWidth:e.kind==="computer"?360:void 0,minHeight:e.kind==="computer"?300:void 0,children:jm(e)},"pip-panel")})}function HR(){const e=L(d=>d.pipContent),t=L(d=>d.pipMinimized),s=L(d=>d.closePip),r=L(d=>d.minimizePip),o=L(d=>d.restorePip),a=L(d=>d.openPip),i=_e();zR(a);const c=u.useRef(i);return u.useEffect(()=>{i&&!c.current&&e!==null&&r(),c.current=i},[i,e,r]),i?n.jsx(Ye,{children:e!==null&&(t?n.jsx(_R,{content:e,onRestore:o,onClose:s},"pip-minibar"):n.jsx(FR,{content:e,onClose:s,onMinimize:r,children:jm(e)},"pip-sheet"))}):n.jsx(KR,{content:e,onClose:s})}const WR=new Set(["permission-prompt","question","schedule-approval"]),GR={"permission-prompt":"Needs your approval to go on.",question:"Has a question for you.","schedule-approval":"Wants to run on a timer."};function km(e){const t=Xl(),s=wx(),r=$t(e),o=u.useRef(null);u.useEffect(()=>{var l,m,h,p;if(s)return;const a=new Map;for(const f of t)!WR.has(f.kind)||f.quiet===!0||a.set(f.id,{id:f.id,who:f.primary,summary:GR[f.kind],deepLink:f.deepLink});const i=o.current;if(o.current=new Set(a.keys()),i===null)return;const c=[...a.values()].filter(f=>!i.has(f.id)),d=[...i].filter(f=>!a.has(f));c.length>0&&((m=(l=r.read()).onArrive)==null||m.call(l,c)),d.length>0&&((p=(h=r.read()).onDepart)==null||p.call(h,d,a.size))},[s,t,r])}function qR(){const{permission:e}=Xb(),{prefs:t}=Jb(),s=Ms(),r=$e(),o=u.useRef(new Map),a=$t(s),i=u.useCallback(()=>r||e!=="granted"||typeof document>"u"||!document.hidden?!1:typeof window<"u"&&typeof window.Notification<"u",[r,e]),c=u.useCallback((h,p,f,g)=>{let x;try{x=new Notification(p,{body:f,tag:h,silent:!0})}catch{return}x.onclick=()=>{var y;window.focus(),x.close(),o.current.delete(h),g!==null&&((y=a.read())==null||y({href:g}))},x.onclose=()=>{o.current.delete(h)},o.current.set(h,{notification:x,href:g})},[a]),d=u.useCallback(h=>{if(i())for(const p of h)c(p.id,`${p.who} needs you`,p.summary,p.deepLink)},[i,c]),l=u.useCallback(h=>{for(const p of h){const f=o.current.get(p);f!==void 0&&(f.notification.close(),o.current.delete(p))}},[]);km({onArrive:d,onDepart:l});const m=t.notifyOnTurnCompleteWhileAway;fe("notification",h=>{const p=jx.safeParse(h);if(!p.success)return;const f=p.data.notification;if(f.tier!=="notable"||!m||!i())return;const g=kx(f),x=g===null?null:YR(g.to,g.search);c(f.id,f.title,f.body??"",x)}),u.useEffect(()=>{const h=o.current;return()=>{for(const{notification:p}of h.values())p.close();h.clear()}},[])}function YR(e,t){const s=new URLSearchParams;for(const[o,a]of Object.entries(t))a!=null&&s.set(o,String(a));const r=s.toString();return r===""?e:`${e}?${r}`}function VR(){const{play:e}=Fb(),t=u.useCallback(()=>{e("knock"),$b()},[e]),s=u.useCallback((r,o)=>{o===0&&e("settle")},[e]);return km({onArrive:t,onDepart:s}),qR(),null}function QR(){const e=L(r=>r.shortcutsPanelOpen),t=L(r=>r.setShortcutsPanelOpen),s=Sx();return n.jsx(vt,{open:e,onOpenChange:t,children:n.jsxs(wt,{className:"sm:max-w-md",children:[n.jsx(gt,{children:n.jsx(ot,{children:"Keyboard shortcuts"})}),n.jsx(Et,{className:"space-y-6",children:s.map(({group:r,label:o,shortcuts:a})=>n.jsxs("div",{children:[n.jsx("h3",{className:"text-muted-foreground mb-2 text-xs font-medium tracking-wider uppercase",children:o}),n.jsx("div",{className:"space-y-1",children:a.map(i=>n.jsxs("div",{className:"flex items-center justify-between py-1.5 text-sm",children:[n.jsx("span",{children:i.label}),n.jsx(Ol,{className:"inline-flex",children:Wt(i)})]},i.id))})]},r))})]})})}function XR(){const e=L(t=>t.toggleShortcutsPanel);u.useEffect(()=>{const t=s=>{const r=s.target,o=r.tagName==="INPUT"||r.tagName==="TEXTAREA"||r.isContentEditable;s.key==="?"&&!o&&(s.preventDefault(),e())};return document.addEventListener("keydown",t),()=>document.removeEventListener("keydown",t)},[e])}const JR=15e3;function ZR(){const e=De({select:r=>r.location.pathname}),s=_s("sidebar.body").find(r=>{var o;return(o=r.visibleWhen)==null?void 0:o.call(r,{pathname:e})});if(s){const r=s.component;return{key:`body:${s.id}`,body:n.jsx(bE,{contributionId:s.id,children:n.jsx(u.Suspense,{fallback:null,children:n.jsx(r,{})})}),direction:1,isTakeover:!0}}return{key:"dashboard",body:n.jsx(VN,{}),direction:-1,isTakeover:!1}}function eT(){const e=De({select:t=>t.matches});return tk(e)}function tT(){const{sidebarOpen:e,setSidebarOpen:t}=L(),s=_e(),r=As(se=>se.panelUp),[o]=Oc(),a=De({select:se=>se.location.pathname}),i=De({select:se=>se.location.searchStr}),c=new URLSearchParams(i),d=a==="/channels"&&!!c.get("community")&&!!c.get("id"),l=uI(ht()??!1),m=De({select:se=>mI(se.matches)});aw();const[h]=Fs(),p=L(se=>se.isStreaming),{data:f}=Uc(h),g=hl(f??null,h??""),{room:x,unreadRoomCount:y}=mE();pE(),gE(),wv({cwd:h,isStreaming:p,color:f?g.color:void 0}),XR(),Jj(),Gb(),HE(),qb(),Bb(),$k(),iE(),cE();const b=lE();dE(),mw(),WS(),Aj(),Ej(),Cx(),cb(),Vw(),Nx(),Zv(),Eb(),kv(),Ax(),qw(),Ex(),i0(),Mb();const C=L(se=>se.onboardingHiddenForSession),k=L(se=>se.setOnboardingHiddenForSession),{shouldShowOnboarding:I,isLoading:v,isOnboardingComplete:E,isOnboardingDismissed:R}=en(),_=hw({shouldShowOnboarding:I,onboardingHiddenForSession:C});pw({done:E||R,overlayVisible:_}),Rj({blocked:_});const{dataUpdatedAt:D,errorUpdatedAt:P,error:T}=Me({refetchOnMount:dI}),j=D>ln,w=P>ln,N=lI(P,T),[S,M]=u.useState(!1);u.useEffect(()=>{if(j)return;const se=setTimeout(()=>M(!0),JR);return()=>clearTimeout(se)},[j]);const B=(N==null?void 0:N.status)===void 0,O=!j&&B&&(w||S),$=j||(N==null?void 0:N.status)===void 0?void 0:N,[G,ee]=u.useState(!1);u.useEffect(()=>{if(!v)return;const se=setTimeout(()=>ee(!0),3e3);return()=>clearTimeout(se)},[v]);const z=u.useCallback(()=>k(!0),[k]),V=ZR(),{origin:ae,originLabel:pe}=Ix(o),{data:Q}=Rx(o,{enabled:!1,select:se=>se.title}),q=eT(),ne=u.useMemo(()=>({sessionId:o??void 0,agentName:f?Le(f):void 0,agentVisual:f?g:void 0,origin:ae,originLabel:pe,sessionTitle:Q,sessionDirectoryName:h?Pl(h):void 0,room:x,teamViewMode:Tx(new URLSearchParams(i).get("view")??void 0)}),[o,f,g,ae,pe,Q,h,x,i]),ve=EI();return O?n.jsx(vE,{}):($==null?void 0:$.status)!==void 0?n.jsx(iI,{status:$.status,message:$.message,code:$.code}):v&&!G?n.jsx("div",{className:"bg-background h-dvh"}):n.jsxs(Dx,{children:[n.jsx(hE,{unreadRoomCount:y}),n.jsxs(Yy,{reducedMotion:"user",children:[n.jsx(Ye,{mode:"wait",children:_?n.jsx(re.div,{initial:{opacity:1},exit:{opacity:0},transition:{duration:.2},className:"fixed inset-0 z-50",children:n.jsx(Fw,{onComplete:z,slots:oI})},"onboarding"):n.jsx(re.div,{initial:{opacity:0},animate:{opacity:1},transition:{duration:.2},className:"h-dvh",children:n.jsxs("div",{"data-testid":"app-shell",className:"bg-background text-foreground flex h-dvh flex-col",children:[n.jsxs(Ox,{open:e,onOpenChange:t,className:K("flex-1 overflow-hidden",s&&"min-h-0"),style:{"--sidebar-width":"calc(272px + 1rem)"},children:[!s&&n.jsxs(Mx,{variant:"inset",children:[n.jsxs(El,{className:"flex min-h-0 flex-1 flex-col",children:[n.jsx(xE,{isFullscreen:b}),n.jsx(sm,{}),n.jsx(WI,{slotKey:V.key,direction:V.direction,children:V.body}),n.jsx(_x,{className:"px-2 py-3",children:n.jsx(Jl,{})})]}),n.jsx(Px,{})]}),n.jsxs(Lx,{className:"overflow-hidden",inert:s&&r,children:[$e()&&n.jsx(Ck,{className:K("app-drag-region",!e&&!b&&"desktop-darwin:pl-20")}),n.jsxs("header",{className:"app-drag-region @container/bar relative flex h-auto min-h-11 shrink-0 flex-wrap items-center gap-x-1 border-b px-2 transition-[border-color] duration-300 md:h-9 md:min-h-0 md:flex-nowrap lg:gap-x-2",children:[!s&&n.jsxs(n.Fragment,{children:[n.jsx(Fx,{className:"-ml-0.5"}),n.jsx(Ek,{}),n.jsx($x,{orientation:"vertical",className:"mr-1 h-4"})]}),s&&n.jsx(EA,{}),q&&n.jsx(re.div,{initial:l?{opacity:0}:!1,animate:{opacity:1},transition:l?{duration:.1}:{duration:0},className:"flex h-11 min-w-0 grow basis-24 items-center gap-1 has-[[data-slot=bar-tab-strip]]:basis-[calc(100%-2.5rem)] md:h-auto md:flex-1 md:self-stretch md:has-[[data-slot=bar-tab-strip]]:basis-0 lg:gap-2",children:n.jsx(Bx,{value:ne,children:n.jsx(q.Header,{})})},q.key),n.jsx(nI,{})]}),n.jsx(hI,{descriptors:ve}),n.jsx("main",{id:iu,className:"flex-1 overflow-hidden pb-[var(--pip-dock,0px)]",children:n.jsxs(zx,{direction:"horizontal",id:Br,autoSaveId:Br,children:[n.jsx(Kc,{id:"main-content",order:1,minSize:30,defaultSize:100,children:n.jsx(re.div,{initial:l?{opacity:0}:!1,animate:{opacity:1},transition:l?{duration:.12,ease:"easeOut"}:{duration:0},"data-route-fade":l,className:"h-full",children:n.jsx(Ux,{})},m)}),n.jsx(Xj,{pathname:a,isRemoteCommunityRoom:d})]})})]})]}),s&&n.jsx(XI,{takeover:V.isTakeover?V.body:null})]})},"main-app")}),n.jsx(i1,{}),n.jsx(HI,{onboardingOverlayVisible:_}),n.jsx(aE,{}),n.jsx(MA,{}),n.jsx(t1,{}),n.jsx(TR,{}),n.jsx(Cj,{}),n.jsx(QR,{}),n.jsx(Rv,{}),n.jsx(gy,{}),n.jsx(HR,{}),n.jsx(Wx,{}),n.jsx(VR,{})]})]})}const DD=tT;export{DD as component};