dorkos 0.124.0 → 0.124.1

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 (311) hide show
  1. package/dist/bin/cli.js +935 -551
  2. package/dist/browser/native/package-manifest.json +1 -1
  3. package/dist/browser/source-manifest.json +1 -1
  4. package/dist/client/assets/{AboutPage-BH8Ndn3e.js → AboutPage-DHaZvsJE.js} +1 -1
  5. package/dist/client/assets/{ActivityErrorState-K5Mew9EX.js → ActivityErrorState-BP-qFk2S.js} +1 -1
  6. package/dist/client/assets/{ActivityPage-BB20L5HU.js → ActivityPage-Bme3TzdQ.js} +1 -1
  7. package/dist/client/assets/{ActivityRow-C5O7rnmS.js → ActivityRow-BRZyW9MA.js} +1 -1
  8. package/dist/client/assets/{AdapterIcon-Bmybvrzb.js → AdapterIcon-BcfquTja.js} +1 -1
  9. package/dist/client/assets/{AdapterSetupWizard-CkdV7Hhh.js → AdapterSetupWizard-B4I23pBg.js} +1 -1
  10. package/dist/client/assets/{AgentOptionRow-BA2cDa7r.js → AgentOptionRow-Cb34LtmH.js} +1 -1
  11. package/dist/client/assets/{AgentPicker-CsIIPGZJ.js → AgentPicker-ouNRFSDh.js} +1 -1
  12. package/dist/client/assets/{AgentRequestCard-0fOxvaoe.js → AgentRequestCard-B6MHIsxa.js} +2 -2
  13. package/dist/client/assets/{AppearancePage-XOjkkoli.js → AppearancePage-CutehigK.js} +1 -1
  14. package/dist/client/assets/ApplyToOverridesDialog-B-wIUI27.js +1 -0
  15. package/dist/client/assets/{AttentionSignalRow-CjjZobp7.js → AttentionSignalRow-B1aMjgX_.js} +1 -1
  16. package/dist/client/assets/{BaseTanStackRouterDevtoolsPanel-B-iktbLX-9TVHyRPJ.js → BaseTanStackRouterDevtoolsPanel-B-iktbLX-CdWF4WLz.js} +1 -1
  17. package/dist/client/assets/{BindingDialog-DLoAQauL.js → BindingDialog-BAdueON5.js} +1 -1
  18. package/dist/client/assets/{BlintzCanvas-CYHsXAcY.js → BlintzCanvas-b30dG4gx.js} +3 -3
  19. package/dist/client/assets/{CanvasCsvContent--Gr7Fe_U.js → CanvasCsvContent-DGHgSikG.js} +1 -1
  20. package/dist/client/assets/{CanvasFileContent-estXyAbr.js → CanvasFileContent-D1bFaUeh.js} +2 -2
  21. package/dist/client/assets/{CanvasModel3dContent-CkOo930M.js → CanvasModel3dContent-dST7g1v2.js} +2 -2
  22. package/dist/client/assets/{ChatAppsOff-D4L1zJVN.js → ChatAppsOff-DiObvmJS.js} +1 -1
  23. package/dist/client/assets/{CodeMirrorDiff-DY_6ju-z.js → CodeMirrorDiff-BncI1OY1.js} +1 -1
  24. package/dist/client/assets/{CodeMirrorEditor-BUoDBsBv.js → CodeMirrorEditor-DV6psv19.js} +1 -1
  25. package/dist/client/assets/{CommitmentList-wDkcVP9c.js → CommitmentList-Dx_Ek_Gl.js} +1 -1
  26. package/dist/client/assets/{CommitmentsPage-CzSM6b8R.js → CommitmentsPage-Bca8NMUa.js} +1 -1
  27. package/dist/client/assets/{ComputerResourceView-cERD9H2L.js → ComputerResourceView-DNVNFTdn.js} +1 -1
  28. package/dist/client/assets/{ComputerViewer-rMcfbk2_.js → ComputerViewer-D8SxJdMm.js} +1 -1
  29. package/dist/client/assets/{ConnectionAccessLists-f7QeQbQo.js → ConnectionAccessLists-Bhj1YT15.js} +1 -1
  30. package/dist/client/assets/{ConnectionsPage-BmjtA6pw.js → ConnectionsPage-B20JZxoK.js} +1 -1
  31. package/dist/client/assets/{ConventionPage-CH-ah6nI.js → ConventionPage-De645wxU.js} +1 -1
  32. package/dist/client/assets/{ExtensionPageRoute-CJIxa6ST.js → ExtensionPageRoute-nTeiOBRQ.js} +1 -1
  33. package/dist/client/assets/{FloatingTanStackRouterDevtools-CqogiFob-BP7EJ2JL.js → FloatingTanStackRouterDevtools-CqogiFob-DM79UITv.js} +1 -1
  34. package/dist/client/assets/HandlePage-B08V-om7.js +1 -0
  35. package/dist/client/assets/{HeartbeatPage-BUsf-qrU.js → HeartbeatPage-CBoUxz6t.js} +1 -1
  36. package/dist/client/assets/{KeyEntry-C2kWdN8q.js → KeyEntry-Cug8ocpX.js} +1 -1
  37. package/dist/client/assets/{LexicalField-CR8ulsI_.js → LexicalField-Bv_ogmAq.js} +1 -1
  38. package/dist/client/assets/{ManagesPage-DTtsIOGi.js → ManagesPage-DfJBQKK3.js} +1 -1
  39. package/dist/client/assets/{Marketplace-iaV5XAzv.js → Marketplace-swCVUbdY.js} +2 -2
  40. package/dist/client/assets/{MarketplaceSourcesView-6tgzUfFj.js → MarketplaceSourcesView-CDZDChpV.js} +1 -1
  41. package/dist/client/assets/{McpAppFrame-C7eYYdI9.js → McpAppFrame-BM9cNPPd.js} +1 -1
  42. package/dist/client/assets/{McpSigninBody-BDyGbJ7I.js → McpSigninBody-DKyUKrEE.js} +1 -1
  43. package/dist/client/assets/{Model3dViewer-BujDNuVS.js → Model3dViewer-rXSL5y2P.js} +1 -1
  44. package/dist/client/assets/NamePage-JwMDK1JD.js +1 -0
  45. package/dist/client/assets/{NewDirectMessageMenu-D4e-z2Jt.js → NewDirectMessageMenu-GCEMS5oV.js} +1 -1
  46. package/dist/client/assets/{NotificationsPage-CkDeTaJp.js → NotificationsPage-DSWsOVLa.js} +1 -1
  47. package/dist/client/assets/{OpenMeshSwitch-CtbOt3r5.js → OpenMeshSwitch-BTuctDj4.js} +1 -1
  48. package/dist/client/assets/{OperatorIdentityForm-Vr4qZnmM.js → OperatorIdentityForm-ODDMd2YN.js} +1 -1
  49. package/dist/client/assets/PermissionHistory-41a58Se7.js +1 -0
  50. package/dist/client/assets/{PermissionsPage-f4QaX8oM.js → PermissionsPage-DefmymZ6.js} +1 -1
  51. package/dist/client/assets/{PersonalityPopover-BkZruwF-.js → PersonalityPopover-7zPVBI1I.js} +1 -1
  52. package/dist/client/assets/PhotoPage-DlOVhkW9.js +1 -0
  53. package/dist/client/assets/{PreviewRefusedNotice-BXC2K0tx.js → PreviewRefusedNotice-CwGlBJ7U.js} +1 -1
  54. package/dist/client/assets/{ProfileFields-BebX5oiv.js → ProfileFields-DVMkpJSb.js} +1 -1
  55. package/dist/client/assets/{ProfilePanelContainer-DZoL65zQ.js → ProfilePanelContainer-RrhoPD3T.js} +1 -1
  56. package/dist/client/assets/{ProfileRolePicker-D9H7wsuT.js → ProfileRolePicker-CXRVBCAu.js} +1 -1
  57. package/dist/client/assets/{PromptSuggestionChips-B5fDmc-g.js → PromptSuggestionChips-bBroJdTi.js} +1 -1
  58. package/dist/client/assets/{ReportsToPopover-uVYhSqj7.js → ReportsToPopover-CfPatsWM.js} +1 -1
  59. package/dist/client/assets/{RoomSurface-Bg5WV4Ep.js → RoomSurface-CdgCdV6h.js} +11 -11
  60. package/dist/client/assets/{RoomsPage-yflYFulU.js → RoomsPage-C3dDp1Mb.js} +1 -1
  61. package/dist/client/assets/{RunsOnPopover-DtGrX1Vq.js → RunsOnPopover-BcKjfQi-.js} +1 -1
  62. package/dist/client/assets/{RuntimeConnectFlow-DjReuQ-T.js → RuntimeConnectFlow-DCIRnvOH.js} +1 -1
  63. package/dist/client/assets/{RuntimeSetupDialog-Cr4GRi8c.js → RuntimeSetupDialog-Bg-0b-LC.js} +1 -1
  64. package/dist/client/assets/SeenDevices-nMsGUQTv.js +19 -0
  65. package/dist/client/assets/{SessionsPage-BWu-en78.js → SessionsPage-Cqfx4FGW.js} +1 -1
  66. package/dist/client/assets/SettingsDialog-C8r2igJ_.js +12 -0
  67. package/dist/client/assets/{SkillsPage-BdUb9SZy.js → SkillsPage-BleHQavF.js} +1 -1
  68. package/dist/client/assets/{TaskDialogWrapper-qYJPEoSR.js → TaskDialogWrapper-BhTEvf-u.js} +1 -1
  69. package/dist/client/assets/{TasksEmptyState-Bgcg9vxF.js → TasksEmptyState-Bprx1k8M.js} +2 -2
  70. package/dist/client/assets/{TasksPage-Ch5W2WQS.js → TasksPage-Dub39yEJ.js} +1 -1
  71. package/dist/client/assets/{TeamComputerEntry-CPwSIMRw.js → TeamComputerEntry-CJ-NG0u5.js} +1 -1
  72. package/dist/client/assets/ToolsPage-IsD6M-ZW.js +2 -0
  73. package/dist/client/assets/{TopologyGraph-I4_mkMHM.js → TopologyGraph-CwyasvFI.js} +14 -14
  74. package/dist/client/assets/{TourHost-BPaSwh9I.js → TourHost-BYfztuPb.js} +1 -1
  75. package/dist/client/assets/{UnlinkDialog-BUWZUu5P.js → UnlinkDialog-BKhgxVdF.js} +1 -1
  76. package/dist/client/assets/{WidgetErrorCard-cS8yMCxU.js → WidgetErrorCard-1NyzIJBj.js} +6 -6
  77. package/dist/client/assets/_shell-Ct2Bz7D0.js +80 -0
  78. package/dist/client/assets/{_shell._home-DCA5k-jb.js → _shell._home-xWj7wO5z.js} +1 -1
  79. package/dist/client/assets/{_shell._home.activity-BX4nFLna.js → _shell._home.activity-BqcLoaB1.js} +1 -1
  80. package/dist/client/assets/{_shell._home.index-C8t8cw72.js → _shell._home.index-D4sQsKKk.js} +1 -1
  81. package/dist/client/assets/{_shell._home.tasks-BgUeEvhK.js → _shell._home.tasks--UhQB6h3.js} +1 -1
  82. package/dist/client/assets/{_shell._home.workspaces-BPBdnkRt.js → _shell._home.workspaces-BPFD8Of2.js} +1 -1
  83. package/dist/client/assets/{_shell.channels-CX4kki7G.js → _shell.channels-CnFdvRzc.js} +4 -4
  84. package/dist/client/assets/{_shell.connections-0vP7g7E4.js → _shell.connections-Ik01wS5M.js} +1 -1
  85. package/dist/client/assets/{_shell.feedback-requests-TsuaO4eR.js → _shell.feedback-requests-Czu42kzo.js} +1 -1
  86. package/dist/client/assets/_shell.marketplace-Cezv-i16.js +1 -0
  87. package/dist/client/assets/_shell.marketplace_.sources-BTENmr4W.js +1 -0
  88. package/dist/client/assets/_shell.session-BjevHF_O.js +63 -0
  89. package/dist/client/assets/{_shell.team-Bm6cOBhR.js → _shell.team-UfaJqohh.js} +3 -3
  90. package/dist/client/assets/_shell.x._extensionId-0OO_Xr72.js +1 -0
  91. package/dist/client/assets/_shell.x._extensionId_._-0OO_Xr72.js +1 -0
  92. package/dist/client/assets/{abnfDiagram-WEYOIA3C-CrvoN15x.js → abnfDiagram-WEYOIA3C-oxkfGyl6.js} +1 -1
  93. package/dist/client/assets/{access-copy-B3yNZ7Gz.js → access-copy-Dggxx2cX.js} +1 -1
  94. package/dist/client/assets/{arc-CuT6QA_y.js → arc-CqQdP0Qe.js} +1 -1
  95. package/dist/client/assets/{architectureDiagram-ZHVYKT53-CPXCZ9H4.js → architectureDiagram-ZHVYKT53-89xM7zJD.js} +1 -1
  96. package/dist/client/assets/{banner-DRumuw3F.js → banner-DqJ2pM0Y.js} +1 -1
  97. package/dist/client/assets/{blockDiagram-RJAE7QA3-CM0rka9p.js → blockDiagram-RJAE7QA3-CcxwDmZC.js} +1 -1
  98. package/dist/client/assets/{c4Diagram-XDPPPE54-D4j2cXRy.js → c4Diagram-XDPPPE54-DCIhIyXa.js} +1 -1
  99. package/dist/client/assets/{card-B3CtfC3R.js → card-DT-vFAns.js} +1 -1
  100. package/dist/client/assets/channel-Ngk70nQZ.js +1 -0
  101. package/dist/client/assets/{chunk-2E7WHVMD-KGyqhVpO.js → chunk-2E7WHVMD-BfWEXcCj.js} +1 -1
  102. package/dist/client/assets/{chunk-2Q5K7J3B-Dl0BHoqK.js → chunk-2Q5K7J3B-KLXLZXlR.js} +1 -1
  103. package/dist/client/assets/{chunk-4EMNKR2T-Da7vH6Kv.js → chunk-4EMNKR2T-CL5Gttmj.js} +1 -1
  104. package/dist/client/assets/{chunk-55XCU76K-DgBUEROO.js → chunk-55XCU76K-cfAl84Mv.js} +1 -1
  105. package/dist/client/assets/{chunk-5VM5RSS4-BQ4mn-_I.js → chunk-5VM5RSS4-BqUyGgoH.js} +1 -1
  106. package/dist/client/assets/{chunk-JWPE2WC7-8LPR3mXf.js → chunk-JWPE2WC7-BWr2ST9i.js} +1 -1
  107. package/dist/client/assets/{chunk-VQ5W62QI-BkIVXi4W.js → chunk-VQ5W62QI-V5zYx50O.js} +1 -1
  108. package/dist/client/assets/{chunk-XXDRQBXY-DQXJx06h.js → chunk-XXDRQBXY-gnvheN_J.js} +1 -1
  109. package/dist/client/assets/{chunk-ZCHMQSOR-DzCE7qlD.js → chunk-ZCHMQSOR-ClGxxZvV.js} +2 -2
  110. package/dist/client/assets/{classDiagram-v2-4MYWR3UA-C_cZra7c.js → classDiagram-v2-4MYWR3UA-DvmHzDb5.js} +1 -1
  111. package/dist/client/assets/{command-CDKbyppr.js → command-CNx4L11m.js} +1 -1
  112. package/dist/client/assets/{cose-bilkent-JH36ORCC-DlXHdGwT.js → cose-bilkent-JH36ORCC-Df8nXBRj.js} +1 -1
  113. package/dist/client/assets/{cpu-B7xLO7jn.js → cpu-D8KJEkdh.js} +1 -1
  114. package/dist/client/assets/{cynefin-EF2NZ3EQ-HhP4ArLc.js → cynefin-EF2NZ3EQ-CAn6ufHs.js} +1 -1
  115. package/dist/client/assets/{cynefinDiagram-WF24UDRP-D4GgWnZV.js → cynefinDiagram-WF24UDRP-Cep_NrRw.js} +1 -1
  116. package/dist/client/assets/{dagre-NK4GIZVX-SZ_OI2Zi.js → dagre-NK4GIZVX-sWD3z9wf.js} +1 -1
  117. package/dist/client/assets/{diagram-CBK3MWTC-BN-_Ja5m.js → diagram-CBK3MWTC-CUpaBATr.js} +1 -1
  118. package/dist/client/assets/{diagram-I5XIIV2D-t7AK6xnL.js → diagram-I5XIIV2D-BejWB2ry.js} +1 -1
  119. package/dist/client/assets/{diagram-ODIL2UCW-C1V7szSc.js → diagram-ODIL2UCW-BGKJfNk9.js} +1 -1
  120. package/dist/client/assets/{diagram-PFBEJUXE-DPtraQ2g.js → diagram-PFBEJUXE-V0dP8H8k.js} +1 -1
  121. package/dist/client/assets/{diagram-RJA3I4VV-D2XNRB2b.js → diagram-RJA3I4VV-Bf5dVsFX.js} +1 -1
  122. package/dist/client/assets/{diagram-TYUNFSNR-BieaRy38.js → diagram-TYUNFSNR-CLrMSqb4.js} +1 -1
  123. package/dist/client/assets/{ebnfDiagram-V4P3TTPT-Bwki86UY.js → ebnfDiagram-V4P3TTPT-BGG4CWA0.js} +1 -1
  124. package/dist/client/assets/{elk-QONTBCTQ-WEXSAyHB.js → elk-QONTBCTQ-bf9D6f0w.js} +1 -1
  125. package/dist/client/assets/{empty-state-J-UJ0BUU.js → empty-state-CDoXnrKn.js} +1 -1
  126. package/dist/client/assets/{erDiagram-KYQIGQAA-DIKASnoc.js → erDiagram-KYQIGQAA-fEUv-33P.js} +1 -1
  127. package/dist/client/assets/{execution-config-ILQiJAmy.js → execution-config-Ca9MDOtV.js} +1 -1
  128. package/dist/client/assets/{file-D40js1Zx.js → file-CiyVL55_.js} +1 -1
  129. package/dist/client/assets/{file-exclamation-point-Dg3ZpiAe.js → file-exclamation-point-DaFRIKco.js} +1 -1
  130. package/dist/client/assets/{file-text-DgdvRfMk.js → file-text-DsnD-A8g.js} +1 -1
  131. package/dist/client/assets/{find-latest-widget-fence-D4kBWC_1.js → find-latest-widget-fence-CNsnCgbB.js} +1 -1
  132. package/dist/client/assets/{flowDiagram-IUGLLWBU-CoavNw0M.js → flowDiagram-IUGLLWBU-CRbeSDod.js} +1 -1
  133. package/dist/client/assets/{form-DlPwEgQH.js → form-Cru78aT-.js} +1 -1
  134. package/dist/client/assets/{format-cron-BrK8RzgT.js → format-cron-9K38-tn1.js} +1 -1
  135. package/dist/client/assets/{ganttDiagram-R7GPNTJY-DccKAz7f.js → ganttDiagram-R7GPNTJY-Mkk7zgs_.js} +1 -1
  136. package/dist/client/assets/{git-branch-BpxhecMq.js → git-branch-CONwEYiR.js} +1 -1
  137. package/dist/client/assets/{gitGraphDiagram-PDYL7XHY-DEbo_dgQ.js → gitGraphDiagram-PDYL7XHY-Drre0vyA.js} +1 -1
  138. package/dist/client/assets/{graph-DROgI3M3.js → graph-BJlnKWgo.js} +1 -1
  139. package/dist/client/assets/{heart-c7u4Ezxt.js → heart-CqwUlIUG.js} +1 -1
  140. package/dist/client/assets/{highlighted-body-KPVGNVTW-CrATNdTR.js → highlighted-body-KPVGNVTW-e4LXC_pS.js} +1 -1
  141. package/dist/client/assets/{image-lightbox-DE_fHkw-.js → image-lightbox-DHDtzoja.js} +1 -1
  142. package/dist/client/assets/{image-off-BExgZjfM.js → image-off-DZuLkaRJ.js} +1 -1
  143. package/dist/client/assets/{index-D0eJtRlK.js → index-1yEXEZiH.js} +1 -1
  144. package/dist/client/assets/{index-Be0OJLWK.js → index-A41zxoWk.js} +1 -1
  145. package/dist/client/assets/{index-DeRDq7bD.js → index-B25gvCK_.js} +1 -1
  146. package/dist/client/assets/index-B9bZYNKR.js +1 -0
  147. package/dist/client/assets/{index-DaZ1I8s-.js → index-BBmkfbXd.js} +1 -1
  148. package/dist/client/assets/{index-DNGNMW3c.js → index-BDD2EyoW.js} +1 -1
  149. package/dist/client/assets/{index-Ccf1XBTs.js → index-BFNy-Yp3.js} +1 -1
  150. package/dist/client/assets/{index-DksjixUS.js → index-BIB-maE5.js} +1 -1
  151. package/dist/client/assets/{index-CbHCZsbE.js → index-BKp2B9JS.js} +1 -1
  152. package/dist/client/assets/{index-DCJQGDZk.js → index-BLP5O7X9.js} +1 -1
  153. package/dist/client/assets/{index-DhHobJd3.js → index-BTjZIgFn.js} +1 -1
  154. package/dist/client/assets/{index-BVqSmajJ.js → index-BV2Ezdxv.js} +1 -1
  155. package/dist/client/assets/{index-C7B3eSOP.js → index-B_0LYi32.js} +1 -1
  156. package/dist/client/assets/{index-DDgOoXP1.js → index-Bd7vUYhr.js} +1 -1
  157. package/dist/client/assets/{index-BlyoyIck.js → index-Bo7x9IkO.js} +1 -1
  158. package/dist/client/assets/{index-D150FXCC.js → index-BtDxwJsM.js} +1 -1
  159. package/dist/client/assets/{index-DswGXheF.js → index-By58MgcZ.js} +1 -1
  160. package/dist/client/assets/index-C3cvP8Fo.js +1033 -0
  161. package/dist/client/assets/{index-C5or4L_3.js → index-CVuEUzi5.js} +1 -1
  162. package/dist/client/assets/{index-BkoMsjtM.js → index-CoWJD3Jg.js} +2 -2
  163. package/dist/client/assets/{index-CqPRAM_6.js → index-CyVH876g.js} +1 -1
  164. package/dist/client/assets/{index-BGqvci3k.js → index-D67Kfy-M.js} +1 -1
  165. package/dist/client/assets/{index-D3YeRrne.js → index-DAlpmAIA.js} +1 -1
  166. package/dist/client/assets/{index-BEkYBuOq.js → index-DDNwNOHF.js} +1 -1
  167. package/dist/client/assets/{index-CD8aw6Jb.js → index-DL8ISRMH.js} +1 -1
  168. package/dist/client/assets/{index-AzyLwYS_.js → index-DabU6r9W.js} +3 -3
  169. package/dist/client/assets/{index-CT_pFeX_.js → index-DdJBZE0H.js} +1 -1
  170. package/dist/client/assets/{index-B3eeEDWj.js → index-DijWcSDZ.js} +1 -1
  171. package/dist/client/assets/index-DyRGZyur.css +1 -0
  172. package/dist/client/assets/{index-DINk1YfD.js → index-DzwZJuO1.js} +1 -1
  173. package/dist/client/assets/{index-CZmqtJWZ.js → index-HR8BYVRQ.js} +1 -1
  174. package/dist/client/assets/{index-J3Hh1MnL.js → index-LEcodwyW.js} +1 -1
  175. package/dist/client/assets/index-UPF8suf2.js +1 -0
  176. package/dist/client/assets/{index-DT7pv2iW.js → index-Vz7VUm9l.js} +1 -1
  177. package/dist/client/assets/index-YW-v746p.js +1 -0
  178. package/dist/client/assets/{index-2wezsLA_.js → index-cI2u8WZS.js} +1 -1
  179. package/dist/client/assets/{index-InEBtYxw.js → index-iTQUa_b2.js} +6 -6
  180. package/dist/client/assets/{index-CYy1cjtq.js → index-mZqojApH.js} +1 -1
  181. package/dist/client/assets/{index-dyAahqKe.js → index-pVFjKNjX.js} +1 -1
  182. package/dist/client/assets/{index-DxiRRZRo.js → index-skAhJyIF.js} +1 -1
  183. package/dist/client/assets/{index-BizvylBV.js → index-vJy88bwb.js} +1 -1
  184. package/dist/client/assets/index-wY5OcS4a.js +43 -0
  185. package/dist/client/assets/{index-mwf7ZNk2.js → index-x1yAu9zJ.js} +1 -1
  186. package/dist/client/assets/{index-F-vqXYqa.js → index-xAgihCJ7.js} +1 -1
  187. package/dist/client/assets/{index.esm-BFJ9SG0n.js → index.esm-BUPoRUaG.js} +1 -1
  188. package/dist/client/assets/{infoDiagram-MVDRKAX5-VL8q5pKx.js → infoDiagram-MVDRKAX5-B_Wyzufh.js} +1 -1
  189. package/dist/client/assets/{inline-code-BE9ckzPs.js → inline-code-BIzGDx6z.js} +1 -1
  190. package/dist/client/assets/{ishikawaDiagram-HPEHV2GE-BLKkPYF-.js → ishikawaDiagram-HPEHV2GE-BDk2-6Pd.js} +1 -1
  191. package/dist/client/assets/{journeyDiagram-BOSHW7O7-CSYpRobu.js → journeyDiagram-BOSHW7O7-7qf9KWEQ.js} +1 -1
  192. package/dist/client/assets/{kanban-definition-FNSA4HC5-HilAqtZo.js → kanban-definition-FNSA4HC5-CFYDQmXn.js} +1 -1
  193. package/dist/client/assets/{layers-Cm7coqdo.js → layers-C9tVVcXg.js} +1 -1
  194. package/dist/client/assets/{lightbulb-DqdWS75d.js → lightbulb-f4jtsAh0.js} +1 -1
  195. package/dist/client/assets/{link-2-CDJapTSa.js → link-2-ZNlK1BG1.js} +1 -1
  196. package/dist/client/assets/{list-runtime-types-CP82p1u4.js → list-runtime-types-CqO-QFYD.js} +1 -1
  197. package/dist/client/assets/{markdown-content-m_qereFc.js → markdown-content-DaEVxezf.js} +1 -1
  198. package/dist/client/assets/{mention-pill-DV5HIG5Q.js → mention-pill-BiCPflY-.js} +1 -1
  199. package/dist/client/assets/{mermaid.core-zxW6MBr-.js → mermaid.core-SX8SzrsU.js} +4 -4
  200. package/dist/client/assets/{message-square-off-YVtpbaJ0.js → message-square-off-_qbedNGF.js} +1 -1
  201. package/dist/client/assets/{mindmap-definition-6OY57UG3-IAYemvOg.js → mindmap-definition-6OY57UG3-BloJIArH.js} +1 -1
  202. package/dist/client/assets/{more-details-ReA2ZFBn.js → more-details-CdJT0Ehl.js} +1 -1
  203. package/dist/client/assets/{owner-notice-M4hn_1ep.js → owner-notice-BDafFD_I.js} +1 -1
  204. package/dist/client/assets/{package-CUuTl39E.js → package-Cb7lEm7t.js} +1 -1
  205. package/dist/client/assets/{page-container-BnmNikNZ.js → page-container-DsRgIMAL.js} +1 -1
  206. package/dist/client/assets/{paperclip-C6fYq5Zf.js → paperclip-DNu1VtoX.js} +1 -1
  207. package/dist/client/assets/{path-input-DHn9-XaE.js → path-input-D3O71b-X.js} +1 -1
  208. package/dist/client/assets/{pegDiagram-ECIUJNBX-CojaUwe7.js → pegDiagram-ECIUJNBX-Di48kPNu.js} +1 -1
  209. package/dist/client/assets/{pieDiagram-GNMPY74T-CjP3pw6V.js → pieDiagram-GNMPY74T-DY8B_SPD.js} +1 -1
  210. package/dist/client/assets/{plug-DHQcxt7N.js → plug-IIS_cL9-.js} +1 -1
  211. package/dist/client/assets/{primer-trigger-BmV5wjek.js → primer-trigger-DurKYe8C.js} +2 -2
  212. package/dist/client/assets/{profile-errors-BSCuj3rT.js → profile-errors-BdhZfdvZ.js} +1 -1
  213. package/dist/client/assets/{progress-4FQQfnS6.js → progress-g5kkqvlR.js} +1 -1
  214. package/dist/client/assets/{quadrantDiagram-D57K4MC3-OP0Z8zcR.js → quadrantDiagram-D57K4MC3-Depv_dON.js} +1 -1
  215. package/dist/client/assets/{query-error-state-BkUdxenP.js → query-error-state-PuLGD7Jp.js} +1 -1
  216. package/dist/client/assets/{radio-ta5Bw763.js → radio-QOLZSBz1.js} +1 -1
  217. package/dist/client/assets/{railroadDiagram-Y72NRBL7-CT3NCb9b.js → railroadDiagram-Y72NRBL7-BfD2AiZM.js} +1 -1
  218. package/dist/client/assets/registry-Ck8p6n1T.js +1 -0
  219. package/dist/client/assets/{relay-trace-schemas-DwUuyxao.js → relay-trace-schemas-DF_DfZ7s.js} +1 -1
  220. package/dist/client/assets/{requirementDiagram-EQYSW5RA-tde4lYGp.js → requirementDiagram-EQYSW5RA-B1iTjrkD.js} +1 -1
  221. package/dist/client/assets/{room-files-source-CZWhaaOy.js → room-files-source-g1th8mWs.js} +2 -2
  222. package/dist/client/assets/{rotate-ccw-clock-RfbbgUa4.js → rotate-ccw-clock-BGwYMaGL.js} +1 -1
  223. package/dist/client/assets/{rotate-cw-B3rB_YSw.js → rotate-cw-B4Y0q4GY.js} +1 -1
  224. package/dist/client/assets/{sankeyDiagram-SY24JHO5-sdCzIA7-.js → sankeyDiagram-SY24JHO5-D5TzVJrQ.js} +1 -1
  225. package/dist/client/assets/{scroll-area-B4WB7Q40.js → scroll-area-BvScZKSa.js} +1 -1
  226. package/dist/client/assets/{search-x-DCUmWW2_.js → search-x-CqN5twBj.js} +1 -1
  227. package/dist/client/assets/{sequenceDiagram-BLEHNHQU-DvzTJcKu.js → sequenceDiagram-BLEHNHQU-BhUahaNf.js} +1 -1
  228. package/dist/client/assets/{shield-x-CANziVLc.js → shield-x-DHJrwtKp.js} +1 -1
  229. package/dist/client/assets/signed-in-BmywDpR5.js +1 -0
  230. package/dist/client/assets/{sizeCapture-INFHLROL-DuDA7TKE.js → sizeCapture-INFHLROL-D2Vi1Kq9.js} +1 -1
  231. package/dist/client/assets/{soul-file-Co_8f1qw.js → soul-file-BMpVFN7U.js} +1 -1
  232. package/dist/client/assets/{stateDiagram-v2-A6IESKWZ-BJPX5JTC.js → stateDiagram-v2-A6IESKWZ-b9gSbZnF.js} +1 -1
  233. package/dist/client/assets/{swimlanes-B3ENRKFQ-CiLSffGv.js → swimlanes-B3ENRKFQ-i47jxLY6.js} +1 -1
  234. package/dist/client/assets/swimlanesDiagram-AYQRV4AK-CA9gW19w.js +8 -0
  235. package/dist/client/assets/{table-BSAvOYPp.js → table-CN2HCi4p.js} +1 -1
  236. package/dist/client/assets/{terminal-6CdY-T1V.js → terminal-BORQniao.js} +1 -1
  237. package/dist/client/assets/{timeline-definition-JXYKGLGB-5oq8sl82.js → timeline-definition-JXYKGLGB-eY5gj0js.js} +1 -1
  238. package/dist/client/assets/{trust-posture-D-Yjm6ot.js → trust-posture-Bcyy5Fub.js} +1 -1
  239. package/dist/client/assets/{unplug-Bq_1WdV7.js → unplug-lkD35Rwp.js} +1 -1
  240. package/dist/client/assets/{unverified-catalog-notice-CEzu54YH.js → unverified-catalog-notice-DiCIrrhU.js} +1 -1
  241. package/dist/client/assets/{use-adapter-catalog-Tn3ZbPAj.js → use-adapter-catalog-BrqVd-47.js} +1 -1
  242. package/dist/client/assets/{use-bindings-Bz9YRgO7.js → use-bindings-CU2RSXOy.js} +1 -1
  243. package/dist/client/assets/{use-composer-prefs-D9oKJSQN.js → use-composer-prefs-Dy2oTM8Y.js} +1 -1
  244. package/dist/client/assets/{use-connector-management-CLYFraXN.js → use-connector-management-5oRqzydY.js} +1 -1
  245. package/dist/client/assets/{use-deep-link-scroll-DkS713kG.js → use-deep-link-scroll-Bg5nW8qq.js} +1 -1
  246. package/dist/client/assets/{use-delete-binding-CukKpHBK.js → use-delete-binding-qeyRkvR1.js} +1 -1
  247. package/dist/client/assets/{use-dev-links-DQ32IcGe.js → use-dev-links-FY4J_PjA.js} +1 -1
  248. package/dist/client/assets/{use-external-adapter-catalog-D-FO_XW6.js → use-external-adapter-catalog-HiWFZZrW.js} +1 -1
  249. package/dist/client/assets/{use-full-activity-feed-BNxcyb1j.js → use-full-activity-feed-K1uk9Wya.js} +1 -1
  250. package/dist/client/assets/use-is-below-desktop-Cu_jKnft.js +1 -0
  251. package/dist/client/assets/use-is-hub-BX7ypNRJ.js +1 -0
  252. package/dist/client/assets/{use-jump-back-in-Bibj5tVk.js → use-jump-back-in-BjZ8EswV.js} +1 -1
  253. package/dist/client/assets/{use-local-browser-xg7WXAVK.js → use-local-browser-CTFiF0wf.js} +1 -1
  254. package/dist/client/assets/{use-mesh-topology-BgCSFw8s.js → use-mesh-topology-CafidaIH.js} +1 -1
  255. package/dist/client/assets/{use-mounted-ref-qRbdZfOU.js → use-mounted-ref-B38uSLCx.js} +1 -1
  256. package/dist/client/assets/{use-notification-prefs-B-4kZR7I.js → use-notification-prefs-m9XSNB6W.js} +1 -1
  257. package/dist/client/assets/{use-panel-tab-placements-CCq-mZlY.js → use-panel-tab-placements-D9n6rNJ1.js} +1 -1
  258. package/dist/client/assets/use-pending-read-BoV-UI1E.js +1 -0
  259. package/dist/client/assets/{use-personality-commit-DwSisUfF.js → use-personality-commit-ChLQfLrK.js} +1 -1
  260. package/dist/client/assets/{use-promo-activation-Botoso6l.js → use-promo-activation-DbJDgp4_.js} +1 -1
  261. package/dist/client/assets/{use-promo-dismissals-RJXp-r_J.js → use-promo-dismissals-Csw0j0N0.js} +1 -1
  262. package/dist/client/assets/{use-pulse-freshness-B3390hGg.js → use-pulse-freshness-BIZ7daHW.js} +1 -1
  263. package/dist/client/assets/{use-relay-config-BV0xcLwS.js → use-relay-config-hUB3lVFv.js} +1 -1
  264. package/dist/client/assets/{use-room-follow-claim-Du4hKHIJ.js → use-room-follow-claim-BpKzhniV.js} +1 -1
  265. package/dist/client/assets/{use-roving-tab-list-g2hO6Ruz.js → use-roving-tab-list-BtM0bZL7.js} +1 -1
  266. package/dist/client/assets/{use-session-canvas-i30oMO_Q.js → use-session-canvas-DRrkNRcL.js} +3 -3
  267. package/dist/client/assets/use-session-diagnostics-BTNgouum.js +16 -0
  268. package/dist/client/assets/{use-unclaimed-chats-B92om889.js → use-unclaimed-chats-BbMZtNG9.js} +1 -1
  269. package/dist/client/assets/use-update-config-CkWwKNkY.js +1 -0
  270. package/dist/client/assets/{useMutationState-DdOGdpjP.js → useMutationState-CVpvw27W.js} +1 -1
  271. package/dist/client/assets/{usecaseDiagram-WPOLBNNX-Di5pJvcw.js → usecaseDiagram-WPOLBNNX-CHcpeLg4.js} +1 -1
  272. package/dist/client/assets/{vennDiagram-Q3Y3IDCW-K7KAf26T.js → vennDiagram-Q3Y3IDCW-gQbZL_A6.js} +1 -1
  273. package/dist/client/assets/{wardleyDiagram-IVAIDKWA-DVTaxQt9.js → wardleyDiagram-IVAIDKWA-BFH_WHzZ.js} +1 -1
  274. package/dist/client/assets/{xychartDiagram-4URNHDU4-x-lSJm_B.js → xychartDiagram-4URNHDU4-B0QpyqeZ.js} +1 -1
  275. package/dist/client/index.html +2 -2
  276. package/dist/drizzle/20261019185620_dor3037_wifi_holds.sql +8 -0
  277. package/dist/drizzle/meta/20261019185620_snapshot.json +14079 -0
  278. package/dist/drizzle/meta/_journal.json +7 -0
  279. package/dist/server/extension-child.cjs +18 -2
  280. package/dist/server/index.js +55523 -26605
  281. package/dist/server/index.js.map +2 -2
  282. package/package.json +6 -6
  283. package/dist/client/assets/ApplyToOverridesDialog-CoO6V1G4.js +0 -1
  284. package/dist/client/assets/HandlePage-Cg8H3mQS.js +0 -1
  285. package/dist/client/assets/NamePage-Bx8T98OF.js +0 -1
  286. package/dist/client/assets/PermissionHistory-DzU1rf2B.js +0 -1
  287. package/dist/client/assets/PhotoPage-CmrOIRjf.js +0 -1
  288. package/dist/client/assets/SeenDevices-SPWkdzoK.js +0 -19
  289. package/dist/client/assets/SettingsDialog-_dEXUhHe.js +0 -12
  290. package/dist/client/assets/ToolsPage-Idimrn3o.js +0 -2
  291. package/dist/client/assets/_shell-ClVN2pUj.js +0 -80
  292. package/dist/client/assets/_shell.marketplace-CiL6YRbl.js +0 -1
  293. package/dist/client/assets/_shell.marketplace_.sources-C0sI8e21.js +0 -1
  294. package/dist/client/assets/_shell.session-_hhBvFc6.js +0 -63
  295. package/dist/client/assets/_shell.x._extensionId-BWy5v1YE.js +0 -1
  296. package/dist/client/assets/_shell.x._extensionId_._-BWy5v1YE.js +0 -1
  297. package/dist/client/assets/channel-DjBlTcCV.js +0 -1
  298. package/dist/client/assets/index-7jby-RRg.js +0 -1
  299. package/dist/client/assets/index-BqIHtiaE.js +0 -1
  300. package/dist/client/assets/index-Cga0qx1T.js +0 -1033
  301. package/dist/client/assets/index-Ct4At33X.js +0 -1
  302. package/dist/client/assets/index-DITPwUa9.js +0 -38
  303. package/dist/client/assets/index-DUZrTFYD.css +0 -1
  304. package/dist/client/assets/registry-Dc102rws.js +0 -1
  305. package/dist/client/assets/signed-in-DctJ2IWe.js +0 -1
  306. package/dist/client/assets/swimlanesDiagram-AYQRV4AK-Dv1-QS9J.js +0 -8
  307. package/dist/client/assets/use-is-below-desktop-gTvJDvw4.js +0 -1
  308. package/dist/client/assets/use-is-hub-B1vPpkYU.js +0 -1
  309. package/dist/client/assets/use-pending-read-C8L_v4Zw.js +0 -1
  310. package/dist/client/assets/use-session-diagnostics-a4b83F5J.js +0 -16
  311. package/dist/client/assets/use-update-config-Tbn3SodN.js +0 -1
@@ -1,80 +0,0 @@
1
- var Yu=Object.defineProperty;var Vu=(e,t,s)=>t in e?Yu(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s;var wn=(e,t,s)=>Vu(e,typeof t!="symbol"?t+"":t,s);import{r8 as Qu,r as l,fz as Qo,r9 as Xu,fx as Jr,j as n,ra as Ju,rb as Xi,fA as Zu,io as Zr,a1 as ie,a2 as Re,au as ze,er as Le,f0 as _n,rc as qs,ij as Sr,rd as em,re as tm,a3 as he,ap as we,oV as nm,rf as sm,W as qe,e6 as As,ar as re,B as L,X as Ke,G as K,iO as Ji,rg as rm,x as Oe,a0 as Zi,bw as ec,bc as Es,d7 as Ue,aX as om,rh as Xo,ri as am,bG as im,at as tc,c6 as Fe,as as $e,s as Ft,jB as cm,jC as nc,a7 as ue,jR as Un,jS as jt,jT as sc,aW as _,qQ as lm,ek as St,ms as hs,iD as cn,rj as dm,a4 as Ht,ej as rc,fp as eo,cF as to,ax as Wt,rk as Jo,j5 as um,j8 as oc,j4 as mm,rl as no,iN as Kn,J as Gt,hK as so,e5 as sn,l as je,aJ as ac,dv as ic,dw as cc,dR as lc,dx as hm,rm as fm,dz as lt,by as ln,bz as dn,T as qt,bA as un,bC as mn,C as hn,e1 as Ge,e2 as pm,l7 as dc,jk as uc,bk as He,rn as gm,ro as xm,bH as bm,z as ro,dA as ot,f9 as at,gk as oo,fu as Is,ju as ao,f as At,b7 as mc,ei as Rs,rp as io,d$ as ym,_ as Pn,cO as fn,cP as pn,cQ as gn,ak as Be,aq as Ts,mk as hc,rq as vm,rr as wm,cv as jm,dl as fs,bx as tt,jH as en,cy as xt,cz as bt,cB as ht,cC as nt,cD as ft,dy as kt,de as tn,dc as Sm,c8 as fc,iv as pc,h8 as Zo,rs as km,hO as ps,iy as Cm,iA as Nm,h6 as gc,rt as Am,g3 as Ds,g4 as Os,g6 as Ms,ru as xc,g7 as Xe,rv as Hn,g9 as as,h as co,rw as lo,rx as Em,g5 as Im,q0 as Rm,ry as bc,iY as Tm,rz as Dm,rA as Om,rB as Mm,eL as yc,rC as _m,rD as Pm,iC as Lm,rE as Fm,g as kr,ii as ea,rF as $m,az as Bm,gx as vc,ad as Me,eJ as _s,rG as zm,rH as Um,gy as Km,ho as Hm,l5 as Wm,hq as Gm,hr as qm,hs as Ym,nC as wc,fo as Wn,ed as Vm,rI as Qm,gm as jc,rJ as Xm,rK as ge,rL as Jm,rM as Sc,rN as uo,rO as Cr,rP as kc,rQ as mo,rR as ho,b6 as Gn,rS as Ps,rT as Zm,rU as eh,rV as th,rW as nh,rX as sh,rY as rh,rZ as oh,r_ as Tt,ik as ah,il as ih,mV as ch,r$ as ta,bb as lh,hy as Cc,s0 as $t,s1 as rn,s2 as dh,s3 as uh,s4 as mh,s5 as hh,ft as Nc,bW as nn,s6 as Ac,s7 as gs,s8 as Ec,s9 as fh,sa as ph,sb as Ic,sc as Rc,sd as gh,se as xh,ht as Tc,hu as Dc,sf as Bt,sg as bh,sh as yh,e9 as vh,si as Ln,sj as wh,aZ as Oc,sk as jh,sl as Sh,sm as kh,sn as Ch,so as Nh,sp as Mc,sq as Dt,fs as Ct,sr as _c,ss as Ah,fI as Ce,fQ as Eh,fH as de,fL as xn,fG as bn,fO as xe,fJ as Mt,I as gt,op as Pc,oz as Lc,fZ as zt,fY as on,eP as Ls,kO as Ih,fX as Fc,el as $c,lW as Bc,nQ as Rh,fW as Th,st as Dh,su as na,sv as Oh,sw as an,sx as zc,bO as Fs,hP as Uc,sy as Mh,pk as _h,sz as Ph,sA as Kc,sB as Lh,sC as Fh,eQ as $h,aY as fo,f_ as po,sD as Bh,gA as $s,sE as En,sF as go,q as xs,o as Hc,sG as zh,jD as sa,lw as Uh,o6 as Kh,sH as Hh,c0 as Wh,aj as xo,ai as bo,no as Wc,nn as Gc,sI as Gh,am as qc,d5 as Bs,kt as Yc,sJ as qh,sK as Yh,sL as Vh,sM as Qh,sN as Xh,sO as Jh,sP as Zh,hf as yo,p2 as ef,sQ as Vc,mn as tf,ji as Nr,dN as nf,sR as qn,nj as vo,sS as yn,sT as sf,sU as rf,sV as of,sW as af,sX as cf,sY as lf,f$ as df,sZ as uf,hF as wo,nk as Qc,nm as mf,r0 as hf,s_ as ff,s$ as Xc,t0 as pf,lj as gf,t1 as Jc,t2 as ra,t3 as oa,t4 as xf,t5 as bf,t6 as yf,t7 as vf,t8 as wf,t9 as jf,ta as aa,tb as Sf,tc as kf,td as Cf,te as Ys,jg as zs,ka as Zc,tf as Nf,gC as el,k3 as Af,kh as Ef,e as _t,tg as If,th as Rf,ti as Tf,b4 as Df,iZ as Of,tj as tl,tk as Mf,b3 as _f,tl as Pf,tm as Lf,gz as Yn,K as Ff,tn as $f,to as bs,km as nl,tp as Bf,tq as sl,tr as ia,ts as zf,tt as Uf,tu as rl,tv as Jn,jW as Kf,tw as Hf,tx as Wf,ty as Gf,tz as ol,tA as Ar,tB as qf,ce as jn,H as jo,aS as Yf,tC as al,dB as ca,jw as So,bh as Vf,t as Qf,hS as Er,hn as Xf,aN as ko,hx as il,tD as Jf,lr as Zf,l4 as ep,ot as tp,jf as np,tE as sp,jh as la,ki as cl,gc as rp,gd as op,ge as ap,gf as ip,gg as cp,gh as lp,gi as dp,tF as up,tG as Ir,tH as mp,tI as Vs,tJ as hp,tK as fp,tL as Fn,tM as pp,tN as da,l9 as gp,kb as xp,tO as bp,ip as yp,iq as vp,b8 as ys,is as wp,it as ua,lF as ma,lD as jp,lE as ha,tP as Sp,tQ as kp,tR as Cp,tS as Np,es as Ap,tT as Ep,tU as Ip,tV as Rp,bR as Tp,tW as Dp,tX as Op,tY as ll,tZ as dl,O as Co,Q as No,U as Ao,t_ as Mp,t$ as _p,bL as Pp,g2 as Lp,u0 as Qs,gH as Fp,u1 as $p,u2 as Bp,u3 as zp,u4 as Up,u5 as Kp,u6 as Hp,u7 as Wp,u8 as Gp,u9 as qp,ua as fa,ir as Yp,bK as Vp,ub as ul,uc as Qp,fv as Xp,ud as pa,hm as Jp,ue as Zp,uf as eg,ou as tg,ug as ng,uh as sg,e7 as rg,ui as og,uj as ga,uk as ag,ul as ig,oo as cg,oH as lg,jc as dg,a9 as ml,um as ug,j6 as mg,j7 as hg,ku as fg,ey as hl,ez as fl,eA as pl,eB as gl,d8 as pg,e4 as gg,ew as xg,ex as bg,kz as yg,kA as vg,kB as wg,kE as jg,kC as Sg,un as kg,uo as Cg,ky as Ng,kw as Ag,kx as Eg,ih as Ig,up as xl,iG as Rg,uq as Tg,ur as Dg,us as bl,ut as Us,bg as yl,$ as vl,uu as wl,p4 as Og,be as Mg,bf as _g,eo as xa,bd as Pg,gn as Xs,gX as Js,e3 as Lg,uv as Eo,n as Fg,aO as ba,os as $g,bB as jl,uw as Sl,ux as kl,pf as Bg,uy as zg,uz as Ug,uA as Zt,cV as Kg,uB as ya,m2 as Hg,m4 as Cl,dd as Wg,j3 as Gg,o5 as qg,uC as Rr,eZ as Yg,hR as Vg,mf as ut,mh as Qg,qP as Xg,mP as va,qR as Jg,uD as Zg,uE as ex,uF as tx,uG as nx,uH as sx,uI as rx,uJ as ox,uK as ax,uL as ix,lm as cx,jQ as lx,l0 as dx,uM as ux,uN as mx,uO as hx,uP as fx,uQ as px,uR as gx,c9 as xx,uS as bx,uT as yx,nB as vx,cE as wx}from"./index-Cga0qx1T.js";import{f as jx,g as Sx}from"./use-connector-management-CLYFraXN.js";import{D as Nt,a as kx}from"./TourHost-BPaSwh9I.js";import{r as Cx,e as Nx,a as Ax,K as Ex}from"./RuntimeConnectFlow-DjReuQ-T.js";import{O as Ix,B as Nl}from"./banner-DRumuw3F.js";import{u as Ks,P as Al,a as Rx}from"./ProfileRolePicker-D9H7wsuT.js";import{u as Tx}from"./use-dev-links-DQ32IcGe.js";import{B as Dx,u as Ox}from"./use-bindings-Bz9YRgO7.js";import{C as Io,o as El,O as Il,p as ct,q as Mx,u as Rl,r as _x,w as Px,b as Lx,e as Fx,k as $x,s as Tr,T as Bx,a as zx,P as Ux,B as Kx,g as Tl,t as Dl,v as Ol,x as Hx,D as Wx,j as Gx,S as wa,W as qx,y as Yx}from"./SeenDevices-SPWkdzoK.js";import{d as Vx}from"./untrusted-text-pHjcUwfI.js";import{S as Tn}from"./scroll-area-B4WB7Q40.js";import{T as Ml,a as _l,b as is,c as Zs,u as Qx,i as Xx,d as Jx,P as Pl}from"./PreviewRefusedNotice-BXC2K0tx.js";import{P as Zx}from"./paperclip-C6fYq5Zf.js";import{L as eb}from"./lightbulb-DqdWS75d.js";import{u as Vn}from"./use-update-config-Tbn3SodN.js";import{a as tb,u as nb,S as sb,s as rb,b as ob,P as ab}from"./ApplyToOverridesDialog-CoO6V1G4.js";import{r as Ll,s as ja,e as ib}from"./access-copy-B3yNZ7Gz.js";import{t as cb,I as Sa}from"./trust-posture-D-Yjm6ot.js";import{a as lb}from"./use-pulse-freshness-B3390hGg.js";import{c as db,B as ub,w as mb,b as hb,a as fb,e as pb}from"./primer-trigger-BmV5wjek.js";import{M as gb,u as xb,s as bb,P as yb,a as vb}from"./use-promo-activation-Botoso6l.js";import{u as Fl}from"./use-promo-dismissals-RJXp-r_J.js";import{u as $l}from"./use-pending-read-C8L_v4Zw.js";import{a as pt}from"./dorkbot-templates-8Yu9POWJ.js";import{i as wb,O as Bl,c as jb,b as Sb}from"./OperatorIdentityForm-Vr4qZnmM.js";import{A as zl,P as kb,u as Cb,a as Nb}from"./use-jump-back-in-Bibj5tVk.js";import{S as Ul,P as Ab}from"./progress-4FQQfnS6.js";import{P as Eb,M as Ib}from"./plug-DHQcxt7N.js";import{i as Ro,a as Rb,u as Tb}from"./use-notification-prefs-B-4kZR7I.js";import{R as Db}from"./rotate-cw-B3rB_YSw.js";import{b as Ob,u as Mb,O as _b,c as Pb}from"./OpenMeshSwitch-CtbOt3r5.js";import{u as Lb,a as Fb,C as $b,N as Bb}from"./NewDirectMessageMenu-D4e-z2Jt.js";import{P as zb,C as Ub,f as Kb,a as Hb}from"./find-latest-widget-fence-D4kBWC_1.js";import{o as Wb}from"./owner-notice-M4hn_1ep.js";import{a as Kl,C as Gb}from"./cpu-B7xLO7jn.js";import{U as qb}from"./unplug-Bq_1WdV7.js";import{c as Yb,H as Hl,a as Wl,b as Gl}from"./RuntimeSetupDialog-Cr4GRi8c.js";import{P as er}from"./page-container-BnmNikNZ.js";import{u as Hs}from"./use-is-hub-B1vPpkYU.js";import{u as Vb}from"./use-roving-tab-list-g2hO6Ruz.js";import{R as ql}from"./rotate-ccw-clock-RfbbgUa4.js";import{d as et,e as Ne,f as ka,g as Yl,C as Vl,a as Ql,b as Xl,c as Qb}from"./command-CDKbyppr.js";import{A as Xb,M as Jb}from"./McpAppFrame-C7eYYdI9.js";import{L as Zb}from"./layers-Cm7coqdo.js";import{A as ey}from"./AgentOptionRow-BA2cDa7r.js";import{R as ty}from"./radio-ta5Bw763.js";import{a as ny}from"./sound-D3r8dGFH.js";import{d as sy}from"./connection-copy--MA7AN04.js";import{P as ry}from"./path-input-DHn9-XaE.js";import"./WidgetErrorCard-cS8yMCxU.js";import{a as oy}from"./ComputerResourceView-cERD9H2L.js";import{u as Jl}from"./use-is-below-desktop-gTvJDvw4.js";import{a as ay,u as iy}from"./use-panel-tab-placements-CCq-mZlY.js";import{u as cy}from"./ComputerViewer-rMcfbk2_.js";import{a as ly}from"./use-local-browser-xg7WXAVK.js";import{F as dy}from"./file-text-DgdvRfMk.js";import"./use-relay-config-BV0xcLwS.js";import"./use-external-adapter-catalog-D-FO_XW6.js";import"./use-adapter-catalog-Tn3ZbPAj.js";import"./inline-code-BE9ckzPs.js";import"./useMutationState-DdOGdpjP.js";import"./runtime-connect-Dn0T5YWv.js";import"./terminal-6CdY-T1V.js";import"./execution-config-ILQiJAmy.js";import"./settings-for-runtime-BoOa-ZFG.js";import"./shield-x-CANziVLc.js";import"./use-full-activity-feed-BNxcyb1j.js";import"./profile-errors-BSCuj3rT.js";import"./use-mounted-ref-qRbdZfOU.js";import"./ProfileFields-BebX5oiv.js";import"./use-mesh-topology-BgCSFw8s.js";import"./card-B3CtfC3R.js";import"./list-runtime-types-CP82p1u4.js";import"./more-details-ReA2ZFBn.js";import"./index-F-vqXYqa.js";import"./markdown-content-m_qereFc.js";import"./table-BSAvOYPp.js";import"./package-CUuTl39E.js";import"./heart-c7u4Ezxt.js";import"./git-branch-BpxhecMq.js";import"./file-D40js1Zx.js";function uy({children:e,isValidProp:t,...s}){t&&Qu(t);const r=l.useContext(Qo);s={...r,...s},s.transition=Xu(s.transition,r.transition),s.isStatic=Jr(()=>s.isStatic);const o=l.useMemo(()=>s,[JSON.stringify(s.transition),s.transformPagePoint,s.reducedMotion,s.skipAnimations]);return n.jsx(Qo.Provider,{value:o,children:e})}function my(e){e.values.forEach(t=>t.stop())}function Dr(e,t){[...t].reverse().forEach(r=>{const o=e.getVariant(r);o&&Xi(e,o),e.variantChildren&&e.variantChildren.forEach(a=>{Dr(a,t)})})}function hy(e,t){if(Array.isArray(t))return Dr(e,t);if(typeof t=="string")return Dr(e,[t]);Xi(e,t)}function fy(){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(Ju(a,s,{transitionOverride:r}))}),Promise.all(o)},set(s){return e.forEach(r=>{hy(r,s)})},stop(){e.forEach(s=>{my(s)})},mount(){return()=>{t.stop()}}};return t}function py(){const e=Jr(fy);return Zu(e.mount,[]),e}class gy{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 xy=()=>new gy;function by(){return Jr(xy)}const yy=`${Zr.repo}/issues/new`,vy={"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"},wy={"runtimes.default":["claude-code","codex","opencode","doe"],"logging.level":["fatal","error","warn","info","debug","trace"],"ui.theme":["light","dark","system"]},jy=/^[a-z0-9][a-z0-9._-]{0,31}$/,Sy={bug:["bug"],feature:["enhancement"],runtime:["bug"]},ky={bug:"Bug: (describe what went wrong)",feature:"Feature: (describe what you want)",runtime:"Runtime issue: (describe what went wrong)"};function Cy(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 To(e){return Cy(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 Ny(e,t){const s=wy[e];return s?s.includes(t):jy.test(t)&&To(t)===t}function Ay(e){const t={};for(const[s,r]of Object.entries(vy)){const o=e[s];o!=null&&(r==="boolean"&&typeof o=="boolean"||r==="number"&&typeof o=="number"&&Number.isFinite(o)||r==="enum"&&typeof o=="string"&&Ny(s,o))&&(t[s]=o)}return t}const Ey=["details","summary"];function Do(e){return Vx(To(e),Ey)}function Iy(e){const t=e.runtimes.length>0?e.runtimes.join(", "):"none configured",s=Object.entries(e.flags).map(([o,a])=>`- ${o}: ${String(a)}`).join(`
2
- `),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 To(r.join(`
3
- `))}function Ry(e){var s;const t=(s=e.body)==null?void 0:s.trim();return t?[Do(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 Ty(e){return["<details><summary>Environment</summary>","",Iy(e),"","</details>","","DorkOS filled in the details above. Please check them and remove anything you do not want to share.","","---","",...Ry(e)].join(`
4
- `)}function tr(e){var r;const t=(r=e.title)==null?void 0:r.trim(),s=new URLSearchParams({title:Do(t||ky[e.kind]),body:Ty(e),labels:Sy[e.kind].join(",")});return`${yy}?${s.toString()}`}const Dy=6e3,Ca=`
5
-
6
- … (shortened to fit the link; paste the rest yourself)`;function Na(e){return new TextEncoder().encode(e).length}function Aa(e,t){return Array.from(e).slice(0,t).join("")}function Oy(e,t=Dy){var d;const s=tr(e);if(Na(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 u=Math.ceil((a+i)/2),m={...e,body:Aa(r,u)+Ca};Na(tr(m))<=t?a=u:i=u-1}const c={...e,body:Aa(r,a)+Ca};return{url:tr(c),truncated:!0,fullBody:Do(r)}}function My(e){return Oy(e).url}function _y(e){var t,s,r,o,a,i,c,d,u,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":(u=e.auth)==null?void 0:u.enabled,"logging.level":(m=e.logging)==null?void 0:m.level}}function Zl(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?Ay(_y(t)):{}}}function Py(){const e=ie(),{data:t}=Re({queryKey:ze.current(),queryFn:()=>e.getConfig(),staleTime:300*1e3}),s=Le({select:r=>r.location.pathname});return l.useCallback(r=>{const o=My(Zl(r,t,s));_n(o)},[t,s])}const Ly=100;function Fy({cwd:e,isStreaming:t,color:s}){const r=l.useRef(""),o=l.useRef([]),a=l.useRef(null),i=l.useRef(0),c=l.useRef(t);l.useEffect(()=>{c.current=t},[t]);const d=l.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&&(qs(m[i.current]),i.current=(i.current+1)%m.length)},Ly))},[]),u=l.useCallback(()=>{a.current&&(clearInterval(a.current),a.current=null),r.current&&qs(r.current)},[]);l.useEffect(()=>{if(!e)return;const m=s??Sr(e),f=em(m);r.current=f,o.current=[],qs(f);let p=!1;return tm(f).then(h=>{p||(o.current=h,c.current&&d())}).catch(()=>{}),()=>{p=!0}},[e,s,d]),l.useEffect(()=>(t?d():u(),u),[t,d,u])}function $y(e,t){const[s,r]=l.useState(()=>document.hidden),[o,a]=l.useState(!1);l.useEffect(()=>{const d=()=>{r(document.hidden),document.hidden||a(!1)};return document.addEventListener("visibilitychange",d),()=>document.removeEventListener("visibilitychange",d)},[]);const i=l.useRef(t);l.useEffect(()=>{i.current&&!t&&document.hidden&&a(!0),i.current=t},[t]);const c=e({hidden:s,unseenReply:o});l.useEffect(()=>{document.title=c},[c])}function By(){const e=he();we("account_usage",t=>{const s=t;!s||typeof s.runtime!="string"||e.getQueryData(nm.usage(s.runtime))!==void 0&&sm(e,s.runtime,[s])})}function zy(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 Uy(e){const[t,s]=l.useState(0),r=l.useRef([]);function o(){const u=r.current.slice(0,e).filter(Boolean);if(u.length===0)return 1;const m=u[0].offsetTop;return Math.max(1,u.filter(f=>f.offsetTop===m).length)}function a(u){var f;const m=Math.max(0,Math.min(e-1,u));s(m),(f=r.current[m])==null||f.focus()}function i(u){return m=>{r.current[u]=m}}function c(u){return t===u?0:-1}function d(u,m){const f=zy(u.key,m,o(),e);f!==null&&(u.preventDefault(),a(f))}return{focusIndex:t,setRef:i,tabIndexFor:c,handleKeyDown:d,moveFocus:a}}function ed(){const[e,t]=l.useState(Ea);return l.useEffect(()=>{const s=window.visualViewport,r=()=>{const o=Ea();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 Ea(){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}}/**
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 td={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"]};td.node;const Ky=qe(td);/**
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 nd={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"}]]};nd.node;const Hy=qe(nd);/**
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 sd={name:"chevron-up",size:24,node:[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]]};sd.node;const Wy=qe(sd);/**
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 rd={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"]};rd.node;const Gy=qe(rd);/**
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 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 ad=qe(od);/**
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 id={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"}]]};id.node;const qy=qe(id);/**
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 cd={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"}]]};cd.node;const Yy=qe(cd);/**
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 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 vs=qe(ld);/**
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 dd={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"}]]};dd.node;const Vy=qe(dd);/**
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 ud={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"}]]};ud.node;const Qy=qe(ud);/**
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 md={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"}]]};md.node;const Xy=qe(md);/**
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 hd={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"]};hd.node;const Jy=qe(hd);/**
67
- * @license lucide-react v1.48.0 - ISC
68
- *
69
- * This source code is licensed under the ISC license.
70
- * See the LICENSE file in the root directory of this source tree.
71
- */const fd={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"}]]};fd.node;const Zy=qe(fd),Ia=16,ev=280,tv=180;function Ra(e,t,s){const r=Math.max(t,window.innerWidth-Ia),o=Math.max(s,window.innerHeight-Ia),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 nv(e,t){return e.x!==t.x||e.y!==t.y||e.width!==t.width||e.height!==t.height}function sv(e){const{title:t,geometry:s,onGeometryChange:r,onClose:o,onRestore:a,minWidth:i,minHeight:c,children:d,className:u}=e,m=l.useRef(null),f=i??ev,p=c??tv;l.useEffect(()=>{const y=()=>{const k=Ra(s,f,p);nv(k,s)&&r(k)};return y(),window.addEventListener("resize",y),()=>window.removeEventListener("resize",y)},[s,f,p,r]);const h=l.useRef(null);l.useEffect(()=>()=>{var y;return(y=h.current)==null?void 0:y.call(h)},[]);const g=l.useCallback((y,k)=>{var D;y.preventDefault();const S=m.current;if(!S)return;const E=S;(D=h.current)==null||D.call(h);const v=y.clientX,A=y.clientY,R=s;let F=R,I=0;function O(){I=0,E.style.left=`${F.x}px`,E.style.top=`${F.y}px`,E.style.width=`${F.width}px`,E.style.height=`${F.height}px`}function C(T){F=k(T.clientX-v,T.clientY-A,R),I||(I=requestAnimationFrame(O))}function j(){I&&cancelAnimationFrame(I),I=0,document.removeEventListener("pointermove",C),document.removeEventListener("pointerup",w),document.removeEventListener("pointercancel",w),h.current=null}function w(){j(),r(Ra(F,f,p))}document.addEventListener("pointermove",C),document.addEventListener("pointerup",w),document.addEventListener("pointercancel",w),h.current=j},[s,f,p,r]),x=l.useCallback(y=>{y.target.closest("button")||g(y,(k,S,E)=>({...E,x:E.x+k,y:E.y+S}))},[g]),b=l.useCallback(y=>{y.stopPropagation(),g(y,(k,S,E)=>({...E,width:Math.max(f,E.width+k),height:Math.max(p,E.height+S)}))},[g,f,p]);return As.createPortal(n.jsxs(re.div,{ref:m,"data-slot":"floating-panel",role:"complementary","aria-label":t,initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.95},transition:{duration:.15,ease:[0,0,.2,1]},style:{left:s.x,top:s.y,width:s.width,height:s.height},className:K("bg-card border-border shadow-floating fixed z-40 flex flex-col overflow-hidden rounded-lg border",u),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(L,{variant:"ghost",size:"icon-sm","aria-label":"Restore",onClick:a,className:"text-muted-foreground hover:text-foreground",children:n.jsx(zb,{})}):null,n.jsx(L,{variant:"ghost",size:"icon-sm","aria-label":"Close",onClick:o,className:"text-muted-foreground hover:text-foreground",children:n.jsx(Ke,{})})]}),n.jsx("div",{className:"min-h-0 flex-1 overflow-auto",children:d}),n.jsx("div",{"aria-hidden":!0,onPointerDown:b,className:"absolute right-0 bottom-0 size-4 cursor-nwse-resize"})]}),document.body)}function rv({...e}){const{theme:t}=Ji();return n.jsx(rm,{theme:t,className:"toaster group",icons:{success:n.jsx(Es,{className:"size-4"}),info:n.jsx(ec,{className:"size-4"}),warning:n.jsx(Zi,{className:"size-4"}),error:n.jsx(Ix,{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 ov(){var t;if(!Ue())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 pd="root";function gd(){return document.getElementById(pd)??document.body}const Ta=2e4;class st extends Error{constructor(s,r){super(r);wn(this,"reason");this.name="AppCaptureError",this.reason=s}}function av(){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 iv(){return new Promise(e=>{requestAnimationFrame(()=>requestAnimationFrame(()=>e()))})}function cv(){const e=[];for(const t of Array.from(document.body.children)){if(!(t instanceof HTMLElement)||t.id===pd)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 lv(e){const t=await e().catch(s=>{throw new st("failed",`The desktop bridge threw: ${String(s)}`)});if(!t.ok)throw new st("failed",t.message);return{dataUrl:t.dataUrl,region:{left:0,top:0,width:window.innerWidth,height:window.innerHeight}}}async function dv(){let e;try{({snapdom:e}=await om(()=>import("./snapdom-SRLjr6oU.js"),[]))}catch(r){const o=r instanceof Error?r.message:String(r);throw new st("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 st("failed",`Rendering the app to an image failed: ${o}`)}}async function uv(e){let t;const s=new Promise((r,o)=>{t=setTimeout(()=>{o(new st("failed",`The capture did not finish in ${Ta}ms.`))},Ta)});try{return await Promise.race([e,s])}finally{clearTimeout(t),e.catch(()=>{})}}async function mv(){const e=av(),t=cv();try{return await iv(),await uv(e?lv(e):dv())}finally{t()}}let Sn=null;function xd(){if(Sn)return Sn;const e=mv();Sn=e;const t=()=>{Sn===e&&(Sn=null)};return e.then(t,t),e}function hv(){return xd().then(e=>e.dataUrl)}function fv(){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 pv(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone||void 0}catch{return}}function gv(e){const t=fv(),s=typeof navigator<"u"?navigator.userAgent:void 0,r=typeof navigator<"u"?navigator.language:void 0,o=pv();return{theme:e,shell:Ue()?"desktop-app":"browser",...t?{viewport:t}:{},...s?{browser:s.slice(0,am)}:{},...r?{locale:r.slice(0,Xo)}:{},...o?{timezone:o.slice(0,Xo)}:{}}}function Ws(e){return t=>()=>{e(),t()}}const xv=2e3,bv=.8,yv=1400,vv=.6,cs=6e5,ws=1e4,wv=["image/webp","image/jpeg","image/png"],jv=/^data:image\/(webp|png|jpeg);base64,/;class Ut extends Error{constructor(s,r){super(r);wn(this,"reason");this.name="ImageCompressError",this.reason=s}}function Sv(e){return jv.test(e)&&e.length<=cs}function kv(e){return new Promise((t,s)=>{const r=new Image,o=setTimeout(()=>{s(new Ut("unreadable",`Decoding timed out after ${ws}ms.`))},ws);r.onload=()=>{clearTimeout(o),t(r)},r.onerror=()=>{clearTimeout(o),s(new Ut("unreadable",`Could not decode the image at ${e.slice(0,32)}…`))},r.src=e})}function Cv(e,t){for(const s of wv){const r=e.toDataURL(s,t);if(r.startsWith(`data:${s};base64,`))return r}throw new Ut("unsupported","This canvas produced no usable image encoding.")}function Da(e,t,s=xv){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 Oa(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 Ut("unsupported","This browser gave no 2d canvas context.");return o.drawImage(e,0,0,t.width,t.height),Cv(r,s)}async function Or(e){const t=typeof e=="string"?null:URL.createObjectURL(e);let s;try{s=await kv(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 Ut("unreadable","The image decoded to zero pixels.");let a=Oa(s,Da(r,o),bv);if(a.length>cs&&(a=Oa(s,Da(r,o,yv),vv)),a.length>cs)throw new Ut("too-large",`Compressed to ${a.length} characters, over the ${cs} cap.`);return a}const Nv=500;function Av(e=Nv){const t=he(),s=im({coalesceMs:e,shouldFlush:()=>t.isMutating({mutationKey:tc})===0});we("config_changed",()=>{const r={queryKey:ze.current()};s([r])})}const bd="dorkbot",Ev=["mesh","agent-paths"];function Iv(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)||bd;return`${t}/${s}`}function Rv(){var d;const e=Fe(),t=ie(),{data:s}=$e(),{data:r}=Re({queryKey:[...Ev],queryFn:()=>t.listMeshAgentPaths(),staleTime:3e4}),o=((d=s==null?void 0:s.agents)==null?void 0:d.defaultAgent)||bd,a=r==null?void 0:r.agents.find(u=>u.name===o),i=(a==null?void 0:a.projectPath)??Iv(s);return{startSession:l.useCallback(()=>{a?e(Ft({agentId:a.id})):i&&cm(t,i).then(u=>e(u)).catch(u=>{nc(t,u),ue.error("Couldn’t open the chat. Try again.")})},[e,i,a,t]),defaultAgentDir:i}}function Tv(e){var t,s;return{pinned:e.pinned??[],groups:e.groups??[],muted:e.muted??[],sections:e.sections??{},gettingStarted:{retired:((t=e.gettingStarted)==null?void 0:t.retired)??[]},digest:{lastShownDate:(s=e.digest)==null?void 0:s.lastShownDate}}}function Dv(){const e=he(),t=Un();we("community_connections_changed",()=>{t&&e.invalidateQueries({queryKey:jt.connections(t),exact:!0})})}function yd(e){const t=ie(),s=e!==null&&e.status!=="pending",r=Un(s),o=(e==null?void 0:e.ref)??"";return Re({queryKey:r?jt.disconnectImpact(r,o):[...jt.all,"owner","unresolved",o,"disconnect-impact"],queryFn:()=>sc(r,()=>t.getCommunityDisconnectImpact(o)),enabled:s&&r!==null,staleTime:0,refetchOnMount:"always"})}function vd(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 wd(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}: ${vd(t)}.`}function jd(e){return`Any agents you added from here will be removed from ${e}.`}function Sd(e,{remoteRevoked:t,agentsNotRemoved:s}){const r=vd(s);return s.length===0?t?{tone:"success",message:`${e} is disconnected.`}:{tone:"warning",message:Ov(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 Ov(e){return`Disconnected here, but ${e} couldn’t be reached. Finish under Connected installations on ${e}.`}function Mv(){const e=ie(),t=_(o=>o.selectedCwd),s=_(o=>o.setSelectedCwd),{data:r}=Re({queryKey:["defaultCwd"],queryFn:()=>e.getDefaultCwd(),enabled:t===null,staleTime:1/0,refetchOnMount:!1,refetchOnReconnect:!1,networkMode:"always"});l.useEffect(()=>{r!=null&&r.path&&_.getState().selectedCwd===null&&s(r.path)},[r,t,s])}function Ma(e){e.invalidateQueries({queryKey:cn.recentRoot})}const _v=5e3;function Pv(e,t=_v){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 _a(e){e.invalidateQueries({queryKey:cn.dailyCountsRoot})}function Lv(e,t){const s=Object.keys(e);return s.length!==Object.keys(t).length?!0:s.some(r=>!(r in t))}function Fv(e,t){e.setQueryData(cn.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 $v(e,t,s){e.setQueryData(cn.list(s),r=>r&&r.filter(o=>o.id!==t))}function Pa(e,t,s){const r=new Set(Object.keys(t).filter(o=>!(o in s)));r.size!==0&&e.setQueriesData({queryKey:cn.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 La(e,t,s){const r=Date.now(),o=[];for(const[a,i]of Object.entries(t))s[a]!==i&&(Fv(e,i),o.push(i));dm(e,o,r);for(const[a,i]of Object.entries(s))t[a]||$v(e,a,i.cwd??null)}function Bv(){const e=he();l.useEffect(()=>{lm();let t={},s={};const r=Pv(()=>Ma(e)),o=St.subscribe(c=>{c.sessions!==t&&(La(e,c.sessions,t),r.request(),Lv(c.sessions,t)&&_a(e),t=c.sessions),c.rekeys!==s&&(Pa(e,c.rekeys,s),s=c.rekeys)}),a=hs.subscribeEvent("session_list_invalidated",()=>{St.getState().dropSessions(),e.invalidateQueries({queryKey:cn.listRoot}),Ma(e),_a(e)}),i=St.getState();return Object.keys(i.sessions).length>0&&(La(e,i.sessions,t),t=i.sessions),Object.keys(i.rekeys).length>0&&(Pa(e,i.rekeys,s),s=i.rekeys),hs.connectList(),()=>{o(),a(),r.dispose()}},[e])}function Yt(){const e=ie(),t=he(),{data:s,isLoading:r}=Re({queryKey:ze.current(),queryFn:()=>e.getConfig(),staleTime:rc}),o=$l(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,f=!o&&c&&!d,p=Ht({mutationFn:b=>e.updateConfig({onboarding:b}),onSuccess:()=>{t.invalidateQueries({queryKey:ze.all})},onError:(b,y)=>{console.error("[onboarding] could not save progress",{fields:Object.keys(y),error:b}),ue.error("Couldn’t save your setup progress",{description:"Keep going. DorkOS tries again."})},meta:{suppressErrorToast:!0}});function h(){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:f,dismiss:h,completeOnboarding:g,startOnboarding:x}}function zv(e){const{shouldShowOnboarding:t,onboardingHiddenForSession:s}=e,r=t&&!s,[o,a]=l.useState(!1);return r&&!o&&a(!0),o&&!s}function Uv(){const e=eo(),t=Wt(),s=to({strict:!1}).onboarding,r=Jo(s)?s:"welcome",o=l.useRef(!1),a=Le({select:u=>u.status==="idle"}),i=l.useRef(!1);l.useEffect(()=>{if(i.current||!a||(i.current=!0,Jo(s)))return;const u=m=>({...m,onboarding:"welcome"});e==null||e({search:u,replace:!0})},[a,s,e]);const c=l.useCallback(u=>{const m=f=>({...f,onboarding:u});o.current=!0,e==null||e({search:m})},[e]),d=l.useCallback(u=>{if(o.current){t.history.back();return}const m=f=>({...f,onboarding:u});e==null||e({search:m})},[t,e]);return{stage:r,goToStage:c,goBack:d}}function Kv(e){const{done:t,overlayVisible:s}=e,r=eo(),o=to({strict:!1}).onboarding;l.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 kd(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 Hv=2500,Wv="Couldn’t finish setup. Try again.";function $n(e){return e instanceof Error&&e.message&&!/^HTTP \d+$/.test(e.message)?e.message:Wv}function Oo(){const e=ie(),t=he();return Ht({mutationFn:s=>e.chooseFirstRunPath(s),onSettled:()=>{for(const s of[ze.all,um,oc.status()])t.invalidateQueries({queryKey:s});t.invalidateQueries({queryKey:mm})},meta:{suppressErrorToast:!0}})}function Gv(e){const t=ie(),{data:s}=Re({queryKey:oc.status(),queryFn:()=>t.getCloudCredits(),enabled:e,refetchInterval:e?Hv:!1,refetchIntervalInBackground:e,staleTime:0});if(s)return s.readiness??(s.linked?"linked":"unlinked")}function qv(){const e=ie(),t=he();return Ht({mutationFn:()=>e.postOnboardingWelcome(),onSettled:()=>void t.invalidateQueries({queryKey:ze.all}),meta:{suppressErrorToast:!0}})}function Yv({link:e,waitingWindowRef:t,onReady:s}){const r=Oo(),[o,a]=l.useState(null),[i,c]=l.useState(!1),d=Gv(i),u=i?d:void 0,m=l.useRef(e),f=l.useRef(r.mutateAsync),p=l.useRef(s);l.useEffect(()=>{m.current=e,f.current=r.mutateAsync,p.current=s});const h=l.useCallback(()=>{var S;(S=t.current)==null||S.close(),t.current=null},[t]),g=l.useCallback(async()=>{a(null);try{await f.current({path:"dorkos"})}catch(v){h(),a($n(v));return}c(!0);const S=m.current;if(S.state==="linked"){h();return}if(S.state==="pending")return;await S.start()===null&&(h(),a(m.current.startError??"Couldn’t reach DorkOS. Try again."))},[h]),x=l.useRef(!1);l.useEffect(()=>{x.current||e.state==="loading"||(x.current=!0,g())},[e.state,g]);const b=e.state==="pending"?e.pending:null;l.useEffect(()=>{if(!b||!t.current)return;const S=kd(b);S?t.current.go(S):t.current.close(),t.current=null},[b,t]);const y=l.useRef(!1);l.useEffect(()=>{u!=="ready"||y.current||(y.current=!0,p.current())},[u]);const k=l.useCallback(()=>{var S;if((S=t.current)==null||S.close(),t.current=no(),m.current.state==="expired"||m.current.state==="denied"){a(null),m.current.start();return}g()},[g,t]);return{phase:Vv(o,i,e,b,u),retry:k}}function Vv(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 Mo(){const e=l.useRef(null);return l.useEffect(()=>{var t;(t=e.current)==null||t.focus({preventScroll:!0})},[]),e}function Cd({phase:e,link:t,onRetry:s,onCancel:r,onUseOwnAi:o}){const a=Mo();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(Nt,{size:72,className:"mb-6 opacity-90 dark:hidden"}),n.jsx(Nt,{variant:"white",size:72,className:"mb-6 hidden opacity-90 dark:block"}),n.jsx(Qv,{phase:e,link:t,onRetry:s,onUseOwnAi:o}),n.jsx(L,{variant:"ghost",size:"sm",className:"text-muted-foreground mt-8",onClick:r,children:"Cancel"})]})}function Qv({phase:e,link:t,onRetry:s,onUseOwnAi:r}){switch(e.kind){case"starting":return n.jsx(Fa,{heading:"Finish in your browser.",line:"Opening the DorkOS page…"});case"waiting":return n.jsxs(n.Fragment,{children:[n.jsx(Jt,{children:"Finish in your browser."}),n.jsx(Zn,{children:"Sign in, then come back. This screen moves on by itself."}),n.jsx(Xv,{pending:e.pending})]});case"finishing":return n.jsx(Fa,{heading:"Signed in.",line:"Getting your account ready…"});case"needs-card":return n.jsxs(n.Fragment,{children:[n.jsx(Jt,{children:"Add a card to finish."}),n.jsx(Zn,{children:"Your agents start once a card is saved."}),n.jsxs(L,{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(Mr,{children:t.billingNotice})]});case"refused":return n.jsxs(n.Fragment,{children:[n.jsx(Jt,{children:"Paid plans are US only."}),n.jsx(Zn,{children:"Use your own AI instead."}),n.jsx(L,{className:"mt-6",onClick:r,children:"Use my own AI"})]});case"expired":return n.jsxs(n.Fragment,{children:[n.jsx(Jt,{children:"Your code expired."}),n.jsx(Zn,{children:"Get a new one to finish signing in."}),n.jsx(L,{className:"mt-6",onClick:s,children:"Get a new code"})]});case"failed":return n.jsxs(n.Fragment,{children:[n.jsx(Jt,{children:"Couldn’t start signing in."}),n.jsx(Mr,{children:e.message}),n.jsx(L,{className:"mt-6",onClick:s,children:"Try again"})]})}}function Fa({heading:e,line:t}){return n.jsxs(n.Fragment,{children:[n.jsx(Jt,{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 Jt({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 Mr({children:e}){return n.jsx("p",{className:"text-destructive mt-3 text-sm text-balance",role:"alert",children:e})}function Xv({pending:e}){const{copied:t,failed:s,copy:r}=Kn(),[o,a]=l.useState(!1),i=kd(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(L,{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(Gt,{className:"text-status-success size-4"}):s?n.jsx(Ke,{className:"text-destructive size-4"}):n.jsx(so,{className:"size-4"})})]}),n.jsxs(L,{variant:"outline",className:"w-full",disabled:i===null,onClick:()=>a(i===null||!_n(i)),children:[n.jsx(sn,{className:"size-4"}),"Open the page again"]}),n.jsx("p",{className:"text-muted-foreground text-xs break-all",children:e.verificationUri}),o&&n.jsx(Mr,{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 Jv({onComplete:e}){const t=qv(),{completeOnboarding:s}=Yt(),r=Fe(),[o,a]=l.useState(null),i=l.useCallback(()=>{s(),r({...je.home(),search:{}}),e()},[s,r,e]),c=l.useCallback(async()=>{a(null);try{await t.mutateAsync()}catch(u){a($n(u));return}i()},[t,i]),d=l.useRef(!1);return l.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(L,{onClick:()=>void c(),children:"Try again"}),n.jsx(L,{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 Zv="claude-code";function Nd(e,t){return e.length===0?null:e.includes(t)?t:ac.find(r=>e.includes(r))??e[0]}function ew({readyTypes:e,settled:t,settleToken:s}){var b,y;const{data:r}=$e(),o=Vn(),a=he(),[i,c]=l.useState(null),[d,u]=l.useState(null),m=l.useRef(null),f=((b=r==null?void 0:r.executionDefaults)==null?void 0:b.runtime)??Zv,p=!!((y=r==null?void 0:r.onboarding)!=null&&y.runtimeDefaultSetAt),h=l.useCallback((k,S)=>{c(null),u(S),o.mutate(k,{onSuccess:()=>void a.invalidateQueries({queryKey:ze.all}),onError:E=>{u(null),c(E.message||"Couldn’t save that. Try again.")}})},[o,a]);l.useEffect(()=>{if(!t||e.length===0||!r||p)return;const k=Nd(e,f);k&&m.current!==s&&(m.current=s,h({onboarding:{runtimeDefaultSetAt:new Date().toISOString()},...k===f?{}:{runtimes:{default:k}}},k))},[t,s,e,r,p,f,h]);const g=l.useCallback(k=>{k!==(d??f)&&h({runtimes:{default:k},...p?{}:{onboarding:{runtimeDefaultSetAt:new Date().toISOString()}}},k)},[h,d,f,p]);return{runtime:d??((p||d!==null)&&r?f:null),current:d??f,choose:g,error:i}}function tw({onContinue:e,renderConnect:t,simulated:s}){const r=ic(),{data:o}=cc(),{data:a}=lc(),i=(s==null?void 0:s.requirements)??r.data,c=s!==void 0||r.isSuccess,d=o?Object.keys(o.capabilities):void 0,u=l.useMemo(()=>ac.filter(b=>(i==null?void 0:i.runtimes[b])!==void 0),[i]),m=l.useMemo(()=>i?u.filter(b=>hm(i,b,!0).state==="ready"||s===void 0&&fm(a,b)):[],[u,i,a,s]),f=ew({readyTypes:m,settled:c&&s===void 0,settleToken:r.dataUpdatedAt}),[p,h]=l.useState(null),g=s!=null&&s.defaultRuntime?{runtime:p??s.defaultRuntime,current:p??s.defaultRuntime,choose:h,error:null}:f;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(L,{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:sw(m,g.runtime)}),n.jsx(nw,{chosen:g.current,readyTypes:m,otherTypes:u.filter(b=>!m.includes(b)),onChoose:g.choose}),g.error&&n.jsx("p",{className:"text-destructive text-xs","data-testid":"default-runtime-error",children:g.error})]}),n.jsx(Yb,{types:u,requirements:i,registeredTypes:d,renderConnect:t,onRecheck:s?void 0:()=>void r.refetch(),isRechecking:r.isFetching}),x&&n.jsx(L,{className:"w-full",onClick:e,"data-testid":"onboarding-ai-app-continue",children:"Continue"})]})}function nw({chosen:e,readyTypes:t,otherTypes:s,onChoose:r}){const[o,a]=l.useState(!1),i=[...t,...s];return i.includes(e)||i.unshift(e),n.jsxs(ln,{open:o,onOpenChange:a,children:[n.jsxs(dn,{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(qt,{className:"size-3"})]}),n.jsxs(un,{align:"start",className:"p-1",children:[n.jsx(mn,{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:lt(c).label}),!t.includes(c)&&n.jsx("span",{className:"text-muted-foreground text-xs",children:"Not signed in yet"})]}),d&&n.jsx(Gt,{className:"size-3.5 shrink-0","aria-hidden":!0})]},c)})})]})]})}function sw(e,t){const s=e.map(c=>lt(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=lt(t).label;if(e.includes(t))return`${r} New chats start with ${o}.`;const a=Nd(e,t),i=a?lt(a).label:null;return i?`${r} New chats use ${i} until ${o} is signed in.`:`${r} New chats start with ${o} once it’s signed in.`}const rw=[{id:"openai",title:"An OpenAI API key",line:"Paste a key. DorkOS picks the model."},{id:"anthropic",title:"An Anthropic API key",line:"Paste a key. DorkOS picks the model."},{id:"openrouter",title:"An OpenRouter key",line:"Paste a key. DorkOS picks the model."},{id:"local",title:"A model on this computer",line:"Uses Ollama on this computer. No key."},{id:"agent-app",title:"An AI app you sign in to",line:"Claude Code, Codex or OpenCode, on your own sign-in."},{id:"custom",title:"Other service",line:"Set the address, format, model and key."}],ow={openai:"OpenAI API key",anthropic:"Anthropic API key",openrouter:"OpenRouter key"};function aw({onSaved:e,beforePick:t,slots:s,initialRow:r,simulatedApps:o}){const[a,i]=l.useState(r??null),c=Oo(),[d,u]=l.useState(null),m=async(p,h=!1)=>{u(null);try{return await(t==null?void 0:t()),(await c.mutateAsync({path:"own",choice:p})).modelListed===!1&&ue("Using a default model. Change it in Settings."),!0}catch(g){if(h)throw new Error($n(g),{cause:g});return u($n(g)),!1}},f=p=>{u(null);const h=a===p?null:p;i(h),h==="agent-app"&&!o&&m({kind:"agent-app"})};return n.jsx("div",{className:"divide-border border-border w-full divide-y rounded-lg border text-left",children:rw.map(p=>n.jsxs("section",{"data-testid":`own-ai-row-${p.id}`,children:[n.jsxs("button",{type:"button","aria-expanded":a===p.id,onClick:()=>f(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(hn,{"aria-hidden":!0,className:K("text-muted-foreground size-4 shrink-0 transition-transform",a===p.id&&"rotate-90")})]}),a===p.id&&n.jsxs("div",{className:"px-4 pt-1 pb-4",children:[n.jsx(iw,{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 iw({row:e,busy:t,save:s,onSaved:r,slots:o,simulatedApps:a}){switch(e){case"local":return n.jsxs(L,{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(tw,{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(cw,{service:e,busy:t,save:s,onSaved:r})}}function cw({service:e,busy:t,save:s,onSaved:r}){const o=l.useId(),[a,i]=l.useState(""),[c,d]=l.useState(null),u=async m=>{m.preventDefault();const f=a.trim();if(d(null),!f){d("Enter a key.");return}if(e==="anthropic"&&f.startsWith("sk-ant-oat")){d("Subscription tokens can’t run agents. Use an API key.");return}await s({kind:e,apiKey:f})&&(i(""),r())};return n.jsxs("form",{onSubmit:m=>void u(m),className:"space-y-3",children:[n.jsxs("div",{className:"space-y-1.5",children:[n.jsx(Ge,{htmlFor:`${o}-key`,children:ow[e]}),n.jsx(pm,{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(L,{type:"submit",disabled:t,children:[t&&n.jsx(Oe,{size:"xs"}),"Save"]})]})}function lw({onBack:e,...t}){const s=Mo();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(aw,{...t}),n.jsx(L,{variant:"ghost",size:"sm",className:"text-muted-foreground mt-6 self-start",onClick:e,children:"Back"})]})}function dw({agentName:e,className:t}){var c;const s=Ll(),r=e.trim()||"This agent";if(s.isPending)return n.jsx("p",{className:K("text-muted-foreground text-center text-xs",t),"data-testid":"every-agent-access-checking",children:"Checking apps every agent can use…"});if(s.isError)return n.jsxs("p",{className:K("text-muted-foreground text-xs",t),"data-testid":"every-agent-access-unknown",children:["Couldn’t check apps shared with every agent. ",r," gets them too."]});const o=((c=s.data)==null?void 0:c.connections)??[];if(o.length===0)return null;const a=new Map;for(const d of o)a.set(d.toolkit,(a.get(d.toolkit)??0)+1);const i=o.map(d=>{const u=(a.get(d.toolkit)??0)>1?`${ja(d.toolkit)} · ${d.label}`:ja(d.toolkit),m=sy(d.access.classifications);return`${u} (${d.lifecycle==="paused"?`${m}, paused`:m})`});return n.jsxs("div",{className:K("bg-muted/40 flex items-start gap-3 rounded-xl px-4 py-3 text-sm",t),"data-testid":"every-agent-access-notice",children:[n.jsx(dc,{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 uw({onContinueWithDorkos:e,onUseOwnAi:t,onContinueWithout:s,busy:r=null,error:o=null}){const a=uc(),i=Mo();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(Nt,{size:120,className:"mb-8 opacity-90 dark:hidden"}),n.jsx(Nt,{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(L,{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(Io,{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(L,{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(L,{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 mw({onComplete:e,slots:t}){const s=t==null?void 0:t.renderAccountLink,r=o=>n.jsx(hw,{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 hw({link:e,slots:t,onComplete:s}){var E;const{stage:r,goToStage:o,goBack:a}=Uv(),{startOnboarding:i}=Yt(),c=Oo(),[d,u]=l.useState(null),m=l.useRef(null),f=l.useRef(!1);l.useEffect(()=>{f.current||(f.current=!0,i())},[i]),l.useEffect(()=>{var v;r!=="connecting"&&((v=m.current)==null||v.close(),m.current=null)},[r]);const p=l.useRef(e);l.useEffect(()=>{p.current=e});const h=l.useCallback(async()=>{var v;((v=p.current)==null?void 0:v.state)==="pending"&&await p.current.cancel()},[]),g=l.useCallback(()=>{m.current!==null||r==="connecting"||(u(null),m.current=e&&e.state!=="linked"?no():null,o("connecting"))},[o,e,r]),x=l.useCallback(async()=>{u(null);try{await h(),await c.mutateAsync({path:"none"}),o("landing")}catch(v){u($n(v))}},[c,o,h]),b=l.useCallback(()=>o("landing"),[o]),y=l.useCallback(()=>o("own-ai"),[o]),k=l.useCallback(()=>a("welcome"),[a]);let S;return r==="connecting"?S=e?n.jsx(fw,{link:e,waitingWindowRef:m,onReady:b,onCancel:()=>{h(),k()},onUseOwnAi:()=>{h(),y()}}):n.jsx(Cd,{phase:{kind:"failed",message:"Signing in isn’t available here."},link:null,onRetry:k,onCancel:k,onUseOwnAi:y}):r==="own-ai"?S=n.jsx(lw,{onBack:k,onSaved:b,beforePick:h,slots:t}):r==="landing"?S=n.jsx(Jv,{onComplete:s}):S=n.jsx(uw,{onContinueWithDorkos:g,onUseOwnAi:y,onContinueWithout:()=>void x(),busy:c.isPending&&((E=c.variables)==null?void 0:E.path)==="none"?"none":null,error:d}),S}function fw({link:e,waitingWindowRef:t,onReady:s,onCancel:r,onUseOwnAi:o}){const{phase:a,retry:i}=Yv({link:e,waitingWindowRef:t,onReady:s});return n.jsx(Cd,{phase:a,link:e,onRetry:i,onCancel:r,onUseOwnAi:o})}function pw(){var u;const e=ie(),t=he(),{data:s}=Re({queryKey:ze.current(),queryFn:()=>e.getConfig(),staleTime:300*1e3}),r=((u=s==null?void 0:s.mesh)==null?void 0:u.scanRoots)??[],o=(s==null?void 0:s.boundary)??"",a=r.length>0?r:o?[o]:[],{mutate:i,isPending:c}=Ht({mutationKey:tc,mutationFn:async m=>{await e.updateConfig({mesh:{scanRoots:m}})},onSuccess:()=>{t.invalidateQueries({queryKey:ze.all})}}),d=l.useCallback(m=>i(m),[i]);return{roots:a,boundary:o,isSaving:c,setScanRoots:d}}const gw=50,kn=["room_created","room_updated","room_member_added","room_member_removed","room_activity"];function $a(e){if(typeof e!="object"||e===null)return!1;const{roomId:t}=e;return typeof t=="string"&&t.length>0}function xw(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 bw(e,t){const s=e.getQueryData(He.detail(t.threadId));return s===void 0||s.viewerAuthorId===t.userId}function yw(e,t){const s=e.isFetching({queryKey:He.lists()})>0;e.cancelQueries({queryKey:He.lists()}),e.setQueriesData({queryKey:He.lists()},o=>Array.isArray(o)?o.map(a=>a.id===t.threadId&&a.unreadCount!==null?{...a,unreadCount:Math.min(a.unreadCount,t.unreadCount)}:a):o),e.setQueryData(He.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(He.threads());r!=null&&r.some(o=>o.roomId===t.threadId&&o.unreadCount>0)&&e.invalidateQueries({queryKey:He.threads()}),s&&e.invalidateQueries({queryKey:He.lists()})}function vw(){const e=he(),t=()=>{e.invalidateQueries({queryKey:He.lists()}),e.invalidateQueries({queryKey:He.wellKnowns()}),e.invalidateQueries({queryKey:He.threads()})};we(kn[0],t),we(kn[1],t),we(kn[2],t),we(kn[3],t),we(kn[4],t),we("room_updated",o=>{$a(o)&&e.invalidateQueries({queryKey:He.detail(o.roomId)})});const s=l.useRef(new Set),r=o=>{if(!$a(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:He.detail(i)})},gw)};we("room_member_added",r),we("room_member_removed",r),we("room_presence",o=>gm.getState().observe(o)),we("read_cursor",o=>{!xw(o)||!bw(e,o)||yw(e,o)})}function ww(){const e=he();we("tasks_changed",()=>{e.invalidateQueries({queryKey:[...xm],exact:!0})});const t=()=>{e.invalidateQueries({queryKey:[...bm]})};we("task_run_failed",t),we("task_run_updated",t)}function jw(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)||(t.add(o.scheduleId),(o.status==="failed"||o.status==="blocked")&&r.push(o.scheduleId))}return{running:s,failed:r}}const Sw=4e3;function Ad(){var o;const e=ro(),{identityPromptDismissedAt:t,isLoading:s}=Ks();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 kw(e={}){const{state:t,isLoading:s,shouldShowGettingStarted:r}=Yt(),o=e.gettingStartedCardShown??r,a=Ad(),{dismissIdentityPrompt:i}=Ks(),[c,d]=l.useState("ask");l.useEffect(()=>{if(c!=="saved")return;const p=setTimeout(()=>d("done"),Sw);return()=>clearTimeout(p)},[c]);const u=t.completedAt!==null||t.dismissedAt!==null,m=!s&&u&&a==="ask"&&!o,f=()=>{i().catch(()=>{})};return{visible:c!=="done"&&(m||c==="saved"),phase:c,markSaved:()=>{d("saved"),f()},skip:()=>{d("done"),f()}}}function Ed(){const{firstRunPath:e}=Yt().state,{offered:t,pending:s}=El(),r=e==="dorkos"||e==="own";return{due:r&&t,pending:r&&s}}const Cw=4e3,nr="Tell DorkBot your name",Ba="Tell DorkBot about your work";function Nw({onDismiss:e}){const t=ot(),s=Fe(),{open:r}=at(),o=oo(),a=_(I=>I.requestTour),{startSession:i}=Rv(),{roles:c,rolePromptDismissedAt:d,isLoading:u,saveRoles:m,dismissIdentityPrompt:f}=Ks(),p=Ad(),h=Ed().due,[g,x]=l.useState("closed"),[b,y]=l.useState("closed"),[k,S]=l.useState([]),E=!u&&c.length===0&&d===null;l.useEffect(()=>{if(g!=="saved")return;const I=setTimeout(()=>x("closed"),Cw);return()=>clearTimeout(I)},[g]);const v=()=>{x("saved"),f().catch(()=>{})},A=()=>{y("saving"),m(k).then(()=>y("closed")).catch(()=>y("error"))};let R="Save";b==="saving"?R="Saving…":b==="error"&&(R="Try again");const F=[{icon:Is,label:"Talk to DorkBot",onClick:i},...p==="ask"||g==="saved"?[{icon:zl,label:nr,onClick:()=>x(I=>I==="saved"?I:I==="closed"?"open":"closed"),expanded:g!=="closed"}]:[],...E?[{icon:ao,label:Ba,onClick:()=>y(I=>I==="closed"?"open":"closed"),expanded:b!=="closed"}]:[],{icon:qy,label:"Show me around",onClick:()=>a("general")},{icon:At,label:"Create an agent",onClick:()=>Rs.getState().open("new")},{icon:mc,label:"Schedule a task",onClick:()=>s({...je.tasks()})},{icon:Ul,label:"Connect more runtimes",onClick:()=>r("runtimes")},{icon:Eb,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(Ke,{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:F.map(({icon:I,label:O,onClick:C,expanded:j})=>n.jsxs("li",{children:[n.jsxs("button",{onClick:C,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(I,{className:"text-muted-foreground size-3.5 shrink-0"}),n.jsx("span",{className:"text-foreground flex-1 text-xs",children:O}),n.jsx(hn,{className:"text-muted-foreground/40 group-hover:text-muted-foreground size-3.5 shrink-0 transition-colors"})]}),O===nr&&g==="open"&&n.jsx("div",{className:"px-1.5 py-2","data-testid":"progress-card-identity-form",children:n.jsx(Bl,{onSaved:v})}),O===nr&&g==="saved"&&n.jsx("p",{role:"status",className:"text-muted-foreground px-1.5 py-2 text-xs",children:pt.identityCardSaved}),O===Ba&&b!=="closed"&&n.jsx("div",{className:"px-1.5 py-2","data-testid":"progress-card-profile-picker",children:n.jsx(Al,{selected:k,onChange:S,onConfirm:A,confirmLabel:R,busy:b==="saving",error:b==="error"?pt.saveError:null})})]},O))}),h&&n.jsx(Il,{compact:!0,className:"border-border mt-2 border-t px-1.5 pt-2"})]})}const za=72;function Id({title:e,description:t,titleIsStatus:s}){return n.jsxs("div",{className:"flex flex-col gap-2",children:[n.jsxs("div",{children:[n.jsx(Nt,{size:za,className:"block dark:hidden"}),n.jsx(Nt,{variant:"white",size:za,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 Aw({prompt:e}){const t=ot(),{open:s}=at(),{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(Id,{title:r==="saved"?pt.profileSaved:pt.profileCardPrompt[0],description:n.jsxs(n.Fragment,{children:[pt.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(Al,{selected:o,onChange:a,onConfirm:e.save,confirmLabel:i,onSkip:e.skip,skipLabel:"Don’t ask again",busy:r==="saving",error:c})]})}const Ew=4e3;function Iw(e={}){const{state:t,isLoading:s,shouldShowGettingStarted:r}=Yt(),o=e.gettingStartedCardShown??r,{roles:a,rolePromptDismissedAt:i,isLoading:c,saveRoles:d,dismissRolePrompt:u}=Ks(),[m,f]=l.useState([]),[p,h]=l.useState("ask");l.useEffect(()=>{if(p!=="saved")return;const k=setTimeout(()=>h("done"),Ew);return()=>clearTimeout(k)},[p]);const g=t.completedAt!==null||t.dismissedAt!==null,x=!t.completedSteps.includes("profile")&&!t.skippedSteps.includes("profile"),b=!s&&!c&&g&&a.length===0&&x&&i===null&&!o;let y="Save";return p==="saving"?y="Saving…":p==="error"&&(y="Try again"),{visible:p!=="done"&&(b||p==="saved"),phase:p,selected:m,setSelected:f,confirmLabel:y,errorMessage:p==="error"?pt.saveError:null,save:()=>{h("saving"),d(m).then(()=>h("saved")).catch(()=>h("error"))},skip:()=>{h("done"),u().catch(()=>{})}}}function Rw({prompt:e}){const t=ot(),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(Id,{title:s?pt.identityCardSaved:pt.identityCardPrompt[0],description:s?void 0:pt.identityCardPrompt[1],titleIsStatus:s}),!s&&n.jsx(Bl,{onSaved:e.markSaved,onSkip:e.skip,skipLabel:"Don’t ask again"})]})}function Tw(){const e=ie(),t=l.useRef(null),{startScan:s,addCandidate:r,addExistingAgent:o,setProgress:a,completeScan:i,setError:c}=io(),d=l.useCallback((m={roots:[]})=>{var p;(p=t.current)==null||p.abort();const f=new AbortController;t.current=f,s(),e.scan(m,h=>{switch(h.type){case"candidate":r(h.data);break;case"existing-agent":o(h.data);break;case"progress":a(h.data);break;case"complete":i(h.data);break;case"error":c(h.data.error);break}},f.signal).catch(h=>{h instanceof Error&&h.name!=="AbortError"&&c(h.message)})},[e,s,r,o,a,i,c]),u=l.useCallback(()=>{var m;(m=t.current)==null||m.abort(),t.current=null},[]);return{startScan:d,stopScan:u}}function Dw(){const[e,t]=l.useState(new Set),s=l.useCallback(o=>{t(a=>new Set(a).add(o))},[]),r=l.useCallback(()=>{t(new Set)},[]);return{actedPaths:e,markActed:s,resetActed:r}}function Ow({register:e,onSuccess:t}){const s=l.useRef(new Set),[r,o]=l.useState(new Set),[a,i]=l.useState(new Set),c=l.useCallback(async u=>{if(!s.current.has(u.path)){s.current.add(u.path),o(m=>new Set(m).add(u.path)),i(m=>{const f=new Set(m);return f.delete(u.path),f});try{await e(u),t(u)}catch{i(m=>new Set(m).add(u.path))}finally{s.current.delete(u.path),o(m=>{const f=new Set(m);return f.delete(u.path),f})}}},[t,e]),d=l.useCallback(()=>i(new Set),[]);return{failedPaths:a,pendingPaths:r,registerCandidate:c,resetFailures:d}}function Mw(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 _w(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 Pw={"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 Lw(e){return Pw[e]??`Found by the “${e}” check.`}const Fw={"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 $w(e){return Fw[e]??"Found in the project’s files."}function Bw({candidate:e,onApprove:t,onDeny:s,onSkip:r,registrationFailed:o=!1,registrationPending:a=!1,className:i,ref:c}){const{path:d,strategy:u,hints:m}=e;return n.jsxs(re.div,{ref:c,"data-slot":"candidate-card","aria-busy":a,layout:!0,initial:{opacity:0,y:6},animate:{opacity:1,y:0},exit:{opacity:0,y:-6},transition:{duration:.15,ease:"easeOut"},className:K("flex items-start justify-between rounded-xl border p-4",i),children:[n.jsxs("div",{className:"min-w-0 flex-1 space-y-2",children:[n.jsx("p",{className:"truncate text-sm leading-tight font-semibold",title:m.suggestedName||d.split("/").pop()||d,children:m.suggestedName||d.split("/").pop()||d}),n.jsxs("div",{className:"text-muted-foreground flex items-center gap-1.5 text-xs",children:[n.jsx(ym,{className:"size-3 shrink-0"}),n.jsx("span",{className:"truncate font-mono",title:d,children:d})]}),n.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[n.jsxs(Hl,{openDelay:300,children:[n.jsx(Wl,{asChild:!0,children:n.jsx(Pn,{variant:"secondary",className:"hover:bg-secondary/80 cursor-default",children:m.detectedRuntime})}),n.jsxs(Gl,{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:Lw(u)})]})]}),m.inferredCapabilities&&m.inferredCapabilities.length>0&&m.inferredCapabilities.map(f=>n.jsxs(fn,{children:[n.jsx(pn,{asChild:!0,children:n.jsx(Pn,{size:"xs",variant:"outline",className:"cursor-default",children:f})}),n.jsx(gn,{side:"top",className:"max-w-48 text-center",children:$w(f)})]},f))]}),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 zw({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(Es,{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:Be(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 Uw=2;function Kw({agents:e}){const[t,s]=l.useState(e.length<=Uw);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(hn,{className:K("size-3 transition-transform",t&&"rotate-90")}),e.length," project",e.length===1?"":"s"," already in DorkOS"]}),t&&n.jsx("div",{className:"mt-2 space-y-2",children:e.map(r=>n.jsx(zw,{agent:r},r.path))})]})}function Hw({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(L,{variant:"outline",size:"sm",onClick:t,disabled:s,children:"Add all"})]})}function Ww({roots:e,onChange:t}){const[s,r]=l.useState(""),[o,a]=l.useState(!1),i=l.useCallback(m=>{const f=m.trim();f&&!e.includes(f)&&t([...e,f])},[e,t]),c=l.useCallback(m=>{t(e.filter(f=>f!==m))},[e,t]),d=l.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]),u=l.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(Pn,{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(Ke,{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(Ts,{className:"size-4"})})]}),n.jsx(hc,{open:o,onOpenChange:a,onSelect:u})]})}function Gw(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 qw(){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 Yw=[{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 Vw({fullBleed:e=!1,onRegistered:t}){var V;const{roots:s,setScanRoots:r}=pw(),[o,a]=l.useState(null),[i,c]=l.useState(!1),[d,u]=l.useState(3),{startScan:m}=Tw(),{candidates:f,existingAgents:p,isScanning:h,progress:g,error:x,lastScanAt:b}=io(),{mutateAsync:y}=vm(),{mutate:k}=wm(),{data:S}=jm(),{actedPaths:E,markActed:v,resetActed:A}=Dw(),R=o??s,F=l.useCallback(M=>y({path:M.path,overrides:Mw(M),scanRoot:Gw(M.path,R)}),[R,y]),I=l.useCallback(M=>{v(M.path),t==null||t()},[v,t]),{failedPaths:O,pendingPaths:C,registerCandidate:j,resetFailures:w}=Ow({register:F,onSuccess:I});function D(M){a(M),r(M)}function T(){R.length>0&&(A(),w(),m({roots:R,maxDepth:d}))}const $=l.useMemo(()=>h?f:_w(f),[f,h]).filter(M=>!E.has(M.path)),B=(((V=S==null?void 0:S.agents)==null?void 0:V.length)??0)>0,Y=p.length>0,se=f.length>0,fe=Y||se,G=!h&&b!==null,q=!h&&b===null;function ee(){for(const M of $)j(M)}const ce=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(qt,{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(Ww,{roots:R,onChange:D}),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:M=>u(Number(M.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(Vy,{className:"size-3"}),"What it looks for"]}),n.jsx("ul",{className:"space-y-1 pl-4",children:Yw.map(M=>n.jsxs("li",{className:"flex items-baseline gap-1.5",children:[n.jsx("code",{className:"text-foreground/70 text-3xs",children:M.signal}),n.jsxs("span",{className:"text-muted-foreground text-3xs",children:["→ ",M.label]})]},M.name))})]})]})]});return n.jsx("div",{className:e?"flex h-full flex-col p-6":"space-y-4 p-4",children:q?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(qw,{}),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(L,{onClick:T,disabled:R.length===0,className:"w-full",children:[n.jsx(fs,{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"}),ce]})}):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:[ce,n.jsxs(L,{onClick:T,disabled:h||R.length===0,children:[h?n.jsx(Oe,{}):n.jsx(fs,{className:"size-4"}),"Search for projects"]})]}),n.jsxs("div",{className:e?"mt-4 flex-1 overflow-y-auto":"",children:[h&&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}),G&&!se&&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."})]}),G&&!fe&&n.jsxs("div",{className:"rounded-xl border border-dashed p-8 text-center",children:[n.jsx("p",{className:"text-sm font-medium",children:B?"No new projects found":"No projects found"}),n.jsx("p",{className:"text-muted-foreground mt-1 text-xs",children:B?"They’re already added. See the Agents tab.":"Try a deeper scan or other folders."})]}),G&&$.length>0&&n.jsxs(n.Fragment,{children:[n.jsx(Hw,{count:$.length,onAddAll:ee,disabled:C.size>0}),n.jsx(tt,{mode:"popLayout",children:$.map(M=>n.jsx(Bw,{candidate:M,className:"mb-2",registrationFailed:O.has(M.path),registrationPending:C.has(M.path),onApprove:X=>void j(X),onSkip:X=>v(X.path),onDeny:X=>k({path:X.path},{onSuccess:()=>v(X.path)})},M.path))})]}),G&&Y&&n.jsx("div",{className:"mt-3",children:n.jsx(Kw,{agents:p})})]})]})})}function Qw(){const e=Hs(),t=en(h=>h.isOpen)&&!e,s=en(h=>h.close);l.useEffect(()=>{e&&en.getState().isOpen&&s()},[e,s]);const r=Fe(),[o,a]=l.useState(0),[i,c]=l.useState(!1),[d,u]=l.useState(!1);t!==d&&(u(t),t&&(a(0),c(!1)));function m(h){h||s()}function f(){if(o>0&&!i){c(!0);return}s(),o>0&&r({...je.team()})}const p=`${o} project${o===1?"":"s"} joined`;return n.jsx(xt,{open:t,onOpenChange:m,children:n.jsxs(bt,{className:"max-h-[85vh] !min-h-0 sm:max-w-2xl",children:[n.jsxs(ht,{className:"shrink-0",children:[n.jsx(nt,{children:"Bring in existing projects"}),n.jsx(ft,{children:i?"Your projects are ready in DorkOS.":"Find projects on this computer to add."})]}),i?n.jsx(kt,{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(Es,{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(kt,{className:"mt-2 overflow-y-auto",children:n.jsx(Vw,{onRegistered:()=>a(h=>h+1)})}),n.jsxs(tn,{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(L,{onClick:f,"data-testid":"import-done",children:"Done"})]})]})})}function Xw(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 Jw(){const e=Sm(s=>s.record),t=Tx();we("marketplace_dev_link_reloaded",s=>{Xw(s)&&(e(s),t())})}function Zw(){const e=he();we("relay_bindings_changed",()=>{e.invalidateQueries({queryKey:[...Dx]})})}class Ua extends l.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 Ka=new Set(["agent-profile","profile","files","room","computer"]),Ha=new Set(["pulse","session","canvas","browser","local-browser","terminal"]),ej={};function tj(e,t){var Qt,U,ye;const s=_(N=>N.activeRightPanelTab),r=_(N=>N.setActiveRightPanelTab),o=_(N=>N.rightPanelLayoutKey),a=_(N=>N.selectedCwd),i=_(N=>N.explicitAgentPath),c=_(N=>N.sessionId),[d]=fc(),u=t==="/session"?d:null,m=u?`chat/${encodeURIComponent(u)}`:"human",{data:f}=ly(e.some(N=>N.id==="local-browser")),p=(f==null?void 0:f.status)==="connected"&&f.connectionId&&f.sessionId===u?f:null,h=p?`resource/browser/${m}/${encodeURIComponent(p.connectionId)}`:"local-browser",g=_(N=>N.roomCanvasLiveRoomId),x=_(N=>N.openDocuments),b=_(N=>g?N.roomCanvasDocuments[g]:void 0),y=_(N=>g?N.roomCanvasUnread[g]:void 0),k=_(N=>g?N.roomCanvasPresence[g]:void 0),S=pc(g),E=ie(),v=_(N=>{var W;return g?(W=N.roomCanvasActive[g])==null?void 0:W.canvas:N.activeCanvasDocumentId}),A=_(N=>{var W;return g?(W=N.roomCanvasActive[g])==null?void 0:W.browser:N.activeBrowserDocumentId}),R=_(N=>N.activateCanvasDocument),F=_(N=>N.activateRoomCanvasDocument),I=Zo(N=>N.chrome),O=`${c??""}:${a}`,C=(I==null?void 0:I.scope)===O?I:null,[j,w]=l.useState(null);l.useEffect(()=>{if((j==null?void 0:j.scope)!==O||!C)return;const N=j.id?C.tabs.find(W=>`resource/terminal/${W.id}`===j.id):C.tabs.find(W=>W.id===C.activeId);N&&!N.closed&&w(null)},[C,j,O]);const D=cy(),T=g?`room:${g}`:i??o??a??t,P=_(N=>N.canvasSessionId),$=_(N=>N.canvasSessionCwd),B=$!==void 0?P:P??c,Y=$!==void 0?$:a,se=g?`room:${g}`:km(B,Y),fe=g?`room:${g}`:Am(B,Y),G=_(N=>N.panelViewPreferences)??ej,q=_(N=>N.updatePanelViewPreference),ee=_(N=>N.reopenPanelResourceView),ce=l.useMemo(()=>new Set(Object.values(G).flatMap(N=>N.closed)),[G]),V=G[T]??{opened:[],closed:[]},M=((Qt=D.data)==null?void 0:Qt.cwd)!=null&&(i?D.data.cwd.replace(/\/workspace\/?$/,"")===i:D.data.cwd===a)&&D.data.phase!=="disabled"&&D.data.phase!=="unsupported",X=l.useMemo(()=>e.filter(N=>N.id!=="computer"||M),[e,M]),ae=N=>q==null?void 0:q(T,N),z=N=>{var W;return((W=Ae.find(J=>J.id===N))==null?void 0:W.resource)==="browser"},te=N=>{var W;return z(N)?N:(W=Ae.find(J=>J.id===N))!=null&&W.resource?`${se}:${N}`:N},me=N=>{var W;return((W=Ae.find(J=>J.id===N))==null?void 0:W.resource)==="document"?[te(N),`${fe}:${N}`]:[te(N)]},Se=N=>{var W;return((W=Ae.find(J=>J.id===N))==null?void 0:W.resource)==="document"},Je=N=>N==="profile"&&t==="/session",ne=N=>!Je(N)&&me(N).some(W=>Se(N)||z(N)?ce.has(W):V.closed.includes(W)),Ae=X.flatMap(N=>{const W=N.id;if(W==="local-browser"){if(!p)return[{...N,category:W,title:"Browser"}];const J=p.tabs.find(ve=>ve.id===p.selectedTabId),oe=p.mode==="embedded"?"DorkOS browser":"New browser window";return[{...N,category:W,resource:"browser",id:h,title:(J==null?void 0:J.title)||oe,icon:ps}]}if(W==="browser"||W==="canvas"){const J=g?Cm(b??[],W):Nm(x??[],W);if(J.length)return J.map(oe=>{var ve,Z,le;return{...N,category:W,resource:"document",id:`resource/${oe.id}`,title:"title"in oe&&oe.title||oe.sourceLabel||N.title,icon:W==="browser"?ps:dy,activate:()=>{g?F(g,oe.id):R(oe.id)},..."authorId"in oe?{author:(Z=(ve=S.data)==null?void 0:ve.members.find(Te=>Te.author.id===oe.authorId))==null?void 0:Z.author,unread:(le=y==null?void 0:y[W])==null?void 0:le.includes(oe.id),pinned:oe.pinned,watchers:Object.entries(k??{}).filter(([Te,Ve])=>{var Qe;return Ve===oe.id&&Te!==((Qe=S.data)==null?void 0:Qe.viewerAuthorId)}).flatMap(([Te])=>{var Ve,Qe;return((Qe=(Ve=S.data)==null?void 0:Ve.members.find(Gs=>Gs.author.id===Te))==null?void 0:Qe.author)??[]})}:{}}})}return W==="terminal"&&(C!=null&&C.tabs.length)?C.tabs.map(J=>({...N,category:W,resource:"terminal",id:`resource/terminal/${J.id}`,title:J.title,closed:J.closed,icon:gc,activate:oe=>C.activate(J.id,oe)})):[{...N,category:W,...W==="browser"?{title:"Page previews"}:{},...Je(W)?{permanent:!0}:{}}]}),it=new Set;if(!g){const N=(x??[]).filter(W=>W.id.startsWith("pending:")&&ne(`resource/${W.id}`));for(const W of x??[])W.id.startsWith("pending:")||W.openedHere||N.some(J=>{var oe;return(oe=J.pendingCandidateIds)==null?void 0:oe.includes(W.id)})&&it.add(`resource/${W.id}`)}const dt=Ae.some(N=>Ka.has(N.category)||!Ha.has(N.category)&&!N.isGlobal),Ee=Ae.filter(N=>(!N.closed||(j==null?void 0:j.scope)===O&&j.id===N.id)&&!ne(N.id)&&!it.has(N.id)&&(Ka.has(N.category)||!Ha.has(N.category)||N.resource||N.extensionId||V.opened.includes(N.category)||N.category===s||!dt&&N.isGlobal&&N.category!=="local-browser"));if(s==="terminal"&&(j==null?void 0:j.scope)===O&&j.id===null&&!Ee.some(N=>N.category==="terminal")){const N=X.find(W=>W.id==="terminal");N&&Ee.push({...N,category:"terminal"})}const be=s==="terminal"?`resource/terminal/${C==null?void 0:C.activeId}`:s==="local-browser"?h:s==="browser"?`resource/${A}`:s==="canvas"?`resource/${v}`:s,yt=((U=Ee.find(N=>N.id===be))==null?void 0:U.id)??((ye=Ee.find(N=>N.category===s))==null?void 0:ye.id)??null,_e=g?b==null?void 0:b.find(N=>`resource/${N.id}`===be):x==null?void 0:x.find(N=>`resource/${N.id}`===be),H=_e?`${_e.rev}:${_e.lastActiveAt}`:null,pe=_(N=>N.requestedRightPanel),ke=(N,W="pointer")=>{var oe;const J=Ae.find(ve=>ve.id===N);J&&(ae(ve=>({opened:[...new Set([...ve.opened,J.category])].slice(-100),closed:ve.closed.filter(Z=>!me(N).includes(Z))})),(J.resource==="document"||J.resource==="browser")&&(ee==null||ee(me(N))),w(J.resource==="terminal"?{scope:O,id:J.id}:null),(oe=J.activate)==null||oe.call(J,W),r(J.category))},Pe=N=>{var Z;if(Je(N))return;const W=x==null?void 0:x.find(le=>le.id.startsWith("pending:")&&`resource/${le.id}`===N),J=W?Ee.filter(le=>{var Te;return!((Te=W.pendingCandidateIds)!=null&&Te.some(Ve=>{var Qe;return`resource/${Ve}`===le.id&&!((Qe=x==null?void 0:x.find(Gs=>Gs.id===Ve))!=null&&Qe.openedHere)}))}):Ee,oe=J[J.findIndex(le=>le.id===N)+1]??J[J.findIndex(le=>le.id===N)-1],ve=Ae.find(le=>le.id===N);if(w(null),(ve==null?void 0:ve.resource)==="terminal"&&(C!=null&&C.hide))C.hide(N.slice(18));else{const le=Te=>({...Te,closed:[...new Set([...Te.closed,te(N)])].slice(-100)});(ve==null?void 0:ve.resource)==="document"?q==null||q(`documents:${se}`,le):(ve==null?void 0:ve.resource)==="browser"?q==null||q(`browsers:${m}`,le):ae(le)}N===yt&&((Z=oe==null?void 0:oe.activate)==null||Z.call(oe,"keyboard"),r((oe==null?void 0:oe.category)??null))};l.useEffect(()=>{if(!s)return;const N=be?me(be):[];!V.closed.includes(s)&&(!be||!ne(be))||(ae(W=>({...W,closed:W.closed.filter(J=>J!==s&&!N.includes(J))})),be&&(Se(be)||z(be))&&(ee==null||ee(N)))},[s,be,H,pe,se,m,T]);const Ye=s==="browser"?A:s==="canvas"?v:null,Ie=g?b==null?void 0:b.find(N=>N.id===Ye):x==null?void 0:x.find(N=>N.id===Ye),Rt=async N=>{try{await N()}catch{ue.error("Couldn’t update the canvas.")}},Vt=N=>{Rt(()=>g?E.openRoomCanvasDocument(g,N):_.getState().openCanvasDocument(N)),r(N.type==="url"?"browser":"canvas")};return{available:X,allViews:Ae,visible:Ee,activeId:yt,activate:ke,closeView:Pe,terminal:C,createTerminal:X.some(N=>N.id==="terminal")?()=>{w({scope:O,id:null}),ae(N=>({opened:[...new Set([...N.opened,"terminal"])].slice(-100),closed:N.closed.filter(W=>W!=="terminal")})),C?C.create():Zo.getState().requestCreate(O),r("terminal")}:void 0,createBrowser:X.some(N=>N.id==="browser")?()=>Vt({type:"url",url:Zr.site,title:"Web Page"}):void 0,createDocument:X.some(N=>N.id==="canvas")?()=>Vt({type:"markdown",content:`# Untitled
72
-
73
- Start writing…`,title:"Document"}):void 0,removeDocument:Ie?()=>void Rt(()=>g?E.closeRoomCanvasDocument(g,Ie.id):_.getState().closeCanvasDocument(Ie.id)):void 0,pinDocument:g&&Ie?()=>void Rt(()=>E.updateRoomCanvasDocument(g,Ie.id,{pinned:!Ie.pinned})):void 0,documentPinned:(Ie==null?void 0:Ie.pinned)??!1}}function nj({views:e,activeId:t,onActivate:s,onCreateTerminal:r,onStopTerminal:o,onCreateBrowser:a,onCreateDocument:i,onRemoveDocument:c,onPinDocument:d,documentPinned:u}){const m=e.find(p=>p.resource==="browser")??e.find(p=>p.category==="local-browser"),f=e.filter(p=>p.category!=="local-browser"||p===m);return n.jsxs(Ds,{children:[n.jsx(Os,{asChild:!0,children:n.jsx(L,{variant:"ghost",size:"icon-md","aria-label":"Add view",className:"size-11 shrink-0 lg:size-7",children:n.jsx(At,{className:"size-3.5"})})}),n.jsxs(Ms,{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(xc,{children:"Views"}),f.map(p=>n.jsxs(Xe,{"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(Hn,{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(as,{}),n.jsxs(Xe,{onSelect:r,children:[n.jsx(gc,{}),"New terminal"]})]}),a&&n.jsx(Xe,{onSelect:a,children:"New page preview"}),i&&n.jsx(Xe,{onSelect:i,children:"New document"}),d&&n.jsxs(n.Fragment,{children:[n.jsx(as,{}),n.jsx(Xe,{onSelect:d,children:u?"Unpin document":"Pin document"})]}),c&&n.jsx(Xe,{onSelect:c,children:"Remove document"}),o&&n.jsxs(n.Fragment,{children:[n.jsx(as,{}),n.jsx(Xe,{onSelect:o,children:"Stop terminal"})]})]})]})}function sj({active:e,hidden:t,here:s,saved:r}){const{setPlacement:o}=ay(),a=_(x=>x.setActiveRightPanelTab),i=at(),c=co(),d=Jl(),u=_(x=>x.setRightPanelOpen),m=lo(),f=Em(s)!==null,p=x=>yc(r.get(x.id),x.declaredPlacement),h=(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=f?t:[];return!e&&g.length===0?null:n.jsxs(Ds,{children:[n.jsx(Os,{asChild:!0,children:n.jsx(L,{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(Im,{className:"size-3.5"})})}),n.jsxs(Ms,{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:[h&&c&&n.jsxs(Xe,{onSelect:()=>{d&&u(!1),c({href:bc(h.extensionId,h.path)})},children:[n.jsx(Rm,{}),"Open full page"]}),f&&n.jsxs(Xe,{onSelect:()=>o(e.id,Dm(p(e),s)),children:[n.jsx(Tm,{}),"Hide here"]}),n.jsxs(Xe,{onSelect:()=>i.open("extensions",e.extensionId),children:[n.jsx(Om,{}),"Where it shows…"]})]}),e&&g.length>0&&n.jsx(as,{}),g.length>0&&n.jsxs(n.Fragment,{children:[n.jsx(xc,{className:"text-muted-foreground text-xs font-normal",children:"Show here"}),g.map(x=>n.jsxs(Xe,{onSelect:()=>{o(x.id,Mm(p(x),s)),a(x.id)},children:[x.icon?n.jsx(Hn,{icon:x.icon}):n.jsx(At,{}),x.title]},x.id))]})]})]})}const rj={canvas:"canvas",browser:"browser"};function oj(e,t){return t==="attention"?`${e}, something needs you`:e}function aj({contributionId:e}){const t=rj[e],s=_(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 _m(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 Rd="right-panel-content";function ls(e){return`right-panel-tab-${e}`}function ij({contributions:e,actions:t,activeId:s,onActivate:r,onCloseView:o}){const a=_(d=>d.setRightPanelOpen),i=_(d=>d.activeRightPanelTab),c=_(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(cj,{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(Hn,{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(L,{variant:"ghost",size:"icon-md","aria-label":"Close panel",className:"size-11 shrink-0 lg:size-7",onClick:()=>a(!1),children:n.jsx(Ke,{className:"size-3.5"})})]})]})}function cj({contributions:e,activeTab:t,onActivate:s,onCloseView:r}){const o=l.useRef(null),a=l.useRef("keyboard"),i=l.useRef(null),c=Pm(p=>p.tabMarkers),d=Lm(o,"horizontal"),u=l.useCallback(()=>{const p=o.current;return!p||!t?null:p.querySelector(`#${CSS.escape(ls(t))}`)},[t]),m=l.useCallback(()=>{const p=o.current,h=u();!p||!h||Fm(p,h)},[u]),f=e.map(p=>p.id).join(",");return l.useEffect(()=>{if(m(),typeof ResizeObserver>"u")return;const p=new ResizeObserver(m);for(const h of[o.current,i.current,u()])h&&p.observe(h);return()=>p.disconnect()},[m,u,f]),n.jsx(Ml,{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,className:"-my-1 overflow-x-auto overflow-y-hidden py-1",children:n.jsx(_l,{ref:i,responsive:!1,"aria-label":"Right panel tabs",className:"bg-accent/60 h-auto justify-start gap-0.5 rounded-lg p-0.5",children:e.map(p=>{var g,x;const h=p.id===t;return n.jsxs("div",{className:"group/view relative flex shrink-0 items-center py-2 md:py-0",children:[n.jsxs(fn,{children:[n.jsx(pn,{asChild:!0,children:n.jsxs(is,{value:p.id,"data-view-category":p.category??p.id,onPointerDown:()=>{a.current="pointer"},onKeyDown:b=>{var y;if(a.current="keyboard",b.key==="Delete"&&r&&!p.permanent){b.preventDefault();const k=e.findIndex(v=>v.id===p.id),S=e[k+1]??e[k-1],E=(y=b.currentTarget.closest('[data-slot="right-panel-header"]'))==null?void 0:y.querySelector('[aria-label="Add view"]');r(p.id),requestAnimationFrame(()=>{var v;S?(v=document.getElementById(ls(S.id)))==null||v.focus():E==null||E.focus()})}},"aria-label":[oj(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(b=>b.displayName).join(", ")} ${p.watchers.length===1?"is":"are"} looking at this.`].filter(Boolean).join(", "),id:ls(p.id),"aria-controls":h?Rd:void 0,className:K("text-muted-foreground hover:text-foreground text-3xs shrink-0 gap-1.5 rounded-md px-2.5 py-1",h&&"bg-background text-foreground shadow-sm"),children:[n.jsx(Hn,{icon:p.icon,className:"size-3.5"}),p.author&&n.jsx("span",{title:`Posted by ${p.author.displayName}`,children:n.jsx(kr,{size:"xs",kind:p.author.kind,color:p.author.color??Sr(p.author.id),emoji:p.author.emoji,imageUrl:p.author.imageUrl,fallback:ea(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(b=>n.jsx(kr,{size:"xs",className:"ring-background text-3xs size-3.5 ring-1",kind:b.kind,color:b.color??Sr(b.id),emoji:b.emoji,imageUrl:b.imageUrl,badge:null,fallback:ea(b.displayName)},b.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(b=>b.displayName).join(", ")," ",p.watchers.length===1?"is":"are"," looking at this."]})]}),n.jsx(aj,{contributionId:p.id})]})}),n.jsx(gn,{side:"bottom",children:p.title})]}),r&&h&&!p.permanent&&n.jsx(L,{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(Ke,{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 _r="app-shell-right-panel",lj=40,dj=320,Td=20,uj=50;function mj(e){if(e<=0)return Td;const t=dj/e*100;return Math.min(Math.round(t*10)/10,uj)}function hj(){const[e,t]=l.useState(Td);return l.useLayoutEffect(()=>{const s=document.querySelector(`[data-panel-group-id="${_r}"]`);if(!(s instanceof HTMLElement))return;const r=()=>t(mj(s.offsetWidth));r();const o=new ResizeObserver(r);return o.observe(s),()=>o.disconnect()},[]),{minPct:e,defaultPct:Math.max(lj,e)}}function fj(e,t){var h;const s=$m(e),r=Bm(),o=_(g=>g.selectedCwd),a=s==="session",i=vc(a?o:null),c=r.status==="loading"||a&&o!==null&&i.isPending,d=r.status==="ready"&&!t?r.roomId:null,u=a?((h=i.data)==null?void 0:h.id)??null:null,m=l.useMemo(()=>pj(s,d,u,a),[s,d,u,a]),[f,p]=l.useState(null);return!c&&f!==m&&p(m),c?{status:"pending",last:f}:{status:"ready",here:m}}function pj(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)",xj="cubic-bezier(0.4, 0, 1, 1)";function Wa(e,t){return`${e} 300ms ${t?gj:xj}`}const bj=new Set(["pulse","files"]);function yj({pathname:e,isRemoteCommunityRoom:t=!1}){var V;const s=_(M=>M.rightPanelOpen),r=_(M=>M.setRightPanelOpen),o=_(M=>M.activeRightPanelTab),a=_(M=>M.setActiveRightPanelTabView),i=Jl(),c=Me(),d=ed(),u=l.useRef(null),[m,f]=l.useState(!1),[p,h]=l.useState(!1);l.useEffect(()=>{const M=requestAnimationFrame(()=>h(!0));return()=>cancelAnimationFrame(M)},[]);const g=ie(),x=_(M=>M.currentAgentId),b=_(M=>M.selectedCwd),y=_(M=>M.explicitAgentPath),k=_s("right-panel"),S=l.useMemo(()=>k.filter(M=>!M.visibleWhen||M.visibleWhen({pathname:e,transport:g,agentId:x,cwd:b,explicitAgentPath:y,isRemoteCommunityRoom:t})),[k,e,g,x,b,y,t]),E=fj(e,t),v=E.status==="ready"?E.here:E.last,A=iy(),R=$e().data!==void 0,F=l.useMemo(()=>new Map(A.map(M=>[M.tab,M])),[A]),{visibleContributions:I,hiddenMiniAppTabs:O}=l.useMemo(()=>{const M=[],X=[];for(const ae of S)ae.extensionId?v&&zm(yc(F.get(ae.id),ae.declaredPlacement),v)?M.push(ae):X.push(ae):M.push(ae);return{visibleContributions:M,hiddenMiniAppTabs:X}},[S,v,F]),C=tj(I,e),j=C.visible,D=`${_(M=>M.sessionId)??""}:${b}`;l.useEffect(()=>{if(E.status!=="pending"&&j.length>0&&!j.some(X=>X.category===o)){const X=j.find(ae=>!ae.isGlobal);a((X??j[0]).category)}},[j,o,a,E.status]);const T=s,{minPct:P,defaultPct:$}=hj();l.useEffect(()=>{const M=u.current;M&&(T&&M.isCollapsed()?M.expand($):!T&&M.isExpanded()&&M.collapse())},[T,$]);const B=C.available.find(M=>M.id===o&&j.some(X=>X.category===M.id)),Y=C.available.find(M=>M.id==="terminal"),se=Y==null?void 0:Y.component,fe=C.terminal!==null||o==="terminal",G=B==null?void 0:B.component,q=B==null?void 0:B.headerActions,ee=n.jsxs(n.Fragment,{children:[n.jsx(ij,{contributions:j,activeId:C.activeId,onActivate:C.activate,onCloseView:C.closeView,actions:n.jsxs(n.Fragment,{children:[n.jsx(nj,{views:C.allViews,activeId:C.activeId,onActivate:C.activate,onCreateBrowser:C.createBrowser,onCreateDocument:C.createDocument,onRemoveDocument:C.removeDocument,onPinDocument:C.pinDocument,documentPinned:C.documentPinned,onCreateTerminal:C.createTerminal,onStopTerminal:o==="terminal"&&((V=C.terminal)!=null&&V.activeId)?()=>{var M;return(M=C.terminal)==null?void 0:M.stop(C.terminal.activeId,"pointer")}:void 0}),q?n.jsx(l.Suspense,{fallback:null,children:n.jsx(q,{})}):null,E.status==="ready"&&R&&n.jsx(sj,{active:B!=null&&B.extensionId?B:null,hidden:O,here:E.here,saved:F})]})}),n.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",...C.activeId&&j.some(M=>M.category===o)?{id:Rd,role:"tabpanel","aria-labelledby":ls(C.activeId)}:{},children:n.jsx(Ua,{tabId:o,children:n.jsx(l.Suspense,{fallback:null,children:n.jsxs(Um,{value:!0,children:[s&&o!=="terminal"&&G?n.jsx(G,{}):null,se&&fe&&n.jsx("div",{hidden:o!=="terminal"||!s||!B,className:"h-full",children:n.jsx(Km,{value:o==="terminal"&&s&&!!B,children:n.jsx(Ua,{tabId:o,children:n.jsx(se,{})})})},D),!B&&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 T?n.jsx(Hm,{open:!0,onOpenChange:M=>!M&&r(!1),children:n.jsxs(Wm,{showCloseButton:!1,style:{top:d.top,bottom:"auto",height:d.height,maxHeight:d.height},className:K("bg-sidebar text-sidebar-foreground flex w-full flex-col gap-0 pt-[env(safe-area-inset-top)] pr-[env(safe-area-inset-right)] pb-[env(safe-area-inset-bottom)] pl-[env(safe-area-inset-left)]",c&&"sm:max-w-full",c&&o&&bj.has(o)&&"!bottom-auto !h-auto max-h-dvh overflow-y-auto"),children:[n.jsxs(Gm,{className:"sr-only",children:[n.jsx(qm,{children:"Panel"}),n.jsx(Ym,{children:"Right panel content."})]}),ee]})}):null;const ce=p&&!m;return n.jsxs(n.Fragment,{children:[n.jsx(kb,{"aria-label":"Resize right panel",disabled:!T,onDragging:f,gripStyle:{opacity:T?1:0,pointerEvents:T?"auto":"none",...ce&&{transition:Wa("opacity",T)}}}),n.jsx(wc,{ref:u,id:"right-panel",order:2,defaultSize:T?$:0,minSize:P,collapsible:!0,collapsedSize:0,onCollapse:()=>{p&&r(!1)},onExpand:()=>{s||r(!0)},style:ce?{transition:Wa("flex-grow",T)}:void 0,children:n.jsx("div",{inert:!T,className:"bg-sidebar text-sidebar-foreground flex h-full flex-col overflow-hidden border-l",children:ee})})]})}const Ga="inbox",vj="open";function wj({blocked:e=!1}={}){const t=Wn()[Ga],s=eo(),r=t!==void 0,o=t==null?"":String(t).trim();l.useEffect(()=>{!r||!s||(o&&!e&&Vm(void 0,o===vj?void 0:{focus:o}),s({search:a=>({...a,[Ga]:void 0}),replace:!0}))},[r,o,e,s]),l.useEffect(()=>{e&&Qm()},[e])}function jj(){const e=_(t=>t.toggleRightPanel);l.useEffect(()=>{const t=s=>{(s.metaKey||s.ctrlKey)&&s.key==="."&&(s.preventDefault(),e())};return document.addEventListener("keydown",t),()=>document.removeEventListener("keydown",t)},[e])}function Sj(){const e=he();we("capabilities_changed",()=>{e.invalidateQueries({queryKey:jc.all})})}function kj(){const e=ie(),t=he();return Ht({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:jc.all}),t.invalidateQueries({queryKey:["mesh","agents"]})}})}const qa=new WeakMap;let Cj=0;function Nj(e){const t=qa.get(e);if(t!==void 0)return t;const s=`bar-${Cj++}`;return qa.set(e,s),s}function Aj(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:Nj(r),Header:r}}return null}function Ej(e){const t=e.startsWith("/")?e:`/${e}`;if(Ue()){const s=t.slice(1);if(s.length>0&&!s.startsWith("?")&&!s.startsWith("#"))return`dorkos://${s}`}return`${window.location.origin}${t}`}const Ij="/";function _o(){const e=Wt();return l.useMemo(()=>{const t=()=>uo(e),s=a=>{ge.getState().selectTab(a),t()},r=a=>{const i=ge.getState().tabs;a(),Sc(i,ge.getState().tabs)},o=a=>{const{tabs:i}=ge.getState(),c=i[a];c&&s(c.id)};return{activate:s,activateIndex:o,activateLast:()=>o(ge.getState().tabs.length-1),activateRelative:a=>{const{tabs:i,activeTabId:c}=ge.getState();if(i.length<2)return;const d=i.findIndex(f=>f.id===c),m=(((d===-1?0:d)+a)%i.length+i.length)%i.length;s(i[m].id)},close:a=>{r(()=>ge.getState().closeTab(a)),t()},closeActive:()=>{const{tabs:a,activeTabId:i}=ge.getState();if(!i)return!1;const c=a.length;r(()=>ge.getState().closeTab(i));const d=ge.getState().tabs.length<c;if(d)try{t()}catch(u){console.error("[dorkos:tabs] could not follow a closed tab",u)}return d},create:()=>Jm(e,Ij),togglePin:a=>{const i=ge.getState().tabs.find(c=>c.id===a);i&&ge.getState().setTabPinned(a,!i.pinned)},duplicate:a=>{ge.getState().duplicateTab(a),t()},closeOthers:a=>{r(()=>ge.getState().closeOtherTabs(a)),t()},reorder:(a,i)=>ge.getState().moveTab(a,i),reopenClosed:a=>{Xm(e,a).catch(i=>{console.error("[dorkos:tabs] could not reopen a closed tab",i)})}}},[e])}const Rj={start:["Space"],cancel:["Escape"],end:["Space","Enter","Tab"]},Tj=4,Dj={draggable:"Press Space to move this tab. Arrows move it, Space drops it, Escape cancels."};function Oj(e){return t=>{const s=e(String(t.active.id));return kc({...t,droppableContainers:t.droppableContainers.filter(r=>e(String(r.id))===s)})}}class Mj extends Map{getEnabled(){return[...this.values()].filter(t=>!t.disabled)}toArray(){return[...this.values()]}}function _j(e){return(t,s)=>{const{context:r}=s;if(!r.active)return Cr(t,s);const o=e(String(r.active.id)),a=new Mj;for(const i of r.droppableContainers.toArray())e(String(i.id))===o&&a.set(i.id,i);return Cr(t,{...s,context:{...r,droppableContainers:a}})}}function Pj(e){return e.length===0?null:{left:Math.min(...e.map(t=>t.left)),right:Math.max(...e.map(t=>t.right))}}function Lj(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 Fj(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 $j(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 Bj=500;function zj(e){const t=Gn(new Date(e).toISOString());return`Last active ${t==="Just now"?"just now":t}`}function Uj({identity:e,className:t}){return n.jsxs("div",{className:K("flex min-w-0 flex-col gap-1.5 text-xs",t),children:[n.jsxs("div",{className:"flex min-w-0 items-start gap-2",children:[n.jsx(mo,{icon:e.icon,className:"mt-px"}),n.jsxs("p",{className:"min-w-0 font-medium break-words",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-center gap-1.5",children:[n.jsx(ho,{identity:e}),n.jsx("span",{children:e.statusSentence})]}),e.lastActiveAt!==void 0&&!Number.isNaN(e.lastActiveAt)&&n.jsx("p",{className:"text-muted-foreground",children:zj(e.lastActiveAt)})]})}function Kj({identity:e,children:t}){return n.jsxs(Hl,{openDelay:Bj,closeDelay:0,children:[n.jsx(Wl,{asChild:!0,children:t}),n.jsx(Gl,{side:"bottom",align:"start",sideOffset:6,className:"w-64 p-3",children:n.jsx(Uj,{identity:e})})]})}const Dd="app-tab-panel";function Hj({identity:e,isActive:t,canClose:s,collapseAgent:r=!1,pinned:o=!1,tabProps:a,onClose:i}){const c=eh(e,{collapseAgent:r}),d=l.useRef(null);l.useEffect(()=>{var m,f;t&&((f=(m=d.current)==null?void 0:m.scrollIntoView)==null||f.call(m,{block:"nearest",inline:"nearest"}))},[t]);const u=s&&!o;return n.jsxs("div",{ref:d,role:"presentation",className:"group relative flex shrink-0",children:[n.jsx(Kj,{identity:e,children:n.jsxs("button",{type:"button",role:"tab","aria-selected":t,"aria-controls":t?Dd:void 0,"aria-label":th(e,{collapseAgent:r}),...a,className:K("focus-ring flex min-w-0 items-center gap-1.5 rounded-md py-1 text-xs transition-colors",o?"px-2":t?"max-w-72 pl-2":"max-w-52 pl-2",!o&&(u?"pr-7":"pr-2"),t?"bg-secondary text-foreground contrast-more:ring-foreground/40 contrast-more:ring-1":"text-muted-foreground/80 hover:bg-secondary/50 hover:text-foreground contrast-more:text-muted-foreground"),children:[n.jsx(mo,{icon:e.icon}),!o&&n.jsxs("span",{className:"min-w-0 truncate",children:[n.jsx("span",{className:"font-medium",children:c.lead}),c.trail&&n.jsxs("span",{className:"opacity-70",children:[" · ",c.trail]})]}),n.jsx(ho,{identity:e})]})}),u&&i&&n.jsx("button",{type:"button",tabIndex:-1,onClick:()=>i("pointer"),"aria-label":`Close ${e.primary}`,className:K("focus-ring hover:bg-muted absolute top-1/2 right-1 -translate-y-1/2 rounded-sm p-0.5","opacity-0 transition-opacity group-hover:opacity-70 hover:opacity-100",t&&"opacity-70"),children:n.jsx(Ke,{className:"size-3"})})]})}function Wj({tab:e,isActive:t,canClose:s,pinned:r,tabProps:o,onClose:a}){const i=Ps(e.href),c=Zm(i.agentKey);return n.jsx(Hj,{identity:i,isActive:t,canClose:s,collapseAgent:c,pinned:r??e.pinned??!1,tabProps:o,onClose:d=>a(e.id,d)})}function Gj({href:e,onSelect:t}){const s=Ps(e);return n.jsxs(Tt,{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 qj({tabId:e,pinned:t,hasOthersToClose:s,canClose:r,actions:o,onClosed:a,children:i}){const c=nh(),{reopenClosed:d}=o;return n.jsxs(sh,{children:[n.jsx(rh,{asChild:!0,children:i}),n.jsxs(oh,{className:"w-56",onCloseAutoFocus:a?u=>{u.preventDefault(),a()}:void 0,children:[n.jsxs(Tt,{onSelect:()=>o.togglePin(e),children:[t?n.jsx(ah,{className:"mr-2 size-4"}):n.jsx(ih,{className:"mr-2 size-4"}),t?"Unpin":"Pin"]}),n.jsxs(Tt,{onSelect:()=>o.duplicate(e),children:[n.jsx(Yy,{className:"mr-2 size-4"}),"Duplicate"]}),n.jsxs(Tt,{onSelect:()=>o.copyLink(e),children:[n.jsx(ch,{className:"mr-2 size-4"}),"Copy link"]}),n.jsx(ta,{}),n.jsxs(Tt,{disabled:!s,onSelect:()=>o.closeOthers(e),children:[n.jsx(lh,{className:"mr-2 size-4"}),"Close others"]}),n.jsxs(Tt,{disabled:!r,onSelect:()=>o.close(e),children:[n.jsx(Ke,{className:"mr-2 size-4"}),"Close"]}),d&&n.jsxs(n.Fragment,{children:[n.jsx(ta,{}),n.jsxs(Tt,{disabled:c.length===0,onSelect:()=>d(),children:[n.jsx(Cc,{className:"mr-2 size-4"}),"Reopen closed tab",n.jsx("kbd",{className:"text-muted-foreground ml-auto pl-4 text-xs",children:$t(rn.REOPEN_CLOSED_TAB)})]}),n.jsxs(dh,{children:[n.jsxs(uh,{disabled:c.length===0,children:[n.jsx(ql,{className:"mr-2 size-4"}),"Recently closed"]}),n.jsx(mh,{className:"max-h-96 w-64 overflow-y-auto",children:c.map(u=>n.jsx(Gj,{href:u.tab.href,onSelect:()=>d({tabId:u.tab.id,closedAt:u.closedAt})},`${u.tab.id}-${u.closedAt}`))})]})]})]})]})}const In="data-app-tab-id";function Yj({tab:e,isActive:t,canClose:s,tabProps:r,onClose:o,sortable:a,dragActive:i,menu:c,hasOthersToClose:d,onMenuClosed:u}){const m=e.pinned??!1,{setNodeRef:f,setActivatorNodeRef:p,attributes:h,listeners:g,transform:x,transition:b,isDragging:y}=hh({id:e.id,disabled:!a}),k=g==null?void 0:g.onPointerDown,S=g==null?void 0:g.onKeyDown,E={transform:x?`translate3d(${Math.round(x.x)}px, 0, 0)`:void 0,transition:b??void 0},{ref:v,onKeyDown:A}=r,R=l.useCallback(C=>{v(C),p(C)},[v,p]),F=l.useCallback(C=>{if(c&&(C.key==="ContextMenu"||C.shiftKey&&C.key==="F10")){C.preventDefault();const j=C.currentTarget,w=j.getBoundingClientRect();j.dispatchEvent(new MouseEvent("contextmenu",{bubbles:!0,cancelable:!0,clientX:w.left,clientY:w.bottom}));return}S==null||S(C),!(C.defaultPrevented||i)&&A(C)},[c,S,i,A]),I=l.useMemo(()=>({...r,ref:R,onKeyDown:F,...a?{"aria-describedby":h["aria-describedby"]}:{}}),[r,R,F,a,h]),O=n.jsx("div",{ref:f,role:"presentation",[In]:e.id,style:E,onPointerDown:k,className:K("flex shrink-0",y&&"bg-background shadow-soft relative z-10 rounded-md"),children:n.jsx(Wj,{tab:e,isActive:t,canClose:s,tabProps:I,onClose:o,pinned:m})});return c?n.jsx(qj,{tabId:e.id,pinned:m,hasOthersToClose:d,canClose:s,actions:c,onClosed:u,children:O}):O}function Vj({tabs:e,activeId:t,onActivate:s,onClose:r,onCreate:o,menu:a,onReorder:i,className:c}){const d=l.useRef(null),u=l.useRef(null),m=Nc(null),f=e.length>1,[p,h]=l.useState(!1),g=l.useMemo(()=>e.map(O=>O.id),[e]),x=nn(e),{collisionDetection:b,coordinateGetter:y,modifiers:k,announcements:S}=l.useMemo(()=>{const O=j=>x.read().findIndex(w=>w.id===j),C=j=>{var w;return((w=x.read().find(D=>D.id===j))==null?void 0:w.pinned)??!1};return{collisionDetection:Oj(C),coordinateGetter:_j(C),modifiers:[Lj(m.read)],announcements:$j({nameOf:j=>{var w,D,T;return((T=(D=(w=Array.from(document.querySelectorAll(`[${In}]`)).find(P=>P.getAttribute(In)===j))==null?void 0:w.querySelector('[role="tab"]'))==null?void 0:D.textContent)==null?void 0:T.trim())||"Tab"},indexOf:O,count:()=>x.read().length})}},[x,m]),E=Ac(gs(Rc,{activationConstraint:{distance:Tj}}),gs(Ic,{coordinateGetter:y,keyboardCodes:Rj})),v=({active:O})=>{var w,D;h(!0);const C=((w=e.find(T=>T.id===O.id))==null?void 0:w.pinned)??!1,j=Array.from(((D=u.current)==null?void 0:D.querySelectorAll(`[${In}]`))??[]).filter(T=>{var $;const P=T.getAttribute(In);return((($=e.find(B=>B.id===P))==null?void 0:$.pinned)??!1)===C}).map(T=>T.getBoundingClientRect());m.write(Pj(j))},A=()=>{h(!1),m.write(null)},R=({active:O,over:C})=>{A();const j=Fj(g,O.id,C==null?void 0:C.id);j&&i&&i(...j)},F=()=>{setTimeout(()=>{var O,C;(C=(O=u.current)==null?void 0:O.querySelector('[role="tab"][aria-selected="true"]'))==null||C.focus()},0)},{getTabProps:I}=Vb({orderedIds:e.map(O=>O.id),activeId:t,onActivate:s,onClose:f?r:void 0,getFallbackFocus:()=>d.current});return n.jsxs("div",{className:K("bg-muted/40 flex shrink-0 items-stretch border-b px-2 py-1",c),children:[n.jsx("div",{className:"flex min-w-0 flex-1 items-stretch overflow-x-auto",children:n.jsx(Ec,{sensors:E,collisionDetection:b,modifiers:k,accessibility:{announcements:S,screenReaderInstructions:Dj},onDragStart:v,onDragEnd:R,onDragCancel:A,children:n.jsx(fh,{items:g,strategy:ph,children:n.jsx("div",{ref:u,role:"tablist","aria-label":"Open tabs",className:"flex items-stretch gap-1",children:e.map(O=>n.jsx(Yj,{tab:O,isActive:O.id===t,canClose:f,tabProps:I(O.id),onClose:r,sortable:i!==void 0,dragActive:p,menu:a,onMenuClosed:F,hasOthersToClose:e.some(C=>C.id!==O.id&&!C.pinned)},O.id))})})})}),n.jsx("button",{ref:d,type:"button",onClick:o,"aria-label":"New tab",title:`New tab (${$t(rn.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(At,{className:"size-3.5"})})]})}function Qj({className:e}){const t=gh(),s=ge(h=>h.activeTabId),{activate:r,close:o,create:a,togglePin:i,duplicate:c,closeOthers:d,reorder:u,reopenClosed:m}=_o(),{copy:f}=Kn({toastOnSettle:!0}),p=l.useMemo(()=>({togglePin:i,duplicate:c,closeOthers:d,close:o,reopenClosed:m,copyLink:h=>{const g=ge.getState().tabs.find(x=>x.id===h);g&&f(Ej(g.href))}}),[i,c,d,o,m,f]);return n.jsx(Vj,{tabs:t,activeId:s,onActivate:r,onClose:o,onCreate:a,menu:p,onReorder:u,className:e})}function js(){var s;const{tabs:e,activeTabId:t}=ge.getState();return((s=e.find(r=>r.id===t))==null?void 0:s.cursor)??null}function Po(e,t){const s=js();s!==null&&(ge.getState().goToHistoryIndex(t),js()!==s&&uo(e))}function Od(e){const t=js();t!==null&&Po(e,t-1)}function Md(e){const t=js();t!==null&&Po(e,t+1)}function Xj(e,t){Po(e,t)}function Ya(e,t){const s=$t(e);return Bt?s:`${s} or ${$t(`alt+${t}`)}`}const sr="size-7";function Jj({href:e,isCurrent:t,onSelect:s}){const r=Ps(e);return n.jsxs(Xe,{disabled:t,"aria-current":t?"page":void 0,onSelect:s,"aria-label":r.accessibleName,className:"data-[disabled]:opacity-100",children:[n.jsx(mo,{icon:r.icon}),n.jsxs("span",{className:"min-w-0 flex-1 truncate",children:[r.primary,r.secondary&&n.jsxs("span",{className:"text-muted-foreground",children:[" · ",r.secondary]})]}),n.jsx(ho,{identity:r}),n.jsx(Gt,{className:K("size-3.5 shrink-0",!t&&"invisible")})]})}function rr({label:e,keys:t,children:s}){return n.jsxs(fn,{children:[n.jsx(pn,{asChild:!0,children:s}),n.jsx(gn,{side:"bottom",className:"text-xs",children:t?`${e} (${t})`:e})]})}function Zj(){const e=Wt(),{entries:t,cursor:s,canGoBack:r,canGoForward:o}=xh();if(!Ue())return null;const a=t.map((i,c)=>({href:i,index:c})).reverse();return n.jsxs("div",{className:"flex items-center",children:[n.jsx(rr,{label:"Back",keys:Ya(rn.HISTORY_BACK.key,"←"),children:n.jsx(L,{variant:"ghost",size:"icon-md",className:sr,"aria-label":"Back",disabled:!r,onClick:()=>Od(e),children:n.jsx(Tc,{})})}),n.jsx(rr,{label:"Forward",keys:Ya(rn.HISTORY_FORWARD.key,"→"),children:n.jsx(L,{variant:"ghost",size:"icon-md",className:sr,"aria-label":"Forward",disabled:!o,onClick:()=>Md(e),children:n.jsx(Dc,{})})}),n.jsxs(Ds,{children:[n.jsx(rr,{label:"History",children:n.jsx(Os,{asChild:!0,children:n.jsx(L,{variant:"ghost",size:"icon-md",className:sr,"aria-label":"History",children:n.jsx(ql,{})})})}),n.jsx(Ms,{align:"start",className:"max-w-72 min-w-48",children:a.map(({href:i,index:c})=>n.jsx(Jj,{href:i,isCurrent:c===s,onSelect:()=>Xj(e,c)},c))})]})]})}function eS(){const e=Wt(),t=Le({select:o=>o.location.href}),s=l.useRef(!1),r=l.useRef(!0);l.useEffect(()=>{if(Ue())return e.history.subscribe(({action:o})=>{s.current=o.type!=="PUSH"&&o.type!=="REPLACE",r.current=o.type==="REPLACE"})},[e]),l.useEffect(()=>{if(!Ue())return;const o=s.current,a=r.current;s.current=!1,r.current=!1,ge.getState().syncLocation(t,{traversal:o,replace:a})},[t])}const Va=9;function tS(){const e=_o();l.useEffect(()=>{if(!Ue())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>Va||(s.preventDefault(),r===Va?e.activateLast():e.activateIndex(r-1))};return document.addEventListener("keydown",t),()=>document.removeEventListener("keydown",t)},[e])}const Qa=3,nS=4;function sS(e){return e instanceof Element?e.closest("input, textarea, select")?!0:e.closest('[contenteditable]:not([contenteditable="false"])')!==null:!1}function Xa(e){return e instanceof Element&&e.closest('[role="dialog"], [role="alertdialog"], [role="menu"]')!==null}function rS(e){if(e.shiftKey)return null;if((Bt?e.metaKey&&!e.ctrlKey:e.ctrlKey&&!e.metaKey)&&!e.altKey)return e.code==="BracketLeft"?"back":e.code==="BracketRight"?"forward":null;if(!Bt&&e.altKey&&!e.ctrlKey&&!e.metaKey){if(sS(e.target))return null;if(e.key==="ArrowLeft")return"back";if(e.key==="ArrowRight")return"forward"}return null}function oS(){const e=Wt();l.useEffect(()=>{if(!Ue())return;const t=i=>i==="back"?Od(e):Md(e),s=i=>{if(i.defaultPrevented||i.isComposing||Xa(i.target))return;const c=rS(i);c&&(i.preventDefault(),t(c))},r=i=>i.button===Qa||i.button===nS,o=i=>{r(i)&&i.preventDefault()},a=i=>{r(i)&&(i.preventDefault(),!Xa(i.target)&&t(i.button===Qa?"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 aS(e){return typeof e=="object"&&e!==null&&e.status===404}async function iS(e){try{return await e(),!1}catch(t){return aS(t)}}async function cS(e,t){const s=new Map,r=(a,i)=>{let c=s.get(a);return c||(c=iS(i),s.set(a,c)),c},o=await Promise.all(e.map(async a=>{const i=bh(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 lS(){const e=ie(),t=Wt();l.useEffect(()=>{if(!Ue())return;let s=!1;const r=ge.getState().tabs;return cS(r,{getSession:o=>e.getSession(o),getRoom:o=>e.getRoom(o)}).then(o=>{if(s||o.size===0)return;const{tabs:a,activeTabId:i}=ge.getState();ge.getState().dropTabs(o),Sc(a,ge.getState().tabs),ge.getState().activeTabId!==i&&uo(t)}).catch(o=>{console.error("[dorkos:tabs] could not check restored tabs",o)}),()=>{s=!0}},[])}function dS(){eS(),tS(),yh(),lS(),oS()}function uS(e){return e.displayName||e.name}function Lo(e,t){const s=Ln(r=>r.setRouteBadge);l.useEffect(()=>{s(e,t)},[e,t,s])}const mS=5*6e4;function hS(e){return e.status==="active"&&e.enabled}function fS(e){const{enabled:t}=wh(),{data:s}=Oc(t),{data:r}=jh(t),o=Ln(c=>c.setSchedulesWaitingCount),a=l.useMemo(()=>{const c=jw(t?r??[]:[]),d=new Map((s??[]).filter(hS).map(u=>[u.id,u]));return{waiting:e,failed:c.failed.filter(u=>d.has(u)).length,running:c.running.flatMap(u=>{const m=d.get(u);return m?[uS(m)]:[]})}},[t,r,s,e]),i=l.useMemo(()=>Sh(a),[a]);Lo("/tasks",i),l.useEffect(()=>{o(e)},[e,o])}function pS(){const{count:e,more:t}=kh(),s=l.useMemo(()=>Ch(e,t),[e,t]);Lo("/activity",s)}function gS(){const{data:e,isSuccess:t}=jx("pending"),{data:s}=Sx("pending",{enabled:t,refetchInterval:mS}),r=((e==null?void 0:e.length)??0)+((s==null?void 0:s.length)??0),o=l.useMemo(()=>Nh(r),[r]);Lo("/connections",o)}function xS(){const{items:e,schedules:t}=vh(),s=Ln(r=>r.setNeedsYouCount);l.useEffect(()=>{s(e.length)},[e.length,s]),fS(t.length),pS(),gS()}function Pt(e){return"problem"in e?{problem:e.problem}:{message:e.message}}const Lt={message:"Couldn’t reach your DorkOS account. Try again."},bS={message:"Finish signing in in your browser, then try again."},yS={message:"Your browser blocked the window. Allow pop-ups, then try again."},or={message:"Couldn’t connect this DorkOS to the space. Try again."},vS={message:"The approval ran out. Connect again."};function Fo(e,t,s){var I,O;const r=ie(),o=he(),a=Un(e!==null),{signsInWithAccount:i,linkFor:c}=Mc(e!==null),[d,u]=l.useState({opened:!1,busy:!1,notice:null}),[m,f]=l.useState(null),p=l.useRef(null),h=Re({queryKey:ct.list(),queryFn:()=>r.listHostedCommunities(),enabled:e!==null&&m===null,refetchInterval:C=>{const j=C.state.data,w=(j==null?void 0:j.available)===!0?j.communities.find(D=>D.communityId===(e==null?void 0:e.communityId)):void 0;return(w==null?void 0:w.state)==="provisioning"?2e3:!1}}),g=((I=h.data)==null?void 0:I.available)===!0?h.data.communities.find(C=>C.communityId===(e==null?void 0:e.communityId)):void 0,x=(g==null?void 0:g.state)==="provisioning",b=l.useCallback(()=>{if(!e||d.busy)return;const C=no();if(C===null){u(j=>({...j,notice:yS}));return}u(j=>({...j,busy:!0,notice:null})),r.getHostedCommunityClaimLink(e.communityId).then(j=>{if(!j.ok){C.close(),u(D=>({...D,busy:!1,notice:Pt(j)}));return}const w=C.go(c(j.claimUrl));u(D=>({opened:D.opened||w,busy:!1,notice:null}))}).catch(()=>{C.close(),u(j=>({...j,busy:!1,notice:Lt}))})},[e,d.busy,r,c]),y=l.useCallback(async()=>{if(e){if(!a||!Dt(a)){f({ref:null,approvalUrl:null,busy:!1,notice:or});return}f({ref:null,approvalUrl:null,busy:!0,notice:null});try{const C=await r.startCommunityConnection({url:e.communityUrl,installName:t});f({ref:C.connection.ref,approvalUrl:C.approvalUrl,busy:!1,notice:null}),await o.invalidateQueries({queryKey:jt.connections(a)})}catch{f({ref:null,approvalUrl:null,busy:!1,notice:or})}}},[e,a,r,t,o]),k=l.useCallback(()=>{!e||d.busy||(u(C=>({...C,busy:!0,notice:null})),r.listHostedCommunities().then(C=>{o.setQueryData(ct.list(),C);const j=C.available===!0?C.communities.find(w=>w.communityId===e.communityId):void 0;if(!j||j.state==="pending_owner"||j.state==="provisioning"){u(w=>({...w,busy:!1,notice:bS}));return}u(w=>({...w,busy:!1})),y()}).catch(()=>u(C=>({...C,busy:!1,notice:Lt}))))},[e,d.busy,r,o,y]),S=(m==null?void 0:m.ref)??null,E=Re({queryKey:a&&S?jt.approval(a,S):["cloud","no-approval"],queryFn:()=>sc(a,()=>r.pollCommunityConnection(S)),enabled:a!==null&&S!==null,retry:!1,refetchInterval:C=>!C.state.error&&(!C.state.data||C.state.data.status==="pending")?2e3:!1}),v=S!==null?((O=E.data)==null?void 0:O.status)??"pending":"pending",A=v==="connected"?S:null;l.useEffect(()=>{A===null||p.current===A||(p.current=A,a&&o.invalidateQueries({queryKey:jt.connections(a)}),o.invalidateQueries({queryKey:ct.all}),s(A))},[A,a,o,s]);const R=v==="expired"||v==="cancelled";return{state:A!==null?{kind:"done",ref:A}:m!==null?{kind:"connecting",approvalUrl:m.approvalUrl,busy:m.busy,notice:m.notice??(R?vS:E.error?or:null)}:x?{kind:"preparing"}:{kind:"claim",...d,withAccount:e!==null&&i(e.communityUrl)},openClaim:b,confirmClaimed:k,openApproval:()=>{m!=null&&m.approvalUrl&&Ct(c(m.approvalUrl))},retryConnect:()=>void y()}}const wt=Ah({offset:!0}).describe("An ISO-8601 instant with an explicit UTC offset."),rt=Ce().min(1).describe("An opaque server-issued identifier. Clients never parse or enumerate it.");Ce().regex(/^-?(0|[1-9][0-9]*)$/,"must be a base-10 integer count of micro-units carried as a string").describe("An exact integer count of micro-units, carried as a string so no value goes through a JavaScript number. A micro-unit is a millionth of the major unit of the currency the response names.");const wS=Ce().regex(/^[1-9][0-9]*$/,"must be a positive base-10 integer count of micro-units carried as a string").describe("A strictly positive exact integer count of micro-units, carried as a string so no amount goes through a JavaScript number."),$o="amountKind";bn(["money","credit"]).describe("What an amount counts: money paid, refunded, offered or capped, or credits held, spent or priced.");const _d=/^-?(0|[1-9][0-9]*)$/,jS=/^[1-9][0-9]*$/;Ce().regex(_d,"must be a base-10 integer count of micro-units carried as a string").describe("An exact integer count of micro-units of the response's currency: money paid, refunded, offered or capped.").meta({[$o]:"money"});Ce().regex(jS,"must be a positive base-10 integer count of micro-units carried as a string").describe("A strictly positive exact integer count of micro-units of money to be paid, in the currency the service names.").meta({[$o]:"money"});Ce().regex(_d,"must be a base-10 integer count of micro-units carried as a string").describe("An exact integer count of micro-units of the response's currency, counted as credits: divide by the response's denomination.microPerCredit to get credits.").meta({[$o]:"credit"});de({currency:Ce().regex(/^[A-Z]{3}$/,"must be an ISO 4217 currency code").describe("An ISO 4217 code. Rendered, never enumerated."),microPerCredit:wS.describe("How many micro-units of currency one credit is. Served by the service; a client never hard-codes it.")}).describe("The unit these amounts are in: the currency their micro-units are millionths of, and how many micro-units one credit is.");const SS=Ce().min(1).describe("A credential returned exactly once. Store it as a credential reference; never log it or persist it as configuration."),Pd=Ce().min(1).describe("An opaque pagination cursor, passed back verbatim from a previous page.");de({cursor:Pd.optional(),limit:xe().int().min(1).max(200).optional().describe("Maximum items in the page. The server may return fewer, and clamps anything larger.")}).describe("Cursor pagination parameters, shared by every collection in this contract.");function Ld(e,t){return de({items:xn(e),nextCursor:Pd.nullable().describe("The cursor for the next page, or null when this is the last page.")}).describe(t)}const kS=_c({protocol:/^https$/}).regex(/^https:\/\//,"must be an https: link").describe("An absolute https: link. Any other scheme is refused."),Qn=_c({protocol:/^https?$/}).regex(/^(https:\/\/|http:\/\/(localhost|127\.0\.0\.1|\[::1\])(:[0-9]+)?([/?#]|$))/,"must be an https: link, or http: to a loopback address").describe("An absolute https: link, or an http: link to a loopback address only."),Fd="x-dorkos-one-time-credential",CS="unrecognised";function Ss(e){return Eh([e,Ce().transform(()=>CS).describe("A value this release does not know. It reads as unrecognised.")])}const vn=Ce().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."),$d=Ce().trim().min(1).max(80).describe("The community`s display name. Trimmed, 1 to 80 characters."),Bd=Ce().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 NS(e){return Qn.meta({description:e,[Fd]:!0})}const AS=bn(["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."),ES=bn(["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."),IS=de({title:Ce().min(1).max(120).describe("A short summary, safe to show a person."),detail:Ce().max(2e3).describe("The explanation, safe to show a person."),actionUrl:kS.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:Ce().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."),RS=de({allowed:Mt().describe("The owner may choose this community as one to keep open."),wouldHold:xn(rt).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."),Bo=de({communityId:rt.describe("The community`s permanent identifier on its Community server. Never changes, even across a rename."),orgId:rt.describe("The organization whose account this community belongs to."),name:Ce().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:Qn.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:Ss(AS).describe("Where the community is in its lifecycle. A state this release does not know reads as unrecognised."),hold:de({reason:Ss(ES).describe("Why the community is on hold. A reason this release does not know reads as unrecognised."),since:wt,deletionNoticeAt:wt.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:wt.nullable().describe("When the Community server will delete the community for good. Always set when the state is deletion_pending."),notice:IS.nullable().describe("What the service wants the owner to read about this community, or null when there is nothing."),kept:Mt().describe("True when the owner chose this community to stay open while the account holds more communities than its allowance covers."),moveId:rt.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:de({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:de({activeMembers:xe().int().nonnegative(),storageBytes:xe().int().nonnegative().describe("The bytes that count against the storage limit. Owner exports never count."),measuredAt:wt}).nullable().describe("The community`s last measured usage, or null before the first measurement."),actions:de({claimLink:Mt().describe("The service will issue a fresh owner-claim link for this community."),keep:RS,restore:Mt().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:wt}).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.");Ld(Bo,"A page of the communities the caller has hosted.");de({name:vn}).describe("The short name to check.");const TS=bn(["taken","reserved"]).describe("Why a short name cannot be used: another community has it, or the host reserves it.");de({name:vn,available:Mt(),reason:TS.nullable().describe("Why the name cannot be used. Null exactly when it is available.")}).superRefine((e,t)=>{e.available!==(e.reason===null)&&t.addIssue({code:"custom",path:["reason"],message:"reason is null exactly when the name is available"})}).describe("Whether a short name is free right now. Advisory; starting a community checks again.");de({idempotencyKey:Bd,name:$d,shortName:vn.optional().describe("The short name to give the community. Omitted means none."),orgId:rt.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 DS=de({communityId:rt,claimUrl:NS("The owner-claim link. A single-use credential: open it in the person`s own browser and never log it."),expiresAt:wt.describe("When the link stops working.")}).describe("A one-time link that makes a person the owner of a new community. Returned once.");de({community:Bo,claim:DS.nullable().describe("The owner-claim link, or null when this answer repeats an earlier request or the community is still provisioning."),replayed:Mt().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.");de({expectedHeldCommunityIds:xn(rt).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.");de({community:Bo,heldCommunityIds:xn(rt).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 OS=bn(["awaiting_upload","importing","ready","failed","cancelled","claimed"]).describe("Where a move is: waiting for the export, importing it, ready to claim, or finished."),MS=bn(["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."),_S=de({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."),zd=de({moveId:rt,communityId:rt.describe("The new community the export fills. It no longer exists once a move has failed or been cancelled."),communityUrl:Qn.describe("The new community`s canonical link. A runtime value."),name:Ce().min(1).max(80).describe("The name the new community was given."),state:Ss(OS).describe("Where the move is. A state this release does not know reads as unrecognised."),failureCode:Ss(MS).nullable().describe("Why the move failed. Always set when the state is failed. A code this release does not know reads as unrecognised."),report:_S.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:wt}).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.");Ld(zd,"A page of the caller`s moves: every unfinished one, and those that finished within the last 7 days, newest first.");de({idempotencyKey:Bd,name:$d,shortName:vn.optional().describe("The short name to give the new community. Omitted means none."),orgId:rt.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:Ce().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 PS=de({url:Qn.describe("Where to send the export. A runtime value."),token:SS.meta({description:"The upload bearer credential. Returned once; never log it.",[Fd]:!0}),expiresAt:wt.describe("When the upload window closes."),maxBytes:xe().int().positive().describe("The largest file the upload accepts."),parts:de({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."),Ud=Ce().regex(/^[a-f0-9]{64}$/,"must be a lower-case hex SHA-256 digest"),zo=1e4,LS=de({partNumber:xe().int().positive().max(zo).describe("The number of the part, counting up from one."),byteSize:xe().int().positive().describe("The size of the part, in bytes."),sha256:Ud.describe("The SHA-256 of the part, as lower-case hex.")}).describe("One part the Community server has received.");de({parts:xn(LS).max(zo).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.");de({parts:xe().int().positive().max(zo).describe("How many parts make up the file."),archiveBytes:xe().int().positive().describe("The size of the whole file, in bytes."),archiveSha256:Ud.describe("The SHA-256 of the whole file, as lower-case hex.")}).describe("Put the uploaded parts together into the declared file.");de({move:zd,upload:PS.nullable().describe("Where to send the export, or null when this answer repeats an earlier request."),replayed:Mt().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 FS=Qn.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."),$S=de({origin:FS}).describe("A Community server whose single sign-on is this account.");de({servers:xn($S).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 Kd(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 BS(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 zS(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 ar(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 Bn(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 Hd(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 Wd="Lower-case letters, numbers and single hyphens. 3 to 32 characters, starting with a letter.";function Xn(e){const t=e.trim().toLowerCase();return t===""?{value:t,valid:!0}:{value:t,valid:vn.safeParse(t).success}}const US=80,Gd="That web address is taken.",qd="That web address can’t be used.";function Yd(e){const t=ie(),{value:s,valid:r}=Xn(e),[o,a]=l.useState(s);l.useEffect(()=>{const d=setTimeout(()=>a(s),400);return()=>clearTimeout(d)},[s]);const i=Re({queryKey:ct.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 KS(){const e=l.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=he(),s=KS(),[r,o]=l.useState(!1),[a,i]=l.useState({field:null,notice:null});async function c(d){const u={name:d.name.trim(),...d.shortName?{shortName:d.shortName}:{}};o(!0),i({field:null,notice:null});try{const m=await e.startHostedCommunity({...u,idempotencyKey:s(u)});return m.ok?(t.invalidateQueries({queryKey:ct.list()}),{community:m.community}):("problem"in m&&m.problem.code==="community_name_taken"?i({field:Gd,notice:null}):"problem"in m&&m.problem.code==="community_name_reserved"?i({field:qd,notice:null}):i({field:null,notice:Pt(m)}),null)}catch{return i({field:null,notice:Lt}),null}finally{o(!1)}}return{submitting:r,failure:a,clearFieldFailure:()=>i(d=>({...d,field:null})),submit:c}}function WS(e){switch(e.state){case"awaiting_upload":{const t=e.upload;if((t==null?void 0:t.state)==="sending")return{kind:"uploading",move:e};if((t==null?void 0:t.state)==="sent")return{kind:"importing",move:e};const s=t===null?"restarted":t.failure==="interrupted"?"interrupted":t.failure==="rejected"?"refused":"expired";return{kind:"upload-failed",move:e,why:s}}case"importing":return{kind:"importing",move:e};case"ready":case"claimed":return{kind:"ready",move:e};case"failed":return{kind:"failed",move:e};case"cancelled":return{kind:"cancelled",move:e};default:return{kind:"unrecognised",move:e}}}function GS(e){return e.state==="awaiting_upload"||e.state==="importing"||e.state==="ready"}function qS(e){var E;const t=ie(),s=he(),[r,o]=l.useState(e),[a,i]=l.useState(null),[c,d]=l.useState({field:null,notice:null}),[u,m]=l.useState(!1),f=l.useRef(null),p=l.useRef(null),h=Re({queryKey:ct.move(r??""),queryFn:()=>t.getHostedCommunityMove(r),enabled:r!==null,refetchInterval:v=>{var R;const A=v.state.data;return(A==null?void 0:A.available)!==!0?!1:((R=A.move.upload)==null?void 0:R.state)==="sending"?1e3:A.move.pollAfterMs===null?!1:Math.max(1e3,A.move.pollAfterMs)}}),g=((E=h.data)==null?void 0:E.available)===!0?h.data.move:null,x=g?WS(g):null,b=l.useCallback(v=>{s.setQueryData(ct.move(v.moveId),{available:!0,move:v})},[s]);async function y(v){var O;const A={name:v.name.trim(),...v.shortName?{shortName:v.shortName}:{},file:[v.file.name,v.file.size,v.file.lastModified]},R=JSON.stringify(A);((O=p.current)==null?void 0:O.body)!==R&&(p.current={body:R,key:crypto.randomUUID()});const F=p.current.key,I=new AbortController;f.current=I,d({field:null,notice:null}),i({loaded:0,total:v.file.size});try{const C=await t.checkHostedCommunityMoveRoom(v.file.size,I.signal);if(I.signal.aborted)return;const j=C.ok?await t.startHostedCommunityMove(v.file,{idempotencyKey:F,name:A.name,...v.shortName?{shortName:v.shortName}:{}},w=>i(w),I.signal):C;(j.ok||j.mayExist!==!0)&&(p.current=null),j.ok?(b(j.move),o(j.move.moveId),s.invalidateQueries({queryKey:ct.list()})):"problem"in j&&j.problem.code==="community_name_taken"?d({field:Gd,notice:null}):"problem"in j&&j.problem.code==="community_name_reserved"?d({field:qd,notice:null}):d({field:null,notice:Pt(j)})}catch{I.signal.aborted?p.current=null:d({field:null,notice:Lt})}finally{f.current=null,i(null)}}async function k(){if(f.current){f.current.abort();return}if(r){m(!0);try{const v=await t.cancelHostedCommunityMove(r);v.ok?b(v.move):d({field:null,notice:Pt(v)}),s.invalidateQueries({queryKey:ct.list()})}catch{d({field:null,notice:Lt})}finally{m(!1)}}}async function S(){if(r){m(!0),d({field:null,notice:null});try{const v=await t.retryHostedCommunityMoveUpload(r);v.ok?b(v.move):d({field:null,notice:Pt(v)})}catch{d({field:null,notice:Lt})}finally{m(!1)}}}return{step:x,sending:a,failure:c,clearFieldFailure:()=>d(v=>({...v,field:null})),busy:u,start:y,cancel:k,sendAgain:S,startOver:()=>{o(null),d({field:null,notice:null})}}}function YS(){var a,i,c;const e=uc(),t=Mx(),s=Rl(t);if(!e||!t||s.isPending||((a=s.data)==null?void 0:a.available)===!1)return null;const r=((i=s.data)==null?void 0:i.available)===!0?s.data:null,o=(r==null?void 0:r.moves)??[];return{allowance:(r==null?void 0:r.allowance)??null,unfinishedMoveId:((c=o.find(GS))==null?void 0:c.moveId)??null}}const VS={message:"Your spaces changed. Check the list again."};function QS(){const e=ie(),t=he(),[s,r]=l.useState(null),[o,a]=l.useState(null),[i,c]=l.useState({});function d(m,f){c(p=>{const h={...p};return f?h[m]=f:delete h[m],h})}async function u(m,f){a(m),d(m,null);try{d(m,await f())}catch{d(m,Lt)}finally{a(null),await t.invalidateQueries({queryKey:ct.list()})}}return{confirmingKeep:s,busyId:o,notices:i,askKeep:r,cancelKeep:()=>r(null),keep:m=>u(m.communityId,async()=>{r(null);const f=await e.keepHostedCommunity(m.communityId,m.actions.keep.wouldHold);return f.ok?null:"problem"in f&&f.problem.code==="conflict"?VS:Pt(f)}),restore:m=>u(m.communityId,async()=>{const f=await e.restoreHostedCommunity(m.communityId);return f.ok?null:Pt(f)})}}function Uo({open:e,onOpenChange:t,step:s,locked:r}){return n.jsx(xt,{open:e,onOpenChange:o=>r&&!o?void 0:t(o),children:n.jsxs(bt,{className:"!min-h-0 sm:max-w-lg",children:[n.jsxs(ht,{children:[n.jsx(nt,{children:s.title}),s.description!==void 0&&n.jsx(ft,{children:s.description})]}),s.body!==void 0&&n.jsx(kt,{className:"space-y-4 py-2",children:s.body}),n.jsx(tn,{className:"gap-2 sm:gap-2",children:s.actions})]})})}function Kt({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(L,{type:"button",size:"sm",variant:"outline",onClick:()=>Ct(r),children:[o??"Open your account",n.jsx(sn,{className:"size-3.5","aria-hidden":!0})]})]})}function Ko(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(L,{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(Kt,{notice:t.notice}):void 0,actions:n.jsxs(n.Fragment,{children:[n.jsxs(L,{variant:t.opened?"outline":"default",disabled:t.busy,onClick:e.onOpenClaim,children:[t.opened?"Open it again":"Open in your browser",n.jsx(sn,{className:"size-3.5","aria-hidden":!0})]}),n.jsx(L,{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(Kt,{notice:t.notice})]}),actions:t.notice?n.jsx(L,{disabled:t.busy,onClick:e.onRetryConnect,children:"Connect again"}):n.jsxs(L,{disabled:t.busy||!t.approvalUrl,onClick:e.onOpenApproval,children:["Open approval page",n.jsx(sn,{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(Es,{className:"text-status-success-fg size-4","aria-hidden":!0}),"It’s selected in your spaces."]}),actions:n.jsx(L,{onClick:e.onClose,children:"Done"})}}}function XS(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=`${Bn(t.storageBytes)}${r!==null?` of ${Bn(r)}`:""} of files`;return`${o} · ${a}`}function JS({community:e,names:t,actions:s,onFinishSetup:r,onOpenMove:o}){const a=s.busyId===e.communityId,i=s.confirmingKeep===e.communityId,c=s.notices[e.communityId],d=XS(e),u=e.actions.keep.wouldHold.map(f=>t.get(f)??"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(Pn,{variant:m?"outline":"secondary",className:m?"border-status-warning-border text-status-warning-fg shrink-0":"shrink-0",children:BS(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:zS(e.hold.reason)}),n.jsxs("p",{className:"text-muted-foreground",children:["On hold since ",ar(e.hold.since),"."]}),e.hold.deletionNoticeAt&&n.jsxs("p",{className:"text-destructive",children:["DorkOS may delete it after ",ar(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 ",ar(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(L,{size:"sm",variant:"outline",onClick:()=>Ct(e.notice.actionUrl),children:[e.notice.actionLabel??"Learn more",n.jsx(sn,{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:u.length===0?`Keep ${e.name} open? Nothing else changes.`:`Keeping ${e.name} open puts ${u.length===1?"this one":"these"} on hold: ${u.join(", ")}. People can still read ${u.length===1?"it":"them"}.`}),n.jsxs("div",{className:"flex flex-wrap gap-2",children:[n.jsx(L,{size:"sm",variant:"outline",onClick:s.cancelKeep,children:"Cancel"}),n.jsx(L,{size:"sm",disabled:a,onClick:()=>void s.keep(e),children:"Keep it open"})]})]}),c&&n.jsx(Kt,{notice:c}),!i&&n.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.actions.claimLink&&n.jsx(L,{size:"sm",onClick:()=>r(e),children:"Finish setting up"}),e.moveId&&n.jsx(L,{size:"sm",variant:"outline",onClick:()=>o(e.moveId),children:"See the move"}),e.actions.keep.allowed&&n.jsx(L,{size:"sm",variant:"outline",disabled:a,onClick:()=>s.askKeep(e.communityId),children:"Keep this one open"}),e.actions.restore&&n.jsx(L,{size:"sm",variant:"outline",disabled:a,onClick:()=>void s.restore(e),children:a?"Reopening…":"Reopen"})]})]})}function ZS(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=Kd(e.failureCode??"unrecognised");return{text:t.title,next:t.next}}default:return{text:"Unknown state. Update DorkOS to see more."}}}function e0(e){const t=new Map(e.communities.map(s=>[s.communityId,s.name]));return n.jsxs("div",{className:"space-y-4",children:[e.allowanceText&&n.jsx("p",{className:"text-muted-foreground text-sm",children:e.allowanceText}),e.communities.length>0?n.jsx("ul",{className:"space-y-2",children:e.communities.map(s=>n.jsx(JS,{community:s,names:t,actions:e.actions,onFinishSetup:e.onFinishSetup,onOpenMove:e.onOpenMove},s.communityId))}):n.jsx("p",{className:"text-muted-foreground text-sm",children:"No spaces yet."}),e.moves.length>0&&n.jsxs("section",{"aria-labelledby":"hosted-moves",className:"space-y-2",children:[n.jsx("h4",{id:"hosted-moves",className:"text-sm font-medium",children:"Recent moves"}),n.jsx("ul",{className:"space-y-2",children:e.moves.map(s=>{const r=ZS(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(L,{size:"sm",variant:"outline",onClick:()=>e.onOpenMove(s.moveId),children:"Continue"})]},s.moveId)})})]})]})}function t0(e){return e.open?n.jsx(n0,{...e}):null}function n0({open:e,onOpenChange:t,installName:s,onOpenMove:r,onMoveHere:o,onConnected:a}){var h;const i=Rl(!0),c=QS(),[d,u]=l.useState(null),m=Fo(d,s,a),f=()=>t(!1);let p;if(d)p=Ko({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:f});else{const g=((h=i.data)==null?void 0:h.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(e0,{communities:g.communities,moves:g.moves,allowanceText:Hd(g.allowance),actions:c,onFinishSetup:u,onOpenMove:x=>{f(),r(x)}}):n.jsx(Kt,{notice:{message:"Couldn’t reach your DorkOS account. Try again."}}),actions:n.jsxs(n.Fragment,{children:[n.jsx(L,{variant:"outline",onClick:f,children:"Close"}),n.jsx(L,{variant:"outline",onClick:()=>{f(),o()},children:"Move one here"})]})}}return n.jsx(Uo,{open:e,onOpenChange:t,step:p})}function s0(e){switch(e.kind){case"invalid":return{text:Wd,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 Vd(e){const t=l.useId(),s=e.webAddressError?{text:e.webAddressError,error:!0}:s0(e.webAddressStatus);return n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{className:"space-y-1.5",children:[n.jsx(Ge,{htmlFor:`${t}-name`,children:"Space name"}),n.jsx(gt,{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(Ge,{htmlFor:`${t}-address`,children:["Web address ",n.jsx("span",{className:"text-muted-foreground font-normal",children:"(optional)"})]}),n.jsx(gt,{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)??Wd})]})]})}const r0="Your history is here. Send invitations so people can join again.";function o0(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(L,{variant:"outline",onClick:t,children:"Cancel"}),n.jsx(L,{onClick:e,children:"I have the file"})]})}}function a0({file:e,onFileChange:t}){const s=l.useId();return n.jsxs("div",{className:"space-y-1.5",children:[n.jsx(Ge,{htmlFor:s,children:"Export file"}),n.jsx(gt,{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,", ",Bn(e.size)]})]})}function i0(e){const t=Xn(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(a0,{file:e.file,onFileChange:e.onFileChange}),n.jsx(Vd,{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(Kt,{notice:e.failure.notice}),n.jsx(Io,{})]}),actions:n.jsxs(n.Fragment,{children:[n.jsx(L,{type:"button",variant:"outline",onClick:e.onBack,children:"Back"}),n.jsx(L,{type:"submit",form:e.formId,disabled:s,children:"Start moving"})]})}}function Qd({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(Ab,{value:r,"aria-label":e}),n.jsxs("p",{className:"text-muted-foreground text-sm tabular-nums",children:[Bn(t)," of ",Bn(s)]})]})}function c0(e,t){return{title:"Getting the file ready",description:"Keep this open. The upload then starts on its own.",body:n.jsx(Qd,{label:"Getting the file ready",...e}),actions:n.jsx(L,{variant:"outline",onClick:t,children:"Cancel"})}}function l0(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 d0(e,t){const{move:s}=e,r=t.notice?n.jsx(Kt,{notice:t.notice}):null,o=n.jsx(L,{variant:"outline",disabled:t.busy,onClick:t.onCancelMove,children:"Cancel move"}),a=n.jsx(L,{onClick:t.onStartOver,children:"Start again"}),i=n.jsx(L,{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(Qd,{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(L,{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=l0(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(L,{onClick:t.onClose,children:"Close"})]})}}case"failed":{const c=Kd(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 u0(e){return e.open?n.jsx(m0,{...e}):null}function m0({open:e,onOpenChange:t,installName:s,resumeMoveId:r,onConnected:o}){var E,v;const[a,i]=l.useState("explain"),[c,d]=l.useState(null),[u,m]=l.useState(""),[f,p]=l.useState(""),h=qS(r),g=Yd(a==="choose"&&!h.step?f:""),x=((E=h.step)==null?void 0:E.kind)==="ready"?h.step.move:null,b=Fo(x?{communityId:x.communityId,name:x.name,communityUrl:x.communityUrl}:null,s,o),y=()=>t(!1);function k(A){A.preventDefault();const R=Xn(f);!c||u.trim()===""||!R.valid||h.start({file:c,name:u,shortName:R.value})}let S;return h.sending?S=c0(h.sending,()=>void h.cancel()):((v=h.step)==null?void 0:v.kind)==="ready"?S=Ko({state:b.state,name:h.step.move.name,doneDetail:r0,onOpenClaim:b.openClaim,onConfirmClaimed:b.confirmClaimed,onOpenApproval:b.openApproval,onRetryConnect:b.retryConnect,onClose:y}):h.step?S=d0(h.step,{busy:h.busy,notice:h.failure.notice,onCancelMove:()=>void h.cancel(),onSendAgain:()=>void h.sendAgain(),onStartOver:()=>{h.startOver(),i("choose")},onClose:y}):a==="explain"?S=o0(()=>i("choose"),y):S=i0({file:c,onFileChange:d,name:u,onNameChange:m,webAddress:f,onWebAddressChange:A=>{p(A),h.clearFieldFailure()},webAddressStatus:g,failure:h.failure,formId:"move-community-form",onSubmit:k,onBack:()=>i("explain")}),n.jsx(Uo,{open:e,onOpenChange:t,step:S,locked:h.sending!==null})}function h0(e){const t=Xn(e.webAddress),s=e.name.trim()===""||!t.valid||e.webAddressStatus.kind==="taken"||e.webAddressStatus.kind==="reserved",r=Hd(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(Vd,{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(Kt,{notice:e.failure.notice}),n.jsx(Io,{})]}),actions:n.jsxs(n.Fragment,{children:[n.jsx(L,{type:"button",variant:"outline",onClick:e.onCancel,children:"Cancel"}),n.jsx(L,{type:"submit",form:e.formId,disabled:s||e.submitting,children:e.submitting?"Starting…":"Start space"})]})}}function f0(e){return e.open?n.jsx(p0,{...e}):null}function p0({open:e,onOpenChange:t,installName:s,allowance:r,onConnected:o}){const[a,i]=l.useState(""),[c,d]=l.useState(""),[u,m]=l.useState(null),f=HS(),p=Yd(u?"":c),h=Fo(u,s,o),g=()=>t(!1);async function x(y){y.preventDefault();const k=Xn(c);if(a.trim()===""||!k.valid||f.submitting)return;const S=await f.submit({name:a,shortName:k.value});S&&m({communityId:S.community.communityId,name:S.community.name,communityUrl:S.community.communityUrl})}const b=u?Ko({state:h.state,name:u.name,doneDetail:"Invite people from the space’s own settings when you’re ready.",onOpenClaim:h.openClaim,onConfirmClaimed:h.confirmClaimed,onOpenApproval:h.openApproval,onRetryConnect:h.retryConnect,onClose:g}):h0({name:a,webAddress:c,onNameChange:i,onWebAddressChange:y=>{d(y),f.clearFieldFailure()},webAddressStatus:p,submitting:f.submitting,failure:f.failure,allowance:r,formId:"start-community-form",onSubmit:y=>void x(y),onCancel:g});return n.jsx(Uo,{open:e,onOpenChange:t,step:b,locked:f.submitting})}function g0({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(f0,{open:(t==null?void 0:t.kind)==="start",onOpenChange:a,installName:r,allowance:e.allowance,onConnected:o}),n.jsx(u0,{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(t0,{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 x0=.1;function b0(e){if(!(e!=null&&e.available)||e.balance===null)return null;const{allowance:t,purchased:s,denomination:r}=e.balance,o=_x(t.remainingMicro,t.grantedMicro);if(o===null||o>=x0||!/^\d+$/.test(t.remainingMicro)||!/^\d+$/.test(s.remainingMicro)||BigInt(s.remainingMicro)>0n)return null;const a=Px(Lx(t.remainingMicro,r));return a===null?null:`${a} left`}function y0(e){if(e.state!=="loading")return e.state==="signed-out"?"Not signed in":["Signed in",e.label,e.lowCredits].filter(Boolean).join(" · ")}function v0(){var r;const e=Pc(),t=((r=e.data)==null?void 0:r.linked)===!0,s=Lc({enabled:t});return e.data===void 0?{state:"loading"}:t?{state:"signed-in",label:e.data.accountLabel,lowCredits:b0(s.data)}:{state:"signed-out"}}function w0(){const e=he();we("commands_changed",()=>{e.invalidateQueries({queryKey:["commands"]})})}function Xd(e){return e.kind==="agent"?zt("agent",e.agent.projectPath):zt("room",e.room.id)}function Pr(e){return e.kind==="agent"?Be(e.agent):e.room.kind==="channel"&&e.room.slug?`#${e.room.slug}`:e.room.title}function Ja(e){return`Chats ${e.kind==="agent"?"with":"in"} ${Pr(e)}`}function j0(e){return e.kind==="agent"?`No chats with ${Pr(e)} yet.`:`No chats came from ${Pr(e)}.`}function S0(e){return e.kind==="channel"&&e.slug?`#${e.slug}`:e.title}function k0(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=S0(r);t.has(o)||t.set(o,r.id)}return t}function C0(e,t){const s=[];e.cwd!==null&&s.push(zt("agent",e.cwd));const r=N0(e,t);return r!==void 0&&s.push(zt("room",r)),s}function N0(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 A0(e,t){const s=Number(e.archived)-Number(t.archived);if(s!==0)return s;const r=Number(on(t))-Number(on(e));return r!==0?r:t.lastActivityAt.localeCompare(e.lastActivityAt)||t.id.localeCompare(e.id)}function ir(e){return[...e].sort(A0)}function Lr(e){const t=[e.title];e.slug&&t.push(e.slug);for(const s of e.participants??[])t.push(s.displayName);return t}function E0(){const{data:e,isLoading:t,isError:s}=Ls({includeArchived:!0});return l.useMemo(()=>{const r=e??[],o=ir(r.filter(i=>i.kind==="channel")),a=ir(r.filter(i=>i.kind==="dm"));return{channels:o,dms:a,unread:ir([...o,...a].filter(i=>!i.archived&&on(i))),isLoading:t,isError:s}},[e,t,s])}const I0=8;function R0(e,t){const s=new Set(Ih(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 Za(e){const t=Date.parse(e.lastActivityAt);return Number.isNaN(t)?Number.NEGATIVE_INFINITY:t}function T0(e){return!(e.unreadCount===null||e.archived||e.lastActivityAt===e.createdAt)}function D0({sessions:e,rooms:t,unreadRoomIds:s,agents:r,agentActivity:o,excludeSessionIds:a=new Set,limit:i=I0}){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]:[])),u=t.filter(T0).map(g=>({kind:"room",key:`room:${g.id}`,lastActivityAt:g.lastActivityAt,room:g})),m=r.flatMap(g=>{if(d.has(g.projectPath))return[];const x=o[g.projectPath];return x?[{kind:"agent",key:`agent:${g.projectPath}`,lastActivityAt:x,agent:g}]:[]}),f=[],p=[];for(const g of[...c,...u,...m])g.kind==="room"&&s.has(g.room.id)?f.push(g):p.push(g);const h=(g,x)=>Za(x)-Za(g)||x.key.localeCompare(g.key);return[...f.sort(h),...p.sort(h)].slice(0,i)}const O0=50;function Jd(e){const t=[e.id];return e.who&&t.push(e.who),e.cwd&&t.push(e.cwd),t}function M0(e){return e?e.split("/").filter(Boolean).pop()??null:null}function ei(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?Be(i):M0(a),title:Fc(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 _0(e,t,s,r){const{data:o}=$c(O0),a=St(p=>p.statuses),i=St(Bc(p=>Object.values(p.sessions))),c=l.useMemo(()=>ei((o==null?void 0:o.sessions)??[],e,r),[o==null?void 0:o.sessions,e,r]),d=l.useMemo(()=>ei(i,e,r),[i,e,r]),u=l.useMemo(()=>[...i,...(o==null?void 0:o.sessions)??[]],[i,o]),m=l.useMemo(()=>{const p=new Map;for(const h of d)p.set(h.id,h);for(const h of c)p.has(h.id)||p.set(h.id,h);return R0(a,u).flatMap(h=>{const g=p.get(h.sessionId);return g?[{session:g,verb:Rh(h.lifecycle,h.activity),signal:h.lifecycle==="blocked"?"needs-you":"working"}]:[]})},[a,d,c,u]),f=l.useMemo(()=>{const p=new Set(Th((o==null?void 0:o.sessions)??[]).yours.map(h=>h.id));return D0({sessions:c.filter(h=>p.has(h.id)),rooms:t,unreadRoomIds:s,agents:e,agentActivity:(o==null?void 0:o.agentActivity)??{},excludeSessionIds:new Set(m.map(h=>h.session.id))})},[o,c,t,s,e,m]);return{sessions:c,continueRows:m,recent:f,agentActivity:(o==null?void 0:o.agentActivity)??P0}}const P0=Object.freeze({});function L0(){const{data:e,dataUpdatedAt:t}=$e(),s=e!==void 0&&t>an,{status:r,url:o}=Dh(e==null?void 0:e.tunnel),a=l.useRef(void 0);l.useEffect(()=>{if(!s)return;const i=a.current;a.current=r,!(i===void 0||i===r)&&(na.getState().consumeSuppression()||Oh(na.getState().report)||(r==="reconnecting"?ue.warning("Remote access is reconnecting",{id:"tunnel-status",description:"Your other devices can’t reach DorkOS until then."}):r==="off"?ue.error("Remote access turned off",{id:"tunnel-status",description:"Your other devices can’t reach DorkOS now."}):o&&ue.success("Remote access is on",{id:"tunnel-status",description:o})))},[s,r,o])}const mt={copyLink:"copyRemoteLink",showQr:"showRemoteQr",turnOn:"turnRemoteAccessOn",turnOff:"turnRemoteAccessOff"},Cn={copyLink:11,showQr:12,turnOff:13,turnOn:11};function F0(e,t,s){return(e==="connected"||e==="reconnecting"||e==="asleep")&&t?[{id:"remote-access-copy",label:"Copy remote link",icon:"Copy",action:mt.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:mt.showQr,category:"quick-action",priority:Cn.showQr,keywords:["remote","tunnel","scan","phone"]},{id:"remote-access-off",label:"Turn remote access off",icon:"Globe",action:mt.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:mt.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:mt.turnOn,category:"quick-action",priority:Cn.turnOn,keywords:["remote","tunnel","ngrok","phone","start"]}]:[]}function $0(){const{state:e,url:t,isSetUp:s}=zc();return l.useMemo(()=>F0(e,t,s),[e,t,s])}const B0=new Set(["discover","browse"]),es={usageKey:null,lastActivityAt:null,waiting:!1,demoted:!1,scopes:[]};function ti(e){return{usageKey:zt("room",e.id),lastActivityAt:e.lastActivityAt,waiting:on(e),demoted:e.archived,scopes:[]}}const z0=[];function U0(e,t){const{data:s,isLoading:r}=Fs(),o=E0(),{sessions:a}=Uc(),i=l.useMemo(()=>!a||!e?null:Mh(a,e)[0]??null,[a,e]),{data:c}=db(e,i==null?void 0:i.id,i==null?void 0:i.runtime),d=_s("command-palette.items"),u=lo(),m=l.useMemo(()=>u.map(j=>({id:j.id,label:j.title,href:bc(j.extensionId,j.path),icon:j.icon})),[u]),f=Hs(),p=l.useMemo(()=>{const j=new Set(_h(f).map(D=>D.id)),w=new Set(Ph.map(D=>D.id).filter(D=>!j.has(D)));return d.filter(D=>{if(D.category!=="feature")return!1;const T=Kc(D.action);return T===null||!w.has(T)})},[d,f]),h=$0(),g=f?z0:h,x=l.useMemo(()=>[...d.filter(j=>j.category==="quick-action"&&!(f&&B0.has(j.id))),...g],[d,g,f]),b=l.useMemo(()=>Lh.flatMap(j=>{const w=x.find(D=>D.id===j);return w?[w]:[]}),[x]),y=l.useMemo(()=>(s==null?void 0:s.agents)??[],[s]),k=l.useMemo(()=>new Set(o.unread.map(j=>j.id)),[o.unread]),S=l.useMemo(()=>[...o.channels,...o.dms],[o.channels,o.dms]),E=l.useMemo(()=>Fh(t),[t]),{sessions:v,continueRows:A,recent:R,agentActivity:F}=_0(y,S,k,E),I=l.useMemo(()=>k0(S),[S]),O=l.useMemo(()=>c?c.commands.map(j=>({name:j.fullCommand,description:j.description})):[],[c]),C=l.useMemo(()=>{const j=[];for(const w of y)j.push({id:w.id,name:w.name,type:"agent",keywords:[w.projectPath,w.id],usageKey:zt("agent",w.projectPath),lastActivityAt:F[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:Jd(w),usageKey:zt("session",w.id),lastActivityAt:w.lastActivityAt,waiting:!1,demoted:!1,scopes:C0(w,I),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 O)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:$h(w),type:"room",keywords:Lr(w),...ti(w),data:w});for(const w of o.dms)j.push({id:w.id,name:w.title,type:"dm",keywords:Lr(w),...ti(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},[y,F,v,O,p,x,o.channels,o.dms,I,m]);return{allAgents:y,newActions:b,rooms:o,sessions:v,continueRows:A,recent:R,searchableItems:C,isLoading:r}}function K0(){const e=_(a=>a.toggleGlobalPalette),t=_(a=>a.setGlobalPaletteOpen),s=_(a=>a.globalPaletteOpen),{close:r}=at(),{close:o}=fo();return l.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 Et(e){return Array.isArray?Array.isArray(e):eu(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 Fr(e){return e==null?"":H0(e)}function De(e){return typeof e=="string"}function ds(e){return typeof e=="number"}function W0(e){return e===!0||e===!1||G0(e)&&eu(e)=="[object Boolean]"}function Zd(e){return typeof e=="object"}function G0(e){return Zd(e)&&e!==null}function We(e){return e!=null}function ts(e){return!e.trim().length}function eu(e){return e==null?e===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(e)}const q0="Incorrect 'index' type",$r="Invalid doc index: must be a non-negative integer within the bounds of the docs array",Y0=e=>`Invalid value for key ${e}`,V0=e=>`Pattern length exceeds max of ${e}.`,Q0=e=>`Missing ${e} property in key`,X0=e=>`Property 'weight' in key '${e}' must be a positive integer`,J0="Fuse.match does not support useTokenSearch: token search requires corpus-level statistics (df, fieldCount) that a one-off string comparison does not have. Use new Fuse(...).search(...) instead.",ni=Object.prototype.hasOwnProperty;var Z0=class{constructor(e){this._keys=[],this._keyMap={};let t=0;e.forEach(s=>{const r=tu(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 tu(e){let t=null,s=null,r=null,o=1,a=null;if(De(e)||Et(e))r=e,t=si(e),s=us(e);else{if(!ni.call(e,"name"))throw new Error(Q0("name"));const i=e.name;if(r=i,ni.call(e,"weight")&&e.weight!==void 0&&(o=e.weight,o<=0))throw new Error(X0(us(i)));t=si(i),s=us(i),a=e.getFn??null}return{path:t,id:s,weight:o,src:r,getFn:a}}function si(e){return Et(e)?e:e.split(".")}function us(e){return Et(e)?e.join("."):e}function ek(e,t){const s=[];let r=!1;const o=(a,i,c,d)=>{if(We(a))if(!i[c])s.push(d!==void 0?{v:a,i:d}:a);else{const u=a[i[c]];if(!We(u))return;if(c===i.length-1&&(De(u)||ds(u)||W0(u)||typeof u=="bigint"))s.push(d!==void 0?{v:Fr(u),i:d}:Fr(u));else if(Et(u)){r=!0;for(let m=0,f=u.length;m<f;m+=1)o(u[m],i,c+1,m)}else i.length&&o(u,i,c+1,d)}};return o(e,De(t)?t.split("."):t,0),r?s:s[0]}const tk={includeMatches:!1,findAllMatches:!1,minMatchCharLength:1},nk={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},sk={location:0,threshold:.6,distance:100},rk={useExtendedSearch:!1,useTokenSearch:!1,tokenize:void 0,tokenMatch:"any",getFn:ek,ignoreLocation:!1,ignoreFieldNorm:!1,fieldNormWeight:1},Q=Object.freeze({...nk,...tk,...sk,...rk});function ok(e){return e>=9&&e<=13||e===32||e===160}function ak(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++)ok(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 Ho=class{constructor({getFn:e=Q.getFn,fieldNormWeight:t=Q.fieldNormWeight}={}){this.norm=ak(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(De(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($r);if(De(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($r);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!We(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(We(i)){if(Et(i)){const c=[];for(let d=0,u=i.length;d<u;d+=1){const m=i[d];if(We(m)){if(De(m)){if(!ts(m)){const f={v:m,i:d,n:this.norm.get(m)};c.push(f)}}else if(We(m.v)){const f=De(m.v)?m.v:Fr(m.v);if(!ts(f)){const p={v:f,i:m.i,n:this.norm.get(f)};c.push(p)}}}}s.$[r]=c}else if(De(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 nu(e,t,{getFn:s=Q.getFn,fieldNormWeight:r=Q.fieldNormWeight}={}){const o=new Ho({getFn:s,fieldNormWeight:r});return o.setKeys(e.map(tu)),o.setSources(t),o.create(),o}function ik(e,{getFn:t=Q.getFn,fieldNormWeight:s=Q.fieldNormWeight}={}){const{keys:r,records:o}=e,a=new Ho({getFn:t,fieldNormWeight:s});return a.setKeys(r),a.setIndexRecords(o),a}function ck(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 lk(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:u=Q.ignoreLocation}={}){if(t.length>32)throw new Error(V0(32));const m=t.length,f=e.length,p=Math.max(0,Math.min(r,f));let h=a,g=p;const x=(I,O)=>{const C=I/m;if(u)return C;const j=Math.abs(p-O);return o?C+j/o:j?1:C},b=c>1||d,y=b?Array(f):[];let k;for(;(k=e.indexOf(t,g))>-1;){const I=x(0,k);if(h=Math.min(I,h),g=k+m,b){let O=0;for(;O<m;)y[k+O]=1,O+=1}}g=-1;let S=[],E=1,v=0,A=m+f;const R=1<<m-1;for(let I=0;I<m;I+=1){let O=0,C=A;for(;O<C;)x(I,p+C)<=h?O=C:A=C,C=Math.floor((A-O)/2+O);A=C;let j=Math.max(1,p-C+1);const w=i?f:Math.min(p+C,f)+m,D=Array(w+2);D[w+1]=(1<<I)-1;for(let T=w;T>=j;T-=1){const P=T-1,$=s[e[P]];if(D[T]=(D[T+1]<<1|1)&$,I&&(D[T]|=(S[T+1]|S[T])<<1|1|S[T+1]),D[T]&R&&(E=x(I,P),E<=h)){if(h=E,g=P,v=I,g<=p)break;j=Math.max(1,2*p-g)}}if(x(I+1,p)>h)break;S=D}if(b&&g>=0){const I=Math.min(f-1,g+m-1+v);for(let O=g;O<=I;O+=1)s[e[O]]&&(y[O]=1)}const F={isMatch:g>=0,score:Math.max(.001,E)};if(b){const I=ck(y,c);I.length?d&&(F.indices=I):F.isMatch=!1}return F}function dk(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 Wo(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 su={ł:"l",Ł:"L",đ:"d",Đ:"D",ø:"o",Ø:"O",ħ:"h",Ħ:"H",ŧ:"t",Ŧ:"T",ı:"i",ß:"ss"},uk=new RegExp("["+Object.keys(su).join("")+"]","g"),zn=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(uk,t=>su[t]):e=>e;var Go=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:u=Q.ignoreLocation}={}){if(this.options={location:t,threshold:s,distance:r,includeMatches:o,findAllMatches:a,minMatchCharLength:i,isCaseSensitive:c,ignoreDiacritics:d,ignoreLocation:u},e=c?e:e.toLowerCase(),e=d?zn(e):e,this.pattern=e,this.chunks=[],!this.pattern.length)return;const m=(p,h)=>{this.chunks.push({pattern:p,alphabet:dk(p),startIndex:h})},f=this.pattern.length;if(f>32){let p=0;const h=f%32,g=f-h;for(;p<g;)m(this.pattern.substr(p,32),p),p+=32;if(h){const x=f-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?zn(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:u}=this.options,m=[];let f=0,p=!1;this.chunks.forEach(({pattern:g,alphabet:x,startIndex:b})=>{const{isMatch:y,score:k,indices:S}=lk(e,g,x,{location:o+b,distance:a,threshold:i,findAllMatches:c,minMatchCharLength:d,includeMatches:r,ignoreLocation:u});y&&(p=!0),f+=k,y&&S&&m.push(...S)});const h={isMatch:p,score:p?f/this.chunks.length:1};return p&&r&&(h.indices=Wo(m)),h}};const mk=new Set(["fuzzy","include"]);function hk(e){return e.startsWith("inverse")}const Br=[{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 Go(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)}}}}],ri=Br.length,fk="\0",pk="|";function gk(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 oi(e,t){const s=e.match(t);return s?s[1]:null}function xk(e,t={}){return e.replace(/\\\|/g,fk).split(pk).map(s=>{const r=gk(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,u=-1;for(;!d&&++u<ri;){const m=Br[u],f=oi(c,m.multiRegex);f&&(o.push(m.create(f,t)),d=!0)}if(!d)for(u=-1;++u<ri;){const m=Br[u],f=oi(c,m.singleRegex);if(f){o.push(m.create(f,t));break}}}return o})}var bk=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:u=Q.distance}={}){this.query=null,this.options={isCaseSensitive:t,ignoreDiacritics:s,includeMatches:r,minMatchCharLength:o,findAllMatches:i,ignoreLocation:a,location:c,threshold:d,distance:u},e=t?e:e.toLowerCase(),e=s?zn(e):e,this.pattern=e,this.query=xk(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?zn(e):e;let a=0;const i=[];let c=0,d=!1;for(let u=0,m=t.length;u<m;u+=1){const f=t[u];i.length=0,a=0,d=!1;for(let p=0,h=f.length;p<h;p+=1){const g=f[p],{isMatch:x,indices:b,score:y}=g.search(e);if(x)a+=1,c+=y,hk(g.type)&&(d=!0),s&&(mk.has(g.type)?i.push(...b):i.push(b));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=Wo(i)),p}}return{isMatch:!1,score:1}}};const zr=[];function qo(...e){zr.push(...e)}function ks(e,t){for(let s=0,r=zr.length;s<r;s+=1){const o=zr[s];if(o.condition(e,t))return new o(e,t)}return new Go(e,t)}const Cs={AND:"$and",OR:"$or"},Ur={PATH:"$path",PATTERN:"$val"},Kr=e=>!!(e[Cs.AND]||e[Cs.OR]),yk=e=>!!e[Ur.PATH],vk=e=>!Et(e)&&Zd(e)&&!Kr(e),ai=e=>({[Cs.AND]:Object.keys(e).map(t=>({[t]:e[t]}))});function ru(e,t,{auto:s=!0}={}){const r=o=>{if(De(o)){const d={keyId:null,pattern:o};return s&&(d.searcher=ks(o,t)),d}const a=Object.keys(o),i=yk(o);if(!i&&a.length>1&&!Kr(o))return r(ai(o));if(vk(o)){const d=i?o[Ur.PATH]:a[0],u=i?o[Ur.PATTERN]:o[d];if(!De(u))throw new Error(Y0(d));const m={keyId:us(d),pattern:u};return s&&(m.searcher=ks(u,t)),m}const c={children:[],operator:a[0]};return a.forEach(d=>{const u=o[d];Et(u)&&u.forEach(m=>{c.children.push(r(m))})}),c};return Kr(e)||(e=ai(e)),r(e)}function Hr(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 wk(e,{ignoreFieldNorm:t=Q.ignoreFieldNorm}){e.forEach(s=>{s.score=Hr(s.matches,{ignoreFieldNorm:t})})}var jk=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 Sk(e){const t=[];return e.matches.forEach(s=>{if(!We(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 kk(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=Sk(o)),r&&(i.score=o.score),i})}const Ck=/[\p{L}\p{M}\p{N}_]+/gu,ii=new WeakSet;function Nk(e){ii.has(e)||(ii.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 Ak(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||Nk(e),t=>t.match(e)||[]):t=>t.match(Ck)||[]}function Wr({isCaseSensitive:e=!1,ignoreDiacritics:t=!1,tokenize:s}={}){const r=Ak(s);return{tokenize(o){return e||(o=o.toLowerCase()),t&&(o=zn(o)),r(o)}}}var Ek=class{static condition(e,t){return t.useTokenSearch}constructor(e,t){this.options=t,this.analyzer=Wr({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 Go(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 u=0;u<this.termSearchers.length;u++){const m=this.termSearchers[u].searchIn(e),f=this.idfWeights[u];r+=f,m.isMatch&&(o++,s+=f*(1-m.score),m.indices&&t.push(...m.indices),this.combineAll&&(this.useMask?a|=1<<u:i.add(u)))}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=Wo(t)),this.combineAll&&(this.useMask?d.matchedMask=a:d.matchedTerms=i,d.termCount=this.numTerms),d}};function cr(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 ou(e,t,s,r){const{i:o,v:a,$:i}=t;if(a!==void 0){cr(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 u of d)cr(e,u.v,o,r);else cr(e,d.v,o,r)}}function Ik(e,t,s){const r={fieldCount:0,df:new Map,docFieldCount:new Map,docTermFieldHits:new Map};for(const o of e)ou(r,o,t,s);return r}function Rk(e,t,s,r){ou(e,t,s,r)}function Tk(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 ci(e,t){if(t.length===0)return;const s=Array.from(new Set(t)).sort((c,d)=>c-d);for(const c of s)Tk(e,c);const r=c=>{let d=0,u=s.length;for(;d<u;){const m=d+u>>>1;s[m]<c?d=m+1:u=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 It=class{constructor(e,t,s){this.options={...Q,...t},this.options.useExtendedSearch,this.options.useTokenSearch,this._keyStore=new Z0(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=ks(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 Ho))throw new Error(q0);if(this._myIndex=t||nu(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight}),this.options.useTokenSearch){const s=Wr({isCaseSensitive:this.options.isCaseSensitive,ignoreDiacritics:this.options.ignoreDiacritics,tokenize:this.options.tokenize});this._invertedIndex=Ik(this._myIndex.records,this._myIndex.keys.length,s)}this._invalidateSearcherCache()}add(e){if(!We(e))return;this._docs.push(e);const t=this._myIndex.add(e,this._docs.length-1);if(this._invertedIndex&&t){const s=Wr({isCaseSensitive:this.options.isCaseSensitive,ignoreDiacritics:this.options.ignoreDiacritics,tokenize:this.options.tokenize});Rk(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&&ci(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($r);this._invertedIndex&&ci(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(De(e)&&!e.trim()){let p=this._docs.map((h,g)=>({item:h,refIndex:g}));return ds(s)&&s>-1&&(p=p.slice(0,s)),p}const d=a&&ds(s)&&s>0&&De(e),u=i,m=(p,h)=>u(p,h)||p.idx-h.idx;let f;if(d){const p=new jk(s,m);De(this._docs[0])?this._searchStringList(e,{heap:p,ignoreFieldNorm:c}):this._searchObjectList(e,{heap:p,ignoreFieldNorm:c}),f=p.extractSorted()}else f=De(e)?De(this._docs[0])?this._searchStringList(e):this._searchObjectList(e):this._searchLogical(e),wk(f,{ignoreFieldNorm:c}),a&&f.sort(De(e)?m:u),ds(s)&&s>-1&&(f=f.slice(0,s));return kk(f,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:u})=>{if(!We(c))return;const m=r.searchIn(c);if(m.isMatch){const f={score:m.score,value:c,norm:u,indices:m.indices};o&&(f.matchedMask=m.matchedMask,f.matchedTerms=m.matchedTerms,f.termCount=m.termCount);const p=[f];if(!o||this._coversAllTokens(p)){const h={item:c,idx:d,matches:p};t?(h.score=Hr(h.matches,{ignoreFieldNorm:s}),t.insert(h)):i.push(h)}}}),i}_searchLogical(e){const t=ru(e,this.options),s=this._normalizedKeys(),r=(c,d,u)=>{if(!("children"in c)){const{keyId:h,searcher:g}=c;let x;return h===null?(x=[],s.forEach((b,y)=>{x.push(...this._findMatches({key:b,value:d[y],searcher:g}))})):x=this._findMatches({key:this._keyStore.get(h),value:this._myIndex.getValueForItemAtKeyId(d,h),searcher:g}),x&&x.length?[{idx:u,item:d,matches:x}]:[]}const{children:m,operator:f}=c,p=[];for(let h=0,g=m.length;h<g;h+=1){const x=m[h],b=r(x,d,u);if(b.length)p.push(...b);else if(f===Cs.AND)return[]}return p},o=this._myIndex.records,a=new Map,i=[];return o.forEach(({$:c,i:d})=>{if(We(c)){const u=r(t,c,d);u.length&&(a.has(d)||(a.set(d,{idx:d,item:c,matches:[]}),i.push(a.get(d))),u.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:u})=>{if(!We(d))return;const m=[];let f=!1,p=!1;if(i.forEach((h,g)=>{const x=this._findMatches({key:h,value:d[g],searcher:r});x.length?(m.push(...x),x[0].hasInverse&&(p=!0)):f=!0}),!(p&&f)&&m.length&&(!o||this._coversAllTokens(m))){const h={idx:u,item:d,matches:m};t?(h.score=Hr(h.matches,{ignoreFieldNorm:s}),t.insert(h)):c.push(h)}}),c}_findMatches({key:e,value:t,searcher:s}){if(!We(t))return[];const r=[];if(Et(t))t.forEach(({v:o,i:a,n:i})=>{if(!We(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}};It.version="7.5.0";It.createIndex=nu;It.parseIndex=ik;It.config=Q;It.match=function(e,t,s){if(s&&s.useTokenSearch)throw new Error(J0);return ks(e,{...Q,...s}).searchIn(t)};It.parseQuery=ru;qo(bk);qo(Ek);It.use=function(...e){e.forEach(t=>qo(t))};var Dk=It;const Ok=.02,au=.5,iu=.35,cu=.15,Mk=1+au+iu+cu,_k=4320*60*1e3,Pk=3,Lk=1440*60*1e3,Fk=.15,$k={lastUsedAt:null,useCount:0};function Yo(e){return!Number.isFinite(e)||e<0?0:e>1?1:e}function lu(e,t){return!Number.isFinite(e)||e<=0?1:Yo(Math.pow(2,-e/t))}function Bk(e,t){const s=e.lastUsedAt===null?0:lu(t-e.lastUsedAt,_k),r=Math.max(0,e.useCount),o=r===0?0:r/(r+Pk);return Yo((s+o)/2)}function zk(e,t){const s=e.distance===null?1:Yo(Math.pow(2,-Math.max(0,e.distance)/Ok)),r=Bk(e.usage,t),o=e.lastActivityAt===null?0:lu(t-e.lastActivityAt,Lk),a=1+(e.waiting?au:0)+iu*r+cu*o;return{score:s*a/Mk,signals:{relevance:s,frecency:r,recency:o}}}function Uk(e,t){return e.map(s=>{const{score:r,signals:o}=zk(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 Kk(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<Fk?{best:null,rest:s}:{best:r,rest:s.slice(1)}:{best:null,rest:s}}function Hk(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 Wk={keys:["name","keywords"],includeMatches:!0,includeScore:!0,threshold:.3,distance:100,minMatchCharLength:1};function Gk(e,t,s){const{usage:r,now:o,scope:a}=s,{prefix:i,term:c}=l.useMemo(()=>a===null?qk(t):{prefix:null,term:t},[t,a]),d=l.useMemo(()=>{if(a===null)return e;const x=Xd(a);return e.filter(b=>b.scopes.includes(x))},[e,a]),u=l.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=l.useMemo(()=>new Dk(u,Wk),[u]),f=l.useMemo(()=>{const x=(b,y,k)=>{const S=b.lastActivityAt===null?NaN:Date.parse(b.lastActivityAt);return{key:`${b.type}:${b.id}`,item:{item:b,matches:y},distance:k,usage:(b.usageKey===null?void 0:r[b.usageKey])??$k,lastActivityAt:Number.isNaN(S)?null:S,waiting:b.waiting,demoted:b.demoted}};return c?m.search(c).map(b=>x(b.item,b.matches,b.score??0)):u.map(b=>x(b,void 0,null))},[m,c,u,r]),p=l.useMemo(()=>Uk(f,o),[f,o]),{best:h,rest:g}=l.useMemo(()=>Kk(p,{queried:c.length>0}),[p,c]);return{bestMatch:h,rows:g,prefix:i,term:c}}function qk(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 Yk(){const e=po(),t=Bh();return l.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 Vk=/^\/([A-Za-z0-9][\w.-]*(?::[\w.-]+)*)(?=\s|$)\s*/;function Qk(e,t){const s=t.trim().replace(Vk,"").trim();return s?`${e} ${s}`:`${e} `}function Xk(e){const[t,s]=$s(),{setTheme:r,theme:o}=Ji(),a=Fe(),i=he(),c=ie(),d=En(w=>w.openFeedback),u=go(),{url:m}=zc(),{copy:f}=Kn({toastOnSettle:!0}),{open:p}=at(),{open:h}=fo(),g=oo(),x=_(w=>w.setPickerOpen),b=_(w=>w.setCanvasOpen),y=_(w=>w.setRightPanelOpen),k=_(w=>w.setActiveRightPanelTab),S=l.useCallback(w=>{xs.getState().recordOpened("agent",w)},[]),E=l.useCallback(w=>{s(w.projectPath,{onOpened:()=>{S(w.projectPath)}}),e()},[S,s,e]),v=Hc(),A=l.useCallback(w=>{xs.getState().recordOpened("room",w.id),e(),a({...je.channels(),search:{id:w.id}})},[e,a]),R=l.useCallback((w,D)=>{D&&S(D),e(),a(Ft({session:w,dir:D??void 0}))},[e,a,S]),F=l.useCallback(w=>{e(),zh({queryClient:i,transport:c},t).then(async D=>{if(D===null){sa(t);return}t&&S(t);const T=Uh.getState(),P=T.getSession(D.sessionId).input;T.updateSession(D.sessionId,{input:Qk(w,P)}),a(D.isNew?await Kh(c,{session:D.sessionId,dir:t??void 0}):Ft({session:D.sessionId}))}).catch(D=>{nc(c,D),sa(t)})},[e,a,i,c,t,S]),I=l.useCallback(w=>{e(),a({href:w})},[e,a]),O=l.useCallback(w=>{Hh(w)||console.warn(`[command-palette] no handler registered for action "${w}"`)},[]),C=l.useCallback(w=>{switch(e(),w){case"openTasks":h();return;case"openRelay":g();return;case"openMesh":a({...je.team()});return;case"openSettings":p();return;case"discoverAgents":en.getState().open();return;case"browseFilesystem":x(!0);return;case"openAgentProfile":k(Wh),y(!0);return;default:{const D=Kc(w);if(D){p(D);return}O(w);return}}},[e,a,h,g,p,x,k,y,O]),j=l.useCallback(w=>{switch(e(),w){case"navigateDashboard":a({...je.home()});return;case"newSession":v();return;case"openDevPlayground":_n("/dev");return;case"toggleDevtools":_.getState().toggleDevtools();return;case"toggleRouterDevtools":_.getState().toggleRouterDevtools();return;case"createAgent":Rs.getState().open();return;case"switchShape":_.getState().setShapeSwitcherOpen(!0);return;case"openControlCenter":_.getState().setControlCenterOpen(!0);return;case"toggleCanvas":b(!_.getState().canvasOpen);return;case"toggleTheme":r(o==="dark"?"light":"dark");return;case"openFeedback":d();return;case"openYourReports":a({...je.feedbackRequests()});return;case"openTasks":h();return;case"openRelay":g();return;case"openMesh":a({...je.team()});return;case"discoverAgents":en.getState().open();return;case"openSettings":p();return;case"browseFilesystem":x(!0);return;case mt.copyLink:m&&f(m);return;case mt.showQr:_.getState().setRemoteAccessBeaconOpen(!0);return;case mt.turnOn:u.start();return;case mt.turnOff:u.stop();return;default:O(w);return}},[e,a,O,r,o,b,x,h,g,p,d,f,u,m,v]);return{handleAgentSelect:E,startNewSession:v,handleFeatureAction:C,handleQuickAction:j,handleRoomSelect:A,handleSessionSelect:R,handleCommandSelect:F,handlePageSelect:I,recordAgentOpened:S,setDir:s,selectedCwd:t}}const li='[cmdk-item=""]:not([aria-disabled="true"])',Jk=new Set(["ArrowUp","ArrowDown","Home","End"]),Zk=new Set(["n","p","j","k"]);function eC({rootRef:e,activePage:t,onPin:s,resetKey:r}){const o=l.useRef(!1);l.useLayoutEffect(()=>{o.current=!1},[r]),l.useLayoutEffect(()=>{var u;if(o.current)return;const c=(u=e.current)==null?void 0:u.querySelector(`[data-palette-page="${CSS.escape(t)}"] ${li}`);if(!c||c.getAttribute("aria-selected")==="true")return;const d=c.getAttribute("data-value");d&&s(d)});const a=l.useCallback(c=>{c.nativeEvent.isComposing||c.keyCode===229||(Jk.has(c.key)||c.ctrlKey&&Zk.has(c.key))&&(o.current=!0)},[]),i=l.useCallback(c=>{c.target instanceof Element&&c.target.closest(li)&&(o.current=!0)},[]);return{onKeyDown:a,onPointerMove:i}}function tC({scope:e,className:t}){return n.jsx("span",{"data-testid":"palette-scope-chip",className:K("bg-accent text-accent-foreground inline-flex shrink-0 items-center gap-1.5 rounded-md px-1.5 py-0.5 text-xs font-medium",t),children:e.kind==="agent"?n.jsxs(n.Fragment,{children:[n.jsx(xo,{...bo(e.agent),size:"xs",badge:null}),Be(e.agent)]}):n.jsxs(n.Fragment,{children:[n.jsx(Wc,{room:e.room,participants:e.room.participants,size:"xs"}),n.jsx(Gc,{room:e.room})]})})}function nC(e){const t=e.trim();return t.length===0?null:t}function du(e,t){const s=l.useDeferredValue(e),{sessions:r}=Gh(t),{data:o}=Ob(s||null),a=l.useMemo(()=>r.slice(0,3).map(i=>({id:i.id,title:Fc(i.title),lastActive:i.updatedAt})),[r]);return{sessionCount:r.length,recentSessions:a,health:o??null}}function sC({agent:e}){const{sessionCount:t,recentSessions:s,health:r}=du(e.id,e.projectPath),{color:o,emoji:a}=bo(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(xo,{color:o,emoji:a,size:"sm",className:"shrink-0"}),n.jsx("span",{className:"truncate text-sm font-semibold",children:Be(e)})]}),n.jsx("p",{className:"text-muted-foreground truncate text-xs",children:qc(e.projectPath)}),n.jsxs("div",{className:"flex items-center gap-3 text-xs",children:[r&&n.jsx(Pn,{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 rC({agent:e,onOpenHere:t,onOpenNewTab:s,onOpenNewWindow:r,onNewSession:o,onBrowseSessions:a,onEditSettings:i,recentSessions:c,onSelectSession:d}){const u=Bt?"⌘":"Ctrl+";return n.jsxs(n.Fragment,{children:[n.jsxs(et,{heading:`${Be(e)} actions`,children:[n.jsxs(Ne,{value:"open-here",onSelect:t,children:[n.jsx(Ts,{className:"size-4"}),n.jsx("span",{children:"Open here"}),n.jsx(ka,{children:"Enter"})]}),n.jsxs(Ne,{value:"open-new-tab",onSelect:s,children:[n.jsx(Xb,{className:"size-4"}),n.jsx("span",{children:"Open in a new tab"}),n.jsxs(ka,{children:[u,"Enter"]})]}),r&&n.jsxs(Ne,{value:"open-new-window",onSelect:r,children:[n.jsx(Jy,{className:"size-4"}),n.jsx("span",{children:"Open in a new window"})]}),n.jsxs(Ne,{value:"new-session",onSelect:o,children:[n.jsx(At,{className:"size-4"}),n.jsx("span",{children:"New chat"})]}),a&&n.jsxs(Ne,{value:"browse-sessions",onSelect:a,children:[n.jsx(Zb,{className:"size-4"}),n.jsx("span",{children:"Browse chats…"})]}),n.jsxs(Ne,{value:"edit-settings",onSelect:i,children:[n.jsx(Bs,{className:"size-4"}),n.jsxs("span",{children:["Edit ",Be(e)," settings"]})]})]}),c.length>0&&n.jsx(et,{heading:"Recent chats",children:c.map(m=>n.jsxs(Ne,{value:m.id,onSelect:()=>d(m.id),children:[n.jsx(Is,{className:"size-4"}),n.jsx("span",{className:"truncate",children:m.title}),n.jsx("span",{className:"text-muted-foreground ml-auto text-xs",children:oC(m.lastActive)})]},m.id))})]})}function oC(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 vt="bg-muted rounded px-1 py-0.5 font-mono text-3xs";function aC({page:e,hasAgentSelected:t,canScope:s,isScoped:r}){const o=Bt?"⌘":"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:vt,children:"↑↓"}),"Navigate"]}),!e&&t&&n.jsxs("span",{className:"inline-flex items-center gap-1",children:[n.jsx("kbd",{className:vt,children:"Enter"}),"Open"]}),(!e&&t||e==="agent-actions")&&n.jsxs("span",{className:"inline-flex items-center gap-1",children:[n.jsxs("kbd",{className:vt,children:[o,"Enter"]}),"New tab"]}),e==="agent-actions"&&n.jsxs("span",{className:"inline-flex items-center gap-1",children:[n.jsx("kbd",{className:vt,children:"Enter"}),"Select"]}),e&&n.jsxs("span",{className:"inline-flex items-center gap-1",children:[n.jsx("kbd",{className:vt,children:"Backspace"}),"Back"]}),s&&n.jsxs("span",{className:"inline-flex items-center gap-1",children:[n.jsx("kbd",{className:vt,children:"Tab"}),"Search inside"]}),r&&n.jsxs("span",{className:"inline-flex items-center gap-1",children:[n.jsx("kbd",{className:vt,children:"Backspace"}),"Clear scope, at the start"]}),n.jsxs("span",{className:"ml-auto inline-flex items-center gap-1",children:[n.jsx("kbd",{className:vt,children:"esc"}),"Close"]})]})}const iC=[{key:"#",means:"channels"},{key:"@",means:"agents and DMs"},{key:">",means:"commands"}];function uu({className:e}){return n.jsx("div",{className:K("text-muted-foreground flex flex-wrap items-center gap-x-3 gap-y-1 px-3 py-2 text-xs",e),children:iC.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 cC({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 mu({agent:e,isActive:t,onSelect:s,nameIndices:r,isSelected:o}){return n.jsxs(Ne,{value:Be(e),keywords:[e.name,e.projectPath,e.id],onSelect:()=>s(),className:"relative py-2",forceMount:t?!0:void 0,children:[o&&n.jsx(re.div,{layoutId:"cmd-palette-selection",className:"bg-accent absolute inset-0 rounded-sm",transition:{duration:.15,ease:[0,0,.2,1]}}),n.jsx("div",{className:"relative z-10 w-full",children:n.jsx(ey,{agent:e,name:r?n.jsx(cC,{text:Be(e),indices:r,className:"truncate text-sm font-semibold"}):n.jsx("span",{className:"truncate text-sm font-semibold",children:Be(e)}),secondary:qc(e.projectPath),selected:t})})]})}function hu(){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 fu({room:e,onSelect:t}){const s=on(e);return n.jsxs(Ne,{value:e.id,keywords:Lr(e),onSelect:t,className:"flex items-center gap-2 py-2",children:[n.jsx(Wc,{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(Gc,{room:e,className:"min-w-0 flex-1 text-sm"}),e.archived&&n.jsx(hu,{}),s&&n.jsx("span",{className:"bg-brand/15 text-brand-text text-3xs shrink-0 rounded-full px-1.5 py-0.5 font-medium tabular-nums","aria-label":`${e.unreadCount} unread`,children:e.unreadCount})]})}const lC=6e4;function dC({lastActivityAt:e}){const t=yo(lC),s=l.useMemo(()=>Number.isNaN(Date.parse(e))?null:Gn(e),[e,t]);return s===null?null:n.jsx("span",{className:"text-muted-foreground text-2xs font-normal",children:s})}function Gr({item:e,live:t,isSelected:s=!1,onSelect:r}){const o=Yc(e.agent,e.cwd??e.id),a=qh(e.who,e.title),i=(t==null?void 0:t.verb)??null;return n.jsxs(Ne,{value:e.id,keywords:Jd(e),onSelect:r,title:a,className:K("flex gap-2 py-1.5",i!==null?"items-start":"items-center"),children:[n.jsx(xo,{color:o.color,emoji:o.emoji,size:"xs",className:K("shrink-0",i!==null&&"mt-px")}),n.jsxs("span",{className:"flex min-w-0 flex-1 flex-col",children:[n.jsxs("span",{"data-slot":"palette-session-line",className:"flex w-full items-center gap-1.5 text-sm",children:[e.who?n.jsxs(n.Fragment,{children:[n.jsx("span",{"data-slot":"palette-session-who",className:Yh,children:e.who}),n.jsx("span",{"aria-hidden":!0,className:"text-muted-foreground/60 flex-none",children:Vh})]}):null,n.jsx("span",{"data-slot":"palette-session-title",className:Qh,children:e.title}),n.jsxs("span",{className:K("flex items-center gap-1.5",Jh),children:[e.archived&&t===void 0&&n.jsx(hu,{}),n.jsx(Xh,{origin:e.origin,label:e.originLabel,className:"text-muted-foreground"}),n.jsx(dC,{lastActivityAt:e.lastActivityAt}),s&&n.jsx(uC,{canStartNewSession:e.cwd!==null})]})]}),i!==null&&n.jsxs("span",{className:"text-muted-foreground text-2xs flex items-center gap-1.5 font-normal",children:[t!==void 0&&n.jsx("span",{"aria-hidden":!0,className:K("size-1.5 shrink-0 rounded-full",Zh(t.signal))}),i]})]})]})}function uC({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 mC={session:"Conversations",agent:"Agents",room:"Channels",dm:"Direct messages",command:"Commands",feature:"Actions","quick-action":"Actions",page:"Add-ons"},hC="Best match",qr={Clock:mc,Radio:ty,Globe:ps,Settings:Bs,Plus:At,Search:fs,FolderOpen:Ts,Moon:gb,Shapes:tf,MessageSquarePlus:Vc,Inbox:ef},Ot=[0,0,.2,1],fC=[.4,0,1,1],pu={hidden:{opacity:0,scale:.96,y:-8},visible:{opacity:1,scale:1,y:0,transition:{duration:.2,ease:Ot}},exit:{opacity:0,scale:.96,y:-8,transition:{duration:.12,ease:fC}}},pC={hidden:{},visible:{transition:{staggerChildren:.035,delayChildren:.04}}},Dn={hidden:{opacity:0,y:-4},visible:{opacity:1,y:0,transition:{duration:.15,ease:Ot}}},lr=8;function gC({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(et,{heading:"Continue",children:e.map((u,m)=>n.jsx(re.div,{variants:m<lr?Dn:void 0,children:n.jsx(Gr,{item:u.session,live:{verb:u.verb,signal:u.signal},isSelected:o===u.session.id,onSelect:()=>a(u.session)})},u.session.id))}),t.length>0&&n.jsx(et,{heading:"Recent",children:t.map((u,m)=>n.jsxs(re.div,{variants:m<lr?Dn:void 0,children:[u.kind==="session"&&n.jsx(Gr,{item:u.session,isSelected:o===u.session.id,onSelect:()=>a(u.session)}),u.kind==="room"&&n.jsx(fu,{room:u.room,onSelect:()=>i(u.room)}),u.kind==="agent"&&n.jsx(mu,{agent:u.agent,isActive:u.agent.projectPath===r,isSelected:o===Be(u.agent),onSelect:()=>c(u.agent)})]},u.key))}),s.length>0&&n.jsxs(n.Fragment,{children:[(e.length>0||t.length>0)&&n.jsx(Yl,{}),n.jsx(et,{heading:"New",children:s.map((u,m)=>{const f=qr[u.icon];return n.jsx(re.div,{variants:m<lr?Dn:void 0,children:n.jsx(Ne,{value:u.label,onSelect:()=>d(u.action),children:n.jsxs(re.div,{whileHover:{x:2},transition:{duration:.1,ease:Ot},className:"flex w-full items-center gap-2",children:[f&&n.jsx(f,{className:"size-4"}),n.jsx("span",{children:u.label})]})})},u.id)})})]})]})}function di({row:e,selectedCwd:t,selectedValue:s,onFeatureAction:r,onQuickAction:o,onGoToAgentActions:a,onRoomSelect:i,onSessionSelect:c,onCommandSelect:d,onPageSelect:u}){var p;const{item:m,matches:f}=e.item;switch(m.type){case"session":return n.jsx(Gr,{item:m.data,isSelected:s===m.data.id,onSelect:()=>c(m.data)});case"agent":return n.jsx(mu,{agent:m.data,isActive:m.data.projectPath===t,isSelected:s===Be(m.data),onSelect:()=>a(m.data),nameIndices:(p=f==null?void 0:f.find(h=>h.key==="name"))==null?void 0:p.indices});case"room":case"dm":return n.jsx(fu,{room:m.data,onSelect:()=>i(m.data)});case"command":return n.jsx(Ne,{value:m.data.name,onSelect:()=>d(m.data.name),children:n.jsxs(re.div,{whileHover:{x:2},transition:{duration:.1,ease:Ot},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 h=qr[m.data.icon];return n.jsx(Ne,{value:m.data.label,onSelect:()=>r(m.data.action),children:n.jsxs(re.div,{whileHover:{x:2},transition:{duration:.1,ease:Ot},className:"flex w-full items-center gap-2",children:[h&&n.jsx(h,{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(Ne,{value:m.data.id,onSelect:()=>u(m.data.href),children:n.jsxs(re.div,{whileHover:{x:2},transition:{duration:.1,ease:Ot},className:"flex w-full items-center gap-2",children:[n.jsx(Hn,{icon:m.data.icon,className:"size-4"}),n.jsx("span",{children:m.data.label})]})});case"quick-action":{const h=qr[m.data.icon];return n.jsx(Ne,{value:m.data.label,onSelect:()=>o(m.data.action),children:n.jsxs(re.div,{whileHover:{x:2},transition:{duration:.1,ease:Ot},className:"flex w-full items-center gap-2",children:[h&&n.jsx(h,{className:"size-4"}),n.jsx("span",{children:m.data.label})]})})}}}function xC({term:e,isScoped:t=!1,onSelect:s}){return n.jsxs(Ne,{value:"search-messages-handoff",onSelect:s,className:"flex items-center gap-2 py-2",children:[n.jsx(Is,{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:Bt?"⌘⇧F":"Ctrl⇧F"})]})}const ui=8;function bC({staggerKey:e,isZeroQuery:t,isRoomMode:s,scope:r,hasQuery:o,selectedCwd:a,selectedValue:i,continueRows:c,recent:d,newActions:u,bestMatch:m,rows:f,rooms:p,searchHandoff:h,onFeatureAction:g,onQuickAction:x,onGoToAgentActions:b,onRoomSelect:y,onSessionSelect:k,onCommandSelect:S,onPageSelect:E}){const v=s?p.isError?"Couldn’t load your channels.":p.isLoading?"Loading channels…":p.channels.length===0?"No channels yet.":null:null,A=Hk(f,O=>r?Ja(r):mC[O.item.item.type]),R=r&&!o&&f.length===0&&!m?j0(r):null,F=new Set(f.slice(0,m?ui-1:ui).map(O=>O.key)),I={selectedCwd:a,selectedValue:i,onFeatureAction:g,onQuickAction:x,onGoToAgentActions:b,onRoomSelect:y,onSessionSelect:k,onCommandSelect:S,onPageSelect:E};return n.jsxs(re.div,{variants:pC,initial:"hidden",animate:"visible",children:[t&&n.jsx(gC,{continueRows:c,recent:d,newActions:u,selectedCwd:a,selectedValue:i,onSessionSelect:k,onRoomSelect:y,onGoToAgentActions:b,onQuickAction:x}),!t&&m&&n.jsx(et,{heading:hC,children:n.jsx(re.div,{variants:Dn,children:n.jsx(di,{row:m,...I})})}),!t&&A.map((O,C)=>n.jsx(et,{heading:O.label,children:O.rows.map(j=>n.jsx(re.div,{variants:F.has(j.key)?Dn:void 0,children:n.jsx(di,{row:j,...I})},j.key))},`${O.label}-${C}`)),R&&n.jsx(et,{heading:r?Ja(r):void 0,children:n.jsx(Ne,{disabled:!0,value:"scope-status",className:"text-muted-foreground text-sm",children:R})}),v&&n.jsx(et,{heading:"Channels",children:n.jsx(Ne,{disabled:!0,value:"rooms-status",className:"text-muted-foreground text-sm",children:v})}),h&&n.jsx(et,{children:n.jsx(xC,{term:h.term,isScoped:h.isScoped,onSelect:h.onSelect})}),t&&n.jsxs(n.Fragment,{children:[n.jsx(Yl,{}),n.jsx(uu,{})]})]},e)}function yC(e,t){const s=xb(),{dismissedIds:r}=Fl(),o=_(a=>a.promoEnabled);return l.useMemo(()=>o?bb(yb.filter(a=>a.placements.includes(e)),s,r,t):[],[e,t,s,r,o])}const vC={initial:{opacity:0,y:12},animate:{opacity:1,y:0},exit:{opacity:0,scale:.95,transition:{duration:.15}}};function wC({promo:e}){const{activate:t,dialog:s}=vb(e),{dismissPromo:r}=Fl(),o=ot(),a=e.content.icon;return n.jsxs(re.div,{variants:o?void 0:vC,layout:!o,className:"group/promo 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-visible:ring-sidebar-ring flex w-full items-center gap-2 rounded-md py-1.5 pr-7 pl-2 text-left outline-hidden transition-colors duration-150 focus-visible:ring-2",children:[n.jsx("span",{className:"flex size-[18px] shrink-0 items-center justify-center",children:n.jsx(a,{className:"size-4"})}),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(Dc,{className:"size-3.5 shrink-0 opacity-60"})]}),n.jsx("button",{type:"button",onClick:()=>r(e.id),"aria-label":"Dismiss",className:"text-sidebar-foreground/40 hover:text-sidebar-foreground focus-ring absolute top-1/2 right-1.5 -translate-y-1/2 rounded-md p-0.5 opacity-70 transition-[color,opacity] duration-150 group-hover/promo:opacity-100",children:n.jsx(Ke,{className:"size-3.5"})}),s]})}const jC=1;function SC(e){const[t]=yC(e,jC);return l.useMemo(()=>t===void 0?{id:"promo",show:!1,render:()=>null}:{id:`promo:${t.id}`,show:!0,render:()=>n.jsx(wC,{promo:t})},[t])}const kC=new Set(["downloading","downloaded","install-failed"]);function mi(e,t){return(e==null?void 0:e.state)==="install-failed"?t.state==="downloaded"&&Ro(t.version,e.version)?t:e:kC.has(t.state)||t.state==="error"?t:e&&(e.state==="downloading"||e.state==="downloaded")?e:t}function CC(){var o;const e=typeof window<"u"&&!!((o=window.electronAPI)!=null&&o.onUpdateStatus),[t,s]=l.useState(null);l.useEffect(()=>{var c;const a=window.electronAPI;if(!(a!=null&&a.onUpdateStatus))return;const i=a.onUpdateStatus(d=>{s(u=>mi(u,d))});return(c=a.getUpdateStatus)==null||c.call(a).then(d=>{d&&s(u=>mi(u,d))}),i},[]);const r=l.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 NC={darwin:Nr("/download/mac"),win32:Nr("/download/windows")},AC=Zr.site;function EC(){var t;const e=typeof window>"u"||(t=window.electronAPI)==null?void 0:t.platform;Ct((e&&NC[e])??AC)}function IC(){const{data:e}=$e(),{isDesktop:t,status:s,restart:r}=CC(),o=Vn(),a=e==null?void 0:e.version,i=(e==null?void 0:e.latestVersion)??null,c=l.useMemo(()=>(e==null?void 0:e.dismissedUpgradeVersions)??[],[e==null?void 0:e.dismissedUpgradeVersions]),d=l.useCallback(m=>{o.mutate({ui:{dismissedUpgradeVersions:[...c,m]}})},[c,o]),u=(e==null?void 0:e.serverRole)==="hub";return l.useMemo(()=>u?{kind:"none"}:t?(s==null?void 0:s.state)==="install-failed"?{kind:"desktop-install-failed",downloadFresh:EC}:(s==null?void 0:s.state)!=="downloaded"?{kind:"none"}:{kind:"desktop-restart",restart:r}:i!==null&&a!==void 0&&Ro(i,a)&&!c.includes(i)?{kind:"command",latestVersion:i,dismiss:()=>d(i)}:{kind:"none"},[u,t,s,r,i,a,c,d])}const RC="npm update -g dorkos",TC="The update couldn’t install itself. Download a fresh copy. Your settings and agents stay put.",dr="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 DC(e,t,s){return t?"Command copied":s?"Couldn’t copy":`Update ready: v${e}`}function OC({update:e}){const{copied:t,failed:s,copy:r}=Kn(),o=l.useCallback(()=>{r(RC)},[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:dr,children:[n.jsx(Db,{className:"size-3"}),"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:TC}),n.jsxs("button",{type:"button",onClick:e.downloadFresh,"aria-label":"Download a fresh copy of DorkOS",className:K(dr,"self-start"),children:[n.jsx(nf,{className:"size-3"}),"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:dr,children:[t?n.jsx(Gt,{className:"size-3"}):n.jsx(so,{className:"size-3"}),DC(e.latestVersion,t,s)]}),n.jsx("button",{type:"button",onClick:e.dismiss,"aria-label":"Dismiss update notification",className:"text-sidebar-foreground/50 hover:text-sidebar-foreground focus-ring rounded-md p-0.5 transition-colors duration-150",children:n.jsx(Ke,{className:"size-3"})})]})}function gu({model:e}){const{shouldShowGettingStarted:t,dismiss:s}=Yt(),r=t&&!e.gettingStartedPending,o=IC(),a=kw({gettingStartedCardShown:r}),i=Iw({gettingStartedCardShown:r}),c=Ed(),d=SC("dashboard-sidebar"),u=qn(),m=[{id:"getting-started",show:r,render:()=>n.jsx(Nw,{onDismiss:s})},{id:"update",show:o.kind!=="none",render:()=>n.jsx(OC,{update:o})},{id:"identity-prompt",show:a.visible,render:()=>n.jsx(Rw,{prompt:a})},{id:"profile-prompt",show:i.visible,render:()=>n.jsx(Aw,{prompt:i})},{id:"official-space-offer",show:c.due&&!r,render:()=>n.jsx(Il,{className:"bg-secondary/60 rounded-lg"})},{...d,show:d.show&&!c.pending}];return n.jsx(ub,{candidates:m,ready:u.settled})}const hi="dorkos-pinned-agents";function xu(){const{data:e}=$e(),t=vo(),{update:s}=yn(),r=t.pinned.length,o=l.useRef(!1);l.useEffect(()=>{if(o.current||e===void 0)return;const a=localStorage.getItem(hi);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(hi)},[e,r,s])}function bu(e){return l.useMemo(()=>sf(e),[e])}const MC=1800*1e3,Nn={finishedWhileAwayCount:0,idleWhileAwayCount:0};function fi(e){let t=null;for(const s of Object.values(e)){const r=Date.parse(s);Number.isNaN(r)||(t===null||r>t)&&(t=r)}return t}function _C(e,t,s,r){const o=new Set(t);let a=0;for(const i of e){if(o.has(i.id))continue;const c=Date.parse(i.updatedAt);Number.isNaN(c)||c>s&&c<=r&&(a+=1)}return a}function PC(e,t,s,r,o){const a=new Set(t);let i=0;for(const c of e){if(a.has(c.id))continue;const d=s[c.id];if(d==="streaming"||d==="blocked"||d==="error")continue;const u=Date.parse(c.updatedAt);Number.isNaN(u)||u<=r||u>o||o-u<MC||(i+=1)}return i}function LC(e){const{now:t,sessions:s,workingSessionIds:r,sessionStatuses:o,interactions:a,storedLastShownDate:i,settled:c}=e,d=Fx(),{update:u}=yn(),[m,f]=l.useState(null),p=l.useRef(!1);l.useEffect(()=>{!c||p.current||(p.current=!0,f({value:i}))},[c,i]);const h=m==null?void 0:m.value,[g]=l.useState(()=>fi(a)),x=fi(a),b=x!==null&&(g===null||x>g),y=l.useMemo(()=>b||!d.isAvailable||!d.enabled||d.maxPosts<=0||x===null||t-x<d.absenceThresholdMinutes*6e4?Nn:{finishedWhileAwayCount:_C(s,r,x,t),idleWhileAwayCount:PC(s,r,o,x,t)},[b,d.isAvailable,d.enabled,d.absenceThresholdMinutes,d.maxPosts,x,t,s,r,o]),k=rf(t),S=m!==null&&y.finishedWhileAwayCount>0&&h!==k,E=l.useRef(!1);return l.useEffect(()=>{!S||E.current||(E.current=!0,u(v=>of(v,k)))},[S,k,u]),{digest:y,lastShownDate:h}}function FC(e,t){const{update:s}=yn(),r=l.useMemo(()=>t?af(e).map(a=>a.target.kind==="suggestion"?a.target.suggestionId:null).filter(a=>a!==null):null,[e,t]),o=l.useRef(null);l.useEffect(()=>{const a=o.current;if(o.current=r,a===null||r===null)return;const i=a.filter(c=>!r.includes(c));i.length!==0&&s(c=>i.reduce((d,u)=>cf(d,u),c))},[r,s])}const $C={discoveredUnregisteredPaths:[],nonSystemAgentCount:1,hasEverStartedSession:!0,hasPostedInTeam:!0,hasDorkBotSession:!0};function BC(e){const{agents:t,agentActivity:s,sessionCount:r,rooms:o,rosterResolved:a}=e,i=io(c=>c.candidates);return l.useMemo(()=>{if(!a)return{facts:$C,isResolved:!1};const c=new Set(t.map(f=>f.path)),d=i.map(f=>f.path).filter(f=>!c.has(f)),u=t.find(f=>f.isSystem)??null,m=o.find(f=>f.wellKnown===lf);return{facts:{discoveredUnregisteredPaths:d,nonSystemAgentCount:t.filter(f=>!f.isSystem).length,hasEverStartedSession:r>0||Object.keys(s).length>0,hasPostedInTeam:(m==null?void 0:m.viewerHasPosted)??!0,hasDorkBotSession:u!==null&&s[u.path]!==void 0},isResolved:!0}},[t,s,r,o,a,i])}const zC=6e4,UC=[],KC={};function yu(e,t){const s=Nc(e),r=s.read();return r!==e&&!t(r,e)?(s.write(e),e):r}function HC(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 WC(e,t){return e.length===t.length&&t.every((s,r)=>e[r]===s)}function ns(e){return yu(e,HC)}function GC(e){return yu(e,WC)}function qC(e,t){const s=Le({select:h=>h.location.pathname}),r=pf(t,s),o=(r==null?void 0:r.extensionId)??null,a=(r==null?void 0:r.path)??null,i=to({strict:!1}),c=s==="/session"?i.session??null:null,d=gf(c),u=s==="/session"?(d==null?void 0:d.cwd)??i.dir??null:null,m=s==="/channels"?i.id??null:null,f=s==="/channels"||s==="/"?i.thread??null:null,p=m===null?null:e(m);return l.useMemo(()=>c!==null?{kind:"session",sessionId:c,agentPath:u??"",cwd:u}:o!==null&&a!==null?{kind:"add-on",extensionId:o,path:a}:m===null||p===null?null:f!==null?{kind:"room",roomId:m,roomKind:"thread",rootEntryId:f}:{kind:"room",roomId:m,roomKind:p},[c,u,o,a,m,p,f])}function vu(e={}){const{coveredSignalIds:t}=e,s=yo(zC),r=qn(),o=$c(df),a=l.useMemo(()=>{var z;return((z=o.data)==null?void 0:z.sessions)??[]},[o.data]),i=St(Bc(z=>{const te={};for(const[me,Se]of Object.entries(z.statuses))te[me]=Se.lifecycle;return te})),c=l.useMemo(()=>Object.entries(i).filter(([,z])=>z==="streaming").map(([z])=>z),[i]),d=St(l.useCallback(z=>z.statusCwds,[])),u=Ls(),m=l.useMemo(()=>{const z=u.data??[];return r.fleetKnown?z:z.filter(te=>te.kind!=="dm")},[u.data,r.fleetKnown]),f=uf(),p=l.useMemo(()=>f.data??[],[f.data]),h=po(),g=ns(l.useMemo(()=>{const z={};for(const[te,me]of Object.entries(h)){if(!te.startsWith("agent:"))continue;const Se=Date.parse(me);Number.isNaN(Se)||(z[te.slice(6)]=Se)}return z},[h])),b=Fs().data,y=GC(l.useMemo(()=>((b==null?void 0:b.agents)??[]).map(z=>z.projectPath),[b])),S=wo(y).data,{brokenPaths:E}=$x(),v=ns(Mb(y,E,g)),A=l.useMemo(()=>{var z;return((z=o.data)==null?void 0:z.agentActivity)??{}},[o.data]),R=r.fleetKnown?y:UC,F=l.useMemo(()=>R.map(z=>{const te=(S==null?void 0:S[z])??null,me=A[z],Se=me===void 0?NaN:Date.parse(me);return{path:z,runtime:(te==null?void 0:te.runtime)??"claude-code",namespace:(te==null?void 0:te.namespace)??null,isSystem:(te==null?void 0:te.isSystem)??!1,lastActivityAt:Number.isNaN(Se)?null:Se,lastInteractionAt:g[z]??null,attention:v[z]??"inactive"}}),[R,S,A,v,g]),I=l.useMemo(()=>Qc(R,S??{}),[R,S]),O=ns(l.useMemo(()=>{const z={};for(const te of a){const me=te.userLastMessageAt;me!==void 0&&(z[`session:${te.id}`]=me)}return z},[a])),C=ns(l.useMemo(()=>{const z={};for(const te of a){const me=te.lastTouchedByYouAt;me!==void 0&&(z[`session:${te.id}`]=me)}return z},[a])),j=vo(),w=l.useMemo(()=>Tv(j),[j]),D=LC({now:s,sessions:a,workingSessionIds:c,sessionStatuses:i,interactions:h,storedLastShownDate:w.digest.lastShownDate,settled:r.settled}),T=l.useMemo(()=>({...w,digest:{lastShownDate:D.lastShownDate}}),[w,D.lastShownDate]),P=l.useMemo(()=>mf(j.muted),[j.muted]),$=Cb({mutedRoomIds:P}),B=l.useMemo(()=>({items:$.items,automated:$.automated}),[$.items,$.automated]),Y=l.useMemo(()=>{const z=new Map;for(const te of m)z.set(te.id,te.kind==="dm"?"dm":"channel");return z},[m]),se=l.useMemo(()=>z=>Y.get(z)??"channel",[Y]),fe=lo(),G=l.useMemo(()=>fe.map(({id:z,extensionId:te,path:me,title:Se})=>({id:z,extensionId:te,path:me,title:Se})),[fe]),q=qC(se,G),{data:ee}=hf((q==null?void 0:q.kind)==="session"?q.sessionId:null),ce=l.useMemo(()=>ee?{kind:"room",roomId:ee.roomId,roomKind:"dm"}:q,[ee,q]),V=ff(z=>z.automatedExpanded),M=Xc(),X=BC({agents:F,agentActivity:A,sessionCount:a.length,rooms:m,rosterResolved:r.phase!=="cold"}),ae=l.useMemo(()=>({now:s,sessions:a,workingSessionIds:c,liveSessionCwds:d,sessionStatuses:i,rooms:m,threads:p,agents:F,displayNames:I,attention:M,recents:B,prefs:T,interactions:h,userLastMessageAt:O,lastTouchedByYouAt:C,mentions:KC,...t===void 0?{}:{coveredSignalIds:t},todayAutomatedExpanded:V,addOns:G,activeTarget:ce,journey:X.facts,digest:D.digest}),[t,s,a,c,d,i,m,p,F,I,M,B,T,h,O,C,V,G,ce,X.facts,D.digest]);return FC(ae,X.isResolved),ae}const YC="Heads up and Today fill themselves. Pin it to Library to keep it in place.",VC="Add-ons lists extension pages only.";function wu(e){return e==="addons"?VC:YC}const ju={channels:"Channels",dms:"Direct messages",agents:"Agents"};function pi(e){if(typeof e!="object"||e===null)return!1;const t=e.kind;if(t==="pinned")return!0;if(t==="ungrouped"){const s=e.section;return s===void 0||typeof s=="string"&&s in ju}if(t==="computed"){const s=e.zone;return s==="now"||s==="today"||s==="getting-started"||s==="addons"}return t==="group"&&typeof e.groupId=="string"}function QC(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 On(e){if(typeof e!="object"||e===null)return null;const t=e.type;if(t==="item"){const s=e.ref,r=e.container;return QC(s)&&pi(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 pi(s)?{type:"container",container:s}:null}return null}function Su(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 ku(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 Cu(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 Rn(e,t){return e.findIndex(s=>Jc(s,t))}function gi(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=Rn(o.items,r);i>=0&&(a=i)}return{kind:"move-to-group",ref:t,groupId:s,toIndex:a}}function Vo(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(u=>u.id===t.groupId),d=e.groups.findIndex(u=>u.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}=Cu(s);if(a.kind==="computed")return{kind:"reject-computed-zone",ref:r,zone:a.zone};if(o.kind==="pinned"){if(a.kind!=="pinned")return{kind:"unpin",ref:r};if(i===void 0)return{kind:"none"};const c=Rn(e.pinned,r),d=Rn(e.pinned,i);return c<0||d<0||c===d?{kind:"none"}:{kind:"reorder-pinned",ref:r,from:c,to:d}}if(o.kind==="group"){if(a.kind==="pinned")return{kind:"pin",ref:r};if(a.kind==="ungrouped")return{kind:"remove-from-group",ref:r};if(a.groupId!==o.groupId)return gi(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=Rn(c.items,r),u=Rn(c.items,i);return d<0||u<0||d===u?{kind:"none"}:{kind:"reorder-within-group",groupId:o.groupId,ref:r,from:d,to:u}}return a.kind==="pinned"?{kind:"pin",ref:r}:a.kind==="group"?gi(e,r,a.groupId,i):{kind:"none"}}function XC(e,t){switch(t.kind){case"none":case"reject-smart-group":case"reject-computed-zone":return e;case"reorder-group":return vf(e,t.from,t.to);case"pin":return yf(e,t.ref);case"unpin":return bf(e,t.ref);case"remove-from-group":return ra(e,t.ref,null);case"reorder-within-group":return oa(e,t.groupId,t.from,t.to);case"reorder-pinned":return xf(e,t.from,t.to);case"move-to-group":{const s=ra(e,t.ref,t.groupId);if(t.toIndex===null)return s;const r=s.groups.find(o=>o.id===t.groupId);return r?oa(s,t.groupId,r.items.length-1,t.toIndex):s}}}function JC(e,t,s){return XC(e,Vo(e,t,s))}function ZC(e,t){return e.type==="group"?`Picked up section ${t.groupName(e.groupId)}.`:`Picked up ${t.itemName(e.ref)}.`}function eN(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"pin":return`Pinned ${t.itemName(e.ref)}.`;case"unpin":return`Unpinned ${t.itemName(e.ref)}.`;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"reorder-pinned":return`Reordered ${t.itemName(e.ref)} in Pinned.`;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-zone":return`Can’t move ${t.itemName(e.ref)} there. ${wu(e.zone)}`;case"none":return""}}function tN(e,t){if(e===null)return"";const{container:s}=Cu(e);switch(s.kind){case"pinned":return"Over Pinned.";case"ungrouped":return`Over ${s.section===void 0?"Agents":ju[s.section]}.`;case"computed":return s.zone==="addons"?"Over Add-ons.":s.zone==="today"?"Over Today.":"Over Heads up.";case"group":return`Over ${t.groupName(s.groupId)}.`}}function nN(e){const t=r=>Su(On(r.active.data.current)),s=r=>{var o;return ku(On((o=r.over)==null?void 0:o.data.current))};return{onDragStart:r=>{const o=t(r);return o?ZC(o,e()):void 0},onDragOver:r=>{if(t(r))return tN(s(r),e())||void 0},onDragEnd:r=>{const o=t(r);if(!o)return;const a=e(),i=Vo(a.prefs,o,s(r));return i.kind==="none"?"Movement cancelled. Item returned to its place.":eN(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 sN({label:e}){const t=ot();return n.jsx(re.div,{initial:{scale:1},animate:{scale:t===!0?1:jf},transition:{duration:t===!0?0:wf},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})}const rN=60;function oN(e){const t=document.querySelectorAll(`[${aa}]`);for(const s of t)if(s.getAttribute(aa)===e)return s.querySelector(`[${Sf}]`);return null}function aN(e,t=rN){let s=t;const r=()=>{const o=oN(e);if(o!==null){o.focus();return}s-- >0&&requestAnimationFrame(r)};requestAnimationFrame(r)}const iN={start:["Space"],cancel:["Escape"],end:["Space","Enter","Tab"]};function cN(e,t){switch(t.kind){case"move-to-group":return Ys(t.groupId,t.ref);case"remove-from-group":return Ys("ungrouped",t.ref);case"unpin":{const s=e.groups.find(r=>r.items.some(o=>Jc(o,t.ref)));return Ys((s==null?void 0:s.id)??"ungrouped",t.ref)}default:return null}}function lN({data:e,itemName:t,groupName:s}){const r=e.type==="group"?s(e.groupId):e.type==="item"?t(e.ref):"";return n.jsx(sN,{label:r})}function dN({children:e,displayNames:t,rooms:s}){const r=Me(),o=vo(),{update:a}=yn(),[i,c]=l.useState(null),d=nn(o),u=nn(t),m=l.useMemo(()=>Object.fromEntries(s.map(k=>[k.id,k.slug??k.title])),[s]),f=nn(m),p=Ac(gs(Rc,{activationConstraint:{distance:8}}),gs(Ic,{coordinateGetter:Cr,keyboardCodes:iN}));if(r)return n.jsx(n.Fragment,{children:e});const h=k=>{var S;return((S=d.read().groups.find(E=>E.id===k))==null?void 0:S.name)??"group"},g=k=>k.kind==="agent"?u.read()[k.path]??k.path.split("/").pop()??"Agent":f.read()[k.roomId]??"room",x=nN(()=>({prefs:d.read(),itemName:g,groupName:h})),b=k=>{c(On(k.active.data.current))},y=k=>{var R;c(null);const S=Su(On(k.active.data.current));if(S===null)return;const E=ku(On((R=k.over)==null?void 0:R.data.current)),v=Vo(d.read(),S,E);if(v.kind==="reject-smart-group"){ue.info("Membership is rule-based. Edit rules instead.",{description:h(v.groupId)});return}if(v.kind==="reject-computed-zone"){ue.info(wu(v.zone),{description:g(v.ref)});return}if(v.kind==="none"||(a(F=>JC(F,S,E)),!(k.activatorEvent instanceof KeyboardEvent)))return;const A=cN(d.read(),v);A!==null&&aN(A)};return n.jsx(kf,{value:!0,children:n.jsxs(Ec,{sensors:p,collisionDetection:kc,accessibility:{announcements:x},onDragStart:b,onDragEnd:y,onDragCancel:()=>c(null),children:[e,n.jsx(Cf,{children:i?n.jsx(lN,{data:i,itemName:g,groupName:h}):null})]})})}function uN(){var r;const e=zs(!0),t=Wn();if(!t.community)return null;if(e.isPending)return n.jsx("p",{role:"status",className:"text-muted-foreground px-3 py-2 text-xs",children:"Loading space…"});if(e.isError)return n.jsxs("p",{role:"status",className:"text-muted-foreground px-3 py-2 text-xs",children:["Spaces could not be loaded."," ",n.jsx(L,{variant:"ghost",size:"sm",onClick:()=>void e.refetch(),children:"Retry"})]});const s=(r=e.data)==null?void 0:r.find(({ref:o})=>o===t.community);return s?s.status!=="connected"?n.jsx("p",{role:"status",className:"text-muted-foreground px-3 py-2 text-xs",children:"Reconnect this space to open its channels."}):n.jsx(mN,{connection:s}):n.jsx("p",{role:"status",className:"text-muted-foreground px-3 py-2 text-xs",children:"This space is no longer connected."})}function mN({connection:e}){var o,a,i;const t=Zc(e.access),s=Nf(e.ref,t.capabilities.read,t.fingerprint),r=Wn();return n.jsxs("section",{"aria-label":e.label,className:"px-2 py-2",children:[n.jsx("h3",{className:"text-muted-foreground px-2 text-xs font-medium",children:e.label}),!t.cacheReadable&&n.jsx("p",{role:"status",className:"text-muted-foreground px-2 py-1 text-xs",children:e.status==="reconnect-required"?"Reconnect to view channels.":"Channels aren’t available."}),t.cacheReadable&&!t.verified&&n.jsx("p",{role:"status",className:"text-muted-foreground px-2 py-1 text-xs",children:"Saved channels"}),t.verified&&s.isPending&&n.jsx("p",{role:"status",className:"text-muted-foreground px-2 py-1 text-xs",children:"Loading channels…"}),t.verified&&s.isError&&n.jsxs("p",{role:"status",className:"text-muted-foreground px-2 py-1 text-xs",children:["Space unavailable."," ",n.jsx(L,{variant:"ghost",size:"sm",onClick:()=>void s.refetch(),children:"Retry"})]}),((o=s.data)==null?void 0:o.stale)&&n.jsx("p",{className:"text-muted-foreground px-2 text-xs",children:"Saved channels · offline"}),(a=s.data)==null?void 0:a.rooms.filter(c=>!c.archived).map(c=>n.jsxs(el,{...je.channels(),search:{community:e.ref,id:c.roomId},"aria-current":r.community===e.ref&&r.id===c.roomId?"page":void 0,className:"hover:bg-accent aria-[current=page]:bg-accent flex min-h-9 items-center justify-between gap-2 rounded-md px-2 py-1 text-sm",children:[n.jsxs("span",{className:"truncate",children:["#",c.slug??c.title]}),c.unreadCount!==null&&c.unreadCount>0&&n.jsx("span",{className:"text-muted-foreground text-xs","aria-label":`${c.unreadCount} unread messages`,children:c.unreadCount})]},c.roomId)),((i=s.data)==null?void 0:i.rooms.length)===0&&n.jsx("p",{className:"text-muted-foreground px-2 py-1 text-xs",children:"No channels available."}),t.verified&&n.jsx(hN,{connection:e})]})}function hN({connection:e}){var o;const t=Zc(e.access),s=Af(e.ref,t.capabilities.read,t.fingerprint),r=Wn();return!((o=s.data)!=null&&o.available)||s.data.dms.length===0&&!s.data.incomplete?null:n.jsxs("section",{className:"mt-2","aria-label":"Direct messages",children:[n.jsx("h4",{className:"text-muted-foreground px-2 text-xs font-medium",children:"Direct messages"}),s.data.dms.map(a=>n.jsxs(el,{...je.channels(),search:{community:e.ref,id:a.roomId},"aria-current":r.community===e.ref&&r.id===a.roomId?"page":void 0,className:"hover:bg-accent aria-[current=page]:bg-accent flex min-h-9 items-center justify-between gap-2 rounded-md px-2 py-1 text-sm",children:[n.jsxs("span",{className:"truncate",children:[Ef(a),a.readOnly&&n.jsx("span",{className:"text-muted-foreground",children:" · read-only"})]}),!a.readOnly&&a.unreadCount>0&&n.jsx("span",{className:"text-muted-foreground text-xs","aria-label":`${a.unreadCount} unread messages`,children:a.unreadCount})]},a.roomId)),s.data.incomplete&&n.jsx("p",{role:"status",className:"text-muted-foreground px-2 py-1 text-xs",children:"Some direct messages couldn’t load."})]})}const fN=[2,3,3],xi=["w-14","w-10","w-16"];function pN(){return n.jsx("div",{className:"flex flex-col gap-1","data-testid":"sidebar-skeleton","aria-hidden":!0,children:fN.map((e,t)=>n.jsxs("div",{className:"flex flex-col",children:[n.jsx("div",{className:K("flex h-7 items-center",If),children:n.jsx(_t,{className:K("h-2.5 rounded-sm",xi[t])})}),Array.from({length:e},(s,r)=>n.jsx(Rf,{showIcon:!0},r))]},xi[t]))})}const gN=.16,xN=4,bN=.03,yN={hidden:{},shown:{transition:{staggerChildren:bN}}},vN={hidden:{opacity:0,y:xN},shown:{opacity:1,y:0}};function bi(e){return{duration:e===!0?0:gN}}const wN=2500;function yi(e){var t;return((t=e.zones.find(s=>s.id==="now"))==null?void 0:t.needsYouCount)??0}function jN(e){const t=ot(),[s,r]=l.useState(!1),o=l.useRef(yi(e)),a=yi(e),i=e.zones.some(c=>c.id==="now");return l.useEffect(()=>{const c=o.current;if(o.current=a,!(t!==!0&&c>0&&a===0&&!i)){r(!1);return}r(!0);const u=setTimeout(()=>r(!1),wN);return()=>clearTimeout(u)},[a,i,t]),s}function Nu(){const[e,t]=l.useState(!1),[s,r]=l.useState(!1),o=l.useCallback(()=>t(!0),[]),a=l.useCallback(()=>t(!1),[]),i=l.useCallback(()=>r(!0),[]),c=l.useCallback(()=>r(!1),[]);return{inside:e||s,handlers:{onPointerEnter:o,onPointerLeave:a,onFocus:i,onBlur:c}}}const vi=5e3;function SN(e){const{inside:t,handlers:s}=Nu(),r=e.zones.some(u=>u.id==="getting-started"),[o,a]=l.useState(r),i=l.useRef(null),c=l.useRef(!r);return l.useEffect(()=>{if(!r){c.current||(c.current=!0,i.current=Date.now(),a(!1));return}if(o||t)return;const u=i.current===null?Number.POSITIVE_INFINITY:Date.now()-i.current;if(u>=vi){c.current=!1,a(!0);return}const m=setTimeout(()=>{c.current=!1,a(!0)},vi-u);return()=>clearTimeout(m)},[r,o,t]),{model:l.useMemo(()=>!r||o?e:{...e,zones:e.zones.filter(u=>u.id!=="getting-started")},[e,r,o]),handlers:s}}const kN=1e3;function Au(e){const[t,s]=l.useState(""),r=l.useRef(t);return l.useEffect(()=>{const o=e??"";if(o===r.current)return;const a=setTimeout(()=>{r.current=o,s(o)},kN);return()=>clearTimeout(a)},[e]),t}function CN(){return n.jsxs("p",{"data-slot":"sidebar-all-clear",className:"text-sidebar-foreground/70 text-control flex min-h-7 items-center gap-1.5 px-2",children:[n.jsx(Gt,{className:"text-status-success size-3.5 shrink-0","aria-hidden":!0}),"All clear"]})}const NN=1,wi=40;function AN({onCommit:e,onCancel:t}){const[s,r]=l.useState(""),o=l.useRef(null),a=l.useRef(!1),i=Tf(o);l.useEffect(()=>{var u;(u=o.current)==null||u.focus()},[]);const c=()=>{if(a.current)return;a.current=!0;const u=s.trim();if(u.length<NN||u.length>wi){t();return}e(u)},d=u=>{u.key==="Enter"?(u.preventDefault(),c()):u.key==="Escape"&&(u.preventDefault(),a.current=!0,t())};return n.jsx(Df,{children:n.jsxs("div",{className:"flex w-full items-center gap-2 rounded-md px-2 py-1.5",children:[n.jsx(Of,{className:"text-muted-foreground size-3.5 shrink-0"}),n.jsx("input",{ref:o,value:s,maxLength:wi,placeholder:"Section name","aria-label":"New section name",onChange:u=>r(u.target.value),onKeyDown:d,onBlur:u=>{i.shouldHandleBlur(u)&&(a.current||t())},className:K("bg-background text-foreground placeholder:text-muted-foreground/50","focus-visible:ring-ring min-w-0 flex-1 rounded border px-1.5 py-0.5 text-xs outline-none focus-visible:ring-1")})]})})}function ms({zone:e,onToggleAll:t,allClear:s=!1,lead:r,silenceLiveRegion:o=!1}){const a=Au(e.liveRegionText);return n.jsxs("section",{"aria-label":e.label,"data-sidebar-zone":e.id,className:K("rounded-lg py-1",e.id==="now"||e.id==="getting-started"?"bg-sidebar-accent/40":void 0),children:[!o&&n.jsx("span",{"aria-live":"polite","aria-atomic":"true",className:"sr-only",children:a}),r,s?n.jsx(CN,{}):n.jsxs(n.Fragment,{children:[e.id==="library"&&e.sections.length>0&&n.jsx(EN,{}),e.sections.map(i=>n.jsx(tl,{section:i,onToggleAll:t},i.id))]})]})}function EN(){const e=Mf();return e.groupCreation===null?null:n.jsx(_f,{children:n.jsx(AN,{onCommit:e.commitNewGroup,onCancel:e.cancelNewGroup})})}const IN='[aria-current="page"]';function RN(e,t,s){const r=ot(),o=l.useRef(null);l.useLayoutEffect(()=>{var u,m;if(!s)return;const a=o.current===null,i=((u=o.current)==null?void 0:u.key)??null;if(o.current={key:t},!a&&(i===t||t===null)||t===null)return;const c=(m=e.current)==null?void 0:m.querySelector(IN);if(!(c instanceof HTMLElement))return;const d=!a&&r!==!0;c.scrollIntoView({block:"nearest",behavior:d?"smooth":"auto"})},[t,e,s])}function TN(e,t){const s=new Map(t.map((a,i)=>[a,i])),r=[],o=[];for(const a of e){const i=s.get(a.key);i===void 0?o.push(a):r.push({row:a,at:i})}return r.sort((a,i)=>a.at-i.at),[...r.map(a=>a.row),...o]}function DN(e,t){const{inside:s,handlers:r}=Nu(),[o,a]=l.useState(null),[i,c]=l.useState(s);i!==s&&(c(s),a(s?e.map(f=>f.key):null));const[d,u]=l.useState(t);return d!==t&&(u(t),a(s?e.map(f=>f.key):null)),{rows:o===null?[...e]:TN(e,o),handlers:r}}const ON="anchor:active-session";function MN({zone:e,onToggleAll:t,silenceLiveRegion:s=!1}){var f;const r=l.useRef(null),o=e.sections.find(p=>p.id==="today"),a=l.useMemo(()=>(o==null?void 0:o.rows)??[],[o]),i=((f=a.find(p=>p.reason===ON))==null?void 0:f.key)??null,c=DN(a,i),d=qn();RN(r,i,d.settled);const u=l.useMemo(()=>_N(a),[a]),m=l.useMemo(()=>({...e,sections:e.sections.map(p=>p.id==="today"?{...p,rows:c.rows}:p)}),[e,c.rows]);return n.jsx("div",{ref:r,...c.handlers,children:n.jsx(ms,{zone:m,onToggleAll:t,silenceLiveRegion:s,lead:n.jsx(PN,{roomIds:u})})})}function _N(e){const t=new Set;for(const s of e)s.unread.tier!=="none"&&s.target.kind==="room"&&t.add(s.target.roomId);return[...t]}function PN({roomIds:e}){const t=Me(),s=Pf();return!t||e.length===0?null:n.jsx(LN,{count:e.length,onCatchUp:()=>s(e)})}function LN({count:e,onCatchUp:t}){return n.jsx("div",{className:"px-2 pt-0.5 pb-1",children:n.jsxs("button",{type:"button","data-testid":"today-catch-up",onClick:t,"aria-label":`Catch up: mark ${e} unread ${e===1?"item":"items"} in Today as read`,className:K("text-sidebar-foreground/80 hover:bg-sidebar-accent/70 hover:text-sidebar-foreground focus-ring","text-control flex w-full items-center gap-2 rounded-md px-2 font-medium",Ff,Yn),children:[n.jsx(Lf,{className:"size-4 shrink-0","aria-hidden":!0}),"Catch up",n.jsx("span",{"data-slot":"catch-up-count",className:"text-sidebar-foreground/70 text-2xs ml-auto tabular-nums",children:e})]})})}const ji={id:"now",label:zf.now,sections:[],reason:"zone:now"};function FN(e){return e.collapsible?e.id.startsWith("group:")||sl(e.id)!==null:!1}function Yr({model:e,zoneIds:t,nowSlot:s=null,silenceLiveRegion:r=!1}){var F;const{update:o}=yn(),a=$f(),i=bs(a.destination),d=nl(i??void 0).visible?i:null,u=qn(),m=ot(),{model:f,handlers:p}=SN(e),h=e.zones.flatMap(I=>I.sections).filter(FN),g=l.useCallback(I=>t===void 0||t.includes(I),[t]),x=l.useCallback(()=>{if(h.length===0)return;const I=h.some(O=>!O.collapsed);o(O=>{let C=O;for(const j of h){if(j.id.startsWith("group:")){C=Bf(C,j.id.slice(6),I);continue}const w=sl(j.id);w!==null&&(C=ia(C,w,I))}return C})},[h,o]),b=g("library")?(F=e.zones.find(I=>I.id==="library"))==null?void 0:F.sections.find(I=>I.id==="addons"):void 0,y=(b==null?void 0:b.collapsed)??!1,k=l.useCallback(()=>o(I=>ia(I,"addons",!y)),[y,o]),S=jN(e),E=e.zones.some(I=>I.id==="now"),v=E||e.zones.some(I=>I.id==="getting-started"),A=s!==null&&!E&&g("now"),R={variants:vN,transition:bi(m)};return d?n.jsxs("div",{className:"flex min-h-0 flex-col","data-community-context":d,children:[n.jsx(uN,{}),b!==void 0&&n.jsx(tl,{section:b,onToggleAll:k})]}):n.jsx("div",{className:"flex flex-col gap-1",...p,children:n.jsx(tt,{mode:"wait",initial:!1,children:u.phase==="cold"?n.jsx(re.div,{exit:{opacity:0},transition:bi(m),children:n.jsx(pN,{})},"skeleton"):n.jsxs(re.div,{className:"flex flex-col gap-1",variants:yN,initial:u.startedWarm?!1:"hidden",animate:"shown",children:[A&&n.jsx(re.div,{...R,children:n.jsx(ms,{zone:ji,onToggleAll:x,lead:s,silenceLiveRegion:r})}),S&&!v&&!A&&g("now")&&n.jsx(re.div,{...R,children:n.jsx(ms,{zone:ji,onToggleAll:x,allClear:!0,silenceLiveRegion:r})}),f.zones.filter(I=>g(I.id)).map(I=>n.jsx(re.div,{...R,children:I.id==="today"?n.jsx(MN,{zone:I,onToggleAll:x,silenceLiveRegion:r}):n.jsx(ms,{zone:I,onToggleAll:x,silenceLiveRegion:r,...I.id==="now"?{lead:s}:{}})},I.id))]},"zones")})})}function $N(){xu();const e=vu(),t=bu(e),s=qn();return n.jsxs("nav",{"aria-label":"Sidebar","aria-busy":s.phase==="cold"?!0:void 0,className:"flex min-h-0 flex-1 flex-col",children:[n.jsx(Uf,{className:"sidebar-scroll-edges px-2 py-3",children:n.jsx(rl,{activeTarget:e.activeTarget,children:n.jsx(dN,{displayNames:e.displayNames,rooms:e.rooms,children:n.jsx(Yr,{model:t})})})}),n.jsx(gu,{model:t})]})}const BN=2;function zN(){return{label:"Active now",rules:{statuses:["needs-attention","active"]}}}function UN(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>=BN).map(([s,r])=>({runtime:s,count:r,label:lt(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 Si="agent:";function KN(){const[e]=$s(),t=po(),{data:s}=Fs(),r=l.useMemo(()=>((s==null?void 0:s.agents)??[]).map(i=>i.projectPath),[s]),{data:o}=wo(r),a=l.useMemo(()=>Qc(r,o??{}),[r,o]);return l.useMemo(()=>{const i=new Set(r);let c=null,d=-1/0;for(const[m,f]of Object.entries(t)){if(!m.startsWith(Si))continue;const p=m.slice(Si.length);if(!i.has(p))continue;const h=Date.parse(f);Number.isNaN(h)||h<=d||(d=h,c=p)}const u=e!==null&&i.has(e)?e:c;return u===null?null:{path:u,displayName:a[u]??u}},[a,t,r,e])}function HN(e){l.useEffect(()=>{if(!Ue())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 WN(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:Vc,opensInput:!1,...e.showSessionShortcut?{hint:$t(rn.NEW_SESSION)}:{},run:e.onNewSession},...e.lastUsedAgentName===null?[]:[{kind:"note",id:"new-session-note",icon:Ub,text:`Starts with ${e.lastUsedAgentName} (last used)`}],{kind:"separator",id:"sep-rooms"},{kind:"action",id:"new-channel",label:"Channel",icon:jo,opensInput:!0,run:e.onNewChannel},{kind:"action",id:"new-message",label:"Group message",icon:zl,opensInput:!0,run:e.onNewMessage},{kind:"separator",id:"sep-agents"},{kind:"action",id:"new-agent",label:"Agent",icon:Yf,opensInput:!0,run:e.onNewAgent},...s]}function GN(){const e=Me(),t=Jn(P=>P.menuOpen),s=Jn(P=>P.preselect),r=Jn(P=>P.setMenuOpen),o=Jn(P=>P.requestNewGroup),a=Fe(),i=Hc(),c=Lb(),d=Kf(),u=KN(),{update:m}=yn(),[f,p]=l.useState(!1),[h,g]=l.useState(!1),[x,b]=l.useState(!1),{data:y}=Fs(),k=l.useMemo(()=>((y==null?void 0:y.agents)??[]).map(P=>P.projectPath),[y]),{data:S}=wo(k),E=l.useMemo(()=>k.map(P=>{var $,B;return{projectPath:P,runtime:(($=S==null?void 0:S[P])==null?void 0:$.runtime)??"claude-code",namespace:((B=S==null?void 0:S[P])==null?void 0:B.namespace)??null,attention:"inactive",lastActivityAt:null}}),[k,S]),v=Hf(E),A=l.useMemo(()=>v?[zN(),...UN(E)]:[],[E,v]),R=l.useMemo(()=>{const P=new Map;for(const $ of E)P.has($.runtime)||P.set($.runtime,lt($.runtime).label);return Array.from(P,([$,B])=>({value:$,label:B})).sort(($,B)=>$.label.localeCompare(B.label))},[E]),F=l.useMemo(()=>{const P=new Set;for(const $ of E)$.namespace&&P.add($.namespace);return Array.from(P).sort()},[E]),I=l.useCallback((P,$)=>m(B=>Wf(B,P,$).next),[m]),O=l.useCallback(P=>{xs.getState().recordOpened("room",P.id),a({...je.channels(),search:{id:P.id}})},[a]),C=l.useCallback(()=>i(u==null?void 0:u.path),[u,i]);HN(C);const j=l.useCallback(P=>{const[$]=P;if($!==void 0&&Fb(P)){xs.getState().recordOpened("agent",$.agentPath),d({agentPath:$.agentPath});return}const B=Gf(P.map(Y=>Y.displayName));c.mutate({agentPaths:P.map(Y=>Y.agentPath),title:B},{onSuccess:O})},[d,O,c]),w=WN({onNewSession:C,lastUsedAgentName:(u==null?void 0:u.displayName)??null,onNewChannel:()=>p(!0),onNewMessage:()=>g(!0),onNewAgent:()=>Rs.getState().open(),onNewGroup:()=>o(),smartGroupPresets:A,onCreatePresetSmartGroup:P=>I(P.label,P.rules),onOpenSmartGroupDialog:()=>b(!0),showSessionShortcut:Ue()}),D=ol(w),T=l.useRef(null);return l.useEffect(()=>{if(!t||s===null)return;const P=requestAnimationFrame(()=>{var $,B;(B=($=T.current)==null?void 0:$.querySelector(`[data-menu-item-id="${s}"]`))==null||B.focus()});return()=>cancelAnimationFrame(P)},[t,s]),n.jsxs(n.Fragment,{children:[n.jsxs(Ds,{open:t,onOpenChange:r,children:[n.jsx(Os,{asChild:!0,children:n.jsxs("button",{type:"button","data-testid":"sidebar-new-button",className:K("bg-sidebar-accent text-sidebar-accent-foreground hover:bg-sidebar-accent/70 focus-visible:ring-sidebar-ring flex shrink-0 items-center gap-1 rounded-md px-2 py-1 text-xs font-medium outline-hidden transition-colors duration-150 focus-visible:ring-2",e&&K(Yn,"px-3")),children:[n.jsx(At,{className:"size-3.5"}),"New"]})}),n.jsx(Ms,{ref:T,align:"end",className:"w-56",onCloseAutoFocus:D.onCloseAutoFocus,children:n.jsx(Ar,{variant:"dropdown",nodes:D.nodes})})]}),f&&n.jsx($b,{open:!0,onOpenChange:P=>!P&&p(!1),onCreated:O}),n.jsx(Bb,{open:h,onOpenChange:g,onStart:j,hideTrigger:!0}),n.jsx(qf,{open:x,onOpenChange:b,mode:"create",runtimeOptions:R,namespaceOptions:F,onSubmit:({name:P,rules:$})=>I(P,$)})]})}function qN(){const e=_(s=>s.setGlobalPaletteOpen),t=Me();return n.jsxs("button",{type:"button","data-testid":"sidebar-search-pill",onClick:()=>e(!0),className:K("bg-sidebar-accent/40 text-sidebar-foreground/60 hover:bg-sidebar-accent/70 hover:text-sidebar-foreground focus-visible:ring-sidebar-ring text-control flex w-full items-center gap-1.5 rounded-md px-2 py-1.5 outline-hidden transition-colors duration-150 focus-visible:ring-2",t&&Yn),children:[n.jsx(fs,{className:"size-(--size-icon-sm) shrink-0"}),n.jsx("span",{className:"truncate",children:"Jump to anything…"}),n.jsx(al,{className:"bg-sidebar-accent text-sidebar-foreground/70 ml-auto shrink-0 border-transparent",children:$t(rn.COMMAND_PALETTE)})]})}function YN(e){const t=[];return e.you!==null&&t.push({kind:"action",id:"you",label:e.you.name,description:"View profile",icon:ao,leading:e.you.face,guardsFocus:!0,run:e.you.onOpen}),t.push({kind:"action",id:"dorkos-account",label:"DorkOS account",description:e.accountStatus,icon:Kl,guardsFocus:!0,run:e.onOpenAccount},{kind:"action",id:"settings",label:"Settings",icon:Bs,guardsFocus:!0,run:e.onOpenSettings}),t}function VN(e){return e.isDevMode?[{kind:"separator",id:"sep-version"},{kind:"note",id:"version",icon:ca,text:"Development build"}]:e.version===null?[]:[{kind:"separator",id:"sep-version"},{kind:"action",id:"version",label:`v${e.version} beta`,icon:ca,opensInput:!1,hint:"Check for updates",run:e.onCheckForUpdates}]}function QN(e){const t=(e==null?void 0:e.trim())??"";return t.length===0||t===Vf?"Your team":t.endsWith("s")?`${t}’ team`:`${t}’s team`}function XN(e,t){const s=Qf(e);return l.createElement(kr,{size:t,kind:s.kind,color:s.color,emoji:s.emoji,imageUrl:s.imageUrl,fallback:s.fallback,origin:s.origin})}function Eu(e="xs"){var i;const t=ro(),{open:s}=at(),{open:r}=So(),o=v0(),a=((i=t.data)==null?void 0:i.members.find(c=>c.isSelf))??null;return{you:a===null?null:{name:a.displayName,face:XN(a,e),onOpen:()=>r(a.id)},accountStatus:y0(o),onOpenAccount:()=>s("account"),onOpenSettings:()=>s()}}function JN(e=[]){var u;const t=ro(),s=ie(),r=he(),o=Eu(),a=((u=t.data)==null?void 0:u.members.find(m=>m.isSelf))??null,{data:i,refetch:c}=Re({queryKey:ze.current(),queryFn:()=>s.getConfig(),staleTime:rc}),d=l.useCallback(async()=>{var h,g;await r.invalidateQueries({queryKey:ze.all});const m=await c(),f=(h=m.data)==null?void 0:h.version,p=((g=m.data)==null?void 0:g.latestVersion)??null;if(f===void 0){ue.error("Couldn’t check for updates");return}if(p!==null&&Ro(p,f)){ue.success(`Version ${p} is available`);return}ue.success("You’re up to date")},[r,c]);return{teamName:QN((a==null?void 0:a.displayName)??null),nameUnknown:t.isPending,identityNodes:YN(o),nodes:[...e,...VN({version:(i==null?void 0:i.version)??null,isDevMode:(i==null?void 0:i.isDevMode)??!1,onCheckForUpdates:()=>void d()})]}}const ZN=il("/self-hosting/space-server");function eA(e){const t=[];for(const s of e)s.hostOperator===!0&&!t.includes(s.pinnedOrigin)&&t.push(s.pinnedOrigin);return t}function tA(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 ss(e){try{return new URL(e).host}catch{return e}}function nA(e){const t=[],s=e.selected;if(s){const{connection:i,availability:c}=s,d=[],u={host:ss(i.pinnedOrigin)};c.canInvite&&d.push({kind:"action",id:"community-invite",label:"Invite people",icon:Jf,external:u,run:e.onInvite}),c.canOpenSettings&&d.push({kind:"action",id:"community-settings",label:"Space settings",icon:Bs,external:u,run:e.onOpenSettings}),s.canMoveUp&&d.push({kind:"action",id:"community-move-up",label:"Move up",icon:Zf,run:()=>e.onMove("up")}),s.canMoveDown&&d.push({kind:"action",id:"community-move-down",label:"Move down",icon:ep,run:()=>e.onMove("down")}),d.push({kind:"separator",id:"community-sep-end"}),d.push({kind:"action",id:"community-disconnect",label:"Disconnect",icon:qb,opensInput:!0,destructive:!0,run:e.onDisconnect}),c.canLeave&&d.push({kind:"action",id:"community-leave",label:"Leave space",icon:tp,opensInput:!0,external:u,run:e.onLeave}),t.push({kind:"submenu",id:"community-actions",label:`Manage ${i.label}`,icon:Tr,items:d})}e.onJoinOfficial&&t.push({kind:"action",id:"join-official-space",label:"Join the DorkOS community",icon:Er,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-${ss(i)}`,label:e.creationOrigins.length===1?"Create a space on your server":`Create a space on ${ss(i)}`,icon:Gy,opensInput:!0,external:{host:ss(i)},run:()=>e.onCreate(i)})),{kind:"action",id:"add-community-deploy",label:"Run your own space server",icon:Xf,run:e.onDeploy}],a=[];return e.hosting&&a.push({kind:"action",id:"add-community-start",label:"Start a space",icon:ko,opensInput:!0,run:e.hosting.onStart}),a.push({kind:"action",id:"add-community-join",label:"Join a space",icon:Er,opensInput:!0,run:r}),e.hosting&&a.push({kind:"action",id:"add-community-yours",label:"Your spaces",icon:Ky,guardsFocus:!0,run:e.hosting.onOpenYourSpaces}),a.push({kind:"separator",id:"add-community-sep-advanced"},{kind:"submenu",id:"add-community-advanced",label:"Advanced",icon:Ul,items:o}),t.push({kind:"submenu",id:"add-community",label:"Add a space",icon:At,items:a}),t}function Iu(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 sA(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=Iu(e);if(s.membershipState!=="active")return s.membershipState.replace("-"," ");if(s.availability!=="online")return s.availability}function rA(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 oA(e){return e.charAt(0).toLowerCase()+e.slice(1)}function aA(e,t){const s=np(),r=nl(e),o=El();return{spaces:s.enabled,anySpace:s.anySpace,selectedRef:r.visible?e:void 0,visible:(t??[]).filter(a=>sp(a,s.enabled)),joinOfficial:o.link!==null&&!o.joined?o.join:null}}function iA(e){const t=la(r=>r.url),s=la(r=>r.take);l.useEffect(()=>{if(t===null)return;const r=s();r!==null&&e(r)},[t,s])}function cA({connection:e,onOpenChange:t,onDisconnected:s}){var p;const r=cl(),o=yd(e),[a,i]=l.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,u=d===void 0&&o.fetchStatus==="fetching",m=d?wd(c,d):u?null:jd(c);function f(){e&&r.mutate(e,{onSuccess:h=>{t(!1);const g=Sd(e.label,h);g.tone==="success"?ue.success(g.message):ue.warning(g.message,{duration:15e3}),s(e)}})}return n.jsx(rp,{open:e!==null,onOpenChange:h=>{h||r.reset(),t(h)},children:n.jsxs(op,{children:[n.jsxs(ap,{children:[n.jsxs(ip,{children:["Disconnect this DorkOS from ",c,"?"]}),n.jsx(cp,{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}),u&&n.jsx("p",{children:"Checking for agents you added from here…"})]})})]}),o.isError&&d===void 0&&!u&&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(L,{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(lp,{children:[n.jsx(dp,{disabled:r.isPending,children:"Keep connected"}),n.jsx(L,{variant:"destructive",disabled:r.isPending||u,onClick:f,children:r.isPending?"Disconnecting…":"Disconnect"})]})]})})}function lA(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 ${uA(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 ${up((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 dA(e){const t=typeof e=="object"&&e!==null?e.code:"";return t!=="COMMUNITY_RATE_LIMITED"&&t!=="COMMUNITY_UPGRADE_REQUIRED"}function uA(e){try{return`${new URL(e??"").origin}/your-space`}catch{return"https://example.com/acme"}}const mA="That invitation link is incomplete or isn’t secure. Copy the whole link again.";function hA(e){let t;try{t=new URL(e.trim())}catch{return!1}return/^\/(?:c\/[^/]+\/)?join\/?$/u.test(t.pathname)&&!Ir(e)}function fA(e){const t=new URL(e.trim()),s=/^(\/c\/[^/]+)\/join\/?$/u.exec(t.pathname);return s?`${t.origin}${s[1]}`:t.origin}function pA({request:e,onOpenChange:t,installName:s,onConnected:r}){var $;const o=Un(!0),a=zs(!0),i=mp(o),c=e!==null,d=Vs(B=>B.links),u=Vs(B=>B.rememberLink),m=Vs(B=>B.ending),f=(o==null?void 0:o.ownerKey)??null,[p,h]=l.useState(null),g=B=>h(B===null?null:{owner:f,ref:B}),[x,b]=l.useState(null),[y,k]=l.useState(null),[S,E]=l.useState((m==null?void 0:m.id)??0),[v,A]=l.useState(null),[R,F]=l.useState(null);e!==R&&(F(e),e&&(g(e.ref),b(null))),p!==null&&f!==null&&p.owner!==f&&(p.owner===null?h({owner:f,ref:p.ref}):(h(null),b(null),A(null)));const I=p!==null&&p.owner===f?p.ref:null,O=I===null||($=a.data)==null?void 0:$.find(B=>B.ref===I),C=!O&&y!==null&&!y.settled&&y.address===i&&y.connection.ref===I?y.connection:null,j=O??C;if(j&&f!==null&&((v==null?void 0:v.owner)!==f||v.ref!==j.ref||v.label!==j.label)&&A({owner:f,ref:j.ref,label:j.label}),m&&m.id!==S)E(m.id),m.ref===I&&m.outcome!=="connected"&&(g(null),b({address:i,value:m.outcome==="expired"?`Approval for ${m.label} expired. Connect again to continue.`:`Approval for ${m.label} was cancelled.`}));else if(c&&I!==null&&!j&&a.isSuccess){const B=(v==null?void 0:v.owner)===f&&v.ref===I?v.label:"this space";g(null),b({address:i,value:`Approval for ${B} ended somewhere else. Connect again to continue.`})}hp(c&&(j==null?void 0:j.status)==="pending"?j.ref:null);const w=fp((j==null?void 0:j.status)==="pending"?j:null),D=c&&(j==null?void 0:j.status)==="connected"?j.ref:null,T=l.useRef(r),P=l.useRef(t);return l.useEffect(()=>{T.current=r,P.current=t}),l.useEffect(()=>{D===null||!j||(ue.success(`${j.label} is connected.`,{id:`community-approval-${D}`}),P.current(!1),T.current(D))},[D]),n.jsx(xt,{open:c,onOpenChange:t,children:n.jsx(bt,{className:"!min-h-0 sm:max-w-md",children:n.jsx(gA,{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:B=>{u(i,B.connection.ref,B.approvalUrl),k({address:i,connection:B.connection,settled:!1}),g(B.connection.ref),b({address:i,value:`Next, approve this DorkOS on ${B.connection.label}.`})},onStartSettled:B=>k(Y=>(Y==null?void 0:Y.connection.ref)===B?{...Y,settled:!0}:Y),onEnded:B=>{g(null),b({address:i,value:B})},onCancelled:B=>{t(!1),ue.success(`Approval for ${B} was cancelled.`)},onClose:()=>t(!1)})})})}function gA({authority:e,connection:t,check:s,approvalUrl:r,notice:o,installName:a,initialUrl:i,onStarted:c,onStartSettled:d,onEnded:u,onCancelled:m,onClose:f}){const p=ie(),h=he(),g=Mc(),x=l.useId(),[b,y]=l.useState(i??""),[k,S]=l.useState(null),[E,v]=l.useState(!1),[A,R]=l.useState(a),F=l.useRef(null),I=l.useRef(null),O=t===null?"form":t.status,C=l.useRef(O);l.useEffect(()=>{var q,ee;const G=C.current;C.current=O,G!==O&&(O==="form"?(q=F.current)==null||q.focus():O==="pending"&&((ee=I.current)==null||ee.focus()))},[O]);const j=Ht({mutationFn:async G=>{if(!e||!Dt(e))throw new Error("Community owner is still loading.");const q=await p.startCommunityConnection({url:G,installName:A.trim()});if(!Dt(e))throw new Error("Community owner changed.");return q},onSuccess:async G=>{y(""),c(G),e&&await h.invalidateQueries({queryKey:jt.connections(e)}),d(G.connection.ref)}}),w=cl(),D=yd((t==null?void 0:t.status)==="reconnect-required"?t:null),T=j.error;l.useEffect(()=>{var G;(T||E)&&((G=F.current)==null||G.focus())},[T,E]);const P=Ir(b),$=E?mA:j.error?lA(j.error,j.variables):null;function B(G){if(G.preventDefault(),!(!b.trim()||j.isPending)){if(hA(b)){j.reset(),v(!0);return}if(Ir(b)){if(!Ct(g.linkFor(b.trim())))return;y(fA(b)),S({host:new URL(b.trim()).host,withAccount:g.signsInWithAccount(b)}),j.reset();return}A.trim()&&j.mutate(b.trim())}}function Y(G){w.mutate(G,{onSuccess:q=>{if(G.status==="pending")m(G.label);else{const ee=Sd(G.label,q);u(ee.tone==="success"?`${G.label} is disconnected. Connect again to continue.`:ee.message)}},onSettled:()=>{e&&h.invalidateQueries({queryKey:jt.connections(e)})}})}const se=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:B,children:[n.jsxs(ht,{children:[n.jsx(nt,{children:"Join a space"}),n.jsx(ft,{children:"Bring a space’s channels here. You approve it on the space’s site."})]}),n.jsxs(kt,{className:"space-y-4 py-4",children:[se,n.jsxs("div",{className:"space-y-1.5",children:[n.jsx(Ge,{htmlFor:`${x}-url`,children:"Space address or invitation link"}),n.jsx(gt,{ref:F,id:`${x}-url`,type:"url",inputMode:"url",placeholder:"https://example.com/acme","aria-describedby":$?`${x}-url-hint ${x}-url-error`:`${x}-url-hint`,"aria-invalid":E||j.error&&dA(j.error)?!0:void 0,required:!0,autoComplete:"off",value:b,onChange:G=>{y(G.target.value),S(null),v(!1)},disabled:j.isPending||!e}),n.jsx("p",{id:`${x}-url-hint`,"aria-live":"polite",className:"text-muted-foreground text-xs",children:k?k.withAccount?`Join on ${k.host} with your DorkOS account in the new tab, then connect.`:`Finish joining on ${k.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(Ge,{htmlFor:`${x}-name`,children:"Name for this installation"}),n.jsx(gt,{id:`${x}-name`,required:!0,maxLength:120,"aria-describedby":`${x}-name-hint`,value:A,onChange:G=>R(G.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."})]}),$&&n.jsx("p",{id:`${x}-url-error`,role:"alert",className:"text-destructive text-sm",children:$})]}),n.jsxs(tn,{children:[n.jsx(L,{type:"button",variant:"outline",onClick:f,children:"Cancel"}),n.jsx(L,{type:"submit",disabled:j.isPending||!b.trim()||!P&&(!e||!A.trim()),children:j.isPending?"Connecting…":P?"Open invitation":"Connect"})]})]});const fe=n.jsx("p",{className:"text-muted-foreground text-xs break-all",children:t.pinnedOrigin});if(t.status==="reconnect-required"){const G=!D.data&&D.fetchStatus==="fetching",q=D.data?wd(t.label,D.data.agents):G?null:jd(t.label);return n.jsxs(n.Fragment,{children:[n.jsxs(ht,{children:[n.jsxs(nt,{children:["Reconnect ",t.label]}),n.jsxs(ft,{children:["DorkOS can’t reach ",t.label,"’s channels. Disconnect, then connect again."]})]}),n.jsxs(kt,{className:"space-y-3 py-4",children:[fe,q&&n.jsx("p",{className:"text-sm",children:q}),D.isError&&!D.data&&!G&&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(L,{size:"sm",variant:"outline",onClick:()=>void D.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(tn,{children:[n.jsx(L,{type:"button",variant:"outline",onClick:f,children:"Close"}),n.jsx(L,{disabled:w.isPending||G,onClick:()=>Y(t),children:w.isPending?"Disconnecting…":"Disconnect"})]})]})}return n.jsxs(n.Fragment,{children:[n.jsxs(ht,{children:[n.jsxs(nt,{children:["Approve on ",t.label]}),n.jsx(ft,{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(kt,{className:"space-y-3 py-4",children:[fe,se,n.jsxs("p",{className:"flex items-center gap-2 text-sm",children:[n.jsx(Oe,{})," Waiting for your approval"]}),r?n.jsx(L,{asChild:!0,children:n.jsxs("a",{ref:I,href:g.linkFor(r),target:"_blank",rel:"noopener noreferrer",children:["Open ",t.label," to approve",n.jsx(sn,{className:"size-3.5","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(L,{size:"sm",variant:"outline",onClick:s.retry,disabled:s.isFetching,children:"Check approval"})]})]}),n.jsxs(tn,{children:[n.jsx(L,{type:"button",variant:"outline",onClick:f,children:"Close"}),n.jsx(L,{variant:"outline",disabled:w.isPending,onClick:()=>Y(t),children:w.isPending?"Cancelling…":"Cancel approval"})]})]})}function xA(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 ki({sheet:e,label:t="Actions",children:s}){return e?n.jsx("div",{role:"menu","aria-label":t,tabIndex:-1,onKeyDown:xA,children:s}):n.jsx(n.Fragment,{children:s})}function ur(){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 bA({trigger:e,selectedRef:t}){const s=ie(),r=Me(),o=Fe(),a=Le({select:h=>h.location}),i=l.useRef(!1),c=l.useRef(!1),[d,u]=l.useState(null);function m(h,g){var b;if(!r||(h||(c.current=!1),g))return;if(h){const y=ur();gp({cancelled:y.acted}).finally(y.stop);return}const x=document.activeElement;(x===null||x===document.body)&&((b=e.current)==null||b.focus())}async function f(h){if(h.ref===t||i.current||h.status!=="connected")return;const g=da();if(g.ownerKey===null)return;const x={epoch:g.epoch,ownerKey:g.ownerKey},b={pathname:a.pathname,search:a.search};c.current=r;const y=ur();i.current=!0,u(h.ref);let k=!1,S=null;try{await o({...je.channels(),search:{community:h.ref}}),k=!0,S=Fn();const E=await s.resolveCommunityNavigation(h.ref),v=E?null:(await s.listRemoteCommunityRooms(h.ref)).rooms.find(R=>R.readable&&!R.archived)??null,A=(E==null?void 0:E.roomId)??(v==null?void 0:v.roomId);if(!Dt(x)||!S.isCurrent()){m(!1,y.acted());return}A&&await o({...je.channels(),search:{community:h.ref,...A?{id:A}:{},...E!=null&&E.threadId?{thread:E.threadId}:{}}}),m(!0,y.acted())}catch{m(!1,y.acted()),k&&(S==null?void 0:S.isCurrent())===!0&&Dt(x)&&await o({to:b.pathname,search:b.search,replace:!0}).then(()=>!0,()=>!1)&&ue.error(`Couldn’t open ${h.label}.`,{description:"You’re still where you were. Try again in a moment."})}finally{y.stop(),i.current=!1,u(null)}}async function p(){if(t===void 0||i.current)return;const h=da();if(h.ownerKey===null)return;const g={epoch:h.epoch,ownerKey:h.ownerKey},x=Fn();c.current=r;const b=ur();i.current=!0;try{const y=await s.getCommunityNavigation();if(y.ownerKey!==g.ownerKey||!Dt(g)||!x.isCurrent()){m(!1,b.acted());return}const k=pp.safeParse(y.installationDestination);await o(k.success?{to:k.data.path,search:k.data.search}:{...je.home()}),m(!0,b.acted())}catch{const y=Dt(g)&&x.isCurrent();y&&await o({...je.home()}),m(y,b.acted())}finally{b.stop(),i.current=!1}}return{pendingRef:d,isSelecting:()=>i.current,holdCloseFocus:()=>{c.current=!0},takeCloseFocusHold:()=>{const h=c.current;return c.current=!1,h},selectCommunity:f,selectInstallation:p}}function yA(e){const t=l.useRef(e);l.useEffect(()=>{t.current=e},[e]),l.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 Ru({triggerClassName:e,compact:t=!1}){var _e;const s=Me(),r=Fe(),o=Le({select:H=>H.location.search.community}),a=xp(),i=bp(),c=zs(),{spaces:d,anySpace:u,selectedRef:m,visible:f,joinOfficial:p}=aA(o,c.data),h=l.useMemo(()=>{var H;return rA(f,((H=a.data)==null?void 0:H.order)??[])},[f,(_e=a.data)==null?void 0:_e.order]),g=h.find(H=>H.ref===m)??null,x=l.useRef(null),b=l.useRef(null),y=l.useRef(null),{pendingRef:k,isSelecting:S,holdCloseFocus:E,takeCloseFocusHold:v,selectCommunity:A,selectInstallation:R}=bA({trigger:y,selectedRef:m}),[F,I]=l.useState(""),[O,C]=l.useState(!1),[j,w]=l.useState(null),[D,T]=l.useState(null),P=YS(),[$,B]=l.useState(null),Y=m?h.findIndex(H=>H.ref===m):-1;function se(H,pe){Ct(new URL(kp(H.remoteCommunityId,pe),H.pinnedOrigin).toString())}const fe=nA({selected:g?{connection:g,availability:tA(g),canMoveUp:Y>0,canMoveDown:Y>=0&&Y<h.length-1}:null,onMove:H=>{g&&i.mutate({ref:g.ref,direction:H})},onInvite:()=>g&&se(g,"community"),onOpenSettings:()=>g&&se(g),onLeave:()=>g&&se(g,"account"),onDisconnect:()=>T(g),onJoin:d?()=>w({ref:null}):null,onJoinOfficial:p,creationOrigins:d?eA(h):[],onCreate:H=>Ct(new URL(Sp,H).toString()),onDeploy:()=>Ct(ZN),hosting:d&&P?{onStart:()=>B({kind:"start"}),onOpenYourSpaces:()=>B({kind:"hosted"})}:null}),G=u?fe:[];iA(H=>w({ref:null,url:H}));const q=JN(G),ee=ol([...q.identityNodes,...q.nodes]),ce=ee.nodes.slice(0,q.identityNodes.length),V=ee.nodes.slice(q.identityNodes.length),M=$e().data,X=(M==null?void 0:M.serverRole)==="hub",ae=X?"Private":q.teamName,z=M===void 0||!X&&q.nameUnknown,te=X?ys:Qy,me=q.nameUnknown?"My DorkOS":q.teamName,Se=m!==void 0&&c.data===void 0,Je=m===void 0?z:Se,ne=m===void 0?ae:(g==null?void 0:g.label)??"Space",Ae=s&&h.length>=8&&F.trim().length>0?h.filter(H=>H.label.toLocaleLowerCase().includes(F.trim().toLocaleLowerCase())):h;yA(H=>{b.current=H,C(!0)});function it(H){if(S())return;if(b.current=null,H==="installation"){R();return}const pe=h.find(ke=>`community:${ke.ref}`===H);if(pe){if(pe.status==="connected"){A(pe);return}E(),w({ref:pe.ref})}}function dt(H){C(H),H||I("")}function Ee(H){if(ee.onCloseAutoFocus(H),v()){H.preventDefault();return}const pe=b.current;b.current=null,!(H.defaultPrevented||!(pe!=null&&pe.isConnected))&&(H.preventDefault(),pe.focus())}l.useEffect(()=>{if(!O)return;const H=requestAnimationFrame(()=>{var pe;return(pe=x.current)==null?void 0:pe.focus()});return()=>cancelAnimationFrame(H)},[O]);async function be(H){var Pe;const ke=(Pe=(await c.refetch()).data)==null?void 0:Pe.find(Ye=>Ye.ref===H&&Ye.status==="connected");ke&&await A(ke)}function yt(H){bs(Fn().destination)===H.ref&&r({...je.home(),replace:!0})}return n.jsxs(n.Fragment,{children:[n.jsxs(yp,{open:O,onOpenChange:dt,children:[n.jsx(vp,{asChild:!0,children:n.jsxs("button",{ref:y,type:"button","data-testid":"sidebar-header-block","aria-label":Je?"Context menu":`${ne} menu`,"aria-busy":k!==null||void 0,title:X&&m===void 0?"Just you and your agents":void 0,className:e,children:[t?m===void 0?n.jsx(te,{className:"size-4 shrink-0","aria-hidden":!0}):n.jsx(Tr,{className:"size-4 shrink-0","aria-hidden":!0}):Je?n.jsx(_t,{className:"my-[3px] h-3.5 w-24 rounded-sm","data-testid":"sidebar-team-name-skeleton"}):n.jsxs(n.Fragment,{children:[X&&m===void 0&&n.jsx(ys,{className:"size-3.5 shrink-0","aria-hidden":!0}),n.jsx("span",{className:"truncate",children:ne})]}),n.jsx(qt,{className:t?"size-3 shrink-0 opacity-50":"size-3.5 shrink-0 opacity-50","aria-hidden":!0}),n.jsx("span",{className:"sr-only",children:"Choose context"})]})}),n.jsxs(wp,{align:"start",className:"max-h-(--radix-dropdown-menu-content-available-height) w-64 overflow-y-auto",onCloseAutoFocus:Ee,children:[s&&n.jsx(ua,{children:u?"Switch context":"Menu"}),n.jsx(ki,{sheet:s,label:"You",children:n.jsx(Ar,{variant:s?"sheet":"dropdown",nodes:ce,onSheetClose:()=>dt(!1)})}),u&&n.jsx(ma,{}),u&&!s&&n.jsx(ua,{children:"Switch context"}),u&&s&&h.length>=8&&n.jsx("div",{className:"px-4 pb-2",children:n.jsx(gt,{type:"search",value:F,onChange:H=>I(H.target.value),placeholder:"Find a space","aria-label":"Find a space"})}),u&&n.jsxs(jp,{value:m?`community:${m}`:"installation",onValueChange:it,children:[n.jsx(ha,{value:"installation",icon:te,disabled:k!==null,itemRef:m===void 0?x:void 0,className:k!==null?"opacity-50":void 0,children:n.jsxs("span",{className:"min-w-0 flex-1 truncate",children:[ae,X&&n.jsx("span",{className:"text-muted-foreground block truncate text-xs",children:"Just you and your agents"})]})}),Ae.map(H=>{var Ie;const pe=Iu(H),ke=pe.mentionCount??0,Pe=Math.max(0,(pe.unreadCount??0)-ke),Ye=[ke>0?`${ke} ${ke===1?"mention":"mentions"}`:null,Pe>0?`${Pe} other unread`:null,((Ie=H.attention)==null?void 0:Ie.state)==="stale"?`last checked ${oA(Gn(H.attention.verifiedAt))}`:null].filter(Boolean).join(", ");return n.jsx(ha,{value:`community:${H.ref}`,icon:Tr,disabled:k!==null,itemRef:H.ref===m?x:void 0,description:[sA(H),Ye].filter(Boolean).join(" · ")||void 0,className:k!==null?"opacity-50":void 0,children:n.jsxs("span",{className:"flex min-w-0 items-center gap-1.5",children:[n.jsx("span",{className:"min-w-0 truncate",children:H.label}),Wb(H)&&n.jsx("span",{role:"img",className:"bg-status-warning-dot size-2 shrink-0 rounded-full","aria-label":"Someone asked to take over this space",title:"Someone asked to take over this space"}),ke>0&&n.jsxs("span",{className:"bg-primary text-primary-foreground shrink-0 rounded-full px-1.5 text-xs","aria-label":`${ke} ${ke===1?"mention":"mentions"}`,children:["@",ke]}),Pe>0&&n.jsx("span",{className:"bg-muted text-muted-foreground shrink-0 rounded-full px-1.5 text-xs","aria-label":`${Pe} other unread`,children:Pe})]})},H.ref)})]}),V.length>0&&n.jsxs(n.Fragment,{children:[n.jsx(ma,{}),n.jsx(ki,{sheet:s,children:n.jsx(Ar,{variant:s?"sheet":"dropdown",nodes:V,onSheetClose:()=>dt(!1)})})]})]})]}),n.jsx(pA,{request:j,onOpenChange:H=>{H||w(null)},installName:me,onConnected:H=>void be(H)}),n.jsx(g0,{entry:P,dialog:$,onDialogChange:B,installName:me,onConnected:H=>void be(H)}),n.jsx(cA,{connection:D,onOpenChange:H=>{H||T(null)},onDisconnected:yt})]})}function vA(){return n.jsx(Ru,{compact:!0,triggerClassName:K("hover:bg-accent focus-visible:ring-ring text-foreground flex shrink-0 items-center rounded-md px-1 py-1.5 outline-hidden focus-visible:ring-2",Yn)})}function Tu(){const e=Me();return n.jsxs(Cp,{className:"gap-2 px-2 py-3",children:[n.jsxs("div",{className:"flex items-center gap-1",children:[!e&&n.jsx(Ru,{triggerClassName:"text-sidebar-foreground hover:bg-sidebar-accent/70 focus-visible:ring-sidebar-ring flex min-w-0 flex-1 items-center gap-1.5 rounded-md px-2 py-1 text-left text-control font-semibold outline-hidden transition-colors duration-150 focus-visible:ring-2"}),n.jsx(GN,{})]}),n.jsx(qN,{})]})}function wA(){const e=Eu("sm");return n.jsxs("div",{className:"space-y-1 pb-2",children:[e.you!==null&&n.jsx(Ci,{leading:e.you.face,label:e.you.name,description:"View profile",onClick:e.you.onOpen}),n.jsx(Ci,{leading:n.jsx(Kl,{className:"text-muted-foreground size-7 p-0.5","aria-hidden":!0}),label:"DorkOS account",description:e.accountStatus,onClick:e.onOpenAccount})]})}function Ci({leading:e,label:t,description:s,onClick:r}){return n.jsxs("button",{type:"button",onClick:r,className:K("hover:bg-accent focus-visible:ring-ring flex w-full items-center gap-3 rounded-md px-2 py-2 text-left outline-hidden focus-visible:ring-2",Yn),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(hn,{className:"text-muted-foreground size-4 shrink-0","aria-hidden":!0})]})}const jA=6e4;function SA(e){return e===null?!0:(e.selectionStart??0)===0&&(e.selectionEnd??0)===0}function kA(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"&&Be(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 CA(){const{globalPaletteOpen:e,setGlobalPaletteOpen:t}=K0(),s=_(U=>U.openMessageSearch),[r,o]=l.useState(""),a=l.useRef(null),[i,c]=l.useState(""),d=l.useRef(null),[u,m]=l.useState([]),[f,p]=l.useState(null),[h,g]=l.useState(null),[x,b]=l.useState(null),y=u[u.length-1],[k,S]=l.useState(0),E=Me(),v=_(U=>U.globalPaletteInitialSearch),A=_(U=>U.clearGlobalPaletteInitialSearch),R=l.useCallback(()=>{t(!1),A(),o(""),c(""),m([]),p(null),b(null)},[t,A]),{handleAgentSelect:F,startNewSession:I,handleFeatureAction:O,handleQuickAction:C,handleRoomSelect:j,handleSessionSelect:w,handleCommandSelect:D,handlePageSelect:T,recordAgentOpened:P,selectedCwd:$}=Xk(R),B=he(),Y=l.useCallback(U=>{const ye=Np(B,U.projectPath);return Ap(ye?{session:ye}:{agentId:U.id})},[B]),se=l.useCallback(U=>{if(!Ep()){F(U);return}_n(Y(U),{target:"tab"}),P(U.projectPath),R()},[Y,F,P,R]),fe=l.useCallback(U=>{_n(Y(U),{target:"window"}),P(U.projectPath),R()},[Y,P,R]),G=Ip(),q=Yk(),ee=yo(jA),{allAgents:ce,newActions:V,rooms:M,sessions:X,continueRows:ae,recent:z,searchableItems:te}=U0($,ee);Rp(ce);const{bestMatch:me,rows:Se,prefix:Je,term:ne}=Gk(te,r,{usage:q,now:ee,scope:x}),Ae=Je==="#",it=nC(ne),dt=it?{term:it,isScoped:x!==null,onSelect:()=>{R(),s(it)}}:null,Ee=l.useMemo(()=>i?ce.find(U=>U.name===i)??null:null,[i,ce]),be=kA(i,me,Se),yt=l.useCallback(U=>{b(U),o(""),c("")},[]),_e=!E&&Ee!==null,H=l.useMemo(()=>{var U;return i?X.find(ye=>ye.id===i)??((U=ae.find(ye=>ye.session.id===i))==null?void 0:U.session)??null:null},[i,X,ae]),pe=du((f==null?void 0:f.id)??"",(f==null?void 0:f.projectPath)??""),ke=l.useCallback(()=>{m(U=>U.slice(0,-1)),p(U=>u.length<=1?null:U),c("")},[u.length]),Pe=l.useCallback(U=>{p(U),m(ye=>[...ye,"agent-actions"]),o(""),c(""),S(ye=>ye+1)},[]);l.useEffect(()=>{e&&v!=null&&(o(v),A(),requestAnimationFrame(()=>{const U=a.current;if(U){const ye=v.length;U.setSelectionRange(ye,ye)}}))},[e,v,A]);const Ye=l.useCallback(U=>{t(U),U?S(ye=>ye+1):(o(""),c(""),m([]),p(null),b(null))},[t]),Ie=eC({rootRef:d,activePage:y??"root",onPin:c,resetKey:JSON.stringify([e,y??null,r,x&&Xd(x)])}),Rt=!r&&x===null,Vt=l.useId(),Qt=n.jsx(xt,{open:e,onOpenChange:Ye,children:n.jsx(bt,{className:K("!min-h-0 overflow-hidden p-0 transition-[max-width] duration-200","[&>button:last-child]:top-2 [&>button:last-child]:right-2.5",_e?"max-w-[640px]":"max-w-[480px]",E&&"h-[85vh]"),children:n.jsxs(re.div,{variants:pu,initial:"hidden",animate:"visible",exit:"exit",className:K("flex overflow-hidden",E&&"h-full flex-col"),children:[n.jsxs(Vl,{ref:d,loop:!0,shouldFilter:!1,value:i,onValueChange:c,onPointerMove:Ie.onPointerMove,className:K("min-w-0 flex-1",E&&"flex flex-col [&_[cmdk-list]]:max-h-none [&_[cmdk-list]]:flex-1 [&_[cmdk-list]]:overflow-y-auto"),onKeyDown:U=>{if(Ie.onKeyDown(U),U.key==="Enter"&&(U.metaKey||U.ctrlKey)&&!y&&(H==null?void 0:H.cwd)!=null){U.preventDefault(),I(H.cwd),R();return}if(U.key==="Enter"&&(U.metaKey||U.ctrlKey)&&!y&&Ee){U.preventDefault(),se(Ee);return}if(U.key==="Enter"&&(U.metaKey||U.ctrlKey)&&y==="agent-actions"&&f){U.preventDefault(),se(f);return}if(U.key==="Tab"&&!U.shiftKey&&!y&&be){U.preventDefault(),U.stopPropagation(),yt(be);return}if(U.key==="Backspace"&&x&&!y&&SA(a.current)){U.preventDefault(),b(null);return}U.key==="Backspace"&&!r&&u.length>0&&(U.preventDefault(),ke()),U.key==="Escape"&&u.length>0&&(U.preventDefault(),U.stopPropagation(),ke())},children:[u.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),S(U=>U+1)},className:"hover:text-foreground transition-colors",children:"All"}),n.jsx("span",{children:"/"}),n.jsxs("span",{children:["Agent: ",f==null?void 0:f.name]})]}),n.jsx(Ql,{ref:a,"data-testid":"command-palette-input",leading:x&&!y?n.jsx(tC,{scope:x}):void 0,placeholder:y==="agent-actions"?`${(f==null?void 0:f.name)??"Agent"} actions…`:x&&!y?"Search within…":"Search rooms, agents, commands…",value:r,onValueChange:o}),n.jsx(Xl,{children:n.jsxs(Tn,{className:"h-full",children:[n.jsxs(Qb,{children:[n.jsx("p",{children:"No results found."}),n.jsx(uu,{className:"justify-center pb-0"})]}),n.jsx(tt,{mode:"wait",initial:!1,children:n.jsxs(re.div,{"data-palette-page":y??"root",initial:{opacity:0,x:y?16:-16},animate:{opacity:1,x:0},exit:{opacity:0,x:y?-16:16},transition:{duration:.15,ease:"easeOut"},children:[!y&&n.jsx(bC,{staggerKey:k,isZeroQuery:Rt,isRoomMode:Ae,scope:x,hasQuery:ne.length>0,selectedCwd:$,selectedValue:i,continueRows:ae,recent:z,newActions:V,bestMatch:me,rows:Se,rooms:M,searchHandoff:dt,onFeatureAction:O,onQuickAction:C,onGoToAgentActions:Pe,onRoomSelect:j,onSessionSelect:U=>w(U.id,U.cwd),onCommandSelect:D,onPageSelect:T}),y==="agent-actions"&&f&&n.jsx(rC,{agent:f,onOpenHere:()=>F(f),onOpenNewTab:()=>se(f),onOpenNewWindow:G?()=>fe(f):void 0,onNewSession:()=>{I(f.projectPath),P(f.projectPath),R()},onEditSettings:()=>{Tp.getState().openProfileDocked(f.projectPath),R()},onBrowseSessions:pe.sessionCount>0?()=>{g(f),P(f.projectPath),R()}:void 0,recentSessions:pe.recentSessions,onSelectSession:U=>w(U,f.projectPath)})]},y??"root")})]})}),n.jsx(aC,{page:y,hasAgentSelected:_e,canScope:!y&&be!==null,isScoped:x!==null})]}),n.jsx(tt,{children:_e&&Ee&&n.jsx(sC,{agent:Ee},Ee.id)})]})})});return n.jsxs(n.Fragment,{children:[n.jsx(Dp,{id:Vt,children:Qt}),h!==null&&n.jsx(Op,{agentPath:h.projectPath,agentName:h.displayName??h.name,agentVisual:bo(h),open:!0,onOpenChange:U=>{U||g(null)},onSelectSession:U=>w(U,h.projectPath),onNewSession:()=>I(h.projectPath)})]})}const NA="",AA="";function EA(e){const t=[];let s=e,r=!1;for(;s.length>0;){const o=r?AA:NA,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 IA({excerpt:e,className:t}){const s=EA(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 Du="rooms",RA=["claude-code","opencode"];function TA(e){if(e.source===Du)return{kind:"room",...je.channels(),search:{id:e.container,entry:e.ordinal}};if(e.sessionId===void 0)return{kind:"unopenable"};const t=e.messageId!==void 0&&RA.includes(e.source);return{kind:"session",...Ft({session:e.sessionId,dir:e.containerPath??void 0,...t?{message:e.messageId}:{}})}}function DA(e,t){return e.source===Du?t.get(e.container)??"Channel":e.containerPath===null?"Conversation":ll(e.containerPath)}function OA(e){return e==="user"?"You":"Agent"}function MA({hit:e,containerLabel:t,value:s,onSelect:r,openable:o}){const a=e.source==="rooms"?jo:Xy;return n.jsxs(Ne,{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:OA(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:Gn(e.createdAt)})]}),n.jsx(IA,{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 _A=["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."],PA=["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."],LA="Searches channels, direct messages, and DorkOS, Claude Code, Codex and OpenCode chats. Not tool output.",FA=`Type at least ${dl} letters to search.`,$A="Search what was said…";function BA({detailOpen:e=!1,className:t}){const[s,r]=l.useState(null),o=s??e,a=PA;return n.jsxs(Co,{open:o,onOpenChange:r,className:K("px-3 py-2",t),children:[n.jsxs(No,{className:K("text-muted-foreground/80 hover:text-foreground focus-ring text-2xs","flex w-full items-start gap-2 rounded-sm py-1 text-left leading-relaxed transition-colors"),children:[n.jsx("span",{className:"min-w-0 flex-1",children:LA}),n.jsx(qt,{className:K("mt-0.5 size-3 shrink-0 transition-transform",!o&&"-rotate-90"),"aria-hidden":"true"})]}),n.jsx(Ao,{children:n.jsxs("ul",{className:"mt-2 space-y-1.5",children:[_A.map(i=>n.jsxs("li",{className:"text-muted-foreground flex gap-2 text-xs leading-relaxed",children:[n.jsx(Gt,{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(Ib,{className:"mt-0.5 size-3.5 shrink-0 opacity-60","aria-hidden":"true"}),n.jsx("span",{children:i})]},i))]})})]})}const zA=3e4,UA=e=>["message-search",e];function mr(e){return Mp(e).some(t=>t.length>=dl)}function KA(e,t){const s=ie(),r=HA(e,_p),o=t&&mr(e)&&mr(r),{data:a,isFetching:i,error:c}=Re({queryKey:UA(r),queryFn:()=>s.search({q:r}),enabled:o,staleTime:zA,placeholderData:u=>u,retry:!1});return{submitted:o?r:"",tooShort:t&&r.trim().length>0&&!mr(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 HA(e,t){const[s,r]=l.useState(e);return l.useEffect(()=>{const o=setTimeout(()=>r(e),t);return()=>clearTimeout(o)},[e,t]),s}function WA(){const e=_(t=>t.toggleMessageSearch);l.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 hr="bg-muted rounded px-1 py-0.5 font-mono text-3xs";function GA(){WA();const e=_(v=>v.messageSearchOpen),t=_(v=>v.messageSearchQuery),s=_(v=>v.setMessageSearchOpen),r=Me(),o=Fe(),a=ie(),[i,c]=l.useState("");l.useEffect(()=>{e&&c(t??"")},[e,t]);const{results:d,warnings:u,tooShort:m,isSearching:f,error:p,submitted:h}=KA(i,e),{data:g}=Ls({includeArchived:!0}),x=l.useMemo(()=>{const v=new Map;for(const A of g??[])v.set(A.id,A.kind==="channel"&&A.slug?`#${A.slug}`:A.title);return v},[g]),b=l.useCallback(()=>s(!1),[s]),y=l.useCallback((v,A)=>{if(A.kind!=="unopenable"&&(b(),o({to:A.to,search:A.search}),A.kind==="session"&&v.containerPath!==null)){const R=v.containerPath;a.browseDirectory(R).catch(F=>{if((F==null?void 0:F.status)===404){ue.info("That folder is gone",{description:`${R} is gone, so nothing new can run there. You can still read it.`});return}ue.info("Couldn’t open that folder",{description:`DorkOS couldn’t read ${R}. The chat may not open.`})})}},[b,o,a]),k=d.length>0,S=!k&&!m&&!f&&h.trim().length>0&&p===null,E=!k&&!m&&h.trim().length>0&&p===null;return n.jsx(xt,{open:e,onOpenChange:s,children:n.jsxs(bt,{"data-testid":"message-search-dialog",className:K("!min-h-0 max-w-[560px] overflow-hidden p-0","[&>button:last-child]:top-2 [&>button:last-child]:right-2.5",r&&"h-[85vh]"),children:[n.jsx(nt,{className:"sr-only",children:"Search your messages"}),n.jsx(re.div,{variants:pu,initial:"hidden",animate:"visible",exit:"exit",className:K("flex overflow-hidden",r&&"h-full flex-col"),children:n.jsxs(Vl,{loop:!0,shouldFilter:!1,className:K("min-w-0 flex-1",r&&"flex flex-col [&_[cmdk-list]]:max-h-none [&_[cmdk-list]]:flex-1 [&_[cmdk-list]]:overflow-y-auto"),children:[n.jsx(Ql,{"data-testid":"message-search-input",placeholder:$A,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(Pp,{className:"mt-0.5 size-3.5 shrink-0","aria-hidden":"true"}),n.jsx("span",{children:p.message})]}),u.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(ec,{className:"mt-0.5 size-3 shrink-0","aria-hidden":"true"}),n.jsx("span",{children:v.message})]},v.source)),n.jsx(Xl,{children:n.jsx(Tn,{className:"h-full",children:k&&n.jsx(et,{className:K("transition-opacity duration-150",f&&"opacity-60"),children:d.map(v=>{const A=`${v.source}:${v.container}:${v.ordinal}`,R=TA(v);return n.jsx(MA,{value:A,hit:v,containerLabel:DA(v,x),openable:R.kind!=="unopenable",onSelect:()=>y(v,R)},A)})})})}),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:FA}),S&&n.jsxs("p",{className:"text-muted-foreground px-3 pt-3 text-xs",children:["No messages match “",h.trim(),"”."]}),n.jsx(BA,{detailOpen:E})]}),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:hr,children:"↑↓"}),"Navigate"]}),n.jsxs("span",{className:"inline-flex items-center gap-1",children:[n.jsx("kbd",{className:hr,children:"Enter"}),"Open"]}),n.jsxs("span",{className:"ml-auto inline-flex items-center gap-1",children:[n.jsx("kbd",{className:hr,children:"esc"}),"Close"]})]})]})})]})})}function qA(e){return`set${e.charAt(0).toUpperCase()}${e.slice(1)}`}function YA(e){const t=at(),s=fo(),r=So();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 VA({contribution:e,openStateKey:t}){const s=_(m=>m[t]),r=_(m=>m[qA(t)]),o=YA(e.urlParam),a=o.isOpen,i=o.close,c=s||a,d=l.useCallback(m=>{r(m),!m&&a&&i()},[r,a,i]),u=e.component;return n.jsx(u,{open:c,onOpenChange:d})}function QA({contribution:e,openState:t}){const s=l.useSyncExternalStore(t.subscribe,t.getSnapshot),r=e.component;return s?n.jsx(Lp,{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 XA({contribution:e}){return e.openState?n.jsx(QA,{contribution:e,openState:e.openState}):n.jsx(VA,{contribution:e,openStateKey:e.openStateKey})}function JA(){const e=_s("dialog");return n.jsx(n.Fragment,{children:e.map(t=>n.jsx(XA,{contribution:t},t.id))})}const ZA=["session","id","thread","entry","itemId","agent","profile","continuedFrom","pkg","view","region","detail","panel"];function eE(e,t){if(e.length>=Qs)return e.slice(0,Qs);const s=new URLSearchParams(t);let r="";for(const o of ZA)for(const a of s.getAll(o)){const i=new URLSearchParams([[o,a]]).toString(),c=r?`${r}&${i}`:i;e.length+1+c.length<=Qs&&(r=c)}return r?`${e}?${r}`:e}const tE=6e4,nE={bug:"when it’s fixed",idea:"when it ships",feedback:"when the team acts on it"};function sE(e,t){var s;return JSON.stringify([e.kind,t,e.screenshotDataUrl??null,((s=e.element)==null?void 0:s.selector)??null])}function Ni(e,t,s,r){const o=Zl("bug",e,t),a=[...zp()];r&&a.push({at:new Date().toISOString(),kind:"console_error",message:$p(r).slice(0,Bp)});const i=a.slice(-Up);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])),...gv(s)},...i.length>0?{breadcrumbs:i}:{}}}function rE(){const e=ie(),t=Le({select:h=>h.location.pathname}),s=Le({select:h=>h.location.searchStr}),r=Fp(),o=eE(t,s),a=Le({select:h=>{const g=h.location.search;return typeof(g==null?void 0:g.session)=="string"?g.session:void 0}}),{data:i}=Re({queryKey:ze.current(),queryFn:()=>e.getConfig(),staleTime:300*1e3}),[c,d]=l.useState(!1),u=Fe(),m=l.useRef(null),f=l.useCallback(h=>i?Ni(i,t,r,h==null?void 0:h.crashStack):void 0,[i,t,r]),p=l.useCallback(async h=>{var v;const g=h.message.trim();if(!g)return!1;const x=(v=h.contact)==null?void 0:v.trim(),b=sE(h,g),y=m.current;if(y&&y.fingerprint===b&&Date.now()-y.at<tE)return ue.info("Already sent a moment ago."),!0;const k=h.includeDiagnostics?Ni(i,t,r,h.crashStack):void 0,S=h.includeDiagnostics&&h.kind==="bug",E=!!(h.includeConversation&&a);d(!0);try{const A=k&&S?await ov():void 0,{ok:R}=await e.sendFeedback({kind:h.kind,message:g,...x?{contact:x}:{},...o?{route:o}:{},...k?{diagnostics:{...k,...A?{shellLogExcerpt:A}:{}}}:{},...S?{includeServerLogs:!0}:{},...E?{sessionId:a,includeTranscript:!0}:{},...h.screenshotDataUrl?{screenshot:{dataUrl:h.screenshotDataUrl}}:{},...h.anonymous?{anonymous:!0}:{},...h.element?{element:h.element}:{}});return R?(m.current={fingerprint:b,at:Date.now()},ue.success("Sent. Thank you.",{...h.notifyEmail?{description:`DorkOS emails ${h.notifyEmail} ${nE[h.kind]}.`}:{},action:{label:"Your reports",onClick:()=>u(je.feedbackRequests())}})):ue.error("Couldn’t send. Your words are still here. Try again or open a GitHub issue."),R}finally{d(!1)}},[e,t,o,a,i,r,u]);return{isSubmitting:c,sessionId:a,route:o,buildDiagnostics:f,send:p}}const oE=24;function Ai(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 aE(e){const{element:t,viewport:s,region:r,image:o}=e,a=e.padding??oE;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=Ai(i,{left:0,top:0,width:s.width,height:s.height});if(!c)return null;const d=Ai(c,r);if(!d)return null;const u=o.width/r.width,m=o.height/r.height,f=Math.round((d.left-r.left)*u),p=Math.round((d.top-r.top)*m),h=Math.round((d.left+d.width-r.left)*u),g=Math.round((d.top+d.height-r.top)*m),x=Math.min(Math.max(0,f),Math.max(0,o.width-1)),b=Math.min(Math.max(0,p),Math.max(0,o.height-1));return{sx:x,sy:b,sw:Math.max(1,h-x),sh:Math.max(1,g-b)}}function iE(e){return new Promise((t,s)=>{const r=new Image,o=i=>{clearTimeout(a),s(new st("failed",i))},a=setTimeout(()=>o(`The capture did not decode within ${ws}ms.`),ws);r.onload=()=>{clearTimeout(a),t(r)},r.onerror=()=>o("The capture did not decode, so it cannot be cropped."),r.src=e})}function cE(e,t){const s=document.createElement("canvas");s.width=t.sw,s.height=t.sh;const r=s.getContext("2d");if(!r)throw new st("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 lE(e,t){const s=t.getBoundingClientRect();if(s.width===0&&s.height===0)throw new st("failed","That element has no size to crop to.");if(!gd().contains(t))throw new st("failed","That element is not part of the app that was captured.");const r=await iE(e.dataUrl),o=aE({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 st("failed","That element is no longer inside the captured picture.");return Or(cE(r,o))}const Ei={"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."},dE={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 uE(e){return e instanceof st?dE[e.reason]:e instanceof Ut?Ei[e.reason]:Ei.unreadable}const fr="Only images can be attached.",mE="Files";function An(e){return e?Array.from(e.types).includes(mE):!1}function Ii(e){return e.find(t=>t.type.startsWith("image/"))}function hE(e={}){const{enabled:t=!1}=e,[s,r]=l.useState(null),[o,a]=l.useState(!1),[i,c]=l.useState(!1),d=l.useRef(0),u=l.useRef(0),m=l.useCallback(async v=>{const A=++u.current;a(!0);try{const R=await v();return A!==u.current?null:(r(R),R)}catch(R){return A!==u.current||ue.error(uE(R)),null}finally{A===u.current&&a(!1)}},[]),f=l.useCallback(async v=>{if(!v.type.startsWith("image/")){ue.error(fr);return}await m(()=>Or(v))},[m]),p=l.useCallback(async()=>{await m(async()=>Or(await hv()))},[m]),h=l.useCallback(v=>m(async()=>lE(await xd(),v)),[m]),g=l.useCallback(()=>{u.current+=1,r(null),a(!1)},[]),x=l.useCallback(v=>{u.current+=1,d.current=0,v!==void 0&&!Sv(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)},[]);l.useEffect(()=>{if(!t)return;const v=A=>{An(A.dataTransfer)&&A.preventDefault()};return window.addEventListener("dragover",v),window.addEventListener("drop",v),()=>{window.removeEventListener("dragover",v),window.removeEventListener("drop",v)}},[t]);const b=l.useCallback(v=>{var F;const A=Array.from(((F=v.clipboardData)==null?void 0:F.items)??[]).map(I=>I.getAsFile()).filter(I=>I!==null);if(A.length===0)return;const R=Ii(A);if(!R){ue.error(fr);return}v.preventDefault(),f(R)},[f]),y=l.useCallback(v=>{An(v.dataTransfer)&&(v.preventDefault(),d.current+=1,c(!0))},[]),k=l.useCallback(v=>{An(v.dataTransfer)&&(v.preventDefault(),v.dataTransfer.dropEffect="copy")},[]),S=l.useCallback(v=>{An(v.dataTransfer)&&(d.current=Math.max(0,d.current-1),d.current===0&&c(!1))},[]),E=l.useCallback(v=>{if(!An(v.dataTransfer))return;v.preventDefault(),d.current=0,c(!1);const A=Ii(Array.from(v.dataTransfer.files));if(!A){ue.error(fr);return}f(A)},[f]);return{dataUrl:s,isPreparing:o,isDraggingOver:i,attach:f,capture:p,captureElement:h,clear:g,reset:x,handlers:{onPaste:b,onDragEnter:y,onDragOver:k,onDragLeave:S,onDrop:E}}}const Ri=Wp,fE="root";function Ou(e){return typeof CSS<"u"&&typeof CSS.escape=="function"?CSS.escape(e):e.replace(/["'\\[\]]/g,t=>`\\${t}`)}function Ti(e,t){try{const s=t.ownerDocument.querySelectorAll(e);return s.length===1&&s[0]===t}catch{return!1}}function Mu(e){return e.id?`#${Ou(e.id)}`:null}function Vr(e,t){const s=e.getAttribute(t);return s?`[${t}="${Ou(s)}"]`:null}function pE(e){const t=e.tagName;let s=1,r=e.previousElementSibling;for(;r;)r.tagName===t&&(s+=1),r=r.previousElementSibling;return s}function gE(e){const t=e.tagName.toLowerCase(),s=Mu(e);if(s)return s;const r=Vr(e,"data-testid")??Vr(e,"data-slot"),o=`:nth-of-type(${pE(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 xE(e){for(const r of[Mu(e),Vr(e,"data-testid")])if(r&&r.length<=Ri&&Ti(r,e))return r;const t=[];let s=e;for(;s&&s.id!==fE&&s.tagName!=="BODY";){t.unshift(gE(s));const r=t.join(" > ");if(r.length>Ri){t.shift();break}if(Ti(r,e))return r;s=s.parentElement}return t.join(" > ")||e.tagName.toLowerCase()}function Di(e,t){var r;const s=(r=e.closest(`[${t}]`))==null?void 0:r.getAttribute(t);if(!(!s||s.length>Kp))return s}const bE=8;function _u(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*bE?s:null}function yE(e){const t=Di(e,"data-slot"),s=_u(e,e),r=s?Di(s,"data-testid"):void 0,o=Pu(e);return{selector:xE(e),...t?{slot:t}:{},...r?{testId:r}:{},...o?{label:o}:{}}}const pr=40,vE=["button","a[href]","summary","input","select","textarea",'[role="button"]','[role="link"]','[role="menuitem"]','[role="tab"]','[role="option"]','[role="checkbox"]','[role="switch"]'].join(", "),wE=new Set(["INPUT","SELECT","TEXTAREA"]),jE=['[contenteditable]:not([contenteditable="false"])','[role="textbox"]','[role="searchbox"]','[role="combobox"]'].join(", "),SE=["h1","h2","h3","h4","h5","h6",'[role="heading"]',"label","legend","th","dt"].join(", ");function kE(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 Mn(e){const t=(e??"").replace(/\s+/g," ").trim();if(!t)return;const s=kE(t);if(s.length<=pr)return t;const r=s.slice(0,pr-1),o=r.lastIndexOf(" ");return`${(o>pr/2?r.slice(0,o):r).join("").trimEnd()}…`}function CE(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 Mn(s)}function rs(e){return Mn(e.getAttribute("aria-label"))??CE(e)}function Pu(e){const t=NE(e);return t&&t.length<=Hp?t:void 0}function NE(e){var a,i;const t=e.closest(jE);if(t)return rs(t);const s=e.closest(vE);if(s){if(wE.has(s.tagName)){const c=s;return rs(s)??Mn((i=(a=c.labels)==null?void 0:a[0])==null?void 0:i.textContent)}return rs(s)??Mn(s.textContent)}const r=rs(e);if(r)return r;const o=e.closest(SE);return o?Mn(o.textContent):void 0}function Oi(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 AE(e){var d;const t=Pu(e);if(t)return{text:t,onScreen:!0};const s=e.getAttribute("data-testid")??e.getAttribute("data-slot"),r=s?Oi(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&&_u(e,o)===o?o.getAttribute("data-testid"):null)??(o==null?void 0:o.getAttribute("data-slot")),c=i?Oi(i):null;return c?{text:c,onScreen:!1}:null}const EE="This part";function Lu(e){return(e==null?void 0:e.text)??EE}function IE(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 RE(e){return e!=null&&e.onScreen?`Remove “${e.text}”`:`Remove ${Lu(e).toLowerCase()}`}const Mi=500;function _i(e){const t=e.trim();return t.length>Mi?`${t.slice(0,Mi)}… [trimmed]`:t}function TE(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: ${_i(s.input)}`),s.result&&t.push(` result: ${_i(s.result)}`);return t.join(`
74
- `)}function DE(e){const t=e.slice(-20),s=Gp(qp(t.map(TE).join(`
75
-
76
- `))).trim();return s.length>fa?`${s.slice(0,fa-1)}…`:s}function OE(e,t){const s=ie(),[r]=$s(),{data:o,isLoading:a,isError:i}=Re({queryKey:["feedback-transcript-preview",e,r],queryFn:async()=>{const{messages:c}=await s.getMessages(e,r??void 0);return DE(c)},enabled:t&&!!e,staleTime:30*1e3});return{text:o??"",isLoading:a,isError:i}}function ME(){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(ys,{className:"size-3 shrink-0","aria-hidden":!0}),"Private. Only the DorkOS core team sees these. Never public."]})})}function Ze({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 _E({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:u,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(Ze,{label:"Page",value:s}),n.jsx(Ze,{label:"Version",value:r.version}),n.jsx(Ze,{label:"Platform",value:r.platform}),n.jsx(Ze,{label:"Runtimes",value:r.runtimes.length?r.runtimes.join(", "):"none"}),a&&n.jsx(Ze,{label:"Window",value:`${a.width}×${a.height}${a.devicePixelRatio&&a.devicePixelRatio!==1?` @${a.devicePixelRatio}x`:""}`}),c&&n.jsx(Ze,{label:"Shell",value:c}),d&&n.jsx(Ze,{label:"Theme",value:d}),u&&n.jsx(Ze,{label:"Locale",value:u}),m&&n.jsx(Ze,{label:"Timezone",value:m}),i&&n.jsx(Ze,{label:"Browser",value:i}),Object.entries(r.flags).map(([f,p])=>n.jsx(Ze,{label:f,value:String(p)},f))]}),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((f,p)=>n.jsxs("li",{className:"text-foreground font-mono text-xs break-all",children:[n.jsx("span",{className:"text-muted-foreground",children:f.kind})," ",f.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:Ue()?"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 PE({sessionId:e,active:t}){const{text:s,isLoading:r,isError:o}=OE(e,t);return r?n.jsxs("div",{className:"flex flex-col gap-2",children:[n.jsx(_t,{className:"h-4 w-3/4"}),n.jsx(_t,{className:"h-4 w-full"}),n.jsx(_t,{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 LE({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 FE({open:e,onOpenChange:t,initialTab:s,diagnostics:r,kind:o,route:a,showConversation:i,sessionId:c,screenshotDataUrl:d}){const u=!Me(),m=["diagnostics",...i?["conversation"]:[],...d?["screenshot"]:[]],f=m.includes(s)?s:"diagnostics";return n.jsx(xt,{open:e,onOpenChange:t,children:n.jsxs(bt,{className:K("max-h-[85vh]",u&&"max-w-lg"),children:[n.jsxs(ht,{children:[n.jsx(nt,{className:"text-sm font-medium",children:"What will be sent"}),n.jsx(ft,{className:"text-muted-foreground text-xs",children:"Each part is sent only if its toggle is on."})]}),n.jsxs(Ml,{defaultValue:f,className:"flex min-h-0 flex-col gap-3 px-4 pb-4 sm:px-0",children:[n.jsxs(_l,{className:K("grid shrink-0",m.length===3&&"grid-cols-3",m.length===2&&"grid-cols-2",m.length===1&&"grid-cols-1"),children:[n.jsx(is,{value:"diagnostics",children:"Diagnostics"}),i&&n.jsx(is,{value:"conversation",children:"Chat"}),d&&n.jsx(is,{value:"screenshot",children:"Screenshot"})]}),n.jsx(Zs,{value:"diagnostics",className:"min-h-0",children:n.jsx(Tn,{className:"max-h-[45vh]",children:n.jsx(_E,{diagnostics:r,kind:o,route:a})})}),i&&n.jsx(Zs,{value:"conversation",className:"min-h-0",children:n.jsx(Tn,{className:"max-h-[45vh]",children:n.jsx(PE,{sessionId:c,active:e})})}),d&&n.jsx(Zs,{value:"screenshot",className:"min-h-0",children:n.jsx(Tn,{className:"max-h-[45vh]",children:n.jsx(LE,{dataUrl:d})})}),n.jsx(ME,{})]},f)]})})}const $E="0 0 0 9999px rgb(0 0 0 / 0.5)";function BE(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 zE(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 UE({phase:e,onSelect:t,onCancel:s}){const r=l.useRef(null),o=l.useRef(null),[a,i]=l.useState(null),c=e==="picking",d=l.useCallback((x,b)=>{const y=r.current;if(!y)return null;const k=y.style.pointerEvents;y.style.pointerEvents="none";try{return document.elementFromPoint(x,b)}finally{y.style.pointerEvents=k}},[]),u=l.useCallback(x=>{var b;return x instanceof Node&&!!((b=o.current)!=null&&b.contains(x))},[]),m=l.useCallback(x=>{if(!c)return;if(u(x.target)){i(null);return}const b=d(x.clientX,x.clientY);if(!b){i(null);return}const y=b.getBoundingClientRect();i({element:b,box:{left:y.left,top:y.top,width:y.width,height:y.height},label:BE(b)})},[c,d,u]),f=l.useCallback(x=>{if(!c||u(x.target))return;const b=d(x.clientX,x.clientY)??(a==null?void 0:a.element);b&&t(b)},[c,d,u,t,a]),p=l.useCallback(x=>{if(!c)return;const b=zE(d(x.clientX,x.clientY));b==null||b.scrollBy({left:x.deltaX,top:x.deltaY})},[c,d]);l.useEffect(()=>{if(!c)return;const x=b=>{b.preventDefault(),b.stopImmediatePropagation(),b.key==="Escape"&&s()};return window.addEventListener("keydown",x,!0),()=>window.removeEventListener("keydown",x,!0)},[c,s]),l.useEffect(()=>{var b;const x=document.activeElement;return(b=r.current)==null||b.focus(),()=>{x instanceof HTMLElement&&x.focus()}},[]),l.useEffect(()=>{if(!c)return;const x=()=>{i(b=>{if(!b)return b;const y=b.element.getBoundingClientRect();return{...b,box:{left:y.left,top:y.top,width:y.width,height:y.height}}})};return window.addEventListener("scroll",x,!0),()=>window.removeEventListener("scroll",x,!0)},[c]);const h=c?a:null,g=h!==null&&h.box.top<28;return As.createPortal(n.jsxs("div",{ref:r,role:"dialog","aria-modal":"true","aria-label":"Point at the part of the app that looks wrong",tabIndex:-1,className:K("fixed inset-0 z-50 focus:outline-none",c?"cursor-crosshair":"cursor-wait"),onPointerMove:m,onPointerLeave:()=>i(null),onClick:f,onWheel:p,onContextMenu:x=>{x.preventDefault(),c&&s()},children:[c&&(h?n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"border-primary pointer-events-none absolute rounded-sm border-2",style:{left:h.box.left,top:h.box.top,width:h.box.width,height:h.box.height,boxShadow:$E}}),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,h.box.left),top:g?h.box.top+h.box.height+4:h.box.top-22},children:h.label})]}):n.jsx("div",{className:"absolute inset-0 bg-black/50"})),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(vs,{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 Pi="text-muted-foreground hover:text-foreground h-8 px-2 text-xs aria-disabled:pointer-events-none aria-disabled:opacity-50";function gr({tip:e,children:t}){return n.jsxs(fn,{children:[n.jsx(pn,{asChild:!0,children:t}),n.jsx(gn,{className:"max-w-60 text-center",children:e})]})}function KE({showPictureTools:e,isPreparing:t,hasPointed:s,hasWords:r,isMobile:o,onCapture:a,onPointAtElement:i,onPick:c}){const d=l.useId(),u=l.useId(),m=l.useId(),f=l.useId();function p(k){var E;const S=(E=k.target.files)==null?void 0:E[0];k.target.value="",S&&c(S)}const h=r&&!o;if(!e&&!h)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.",b="Take a picture of this app. Never the rest of your screen.",y="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:u,className:"sr-only",children:b}),n.jsx(gr,{tip:b,children:n.jsxs(L,{"aria-describedby":u,type:"button",variant:"ghost",size:"sm",onClick:()=>{t||a()},"aria-disabled":t||void 0,className:Pi,children:[n.jsx(Hy,{className:"size-3.5","aria-hidden":!0}),"Capture app"]})}),!o&&n.jsx(gr,{tip:y,children:n.jsxs(L,{"aria-describedby":m,type:"button",variant:"ghost",size:"sm",onClick:()=>{t||i()},"aria-disabled":t||void 0,className:Pi,children:[n.jsx(vs,{className:"size-3.5","aria-hidden":!0}),s?"Point again":"Point at it"]})}),!o&&n.jsx("span",{id:m,className:"sr-only",children:y}),n.jsx("span",{id:f,className:"sr-only",children:x}),n.jsx(gr,{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(Zx,{className:"size-3.5","aria-hidden":!0}),n.jsx("input",{id:d,type:"file",accept:"image/*","aria-label":g,"aria-describedby":f,disabled:t,className:"sr-only",onChange:p})]})})]}),h&&n.jsxs("span",{className:"text-muted-foreground ml-auto pr-1.5 text-xs","aria-hidden":!0,children:[Bt?"⌘↵":"Ctrl+↵"," to send"]})]})}function Li({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(vs,{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(vs,{className:"size-3 shrink-0","aria-hidden":!0}),n.jsx("span",{className:"truncate",children:s})]})]}),u=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(fn,{children:[n.jsx(pn,{asChild:!0,children:u}),n.jsx(gn,{className:"text-2xs max-w-72 font-mono break-all",children:o})]}):u,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(Ke,{className:"size-3","aria-hidden":!0})})]})}function Fi({label:e,summary:t,pressed:s,onPressedChange:r,onPreview:o}){return n.jsxs("span",{className:K("inline-flex items-center rounded-full border text-xs transition-colors duration-150",s?"bg-muted/60 text-foreground":"text-muted-foreground"),children:[n.jsxs(fn,{children:[n.jsx(pn,{asChild:!0,children:n.jsxs("button",{type:"button","aria-pressed":s,onClick:()=>r(!s),className:"hover:text-foreground focus-visible:ring-ring flex items-center gap-1.5 rounded-full py-1 pr-1.5 pl-2.5 focus-visible:ring-2 focus-visible:outline-none",children:[n.jsx("span",{"aria-hidden":!0,className:K("size-1.5 rounded-full transition-colors duration-150",s?"bg-primary":"bg-muted-foreground/40")}),e]})}),n.jsx(gn,{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-visible:ring-ring flex items-center rounded-full py-1 pr-2.5 pl-1 focus-visible:ring-2 focus-visible:outline-none",children:n.jsx(Yp,{className:"size-3.5","aria-hidden":!0})})]})}function HE({currentUser:e,anonymous:t,onToggleAnonymous:s,contact:r,onContactChange:o}){const a=l.useId(),i=l.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(Zy,{className:"size-3.5 shrink-0","aria-hidden":!0}):n.jsx(Vp,{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&&!ul(r);return n.jsxs("div",{className:"flex flex-col gap-1.5",children:[n.jsx(Ge,{htmlFor:a,className:"text-xs",children:"Your email"}),n.jsx(gt,{id:a,type:"email",inputMode:"email",autoComplete:"email",value:r,onChange:d=>o(d.target.value),placeholder:"you@example.com",maxLength:Qp,"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 WE=[{value:"feedback",label:"Feedback",icon:Is},{value:"bug",label:"Bug",icon:Xp},{value:"idea",label:"Idea",icon:eb}];function GE({kind:e,onChange:t}){return n.jsx("div",{role:"radiogroup","aria-label":"What kind of feedback",className:"flex gap-1.5",children:WE.map(({value:s,label:r,icon:o})=>{const a=e===s;return n.jsxs("button",{type:"button",role:"radio","aria-checked":a,onClick:()=>t(s),className:K("focus-visible:ring-ring flex items-center gap-1.5 rounded-full border px-3 py-1 text-xs font-medium transition-colors duration-150 focus-visible:ring-2 focus-visible:outline-none",a?"border-foreground/60 text-foreground bg-muted/60":"text-muted-foreground hover:text-foreground"),children:[n.jsx(o,{className:"size-3.5","aria-hidden":!0}),r]},s)})})}function qE({needsWords:e,canSend:t,isSubmitting:s,onOpenGitHubIssue:r}){const o=l.useId();return n.jsxs(tn,{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(ys,{className:"size-3 shrink-0","aria-hidden":!0}),"Only the DorkOS team sees this"]}),n.jsx(L,{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 YE={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 $i(e,t,s){return{diagnostics:e==="bug"||s,conversation:e==="bug"&&t}}function VE({open:e,onOpenChange:t,initialKind:s,prefillMessage:r,crashStack:o,currentUser:a,initialScreenshotDataUrl:i}){const c=!Me(),{isSubmitting:d,sessionId:u,route:m,buildDiagnostics:f,send:p}=rE(),h=Py(),g=!!u,x=!!a,b=l.useId(),[y,k]=l.useState(s??"feedback"),[S,E]=l.useState(r??""),[v,A]=l.useState(pa),[R,F]=l.useState(!1),[I,O]=l.useState(!1),[C,j]=l.useState(!1),[w,D]=l.useState(!1),[T,P]=l.useState("diagnostics"),[$,B]=l.useState(null),[Y,se]=l.useState(null),[fe,G]=l.useState(null),[q,ee]=l.useState(null),[ce,V]=l.useState(0),M=l.useRef(ce);l.useEffect(()=>{M.current=ce},[ce]);const[X,ae]=l.useState(!1),[z,te]=l.useState(o),[me,Se]=l.useState(u),Je=l.useRef(null),ne=hE({enabled:e}),Ae=S.trim().length>0,it=Ae||ne.dataUrl!==null||$!==null,[dt,Ee]=l.useState(e);if(e!==dt&&(Ee(e),e)){D(!1),ee(null);const Z=i;if(!!(r||o||Z)||!it){const Te=s??"feedback",Ve=$i(Te,g,!!o);k(Te),E(r??""),A(pa()),F(!1),O(Ve.diagnostics),j(Ve.conversation),ae(!1),B(null),se(null),te(o),Se(u),ne.reset(Z),V(Qe=>Qe+1)}else u!==me&&(j(!1),Se(u))}function be(Z){const le=$i(Z,g,!!z);O(le.diagnostics),j(le.conversation)}function yt(Z){k(Z),be(Z)}function _e(Z){P(Z),D(!0)}async function H(Z){const le=M.current,Te=yE(Z),Ve=AE(Z);Y&&ne.dataUrl===Y&&ne.clear(),se(null),ee("capturing");const Qe=await ne.captureElement(Z);le===M.current&&(ee(null),B(Te),G(Ve),se(Qe),k("bug"),X||be("bug"))}function pe(){Y&&ne.dataUrl===Y&&ne.clear(),B(null),se(null)}function ke(){E(""),B(null),se(null),ae(!1),te(void 0),ne.clear()}const Pe=Ae&&!d&&!ne.isPreparing,Ye=x?R||a==null?void 0:a.email:ul(v)?v.trim():void 0;async function Ie(){!Pe||!await p({kind:y,message:S,...x?{}:{contact:v},includeDiagnostics:I,includeConversation:C,anonymous:R,...z?{crashStack:z}:{},...ne.dataUrl?{screenshotDataUrl:ne.dataUrl}:{},...$?{element:$}:{},...Ye?{notifyEmail:Ye}:{}})||(x||eg(v),ke(),t(!1))}function Rt(Z){Z.preventDefault(),Ie()}function Vt(Z){const le=Je.current;le&&(Z.preventDefault(),le.focus(),le.setSelectionRange(le.value.length,le.value.length))}function Qt(Z){Z.key!=="Enter"||!(Z.metaKey||Z.ctrlKey)||Z.nativeEvent.isComposing||w||(Z.preventDefault(),Ie())}const U=ne.handlers,ye=q!==null,N=$?fe:null,W=Lu(N),J=!!($&&Y&&ne.dataUrl===Y),oe=!!ne.dataUrl&&!J,ve=!Ae&&(!!ne.dataUrl||$!==null);return n.jsxs(n.Fragment,{children:[ye&&n.jsx(UE,{phase:q,onSelect:Z=>void H(Z),onCancel:()=>ee(null)}),n.jsx(xt,{open:e&&!ye,onOpenChange:t,children:n.jsxs(bt,{...U,onKeyDown:Qt,desktopProps:{className:"max-w-md",onOpenAutoFocus:Vt},className:K("max-h-[85vh] !min-h-0",ne.isDraggingOver&&"ring-primary ring-2"),children:[n.jsxs(ht,{children:[n.jsx(nt,{className:"text-sm font-medium",children:"Send feedback"}),n.jsx(ft,{className:"text-muted-foreground text-xs",children:"Straight to the DorkOS team. Private."})]}),n.jsxs("form",{onSubmit:Rt,noValidate:!0,className:"flex min-h-0 flex-1 flex-col gap-4",children:[n.jsxs(kt,{alignWithHeader:!0,className:"flex flex-col gap-4",children:[n.jsx(GE,{kind:y,onChange:yt}),n.jsxs("div",{className:K("dark:bg-input/30 flex flex-col rounded-lg border transition-[border-color,box-shadow] duration-150","focus-within:border-ring focus-within:ring-ring focus-within:ring-[3px]",ne.isDraggingOver&&"border-primary"),children:[n.jsx(Ge,{htmlFor:b,className:"sr-only",children:"Your message"}),n.jsx(Jp,{ref:Je,id:b,value:S,onChange:Z=>E(Z.target.value),placeholder:$?IE(N):YE[y],rows:4,maxLength:Zp,className:"min-h-24 resize-none rounded-lg border-0 bg-transparent shadow-none focus-visible:ring-0 dark:bg-transparent"}),($||oe||ne.isPreparing||ne.isDraggingOver)&&n.jsxs("div",{className:"flex flex-wrap items-center gap-2 px-2.5 pb-2.5",children:[$&&n.jsx(Li,{imageUrl:J?Y??void 0:void 0,alt:`The part you pointed at: ${W}`,caption:W,pointed:!0,detail:$.selector,...J?{onOpen:()=>_e("screenshot")}:{},onRemove:pe,removeLabel:RE(N)}),oe&&ne.dataUrl&&n.jsx(Li,{imageUrl:ne.dataUrl,alt:"The screenshot you attached",onOpen:()=>_e("screenshot"),onRemove:ne.clear,removeLabel:"Remove screenshot"}),(ne.isPreparing||ne.isDraggingOver)&&n.jsx("p",{role:"status","aria-live":"polite",className:"text-muted-foreground text-xs",children:ne.isDraggingOver?"Drop to attach":"Getting it ready…"})]}),n.jsx(KE,{showPictureTools:!0,isPreparing:ne.isPreparing,hasPointed:$!==null,hasWords:Ae,isMobile:!c,onCapture:()=>void ne.capture(),onPointAtElement:()=>ee("picking"),onPick:Z=>void ne.attach(Z)})]}),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(Fi,{label:"Diagnostics",summary:"Version, window size, browser, and recent errors.",pressed:I,onPressedChange:Z=>{ae(!0),O(Z)},onPreview:()=>_e("diagnostics")}),g&&n.jsx(Fi,{label:"This chat",summary:"Shows what led to the bug.",pressed:C,onPressedChange:Z=>{ae(!0),j(Z)},onPreview:()=>_e("conversation")})]}),n.jsx(HE,{currentUser:a??null,anonymous:R,onToggleAnonymous:()=>F(Z=>!Z),contact:v,onContactChange:A})]}),n.jsx(qE,{needsWords:ve,canSend:Pe,isSubmitting:d,onOpenGitHubIssue:()=>h(y==="idea"?"feature":"bug")})]}),n.jsx(FE,{open:w,onOpenChange:D,initialTab:T,diagnostics:f(z?{crashStack:z}:void 0),kind:y,route:m,showConversation:g,sessionId:u,...ne.dataUrl?{screenshotDataUrl:ne.dataUrl}:{}})]})})]})}function QE(){const e=En(a=>a.open),t=En(a=>a.prefill),s=En(a=>a.openFeedback),r=En(a=>a.setOpen),o=tg();return l.useEffect(()=>{const a=ng();a&&s(a)},[s]),n.jsx(VE,{open:e,onOpenChange:r,initialKind:t.kind,prefillMessage:t.message,crashStack:t.crashStack,currentUser:o?{email:o.email,name:o.name}:null})}function XE(){const e=Fe();l.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 JE(){const{closeActive:e}=_o();l.useEffect(()=>{const t=window.electronAPI;if(t!=null&&t.onCloseTab)return t.onCloseTab(()=>e())},[e])}function ZE(){const[e,t]=l.useState(!1);return l.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 Bi="window-blurred";function e1(){l.useEffect(()=>{var a,i,c;if(!sg||!((a=window.electronAPI)!=null&&a.onFocusChange))return;const e=document.documentElement,t=d=>{e.classList.toggle(Bi,!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(Bi)}},[])}const t1="/channels";function n1(){vw();const e=rg(),t=Wn(),s=e===t1&&!t.community?t.id??null:null,{data:r}=pc(s),{data:o}=Ls(),a=l.useMemo(()=>(o??[]).filter(on).length,[o]);return{room:s&&r?r:null,unreadRoomCount:a}}function s1({unreadRoomCount:e}){xS();const t=_(c=>c.isStreaming),s=_(c=>c.isWaitingForUser),r=Ln(c=>c.schedulesWaitingCount),o=Ln(c=>c.needsYouCount),a=Le({select:c=>c.location.href}),i=Ps(a);return $y(c=>og(i,{...c,badgeCount:e+r,needsYou:s||o>0}),t),null}function r1(){const e=Un(),t=zs(),s=he(),r=Fe(),o=l.useRef(null);l.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(u=>[u.ref,{status:u.status,label:u.label,generation:ga(u.ref)}]));if(o.current={owner:a,rows:c},!!i)for(const[u,m]of i){if(m.status!=="connected")continue;const f=c.get(u);if((f==null?void 0:f.status)==="connected")continue;const p=bs(Fn().destination)===u,h=ga(u)>m.generation,g=f===void 0?"removed":"revoked";(h?Promise.resolve():ag(s,e,u,g)).then(()=>{p&&bs(Fn().destination)===u&&r({...je.home(),replace:!0})}),g==="revoked"&&ue(`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 o1(){r1(),Dv(),ig()}function a1({isFullscreen:e}){return n.jsx("div",{className:K("desktop-darwin:block app-drag-region hidden shrink-0",!e&&"desktop-darwin:h-11"),"aria-hidden":"true"})}class i1 extends l.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 c1=5e3;function Fu({testId:e,headline:t,detail:s}){const{isFetching:r,refetch:o}=$e({refetchInterval:c1});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(Nt,{size:120,className:"mb-8 opacity-80 dark:hidden"}),n.jsx(Nt,{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(L,{variant:"outline",className:"mt-6",onClick:()=>void o(),disabled:r,children:r?"Trying…":"Try again"})]})})}function l1(){return n.jsx(Fu,{testId:"server-unreachable",headline:"DorkOS can’t reach its server",detail:"It may still be starting up. DorkOS keeps checking."})}const d1="onboarding";function u1({render:e}){const t=cg(),s=lg(),{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:d1}),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 m1={renderAccountLink:e=>n.jsx(u1,{render:e}),renderRuntimeConnect:Cx,renderOtherService:({onSave:e})=>n.jsx(Nx,{onSave:e})},h1="HOST_NOT_ALLOWED",zi=240;function f1({status:e,message:t,code:s}){const r=s===h1&&t?t:void 0,o=r===void 0?`Your settings didn’t load (HTTP ${e}). DorkOS keeps trying.`:r.length>zi?`${r.slice(0,zi).trimEnd()}…`:r;return n.jsx(Fu,{testId:"server-error",headline:"The server answered with an error",detail:o})}function p1(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 xr={at:0};function g1(e,t){return e>xr.at&&(xr=t==null?{at:e}:{at:e,...p1(t)}),e>an?xr:void 0}function x1(e){return e.state.dataUpdatedAt>an?!0:"always"}function b1(e){return!e}function y1(e){var t;return((t=e.at(-1))==null?void 0:t.pathname)??""}function v1({descriptors:e}){const t=e.reduce((s,r)=>s===null||r.priority>s.priority?r:s,null);return n.jsx(tt,{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 w1=["memory-provider-status"],j1=6e4;function S1(){const e=ie(),{data:t}=Re({queryKey:[...w1],queryFn:()=>e.getMemoryProviderStatus(),staleTime:j1,refetchOnWindowFocus:!0});return t}function k1(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||C1(s,r))&&t.set(s.subject.id,s)}return[...t.entries()].filter(([,s])=>s.outcome!=="cleared").map(([s])=>s)}function C1(e,t){return e.createdAt!==t.createdAt?e.createdAt>t.createdAt:e.id>t.id}function N1({configuredId:e,benched:t}){return n.jsxs(Nl,{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 A1="runtimes",E1=3;function I1({runtimes:e}){const{open:t}=at(),s=dg();if(e.length===0)return null;const r=e.slice(0,E1).map(ml),o=e.length-r.length,a=e.length===1?`${r[0]} sign-in`:`${T1(r)} sign-ins`,i=o>0?`, and ${o} more`:"";return n.jsxs(Nl,{variant:"critical",icon:Er,actions:n.jsxs(n.Fragment,{children:[s&&n.jsx(R1,{runtimes:e,renderCreditsOffer:s}),n.jsx(L,{variant:"outline",size:"sm",onClick:()=>t(A1),children:"Sign in"})]}),children:["Your ",n.jsx("span",{className:"font-medium",children:a})," stopped working",i,". Agents and tasks wait until you sign in again."]})}function R1({runtimes:e,renderCreditsOffer:t}){var d;const s=ic(),{data:r}=lc(),o=!Ax(),a=((d=Pc().data)==null?void 0:d.linked)===!0,i=ug(a,Lc({enabled:a}).data),c=e.find(u=>mg(hg(s.data,u),r,u)==="lead");return c?n.jsxs(ln,{children:[n.jsx(dn,{asChild:!0,children:n.jsx(L,{size:"sm","data-testid":"signin-banner-credits",disabled:i===null,children:i===null?"DorkOS credits":`${i} DorkOS credits`})}),n.jsxs(un,{align:"end",className:"w-80 p-4",children:[n.jsxs(mn,{children:["Run ",ml(c)," on DorkOS credits"]}),n.jsxs("div",{className:"space-y-3",children:[t({runtime:c,origin:`signin-banner:${c}`,fullWidth:!0}),n.jsx(Ex,{remote:o})]})]})]}):null}function T1(e){return e.length<=1?e[0]??"":`${e.slice(0,-1).join(", ")} and ${e[e.length-1]}`}const $u={critical:40,warning:30};function D1(){const e=S1();return!e||e.configuredId===e.activeId?null:{id:"memory-provider-benched",variant:"warning",priority:$u.warning,render:()=>n.jsx(N1,{configuredId:e.configuredId,benched:e.benched})}}const O1={kinds:["signin.required"]};function M1(){const{notifications:e}=fg(O1),t=l.useMemo(()=>k1(e),[e]);return t.length===0?null:{id:"runtime-signin",variant:"critical",priority:$u.critical,render:()=>n.jsx(I1,{runtimes:t})}}function _1(e){const t=D1(),s=M1();return[t,s].filter(r=>r!==null)}function P1(){const e=Vn(),[t,s]=l.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(hl,{children:[n.jsx(fl,{children:"Share anonymous usage data?"}),n.jsx(pl,{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(Bx,{open:t,onToggle:()=>s(a=>!a)}),n.jsx("a",{href:Nr("/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(zx,{})]}),n.jsxs(gl,{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(L,{variant:"outline",size:"sm",onClick:r,disabled:e.isPending,children:"Don’t share"}),n.jsx(L,{size:"sm",onClick:o,disabled:e.isPending,children:"Share anonymously"})]})]})]})}function L1(e){return e.everyAgentLevel!==void 0?e.everyAgentLevel!==null:e.everyAgent!==null}function F1(e){const{data:t}=ib(),s=new Set(e),r=((t==null?void 0:t.connections)??[]).filter(a=>s.has(a.connectionId)&&L1(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=pg(a.toolkit);return{connectionId:a.connectionId,name:(o.get(a.toolkit)??0)>1?`${i} (${a.label})`:i}})}function $1({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(L,{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 B1=il("/guides/permissions#what-changed"),z1=["Everything they do is recorded in Activity. Anyone can pause an agent.","Messages and code from strangers still need your yes."],U1="Agents ask first again. Shared apps stay shared; change them in Connections.";function K1(e){return e instanceof Error&&e.message||"Couldn’t save that. Try again."}function H1({onClose:e,sharedConnectionIds:t=[]}){return t.length>0?n.jsx(W1,{onClose:e,connectionIds:t}):n.jsx(Bu,{onClose:e,sharedApps:[]})}function W1({onClose:e,connectionIds:t}){return n.jsx(Bu,{onClose:e,sharedApps:F1(t)})}function Bu({onClose:e,sharedApps:t}){const s=Fe(),r=Vn(),o=tb({kind:"default"}),[a,i]=l.useState(!1),[c,d]=l.useState(null),u=a||r.isPending||o.isPending,m=async(h,g)=>{d(null),i(!0);try{h&&await o.mutateAsync({kind:"preset",preset:"careful",surface:"first-run"}),await r.mutateAsync({ui:{trustNoticeSeenAt:new Date().toISOString()}})}catch(x){d(K1(x)),i(!1);return}i(!1),h&&ue.success(t.length>0?U1:"Agents ask first again. Change it in Permissions."),e(),g==null||g()},f=h=>void s({...je.connections(),search:{app:h,who:"picked"}}),p=h=>{if(t.length>1){e(),f(h);return}m(!1,()=>f(h))};return n.jsxs(n.Fragment,{children:[n.jsxs(hl,{children:[n.jsx(fl,{"data-testid":"trust-notice",children:"Agents now work without asking"}),n.jsx(pl,{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:z1.map(h=>n.jsx("p",{children:h},h))}),t.length>0&&n.jsx($1,{apps:t,onChooseAgents:p,disabled:u}),c&&n.jsx("p",{role:"alert",className:"text-destructive text-xs",children:c}),n.jsxs(gl,{className:"items-center gap-2 sm:justify-between",children:[n.jsx(gg,{href:B1,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(L,{variant:"outline",size:"sm",onClick:()=>m(!0),disabled:u,children:"Keep asking me"}),n.jsx(L,{size:"sm",onClick:()=>m(!1),disabled:u,children:"Got it"})]})]})]})}function G1(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?!1:cb((a=e.permissions)==null?void 0:a.preset)==="trusted"}const zu={high:30,low:10};function q1(){var t;const{data:e}=$e();return(t=e==null?void 0:e.telemetry)!=null&&t.userHasDecided?null:{id:"telemetry-consent",priority:zu.low,render:()=>n.jsx(P1,{})}}function Y1(){const{data:e}=$e();return G1(e)?{id:"trust-notice",priority:zu.high,render:({onClose:t})=>{var s;return n.jsx(H1,{onClose:t,sharedConnectionIds:((s=e==null?void 0:e.permissions)==null?void 0:s.sharedAtUpgrade)??[]})}}:null}function V1(){const e=Y1(),t=q1();return _(r=>r.onboardingHiddenForSession)?[]:[e,t].filter(r=>r!==null)}function Q1(e){return e.reduce((t,s)=>t===null||s.priority>t.priority?s:t,null)}function X1({onboardingOverlayVisible:e=!1}){const t=V1(),{data:s,dataUpdatedAt:r}=$e(),o=_(y=>y.momentShownThisLaunch),a=_(y=>y.markMomentShown),[i,c]=l.useState(null),[d,u]=l.useState(null),m=l.useRef(null),f=(s==null?void 0:s.onboarding)!=null&&(s.onboarding.completedAt!=null||s.onboarding.dismissedAt!=null),p=r>an,h=e||!p||!f,g=h?null:Q1(t);i===null&&g!==null&&!o&&(c(g.id),u(g)),l.useEffect(()=>{i!==null&&a()},[i,a]);const x=!h&&i!==null&&t.some(y=>y.id===i),b=()=>c(null);return n.jsx(xg,{open:x,onOpenChange:y=>{y||b()},children:d!==null&&n.jsx(bg,{ref:m,onOpenAutoFocus:y=>{var k;y.preventDefault(),(k=m.current)==null||k.focus()},children:d.render({onClose:b})},d.id)})}const J1=[];function Z1(){const{approvals:e,isError:t,retry:s}=yg(),{interactions:r}=vg(),o=wg(),a=jg(e),i=Sg(r),c=Fe(),d=l.useMemo(()=>[...e.map(m=>kg(m.approvalId)),...r.map(m=>Cg(m.interaction.id))],[e,r]);return!t&&a.length===0&&r.length===0&&o.length===0?{slot:null,coveredSignalIds:J1}:{coveredSignalIds:d,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(Ng,{onRetry:s}),(r.length>0||o.length>0)&&n.jsx(Ag,{asks:r,agentNames:i,onOpenSession:m=>{c(Ft({session:m}))}}),a.length>0&&n.jsx(Eg,{approvals:a})]})}}const Uu=[{id:"home",label:"Home",icon:Ig,badged:!0,kind:"panel"},{id:"library",label:"All",icon:jo,badged:!1,kind:"panel"},{id:"dorkbot",label:"DorkBot",icon:ko,badged:!1,kind:"action"},{id:"you",label:"You",icon:ao,badged:!1,kind:"panel"}],eI=xl.filter(e=>e==="library"),tI=xl.filter(e=>e!=="library"),Qr="calc(3.5rem + env(safe-area-inset-bottom))",Ns=Rg(e=>({panelUp:!1,raise:()=>e({panelUp:!0}),lower:()=>e({panelUp:!1})}));function Ui(){Ns.getState().lower()}function nI({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 border-border/60 flex shrink-0 items-stretch border-t",style:{height:Qr,paddingBottom:"env(safe-area-inset-bottom)"},children:Uu.map(a=>{const i=a.icon,c=a.id===e,d=a.badged&&t>0?t:null,u=a.kind==="action"&&!s;return n.jsxs("button",{type:"button",onClick:()=>r(a.id),disabled:u,"aria-current":c?"page":void 0,"data-testid":`mobile-tab-${a.id}`,"data-mobile-tab":"",className:K("focus-ring text-2xs relative flex flex-1 flex-col items-center justify-center gap-0.5 transition-[color,background-color,scale] duration-150","active:bg-sidebar-accent motion-safe:active:scale-[0.96]",c?"text-sidebar-foreground font-semibold":"text-sidebar-foreground/70 hover:text-sidebar-foreground font-medium","disabled:pointer-events-none disabled:opacity-50"),children:[n.jsxs("span",{className:"relative",children:[n.jsx(i,{className:"size-5","aria-hidden":!0}),d!==null&&n.jsx("span",{"data-testid":`mobile-tab-badge-${a.id}`,"aria-hidden":!0,className:"text-3xs absolute -top-1.5 -right-2.5 min-w-4 rounded-full bg-amber-500 px-1 text-center leading-4 font-semibold text-amber-950 tabular-nums",children:d})]}),a.label]},a.id)})})}function br({id:e,active:t,children:s}){return n.jsx("div",{id:`mobile-tab-panel-${e}`,"data-testid":`mobile-tab-panel-${e}`,"data-active":t?"":void 0,inert:!t,className:K("absolute inset-0",!t&&"invisible"),children:s})}function sI({takeover:e}){xu();const t=Z1(),s=vu({coveredSignalIds:t.coveredSignalIds}),r=bu(s),{ask:o,ready:a}=Tg(),[i,c]=l.useState("home"),d=Ns(x=>x.panelUp),u=Ns(x=>x.raise),m=Wt();l.useEffect(()=>m.subscribe("onBeforeLoad",Ui),[m]),l.useEffect(()=>Ui,[]),l.useEffect(()=>(document.documentElement.style.setProperty("--mobile-tab-dock",Qr),()=>{document.documentElement.style.removeProperty("--mobile-tab-dock")}),[]);const f=l.useCallback(x=>{const b=Uu.find(y=>y.id===x);if(b!==void 0){if(b.kind==="action"){if(!a)return;c(x),o();return}c(x),u()}},[o,a,u]),p=r.zones.find(x=>x.id==="now"),h=(p==null?void 0:p.needsYouCount)??s.attention.length,g=Au((p==null?void 0:p.liveRegionText)??Dg(h));return n.jsxs(rl,{activeTarget:s.activeTarget,children:[n.jsxs("div",{"data-testid":"mobile-tab-panels",inert:!d,className:K("bg-background fixed inset-x-0 top-0 z-30",!d&&"pointer-events-none invisible"),style:{bottom:`calc(${Qr} + var(--pip-dock, 0px))`},children:[n.jsx(br,{id:"home",active:i==="home",children:n.jsxs(er,{width:"full",className:"px-3 py-2",children:[n.jsx(Tu,{}),n.jsx(Yr,{model:r,zoneIds:tI,nowSlot:t.slot,silenceLiveRegion:!0}),n.jsx(gu,{model:r})]})}),n.jsx(br,{id:"library",active:i==="library",children:n.jsx(er,{width:"full",className:"px-3 py-2",children:e??n.jsx(Yr,{model:r,zoneIds:eI,silenceLiveRegion:!0})})}),n.jsx(br,{id:"you",active:i==="you",children:n.jsxs(er,{width:"full",className:"px-3 py-4",children:[n.jsx("h1",{className:"text-foreground px-2 pb-2 text-sm font-semibold",children:"You"}),n.jsx(wA,{}),n.jsx(bl,{})]})})]}),n.jsx("span",{"data-testid":"mobile-needs-you-live-region","aria-live":"polite","aria-atomic":"true",className:"sr-only",children:g}),n.jsx(nI,{current:d?i:null,needsYouCount:h,dorkBotReady:a,onSelect:f})]})}function rI(){const{open:e}=at(),t=_(r=>r.setControlCenterOpen),s=Ws(()=>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(Ux,{surface:"control-center"}),n.jsxs(L,{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(hn,{className:"size-3.5","aria-hidden":!0})]})]})}const Xt={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 oI(){var m,f;const e=Us(),t=go(),s=_(p=>p.setRemoteAccessOpen),r=_(p=>p.setControlCenterOpen),a=Ws(()=>r(!1))(()=>s(!0)),i=e.isSetUp,c=e.state==="starting"||e.state==="stopping",d=e.hasServerReport;let u;return d?i?e.error!==null?u=n.jsxs("span",{className:"flex min-w-0 items-baseline gap-1.5",children:[n.jsx("span",{className:"text-destructive truncate",children:wl(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"?u=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"?u=`On · ${e.host??"connected"}`:e.state==="asleep"?u=e.host?`Closed for now · ${e.host}`:"Closed for now":e.state==="draining"?u=Xt.draining:e.state==="reconnecting"?u=e.host?`On · ${e.host} · reconnecting…`:"Reconnecting…":e.state==="starting"?u=Xt.starting:e.state==="stopping"?u=Xt.stopping:u=Xt.off:u=Xt.unconfigured:u=Xt.off,d&&((f=e.managed)!=null&&f.cloudStale)&&typeof u=="string"&&(u=`${u} · Can’t reach DorkOS Cloud`),n.jsx(yl,{label:"Remote access",description:n.jsx("span",{"data-testid":"remote-access-row-description",className:K("block min-w-0",c&&"motion-safe:animate-breath"),children:u}),children:n.jsx(vl,{checked:i&&e.isChecked,disabled:!d||i&&e.isTransitioning,"aria-label":"Remote access",onCheckedChange:p=>{if(!i){a();return}t.toggle(p)}})})}const aI=1,iI=10,cI=4;function lI(){var u,m;const{data:e}=$e(),t=Vn(),s=he(),{limits:r,setLimits:o}=Og(),a=Hs(),i=()=>void s.invalidateQueries({queryKey:ze.all}),c=((u=e==null?void 0:e.claudeCode)==null?void 0:u.persistentSession)??!0,d=((m=e==null?void 0:e.scheduler)==null?void 0:m.maxConcurrentRuns)??cI;return n.jsx(Mg,{children:n.jsxs(_g,{children:[!a&&n.jsx(oI,{}),n.jsx(_b,{}),n.jsx(xa,{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(Sa,{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:f=>o({turnLimitsEnabled:f})}),!a&&n.jsx(xa,{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(Sa,{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:f=>t.mutate({runtimes:{claudeCode:{persistentSession:f}}},{onSuccess:i})}),n.jsx(yl,{label:"Scheduled runs at once",description:"How many scheduled tasks run together.",children:n.jsx(Kx,{value:d,min:aI,max:iI,"aria-label":"Scheduled runs at once",onCommit:f=>t.mutate({scheduler:{maxConcurrentRuns:f}},{onSuccess:i})})})]})})}const Ki="claude-code";function dI(){var R,F,I,O,C;const{data:e}=$e(),{data:t}=cc(),{sessions:s}=Uc(),r=Pg(),{data:o}=Oc(r),{data:a}=Ox(),i=nb(),c=i.data,d=kj(),u=co(),{open:m}=at(),{open:f}=So(),p=oo(),h=_(j=>j.setControlCenterOpen),g=Ws(()=>h(!1)),x=i.isError,b=t===void 0||e===void 0||c===void 0&&!x,y=e==null?void 0:e.executionDefaults,k=(y==null?void 0:y.runtime)??Ki,S=(R=t==null?void 0:t.capabilities[k])==null?void 0:R.permissionModes,E=((F=S==null?void 0:S.values.find(j=>j.id===S.default))==null?void 0:F.stop)??"ask",v=(y==null?void 0:y.trustStop)??E,A=[];if(!b){for(const w of(y==null?void 0:y.perRuntime)??[])w.trustStop===null||w.trustStop===v||A.push({key:`runtime:${w.runtime}`,kind:"runtime",name:lt(w.runtime).label,detail:Xs(w.trustStop),onOpen:u?g(()=>m("runtimes")):null});for(const w of s){const D=(I=t==null?void 0:t.capabilities[w.runtime])==null?void 0:I.permissionModes,T=D==null?void 0:D.values.find($=>$.id===w.permissionMode),P=T==null?void 0:T.stop;!P||P===v||A.push({key:`session:${w.id}`,kind:"session",name:w.title||"Untitled chat",detail:(T==null?void 0:T.label)??Js(w.permissionMode),onOpen:u?g(()=>u(Ft({session:w.id,dir:w.cwd}))):null})}const j=((C=(O=t==null?void 0:t.capabilities[Ki])==null?void 0:O.permissionModes)==null?void 0:C.values)??[];for(const w of o??[]){const D=j.find(P=>P.id===w.permissionMode),T=D==null?void 0:D.stop;!T||T===v||A.push({key:`task:${w.id}`,kind:"task",name:w.displayName??w.name,detail:(D==null?void 0:D.label)??Js(w.permissionMode),onOpen:u?g(()=>u({...je.tasks()})):null})}for(const w of a??[]){const D=j.find(P=>P.id===w.permissionMode),T=D==null?void 0:D.stop;!T||T===v||A.push({key:`binding:${w.id}`,kind:"binding",name:w.label||w.adapterId,detail:(D==null?void 0:D.label)??Js(w.permissionMode),onOpen:u?g(()=>p({app:w.adapterId})):null})}}if(c){const j=new Map(c.areas.map(T=>[T.id,T.label])),w=new Map(c.areas.flatMap(T=>T.actions.map(P=>[P.id,P.title]))),D=T=>g(()=>f(T,"permissions"));for(const T of c.exceptions){const P=T.action?w.get(T.action)??T.action:j.get(T.area),$=sb[T.state];A.push({key:`agent-permission:${T.agentId}:${T.action??T.area}`,kind:"agent-permission",name:T.agentName,detail:`${P??T.area} ${$}`,why:{question:`Why is ${P??T.area} set to ${$} for ${T.agentName}?`,sentence:rb({state:T.state,source:T.action?"agent-action":"agent-area",preset:c.preset,agentName:T.agentName}),...T.lastChange?{lastChange:T.lastChange}:{}},onOpen:D(T.agentId),onReset:()=>d.mutate({agentId:T.agentId,key:T.action?{kind:"action",action:T.action}:{kind:"area",area:T.area},surface:"control-center"}),resetting:d.isPending})}for(const T of c.filesAndCommands.exceptions)A.push({key:`agent-permission:${T.agentId}:files`,kind:"agent-permission",name:T.agentName,detail:`Files & commands ${Xs(T.stop)}`,why:{question:`Why is Files & commands set to ${Xs(T.stop)} for ${T.agentName}?`,sentence:ob(T.stop,"agent",T.agentName),...T.lastChange?{lastChange:T.lastChange}:{}},onOpen:D(T.agentId),onReset:()=>d.mutate({agentId:T.agentId,key:{kind:"files"},surface:"control-center"}),resetting:d.isPending})}return{rows:A,isEmpty:!b&&!x&&A.length===0,isResolving:b,permissionsUnreadable:x}}const uI={runtime:Gb,session:Fg,task:Eo,binding:dc,"agent-permission":Lg};function mI(){const{rows:e,isEmpty:t,isResolving:s,permissionsUnreadable:r}=dI();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=uI[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(hn,{className:"text-muted-foreground/60 size-3.5 shrink-0","aria-hidden":!0})]}),o.why?n.jsx(ab,{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(L,{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(Cc,{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]})}function hI(){const e=Tl();return Dl(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(ad,{className:"mt-px size-3 shrink-0","aria-hidden":!0}),n.jsxs("span",{children:["Keeping this computer awake: ",Ol(e.working),"."]})]}):null}function fI(){return n.jsxs("div",{className:"flex flex-col gap-4","data-testid":"control-center-body",children:[n.jsx(rI,{}),n.jsx(lI,{}),n.jsx(mI,{}),n.jsx(hI,{})]})}function pI(){const e=_(r=>r.controlCenterOpen),t=_(r=>r.setControlCenterOpen),s=Me();return n.jsxs(ln,{open:e,onOpenChange:t,modal:!0,autoFocus:!0,children:[n.jsx(dn,{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-7 shrink-0 items-center justify-center rounded-md transition-colors",children:n.jsx(ba,{className:"size-4","aria-hidden":!0})})}),n.jsxs(un,{side:"bottom",align:"end","aria-label":"Control Center",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(ba,{className:"text-status-success size-4 shrink-0","aria-hidden":!0}),n.jsx("h2",{className:"text-sm font-semibold",children:"Control Center"})]}),n.jsx(mn,{children:"Control Center"}),n.jsx(fI,{})]})]})}function gI(){const e=_(t=>t.toggleControlCenter);l.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 xI(){const{isDesktop:e}=jl(),t="In use from the web";return e?n.jsx("p",{className:"text-sm font-medium",children:t}):n.jsx(mn,{className:"text-sm font-medium",children:t})}function bI(){const{presence:e,atThisComputer:t,end:s,ending:r,error:o}=Hx(),[a,i]=l.useState(!1);return e!=null&&e.active?n.jsxs(ln,{open:a,onOpenChange:i,children:[n.jsx(dn,{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($g,{className:"size-4","aria-hidden":!0})})}),n.jsxs(un,{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(xI,{}),e.since&&n.jsxs("p",{className:"text-muted-foreground text-xs",children:["Someone is chatting here from the web. Started ",Gn(e.since),"."]})]}),e.devices.length>0?n.jsx(Wx,{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(L,{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 yI(e,t){const s=l.useRef(null),[r,o]=l.useState(0);return l.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 vI({url:e}){const t=ot();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(Bg,{url:e,size:168})}),n.jsx("p",{className:"text-muted-foreground mt-2 text-center text-xs",children:"Scan with your phone"})]})}function wI({url:e}){const{copied:t,failed:s,copy:r}=Kn();let o,a;return t?(o=n.jsx(Gt,{className:"size-3.5"}),a="Copied"):s?(o=n.jsx(Ke,{className:"text-destructive size-3.5"}),a="Couldn’t copy"):(o=n.jsx(so,{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(L,{variant:"outline",size:"sm",className:"mt-2 w-full gap-1.5",onClick:()=>void r(e),children:[o,a]})]})}function jI(){const e=Us(),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 SI({onClose:e}){const t=Us(),s=go(),r=Me(),o=_(f=>f.setRemoteAccessOpen),a=Ws(e),i=t.url,c=t.mode==="managed",d=i?n.jsx(wI,{url:i},"link"):null,u=i?n.jsx(vI,{url:i},"qr"):null,m=r?[d,u]:[u,d];return n.jsxs("div",{className:"flex flex-col gap-3","data-testid":"remote-access-panel",children:[!r&&n.jsxs("header",{className:"flex items-center gap-2",children:[n.jsx("span",{className:K("inline-block size-2 shrink-0 rounded-full",Sl(t.state)),"aria-hidden":!0}),n.jsx("h2",{className:"text-sm font-semibold",children:kl(t.state)})]}),t.error!==null&&n.jsx("p",{role:"alert","data-testid":"remote-access-panel-error",className:"text-destructive text-xs",children:wl(t.error)}),c&&n.jsx(jI,{}),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(vl,{checked:t.isChecked,disabled:t.isTransitioning,"aria-label":"Remote access",onCheckedChange:f=>void s.toggle(f)})]}),n.jsx(L,{variant:"ghost",size:"sm",className:"text-muted-foreground hover:text-foreground -mx-1 justify-start",onClick:a(()=>o(!0)),children:"Manage…"})]})}function Ku(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 kI(e,t){const s=e==="starting"||e==="asleep"&&!t?"Open remote access":"Show link and QR code";return`${Ku(e,t)}. ${s}`}function CI(){const e=Us(),t=_(i=>i.remoteAccessBeaconOpen),s=_(i=>i.setRemoteAccessBeaconOpen),r=ot(),o=yI(e.state,e.hasServerReport);l.useEffect(()=>{!e.isLive&&t&&s(!1)},[e.isLive,t,s]);const a=e.isLive?Ku(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(ln,{open:t,onOpenChange:s,modal:!0,children:[n.jsx(dn,{asChild:!0,children:n.jsxs("button",{type:"button","data-testid":"remote-access-beacon","data-state-name":e.state,"aria-label":kI(e.state,e.host),className:K("focus-ring text-muted-foreground hover:text-foreground relative inline-flex size-7 shrink-0 items-center justify-center rounded-md transition-colors",e.state==="reconnecting"&&"opacity-70"),children:[n.jsx(ps,{className:K("size-4",e.state==="starting"&&"motion-safe:animate-breath"),"aria-hidden":!0}),n.jsx("span",{"aria-hidden":!0,"data-testid":"remote-access-beacon-dot",className:K("border-background absolute right-0.5 bottom-0.5 size-1.5 rounded-full border",Sl(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(un,{side:"bottom",align:"end","aria-label":"Remote access",className:"w-72 max-w-[calc(100vw-1.5rem)] p-3",children:[n.jsx(mn,{children:kl(e.state)}),n.jsx(SI,{onClose:()=>s(!1)})]})]}),n.jsx(bI,{})]})}function NI({work:e}){const{isDesktop:t}=jl();return t?n.jsxs("p",{className:"text-sm font-medium",children:["Keeping awake: ",e]}):n.jsxs(mn,{className:"text-sm font-medium",children:["Keeping awake: ",e]})}function AI(){const e=Tl(),{open:t}=at(),[s,r]=l.useState(!1);if(!Dl(e))return null;const o=Ol(e.working);return n.jsxs(ln,{open:s,onOpenChange:r,children:[n.jsx(dn,{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-7 shrink-0 items-center justify-center rounded-md transition-colors",children:n.jsx(ad,{className:"size-4","aria-hidden":!0})})}),n.jsxs(un,{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(NI,{work:o}),n.jsx("p",{className:"text-muted-foreground text-xs",children:Gx}),n.jsx(L,{variant:"outline",size:"sm",onClick:()=>{r(!1),t(wa.tab,wa.section)},children:"Sleep settings"})]})]})}function EI(){const e=ie(),t=he();return Ht({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 II(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 RI({step:e,templateName:t,seedDisplayName:s=null,faceSeed:r=null,runtimeSeed:o="claude-code"}){var ce;const a=ie(),{data:i}=Re({queryKey:ze.current(),queryFn:()=>a.getConfig(),staleTime:3e4}),c=((ce=i==null?void 0:i.agents)==null?void 0:ce.defaultDirectory)??"",[d,u]=l.useState(""),[m,f]=l.useState(!1),[p,h]=l.useState(""),[g,x]=l.useState(!1),[b,y]=l.useState(!1),[k,S]=l.useState(null),[E,v]=l.useState(""),[A,R]=l.useState(!1),[F,I]=l.useState(o),[O,C]=l.useState(s);s!==O&&(C(s),s&&(u(s),f(!1)));const[j,w]=l.useState(o);o!==j&&(w(o),I(o));const D=l.useMemo(()=>d?zg(d):"",[d]),T=l.useMemo(()=>D?Ug(D):{valid:!1,error:void 0},[D]),P=d.length>0&&D.length>0&&!T.valid,$=p||(c&&D?`${c}/${D}`:""),B=e!=="naming"||!$?"idle":k!==null&&k.directory===$?k.status:"checking",Y=d.length>0&&T.valid&&B!=="error",se=l.useRef(null);l.useEffect(()=>{if(e!=="naming")return;const V=t?!d||m?t.replace(/^@[^/]+\//,""):null:m?"":null;if(V===null)return;const M=`${e}|${t??""}`;se.current!==M&&(se.current=M,u(V),f(!!t))},[e,t]);const fe=l.useRef(null);l.useEffect(()=>{if(e!=="naming"||A||!r)return;const V=`${e}|${r}`;fe.current!==V&&(fe.current=V,v(r))},[e,r]),l.useEffect(()=>{if(e!=="naming"||!$)return;const V=$,M=setTimeout(()=>{II(a,V).then(X=>{S({directory:V,status:X})})},500);return()=>clearTimeout(M)},[e,$,a]);function G(V){u(V),m&&f(!1)}function q(V){v(V),R(!0)}function ee(){se.current=null,fe.current=null,u(""),f(!1),h(""),x(!1),y(!1),S(null),v(""),R(!1),I(o)}return{displayName:d,slug:D,handleNameChange:G,nameAutoFilled:m,slugValidation:T,showSlugError:P,defaultDirectory:c,resolvedDirectory:$,directoryOverride:p,setDirectoryOverride:h,directoryOpen:g,setDirectoryOpen:x,directoryPickerOpen:b,setDirectoryPickerOpen:y,conflictStatus:B,canSubmit:Y,icon:E,setIcon:q,runtime:F,setRuntime:I,reset:ee}}function TI(e){var a;const t=(e==null?void 0:e.packageName)??null,{data:s,isError:r,error:o}=Qx(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&&Xx(o)&&{refusal:o},...s!=null&&s.disclosed&&s.contentHash?{approval:{approvedDisclosure:s.disclosed,approvedContentHash:s.contentHash},packageAgentName:s.manifest.name}:{}}}const DI={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."}},yr={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"]},OI=[["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 MI(e){if(!e)return yr.default;const t=[e.name,e.description,e.category,...e.tags??[]].filter(Boolean).join(" ").toLowerCase();for(const[s,r]of OI)if(r.some(o=>t.includes(o)))return yr[s];return yr.default}function _I(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 PI=64,LI=16,Hi=3;function FI(e){return e.map(t=>t.replace(/[\u0000-\u001f\u007f]/g," ").replace(/\s+/g," ").trim().slice(0,PI)).filter(t=>t.length>0).slice(0,LI)}function $I(e){const t=FI(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 ${Zt.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 ${Zt.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 BI(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 ${Zt.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 ${Hi} 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 ${Hi} 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 ${Zt.soul} now, using your file-editing tools. It lives at \`.dork/${Zt.soul}\` in your working directory and already contains a "Personality Traits" block fenced by \`${Kg}\` and \`${ya}\` — leave that fenced block exactly as it is. Replace only the prose BELOW the \`${ya}\` 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 ${Zt.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 zI={template:$I,"design-your-own":BI};function UI(e,t){return zI[e](t)}function KI(e,t){return mb(UI(e,t))}const Hu="🤖",HI=["🤖","🦾","🧭","🛰️","📡","🔭","🗺️","🧠","🦉","🦊","🐝","🐙","🚀","⚡","🌟","🔮","🛠️","🔧","📊","📋","✅","🗂️","🔔","🛡️"];function Wi({face:e,title:t,subtitle:s,chips:r,variant:o,tabIndex:a,onSelect:i,onKeyDown:c,ref:d,"data-testid":u}){return n.jsxs("button",{ref:d,type:"button",tabIndex:a,onClick:i,onKeyDown:c,"data-gallery-card":"","data-testid":u,className:K("card-interactive group flex h-full flex-col gap-2 rounded-xl border p-4 text-left","focus-visible:ring-ring focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none",o==="design"?"border-primary/40 bg-primary/5 hover:border-primary/60 border-dashed":"bg-card hover:border-border/80 hover:shadow-md"),children:[n.jsx("span",{className:"text-3xl leading-none","aria-hidden":!0,children:e}),n.jsxs("div",{className:"space-y-0.5",children:[n.jsx("p",{className:"text-sm font-semibold",children:t}),n.jsx("p",{className:"text-muted-foreground text-xs leading-relaxed",children:s})]}),r&&r.length>0&&n.jsx("div",{className:"mt-auto flex flex-wrap gap-1 pt-1",children:r.map(m=>n.jsx("span",{className:"bg-muted text-muted-foreground text-2xs rounded-full px-2 py-0.5",children:m},m))})]})}function WI(e){return{source:e.source,name:e.name,displayName:Cl(e),description:e.description,icon:e.icon,tags:e.tags,category:e.category,packageName:e.name,...e.marketplace?{marketplace:e.marketplace}:{}}}function GI(e){return e.tags&&e.tags.length>0?e.tags.slice(0,2):e.category?[e.category]:[]}function qI(e){const t=e.replace(/\/+$/,"");return t.split("/").pop()??t}function YI({onDesignYourOwn:e,onSelectTemplate:t,onImport:s}){const{data:r,error:o,isLoading:a}=Hg(),i=$l(a),[c,d]=l.useState(""),[u,m]=l.useState(!1),f=l.useMemo(()=>(r??[]).filter(h=>h.type==="agent"),[r]),p=Uy(f.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(Wi,{ref:p.setRef(0),variant:"design",face:n.jsx(ko,{className:"text-primary size-7"}),title:"Design your own",subtitle:"Describe the job in your own words.",tabIndex:p.tabIndexFor(0),onSelect:e,onKeyDown:h=>p.handleKeyDown(h,0),"data-testid":"gallery-design-your-own"}),f.map((h,g)=>{const x=g+1;return n.jsx(Wi,{ref:p.setRef(x),variant:"template",face:h.icon??Hu,title:Cl(h),subtitle:h.description??"A ready-made agent.",chips:GI(h),tabIndex:p.tabIndexFor(x),onSelect:()=>t(WI(h)),onKeyDown:b=>p.handleKeyDown(b,x),"data-testid":`gallery-template-${h.name}`},h.name)}),i&&f.length===0&&Array.from({length:2}).map((h,g)=>n.jsx(_t,{className:"h-28 rounded-xl","data-testid":"gallery-skeleton"},g))]}),!i&&f.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(Co,{open:u,onOpenChange:m,children:[n.jsx(No,{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(qt,{className:K("size-3.5 transition-transform",u&&"rotate-180")}),"Build from a template URL"]})}),n.jsx(Ao,{children:n.jsxs("div",{className:"flex items-center gap-2 pt-2",children:[n.jsx(gt,{value:c,onChange:h=>d(h.target.value),placeholder:"github.com/org/repo","data-testid":"custom-url-input",className:"flex-1"}),n.jsx(L,{size:"sm",disabled:!c,onClick:()=>{const h=qI(c);t({source:c,name:h,displayName:Wg(h)}),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(Gg,{className:"size-4"}),"Bring in an existing project folder",n.jsx("span",{"aria-hidden":!0,children:"→"})]})})]})}function VI({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:HI.map(s=>{const r=s===e;return n.jsx("button",{type:"button","aria-label":`Face ${s}`,"aria-pressed":r,onClick:()=>t(s),className:K("flex size-9 items-center justify-center rounded-md border text-lg transition-colors","focus-visible:ring-ring focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none",r?"border-primary bg-primary/10":"hover:border-border hover:bg-accent border-transparent"),"data-testid":`face-${s}`,children:n.jsx("span",{"aria-hidden":!0,children:s})},s)})})}function QI({value:e,onChange:t}){return n.jsx("div",{role:"radiogroup","aria-label":"Runs on",className:"flex gap-1.5","data-testid":"runtime-picker",children:qg.map(s=>{const r=lt(s),o=r.icon,a=e===s;return n.jsxs("button",{type:"button",role:"radio","aria-checked":a,onClick:()=>t(s),className:K("flex flex-1 items-center justify-center gap-1.5 rounded-md border px-2 py-1.5 text-xs transition-colors","focus-visible:ring-ring focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none",a?"border-primary bg-primary/10 font-medium":"hover:border-border hover:bg-accent border-transparent"),"data-testid":`runtime-${s}`,children:[n.jsx(o,{size:14}),r.label]},s)})})}function XI({face:e,name:t,jobLine:s,capabilities:r,className:o}){const a=t.trim()||"Your agent",i=t.trim().length===0;return n.jsxs("div",{className:K("bg-card shadow-soft flex flex-col items-center gap-3 rounded-lg border p-5",o),"data-testid":"agent-preview",children:[n.jsx("span",{className:"bg-primary/10 flex size-16 items-center justify-center rounded-full text-3xl","aria-hidden":!0,children:e}),n.jsxs("div",{className:"space-y-1 text-center",children:[n.jsx("p",{className:K("text-lg font-semibold",i&&"text-muted-foreground"),"data-testid":"preview-name",children:a}),n.jsx("p",{className:"text-muted-foreground text-sm leading-relaxed",children:s})]}),r.length>0&&n.jsx("div",{className:"flex flex-wrap justify-center gap-1.5","data-testid":"preview-capabilities",children:r.map(c=>n.jsx("span",{className:"bg-muted text-muted-foreground rounded-full px-2 py-0.5 text-xs",children:c},c))})]})}function Wu({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(Eo,{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}),": ",Jx(r)]},`${r.name}-${o}`))})]}),t&&n.jsxs("div",{className:"flex items-start gap-2","data-testid":`${s}-offer-check-failed`,children:[n.jsx(Zi,{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 Gi=4;function JI({form:e,suggestionPool:t,jobLine:s,previewCapabilities:r,onBack:o,onImportInstead:a,onCreate:i,isCreating:c,packageSchedules:d=[],offerCheckFailed:u=!1,isCheckingOffer:m=!1,offerRefusal:f,packageDirectory:p,templateReview:h,inheritance:g,isCheckingInheritance:x=!1}){const b=l.useRef(null),[y,k]=l.useState(0),S=e.displayName.trim().toLowerCase(),E=t.filter(F=>F.toLowerCase()!==S),v=_I(E,y,Gi);l.useEffect(()=>{const F=setTimeout(()=>{var I;return(I=b.current)==null?void 0:I.focus()},160);return()=>clearTimeout(F)},[]);const A=e.displayName.trim(),R=c?`Creating ${A||"your agent"}…`:`Create ${A||"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(Tc,{className:"size-3.5"}),"Choose a different agent"]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(Ge,{htmlFor:"agent-name",className:"text-sm",children:"Name"}),n.jsx(gt,{ref:b,id:"agent-name",placeholder:"Name your agent",value:e.displayName,onChange:F=>e.handleNameChange(F.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:()=>k(F=>F+Gi),"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(F=>n.jsx("button",{type:"button",onClick:()=>e.handleNameChange(F),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-${F}`,children:F},F))})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsxs("div",{className:"flex items-baseline gap-2",children:[n.jsx(Ge,{className:"text-sm",children:"Face"}),!e.icon&&n.jsx("span",{className:"text-muted-foreground text-xs",children:"Picked for you if skipped"})]}),n.jsx(VI,{value:e.icon,onChange:e.setIcon})]}),n.jsxs(Co,{open:e.directoryOpen,onOpenChange:e.setDirectoryOpen,children:[n.jsx(No,{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(qt,{className:K("size-4 transition-transform",e.directoryOpen&&"rotate-180")}),"Details",e.directoryOverride&&n.jsx("span",{className:"bg-primary/10 text-primary ml-1 rounded px-1.5 py-0.5 text-xs",children:"Custom"})]})}),n.jsx(Ao,{children:n.jsxs("div",{className:"space-y-4 pt-3",children:[n.jsxs("div",{className:"space-y-1.5",children:[n.jsx(Ge,{className:"text-muted-foreground text-xs",children:"Runs on"}),n.jsx(QI,{value:e.runtime,onChange:e.setRuntime})]}),p?n.jsxs("div",{className:"space-y-1.5","data-testid":"package-directory",children:[n.jsx(Ge,{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(Ge,{htmlFor:"agent-directory",className:"text-muted-foreground text-xs",children:"Directory"}),n.jsx(ry,{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(XI,{face:e.icon||Hu,name:e.displayName,jobLine:s,capabilities:r}),(d.length>0||u)&&n.jsx("dl",{className:"bg-muted/30 space-y-2.5 rounded-lg border p-3.5 text-sm",children:n.jsx(Wu,{schedules:d,checkFailed:u,testIdPrefix:"naming"})}),f!==void 0&&n.jsx(Pl,{error:f}),h,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(L,{size:"lg",onClick:i,disabled:!e.canSubmit||c||m||x||f!==void 0,"data-testid":"create-button",children:R})]})]})}function ZI({seed:e,packageSchedules:t,isCheckingOffer:s,offerCheckFailed:r,offerRefusal:o,resolvedDirectory:a,canSubmit:i,isCreating:c,inheritance:d,isCheckingInheritance:u=!1,onCreate:m,onCustomize:f,onNotNow:p}){const{displayName:h,persona:g,runtime:x,capabilities:b,skills:y,schedule:k,icon:S}=e.template,E=lt(x??"claude-code").label,v=h.trim().charAt(0).toUpperCase()||"?",A=S&&Rr(S)?S: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:A}),n.jsxs("div",{className:"space-y-1",children:[n.jsxs(nt,{className:"text-xl",children:["Meet ",h]}),n.jsx(ft,{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(eR,{runtime:x}),n.jsx("dt",{className:"text-muted-foreground shrink-0",children:"Runs on"}),n.jsx("dd",{children:E})]}),n.jsxs("div",{className:"flex items-start gap-2",children:[n.jsx(Ts,{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(_t,{className:"h-3.5 w-48 max-w-full rounded"})})]}),k&&n.jsxs("div",{className:"flex items-start gap-2","data-testid":"arrival-schedule",children:[n.jsx(Eo,{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:k})]}),n.jsx(Wu,{schedules:t,checkFailed:r,testIdPrefix:"arrival"}),b&&b.length>0&&n.jsxs("div",{className:"flex items-start gap-2",children:[n.jsx(qx,{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:b.join(", ")})]}),y&&y.length>0&&n.jsxs("div",{className:"flex items-start gap-2",children:[n.jsx(Yg,{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:y.join(", ")})]})]}),o!==void 0&&n.jsx(Pl,{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(L,{size:"lg",onClick:m,disabled:c||!i||s||u||o!==void 0,"data-testid":"arrival-create",children:c?"Creating…":`Create ${h}`}),n.jsxs("div",{className:"flex items-center justify-center gap-4",children:[n.jsx(L,{variant:"ghost",size:"sm",onClick:f,className:"text-muted-foreground","data-testid":"arrival-customize",children:"Customize first"}),n.jsx(L,{variant:"ghost",size:"sm",onClick:p,className:"text-muted-foreground","data-testid":"arrival-not-now",children:"Not now"})]})]})]})}function eR({runtime:e}){const t=lt(e??"claude-code").icon;return n.jsx(t,{size:16,className:"text-muted-foreground shrink-0"})}function tR(e){const t=e==null?void 0:e.body;return(t==null?void 0:t.code)==="template_needs_review"?t.template:void 0}function nR(e,t){const s=e.replace(/\/*$/,"/");return t.filter(r=>r.path===e||r.path.startsWith(s))}function sR(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 rR(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 oR(e){const{disclosed:t}=e;return[...e.findings.map(s=>({key:`finding:${s.path}`,label:s.path,detail:"Settings the agent loads: hooks, permission rules or servers.",files:nR(s.path,e.settings??[])})),...t.hooks.map((s,r)=>({key:`hook:${r}`,label:ut(s.command),detail:`Runs on ${s.event}${s.source?`, while ${ut(s.source)} is in use`:""}.`})),...(t.skillCommands??[]).map((s,r)=>({key:`command:${s.source}:${r}`,label:ut(s.command),detail:`Runs when skill “${ut(s.skill)}” is used (${ut(s.source)})`+(s.usesArguments?". Reads the text typed after it.":".")})),...t.mcpServers.map(s=>({key:`mcp:${s.name}`,label:s.command?Qg(s.command,s.args):ut(s.url??s.name),detail:`Starts the MCP server “${ut(s.name)}”.`})),...t.skillTools.map(s=>({key:`tools:${s.source}`,label:s.tools.map(ut).join(", "),detail:`Skill “${ut(s.skill)}” may use these without asking you.`}))]}function aR({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(Vg,{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:oR(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:sR(i)})]},i.path))]},o.key)})}),n.jsxs("div",{className:"flex flex-wrap justify-end gap-2",children:[n.jsx(L,{variant:"ghost",size:"sm",onClick:s,disabled:r,children:"Don’t create it"}),n.jsx(L,{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…":rR(e)})]})]})}function iR(){const{isOpen:e,seed:t,onCreated:s,close:r}=Rs(),o=en(G=>G.open),a=EI(),i=Fe(),[c,d]=l.useState("gallery"),[u,m]=l.useState(null),[f,p]=l.useState(!1);e!==f&&(p(e),e&&(m(null),d(t?"arrival":"gallery")));const h=t!=null&&t.template.icon&&Rr(t.template.icon)?t.template.icon:void 0,g=u!=null&&u.icon&&Rr(u.icon)?u.icon:h??null,x=(t==null?void 0:t.template.runtime)??"claude-code",b=(t==null?void 0:t.packageName)!==void 0?t:(u==null?void 0:u.packageName)!==void 0?{packageName:u.packageName,marketplace:u.marketplace}:null,y=TI(b),{data:k}=$e(),S=Hs()?void 0:T,E=b&&y.packageAgentName&&(k!=null&&k.dorkHome)?`${k.dorkHome}/agents/${y.packageAgentName}`:void 0,[v,A]=l.useState(null),R=RI({step:c,templateName:(u==null?void 0:u.displayName)??null,seedDisplayName:(t==null?void 0:t.template.displayName)??null,faceSeed:g,runtimeSeed:x}),F=MI(u?{name:u.name,description:u.description,category:u.category,tags:u.tags}:t?{name:t.template.displayName,description:t.template.persona}:void 0),I=u?u.description??"A ready-made agent.":t!=null&&t.template.persona?t.template.persona:"You’ll define the job together in your first chat.",O=u?u.tags??[]:(t==null?void 0:t.template.capabilities)??[];function C(){R.reset(),A(null),m(null),d("gallery")}const j=l.useCallback(G=>{m(G),d("naming")},[]),w=l.useCallback(()=>{m(null),d("naming")},[]);function D(){d(t?"arrival":"gallery")}function T(){r(),C(),o()}function P(G){var ce;if(!R.canSubmit||a.isPending)return;const q=(b==null?void 0:b.packageName)!==void 0&&y.approval?{package:{name:b.packageName,...b.marketplace?{marketplace:b.marketplace}:{},...y.approval}}:void 0,ee=q?void 0:(u==null?void 0:u.source)??(t==null?void 0:t.template.source);a.mutate({name:R.slug,displayName:R.displayName.trim()||void 0,runtime:R.runtime,...!q&&R.directoryOverride?{directory:R.directoryOverride}:{},...R.icon?{icon:R.icon}:{},...q??{},...ee?{template:ee}:{},...G?{approvedTemplateHash:G}:{},...t!=null&&t.template.persona?{persona:t.template.persona}:{},...(ce=t==null?void 0:t.template.capabilities)!=null&&ce.length?{capabilities:t.template.capabilities}:{}},{onSuccess:V=>{const M=crypto.randomUUID(),X=V.displayName??V.name,ae=u||t?"template":"design-your-own";Xg.getState().register(M,{name:V.name,displayName:X,agentId:V.id,icon:V.icon,color:V.color,bornAt:V.registeredAt,path:V._path,runtime:V.runtime,kickoffMessage:KI(ae,{displayName:X,capabilities:V.capabilities})}),ny();const z=s;if(r(),C(),z){z();return}i(Ft({agentId:V.id,draft:"1",session:M,runtime:V.runtime}))},onError:V=>{const M=tR(V);M&&A(M)}})}function $(G){G||(r(),C())}const B=Ll(e),Y=n.jsx(dw,{agentName:R.displayName||(t==null?void 0:t.template.displayName)||""}),se=DI[c],fe=c==="gallery"?"max-w-6xl":c==="naming"?"max-w-5xl":"max-w-2xl";return n.jsx(xt,{open:e,onOpenChange:$,defaultFullscreen:!0,children:n.jsxs(bt,{className:"flex flex-col gap-0 p-0",children:["title"in se&&n.jsxs(ht,{className:"shrink-0 border-b px-5 py-4",children:[n.jsx(nt,{children:se.title}),n.jsx(ft,{children:se.description})]}),n.jsx("span",{className:"sr-only","aria-live":"polite","aria-atomic":"true",children:se.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 ${fe}`,children:[n.jsx(tt,{mode:"wait",children:n.jsxs(re.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.15},children:[c==="gallery"&&n.jsx(YI,{onDesignYourOwn:w,onSelectTemplate:j,onImport:S}),c==="arrival"&&t&&n.jsx(ZI,{seed:t,packageSchedules:y.schedules,isCheckingOffer:y.isChecking,offerCheckFailed:y.failed,offerRefusal:y.refusal,resolvedDirectory:E??R.resolvedDirectory,canSubmit:R.canSubmit,isCreating:a.isPending,inheritance:Y,isCheckingInheritance:B.isPending,onCreate:()=>P(),onCustomize:()=>d("naming"),onNotNow:()=>$(!1)}),c==="naming"&&n.jsx(JI,{form:R,suggestionPool:F,jobLine:I,previewCapabilities:O,onBack:D,onImportInstead:S,onCreate:()=>P(),isCreating:a.isPending,packageSchedules:y.schedules,offerCheckFailed:y.failed,offerRefusal:y.refusal,isCheckingOffer:y.isChecking,packageDirectory:E,inheritance:Y,isCheckingInheritance:B.isPending,templateReview:v?n.jsx(aR,{template:v,isCreating:a.isPending,onCreateAnyway:()=>P(v.contentHash),onCancel:()=>A(null)}):void 0})]},c)}),c!=="gallery"&&n.jsx(Pb,{className:"mt-6"})]})}),n.jsx(hc,{open:R.directoryPickerOpen,onOpenChange:R.setDirectoryPickerOpen,initialPath:R.directoryOverride||R.defaultDirectory,onSelect:G=>{R.setDirectoryOverride(G),R.directoryOpen||R.setDirectoryOpen(!0)}})]})})}function cR({sessionId:e}){l.useEffect(()=>{var a;const r=St.getState(),o=((a=r.sessions[e])==null?void 0:a.cwd)??r.statusCwds[e]??null;return hs.pinSession(e,o),va.getState().setPinnedSession(e),()=>{hs.unpinSession(),va.getState().setPinnedSession(null)}},[e]);const t=Jg(e),s=l.useMemo(()=>Kb(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(Hb,{code:s.code,isIncomplete:s.isIncomplete,sessionId:e,isLatestMessage:s.isLatest,isStreaming:s.isStreaming},s.sourceMessageKey)}function lR({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 vr=64,dR={type:"spring",stiffness:480,damping:44};function uR({content:e,onRestore:t,onClose:s}){l.useEffect(()=>(document.documentElement.style.setProperty("--pip-dock",`${vr}px`),()=>{document.documentElement.style.removeProperty("--pip-dock")}),[]);const r=Nb();return As.createPortal(n.jsxs(re.div,{"data-slot":"pip-minibar",role:"complementary","aria-label":e.title,initial:{y:vr},animate:{y:0},exit:{y:vr},transition:dR,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(Wy,{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(Ke,{className:"size-4"})})]}),document.body)}const os={peek:.5,expanded:.94},mR=.4,hR=800,qi=500,wr={type:"spring",stiffness:480,damping:44};function fR({content:e,onClose:t,onMinimize:s,children:r}){const o=by(),a=py(),[i,c]=l.useState("peek"),d=ed(),u=d.height,m=Math.max(0,window.innerHeight-d.top-d.height),f=os.expanded*u,p=(os.expanded-os.peek)*u,h=i==="expanded"?0:p;l.useEffect(()=>{a.start({y:h,transition:wr})},[a,h]);const g=(b,y)=>{const k=h+y.offset.y,S=y.velocity.y,E=k-p,v=os.peek*u;if(E>mR*v||E>0&&S>hR){s();return}let A;S<-qi?A="expanded":S>qi?A="peek":A=k<p/2?"expanded":"peek",A===i?a.start({y:h,transition:wr}):c(A)},x=b=>{b.target.closest("button")||o.start(b)};return As.createPortal(n.jsxs(re.div,{"data-slot":"pip-sheet",role:"complementary","aria-label":e.title,initial:{y:f},animate:a,exit:{y:f},transition:wr,drag:"y",dragListener:!1,dragControls:o,dragConstraints:{top:0,bottom:f},dragElastic:.1,dragMomentum:!1,onDragEnd:g,style:{height:f,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(qt,{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(Ke,{className:"size-4"})})]})]}),n.jsx("div",{"data-slot":"pip-sheet-content",style:{marginBottom:h},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 Yi=360,Vi=240,Xr=16,jr={demo:lR,mcp_app:pR,widget:gR};function pR({content:e}){return n.jsx(Jb,{sessionId:e.sessionId,serverName:e.serverName,uri:e.uri,title:e.title,className:"h-full"})}function gR({content:e}){return n.jsx(cR,{sessionId:e.sessionId})}function xR(e){l.useEffect(()=>{},[e])}function Qi(){return{x:window.innerWidth-Yi-Xr,y:window.innerHeight-Vi-Xr,width:Yi,height:Vi}}function bR(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function Gu(e){switch(e.kind){case"demo":{const t=jr.demo;return n.jsx(t,{content:e})}case"mcp_app":{const t=jr.mcp_app;return n.jsx(t,{content:e})}case"computer":return n.jsx(oy,{content:e});case"widget":{const t=jr.widget;return n.jsx(t,{content:e})}default:return e}}function yR({content:e,onClose:t}){const s=_(c=>c.pipGeometry),r=_(c=>c.setPipGeometry),[o,a]=l.useState(Qi);l.useEffect(()=>{if(s!==null)return;const c=()=>a(d=>{const u=Qi();return bR(d,u)?d:u});return c(),window.addEventListener("resize",c),()=>window.removeEventListener("resize",c)},[s]);const i=l.useMemo(()=>s||((e==null?void 0:e.kind)!=="computer"?o:{...o,width:480,height:360,x:Math.max(0,window.innerWidth-480-Xr),y:Math.max(0,window.innerHeight-360-80)}),[s,o,e==null?void 0:e.kind]);return n.jsx(tt,{children:e!==null&&n.jsx(sv,{title:e.title,geometry:i,onGeometryChange:r,onClose:t,minWidth:e.kind==="computer"?360:void 0,minHeight:e.kind==="computer"?300:void 0,children:Gu(e)},"pip-panel")})}function vR(){const e=_(d=>d.pipContent),t=_(d=>d.pipMinimized),s=_(d=>d.closePip),r=_(d=>d.minimizePip),o=_(d=>d.restorePip),a=_(d=>d.openPip),i=Me();xR(a);const c=l.useRef(i);return l.useEffect(()=>{i&&!c.current&&e!==null&&r(),c.current=i},[i,e,r]),i?n.jsx(tt,{children:e!==null&&(t?n.jsx(uR,{content:e,onRestore:o,onClose:s},"pip-minibar"):n.jsx(fR,{content:e,onClose:s,onMinimize:r,children:Gu(e)},"pip-sheet"))}):n.jsx(yR,{content:e,onClose:s})}const wR=new Set(["permission-prompt","question","schedule-approval"]),jR={"permission-prompt":"Needs your approval to go on.",question:"Has a question for you.","schedule-approval":"Wants to run on a timer."};function qu(e){const t=Xc(),s=Zg(),r=nn(e),o=l.useRef(null);l.useEffect(()=>{var u,m,f,p;if(s)return;const a=new Map;for(const h of t)wR.has(h.kind)&&a.set(h.id,{id:h.id,who:h.primary,summary:jR[h.kind],deepLink:h.deepLink});const i=o.current;if(o.current=new Set(a.keys()),i===null)return;const c=[...a.values()].filter(h=>!i.has(h.id)),d=[...i].filter(h=>!a.has(h));c.length>0&&((m=(u=r.read()).onArrive)==null||m.call(u,c)),d.length>0&&((p=(f=r.read()).onDepart)==null||p.call(f,d,a.size))},[s,t,r])}function SR(){const{permission:e}=Rb(),{prefs:t}=Tb(),s=co(),r=Ue(),o=l.useRef(new Map),a=nn(s),i=l.useCallback(()=>r||e!=="granted"||typeof document>"u"||!document.hidden?!1:typeof window<"u"&&typeof window.Notification<"u",[r,e]),c=l.useCallback((f,p,h,g)=>{let x;try{x=new Notification(p,{body:h,tag:f,silent:!0})}catch{return}x.onclick=()=>{var b;window.focus(),x.close(),o.current.delete(f),g!==null&&((b=a.read())==null||b({href:g}))},x.onclose=()=>{o.current.delete(f)},o.current.set(f,{notification:x,href:g})},[a]),d=l.useCallback(f=>{if(i())for(const p of f)c(p.id,`${p.who} needs you`,p.summary,p.deepLink)},[i,c]),u=l.useCallback(f=>{for(const p of f){const h=o.current.get(p);h!==void 0&&(h.notification.close(),o.current.delete(p))}},[]);qu({onArrive:d,onDepart:u});const m=t.notifyOnTurnCompleteWhileAway;we("notification",f=>{const p=ex.safeParse(f);if(!p.success)return;const h=p.data.notification;if(h.tier!=="notable"||!m||!i())return;const g=tx(h),x=g===null?null:kR(g.to,g.search);c(h.id,h.title,h.body??"",x)}),l.useEffect(()=>{const f=o.current;return()=>{for(const{notification:p}of f.values())p.close();f.clear()}},[])}function kR(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 CR(){const{play:e}=hb(),t=l.useCallback(()=>{e("knock"),fb()},[e]),s=l.useCallback((r,o)=>{o===0&&e("settle")},[e]);return qu({onArrive:t,onDepart:s}),SR(),null}function NR(){const e=_(r=>r.shortcutsPanelOpen),t=_(r=>r.setShortcutsPanelOpen),s=nx();return n.jsx(xt,{open:e,onOpenChange:t,children:n.jsxs(bt,{className:"sm:max-w-md",children:[n.jsx(ht,{children:n.jsx(nt,{children:"Keyboard shortcuts"})}),n.jsx(kt,{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(al,{className:"inline-flex",children:$t(i)})]},i.id))})]},r))})]})})}function AR(){const e=_(t=>t.toggleShortcutsPanel);l.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 ER=15e3;function IR(){const e=Le({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(i1,{contributionId:s.id,children:n.jsx(l.Suspense,{fallback:null,children:n.jsx(r,{})})}),direction:1,isTakeover:!0}}return{key:"dashboard",body:n.jsx($N,{}),direction:-1,isTakeover:!1}}function RR(){const e=Le({select:t=>t.matches});return Aj(e)}function TR(){const{sidebarOpen:e,setSidebarOpen:t}=_(),s=Me(),r=Ns(z=>z.panelUp),[o]=fc(),a=Le({select:z=>z.location.pathname}),i=Le({select:z=>z.location.searchStr}),c=new URLSearchParams(i),d=a==="/channels"&&!!c.get("community")&&!!c.get("id"),u=b1(ot()??!1),m=Le({select:z=>y1(z.matches)});Mv();const[f]=$s(),p=_(z=>z.isStreaming),{data:h}=vc(f),g=Yc(h??null,f??""),{room:x,unreadRoomCount:b}=n1();o1(),Fy({cwd:f,isStreaming:p,color:h?g.color:void 0}),AR(),jj(),jb(),gI(),Sb(),pb(),dS(),XE(),JE();const y=ZE();e1(),Bv(),w0(),Jw(),Zw(),sx(),Yx(),ww(),rx(),Av(),Rx(),By(),ox(),Sj(),ax(),L0(),lb();const k=_(z=>z.onboardingHiddenForSession),S=_(z=>z.setOnboardingHiddenForSession),{shouldShowOnboarding:E,isLoading:v,isOnboardingComplete:A,isOnboardingDismissed:R}=Yt(),F=zv({shouldShowOnboarding:E,onboardingHiddenForSession:k});Kv({done:A||R,overlayVisible:F}),wj({blocked:F});const{dataUpdatedAt:I,errorUpdatedAt:O,error:C}=$e({refetchOnMount:x1}),j=I>an,w=O>an,D=g1(O,C),[T,P]=l.useState(!1);l.useEffect(()=>{if(j)return;const z=setTimeout(()=>P(!0),ER);return()=>clearTimeout(z)},[j]);const $=(D==null?void 0:D.status)===void 0,B=!j&&$&&(w||T),Y=j||(D==null?void 0:D.status)===void 0?void 0:D,[se,fe]=l.useState(!1);l.useEffect(()=>{if(!v)return;const z=setTimeout(()=>fe(!0),3e3);return()=>clearTimeout(z)},[v]);const G=l.useCallback(()=>S(!0),[S]),q=IR(),{origin:ee,originLabel:ce}=ix(o),{data:V}=cx(o,{enabled:!1,select:z=>z.title}),M=RR(),X=l.useMemo(()=>({sessionId:o??void 0,agentName:h?Be(h):void 0,agentVisual:h?g:void 0,origin:ee,originLabel:ce,sessionTitle:V,sessionDirectoryName:f?ll(f):void 0,room:x,teamViewMode:lx(new URLSearchParams(i).get("view")??void 0)}),[o,h,g,ee,ce,V,f,x,i]),ae=_1();return B?n.jsx(l1,{}):(Y==null?void 0:Y.status)!==void 0?n.jsx(f1,{status:Y.status,message:Y.message,code:Y.code}):v&&!se?n.jsx("div",{className:"bg-background h-dvh"}):n.jsxs(dx,{children:[n.jsx(s1,{unreadRoomCount:b}),n.jsxs(uy,{reducedMotion:"user",children:[n.jsx(tt,{mode:"wait",children:F?n.jsx(re.div,{initial:{opacity:1},exit:{opacity:0},transition:{duration:.2},className:"fixed inset-0 z-50",children:n.jsx(mw,{onComplete:G,slots:m1})},"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(ux,{open:e,onOpenChange:t,className:K("flex-1 overflow-hidden",s&&"min-h-0"),style:{"--sidebar-width":"calc(272px + 1rem)"},children:[!s&&n.jsxs(mx,{variant:"inset",children:[n.jsx(a1,{isFullscreen:y}),n.jsx(Tu,{}),n.jsx("div",{className:"relative flex min-h-0 flex-1 flex-col overflow-hidden",children:n.jsx(tt,{mode:"wait",initial:!1,custom:q.direction,children:n.jsx(re.div,{"data-testid":"sidebar-body-swap",custom:q.direction,initial:"enter",animate:"center",exit:"exit",variants:{enter:z=>({x:`${z*100}%`,opacity:0}),center:{x:0,opacity:1},exit:z=>({x:`${z*-100}%`,opacity:0})},transition:{duration:.2,ease:[.4,0,.2,1]},className:"flex min-h-0 flex-1 flex-col overflow-hidden",children:q.body},q.key)})}),n.jsx(hx,{className:"px-2 py-3",children:n.jsx(bl,{})}),n.jsx(fx,{})]}),n.jsxs(px,{className:"overflow-hidden",inert:s&&r,children:[Ue()&&n.jsx(Qj,{className:K("app-drag-region",!e&&!y&&"desktop-darwin:pl-20")}),n.jsxs("header",{className:"app-drag-region @container/bar relative flex h-9 shrink-0 items-center gap-1 border-b px-2 transition-[border-color] duration-300 lg:gap-2",children:[!s&&n.jsxs(n.Fragment,{children:[n.jsx(gx,{className:"-ml-0.5"}),n.jsx(Zj,{}),n.jsx(xx,{orientation:"vertical",className:"mr-1 h-4"})]}),s&&n.jsx(vA,{}),n.jsx(tt,{mode:"wait",initial:!1,children:M&&n.jsx(re.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.1},className:"flex min-w-0 flex-1 items-center gap-1 self-stretch lg:gap-2",children:n.jsx(bx,{value:X,children:n.jsx(M.Header,{})})},M.key)}),n.jsx(pI,{}),n.jsx(CI,{}),n.jsx(AI,{}),n.jsx(yx,{})]}),n.jsx(v1,{descriptors:ae}),n.jsx("main",{id:Dd,className:"flex-1 overflow-hidden pb-[var(--pip-dock,0px)]",children:n.jsxs(vx,{direction:"horizontal",id:_r,autoSaveId:_r,children:[n.jsx(wc,{id:"main-content",order:1,minSize:30,defaultSize:100,children:n.jsx(re.div,{initial:u?{opacity:0}:!1,animate:{opacity:1},transition:u?{duration:.12,ease:"easeOut"}:{duration:0},"data-route-fade":u,className:"h-full",children:n.jsx(wx,{})},m)}),n.jsx(yj,{pathname:a,isRemoteCommunityRoom:d})]})})]})]}),s&&n.jsx(sI,{takeover:q.isTakeover?q.body:null})]})},"main-app")}),n.jsx(JA,{}),n.jsx(X1,{onboardingOverlayVisible:F}),n.jsx(QE,{}),n.jsx(CA,{}),n.jsx(GA,{}),n.jsx(iR,{}),n.jsx(Qw,{}),n.jsx(NR,{}),n.jsx(rv,{}),n.jsx(vR,{}),n.jsx(kx,{}),n.jsx(CR,{})]})]})}const aD=TR;export{aD as component};