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
@@ -0,0 +1,80 @@
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 Ge,sO as Nm,r as u,fz as sa,sP as Am,fx as so,j as n,sQ as Em,sR as hc,fA as Im,kL as ro,a5 as ie,a6 as Ee,aJ as Fe,fv as De,g8 as Dn,sS as Xs,kI as ms,sT as Rm,sU as Tm,a7 as le,ar as pe,kt as ra,sV as Dm,eQ as Es,_ as re,B as F,X as Be,G as U,k6 as fc,sW as Om,x as Oe,a4 as pc,bx as gc,bf as Is,dU as $e,a_ as Mm,sX as oa,sY as _m,bX as Pm,aI as xc,cz as Pe,aO as Me,s as Rt,l1 as Lm,l2 as bc,dR as ce,m5 as Bn,m6 as At,m7 as yc,aZ as L,sk as Fm,fg as rt,e9 as hs,jx as un,sZ as $m,a8 as Qt,f1 as vc,fU as oo,dc as ao,av as Xt,s_ as aa,ks as Bm,kx as wc,kr as zm,qw as io,Y as zn,J as Jt,$ as co,eP as an,l as Ne,aK as jc,fd as kc,ep as Sc,eq as Cc,fe as Um,s$ as Km,eu as dt,by as mn,bz as hn,U as Zt,bA as fn,bC as pn,C as gn,eL as We,eM as Hm,nl as Nc,lK as Ac,aQ as Ke,t0 as Wm,gZ as Ec,bY as ia,t1 as Gm,g as fs,kH as Ar,z as lo,ej as ht,hS as ct,gr as uo,f_ as Rs,kW as mo,f as Dt,ba as Ic,f0 as Ts,t2 as Rc,eB as qm,ao as ho,a2 as On,dn as xn,dp as bn,dq as yn,am as Le,as as Ds,op as Tc,t3 as Ym,t4 as Vm,c$ as Qm,e8 as ps,Z as Ve,l8 as Os,l7 as rn,d2 as vt,d3 as wt,d5 as gt,d6 as ot,d7 as xt,e_ as Et,d$ as on,dZ as Xm,ct as Un,eW as Dc,t5 as Jm,cr as Oc,t6 as Zm,gH as Mc,hg as ca,t7 as eh,ir as gs,kS as th,kU as nh,he as _c,t8 as sh,ge as fo,gf as po,gh as go,iA as Pc,gi as Ye,t9 as Kn,gk as os,h as Ms,ta as xo,tb as rh,gg as oh,rx as ah,tc as Lc,ki as ih,td as ch,te as lh,tf as dh,hx as Fc,tg as uh,th as $c,jw as Bc,ti as zc,tj as mh,ay as hh,gB as Uc,af as _e,hv as _s,tk as fh,tl as ph,hc as gh,sH as la,i9 as xh,ni as bh,ib as yh,ic as vh,id as wh,jY as Kc,tm as jh,tn as ue,to as kh,tp as Hc,tq as bo,iP as Er,iK as Wc,tr as yo,ts as Ir,tt as vo,b9 as Hn,tu as Ps,tv as Sh,tw as Ch,tx as Nh,ty as Ah,tz as Eh,tA as Ih,tB as Rh,tC as Lt,kJ as Th,kb as Dh,oM as Oh,tD as da,be as Mh,i2 as Gc,tE as Wt,tF as cn,tG as _h,tH as Ph,tI as Lh,ix as Fh,fZ as qc,cb as $t,iH as Yc,iI as xs,iQ as Vc,tJ as Qc,iJ as Xc,iL as $h,tK as Bh,tL as zh,tM as Uh,ii as Jc,ij as Zc,tN as Gt,tO as Kh,tP as Hh,eS as Wh,tQ as Mn,tR as Gh,b0 as el,tS as qh,tT as Yh,tU as Vh,tV as Qh,tW as Xh,tX as tl,tY as Bt,fX as It,dw as ut,du as Wn,dv as me,dz as Gn,dy as Ut,dx as xe,I as yt,pU as nl,q2 as sl,nU as qt,nT as _n,cv as Ls,lC as Jh,nS as rl,fh as ol,su as al,pe as il,nR as Zh,tZ as ef,t_ as ua,t$ as tf,u0 as ln,u1 as cl,c3 as qn,is as ll,u2 as nf,qQ as sf,u3 as rf,u4 as dl,u5 as of,u6 as af,gI as cf,a$ as wo,nV as jo,u7 as lf,gA as Fs,u8 as An,u9 as ko,q as bs,ma as ul,ua as df,o as ml,ub as uf,l3 as ma,mP as mf,pv as hf,uc as ff,ch as pf,al as $s,ak as Bs,o0 as So,n$ as Co,ud as gf,dS as zs,ot as Us,ue as Js,uf as as,ln as hl,ug as xf,uh as bf,ui as yf,uj as vf,uk as wf,ul as jf,um as kf,hr as Ks,qv as Sf,un as fl,os as Cf,iq as Nf,jL as ha,uo as Af,up as dn,lI as Rr,el as Ef,uq as No,nX as Hs,ur as Ws,us as If,nW as Rf,iX as Ao,nY as pl,ut as gl,uu as Tf,rp as Df,uv as Of,uw as Mf,ux as fa,uy as _f,uz as Pf,uA as Lf,uB as Ff,uC as pa,uD as xl,uE as $f,uF as Bf,uG as zf,uH as ga,e as mt,uI as Uf,uJ as Kf,lG as Gs,c0 as bl,uK as yl,uL as vl,uM as wl,uN as Hf,mm as jl,uO as Wf,uP as Gf,H as Eo,gD as qf,uQ as Yf,mh as Vf,mt as Qf,uR as Xf,uS as Jf,uT as Zf,b7 as ep,kj as tp,uU as np,uV as ys,mC as kl,uW as Sl,uX as sp,uY as rp,uZ as Cl,u_ as xa,u$ as ba,v0 as Nl,b6 as op,v1 as ap,v2 as ip,v3 as Al,v4 as El,v5 as Jn,v6 as cp,v7 as lp,v8 as dp,v9 as Il,kM as Rl,kN as Tl,kO as Dl,kP as Tr,va as Dr,vb as up,cF as jn,aW as mp,vc as Ol,gz as Io,ff as ya,kY as Ro,bk as hp,t as fp,j7 as Or,i8 as pp,aR as To,io as Ml,vd as gp,dA as xp,dB as bp,pY as yp,lF as vp,ve as wp,lH as va,mu as _l,bO as jp,bP as kp,bQ as Sp,bR as Cp,bS as Np,bT as Ap,bU as Ep,vf as Ip,vg as Mr,vh as Rp,vi as Zs,vj as Tp,vk as Dp,vl as Pn,vm as Op,vn as wa,nv as Mp,mn as _p,vo as Pp,bb as vs,mW as ja,mU as Lp,mV as ka,vp as Fp,mB as $p,vq as Sa,vr as Bp,fI as zp,vs as Up,vt as Kp,vu as Hp,c6 as Wp,vv as Gp,vw as Pl,vx as Ll,Q as Do,T as Oo,V as Mo,vy as qp,vz as Yp,gc as Vp,vA as er,hk as Qp,gM as Xp,vB as Jp,vC as Zp,vD as eg,vE as tg,vF as ng,vG as sg,vH as Ca,vI as rg,vJ as og,vK as ag,vL as Fl,kh as ig,b$ as cg,vM as $l,vN as lg,f$ as dg,vO as Na,dC as ug,vP as mg,vQ as hg,pZ as fg,vR as pg,vS as gg,cq as xg,vT as bg,vU as Aa,vV as yg,vW as vg,vX as wg,vY as jg,iU as kg,vZ as qs,bj as Bl,a3 as zl,v_ as Ul,qy as Sg,bh as Cg,bi as Ng,fk as Ea,bg as Ag,eJ as tr,eN as Eg,v$ as _o,n as Ig,eH as Rg,eI as Ia,pX as Tg,bB as Kl,w0 as Hl,w1 as Wl,qJ as Dg,w2 as Og,pT as Mg,qa as _g,kB as Pg,es as Lg,w3 as Fg,ab as Gl,w4 as $g,kv as Bg,kw as zg,lo as Ug,fO as ql,fP as Yl,fQ as Vl,fR as Ql,dV as Kg,eO as Hg,fM as Wg,fN as Gg,jM as qg,jT as Yg,ls as Vg,jN as Qg,w5 as Xg,eU as Jg,lt as Zg,w6 as Xl,w7 as ex,w8 as tx,lr as nx,lq as sx,jO as rx,eX as ox,kG as ax,jA as ix,w9 as cx,wa as Jl,wb as lx,wc as dx,wd as sn,dF as ux,we as Ra,o7 as mx,o9 as Zl,d_ as hx,kq as fx,pu as px,wf as _r,gd as gx,j6 as xx,ok as ft,om as bx,sj as yx,oG as Ta,cW as vx,wg as wx,wh as jx,wi as kx,wj as Sx,wk as Cx,wl as Nx,wm as Ax,wn as Ex,wo as Ix,sN as Rx,lh as Tx,hi as Dx,wp as Ox,wq as Mx,wr as _x,ws as Px,wt as Lx,wu as Fx,cC as $x,wv as Bx,jX as zx,db as Ux}from"./index-BR1m9FON.js";import{u as Kx,g as Hx}from"./use-connector-management-BLiCJMgU.js";import{D as Tt,a as Wx}from"./TourHost-Bw3Uoea5.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 Da,A as rb,T as ob,a as ab,n as ib,L as cb}from"./SeenDevices-cuY7ASEy.js";import{I as Oa,t as lb}from"./trust-posture-DaHHtOZn.js";import{u as Vn}from"./use-update-config-DjL7-nUR.js";import{b as db,u as ub,O as mb,c as hb}from"./OpenMeshSwitch-RNAZY1vn.js";import{u as fb,S as pb,s as gb,b as xb,P as bb,a as yb}from"./ApplyToOverridesDialog-CnL1ubxL.js";import{s as nr}from"./trust-dial-D__tIhzt.js";import{B as vb,u as wb}from"./use-bindings-gLHRNAFU.js";import{a as cd,C as jb}from"./cpu-j9vX9Wfk.js";import{Z as Ma}from"./zap-DSllMMHe.js";import{r as kb,f as Sb,b as Cb,K as Nb}from"./RuntimeConnectFlow-BYQnY5vv.js";import{O as Ab,B as ld}from"./banner-CSKUrrI0.js";import{u as Ys,P as dd,a as Eb}from"./ProfileRolePicker-DrOtV-0N.js";import{u as Ib}from"./use-dev-links-DXcIlMf-.js";import{d as Rb}from"./untrusted-text-BDygHCRk.js";import{S as En}from"./scroll-area-DAC7NrVU.js";import{T as ud,a as md,b as is,c as sr}from"./tabs-Ctjzrm8t.js";import{P as Tb}from"./paperclip-C-7LhBfl.js";import{L as Db}from"./lightbulb-Cfb5ecEd.js";import{r as hd,s as _a,e as Ob}from"./access-copy-tkiFMhRf.js";import{a as Mb}from"./use-pulse-freshness-CG_I6a-O.js";import{c as _b,B as Pb,w as Lb,b as Fb,a as $b,e as Bb}from"./primer-trigger-XA5fLzR5.js";import{u as zb,s as Ub,P as Kb,a as Hb}from"./use-promo-activation-Dlw6bg7G.js";import{u as fd}from"./use-promo-dismissals-Dx_fli7I.js";import{u as pd}from"./use-pending-read-mVsOBTzn.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-B7S2C_eT.js";import{A as xd}from"./repeat-B8g-x-Sc.js";import{S as bd,P as Yb}from"./progress-BA2JPtb6.js";import{P as Vb,M as Qb}from"./plug-CIZ-wWL8.js";import{i as Lo,a as Xb,u as Jb}from"./use-notification-prefs-BHOK2P2l.js";import{R as Zb}from"./rotate-cw-BbHkWN-J.js";import{b as ey}from"./use-todos-BzRauzdQ.js";import{u as ty,a as ny,C as sy,N as ry}from"./NewDirectMessageMenu-CjBjzsDe.js";import{P as oy,C as ay,f as iy,a as cy}from"./find-latest-widget-fence-B6sJdG3Q.js";import{o as ly}from"./owner-notice-DdFc2P8z.js";import{U as dy}from"./unplug-B-ipHefz.js";import{c as uy,H as yd,a as vd,b as wd}from"./RuntimeSetupDialog-DTO5v0dP.js";import{u as jd}from"./use-is-below-desktop-LUZL5z5t.js";import{P as my,u as hy}from"./pane-resize-handle-Bjy4udre.js";import{a as fy,u as py,F as gy}from"./ForwardConsentHost-DSR1pEEK.js";import{W as xy}from"./WithheldExtensionsNotice-CCO4ClRZ.js";import{u as by}from"./use-direct-message-panel-BbH8N4mE.js";import{u as yy}from"./ComputerViewer-BKMR5LkF.js";import{F as vy}from"./file-text-Cycq_S0e.js";import{P as Pa}from"./page-container-0sWZ3xh9.js";import{A as wy}from"./AttentionSignalRow-CCKhUtil.js";import{u as jy}from"./use-roving-tab-list-CDkh-Ujm.js";import{R as kd}from"./rotate-ccw-clock-DRtL-2nr.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 ky}from"./command-CaUEAy3b.js";import{A as Sy,M as Cy}from"./McpAppFrame-z5JUaCSA.js";import{L as Ny}from"./layers-B0Z5Od3N.js";import{A as Ay}from"./AgentOptionRow-ApuDEKqq.js";import{R as Ey}from"./radio-DQ29H26H.js";import{a as Iy}from"./sound-D3r8dGFH.js";import{d as Ry}from"./connection-copy--MA7AN04.js";import{u as Ty,i as Dy,d as Oy,P as Ed}from"./PreviewRefusedNotice-DzbkMrUo.js";import{P as My}from"./path-input-BPVyI72G.js";import"./WidgetErrorCard-C5ieVv_9.js";import{a as _y}from"./ComputerResourceView-BUmsVssG.js";import"./use-external-adapter-catalog-mmKni5ui.js";import"./execution-config-BS5rtvTZ.js";import"./settings-for-runtime-BoOa-ZFG.js";import"./use-mesh-topology-upehQ5Cv.js";import"./copy-button-BOznikwM.js";import"./inline-code-mh48Uhbi.js";import"./useMutationState-DIywUTDG.js";import"./runtime-connect-Dn0T5YWv.js";import"./use-full-activity-feed-DXroUzfN.js";import"./profile-errors-C1XACbc9.js";import"./use-mounted-ref-IHwyriaF.js";import"./ProfileFields-DU8dTGHT.js";import"./list-runtime-types-DLmjtBMq.js";import"./more-details-DV7LmY0E.js";import"./shield-x-CEWfkzDN.js";import"./index-CpWxcN5D.js";import"./markdown-content-DhAtZOfj.js";import"./table-D0EJT0uP.js";import"./package-BhKXbvU_.js";import"./heart-Cn3a-UQI.js";import"./git-branch-CsLE6G0Y.js";import"./file-CQGljfDT.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 Py=Ge(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 Ly=Ge(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 Fy=Ge(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 $y=Ge(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=Ge(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 By=Ge(_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 zy=Ge(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=Ge(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 Uy=Ge(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 Ky=Ge($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 Hy=Ge(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 Wy=Ge(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 Gy=Ge(Ud);function qy({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 Yy(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 Vy(e,t){if(Array.isArray(t))return Lr(e,t);if(typeof t=="string")return Lr(e,[t]);hc(e,t)}function Qy(){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=>{Vy(r,s)})},stop(){e.forEach(s=>{Yy(s)})},mount(){return()=>{t.stop()}}};return t}function Xy(){const e=so(Qy);return Im(e.mount,[]),e}class Jy{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 Zy=()=>new Jy;function ev(){return so(Zy)}const tv=`${ro.repo}/issues/new`,nv={"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"},sv={"runtimes.default":["claude-code","codex","opencode","doe"],"logging.level":["fatal","error","warn","info","debug","trace"],"ui.theme":["light","dark","system"]},rv=/^[a-z0-9][a-z0-9._-]{0,31}$/,ov={bug:["bug"],feature:["enhancement"],runtime:["bug"]},av={bug:"Bug: (describe what went wrong)",feature:"Feature: (describe what you want)",runtime:"Runtime issue: (describe what went wrong)"};function iv(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 iv(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 cv(e,t){const s=sv[e];return s?s.includes(t):rv.test(t)&&Fo(t)===t}function lv(e){const t={};for(const[s,r]of Object.entries(nv)){const o=e[s];o!=null&&(r==="boolean"&&typeof o=="boolean"||r==="number"&&typeof o=="number"&&Number.isFinite(o)||r==="enum"&&typeof o=="string"&&cv(s,o))&&(t[s]=o)}return t}const dv=["details","summary"];function $o(e){return Rb(Fo(e),dv)}function uv(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 mv(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 hv(e){return["<details><summary>Environment</summary>","",uv(e),"","</details>","","DorkOS filled in the details above. Please check them and remove anything you do not want to share.","","---","",...mv(e)].join(`
69
+ `)}function rr(e){var r;const t=(r=e.title)==null?void 0:r.trim(),s=new URLSearchParams({title:$o(t||av[e.kind]),body:hv(e),labels:ov[e.kind].join(",")});return`${tv}?${s.toString()}`}const fv=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 pv(e,t=fv){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 gv(e){return pv(e).url}function xv(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?lv(xv(t)):{}}}function bv(){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=gv(Kd(r,t,s));Dn(o)},[t,s])}const yv=100;function vv({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)},yv))},[]),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 wv(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 jv(){const e=le();pe("notification",t=>{(t==null?void 0:t.kind)==="signin.required"&&e.invalidateQueries({queryKey:ra.all})}),pe("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 kv(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 Sv(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=kv(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,Cv=280,Nv=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 Av(e,t){return e.x!==t.x||e.y!==t.y||e.width!==t.width||e.height!==t.height}function Ev(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??Cv,p=c??Nv;u.useEffect(()=>{const b=()=>{const C=Ka(s,h,p);Av(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:U("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 Iv({...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 Rv(){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 Tv(){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 Dv(){return new Promise(e=>{requestAnimationFrame(()=>requestAnimationFrame(()=>e()))})}function Ov(){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 Mv(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 _v(){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 Pv(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 Lv(){const e=Tv(),t=Ov();try{return await Dv(),await Pv(e?Mv(e):_v())}finally{t()}}let kn=null;function qd(){if(kn)return kn;const e=Lv();kn=e;const t=()=>{kn===e&&(kn=null)};return e.then(t,t),e}function Fv(){return qd().then(e=>e.dataUrl)}function $v(){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 Bv(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone||void 0}catch{return}}function zv(e){const t=$v(),s=typeof navigator<"u"?navigator.userAgent:void 0,r=typeof navigator<"u"?navigator.language:void 0,o=Bv();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 Uv=2e3,Kv=.8,Hv=1400,Wv=.6,cs=6e5,ks=1e4,Gv=["image/webp","image/jpeg","image/png"],qv=/^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 Yv(e){return qv.test(e)&&e.length<=cs}function Vv(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 Qv(e,t){for(const s of Gv){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=Uv){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),Qv(r,s)}async function Fr(e){const t=typeof e=="string"?null:URL.createObjectURL(e);let s;try{s=await Vv(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),Kv);if(a.length>cs&&(a=Ga(s,Wa(r,o,Hv),Wv)),a.length>cs)throw new Yt("too-large",`Compressed to ${a.length} characters, over the ${cs} cap.`);return a}const Xv=500;function Jv(e=Xv){const t=le(),s=Pm({coalesceMs:e,shouldFlush:()=>t.isMutating({mutationKey:xc})===0});pe("config_changed",()=>{const r={queryKey:Fe.current()};s([r])})}const Yd="dorkbot",Zv=["mesh","agent-paths"];function ew(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 tw(){var d;const e=Pe(),t=ie(),{data:s}=Me(),{data:r}=Ee({queryKey:[...Zv],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)??ew(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 nw(e){return{pinned:e.pinned??[],groups:e.groups??[],muted:e.muted??[],sections:e.sections??{}}}function sw(){const e=le(),t=Bn();pe("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:rw(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 rw(e){return`Disconnected here, but ${e} couldn’t be reached. Finish under Connected installations on ${e}.`}function ow(){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 aw=5e3;function iw(e,t=aw){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 cw(e,t){const s=Object.keys(e);return s.length!==Object.keys(t).length?!0:s.some(r=>!(r in t))}function lw(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 dw(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&&(lw(e,i),o.push(i));$m(e,o,r);for(const[a,i]of Object.entries(s))t[a]||dw(e,a,i.cwd??null)}function uw(){const e=le();u.useEffect(()=>{Fm();let t={},s={};const r=iw(()=>qa(e)),o=rt.subscribe(c=>{c.sessions!==t&&(Qa(e,c.sessions,t),r.request(),cw(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 mw(e){const{shouldShowOnboarding:t,onboardingHiddenForSession:s}=e,r=t&&!s,[o,a]=u.useState(!1);return r&&!o&&a(!0),o&&!s}function hw(){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 fw(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 pw=2500,gw="Couldn’t finish setup. Try again.";function Ln(e){return e instanceof Error&&e.message&&!/^HTTP \d+$/.test(e.message)?e.message:gw}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 xw(e){const t=ie(),{data:s}=Ee({queryKey:wc.status(),queryFn:()=>t.getCloudCredits(),enabled:e,refetchInterval:e?pw:!1,refetchIntervalInBackground:e,staleTime:0});if(s)return s.readiness??(s.linked?"linked":"unlinked")}function bw(){const e=ie(),t=le();return Qt({mutationFn:()=>e.postOnboardingWelcome(),onSettled:()=>void t.invalidateQueries({queryKey:Fe.all}),meta:{suppressErrorToast:!0}})}function yw({link:e,waitingWindowRef:t,onReady:s}){const r=Bo(),[o,a]=u.useState(null),[i,c]=u.useState(!1),d=xw(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:vw(o,i,e,y,l),retry:C}}function vw(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(ww,{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 ww({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(jw,{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 jw({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 kw({onComplete:e}){const t=bw(),{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 Sw="claude-code";function nu(e,t){return e.length===0?null:e.includes(t)?t:jc.find(r=>e.includes(r))??e[0]}function Cw({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)??Sw,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 Nw({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=Cw({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:Ew(m,g.runtime)}),n.jsx(Aw,{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 Aw({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 Ew(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 Iw=[{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."}],Rw={openai:"OpenAI API key",anthropic:"Anthropic API key",openrouter:"OpenRouter key"};function Tw({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:Iw.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:U("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(Dw,{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 Dw({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(Nw,{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(Ow,{service:e,busy:t,save:s,onSaved:r})}}function Ow({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(We,{htmlFor:`${o}-key`,children:Rw[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 Mw({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(Tw,{...t}),n.jsx(F,{variant:"ghost",size:"sm",className:"text-muted-foreground mt-6 self-start",onClick:e,children:"Back"})]})}function _w({agentName:e,className:t}){var c;const s=hd(),r=e.trim()||"This agent";if(s.isPending)return n.jsx("p",{className:U("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:U("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=Ry(d.access.classifications);return`${l} (${d.lifecycle==="paused"?`${m}, paused`:m})`});return n.jsxs("div",{className:U("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 Pw({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 Lw({onComplete:e,slots:t}){const s=t==null?void 0:t.renderAccountLink,r=o=>n.jsx(Fw,{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 Fw({link:e,slots:t,onComplete:s}){var I;const{stage:r,goToStage:o,goBack:a}=hw(),{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($w,{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(Mw,{onBack:C,onSaved:y,beforePick:f,slots:t}):r==="landing"?k=n.jsx(kw,{onComplete:s}):k=n.jsx(Pw,{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 $w({link:e,waitingWindowRef:t,onReady:s,onCancel:r,onUseOwnAi:o}){const{phase:a,retry:i}=yw({link:e,waitingWindowRef:t,onReady:s});return n.jsx(tu,{phase:a,link:e,onRetry:i,onCancel:r,onUseOwnAi:o})}function Bw(){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 zw=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 Uw(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 Kw(e,t){const s=e.getQueryData(Ke.detail(t.threadId));return s===void 0||s.viewerAuthorId===t.userId}function Hw(e,t){const s=e.isFetching({queryKey:Ke.lists()})>0;e.cancelQueries({queryKey:Ke.lists()}),e.setQueriesData({queryKey:Ke.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(Ke.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(Ke.threads());r!=null&&r.some(o=>o.roomId===t.threadId&&o.unreadCount>0)&&e.invalidateQueries({queryKey:Ke.threads()}),s&&e.invalidateQueries({queryKey:Ke.lists()})}function Ww(){const e=le(),t=()=>{e.invalidateQueries({queryKey:Ke.lists()}),e.invalidateQueries({queryKey:Ke.wellKnowns()}),e.invalidateQueries({queryKey:Ke.threads()})};pe(Sn[0],t),pe(Sn[1],t),pe(Sn[2],t),pe(Sn[3],t),pe(Sn[4],t),pe("room_awaiting",t),pe("room_updated",o=>{Ja(o)&&e.invalidateQueries({queryKey:Ke.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:Ke.detail(i)})},zw)};pe("room_member_added",r),pe("room_member_removed",r),pe("room_presence",o=>Wm.getState().observe(o)),pe("read_cursor",o=>{!Uw(o)||!Kw(e,o)||Hw(e,o)})}function Gw(){const e=le();pe("capabilities_changed",()=>{e.invalidateQueries({queryKey:Ec.all})})}function qw(){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 Yw(){const e=le(),t=()=>{e.invalidateQueries({queryKey:[...Gm],exact:!0})};pe("tasks_changed",t),pe("task_run_finished",()=>{t(),e.invalidateQueries({queryKey:[...ia]})});const s=()=>{e.invalidateQueries({queryKey:[...ia]})};pe("task_run_failed",s),pe("task_run_updated",s)}function Vw(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 Qw({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:U("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 Xw=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 Jw(){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"),Xw);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 Zw=4e3,or="Tell DorkBot your name",Za="Tell DorkBot about your work";function ej({onDismiss:e}){const t=ht(),s=Pe(),{open:r}=ct(),o=uo(),a=L(D=>D.requestTour),{startSession:i}=tw(),{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"),Zw);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:By,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 tj({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 nj=4e3;function sj(){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"),nj);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 rj({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 oj(){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 aj(){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 ij({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 cj(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 lj(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 dj={"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 uj(e){return dj[e]??`Found by the “${e}” check.`}const mj={"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 hj(e){return mj[e]??"Found in the project’s files."}function fj({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:U("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:uj(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:hj(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 pj({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 gj=2;function xj({agents:e}){const[t,s]=u.useState(e.length<=gj);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:U("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(pj,{agent:r},r.path))})]})}function bj({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 yj({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 vj(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 wj(){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 jj=[{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 kj({fullBleed:e=!1,onRegistered:t}){var X;const{roots:s,setScanRoots:r}=Bw(),[o,a]=u.useState(null),[i,c]=u.useState(!1),[d,l]=u.useState(3),{startScan:m}=oj(),{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}=aj(),R=o??s,_=u.useCallback(V=>b({path:V.path,overrides:cj(V),scanRoot:vj(V.path,R)}),[R,b]),D=u.useCallback(V=>{v(V.path),t==null||t()},[v,t]),{failedPaths:P,pendingPaths:T,registerCandidate:j,resetFailures:w}=ij({register:_,onSuccess:D});function N(V){a(V),r(V)}function S(){R.length>0&&(E(),w(),m({roots:R,maxDepth:d}))}const B=u.useMemo(()=>f?h:lj(h),[h,f]).filter(V=>!I.has(V.path)),O=(((X=k==null?void 0:k.agents)==null?void 0:X.length)??0)>0,$=p.length>0,Y=h.length>0,ee=$||Y,H=!f&&y!==null,W=!f&&y===null;function oe(){for(const V of B)j(V)}const he=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(yj,{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:V=>l(Number(V.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(Uy,{className:"size-3"}),"What it looks for"]}),n.jsx("ul",{className:"space-y-1 pl-4",children:jj.map(V=>n.jsxs("li",{className:"flex items-baseline gap-1.5",children:[n.jsx("code",{className:"text-foreground/70 text-3xs",children:V.signal}),n.jsxs("span",{className:"text-muted-foreground text-3xs",children:["→ ",V.label]})]},V.name))})]})]})]});return n.jsx("div",{className:e?"flex h-full flex-col p-6":"space-y-4 p-4",children:W?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(wj,{}),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"}),he]})}):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:[he,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}),H&&!Y&&$&&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."})]}),H&&!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."})]}),H&&B.length>0&&n.jsxs(n.Fragment,{children:[n.jsx(bj,{count:B.length,onAddAll:oe,disabled:T.size>0}),n.jsx(Ve,{mode:"popLayout",children:B.map(V=>n.jsx(fj,{candidate:V,className:"mb-2",registrationFailed:P.has(V.path),registrationPending:T.has(V.path),onApprove:ne=>void j(ne),onSkip:ne=>v(ne.path),onDeny:ne=>C({path:ne.path},{onSuccess:()=>v(ne.path)})},V.path))})]}),H&&$&&n.jsx("div",{className:"mt-3",children:n.jsx(xj,{agents:p})})]})]})})}function Sj(){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(kj,{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 Cj(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 Nj(){const e=Xm(s=>s.record),t=Ib();pe("marketplace_dev_link_reloaded",s=>{Cj(s)&&(e(s),t())})}function Aj(){const e=le();pe("relay_bindings_changed",()=>{e.invalidateQueries({queryKey:[...vb]})})}const ti="inbox",Ej="open";function Ij({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===Ej?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"]),Rj={};function Tj(e,t){var Pt,z,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}=Zm(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 q;return g?(q=A.roomCanvasActive[g])==null?void 0:q.canvas:A.activeCanvasDocumentId}),E=L(A=>{var q;return g?(q=A.roomCanvasActive[g])==null?void 0:q.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(q=>`resource/terminal/${q.id}`===j.id):T.tabs.find(q=>q.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,Y=g?`room:${g}`:eh(O,$),ee=g?`room:${g}`:sh(O,$),H=L(A=>A.panelViewPreferences)??Rj,W=L(A=>A.updatePanelViewPreference),oe=L(A=>A.reopenPanelResourceView),he=u.useMemo(()=>new Set(Object.values(H).flatMap(A=>A.closed)),[H]),X=H[S]??{opened:[],closed:[]},V=((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"||V),[e,V]),ye=A=>W==null?void 0:W(S,A),se=A=>{var q;return((q=Re.find(Z=>Z.id===A))==null?void 0:q.resource)==="browser"},ze=A=>{var q;return se(A)?A:(q=Re.find(Z=>Z.id===A))!=null&&q.resource?`${Y}:${A}`:A},G=A=>{var q;return((q=Re.find(Z=>Z.id===A))==null?void 0:q.resource)==="document"?[ze(A),`${ee}:${A}`]:[ze(A)]},fe=A=>{var q;return((q=Re.find(Z=>Z.id===A))==null?void 0:q.resource)==="document"},ve=A=>A==="profile"&&t==="/session",Qe=A=>!ve(A)&&G(A).some(q=>fe(A)||se(A)?he.has(q):X.closed.includes(q)),Re=ne.flatMap(A=>{const q=A.id;if(q==="local-browser"){if(!p)return[{...A,category:q,title:"Browser"}];const Z=p.tabs.find(ge=>ge.id===p.selectedTabId),ae=p.mode==="embedded"?"DorkOS browser":"New browser window";return[{...A,category:q,resource:"browser",id:f,title:(Z==null?void 0:Z.title)||ae,icon:gs}]}if(q==="browser"||q==="canvas"){const Z=g?th(y??[],q):nh(x??[],q);if(Z.length)return Z.map(ae=>{var ge,et,Se;return{...A,category:q,resource:"document",id:`resource/${ae.id}`,title:"title"in ae&&ae.title||ae.sourceLabel||A.title,icon:q==="browser"?gs:vy,activate:()=>{g?_(g,ae.id):R(ae.id)},..."authorId"in ae?{author:(et=(ge=k.data)==null?void 0:ge.members.find(Ue=>Ue.author.id===ae.authorId))==null?void 0:et.author,unread:(Se=b==null?void 0:b[q])==null?void 0:Se.includes(ae.id),pinned:ae.pinned,watchers:Object.entries(C??{}).filter(([Ue,J])=>{var Ce;return J===ae.id&&Ue!==((Ce=k.data)==null?void 0:Ce.viewerAuthorId)}).flatMap(([Ue])=>{var J,Ce;return((Ce=(J=k.data)==null?void 0:J.members.find(St=>St.author.id===Ue))==null?void 0:Ce.author)??[]})}:{}}})}return q==="terminal"&&(T!=null&&T.tabs.length)?T.tabs.map(Z=>({...A,category:q,resource:"terminal",id:`resource/terminal/${Z.id}`,title:Z.title,closed:Z.closed,icon:_c,activate:ae=>T.activate(Z.id,ae)})):[{...A,category:q,...q==="browser"?{title:"Page previews"}:{},...ve(q)?{permanent:!0}:{}}]}),Xe=new Set;if(!g){const A=(x??[]).filter(q=>q.id.startsWith("pending:")&&Qe(`resource/${q.id}`));for(const q of x??[])q.id.startsWith("pending:")||q.openedHere||A.some(Z=>{var ae;return(ae=Z.pendingCandidateIds)==null?void 0:ae.includes(q.id)})&&Xe.add(`resource/${q.id}`)}const te=Re.some(A=>si.has(A.category)||!ri.has(A.category)&&!A.isGlobal),be=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||X.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&&!be.some(A=>A.category==="terminal")){const A=ne.find(q=>q.id==="terminal");A&&be.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=((z=be.find(A=>A.id===we))==null?void 0:z.id)??((ke=be.find(A=>A.category===s))==null?void 0:ke.id)??null,qe=g?y==null?void 0:y.find(A=>`resource/${A.id}`===we):x==null?void 0:x.find(A=>`resource/${A.id}`===we),K=qe?`${qe.rev}:${qe.lastActiveAt}`:null,de=L(A=>A.requestedRightPanel),je=(A,q="pointer")=>{var ae;const Z=Re.find(ge=>ge.id===A);Z&&(ye(ge=>({opened:[...new Set([...ge.opened,Z.category])].slice(-100),closed:ge.closed.filter(et=>!G(A).includes(et))})),(Z.resource==="document"||Z.resource==="browser")&&(oe==null||oe(G(A))),w(Z.resource==="terminal"?{scope:P,id:Z.id}:null),(ae=Z.activate)==null||ae.call(Z,q),r(Z.category))},Je=A=>{var et;if(ve(A))return;const q=x==null?void 0:x.find(Se=>Se.id.startsWith("pending:")&&`resource/${Se.id}`===A),Z=q?be.filter(Se=>{var Ue;return!((Ue=q.pendingCandidateIds)!=null&&Ue.some(J=>{var Ce;return`resource/${J}`===Se.id&&!((Ce=x==null?void 0:x.find(St=>St.id===J))!=null&&Ce.openedHere)}))}):be,ae=Z[Z.findIndex(Se=>Se.id===A)+1]??Z[Z.findIndex(Se=>Se.id===A)-1],ge=Re.find(Se=>Se.id===A);if(w(null),(ge==null?void 0:ge.resource)==="terminal"&&(T!=null&&T.hide))T.hide(A.slice(18));else{const Se=Ue=>({...Ue,closed:[...new Set([...Ue.closed,ze(A)])].slice(-100)});(ge==null?void 0:ge.resource)==="document"?W==null||W(`documents:${Y}`,Se):(ge==null?void 0:ge.resource)==="browser"?W==null||W(`browsers:${m}`,Se):ye(Se)}A===jt&&((et=ae==null?void 0:ae.activate)==null||et.call(ae,"keyboard"),r((ae==null?void 0:ae.category)??null))};u.useEffect(()=>{if(!s)return;const A=we?G(we):[];!X.closed.includes(s)&&(!we||!Qe(we))||(ye(q=>({...q,closed:q.closed.filter(Z=>Z!==s&&!A.includes(Z))})),we&&(fe(we)||se(we))&&(oe==null||oe(A)))},[s,we,K,de,Y,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:be,activeId:jt,activate:je,closeView:Je,terminal:T,createTerminal:ne.some(A=>A.id==="terminal")?()=>{w({scope:P,id:null}),ye(A=>({opened:[...new Set([...A.opened,"terminal"])].slice(-100),closed:A.closed.filter(q=>q!=="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 Dj({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(Ye,{"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(Ye,{onSelect:r,children:[n.jsx(_c,{}),"New terminal"]})]}),a&&n.jsx(Ye,{onSelect:a,children:"New page preview"}),i&&n.jsx(Ye,{onSelect:i,children:"New document"}),d&&n.jsxs(n.Fragment,{children:[n.jsx(os,{}),n.jsx(Ye,{onSelect:d,children:l?"Unpin document":"Pin document"})]}),c&&n.jsx(Ye,{onSelect:c,children:"Remove document"}),o&&n.jsxs(n.Fragment,{children:[n.jsx(os,{}),n.jsx(Ye,{onSelect:o,children:"Stop terminal"})]})]})]})}function Oj({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=rh(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(oh,{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(Ye,{onSelect:()=>{d&&l(!1),c({href:Lc(f.extensionId,f.path)})},children:[n.jsx(ah,{}),"Open full page"]}),h&&n.jsxs(Ye,{onSelect:()=>o(e.id,ch(p(e),s)),children:[n.jsx(ih,{}),"Hide here"]}),n.jsxs(Ye,{onSelect:()=>i.open("extensions",e.extensionId),children:[n.jsx(lh,{}),"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(Ye,{onSelect:()=>{o(x.id,dh(p(x),s)),a(x.id)},children:[x.icon?n.jsx(Kn,{icon:x.icon}):n.jsx(Dt,{}),x.title]},x.id))]})]})]})}const Mj={canvas:"canvas",browser:"browser"};function _j(e,t){return t==="attention"?`${e}, something needs you`:e}function Pj({contributionId:e}){const t=Mj[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 uh(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 Lj({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(Fj,{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 Fj({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 min-h-9 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":[_j(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:U("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(Pj,{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",$j=40,Bj=320,au=20,zj=50;function Uj(e){if(e<=0)return au;const t=Bj/e*100;return Math.min(Math.round(t*10)/10,zj)}function Kj(){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(Uj(s.offsetWidth));r();const o=new ResizeObserver(r);return o.observe(s),()=>o.disconnect()},[]),{minPct:e,defaultPct:Math.max($j,e)}}function Hj(e,t){var f;const s=mh(e),r=hh(),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(()=>Wj(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 Wj(e,t,s,r){const o={page:e};return t&&(o.roomId=t),r&&(o.agentId=s),o}const Gj="cubic-bezier(0, 0, 0.2, 1)",qj="cubic-bezier(0.4, 0, 1, 1)";function oi(e,t){return`${e} 300ms ${t?Gj:qj}`}const Yj=new Set(["pulse","files"]);function Vj(e){e.preventDefault();const t=document.getElementById(Uo);t&&!t.contains(document.activeElement)&&t.focus({preventScroll:!0})}function Qj({pathname:e,isRemoteCommunityRoom:t=!1}){var ze;const s=L(G=>G.rightPanelOpen),r=L(G=>G.setRightPanelOpen),o=L(G=>G.activeRightPanelTab),a=L(G=>G.setActiveRightPanelTabView),i=jd(),c=_e(),d=Hd(),l=u.useRef(null),[m,h]=u.useState(!1),[p,f]=u.useState(!1);u.useEffect(()=>{const G=requestAnimationFrame(()=>f(!0));return()=>cancelAnimationFrame(G)},[]);const g=ie(),x=L(G=>G.currentAgentId),y=L(G=>G.selectedCwd),b=L(G=>G.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(G=>!G.visibleWhen||G.visibleWhen({pathname:e,transport:g,agentId:x,cwd:y,explicitAgentPath:b,isRemoteCommunityRoom:t,directMessage:v})),[E,e,g,x,y,b,t,v]),_=Hj(e,t),D=_.status==="ready"?_.here:_.last,P=py(),T=Me().data!==void 0,j=u.useMemo(()=>new Map(P.map(G=>[G.tab,G])),[P]),{visibleContributions:w,hiddenMiniAppTabs:N}=u.useMemo(()=>{const G=[],fe=[];for(const ve of R)ve.extensionId?D&&fh(Fc(j.get(ve.id),ve.declaredPlacement),D)?G.push(ve):fe.push(ve):G.push(ve);return{visibleContributions:G,hiddenMiniAppTabs:fe}},[R,D,j]),S=Tj(w,e),M=S.visible,O=`${L(G=>G.sessionId)??""}:${y}`;u.useEffect(()=>{if(!(_.status==="pending"||k==="pending")&&M.length>0&&!M.some(fe=>fe.category===o)){const fe=M.find(ve=>!ve.isGlobal);a((fe??M[0]).category)}},[M,o,a,_.status,k]);const $=s,{minPct:Y,defaultPct:ee}=Kj();u.useEffect(()=>{const G=l.current;G&&($&&G.isCollapsed()?G.expand(ee):!$&&G.isExpanded()&&G.collapse())},[$,ee]);const H=G=>k==="pending"?E.find(fe=>fe.id===G):void 0,W=S.available.find(G=>G.id===o&&M.some(fe=>fe.category===G.id))??H(o),oe=S.available.find(G=>G.id==="terminal")??H("terminal"),he=oe==null?void 0:oe.component,X=S.terminal!==null||o==="terminal",V=W==null?void 0:W.component,ne=W==null?void 0:W.headerActions,ye=n.jsxs(n.Fragment,{children:[n.jsx(Lj,{contributions:M,activeId:S.activeId,onActivate:S.activate,onCloseView:S.closeView,actions:n.jsxs(n.Fragment,{children:[n.jsx(Dj,{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"&&((ze=S.terminal)!=null&&ze.activeId)?()=>{var G;return(G=S.terminal)==null?void 0:G.stop(S.terminal.activeId,"pointer")}:void 0}),ne?n.jsx(u.Suspense,{fallback:null,children:n.jsx(ne,{})}):null,_.status==="ready"&&T&&n.jsx(Oj,{active:W!=null&&W.extensionId?W:null,hidden:N,here:_.here,saved:j})]})}),(C==null?void 0:C.kind)==="group"&&s&&n.jsx(Qw,{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(G=>G.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(ph,{value:!0,children:[s&&o!=="terminal"&&V?n.jsx(V,{}):null,he&&X&&n.jsx("div",{hidden:o!=="terminal"||!s||!W,className:"h-full",children:n.jsx(gh,{value:o==="terminal"&&s&&!!W,children:n.jsx(ni,{tabId:o,children:n.jsx(he,{})})})},O),!W&&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(xh,{open:!0,onOpenChange:G=>!G&&r(!1),children:n.jsxs(bh,{showCloseButton:!1,...o===la?{onOpenAutoFocus:Vj}:{},style:{top:d.top,bottom:"auto",height:d.height,maxHeight:d.height},className:U("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&&Yj.has(o)&&"!bottom-auto !h-auto max-h-dvh overflow-y-auto"),children:[n.jsxs(yh,{className:"sr-only",children:[n.jsx(vh,{children:"Panel"}),n.jsx(wh,{children:"Right panel content."})]}),ye]})}):null;const se=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",...se&&{transition:oi("opacity",$)}}}),n.jsx(Kc,{ref:l,id:"right-panel",order:2,defaultSize:$?ee:0,minSize:Y,collapsible:!0,collapsedSize:0,onCollapse:()=>{p&&r(!1)},onExpand:()=>{s||r(!0)},style:se?{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:ye})})]})}function Xj(){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 Jj=0;function Zj(e){const t=ai.get(e);if(t!==void 0)return t;const s=`bar-${Jj++}`;return ai.set(e,s),s}function ek(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:Zj(r),Header:r}}return null}function tk(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 nk="/";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:()=>kh(e,nk),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=>{jh(e,a).catch(i=>{console.error("[dorkos:tabs] could not reopen a closed tab",i)})}}},[e])}const sk={start:["Space"],cancel:["Escape"],end:["Space","Enter","Tab"]},rk=4,ok={draggable:"Press Space to move this tab. Arrows move it, Space drops it, Escape cancels."};function ak(e){return t=>{const s=e(String(t.active.id));return Wc({...t,droppableContainers:t.droppableContainers.filter(r=>e(String(r.id))===s)})}}class ik extends Map{getEnabled(){return[...this.values()].filter(t=>!t.disabled)}toArray(){return[...this.values()]}}function ck(e){return(t,s)=>{const{context:r}=s;if(!r.active)return Er(t,s);const o=e(String(r.active.id)),a=new ik;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 lk(e){return e.length===0?null:{left:Math.min(...e.map(t=>t.left)),right:Math.max(...e.map(t=>t.right))}}function dk(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 uk(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 mk(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 hk=500;function fk(e){const t=Hn(new Date(e).toISOString());return`Last active ${t==="Just now"?"just now":t}`}function pk({identity:e,className:t}){return n.jsxs("div",{className:U("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:fk(e.lastActiveAt)})]})}function gk({identity:e,children:t}){return n.jsxs(yd,{openDelay:hk,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(pk,{identity:e})})]})}const iu="app-tab-panel";function xk({identity:e,isActive:t,canClose:s,collapseAgent:r=!1,pinned:o=!1,tabProps:a,onClose:i}){const c=Ch(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(gk,{identity:e,children:n.jsxs("button",{type:"button",role:"tab","aria-selected":t,"aria-controls":t?iu:void 0,"aria-label":Nh(e,{collapseAgent:r}),...a,className:U("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:U("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 bk({tab:e,isActive:t,canClose:s,pinned:r,tabProps:o,onClose:a}){const i=Ps(e.href),c=Sh(i.agentKey);return n.jsx(xk,{identity:i,isActive:t,canClose:s,collapseAgent:c,pinned:r??e.pinned??!1,tabProps:o,onClose:d=>a(e.id,d)})}function yk({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 vk({tabId:e,pinned:t,hasOthersToClose:s,canClose:r,actions:o,onClosed:a,children:i}){const c=Ah(),{reopenClosed:d}=o;return n.jsxs(Eh,{children:[n.jsx(Ih,{asChild:!0,children:i}),n.jsxs(Rh,{className:"w-56",onCloseAutoFocus:a?l=>{l.preventDefault(),a()}:void 0,children:[n.jsxs(Lt,{onSelect:()=>o.togglePin(e),children:[t?n.jsx(Th,{className:"mr-2 size-4"}):n.jsx(Dh,{className:"mr-2 size-4"}),t?"Unpin":"Pin"]}),n.jsxs(Lt,{onSelect:()=>o.duplicate(e),children:[n.jsx(zy,{className:"mr-2 size-4"}),"Duplicate"]}),n.jsxs(Lt,{onSelect:()=>o.copyLink(e),children:[n.jsx(Oh,{className:"mr-2 size-4"}),"Copy link"]}),n.jsx(da,{}),n.jsxs(Lt,{disabled:!s,onSelect:()=>o.closeOthers(e),children:[n.jsx(Mh,{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(_h,{children:[n.jsxs(Ph,{disabled:c.length===0,children:[n.jsx(kd,{className:"mr-2 size-4"}),"Recently closed"]}),n.jsx(Lh,{className:"max-h-96 w-64 overflow-y-auto",children:c.map(l=>n.jsx(yk,{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 wk({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}=Fh({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:U("flex shrink-0",b&&"bg-background shadow-soft relative z-10 rounded-md"),children:n.jsx(bk,{tab:e,isActive:t,canClose:s,tabProps:D,onClose:o,pinned:m})});return c?n.jsx(vk,{tabId:e.id,pinned:m,hasOthersToClose:d,canClose:s,actions:c,onClosed:l,children:P}):P}const jk=32;function kk({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:ak(N),coordinateGetter:ck(N),modifiers:[dk(h.read)],announcements:mk({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,jk)},[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:rk}}),xs(Vc,{coordinateGetter:C,keyboardCodes:sk})),_=({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 Y;const $=O.getAttribute(Ft);return(((Y=e.find(ee=>ee.id===$))==null?void 0:Y.pinned)??!1)===N}).map(O=>O.getBoundingClientRect());h.write(lk(S))},D=()=>{g(!1),h.write(null)},P=({active:w,over:N})=>{D();const S=uk(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}=jy({orderedIds:e.map(w=>w.id),activeId:t,onActivate:s,onClose:p?r:void 0,getFallbackFocus:()=>d.current});return n.jsxs("div",{className:U("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:ok},onDragStart:_,onDragEnd:P,onDragCancel:D,children:n.jsx($h,{items:x,strategy:Bh,children:n.jsx("div",{ref:l,role:"tablist","aria-label":"Open tabs",className:"flex items-stretch gap-1",children:e.map(w=>n.jsx(wk,{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 Sk({className:e}){const t=zh(),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(tk(g.href))}}),[i,c,d,o,m,h]);return n.jsx(kk,{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 Ck(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 Nk({href:e,isCurrent:t,onSelect:s}){const r=Ps(e);return n.jsxs(Ye,{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:U("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 Ak(){const e=Xt(),{entries:t,cursor:s,canGoBack:r,canGoForward:o}=Uh();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(Nk,{href:i,isCurrent:c===s,onSelect:()=>Ck(e,c)},c))})]})]})}function Ek(){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 Ik(){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,Rk=4;function Tk(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 Dk(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(Tk(e.target))return null;if(e.key==="ArrowLeft")return"back";if(e.key==="ArrowRight")return"forward"}return null}function Ok(){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=Dk(i);c&&(i.preventDefault(),t(c))},r=i=>i.button===li||i.button===Rk,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 Mk(e){return typeof e=="object"&&e!==null&&e.status===404}async function _k(e){try{return await e(),!1}catch(t){return Mk(t)}}async function Pk(e,t){const s=new Map,r=(a,i)=>{let c=s.get(a);return c||(c=_k(i),s.set(a,c)),c},o=await Promise.all(e.map(async a=>{const i=Kh(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 Lk(){const e=ie(),t=Xt();u.useEffect(()=>{if(!$e())return;let s=!1;const r=ue.getState().tabs;return Pk(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 Fk(){Ek(),Ik(),Hh(),Lk(),Ok()}function $k(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 Bk=5*6e4;function zk(e){return e.status==="active"&&e.enabled}function Uk(e){const{enabled:t}=Gh(),{data:s}=el(t),{data:r}=qh(t),o=Mn(c=>c.setSchedulesWaitingCount),a=u.useMemo(()=>{const c=Vw(t?r??[]:[]),d=new Map((s??[]).filter(zk).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?[$k(m)]:[]})}},[t,r,s,e]),i=u.useMemo(()=>Yh(a),[a]);Wo("/tasks",i),u.useEffect(()=>{o(e)},[e,o])}function Kk(){const{count:e,more:t}=Vh(),s=u.useMemo(()=>Qh(e,t),[e,t]);Wo("/activity",s)}function Hk(){const{data:e,isSuccess:t}=Kx("pending"),{data:s}=Hx("pending",{enabled:t,refetchInterval:Bk}),r=((e==null?void 0:e.length)??0)+((s==null?void 0:s.length)??0),o=u.useMemo(()=>Xh(r),[r]);Wo("/connections",o)}function Wk(){const{items:e,schedules:t}=Wh(),s=Mn(r=>r.setNeedsYouCount);u.useEffect(()=>{s(e.length)},[e.length,s]),Uk(t.length),Kk(),Hk()}function Kt(e){return"problem"in e?{problem:e.problem}:{message:e.message}}const Ht={message:"Couldn’t reach your DorkOS account. Try again."},Gk={message:"Finish signing in in your browser, then try again."},qk={message:"Your browser blocked the window. Allow pop-ups, then try again."},cr={message:"Couldn’t connect this DorkOS to the space. Try again."},Yk={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:qk}));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:Gk}));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?Yk: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 Vk(e){return Yn.meta({description:e,[sd]:!0})}const Qk=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."),Xk=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."),Jk=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."),Zk=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(Qk).describe("Where the community is in its lifecycle. A state this release does not know reads as unrecognised."),hold:me({reason:ws(Xk).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:Jk.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:xe().int().positive().nullable().describe("The most people who may be active members at once. Null means no limit."),maxStorageBytes:xe().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:xe().int().nonnegative(),storageBytes:xe().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:Zk,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 eS=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:eS.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 tS=me({communityId:at,claimUrl:Vk("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:tS.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 nS=Wn(["awaiting_upload","importing","ready","failed","cancelled","claimed"]).describe("Where a move is: waiting for the export, importing it, ready to claim, or finished."),sS=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."),rS=me({channels:xe().int().nonnegative(),entries:xe().int().nonnegative().describe("Messages and replies."),attachments:xe().int().nonnegative(),historicalMembers:xe().int().nonnegative().describe("People whose messages move. They join again by invitation."),historicalAgents:xe().int().nonnegative().describe("Agents whose messages move. Their owners pair them again."),attachmentBytes:xe().int().nonnegative(),countedBytes:xe().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(nS).describe("Where the move is. A state this release does not know reads as unrecognised."),failureCode:ws(sS).nullable().describe("Why the move failed. Always set when the state is failed. A code this release does not know reads as unrecognised."),report:rS.nullable().describe("What the export holds, once it has been read. Null before then."),pollAfterMs:xe().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:xe().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 oS=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:xe().int().positive().describe("The largest file the upload accepts."),parts:me({partBytes:xe().int().positive().describe("The largest part the upload accepts."),maxBytes:xe().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,aS=me({partNumber:xe().int().positive().max(Yo).describe("The number of the part, counting up from one."),byteSize:xe().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(aS).max(Yo).describe("The parts received, in part order."),maxPartBytes:xe().int().positive().describe("The largest part the upload accepts."),maxArchiveBytes:xe().int().positive().describe("The largest file a parted upload accepts.")}).describe("The parts of a parted upload received so far.");me({parts:xe().int().positive().max(Yo).describe("How many parts make up the file."),archiveBytes:xe().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:oS.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 iS=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."),cS=me({origin:iS}).describe("A Community server whose single sign-on is this account.");me({servers:Gn(cS).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 lS(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 dS(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 uS=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 mS(){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 hS(){const e=ie(),t=le(),s=mS(),[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 fS(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 pS(e){return e.state==="awaiting_upload"||e.state==="importing"||e.state==="ready"}function gS(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?fS(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 xS(){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(pS))==null?void 0:c.moveId)??null}}const bS={message:"Your spaces changed. Check the list again."};function yS(){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"?bS: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 vS(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 wS({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=vS(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:lS(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:dS(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 jS(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 kS(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(wS,{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=jS(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 SS(e){return e.open?n.jsx(CS,{...e}):null}function CS({open:e,onOpenChange:t,installName:s,onOpenMove:r,onMoveHere:o,onConnected:a}){var f;const i=rd(!0),c=yS(),[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(kS,{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 NS(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}:NS(e.webAddressStatus);return n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{className:"space-y-1.5",children:[n.jsx(We,{htmlFor:`${t}-name`,children:"Space name"}),n.jsx(yt,{id:`${t}-name`,required:!0,maxLength:uS,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(We,{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 AS="Your history is here. Send invitations so people can join again.";function ES(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 IS({file:e,onFileChange:t}){const s=u.useId();return n.jsxs("div",{className:"space-y-1.5",children:[n.jsx(We,{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 RS(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(IS,{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 TS(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 DS(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 OS(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=DS(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 MS(e){return e.open?n.jsx(_S,{...e}):null}function _S({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=gS(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=TS(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:AS,onOpenClaim:y.openClaim,onConfirmClaimed:y.confirmClaimed,onOpenApproval:y.openApproval,onRetryConnect:y.retryConnect,onClose:b}):f.step?k=OS(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=ES(()=>i("choose"),b):k=RS({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 PS(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 LS(e){return e.open?n.jsx(FS,{...e}):null}function FS({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=hS(),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}):PS({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 $S({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(LS,{open:(t==null?void 0:t.kind)==="start",onOpenChange:a,installName:r,allowance:e.allowance,onConnected:o}),n.jsx(MS,{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(SS,{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 BS=.1;function zS(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>=BS||!/^\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 US(e){if(e.state!=="loading")return e.state==="signed-out"?"Not signed in":["Signed in",e.label,e.lowCredits].filter(Boolean).join(" · ")}function KS(){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:zS(s.data)}:{state:"signed-out"}}function HS(){const e=le();pe("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 WS(e){return e.kind==="agent"?`No chats with ${zr(e)} yet.`:`No chats came from ${zr(e)}.`}function GS(e){return e.kind==="channel"&&e.slug?`#${e.slug}`:e.title}function qS(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=GS(r);t.has(o)||t.set(o,r.id)}return t}function YS(e,t){const s=[];e.cwd!==null&&s.push(qt("agent",e.cwd));const r=VS(e,t);return r!==void 0&&s.push(qt("room",r)),s}function VS(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 QS(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(QS)}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 XS(){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 JS=8;function ZS(e,t){const s=new Set(Jh(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 e0(e){return!(e.unreadCount===null||e.archived||e.lastActivityAt===e.createdAt)}function t0({sessions:e,rooms:t,unreadRoomIds:s,agents:r,agentActivity:o,excludeSessionIds:a=new Set,limit:i=JS}){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(e0).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 n0=50;function ku(e){const t=[e.id];return e.who&&t.push(e.who),e.cwd&&t.push(e.cwd),t}function s0(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):s0(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 r0(e,t,s,r){const{data:o}=ol(n0),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 ZS(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(Zh((o==null?void 0:o.sessions)??[]).yours.map(f=>f.id));return t0({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)??o0}}const o0=Object.freeze({});function a0(){const{data:e,dataUpdatedAt:t}=Me(),s=e!==void 0&&t>ln,{status:r,url:o}=ef(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()||tf(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 i0(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 c0(){const{state:e,url:t,isSetUp:s}=cl();return u.useMemo(()=>i0(e,t,s),[e,t,s])}const l0=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 d0=[];function u0(e,t){const{data:s,isLoading:r}=qn(),o=XS(),{sessions:a}=ll(),i=u.useMemo(()=>!a||!e?null:nf(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(sf(h).map(N=>N.id)),w=new Set(rf.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=c0(),g=h?d0:f,x=u.useMemo(()=>[...d.filter(j=>j.category==="quick-action"&&!(h&&l0.has(j.id))),...g],[d,g,h]),y=u.useMemo(()=>of.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(()=>af(t),[t]),{sessions:v,continueRows:E,recent:R,agentActivity:_}=r0(b,k,C,I),D=u.useMemo(()=>qS(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:YS(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:cf(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 m0(){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 h0(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?"":h0(e)}function Te(e){return typeof e=="string"}function ds(e){return typeof e=="number"}function f0(e){return e===!0||e===!1||p0(e)&&Cu(e)=="[object Boolean]"}function Su(e){return typeof e=="object"}function p0(e){return Su(e)&&e!==null}function He(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 g0="Incorrect 'index' type",Hr="Invalid doc index: must be a non-negative integer within the bounds of the docs array",x0=e=>`Invalid value for key ${e}`,b0=e=>`Pattern length exceeds max of ${e}.`,y0=e=>`Missing ${e} property in key`,v0=e=>`Property 'weight' in key '${e}' must be a positive integer`,w0="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 j0=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(y0("name"));const i=e.name;if(r=i,pi.call(e,"weight")&&e.weight!==void 0&&(o=e.weight,o<=0))throw new Error(v0(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 k0(e,t){const s=[];let r=!1;const o=(a,i,c,d)=>{if(He(a))if(!i[c])s.push(d!==void 0?{v:a,i:d}:a);else{const l=a[i[c]];if(!He(l))return;if(c===i.length-1&&(Te(l)||ds(l)||f0(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 S0={includeMatches:!1,findAllMatches:!1,minMatchCharLength:1},C0={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},N0={location:0,threshold:.6,distance:100},A0={useExtendedSearch:!1,useTokenSearch:!1,tokenize:void 0,tokenMatch:"any",getFn:k0,ignoreLocation:!1,ignoreFieldNorm:!1,fieldNormWeight:1},Q=Object.freeze({...C0,...S0,...N0,...A0});function E0(e){return e>=9&&e<=13||e===32||e===160}function I0(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++)E0(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=Q.getFn,fieldNormWeight:t=Q.fieldNormWeight}={}){this.norm=I0(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!He(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(He(i)){if(Ot(i)){const c=[];for(let d=0,l=i.length;d<l;d+=1){const m=i[d];if(He(m)){if(Te(m)){if(!ts(m)){const h={v:m,i:d,n:this.norm.get(m)};c.push(h)}}else if(He(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=Q.getFn,fieldNormWeight:r=Q.fieldNormWeight}={}){const o=new Xo({getFn:s,fieldNormWeight:r});return o.setKeys(e.map(Nu)),o.setSources(t),o.create(),o}function R0(e,{getFn:t=Q.getFn,fieldNormWeight:s=Q.fieldNormWeight}={}){const{keys:r,records:o}=e,a=new Xo({getFn:t,fieldNormWeight:s});return a.setKeys(r),a.setIndexRecords(o),a}function T0(e=[],t=Q.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 D0(e,t,s,{location:r=Q.location,distance:o=Q.distance,threshold:a=Q.threshold,findAllMatches:i=Q.findAllMatches,minMatchCharLength:c=Q.minMatchCharLength,includeMatches:d=Q.includeMatches,ignoreLocation:l=Q.ignoreLocation}={}){if(t.length>32)throw new Error(b0(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=T0(b,c);D.length?d&&(_.indices=D):_.isMatch=!1}return _}function O0(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"},M0=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(M0,t=>Eu[t]):e=>e;var Zo=class{constructor(e,{location:t=Q.location,threshold:s=Q.threshold,distance:r=Q.distance,includeMatches:o=Q.includeMatches,findAllMatches:a=Q.findAllMatches,minMatchCharLength:i=Q.minMatchCharLength,isCaseSensitive:c=Q.isCaseSensitive,ignoreDiacritics:d=Q.ignoreDiacritics,ignoreLocation:l=Q.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:O0(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}=D0(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 _0=new Set(["fuzzy","include"]);function P0(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??Q.location,threshold:t.threshold??Q.threshold,distance:t.distance??Q.distance,includeMatches:t.includeMatches??Q.includeMatches,findAllMatches:t.findAllMatches??Q.findAllMatches,minMatchCharLength:t.minMatchCharLength??Q.minMatchCharLength,isCaseSensitive:t.isCaseSensitive??Q.isCaseSensitive,ignoreDiacritics:t.ignoreDiacritics??Q.ignoreDiacritics,ignoreLocation:t.ignoreLocation??Q.ignoreLocation});return{type:"fuzzy",search(r){return s.searchIn(r)}}}}],xi=Wr.length,L0="\0",F0="|";function $0(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 B0(e,t={}){return e.replace(/\\\|/g,L0).split(F0).map(s=>{const r=$0(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 z0=class{constructor(e,{isCaseSensitive:t=Q.isCaseSensitive,ignoreDiacritics:s=Q.ignoreDiacritics,includeMatches:r=Q.includeMatches,minMatchCharLength:o=Q.minMatchCharLength,ignoreLocation:a=Q.ignoreLocation,findAllMatches:i=Q.findAllMatches,location:c=Q.location,threshold:d=Q.threshold,distance:l=Q.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=B0(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,P0(g.type)&&(d=!0),s&&(_0.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]),U0=e=>!!e[qr.PATH],K0=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=U0(o);if(!i&&a.length>1&&!Yr(o))return r(yi(o));if(K0(o)){const d=i?o[qr.PATH]:a[0],l=i?o[qr.PATTERN]:o[d];if(!Te(l))throw new Error(x0(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=Q.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 H0(e,{ignoreFieldNorm:t=Q.ignoreFieldNorm}){e.forEach(s=>{s.score=Vr(s.matches,{ignoreFieldNorm:t})})}var W0=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 G0(e){const t=[];return e.matches.forEach(s=>{if(!He(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 q0(e,t,{includeMatches:s=Q.includeMatches,includeScore:r=Q.includeScore}={}){return e.map(o=>{const{idx:a}=o,i={item:t[a],refIndex:a};return s&&(i.matches=G0(o)),r&&(i.score=o.score),i})}const Y0=/[\p{L}\p{M}\p{N}_]+/gu,vi=new WeakSet;function V0(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 Q0(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||V0(e),t=>t.match(e)||[]):t=>t.match(Y0)||[]}function Qr({isCaseSensitive:e=!1,ignoreDiacritics:t=!1,tokenize:s}={}){const r=Q0(s);return{tokenize(o){return e||(o=o.toLowerCase()),t&&(o=$n(o)),r(o)}}}var X0=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 J0(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 Z0(e,t,s,r){Ru(e,t,s,r)}function eC(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)eC(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={...Q,...t},this.options.useExtendedSearch,this.options.useTokenSearch,this._keyStore=new j0(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(g0);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=J0(this._myIndex.records,this._myIndex.keys.length,s)}this._invalidateSearcherCache()}add(e){if(!He(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});Z0(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 W0(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),H0(h,{ignoreFieldNorm:c}),a&&h.sort(Te(e)?m:l),ds(s)&&s>-1&&(h=h.slice(0,s));return q0(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(!He(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(He(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(!He(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(!He(t))return[];const r=[];if(Ot(t))t.forEach(({v:o,i:a,n:i})=>{if(!He(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=R0;Mt.config=Q;Mt.match=function(e,t,s){if(s&&s.useTokenSearch)throw new Error(w0);return Cs(e,{...Q,...s}).searchIn(t)};Mt.parseQuery=Iu;ea(z0);ea(X0);Mt.use=function(...e){e.forEach(t=>ea(t))};var tC=Mt;const nC=.02,Tu=.5,Du=.35,Ou=.15,sC=1+Tu+Du+Ou,rC=4320*60*1e3,oC=3,aC=1440*60*1e3,iC=.15,cC={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 lC(e,t){const s=e.lastUsedAt===null?0:Mu(t-e.lastUsedAt,rC),r=Math.max(0,e.useCount),o=r===0?0:r/(r+oC);return ta((s+o)/2)}function dC(e,t){const s=e.distance===null?1:ta(Math.pow(2,-Math.max(0,e.distance)/nC)),r=lC(e.usage,t),o=e.lastActivityAt===null?0:Mu(t-e.lastActivityAt,aC),a=1+(e.waiting?Tu:0)+Du*r+Ou*o;return{score:s*a/sC,signals:{relevance:s,frecency:r,recency:o}}}function uC(e,t){return e.map(s=>{const{score:r,signals:o}=dC(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 mC(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<iC?{best:null,rest:s}:{best:r,rest:s.slice(1)}:{best:null,rest:s}}function hC(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 fC={keys:["name","keywords"],includeMatches:!0,includeScore:!0,threshold:.3,distance:100,minMatchCharLength:1};function pC(e,t,s){const{usage:r,now:o,scope:a}=s,{prefix:i,term:c}=u.useMemo(()=>a===null?gC(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 tC(l,fC),[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])??cC,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(()=>uC(h,o),[h,o]),{best:f,rest:g}=u.useMemo(()=>mC(p,{queried:c.length>0}),[p,c]);return{bestMatch:f,rows:g,prefix:i,term:c}}function gC(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 xC(){const e=jo(),t=lf();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 bC=/^\/([A-Za-z0-9][\w.-]*(?::[\w.-]+)*)(?=\s|$)\s*/;function yC(e,t){const s=t.trim().replace(bC,"").trim();return s?`${e} ${s}`:`${e} `}function vC(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(df(i)){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(),uf({queryClient:i,transport:c},t).then(async S=>{if(S===null){ma(t);return}t&&k(t);const M=mf.getState(),B=M.getSession(S.sessionId).input;M.updateSession(S.sessionId,{input:yC(N,B)}),a(S.isNew?await hf(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=>{ff(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(pf),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"])',wC=new Set(["ArrowUp","ArrowDown","Home","End"]),jC=new Set(["n","p","j","k"]);function kC({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||(wC.has(c.key)||c.ctrlKey&&jC.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 SC({scope:e,className:t}){return n.jsx("span",{"data-testid":"palette-scope-chip",className:U("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 CC(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 NC({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 AC({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(Sy,{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(Wy,{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(Ny,{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:EC(m.lastActive)})]},m.id))})]})}function EC(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 IC({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 RC=[{key:"#",means:"channels"},{key:"@",means:"agents and DMs"},{key:">",means:"commands"}];function Pu({className:e}){return n.jsx("div",{className:U("text-muted-foreground flex flex-wrap items-center gap-x-3 gap-y-1 px-3 py-2 text-xs",e),children:RC.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 TC({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(Ay,{agent:e,name:r?n.jsx(TC,{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 DC(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=DC(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 OC=6e4;function MC({lastActivityAt:e}){const t=Ks(OC),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:U("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:U("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:U("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(MC,{lastActivityAt:e.lastActivityAt}),s&&n.jsx(_C,{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:U("size-1.5 shrink-0 rounded-full",kf(t.signal))}),i]})]})]})}function _C({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 PC={session:"Conversations",agent:"Agents",room:"Channels",dm:"Direct messages",command:"Commands",feature:"Actions","quick-action":"Actions",page:"Add-ons"},LC="Best match",Jr={Clock:Ic,Radio:Ey,Globe:gs,Settings:zs,Plus:Dt,Search:ps,FolderOpen:Ds,Moon:Nf,Shapes:Cf,MessageSquarePlus:fl,Inbox:Sf},zt=[0,0,.2,1],FC=[.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:FC}}},$C={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 BC({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 zC({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 UC({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=hC(h,P=>r?ui(r):PC[P.item.item.type]),R=r&&!o&&h.length===0&&!m?WS(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:$C,initial:"hidden",animate:"visible",children:[t&&n.jsx(BC,{continueRows:c,recent:d,newActions:l,selectedCwd:a,selectedValue:i,onSessionSelect:C,onRoomSelect:b,onGoToAgentActions:y,onQuickAction:x}),!t&&m&&n.jsx(st,{heading:LC,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(zC,{term:f.term,isScoped:f.isScoped,onSelect:f.onSelect})}),t&&n.jsxs(n.Fragment,{children:[n.jsx(Sd,{}),n.jsx(Pu,{})]})]},e)}function KC(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 HC={initial:{opacity:0},animate:{opacity:1,transition:{duration:ha.fast}},exit:{opacity:0,transition:{duration:ha.fast}}};function WC({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:HC,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 GC=1;function qC(e){const[t]=KC(e,GC);return u.useMemo(()=>t===void 0?{id:"promo",show:!1,render:()=>null}:{id:`promo:${t.id}`,show:!0,render:()=>n.jsx(WC,{promo:t})},[t])}const YC=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:YC.has(t.state)||t.state==="error"?t:e&&(e.state==="downloading"||e.state==="downloaded")?e:t}function VC(){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 QC={darwin:Rr("/download/mac"),win32:Rr("/download/windows")},XC=ro.site;function JC(){var t;const e=typeof window>"u"||(t=window.electronAPI)==null?void 0:t.platform;It((e&&QC[e])??XC)}function ZC(){const{data:e}=Me(),{isDesktop:t,status:s,restart:r}=VC(),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:JC}:(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 eN="npm update -g dorkos",tN="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 nN(e,t,s){return t?"Command copied":s?"Couldn’t copy":`Update ready: v${e}`}function sN({update:e}){const{copied:t,failed:s,copy:r}=zn(),o=u.useCallback(()=>{r(eN)},[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:tN}),n.jsxs("button",{type:"button",onClick:e.downloadFresh,"aria-label":"Download a fresh copy of DorkOS",className:U(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)"}),nN(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=ZC(),r=Jw(),o=sj(),a=ru(),i=qC("dashboard-sidebar"),c=No(),d=[{id:"getting-started",show:e,render:()=>n.jsx(ej,{onDismiss:t})},{id:"update",show:s.kind!=="none",render:()=>n.jsx(sN,{update:s})},{id:"identity-prompt",show:r.visible,render:()=>n.jsx(rj,{prompt:r})},{id:"profile-prompt",show:o.visible,render:()=>n.jsx(tj,{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 rN=6e4,oN=[];function Hu(e,t){const s=qc(e),r=s.read();return r!==e&&!t(r,e)?(s.write(e),e):r}function aN(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 iN(e,t){return e.length===t.length&&t.every((s,r)=>e[r]===s)}function fr(e){return Hu(e,aN)}function cN(e){return Hu(e,iN)}function lN(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(rN),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[Y,ee]of Object.entries(O.statuses))$[Y]=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 Y=$.mentionCount??0;Y>0&&(O[$.id]=Y)}return O},[d.data])),h=jo(),p=fr(u.useMemo(()=>{const O={};for(const[$,Y]of Object.entries(h)){if(!$.startsWith("agent:"))continue;const ee=Date.parse(Y);Number.isNaN(ee)||(O[$.slice(6)]=ee)}return O},[h])),g=qn().data,x=cN(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:oN,E=u.useMemo(()=>v.map(O=>{const $=(b==null?void 0:b[O])??null,Y=I[O],ee=Y===void 0?NaN:Date.parse(Y);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(()=>nw(_),[_]),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:Y,title:ee})=>({id:O,extensionId:$,path:Y,title:ee})),[j]),N=lN(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 dN="Threads and Directory are pages. Drop it in a section.",uN="Add-ons lists extension pages only.";function Gu(e){return e==="addons"?uN:dN}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 mN(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 mN(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 hN(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 fN(e,t,s,r){return hN(e,na(e,t,s),r)}function pN(e,t){return e.type==="group"?`Picked up section ${t.groupName(e.groupId)}.`:`Picked up ${t.itemName(e.ref)}.`}function gN(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 xN(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 bN(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?pN(o,e()):void 0},onDragOver:r=>{if(t(r))return xN(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.":gN(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 yN({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 vN(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 wN=60;function jN(e){const t=document.querySelectorAll(`[${pa}]`);for(const s of t)if(s.getAttribute(pa)===e)return s.querySelector(`[${xl}]`);return null}function kN(e,t=wN){let s=t;const r=()=>{const o=jN(e);if(o!==null){o.focus();return}s-- >0&&requestAnimationFrame(r)};requestAnimationFrame(r)}const SN={start:["Space"],cancel:["Escape"],end:["Space","Enter","Tab"]};function CN(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 NN({data:e,itemName:t,groupName:s}){const r=e.type==="group"?s(e.groupId):e.type==="item"?t(e.ref):"";return n.jsx(yN,{label:r})}function AN({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:SN}));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=bN(()=>({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&&vN(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=>fN(P,v,E,f.read())),!(I.activatorEvent instanceof KeyboardEvent)))return;const _=CN(R);_!==null&&kN(_)};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(NN,{data:i,itemName:y,groupName:x}):null})]})})}const EN='[aria-current="page"]';function IN(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(EN);if(!(c instanceof HTMLElement))return;const d=!a&&r!==!0;c.scrollIntoView({block:"nearest",behavior:d?"smooth":"auto"})},[t,e,s])}function RN(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 TN(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 DN(){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 ON(e,t,s){const[r,o]=u.useState(null);!t&&r!==null&&o(null),t&&(r===null||r.key!==s)&&o({held:RN(e),key:s});const a=t?(r==null?void 0:r.held)??null:null;return u.useMemo(()=>a===null?e:TN(e,a),[e,a])}const MN=[2,3,3],Ii=["w-14","w-10","w-16"];function _N(){return n.jsx("div",{className:"flex flex-col gap-1","data-testid":"sidebar-skeleton","aria-hidden":!0,children:MN.map((e,t)=>n.jsxs("div",{className:"flex flex-col",children:[n.jsx("div",{className:U("flex h-7 items-center",Uf),children:n.jsx(mt,{className:U("h-2.5 rounded-sm",Ii[t])})}),Array.from({length:e},(s,r)=>n.jsx(Kf,{showIcon:!0},r))]},Ii[t]))})}const PN=.16,LN=4,FN=.03,$N={hidden:{},shown:{transition:{staggerChildren:FN}}},BN={hidden:{opacity:0,y:LN},shown:{opacity:1,y:0}};function Ri(e){return{duration:e===!0?0:PN}}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:U("flex shrink-0 items-center",vl),children:r}),n.jsxs("span",{className:U("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:U("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:U("flex shrink-0 items-center",vl),children:t&&n.jsx(bl,{"aria-hidden":!0,className:U(yl,"text-status-error-fg")})}),n.jsx("span",{className:U("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 zN(){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(UN,{connection:s}):n.jsx(nt,{children:"This space is no longer connected."})}function UN({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(KN,{connection:e})]})}function KN({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 HN=1,Ti=40;function WN({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<HN||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:U("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 GN(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}=DN(),a=ON(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);IN(f,g,m.settled);const x=e.sections.filter(GN),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:BN,transition:Ri(h)};return l?n.jsxs("div",{className:"flex min-h-0 flex-col","data-community-context":l,children:[n.jsx(zN,{}),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(Ve,{mode:"wait",initial:!1,children:m.phase==="cold"?n.jsx(re.div,{exit:{opacity:0},transition:Ri(h),children:n.jsx(_N,{})},"skeleton"):n.jsx(re.div,{className:"flex flex-col gap-1",variants:$N,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(qN,{})]},v.id))})},"sections")})})}function qN(){const e=Sl();return e.groupCreation===null?null:n.jsx(op,{children:n.jsx(WN,{onCommit:e.commitNewGroup,onCancel:e.cancelNewGroup})})}const Di="flex min-h-0 flex-1 flex-col";function YN(){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(AN,{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 VN=2;function QN(){return{label:"Active now",rules:{statuses:["needs-attention","active"]}}}function XN(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>=VN).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 JN(){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 ZN(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 eA(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=JN(),{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?[QN(),...XN(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]);ZN(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=eA({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:U("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 tA(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 nA(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 sA(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 rA(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=KS(),a=((i=t.data)==null?void 0:i.members.find(c=>c.isSelf))??null;return{you:a===null?null:{name:a.displayName,face:rA(a,e),onOpen:()=>r(a.id)},accountStatus:US(o),onOpenAccount:()=>s("account"),onOpenSettings:()=>s()}}function oA(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:sA((a==null?void 0:a.displayName)??null),nameUnknown:t.isPending,identityNodes:tA(o),nodes:[...e,...nA({version:(i==null?void 0:i.version)??null,isDevMode:(i==null?void 0:i.isDevMode)??!1,onCheckForUpdates:()=>void d()})]}}const aA=Ml("/self-hosting/space-server");function iA(e){const t=[];for(const s of e)s.hostOperator===!0&&!t.includes(s.pinnedOrigin)&&t.push(s.pinnedOrigin);return t}function cA(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 lA(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:$y,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:Py,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 dA(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 uA(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 mA(e){return e.charAt(0).toLowerCase()+e.slice(1)}function hA(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 fA(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 pA({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 gA(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 ${bA(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 xA(e){const t=typeof e=="object"&&e!==null?e.code:"";return t!=="COMMUNITY_RATE_LIMITED"&&t!=="COMMUNITY_UPGRADE_REQUIRED"}function bA(e){try{return`${new URL(e??"").origin}/your-space`}catch{return"https://example.com/acme"}}const yA="That invitation link is incomplete or isn’t secure. Copy the whole link again.";function vA(e){let t;try{t=new URL(e.trim())}catch{return!1}return/^\/(?:c\/[^/]+\/)?join\/?$/u.test(t.pathname)&&!Mr(e)}function wA(e){const t=new URL(e.trim()),s=/^(\/c\/[^/]+)\/join\/?$/u.exec(t.pathname);return s?`${t.origin}${s[1]}`:t.origin}function jA({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(kA,{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 kA({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 W,oe;const H=T.current;T.current=P,H!==P&&(P==="form"?(W=_.current)==null||W.focus():P==="pending"&&((oe=D.current)==null||oe.focus()))},[P]);const j=Qt({mutationFn:async H=>{if(!e||!Bt(e))throw new Error("Community owner is still loading.");const W=await p.startCommunityConnection({url:H,installName:E.trim()});if(!Bt(e))throw new Error("Community owner changed.");return W},onSuccess:async H=>{b(""),c(H),e&&await f.invalidateQueries({queryKey:At.connections(e)}),d(H.connection.ref)}}),w=_l(),N=Vd((t==null?void 0:t.status)==="reconnect-required"?t:null),S=j.error;u.useEffect(()=>{var H;(S||I)&&((H=_.current)==null||H.focus())},[S,I]);const M=Mr(y),B=I?yA:j.error?gA(j.error,j.variables):null;function O(H){if(H.preventDefault(),!(!y.trim()||j.isPending)){if(vA(y)){j.reset(),v(!0);return}if(Mr(y)){if(!It(g.linkFor(y.trim())))return;b(wA(y)),k({host:new URL(y.trim()).host,withAccount:g.signsInWithAccount(y)}),j.reset();return}E.trim()&&j.mutate(y.trim())}}function $(H){w.mutate(H,{onSuccess:W=>{if(H.status==="pending")m(H.label);else{const oe=Zd(H.label,W);l(oe.tone==="success"?`${H.label} is disconnected. Connect again to continue.`:oe.message)}},onSettled:()=>{e&&f.invalidateQueries({queryKey:At.connections(e)})}})}const Y=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:[Y,n.jsxs("div",{className:"space-y-1.5",children:[n.jsx(We,{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&&xA(j.error)?!0:void 0,required:!0,autoComplete:"off",value:y,onChange:H=>{b(H.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(We,{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:H=>R(H.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 H=!N.data&&N.fetchStatus==="fetching",W=N.data?Xd(t.label,N.data.agents):H?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,W&&n.jsx("p",{className:"text-sm",children:W}),N.isError&&!N.data&&!H&&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||H,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,Y,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 SA(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:SA,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 CA({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 NA(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 qe;const s=_e(),r=Pe(),o=De({select:K=>K.location.search.community}),a=_p(),i=Pp(),c=Gs(),{spaces:d,anySpace:l,selectedRef:m,visible:h,joinOfficial:p}=hA(o,c.data),f=u.useMemo(()=>{var K;return uA(h,((K=a.data)==null?void 0:K.order)??[])},[h,(qe=a.data)==null?void 0:qe.order]),g=f.find(K=>K.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}=CA({trigger:b,selectedRef:m}),[_,D]=u.useState(""),[P,T]=u.useState(!1),[j,w]=u.useState(null),[N,S]=u.useState(null),M=xS(),[B,O]=u.useState(null),$=m?f.findIndex(K=>K.ref===m):-1;function Y(K,de){It(new URL($p(K.remoteCommunityId,de),K.pinnedOrigin).toString())}const ee=lA({selected:g?{connection:g,availability:cA(g),canMoveUp:$>0,canMoveDown:$>=0&&$<f.length-1}:null,onMove:K=>{g&&i.mutate({ref:g.ref,direction:K})},onInvite:()=>g&&Y(g,"community"),onOpenSettings:()=>g&&Y(g),onLeave:()=>g&&Y(g,"account"),onDisconnect:()=>S(g),onJoin:d?()=>w({ref:null}):null,onJoinOfficial:p,creationOrigins:d?iA(f):[],onCreate:K=>It(new URL(Fp,K).toString()),onDeploy:()=>It(aA),hosting:d&&M?{onStart:()=>O({kind:"start"}),onOpenYourSpaces:()=>O({kind:"hosted"})}:null}),H=l?ee:[];fA(K=>w({ref:null,url:K}));const W=oA(H),oe=Il([...W.identityNodes,...W.nodes]),he=oe.nodes.slice(0,W.identityNodes.length),X=oe.nodes.slice(W.identityNodes.length),V=Me().data,ne=(V==null?void 0:V.serverRole)==="hub",ye=ne?"Private":W.teamName,se=V===void 0||!ne&&W.nameUnknown,ze=ne?vs:Ky,G=W.nameUnknown?"My DorkOS":W.teamName,fe=m!==void 0&&c.data===void 0,ve=m===void 0?se:fe,Qe=m===void 0?ye:(g==null?void 0:g.label)??"Space",Re=s&&f.length>=8&&_.trim().length>0?f.filter(K=>K.label.toLocaleLowerCase().includes(_.trim().toLocaleLowerCase())):f;NA(K=>{y.current=K,T(!0)});function Xe(K){if(k())return;if(y.current=null,K==="installation"){R();return}const de=f.find(je=>`community:${je.ref}`===K);if(de){if(de.status==="connected"){E(de);return}I(),w({ref:de.ref})}}function te(K){T(K),K||D("")}function be(K){if(oe.onCloseAutoFocus(K),v()){K.preventDefault();return}const de=y.current;y.current=null,!(K.defaultPrevented||!(de!=null&&de.isConnected))&&(K.preventDefault(),de.focus())}u.useEffect(()=>{if(!P)return;const K=requestAnimationFrame(()=>{var de;return(de=x.current)==null?void 0:de.focus()});return()=>cancelAnimationFrame(K)},[P]);async function we(K){var Je;const je=(Je=(await c.refetch()).data)==null?void 0:Je.find(Ze=>Ze.ref===K&&Ze.status==="connected");je&&await E(je)}function jt(K){ys(Pn().destination)===K.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(ze,{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:U(dn,"shrink-0"),"aria-hidden":!0}),n.jsx("span",{className:"truncate",children:Qe})]}),n.jsx(Zt,{className:U(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:be,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:he,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:K=>D(K.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:ze,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:[ye,ne&&n.jsx("span",{className:"text-muted-foreground block truncate text-xs",children:"Just you and your agents"})]})}),Re.map(K=>{var Ie;const de=tm(K),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=K.attention)==null?void 0:Ie.state)==="stale"?`last checked ${mA(Hn(K.attention.verifiedAt))}`:null].filter(Boolean).join(", ");return n.jsx(ka,{value:`community:${K.ref}`,icon:Pr,disabled:C!==null,itemRef:K.ref===m?x:void 0,description:[dA(K),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:K.label}),ly(K)&&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})]})},K.ref)})]}),X.length>0&&n.jsxs(n.Fragment,{children:[n.jsx(ja,{}),n.jsx(Pi,{sheet:s,children:n.jsx(Dr,{variant:s?"sheet":"dropdown",nodes:X,onSheetClose:()=>te(!1)})})]})]})]}),n.jsx(jA,{request:j,onOpenChange:K=>{K||w(null)},installName:G,onConnected:K=>void we(K)}),n.jsx($S,{entry:M,dialog:B,onDialogChange:O,installName:G,onConnected:K=>void we(K)}),n.jsx(pA,{connection:N,onOpenChange:K=>{K||S(null)},onDisconnected:jt})]})}function AA(){return n.jsx(nm,{compact:!0,triggerClassName:U("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 EA="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:EA}),n.jsx(Mi,{})]}),n.jsx(_i,{})]})}function IA(){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:U("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:U("text-muted-foreground shrink-0",dn),"aria-hidden":!0})]})}const RA=6e4;function TA(e){return e===null?!0:(e.selectionStart??0)===0&&(e.selectionEnd??0)===0}function DA(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 OA(){const{globalPaletteOpen:e,setGlobalPaletteOpen:t}=m0(),s=L(z=>z.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(z=>z.globalPaletteInitialSearch),E=L(z=>z.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}=vC(R),O=le(),$=u.useCallback(z=>{const ke=Bp(O,z.projectPath);return zp(ke?{session:ke}:{agentId:z.id})},[O]),Y=u.useCallback(z=>{if(!Up()){_(z);return}Dn($(z),{target:"tab"}),M(z.projectPath),R()},[$,_,M,R]),ee=u.useCallback(z=>{Dn($(z),{target:"window"}),M(z.projectPath),R()},[$,M,R]),H=Kp(),W=xC(),oe=Ks(RA),{allAgents:he,newActions:X,rooms:V,sessions:ne,continueRows:ye,recent:se,searchableItems:ze}=u0(B,oe);Hp(he);const{bestMatch:G,rows:fe,prefix:ve,term:Qe}=pC(ze,r,{usage:W,now:oe,scope:x}),Re=ve==="#",Xe=CC(Qe),te=Xe?{term:Xe,isScoped:x!==null,onSelect:()=>{R(),s(Xe)}}:null,be=u.useMemo(()=>i?he.find(z=>z.name===i)??null:null,[i,he]),we=DA(i,G,fe),jt=u.useCallback(z=>{y(z),o(""),c("")},[]),qe=!I&&be!==null,K=u.useMemo(()=>{var z;return i?ne.find(ke=>ke.id===i)??((z=ye.find(ke=>ke.session.id===i))==null?void 0:z.session)??null:null},[i,ne,ye]),de=_u((h==null?void 0:h.id)??"",(h==null?void 0:h.projectPath)??""),je=u.useCallback(()=>{m(z=>z.slice(0,-1)),p(z=>l.length<=1?null:z),c("")},[l.length]),Je=u.useCallback(z=>{p(z),m(ke=>[...ke,"agent-actions"]),o(""),c(""),k(ke=>ke+1)},[]);u.useEffect(()=>{e&&v!=null&&(o(v),E(),requestAnimationFrame(()=>{const z=a.current;if(z){const ke=v.length;z.setSelectionRange(ke,ke)}}))},[e,v,E]);const Ze=u.useCallback(z=>{t(z),z?k(ke=>ke+1):(o(""),c(""),m([]),p(null),y(null))},[t]),Ie=kC({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:U("!min-h-0 overflow-hidden p-0 transition-[max-width] duration-200","[&>button:last-child]:top-2 [&>button:last-child]:right-2.5",qe?"max-w-[640px]":"max-w-[480px]",I&&"h-[85vh]"),children:n.jsxs(re.div,{variants:Bu,initial:"hidden",animate:"visible",exit:"exit",className:U("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:U("min-w-0 flex-1",I&&"flex flex-col [&_[cmdk-list]]:max-h-none [&_[cmdk-list]]:flex-1 [&_[cmdk-list]]:overflow-y-auto"),onKeyDown:z=>{if(Ie.onKeyDown(z),z.key==="Enter"&&(z.metaKey||z.ctrlKey)&&!b&&(K==null?void 0:K.cwd)!=null){z.preventDefault(),D(K.cwd),R();return}if(z.key==="Enter"&&(z.metaKey||z.ctrlKey)&&!b&&be){z.preventDefault(),Y(be);return}if(z.key==="Enter"&&(z.metaKey||z.ctrlKey)&&b==="agent-actions"&&h){z.preventDefault(),Y(h);return}if(z.key==="Tab"&&!z.shiftKey&&!b&&we){z.preventDefault(),z.stopPropagation(),jt(we);return}if(z.key==="Backspace"&&x&&!b&&TA(a.current)){z.preventDefault(),y(null);return}z.key==="Backspace"&&!r&&l.length>0&&(z.preventDefault(),je()),z.key==="Escape"&&l.length>0&&(z.preventDefault(),z.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(z=>z+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(SC,{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(ky,{children:[n.jsx("p",{children:"No results found."}),n.jsx(Pu,{className:"justify-center pb-0"})]}),n.jsx(Ve,{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(UC,{staggerKey:C,isZeroQuery:kt,isRoomMode:Re,scope:x,hasQuery:Qe.length>0,selectedCwd:B,selectedValue:i,continueRows:ye,recent:se,newActions:X,bestMatch:G,rows:fe,rooms:V,searchHandoff:te,onFeatureAction:P,onQuickAction:T,onGoToAgentActions:Je,onRoomSelect:j,onSessionSelect:z=>w(z.id,z.cwd),onCommandSelect:N,onPageSelect:S}),b==="agent-actions"&&h&&n.jsx(AC,{agent:h,onOpenHere:()=>_(h),onOpenNewTab:()=>Y(h),onOpenNewWindow:H?()=>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:z=>w(z,h.projectPath)})]},b??"root")})]})}),n.jsx(IC,{page:b,hasAgentSelected:qe,canScope:!b&&we!==null,isScoped:x!==null})]}),n.jsx(Ve,{children:qe&&be&&n.jsx(NC,{agent:be},be.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:z=>{z||g(null)},onSelectSession:z=>w(z,f.projectPath),onNewSession:()=>D(f.projectPath)})]})}const MA="",_A="";function PA(e){const t=[];let s=e,r=!1;for(;s.length>0;){const o=r?_A:MA,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 LA({excerpt:e,className:t}){const s=PA(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",FA=["claude-code","opencode"];function $A(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&&FA.includes(e.source);return{kind:"session",...Rt({session:e.sessionId,dir:e.containerPath??void 0,...t?{message:e.messageId}:{}})}}function BA(e,t){return e.source===rm?t.get(e.container)??"Channel":e.containerPath===null?"Conversation":Pl(e.containerPath)}function zA(e){return e==="user"?"You":"Agent"}function UA({hit:e,containerLabel:t,value:s,onSelect:r,openable:o}){const a=e.source==="rooms"?Eo:Hy;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:zA(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(LA,{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 KA=["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."],HA=["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."],WA="Searches channels, direct messages, and DorkOS, Claude Code, Codex and OpenCode chats. Not tool output.",GA=`Type at least ${Ll} letters to search.`,qA="Search what was said…";function YA({detailOpen:e=!1,className:t}){const[s,r]=u.useState(null),o=s??e,a=HA;return n.jsxs(Do,{open:o,onOpenChange:r,className:U("px-3 py-2",t),children:[n.jsxs(Oo,{className:U("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:WA}),n.jsx(Zt,{className:U("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:[KA.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 VA=3e4,QA=e=>["message-search",e];function gr(e){return qp(e).some(t=>t.length>=Ll)}function XA(e,t){const s=ie(),r=JA(e,Yp),o=t&&gr(e)&&gr(r),{data:a,isFetching:i,error:c}=Ee({queryKey:QA(r),queryFn:()=>s.search({q:r}),enabled:o,staleTime:VA,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 JA(e,t){const[s,r]=u.useState(e);return u.useEffect(()=>{const o=setTimeout(()=>r(e),t);return()=>clearTimeout(o)},[e,t]),s}function ZA(){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 e1(){ZA();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}=XA(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:U("!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:U("flex overflow-hidden",r&&"h-full flex-col"),children:n.jsxs(Cd,{loop:!0,shouldFilter:!1,className:U("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:qA,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:U("transition-opacity duration-150",h&&"opacity-60"),children:d.map(v=>{const E=`${v.source}:${v.container}:${v.ordinal}`,R=$A(v);return n.jsx(UA,{value:E,hit:v,containerLabel:BA(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:GA}),k&&n.jsxs("p",{className:"text-muted-foreground px-3 pt-3 text-xs",children:["No messages match “",f.trim(),"”."]}),n.jsx(YA,{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 t1(e){return`set${e.charAt(0).toUpperCase()}${e.slice(1)}`}function n1(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 s1({contribution:e,openStateKey:t}){const s=L(m=>m[t]),r=L(m=>m[t1(t)]),o=n1(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 r1({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 o1({contribution:e}){return e.openState?n.jsx(r1,{contribution:e,openState:e.openState}):n.jsx(s1,{contribution:e,openStateKey:e.openStateKey})}function a1(){const e=_s("dialog");return n.jsx(n.Fragment,{children:e.map(t=>n.jsx(o1,{contribution:t},t.id))})}const i1=["session","id","thread","entry","itemId","agent","profile","continuedFrom","pkg","view","region","detail","panel"];function c1(e,t){if(e.length>=er)return e.slice(0,er);const s=new URLSearchParams(t);let r="";for(const o of i1)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 l1=6e4,d1={bug:"when it’s fixed",idea:"when it ships",feedback:"when the team acts on it"};function u1(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])),...zv(s)},...i.length>0?{breadcrumbs:i}:{}}}function m1(){const e=ie(),t=De({select:b=>b.location.pathname}),s=De({select:b=>b.location.searchStr}),r=Qp(),o=c1(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=u1(b,C),v=g.current;if(v&&v.fingerprint===I&&Date.now()-v.at<l1)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 Rv():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} ${d1[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 h1(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 f1(e){const t=e.slice(-20),s=ng(sg(t.map(h1).join(`
75
+
76
+ `))).trim();return s.length>Ca?`${s.slice(0,Ca-1)}…`:s}function p1(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 f1(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 g1=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 x1(e){const{element:t,viewport:s,region:r,image:o}=e,a=e.padding??g1;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 b1(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 y1(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 v1(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 b1(e.dataUrl),o=x1({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(y1(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."},w1={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 j1(e){return e instanceof it?w1[e.reason]:e instanceof Yt?Ui[e.reason]:Ui.unreadable}const br="Only images can be attached.",k1="Files";function Nn(e){return e?Array.from(e.types).includes(k1):!1}function Ki(e){return e.find(t=>t.type.startsWith("image/"))}function S1(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(j1(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 Fv()))},[m]),f=u.useCallback(v=>m(async()=>v1(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&&!Yv(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,C1="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 N1(e){const t=e.tagName;let s=1,r=e.previousElementSibling;for(;r;)r.tagName===t&&(s+=1),r=r.previousElementSibling;return s}function A1(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(${N1(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 E1(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!==C1&&s.tagName!=="BODY";){t.unshift(A1(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 I1=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*I1?s:null}function R1(e){const t=Gi(e,"data-slot"),s=cm(e,e),r=s?Gi(s,"data-testid"):void 0,o=lm(e);return{selector:E1(e),...t?{slot:t}:{},...r?{testId:r}:{},...o?{label:o}:{}}}const yr=40,T1=["button","a[href]","summary","input","select","textarea",'[role="button"]','[role="link"]','[role="menuitem"]','[role="tab"]','[role="option"]','[role="checkbox"]','[role="switch"]'].join(", "),D1=new Set(["INPUT","SELECT","TEXTAREA"]),O1=['[contenteditable]:not([contenteditable="false"])','[role="textbox"]','[role="searchbox"]','[role="combobox"]'].join(", "),M1=["h1","h2","h3","h4","h5","h6",'[role="heading"]',"label","legend","th","dt"].join(", ");function _1(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=_1(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 P1(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"))??P1(e)}function lm(e){const t=L1(e);return t&&t.length<=og?t:void 0}function L1(e){var a,i;const t=e.closest(O1);if(t)return ss(t);const s=e.closest(T1);if(s){if(D1.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(M1);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 F1(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 $1="This part";function dm(e){return(e==null?void 0:e.text)??$1}function B1(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 z1(e){return e!=null&&e.onScreen?`Remove “${e.text}”`:`Remove ${dm(e).toLowerCase()}`}function U1(){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 K1({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 H1({sessionId:e,active:t}){const{text:s,isLoading:r,isError:o}=p1(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 W1({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 G1({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 q1({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:U("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:U("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(K1,{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(W1,{roomId:d,active:e}):n.jsx(H1,{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(G1,{dataUrl:l})})}),n.jsx(U1,{})]},p)]})})}const Y1="0 0 0 9999px var(--scrim)";function V1(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 Q1(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 X1({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:V1(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=Q1(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:U("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:Y1}}),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 J1({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(Ly,{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:U("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 Z1({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(Gy,{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(We,{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 eE=[{value:"feedback",label:"Feedback",icon:Rs},{value:"bug",label:"Bug",icon:dg},{value:"idea",label:"Idea",icon:Db}];function tE({kind:e,onChange:t}){return n.jsx("div",{role:"radiogroup","aria-label":"What kind of feedback",className:"flex gap-1.5",children:eE.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:U("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 nE({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 sE={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 rE({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}=m1(),g=bv(),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"),[Y,ee]=u.useState(null),[H,W]=u.useState(null),[oe,he]=u.useState(null),[X,V]=u.useState(null),[ne,ye]=u.useState(0),se=u.useRef(ne);u.useEffect(()=>{se.current=ne},[ne]);const[ze,G]=u.useState(!1),[fe,ve]=u.useState(o),[Qe,Re]=u.useState(y),Xe=u.useRef(null),te=S1({enabled:e}),be=E.trim().length>0,we=be||te.dataUrl!==null||Y!==null,[jt,qe]=u.useState(e);if(e!==jt&&(qe(e),e)){B(!1),V(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),G(!1),ee(null),W(null),ve(o),Re(y),te.reset(J),ye(Qs=>Qs+1)}else y!==Qe&&(S(!1),Re(y))}function K(J){const Ce=Xi(J,!!l,!!fe);w(Ce.diagnostics),S(Ce.conversation)}function de(J){v(J),K(J)}function je(J){$(J),B(!0)}async function Je(J){const Ce=se.current,St=R1(J),Xn=F1(J);H&&te.dataUrl===H&&te.clear(),W(null),V("capturing");const Qs=await te.captureElement(J);Ce===se.current&&(V(null),ee(St),he(Xn),W(Qs),v("bug"),ze||K("bug"))}function Ze(){H&&te.dataUrl===H&&te.clear(),ee(null),W(null)}function Ie(){R(""),ee(null),W(null),G(!1),ve(void 0),te.clear()}const kt=be&&!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,...fe?{crashStack:fe}:{},...te.dataUrl?{screenshotDataUrl:te.dataUrl}:{},...Y?{element:Y}:{},..._t?{notifyEmail:_t}:{}})||(C||hg(_),Ie(),t(!1))}function z(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 q=te.handlers,Z=X!==null,ae=Y?oe:null,ge=dm(ae),et=!!(Y&&H&&te.dataUrl===H),Se=!!te.dataUrl&&!et,Ue=!be&&(!!te.dataUrl||Y!==null);return n.jsxs(n.Fragment,{children:[Z&&n.jsx(X1,{phase:X,onSelect:J=>void Je(J),onCancel:()=>V(null)}),n.jsx(vt,{open:e&&!Z,onOpenChange:t,children:n.jsxs(wt,{...q,onKeyDown:A,desktopProps:{className:"max-w-md",onOpenAutoFocus:ke},className:U("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:z,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(tE,{kind:I,onChange:de}),n.jsxs("div",{className:U("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(We,{htmlFor:k,className:"sr-only",children:"Your message"}),n.jsx(ug,{ref:Xe,id:k,value:E,onChange:J=>R(J.target.value),placeholder:Y?B1(ae):sE[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"}),(Y||Se||te.isPreparing||te.isDraggingOver)&&n.jsxs("div",{className:"flex flex-wrap items-center gap-2 px-2.5 pb-2.5",children:[Y&&n.jsx(Vi,{imageUrl:et?H??void 0:void 0,alt:`The part you pointed at: ${ge}`,caption:ge,pointed:!0,detail:Y.selector,...et?{onOpen:()=>je("screenshot")}:{},onRemove:Ze,removeLabel:z1(ae)}),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(J1,{showPictureTools:!0,isPreparing:te.isPreparing,hasPointed:Y!==null,hasWords:be,isMobile:!c,onCapture:()=>void te.capture(),onPointAtElement:()=>V("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=>{G(!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=>{G(!0),S(J)},onPreview:()=>je("conversation")})]}),n.jsx(Z1,{currentUser:a??null,anonymous:P,onToggleAnonymous:()=>T(J=>!J),contact:_,onContactChange:D})]}),n.jsx(nE,{needsWords:Ue,canSend:kt,isSubmitting:d,onOpenGitHubIssue:()=>g(I==="idea"?"feature":"bug")})]}),n.jsx(q1,{open:M,onOpenChange:B,initialTab:O,diagnostics:p(fe?{crashStack:fe}:void 0),kind:I,route:h,showConversation:x,sessionId:l,roomId:m,...te.dataUrl?{screenshotDataUrl:te.dataUrl}:{}})]})})]})}function oE(){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(rE,{open:e,onOpenChange:r,initialKind:t.kind,prefillMessage:t.message,crashStack:t.crashStack,currentUser:o?{email:o.email,name:o.name}:null})}function aE(){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 iE(){const{closeActive:e}=Ko();u.useEffect(()=>{const t=window.electronAPI;if(t!=null&&t.onCloseTab)return t.onCloseTab(()=>e())},[e])}function cE(){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 lE(){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 dE="/channels";function uE(){Ww();const e=xg(),t=Un(),s=e===dE&&!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 mE({unreadRoomCount:e}){Wk();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 wv(c=>bg(i,{...c,badgeCount:e+r,needsYou:s||o>0}),t),null}function hE(){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 fE(){hE(),sw(),vg()}const wr="newTodo";function pE(){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 gE({isFullscreen:e}){return n.jsx("div",{className:U("desktop-darwin:block app-drag-region hidden shrink-0",!e&&"desktop-darwin:h-11"),"aria-hidden":"true"})}class xE 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 bE=5e3;function um({testId:e,headline:t,detail:s}){const{isFetching:r,refetch:o}=Me({refetchInterval:bE});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 yE(){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 vE(){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 wE(){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:U("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 jE=1,kE=10,SE=4;function CE(){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)??SE;return n.jsx(Cg,{children:n.jsxs(Ng,{children:[!a&&n.jsx(wE,{}),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(Oa,{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(Oa,{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:jE,max:kE,"aria-label":"Scheduled runs at once",onCommit:h=>t.mutate({scheduler:{maxConcurrentRuns:h}},{onSuccess:i})})})]})})}const Zi="claude-code";function NE(){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=qw(),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:nr(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)??tr(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)??tr(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)??tr(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 ${nr(S.stop)}`,why:{question:`Why is Files & commands set to ${nr(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 AE={runtime:jb,session:Ig,task:_o,binding:Nc,"agent-permission":Eg};function EE(){const{rows:e,isEmpty:t,isResolving:s,permissionsUnreadable:r}=NE();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=AE[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 IE(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 RE(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 TE(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 DE(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 OE(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 ME=15e3;function _E(){const{data:e}=qn(),{data:t}=Me({refetchInterval:ME}),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:TE(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:IE(i,a),otherChats:RE(i,a),isEmpty:a.length===0}},[i,a,c])}function hm({text:e,className:t}){return n.jsx("span",{className:U("grid min-w-0",t),children:n.jsx(Ve,{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:OE(t-e.startedAt)}):null]})})}function PE({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:DE(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 LE(){const e=_E(),t=Ks(3e4),s=Ms(),r=L(o=>o.setControlCenterOpen);return n.jsx(FE,{board:e,now:t,onOpenChat:o=>{r(!1),s==null||s(Rt({session:o.id,dir:o.cwd}))}})}function FE({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:U(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(PE,{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 $E(){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 BE(){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(LE,{}):n.jsxs(n.Fragment,{children:[n.jsx(vE,{}),n.jsx(CE,{}),n.jsx(EE,{}),n.jsx($E,{})]})]})}function zE(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 UE(){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(Ma,{className:"size-(--size-icon-sm)","aria-hidden":!0})})}),n.jsxs(fn,{side:"bottom",align:"end","aria-label":"Control Center",onOpenAutoFocus:zE,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(Ma,{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(BE,{})]})]})}function KE(){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 HE(){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 WE(){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(HE,{}),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 GE(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 qE({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 YE({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 VE(){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 QE({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(YE,{url:i},"link"):null,l=i?n.jsx(qE,{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:U("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(VE,{}),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 XE(e,t){const s=e==="starting"||e==="asleep"&&!t?"Open remote access":"Show link and QR code";return`${pm(e,t)}. ${s}`}function JE(){const e=qs(),t=L(i=>i.remoteAccessBeaconOpen),s=L(i=>i.setRemoteAccessBeaconOpen),r=ht(),o=GE(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":XE(e.state,e.host),className:U("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:U("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:U("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(QE,{onClose:()=>s(!1)})]})]}),n.jsx(WE,{})]})}function ZE({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 eI(){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(ZE,{work:o}),n.jsx("p",{className:"text-muted-foreground text-xs",children:sb}),n.jsx(F,{variant:"outline",size:"sm",onClick:()=>{r(!1),t(Da.tab,Da.section)},children:"Sleep settings"})]})]})}function tI(){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(UE,{}),n.jsx(JE,{}),n.jsx(eI,{}),n.jsx(Og,{})]})}const nI="onboarding";function sI({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:nI}),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 rI={renderAccountLink:e=>n.jsx(sI,{render:e}),renderRuntimeConnect:kb,renderOtherService:({onSave:e})=>n.jsx(Sb,{onSave:e})},oI="HOST_NOT_ALLOWED",sc=240;function aI({status:e,message:t,code:s}){const r=s===oI&&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 iI(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 cI(e,t){return e>jr.at&&(jr=t==null?{at:e}:{at:e,...iI(t)}),e>ln?jr:void 0}function lI(e){return e.state.dataUpdatedAt>ln?!0:"always"}function dI(e){return!e}function uI(e){var t;return((t=e.at(-1))==null?void 0:t.pathname)??""}function mI({descriptors:e}){const t=e.reduce((s,r)=>s===null||r.priority>s.priority?r:s,null);return n.jsx(Ve,{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 hI=["memory-provider-status"],fI=6e4;function pI(){const e=ie(),{data:t}=Ee({queryKey:[...hI],queryFn:()=>e.getMemoryProviderStatus(),staleTime:fI,refetchOnWindowFocus:!0});return t}function gI(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||xI(s,r))&&t.set(s.subject.id,s)}return[...t.entries()].filter(([,s])=>s.outcome!=="cleared").map(([s])=>s)}function xI(e,t){return e.createdAt!==t.createdAt?e.createdAt>t.createdAt:e.id>t.id}function bI({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 yI="runtimes",vI=3;function wI({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,vI).map(l=>l.accountRoot?r(l.accountRoot):Gl(l.runtime)),i=e.length-a.length,c=`${kI(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(jI,{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(yI),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 jI({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 kI(e){return e.length<=1?e[0]??"":`${e.slice(0,-1).join(", ")} and ${e[e.length-1]}`}const gm={critical:40,warning:30};function SI(){const e=pI();return!e||e.configuredId===e.activeId?null:{id:"memory-provider-benched",variant:"warning",priority:gm.warning,render:()=>n.jsx(bI,{configuredId:e.configuredId,benched:e.benched})}}const CI={kinds:["signin.required"]};function NI(){const{notifications:e}=Ug(CI),t=u.useMemo(()=>gI(e),[e]);return t.length===0?null:{id:"runtime-signin",variant:"critical",priority:gm.critical,render:()=>n.jsx(wI,{runtimes:t})}}function AI(e){const t=SI(),s=NI();return[t,s].filter(r=>r!==null)}function EI(){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 II(e){return e.everyAgentLevel!==void 0?e.everyAgentLevel!==null:e.everyAgent!==null}function RI(e){const{data:t}=Ob(),s=new Set(e),r=((t==null?void 0:t.connections)??[]).filter(a=>s.has(a.connectionId)&&II(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 TI({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 DI=Ml("/guides/permissions#what-changed"),OI=["Everything they do is recorded in Activity. Anyone can pause an agent.","Messages and code from strangers still need your yes."],MI="Agents ask first again. Shared apps stay shared; change them in Connections.";function _I(e){return e instanceof Error&&e.message||"Couldn’t save that. Try again."}function PI({onClose:e,sharedConnectionIds:t=[]}){return t.length>0?n.jsx(LI,{onClose:e,connectionIds:t}):n.jsx(xm,{onClose:e,sharedApps:[]})}function LI({onClose:e,connectionIds:t}){return n.jsx(xm,{onClose:e,sharedApps:RI(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(_I(x)),i(!1);return}i(!1),f&&ce.success(t.length>0?MI:"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:OI.map(f=>n.jsx("p",{children:f},f))}),t.length>0&&n.jsx(TI,{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:DI,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 FI(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 $I(){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(EI,{})}}function BI(){const{data:e}=Me();return FI(e)?{id:"trust-notice",priority:bm.high,render:({onClose:t})=>{var s;return n.jsx(PI,{onClose:t,sharedConnectionIds:((s=e==null?void 0:e.permissions)==null?void 0:s.sharedAtUpgrade)??[]})}}:null}function zI(){const e=BI(),t=$I();return L(r=>r.onboardingHiddenForSession)?[]:[e,t].filter(r=>r!==null)}function UI(e){return e.reduce((t,s)=>t===null||s.priority>t.priority?s:t,null)}function KI({onboardingOverlayVisible:e=!1}){const t=zI(),{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:UI(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 HI({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(Ve,{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 WI(){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(Ve,{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(wy,{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 GI=1e3;function qI(e){if(e!==0)return e===1?"1 agent needs you":`${e} agents need you`}function YI(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)},GI);return()=>clearTimeout(a)},[e]),t}function VI({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:U("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:U("absolute inset-0",!t&&"invisible"),children:s})}function QI({takeover:e}){Uu();const t=WI(),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=YI(qI(p));return n.jsxs(Al,{activeTarget:s.activeTarget,children:[n.jsxs("div",{"data-testid":"mobile-tab-panels",inert:!d,className:U("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(IA,{}),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(VI,{current:d?i:null,needsYouCount:p,dorkBotReady:a,onSelect:h})]})}function XI(){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 JI(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 ZI({step:e,templateName:t,seedDisplayName:s=null,faceSeed:r=null,runtimeSeed:o="claude-code"}){var he;const a=ie(),{data:i}=Ee({queryKey:Fe.current(),queryFn:()=>a.getConfig(),staleTime:3e4}),c=((he=i==null?void 0:i.agents)==null?void 0:he.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",Y=u.useRef(null);u.useEffect(()=>{if(e!=="naming")return;const X=t?!d||m?t.replace(/^@[^/]+\//,""):null:m?"":null;if(X===null)return;const V=`${e}|${t??""}`;Y.current!==V&&(Y.current=V,l(X),h(!!t))},[e,t]);const ee=u.useRef(null);u.useEffect(()=>{if(e!=="naming"||E||!r)return;const X=`${e}|${r}`;ee.current!==X&&(ee.current=X,v(r))},[e,r]),u.useEffect(()=>{if(e!=="naming"||!B)return;const X=B,V=setTimeout(()=>{JI(a,X).then(ne=>{k({directory:X,status:ne})})},500);return()=>clearTimeout(V)},[e,B,a]);function H(X){l(X),m&&h(!1)}function W(X){v(X),R(!0)}function oe(){Y.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:H,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:W,runtime:_,setRuntime:D,reset:oe}}function eR(e){var a;const t=(e==null?void 0:e.packageName)??null,{data:s,isError:r,error:o}=Ty(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&&Dy(o)&&{refusal:o},...s!=null&&s.disclosed&&s.contentHash?{approval:{approvedDisclosure:s.disclosed,approvedContentHash:s.contentHash},packageAgentName:s.manifest.name}:{}}}const tR={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"]},nR=[["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 sR(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 nR)if(r.some(o=>t.includes(o)))return kr[s];return kr.default}function rR(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 oR=64,aR=16,ac=3;function iR(e){return e.map(t=>t.replace(/[\u0000-\u001f\u007f]/g," ").replace(/\s+/g," ").trim().slice(0,oR)).filter(t=>t.length>0).slice(0,aR)}function cR(e){const t=iR(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 lR(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 \`${Ra}\` — leave that fenced block exactly as it is. Replace only the prose BELOW the \`${Ra}\` 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 dR={template:cR,"design-your-own":lR};function uR(e,t){return dR[e](t)}function mR(e,t){return Lb(uR(e,t))}const vm="🤖",hR=["🤖","🦾","🧭","🛰️","📡","🔭","🗺️","🧠","🦉","🦊","🐝","🐙","🚀","⚡","🌟","🔮","🛠️","🔧","📊","📋","✅","🗂️","🔔","🛡️"];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:U("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 fR(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 pR(e){return e.tags&&e.tags.length>0?e.tags.slice(0,2):e.category?[e.category]:[]}function gR(e){const t=e.replace(/\/+$/,"");return t.split("/").pop()??t}function xR({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=Sv(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:pR(f),tabIndex:p.tabIndexFor(x),onSelect:()=>t(fR(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:U("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=gR(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 bR({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:hR.map(s=>{const r=s===e;return n.jsx("button",{type:"button","aria-label":`Face ${s}`,"aria-pressed":r,onClick:()=>t(s),className:U("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 yR({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:U("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 vR({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:U("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:U("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}),": ",Oy(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 wR({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=rR(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(We,{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(We,{className:"text-sm",children:"Face"}),!e.icon&&n.jsx("span",{className:"text-muted-foreground text-xs",children:"Picked for you if skipped"})]}),n.jsx(bR,{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:U("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(We,{className:"text-muted-foreground text-xs",children:"Runs on"}),n.jsx(yR,{value:e.runtime,onChange:e.setRuntime})]}),p?n.jsxs("div",{className:"space-y-1.5","data-testid":"package-directory",children:[n.jsx(We,{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(We,{htmlFor:"agent-directory",className:"text-muted-foreground text-xs",children:"Directory"}),n.jsx(My,{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(vR,{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 jR({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(kR,{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 kR({runtime:e}){const t=dt(e??"claude-code").icon;return n.jsx(t,{size:16,className:"text-muted-foreground shrink-0"})}function SR(e){const t=e==null?void 0:e.body;return(t==null?void 0:t.code)==="template_needs_review"?t.template:void 0}function CR(e,t){const s=e.replace(/\/*$/,"/");return t.filter(r=>r.path===e||r.path.startsWith(s))}function NR(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 AR(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 ER(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:CR(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 IR({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:ER(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:NR(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…":AR(e)})]})]})}function RR(){const{isOpen:e,seed:t,onCreated:s,close:r}=Ts(),o=rn(H=>H.open),a=XI(),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=eR(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=ZI({step:c,templateName:(l==null?void 0:l.displayName)??null,seedDisplayName:(t==null?void 0:t.template.displayName)??null,faceSeed:g,runtimeSeed:x}),_=sR(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(H=>{m(H),d("naming")},[]),w=u.useCallback(()=>{m(null),d("naming")},[]);function N(){d(t?"arrival":"gallery")}function S(){r(),T(),o()}function M(H){var he;if(!R.canSubmit||a.isPending)return;const W=(y==null?void 0:y.packageName)!==void 0&&b.approval?{package:{name:y.packageName,...y.marketplace?{marketplace:y.marketplace}:{},...b.approval}}:void 0,oe=W?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,...!W&&R.directoryOverride?{directory:R.directoryOverride}:{},...R.icon?{icon:R.icon}:{},...W??{},...oe?{template:oe}:{},...H?{approvedTemplateHash:H}:{},...t!=null&&t.template.persona?{persona:t.template.persona}:{},...(he=t==null?void 0:t.template.capabilities)!=null&&he.length?{capabilities:t.template.capabilities}:{}},{onSuccess:X=>{const V=crypto.randomUUID(),ne=X.displayName??X.name,ye=l||t?"template":"design-your-own";yx.getState().register(V,{name:X.name,displayName:ne,agentId:X.id,icon:X.icon,color:X.color,bornAt:X.registeredAt,path:X._path,runtime:X.runtime,kickoffMessage:mR(ye,{displayName:ne,capabilities:X.capabilities})}),Iy();const se=s;if(r(),T(),se){se();return}i(Rt({agentId:X.id,draft:"1",session:V,runtime:X.runtime}))},onError:X=>{const V=SR(X);V&&E(V)}})}function B(H){H||(r(),T())}const O=hd(e),$=n.jsx(_w,{agentName:R.displayName||(t==null?void 0:t.template.displayName)||""}),Y=tR[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 Y&&n.jsxs(gt,{className:"shrink-0 border-b px-5 py-4",children:[n.jsx(ot,{children:Y.title}),n.jsx(xt,{children:Y.description})]}),n.jsx("span",{className:"sr-only","aria-live":"polite","aria-atomic":"true",children:Y.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(Ve,{mode:"wait",children:n.jsxs(re.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.15},children:[c==="gallery"&&n.jsx(xR,{onDesignYourOwn:w,onSelectTemplate:j,onImport:k}),c==="arrival"&&t&&n.jsx(jR,{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(wR,{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(IR,{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:H=>{R.setDirectoryOverride(H),R.directoryOpen||R.setDirectoryOpen(!0)}})]})})}function TR({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),Ta.getState().setPinnedSession(e),()=>{hs.unpinSession(),Ta.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 DR({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,OR={type:"spring",stiffness:480,damping:44};function MR({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:OR,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(Fy,{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},_R=.4,PR=800,lc=500,Cr={type:"spring",stiffness:480,damping:44};function LR({content:e,onClose:t,onMinimize:s,children:r}){const o=ev(),a=Xy(),[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>_R*v||I>0&&k>PR){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:DR,mcp_app:FR,widget:$R};function FR({content:e}){return n.jsx(Cy,{sessionId:e.sessionId,serverName:e.serverName,uri:e.uri,title:e.title,className:"h-full"})}function $R({content:e}){return n.jsx(TR,{sessionId:e.sessionId})}function BR(e){u.useEffect(()=>{},[e])}function mc(){return{x:window.innerWidth-dc-no,y:window.innerHeight-uc-no,width:dc,height:uc}}function zR(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(_y,{content:e});case"widget":{const t=Nr.widget;return n.jsx(t,{content:e})}default:return e}}function UR({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 zR(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(Ve,{children:e!==null&&n.jsx(Ev,{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 KR(){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();BR(a);const c=u.useRef(i);return u.useEffect(()=>{i&&!c.current&&e!==null&&r(),c.current=i},[i,e,r]),i?n.jsx(Ve,{children:e!==null&&(t?n.jsx(MR,{content:e,onRestore:o,onClose:s},"pip-minibar"):n.jsx(LR,{content:e,onClose:s,onMinimize:r,children:jm(e)},"pip-sheet"))}):n.jsx(UR,{content:e,onClose:s})}const HR=new Set(["permission-prompt","question","schedule-approval"]),WR={"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)!HR.has(f.kind)||f.quiet===!0||a.set(f.id,{id:f.id,who:f.primary,summary:WR[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 GR(){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;pe("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:qR(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 qR(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 YR(){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}),GR(),null}function VR(){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 QR(){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 XR=15e3;function JR(){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(xE,{contributionId:s.id,children:n.jsx(u.Suspense,{fallback:null,children:n.jsx(r,{})})}),direction:1,isTakeover:!0}}return{key:"dashboard",body:n.jsx(YN,{}),direction:-1,isTakeover:!1}}function ZR(){const e=De({select:t=>t.matches});return ek(e)}function eT(){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=dI(ht()??!1),m=De({select:se=>uI(se.matches)});ow();const[h]=Fs(),p=L(se=>se.isStreaming),{data:f}=Uc(h),g=hl(f??null,h??""),{room:x,unreadRoomCount:y}=uE();fE(),pE(),vv({cwd:h,isStreaming:p,color:f?g.color:void 0}),QR(),Xj(),Gb(),KE(),qb(),Bb(),Fk(),aE(),iE();const b=cE();lE(),uw(),HS(),Nj(),Aj(),Cx(),cb(),Yw(),Nx(),Jv(),Eb(),jv(),Ax(),Gw(),Ex(),a0(),Mb();const C=L(se=>se.onboardingHiddenForSession),k=L(se=>se.setOnboardingHiddenForSession),{shouldShowOnboarding:I,isLoading:v,isOnboardingComplete:E,isOnboardingDismissed:R}=en(),_=mw({shouldShowOnboarding:I,onboardingHiddenForSession:C});fw({done:E||R,overlayVisible:_}),Ij({blocked:_});const{dataUpdatedAt:D,errorUpdatedAt:P,error:T}=Me({refetchOnMount:lI}),j=D>ln,w=P>ln,N=cI(P,T),[S,M]=u.useState(!1);u.useEffect(()=>{if(j)return;const se=setTimeout(()=>M(!0),XR);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,[Y,ee]=u.useState(!1);u.useEffect(()=>{if(!v)return;const se=setTimeout(()=>ee(!0),3e3);return()=>clearTimeout(se)},[v]);const H=u.useCallback(()=>k(!0),[k]),W=JR(),{origin:oe,originLabel:he}=Ix(o),{data:X}=Rx(o,{enabled:!1,select:se=>se.title}),V=ZR(),ne=u.useMemo(()=>({sessionId:o??void 0,agentName:f?Le(f):void 0,agentVisual:f?g:void 0,origin:oe,originLabel:he,sessionTitle:X,sessionDirectoryName:h?Pl(h):void 0,room:x,teamViewMode:Tx(new URLSearchParams(i).get("view")??void 0)}),[o,f,g,oe,he,X,h,x,i]),ye=AI();return O?n.jsx(yE,{}):($==null?void 0:$.status)!==void 0?n.jsx(aI,{status:$.status,message:$.message,code:$.code}):v&&!Y?n.jsx("div",{className:"bg-background h-dvh"}):n.jsxs(Dx,{children:[n.jsx(mE,{unreadRoomCount:y}),n.jsxs(qy,{reducedMotion:"user",children:[n.jsx(Ve,{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(Lw,{onComplete:H,slots:rI})},"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:U("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(gE,{isFullscreen:b}),n.jsx(sm,{}),n.jsx(HI,{slotKey:W.key,direction:W.direction,children:W.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(Sk,{className:U("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(Ak,{}),n.jsx($x,{orientation:"vertical",className:"mr-1 h-4"})]}),s&&n.jsx(AA,{}),V&&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(V.Header,{})})},V.key),n.jsx(tI,{})]}),n.jsx(mI,{descriptors:ye}),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(Qj,{pathname:a,isRemoteCommunityRoom:d})]})})]})]}),s&&n.jsx(QI,{takeover:W.isTakeover?W.body:null})]})},"main-app")}),n.jsx(a1,{}),n.jsx(KI,{onboardingOverlayVisible:_}),n.jsx(oE,{}),n.jsx(OA,{}),n.jsx(e1,{}),n.jsx(RR,{}),n.jsx(Sj,{}),n.jsx(VR,{}),n.jsx(Iv,{}),n.jsx(gy,{}),n.jsx(KR,{}),n.jsx(Wx,{}),n.jsx(YR,{})]})]})}const DD=eT;export{DD as component};