dorkos 0.119.0 → 0.121.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (319) hide show
  1. package/dist/bin/cli.js +3332 -2835
  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-DPEGtCwv.js → AboutPage-CtI8gbER.js} +1 -1
  5. package/dist/client/assets/{ActivityErrorState-ENqFKw2l.js → ActivityErrorState-CHTXfBS7.js} +1 -1
  6. package/dist/client/assets/{ActivityPage-Bh3Fhkkr.js → ActivityPage-B8p4yYJL.js} +1 -1
  7. package/dist/client/assets/{ActivityRow-Mj9YGZo2.js → ActivityRow-CSuSz-92.js} +1 -1
  8. package/dist/client/assets/{AdapterIcon-BcejWkC-.js → AdapterIcon-Qnxn0cE5.js} +1 -1
  9. package/dist/client/assets/{AdapterSetupWizard-CEnUjD84.js → AdapterSetupWizard-BG8H-Lld.js} +1 -1
  10. package/dist/client/assets/{AgentOptionRow-DcKMOkUs.js → AgentOptionRow-BWFQFynn.js} +1 -1
  11. package/dist/client/assets/{AgentPicker-W6XeKjz9.js → AgentPicker-CL93SET3.js} +1 -1
  12. package/dist/client/assets/{AgentRequestCard-C8xPf4Ij.js → AgentRequestCard-CamX7Tvr.js} +3 -3
  13. package/dist/client/assets/{AppearancePage-uoWRNL1C.js → AppearancePage-rN70_7ih.js} +1 -1
  14. package/dist/client/assets/{ApplyToOverridesDialog-C5Nf8pjH.js → ApplyToOverridesDialog-DeWaXbgm.js} +1 -1
  15. package/dist/client/assets/{AttentionSignalRow-BI-uQ-ay.js → AttentionSignalRow-CKcSWExi.js} +1 -1
  16. package/dist/client/assets/{BaseTanStackRouterDevtoolsPanel-B-iktbLX-Cpi-0c7y.js → BaseTanStackRouterDevtoolsPanel-B-iktbLX-BwYaLf2P.js} +1 -1
  17. package/dist/client/assets/{BindingDialog-B3vCYvfL.js → BindingDialog-DqPDLYbF.js} +1 -1
  18. package/dist/client/assets/BlintzCanvas-DoAZs5bz.js +1231 -0
  19. package/dist/client/assets/{BlintzCanvas-GgiCXV7C.css → BlintzCanvas-xZ3u3nk7.css} +1 -1
  20. package/dist/client/assets/{CanvasCsvContent-DtZuAo03.js → CanvasCsvContent-ViqRJuhW.js} +1 -1
  21. package/dist/client/assets/CanvasFileContent-ClcHZ_l-.js +2 -0
  22. package/dist/client/assets/{CanvasModel3dContent-BlYcTOLd.js → CanvasModel3dContent-Cm3msNdQ.js} +2 -2
  23. package/dist/client/assets/{ChatAppsOff-B996C06C.js → ChatAppsOff-D0PbHYqF.js} +1 -1
  24. package/dist/client/assets/{CodeMirrorDiff-UfNeO6Wa.js → CodeMirrorDiff-DFNSXeuV.js} +1 -1
  25. package/dist/client/assets/{CodeMirrorEditor-BMSnTJnS.js → CodeMirrorEditor-AgkgsSqN.js} +1 -1
  26. package/dist/client/assets/{CommitmentList-LBnn140g.js → CommitmentList-0V6QivXH.js} +1 -1
  27. package/dist/client/assets/{CommitmentsPage-BNEP939u.js → CommitmentsPage-i3XoHwBj.js} +1 -1
  28. package/dist/client/assets/{ComputerResourceView-C97PoLhs.js → ComputerResourceView-RPoBc-km.js} +1 -1
  29. package/dist/client/assets/{ComputerViewer-DVaP4S-x.js → ComputerViewer-2ugaCd0H.js} +1 -1
  30. package/dist/client/assets/{ConnectionAccessLists-COotkMKW.js → ConnectionAccessLists-DaPP4U96.js} +1 -1
  31. package/dist/client/assets/{ConnectionsPage-DMqldmCl.js → ConnectionsPage-BVqYvfk5.js} +2 -2
  32. package/dist/client/assets/{ConventionPage-DXcAUNjb.js → ConventionPage-BoqncrFd.js} +1 -1
  33. package/dist/client/assets/{ExtensionPageRoute-Cx-zCEnS.js → ExtensionPageRoute-BrOEeNX3.js} +2 -2
  34. package/dist/client/assets/{FloatingTanStackRouterDevtools-CqogiFob-U9QmMzNM.js → FloatingTanStackRouterDevtools-CqogiFob-DLwix3K7.js} +1 -1
  35. package/dist/client/assets/HandlePage-B_5GLHsp.js +1 -0
  36. package/dist/client/assets/{HeartbeatPage-lS53N7qR.js → HeartbeatPage-DgXhbaBJ.js} +1 -1
  37. package/dist/client/assets/KeyEntry-CRr32Ae5.js +1 -0
  38. package/dist/client/assets/{LexicalField-NpV0yrX5.js → LexicalField-DeAoA6yr.js} +1 -1
  39. package/dist/client/assets/{ManagesPage-Dvjt_Ql0.js → ManagesPage-ZBWYLTZx.js} +1 -1
  40. package/dist/client/assets/{Marketplace-BXrL6XrG.js → Marketplace-iL5p8Omt.js} +4 -4
  41. package/dist/client/assets/{MarketplaceSourcesView-Xm9UboIG.js → MarketplaceSourcesView-CsNLVOdP.js} +1 -1
  42. package/dist/client/assets/{McpAppFrame-BOhSmDHb.js → McpAppFrame-B1WPswgk.js} +1 -1
  43. package/dist/client/assets/McpSigninBody-CJ28yu0o.js +1 -0
  44. package/dist/client/assets/{Model3dViewer-B0efG9VW.js → Model3dViewer-BIZWdK8g.js} +1 -1
  45. package/dist/client/assets/NamePage-0nr288eM.js +1 -0
  46. package/dist/client/assets/{NewDirectMessageMenu-BOwmahin.js → NewDirectMessageMenu-DRx9e9kM.js} +1 -1
  47. package/dist/client/assets/{NotificationsPage-pQg9DtG3.js → NotificationsPage-cfqgSuVy.js} +1 -1
  48. package/dist/client/assets/{OpenMeshSwitch-C5dCRdqs.js → OpenMeshSwitch-BIIuKDku.js} +1 -1
  49. package/dist/client/assets/{OperatorIdentityForm-CgSvpX-s.js → OperatorIdentityForm-BKUSGrs6.js} +1 -1
  50. package/dist/client/assets/{PermissionHistory-ChEe8iYR.js → PermissionHistory-Ctdqhib6.js} +1 -1
  51. package/dist/client/assets/{PermissionsPage-C8gICIw9.js → PermissionsPage-CYA_zdrV.js} +1 -1
  52. package/dist/client/assets/{PersonalityPopover-DcuHjnIT.js → PersonalityPopover-BR4Cpr2C.js} +1 -1
  53. package/dist/client/assets/PhotoPage-C3Ir3wlA.js +1 -0
  54. package/dist/client/assets/{PresetPicker-C-HcfktA.js → PresetPicker-zGvDOqTf.js} +2 -2
  55. package/dist/client/assets/{PreviewRefusedNotice-CgJeWKad.js → PreviewRefusedNotice-D1Tl265t.js} +1 -1
  56. package/dist/client/assets/{ProfileFields-Bpe71duM.js → ProfileFields-T3vVbHRC.js} +1 -1
  57. package/dist/client/assets/{ProfilePanelContainer-r2T2nLuy.js → ProfilePanelContainer-CParzTPA.js} +1 -1
  58. package/dist/client/assets/{ProfileRolePicker-B9as28eL.js → ProfileRolePicker-BU4eiMKn.js} +1 -1
  59. package/dist/client/assets/{PromptSuggestionChips-BjyRYcZH.js → PromptSuggestionChips-CGNQc2Tf.js} +1 -1
  60. package/dist/client/assets/{ReportsToPopover-Bs59IbmP.js → ReportsToPopover-Dj5U_Ppi.js} +1 -1
  61. package/dist/client/assets/{RoomSurface-CcxCucEt.js → RoomSurface-BIyjtxKD.js} +7 -7
  62. package/dist/client/assets/{RoomsPage-gAEppmDN.js → RoomsPage-Cvs3h6f0.js} +1 -1
  63. package/dist/client/assets/{RunsOnPopover-BYqbPh-k.js → RunsOnPopover-BUlYwRW4.js} +1 -1
  64. package/dist/client/assets/{RuntimeConnectFlow-BmMBE_ki.js → RuntimeConnectFlow-ChrvjC84.js} +1 -1
  65. package/dist/client/assets/{RuntimeSetupDialog-DsDi5RBn.js → RuntimeSetupDialog-BK9yo7YF.js} +1 -1
  66. package/dist/client/assets/{SessionsPage-Cid8fhdk.js → SessionsPage-CWUwU3US.js} +1 -1
  67. package/dist/client/assets/SettingsDialog-BApzy0J8.js +12 -0
  68. package/dist/client/assets/{SkillsPage-YiAaBf5n.js → SkillsPage-z3XnApNX.js} +1 -1
  69. package/dist/client/assets/{TaskDialogWrapper-BZ19n03x.js → TaskDialogWrapper-BEWUpAlk.js} +1 -1
  70. package/dist/client/assets/{TasksEmptyState-RqhzTXZs.js → TasksEmptyState-CLwpLnIO.js} +2 -2
  71. package/dist/client/assets/{TasksPage-CkaqOq26.js → TasksPage-CyHjr9OZ.js} +1 -1
  72. package/dist/client/assets/{TeamComputerEntry-BFwHEcxT.js → TeamComputerEntry-BHHIofx3.js} +1 -1
  73. package/dist/client/assets/{ToolsPage-BnCLKQr8.js → ToolsPage-CckCco8x.js} +2 -2
  74. package/dist/client/assets/TopologyGraph-Dox7aWP3.js +30 -0
  75. package/dist/client/assets/{TourHost-D6Lclw6P.js → TourHost-CTBewD-a.js} +1 -1
  76. package/dist/client/assets/{UnlinkDialog-DqKrNRIZ.js → UnlinkDialog-CFRgExId.js} +1 -1
  77. package/dist/client/assets/{WidgetErrorCard-YpoGnbGt.js → WidgetErrorCard-Dx5oPMlF.js} +3 -3
  78. package/dist/client/assets/_commonjs-dynamic-modules-TDtrdbi3.js +1 -0
  79. package/dist/client/assets/_shell-BHUZq_8C.js +80 -0
  80. package/dist/client/assets/{_shell._home-BcVOIprN.js → _shell._home-DnBkgWs4.js} +1 -1
  81. package/dist/client/assets/{_shell._home.activity-B-5keh6v.js → _shell._home.activity-CVCC-EEI.js} +1 -1
  82. package/dist/client/assets/{_shell._home.index-CeUO_fiS.js → _shell._home.index-Ck6jxwIx.js} +1 -1
  83. package/dist/client/assets/{_shell._home.tasks-DrghkSwu.js → _shell._home.tasks-B7QQAZnA.js} +1 -1
  84. package/dist/client/assets/{_shell._home.workspaces-ClpXSXb7.js → _shell._home.workspaces-DlrRd9tv.js} +1 -1
  85. package/dist/client/assets/_shell.channels-CiWehoyl.js +10 -0
  86. package/dist/client/assets/{_shell.connections-BAyaKCu0.js → _shell.connections-CGP5hZHq.js} +1 -1
  87. package/dist/client/assets/{_shell.feedback-requests-C_0Cb9ew.js → _shell.feedback-requests-BxxNvw6j.js} +1 -1
  88. package/dist/client/assets/_shell.marketplace-BoAmyvPt.js +1 -0
  89. package/dist/client/assets/_shell.marketplace_.sources-BpqWjkGL.js +1 -0
  90. package/dist/client/assets/{_shell.session-DAOicD3_.js → _shell.session-KyPj3OxK.js} +17 -17
  91. package/dist/client/assets/{_shell.team-C9JBEYch.js → _shell.team-CsXH3NkS.js} +6 -6
  92. package/dist/client/assets/_shell.x._extensionId-CfiAgtoq.js +1 -0
  93. package/dist/client/assets/_shell.x._extensionId_._-CfiAgtoq.js +1 -0
  94. package/dist/client/assets/abnfDiagram-WEYOIA3C-CMdkyiQ3.js +1 -0
  95. package/dist/client/assets/{access-copy-DBchOVu9.js → access-copy-CW-z1oMH.js} +1 -1
  96. package/dist/client/assets/arc-Bw7tftQk.js +1 -0
  97. package/dist/client/assets/architectureDiagram-ZHVYKT53-BhpXALtX.js +36 -0
  98. package/dist/client/assets/{banner-DyAc42ob.js → banner-EomQNDOH.js} +1 -1
  99. package/dist/client/assets/blockDiagram-RJAE7QA3-Bxk_BuZv.js +140 -0
  100. package/dist/client/assets/c4Diagram-XDPPPE54-CYN0FwR8.js +38 -0
  101. package/dist/client/assets/{card-B1UFbnvJ.js → card-ww4ebz8h.js} +1 -1
  102. package/dist/client/assets/channel-DZpRF3QJ.js +1 -0
  103. package/dist/client/assets/chunk-2E7WHVMD-IPDvYcPa.js +88 -0
  104. package/dist/client/assets/chunk-2Q5K7J3B-DZ5bU5Ax.js +1 -0
  105. package/dist/client/assets/chunk-4EMNKR2T-DrsWxa6Y.js +1 -0
  106. package/dist/client/assets/chunk-55XCU76K-CiBbKG0b.js +1 -0
  107. package/dist/client/assets/chunk-5VM5RSS4-B3K3MUav.js +15 -0
  108. package/dist/client/assets/chunk-JWPE2WC7-CjV5RcIh.js +1 -0
  109. package/dist/client/assets/chunk-VQ5W62QI-CWoRr0H2.js +1 -0
  110. package/dist/client/assets/chunk-XXDRQBXY-E0nvzXiG.js +1 -0
  111. package/dist/client/assets/chunk-ZCHMQSOR-DFop6Lvt.js +2 -0
  112. package/dist/client/assets/classDiagram-v2-4MYWR3UA-B7JJfc9z.js +217 -0
  113. package/dist/client/assets/{command-EveETx4P.js → command-D4fLpJxA.js} +1 -1
  114. package/dist/client/assets/cose-bilkent-JH36ORCC-BjNppl29.js +1 -0
  115. package/dist/client/assets/{cpu-6HIzSTBv.js → cpu-DCe0Yyml.js} +1 -1
  116. package/dist/client/assets/cynefin-EF2NZ3EQ-PmRntJwW.js +141 -0
  117. package/dist/client/assets/cynefinDiagram-WF24UDRP-Ctdbp_Vg.js +62 -0
  118. package/dist/client/assets/cytoscape.esm-BLAcgzS2.js +331 -0
  119. package/dist/client/assets/dagre-NK4GIZVX-5tvLY2ZW.js +4 -0
  120. package/dist/client/assets/defaultLocale-DX6XiGOO.js +1 -0
  121. package/dist/client/assets/diagram-CBK3MWTC-DZO-XBOO.js +24 -0
  122. package/dist/client/assets/diagram-I5XIIV2D-CWBbA1Pv.js +24 -0
  123. package/dist/client/assets/diagram-ODIL2UCW-hP5A1tGl.js +30 -0
  124. package/dist/client/assets/diagram-PFBEJUXE-EI_-RoN7.js +3 -0
  125. package/dist/client/assets/diagram-RJA3I4VV-TrYq9A4Z.js +41 -0
  126. package/dist/client/assets/diagram-TYUNFSNR-BAQq2OM5.js +200 -0
  127. package/dist/client/assets/ebnfDiagram-V4P3TTPT-cKbeW9dQ.js +1 -0
  128. package/dist/client/assets/elk-QONTBCTQ-wpfNPp0q.js +27 -0
  129. package/dist/client/assets/{empty-state-DK2Wg9m3.js → empty-state-DXWQsHMf.js} +1 -1
  130. package/dist/client/assets/erDiagram-KYQIGQAA-Dk0OrvjE.js +99 -0
  131. package/dist/client/assets/{execution-config-e5c_6oSg.js → execution-config-CAyT2Qoo.js} +1 -1
  132. package/dist/client/assets/{file-CxdN5JO4.js → file-Bf7D_47y.js} +1 -1
  133. package/dist/client/assets/{file-exclamation-point-ID9vXo0l.js → file-exclamation-point-DZXE9_8o.js} +1 -1
  134. package/dist/client/assets/{file-text-DtcloCeg.js → file-text-C1ougnBY.js} +1 -1
  135. package/dist/client/assets/{find-latest-widget-fence-BGZDFnjV.js → find-latest-widget-fence-B1_-pC-Z.js} +1 -1
  136. package/dist/client/assets/flowDiagram-IUGLLWBU-CdlOoRZV.js +213 -0
  137. package/dist/client/assets/{form-Bs1x_gSI.js → form-D7kF-U0d.js} +1 -1
  138. package/dist/client/assets/{format-cron-i_Bh2HP3.js → format-cron-ZtliseYi.js} +1 -1
  139. package/dist/client/assets/ganttDiagram-R7GPNTJY-x0MJLv5d.js +292 -0
  140. package/dist/client/assets/{git-branch-B3IXXOlG.js → git-branch-B2k77X3Q.js} +1 -1
  141. package/dist/client/assets/gitGraphDiagram-PDYL7XHY-CruCvk7w.js +106 -0
  142. package/dist/client/assets/graph-5PBe05F8.js +1 -0
  143. package/dist/client/assets/{heart-BKVGdKg5.js → heart-CmqGJPDc.js} +1 -1
  144. package/dist/client/assets/{highlighted-body-KPVGNVTW-2S9TnGZL.js → highlighted-body-KPVGNVTW-Bqu2cQDj.js} +1 -1
  145. package/dist/client/assets/{image-lightbox-D28E719A.js → image-lightbox-BBbz-ThL.js} +1 -1
  146. package/dist/client/assets/{image-off-BuNZtQ_w.js → image-off-BCtWIY4q.js} +1 -1
  147. package/dist/client/assets/{index-LPr-pCZr.js → index-1ShgR_xt.js} +1 -1
  148. package/dist/client/assets/{index-V5Rn9SxH.js → index-8IAr9b71.js} +1 -1
  149. package/dist/client/assets/{index-rROsmUvj.js → index-8TfzCkKR.js} +1 -1
  150. package/dist/client/assets/{index-CsUyZMaJ.js → index-B5rRtvWx.js} +1 -1
  151. package/dist/client/assets/index-B6dEbNhI.js +1 -0
  152. package/dist/client/assets/{index-7cQQSs20.js → index-BCk4wW-T.js} +1 -1
  153. package/dist/client/assets/{index-CfpVrvtk.js → index-BIIH5CXj.js} +1 -1
  154. package/dist/client/assets/{index-DP_WiQNC.js → index-BXMxoWrk.js} +1 -1
  155. package/dist/client/assets/index-BXZlDqvy.js +74 -0
  156. package/dist/client/assets/{index-5081rTdO.js → index-BfRW2WTx.js} +1 -1
  157. package/dist/client/assets/{index-DVpRV8UX.js → index-BpmmNapD.js} +1 -1
  158. package/dist/client/assets/{index-CQ_s1Luo.js → index-BrQGZ6iF.js} +1 -1
  159. package/dist/client/assets/{index-KONo3kU0.js → index-BuGQxHrf.js} +1 -1
  160. package/dist/client/assets/{index-BM9n-UZ_.js → index-BzPgsdPn.js} +1 -1
  161. package/dist/client/assets/{index-ByUBGmdN.js → index-C11Ssk2u.js} +3 -3
  162. package/dist/client/assets/{index-Ce9sdGIU.js → index-CJ5v2_Cz.js} +1 -1
  163. package/dist/client/assets/{index-CIxwv14l.js → index-CMNc_OrC.js} +1 -1
  164. package/dist/client/assets/{index-ClxqCDE6.js → index-CQ0VLZf-.js} +1 -1
  165. package/dist/client/assets/{index-CHZfO-eM.js → index-ChwNEkM8.js} +1 -1
  166. package/dist/client/assets/index-Cl8trmnL.js +1 -0
  167. package/dist/client/assets/{index-CDBp2azY.js → index-ClBIPuLA.js} +1 -1
  168. package/dist/client/assets/{index-CtRknSis.js → index-Cml5572f.js} +1 -1
  169. package/dist/client/assets/{index-DIpkbx_g.js → index-Cp3yShS8.js} +7 -7
  170. package/dist/client/assets/index-CrflCTqO.css +1 -0
  171. package/dist/client/assets/{index-CJllc1_e.js → index-CtycM8wY.js} +1 -1
  172. package/dist/client/assets/{index-DVUGIueq.js → index-Cv0GsC4n.js} +1 -1
  173. package/dist/client/assets/{index-CqcPXANi.js → index-DAdo_yIq.js} +1 -1
  174. package/dist/client/assets/{index-DwKOsAwH.js → index-DIxzqCwG.js} +1 -1
  175. package/dist/client/assets/index-DKDK-3KH.js +17 -0
  176. package/dist/client/assets/index-DPNBHwcQ.js +1 -0
  177. package/dist/client/assets/{index-B-wVtE7g.js → index-DbDI5BAA.js} +1 -1
  178. package/dist/client/assets/index-DcZPWi_I.js +1023 -0
  179. package/dist/client/assets/{index-Pcm0P4su.js → index-Dmn03xST.js} +1 -1
  180. package/dist/client/assets/{index-BUAYrK-t.js → index-Do6eeFps.js} +2 -2
  181. package/dist/client/assets/{index-CAB4SfyK.js → index-DrA03bMq.js} +1 -1
  182. package/dist/client/assets/{index-5BVp-usS.js → index-DsJWzmWw.js} +1 -1
  183. package/dist/client/assets/{index-Cc5UdmnD.js → index-EdJm7ZN-.js} +1 -1
  184. package/dist/client/assets/{index-CxYD3BRB.js → index-JxeBJIuE.js} +1 -1
  185. package/dist/client/assets/{index-Dr3MaxIU.js → index-mFOJXyAE.js} +3 -3
  186. package/dist/client/assets/{index-uukEE2As.js → index-rWZWP3Wh.js} +1 -1
  187. package/dist/client/assets/{index-CFo8WKHw.js → index-t4Ud6YTX.js} +1 -1
  188. package/dist/client/assets/{index-DaFf8fyv.js → index-xaMF1mrN.js} +1 -1
  189. package/dist/client/assets/{index-DrBU917j.js → index-xmk9Ohv9.js} +1 -1
  190. package/dist/client/assets/{index-OTmqX-Xu.js → index-yI1r4pSP.js} +1 -1
  191. package/dist/client/assets/{index.esm-C1I5Nd91.js → index.esm-CZZtbPRj.js} +1 -1
  192. package/dist/client/assets/infoDiagram-MVDRKAX5-Bj9DD77n.js +2 -0
  193. package/dist/client/assets/init-Gi6I4Gst.js +1 -0
  194. package/dist/client/assets/{inline-code-BxjIkZsu.js → inline-code-g9PVHZI2.js} +1 -1
  195. package/dist/client/assets/ishikawaDiagram-HPEHV2GE-DckI6dhS.js +70 -0
  196. package/dist/client/assets/journeyDiagram-BOSHW7O7-Ce1GAVa0.js +139 -0
  197. package/dist/client/assets/kanban-definition-FNSA4HC5-Kq5O9rZa.js +89 -0
  198. package/dist/client/assets/katex-DLorvT8M.js +257 -0
  199. package/dist/client/assets/{layers-CIuBDynf.js → layers-D3lEdRF0.js} +1 -1
  200. package/dist/client/assets/{lightbulb-C75cqB7d.js → lightbulb-BFE-KkFU.js} +1 -1
  201. package/dist/client/assets/linear-BT-xgETh.js +1 -0
  202. package/dist/client/assets/{link-2-g7crG37S.js → link-2-Dvb6g-2Q.js} +1 -1
  203. package/dist/client/assets/{list-runtime-types-GVPyyQUh.js → list-runtime-types-8YGEK3Al.js} +1 -1
  204. package/dist/client/assets/{markdown-content-siVxwwSU.js → markdown-content-Cqq_QMXA.js} +1 -1
  205. package/dist/client/assets/{mention-pill-CjxBxD6M.js → mention-pill-Bnzt4u2l.js} +1 -1
  206. package/dist/client/assets/mermaid.core-dpp59v7L.js +312 -0
  207. package/dist/client/assets/{message-square-off-BxuvD1QP.js → message-square-off-BX2XnEDx.js} +1 -1
  208. package/dist/client/assets/mindmap-definition-6OY57UG3-CFdfJO6g.js +98 -0
  209. package/dist/client/assets/{more-details-DN_gIeya.js → more-details-B4lBMpKi.js} +1 -1
  210. package/dist/client/assets/ordinal-Cboi1Yqb.js +1 -0
  211. package/dist/client/assets/{owner-notice-DnYrX3mh.js → owner-notice-ByjrIRmX.js} +1 -1
  212. package/dist/client/assets/{package-b8MxCYZr.js → package-6Rbxg35g.js} +1 -1
  213. package/dist/client/assets/{page-container-bbfE5uTV.js → page-container-DoZzad36.js} +1 -1
  214. package/dist/client/assets/{paperclip-BNBU7WUb.js → paperclip-B-jDXtxw.js} +1 -1
  215. package/dist/client/assets/{path-input-BhzVuKWq.js → path-input-DpqUD8hN.js} +1 -1
  216. package/dist/client/assets/pegDiagram-ECIUJNBX-eVnSw2Ma.js +1 -0
  217. package/dist/client/assets/pieDiagram-GNMPY74T-BYG7LY5Q.js +39 -0
  218. package/dist/client/assets/plug-DnaAhcy4.js +11 -0
  219. package/dist/client/assets/{primer-trigger-DHPWwwZl.js → primer-trigger-Da5ECjY8.js} +2 -2
  220. package/dist/client/assets/{profile-errors-DDvyjpcQ.js → profile-errors-GbTNc2-M.js} +1 -1
  221. package/dist/client/assets/{progress-DUKHwOZJ.js → progress-DlIRjXIA.js} +1 -1
  222. package/dist/client/assets/quadrantDiagram-D57K4MC3-CRgNKuHR.js +7 -0
  223. package/dist/client/assets/{query-error-state-DOJRiizQ.js → query-error-state-DB-Jby7_.js} +1 -1
  224. package/dist/client/assets/{radio-kbMW2w1m.js → radio-CaaE60ws.js} +1 -1
  225. package/dist/client/assets/railroadDiagram-Y72NRBL7-DGL-Hqz9.js +1 -0
  226. package/dist/client/assets/registry-DS1Ghdft.js +1 -0
  227. package/dist/client/assets/{relay-trace-schemas-3XV1_WMC.js → relay-trace-schemas-CcCqyOrA.js} +2 -2
  228. package/dist/client/assets/requirementDiagram-EQYSW5RA-DKsFpU3l.js +84 -0
  229. package/dist/client/assets/{room-files-source-CDA5V_Mw.js → room-files-source-CbbVpvSW.js} +1 -1
  230. package/dist/client/assets/{rotate-ccw-clock-BGYqHuYK.js → rotate-ccw-clock-CeY00nlZ.js} +1 -1
  231. package/dist/client/assets/{rotate-cw-BdJrGLyp.js → rotate-cw-Djl5J_x9.js} +1 -1
  232. package/dist/client/assets/sankeyDiagram-SY24JHO5-BFRkDxic.js +40 -0
  233. package/dist/client/assets/{scroll-area-D-CWiQov.js → scroll-area-BOqrziJf.js} +1 -1
  234. package/dist/client/assets/{search-x-DNIPyXe6.js → search-x-B_mHjnlo.js} +1 -1
  235. package/dist/client/assets/sequenceDiagram-BLEHNHQU-fHea3KOI.js +169 -0
  236. package/dist/client/assets/{shield-check-zWzf9nt2.js → shield-check-Csnr5rFy.js} +1 -1
  237. package/dist/client/assets/{shield-x-Bu5-LOse.js → shield-x-Dhl4YvvW.js} +1 -1
  238. package/dist/client/assets/signed-in-BMqAss8c.js +1 -0
  239. package/dist/client/assets/sizeCapture-INFHLROL-CztsD3qF.js +1 -0
  240. package/dist/client/assets/{soul-file-CoSSajv6.js → soul-file-DOfamgB5.js} +1 -1
  241. package/dist/client/assets/stateDiagram-v2-A6IESKWZ-CWyOqZ9S.js +291 -0
  242. package/dist/client/assets/swimlanes-B3ENRKFQ-0EfOxSAX.js +1 -0
  243. package/dist/client/assets/swimlanesDiagram-AYQRV4AK-C7fkUKrq.js +8 -0
  244. package/dist/client/assets/{table-Bt_aJtoi.js → table-L7FvN6Or.js} +1 -1
  245. package/dist/client/assets/{terminal-ub-ExeTA.js → terminal-C9M5a_PS.js} +1 -1
  246. package/dist/client/assets/timeline-definition-JXYKGLGB-sFyYvZ20.js +120 -0
  247. package/dist/client/assets/transform-BqqRT-Iy.js +1 -0
  248. package/dist/client/assets/{trust-posture-CWt3tUjL.js → trust-posture-dl6qwDtI.js} +1 -1
  249. package/dist/client/assets/{unplug-BCqRQfhH.js → unplug-CFUEVRbc.js} +1 -1
  250. package/dist/client/assets/{unverified-catalog-notice-CgvUEO5t.js → unverified-catalog-notice-CdYU3WEJ.js} +1 -1
  251. package/dist/client/assets/{use-adapter-catalog-ClW3m3Yz.js → use-adapter-catalog-YTofdqDJ.js} +1 -1
  252. package/dist/client/assets/{use-bindings-CFiTPDOx.js → use-bindings-CpyT6kNu.js} +1 -1
  253. package/dist/client/assets/{use-composer-prefs-B70wbKdU.js → use-composer-prefs-CK_EK_QJ.js} +1 -1
  254. package/dist/client/assets/{use-connector-management-B_mb2h8I.js → use-connector-management-DwoK8kon.js} +1 -1
  255. package/dist/client/assets/{use-deep-link-scroll-DuJW3UA9.js → use-deep-link-scroll-CgRjt48R.js} +1 -1
  256. package/dist/client/assets/{use-delete-binding-DWXownno.js → use-delete-binding-CfsnMXrL.js} +1 -1
  257. package/dist/client/assets/{use-dev-links-UPIkbIjA.js → use-dev-links-B3I-ZK34.js} +1 -1
  258. package/dist/client/assets/{use-external-adapter-catalog-x7pDUqmo.js → use-external-adapter-catalog-aGlZNRrp.js} +1 -1
  259. package/dist/client/assets/{use-full-activity-feed-l9UhDUNU.js → use-full-activity-feed-B61Olhdw.js} +1 -1
  260. package/dist/client/assets/use-is-below-desktop-Qwyg-mFb.js +1 -0
  261. package/dist/client/assets/use-is-hub-CSz6NDaP.js +1 -0
  262. package/dist/client/assets/{use-jump-back-in-CKA3z2by.js → use-jump-back-in-C39GOTHa.js} +3 -3
  263. package/dist/client/assets/{use-local-browser-DL5b5JIK.js → use-local-browser-DCwzB4D8.js} +1 -1
  264. package/dist/client/assets/{use-mesh-topology-BYGYArKq.js → use-mesh-topology-LRYxFuZp.js} +1 -1
  265. package/dist/client/assets/{use-mounted-ref-D_xUn22L.js → use-mounted-ref-CZaegwTr.js} +1 -1
  266. package/dist/client/assets/{use-notification-prefs-42ajom2z.js → use-notification-prefs-FtOiUS5H.js} +1 -1
  267. package/dist/client/assets/{use-panel-tab-placements-CLIDc7_z.js → use-panel-tab-placements-Dv2OPvKh.js} +1 -1
  268. package/dist/client/assets/use-pending-read-DBOl1ee_.js +1 -0
  269. package/dist/client/assets/{use-personality-commit-D7jyGUrF.js → use-personality-commit-BB5aeh6p.js} +1 -1
  270. package/dist/client/assets/use-promo-activation-BW0u7n7m.js +11 -0
  271. package/dist/client/assets/{use-promo-dismissals-CsJELZ1_.js → use-promo-dismissals-BOXzW4kD.js} +1 -1
  272. package/dist/client/assets/{use-pulse-freshness-TqSBTrFT.js → use-pulse-freshness-ClW-MLMo.js} +1 -1
  273. package/dist/client/assets/{use-relay-config-CLeVWrpV.js → use-relay-config-hItHtkSr.js} +1 -1
  274. package/dist/client/assets/{use-room-follow-claim-C-zlw4nh.js → use-room-follow-claim-wotzxUWc.js} +1 -1
  275. package/dist/client/assets/{use-roving-tab-list-H2EzOl9b.js → use-roving-tab-list-DkbO6xSs.js} +1 -1
  276. package/dist/client/assets/use-session-canvas-C_fuAgW_.js +24 -0
  277. package/dist/client/assets/{use-session-diagnostics-CDmiMYHx.js → use-session-diagnostics-DmxvD-wy.js} +3 -3
  278. package/dist/client/assets/{use-unclaimed-chats-Bd93jy-J.js → use-unclaimed-chats-DKpexDm3.js} +1 -1
  279. package/dist/client/assets/use-update-config-CSYwg557.js +1 -0
  280. package/dist/client/assets/{useMutationState-BZZ5TO4d.js → useMutationState-Btf2Hp1a.js} +1 -1
  281. package/dist/client/assets/usecaseDiagram-WPOLBNNX-DRngjDUq.js +370 -0
  282. package/dist/client/assets/value-wA6veExk.js +1 -0
  283. package/dist/client/assets/vennDiagram-Q3Y3IDCW-iK-dlS1-.js +34 -0
  284. package/dist/client/assets/wardleyDiagram-IVAIDKWA-sOS67Cks.js +78 -0
  285. package/dist/client/assets/xychartDiagram-4URNHDU4-EgnLiIao.js +7 -0
  286. package/dist/client/index.html +2 -2
  287. package/dist/drizzle/20261017113300_session_public_computer.sql +1 -0
  288. package/dist/drizzle/meta/20261017113300_snapshot.json +14020 -0
  289. package/dist/drizzle/meta/_journal.json +7 -0
  290. package/dist/server/index.js +24307 -20763
  291. package/dist/server/index.js.map +2 -2
  292. package/package.json +7 -7
  293. package/dist/client/assets/BlintzCanvas-D_HlpfZu.js +0 -1141
  294. package/dist/client/assets/CanvasFileContent-g5wQR7yt.js +0 -2
  295. package/dist/client/assets/HandlePage-DUFrvuVy.js +0 -1
  296. package/dist/client/assets/KeyEntry-tKXV9D24.js +0 -6
  297. package/dist/client/assets/McpSigninBody-CRj8tXsh.js +0 -1
  298. package/dist/client/assets/NamePage-fiIXQig_.js +0 -1
  299. package/dist/client/assets/PhotoPage-BnxmY5mq.js +0 -1
  300. package/dist/client/assets/SettingsDialog-BZkPlifY.js +0 -12
  301. package/dist/client/assets/TopologyGraph-CAkARLa1.js +0 -30
  302. package/dist/client/assets/_shell-BQ7hvFsP.js +0 -90
  303. package/dist/client/assets/_shell.channels-DYNK-rbr.js +0 -10
  304. package/dist/client/assets/_shell.marketplace-B1CT9Y3y.js +0 -1
  305. package/dist/client/assets/_shell.marketplace_.sources-DVHJ2s7a.js +0 -1
  306. package/dist/client/assets/_shell.x._extensionId-B6Ccjrvp.js +0 -1
  307. package/dist/client/assets/_shell.x._extensionId_._-B6Ccjrvp.js +0 -1
  308. package/dist/client/assets/index-BONR--d7.css +0 -1
  309. package/dist/client/assets/index-BULRe04c.js +0 -1018
  310. package/dist/client/assets/index-C8NfFfij.js +0 -17
  311. package/dist/client/assets/index-CRMbYKMh.js +0 -1
  312. package/dist/client/assets/index-CidWt_HE.js +0 -1
  313. package/dist/client/assets/index-CoMMwnLj.js +0 -74
  314. package/dist/client/assets/registry-BisJE2TH.js +0 -1
  315. package/dist/client/assets/use-is-below-desktop-ByiGZk3p.js +0 -1
  316. package/dist/client/assets/use-pending-read-Cy9OB3jX.js +0 -1
  317. package/dist/client/assets/use-promo-activation-Dw1KvykA.js +0 -11
  318. package/dist/client/assets/use-session-canvas-Bm_AzSm7.js +0 -24
  319. package/dist/client/assets/use-update-config-DjF61lwf.js +0 -1
@@ -1,90 +0,0 @@
1
- var zu=Object.defineProperty;var Uu=(e,t,s)=>t in e?zu(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s;var fn=(e,t,s)=>Uu(e,typeof t!="symbol"?t+"":t,s);import{qA as Ku,r as l,fv as Go,qB as Hu,ft as Yr,j as n,qC as Wu,qD as qi,fw as Gu,ic as Vr,a1 as ce,a2 as ke,au as Me,en as Ee,eY as In,qE as Ks,i8 as yr,qF as qu,qG as Yu,a3 as me,ap as be,or as Vu,qH as Qu,W as Ie,e3 as Cs,ar as re,B as F,X as _e,G as H,ja as Yi,qI as Xu,x as Ne,a0 as Vi,bw as Qi,bc as Ns,d5 as Ue,aX as Ju,qJ as qo,qK as Zu,bG as em,at as Xi,c4 as Re,as as Pe,s as _t,jK as tm,jL as Ji,a7 as ue,qL as Fn,iJ as yt,qM as Zi,aW as _,qi as nm,eh as vt,lE as ms,it as sn,qN as sm,a4 as Bt,eg as ec,fl as Qr,cD as Xr,ax as rn,qO as Yo,js as rm,jv as tc,jr as om,qP as Jr,j1 as $n,J as zt,hA as Zr,e2 as Zt,l as ye,aJ as nc,dt as sc,du as rc,dP as oc,dv as am,qQ as im,dx as rt,by as Bn,bz as zn,T as Ut,bA as Un,bC as Kn,C as on,d$ as ze,e0 as cm,kJ as ac,iD as ic,bk as $e,qR as lm,qS as dm,bH as um,z as eo,dy as et,f5 as tt,gg as to,fq as As,jD as no,f as kt,b7 as cc,ef as Es,qT as so,dZ as mm,_ as Rn,cM as an,cN as cn,cO as ln,ak as Oe,aq as Is,m8 as lc,qU as hm,qV as fm,ct as pm,dj as hs,bx as Qe,jQ as Tn,cw as pt,cx as gt,cz as ut,cA as Xe,cB as mt,dw as wt,dc as Xt,da as gm,c6 as dc,ik as uc,g$ as Vo,qW as xm,hE as fs,io as bm,iq as ym,gZ as mc,qX as vm,f$ as Rs,g0 as Ts,g2 as Ds,qY as hc,g3 as Ge,qZ as Hn,g5 as os,h as ro,q_ as oo,q$ as wm,g1 as jm,py as Sm,r0 as fc,jj as km,r1 as Cm,r2 as Nm,r3 as Am,eH as pc,r4 as Em,r5 as Im,is as Rm,r6 as Tm,g as vr,i7 as Qo,r7 as Dm,az as Om,gt as gc,ad as Ae,eF as Os,r8 as Mm,r9 as _m,gu as Pm,hf as Lm,kH as Fm,hh as $m,hi as Bm,hj as zm,ng as xc,fk as Ms,ea as Um,ra as Km,gi as bc,rb as Se,rc as Hm,rd as yc,re as wr,rf as vc,rg as ao,rh as io,b6 as _s,ri as co,rj as Wm,rk as Gm,rl as qm,rm as Ym,rn as Vm,ro as Qm,rp as pn,i9 as Xm,ia as Jm,mt as Zm,rq as eh,bb as th,rr as nh,fp as wc,bW as Jt,rs as jc,rt as ps,ru as Sc,rv as sh,rw as rh,rx as en,ry as kc,rz as Cc,rA as Dn,rB as oh,rC as ah,hk as Nc,hl as Ac,rD as Pt,e6 as ih,rE as On,rF as ch,aZ as Ec,rG as lh,rH as dh,rI as uh,rJ as mh,rK as hh,rL as Ic,rM as It,fo as jt,rN as Rc,rO as fh,fE as ve,fM as ph,fD as de,fH as dn,fC as un,fK as fe,fF as Tt,I as ft,nZ as Tc,o5 as Dc,fV as Lt,fU as tn,eL as Ps,ko as gh,fT as Oc,ei as Mc,lt as _c,no as xh,fS as bh,rP as yh,rQ as Xo,rR as vh,rS as nn,rT as Pc,bO as Ls,hF as Lc,rU as wh,rV as jh,rW as Sh,eM as kh,aY as lo,fW as uo,rX as Ch,gw as Wn,rY as jn,rZ as mo,q as gs,o as Fc,r_ as Nh,jM as Jo,l3 as Ah,nG as Eh,r$ as Ih,s0 as Rh,c0 as Th,aj as ho,ai as fo,n2 as $c,n1 as Bc,s1 as Dh,am as zc,d3 as Fs,k3 as Uc,s2 as Oh,s3 as Mh,s4 as _h,s5 as Ph,s6 as Lh,s7 as Fh,s8 as $h,h6 as po,oA as Bh,s9 as Kc,mb as zh,iA as jr,dL as Uh,sa as Gn,mZ as go,sb as mn,sc as Kh,sd as Hh,se as Wh,sf as Gh,sg as qh,sh as Yh,fX as Vh,si as Qh,hv as xo,m_ as Hc,n0 as Xh,sj as Jh,sk as Wc,sl as Zh,kS as ef,sm as Gc,sn as Zo,so as ea,sp as tf,sq as nf,sr as sf,ss as rf,st as of,su as af,sv as ta,sw as cf,sx as lf,sy as df,sz as Hs,iy as $s,iU as uf,sA as mf,ky as hf,e as Dt,sB as ff,sC as pf,sD as gf,b4 as xf,jk as bf,sE as qc,sF as yf,b3 as vf,sG as wf,sH as jf,gv as qn,K as Sf,sI as kf,sJ as xs,j2 as Yc,sK as Cf,sL as Vc,sM as na,sN as Nf,sO as Af,sP as Qc,sQ as Xn,sR as Ef,sS as If,sT as Rf,sU as Xc,sV as Sr,sW as Tf,cc as gn,H as bo,aS as Df,pu as Jc,dz as sa,jF as yo,bh as Of,t as Mf,hI as kr,he as _f,aN as vo,ho as Zc,sX as Pf,k_ as Lf,kG as Ff,o2 as $f,ix as Bf,sY as zf,iz as ra,i_ as el,g8 as Uf,g9 as Kf,ga as Hf,gb as Wf,gc as Gf,gd as qf,ge as Yf,sZ as Vf,s_ as Cr,s$ as Qf,t0 as Ws,t1 as Xf,t2 as Jf,t3 as Mn,t4 as Zf,t5 as oa,kL as ep,iV as tp,t6 as np,id as sp,ie as rp,ih as op,ii as aa,lc as ia,la as ap,lb as ca,t7 as ip,t8 as cp,t9 as lp,ta as dp,eo as up,tb as mp,tc as hp,td as fp,bR as pp,te as gp,tf as xp,tg as tl,th as nl,O as wo,Q as jo,U as So,ti as bp,tj as yp,bL as vp,f_ as wp,tk as Gs,gA as jp,tl as Sp,tm as kp,tn as Cp,to as Np,tp as Ap,tq as Ep,tr as Ip,ts as Rp,tt as Tp,tu as la,b8 as sl,ig as Dp,bK as Op,tv as rl,tw as Mp,fr as _p,tx as da,hd as Pp,ty as Lp,tz as Fp,o0 as $p,tA as Bp,tB as zp,e4 as Up,tC as Kp,tD as ua,tE as Hp,tF as Wp,nY as Gp,od as qp,jz as Yp,a9 as ol,tG as Vp,jt as Qp,ju as Xp,k4 as Jp,eu as al,ev as il,ew as cl,ex as ll,d6 as Zp,e1 as eg,es as tg,et as ng,k9 as sg,ka as rg,kb as og,ke as ag,kc as ig,tH as cg,tI as lg,k8 as dg,k6 as ug,k7 as mg,i6 as hg,tJ as dl,iw as fg,tK as pg,tL as gg,tM as ul,tN as Bs,bg as ml,$ as hl,tO as fl,oC as xg,be as bg,bf as yg,el as ma,bd as vg,gj as qs,gP as Ys,tP as ko,n as wg,hp as jg,aO as ha,tQ as pl,tR as gl,oN as Sg,bB as kg,tS as Cg,tT as Ng,tU as Qt,cT as Ag,tV as fa,lS as Eg,lU as xl,db as Ig,jq as Rg,nF as Tg,tW as Nr,eV as Dg,hH as Og,m3 as lt,m5 as Mg,qh as _g,mn as pa,qj as Pg,tX as Lg,tY as Fg,tZ as $g,t_ as Bg,t$ as zg,u0 as Ug,u1 as Kg,u2 as Hg,u3 as Wg,kV as Gg,jZ as qg,kC as Yg,u4 as Vg,u5 as Qg,u6 as Xg,u7 as Jg,u8 as Zg,u9 as ex,c7 as tx,ua as nx,ub as sx,nf as rx,cC as ox}from"./index-BULRe04c.js";import{f as ax,g as ix}from"./use-connector-management-B_mb2h8I.js";import{D as St,a as cx}from"./TourHost-D6Lclw6P.js";import{r as lx,e as dx,a as ux,K as mx}from"./RuntimeConnectFlow-BmMBE_ki.js";import{O as hx,B as bl}from"./banner-DyAc42ob.js";import{u as zs,P as yl,a as fx}from"./ProfileRolePicker-B9as28eL.js";import{u as px}from"./use-dev-links-UPIkbIjA.js";import{B as gx,u as xx}from"./use-bindings-CFiTPDOx.js";import{C as Co,l as vl,O as wl,m as st,n as bx,u as jl,r as yx,w as vx,b as wx,e as jx,k as Sx,o as Ar,T as kx,a as Cx,P as Nx,B as Ax,g as Sl,p as kl,q as Cl,j as Ex,S as ga,W as Ix,s as Rx}from"./PresetPicker-C-HcfktA.js";import{d as Tx}from"./untrusted-text-pHjcUwfI.js";import{S as Cn}from"./scroll-area-D-CWiQov.js";import{T as Nl,a as Al,b as as,c as Vs,u as Dx,i as Ox,d as Mx,P as El}from"./PreviewRefusedNotice-CgJeWKad.js";import{P as _x}from"./paperclip-BNBU7WUb.js";import{L as Px}from"./lightbulb-C75cqB7d.js";import{u as Yn}from"./use-update-config-DjF61lwf.js";import{a as Lx,u as Fx,S as $x,s as Bx,b as zx,P as Ux}from"./ApplyToOverridesDialog-C5Nf8pjH.js";import{r as Il,s as xa,e as Kx}from"./access-copy-DBchOVu9.js";import{t as Hx,I as ba}from"./trust-posture-CWt3tUjL.js";import{a as Wx}from"./use-pulse-freshness-TqSBTrFT.js";import{c as Gx,B as qx,w as Yx,b as Vx,a as Qx,e as Xx}from"./primer-trigger-DHPWwwZl.js";import{M as Jx,u as Zx,s as eb,P as tb,a as nb}from"./use-promo-activation-Dw1KvykA.js";import{u as Rl}from"./use-promo-dismissals-CsJELZ1_.js";import{u as Tl}from"./use-pending-read-Cy9OB3jX.js";import{a as ht}from"./dorkbot-templates-8Yu9POWJ.js";import{i as sb,O as Dl,b as rb,u as ob,a as ab}from"./OperatorIdentityForm-CgSvpX-s.js";import{A as Ol,P as ib,u as cb,a as lb}from"./use-jump-back-in-CKA3z2by.js";import{S as Ml,P as db}from"./progress-DUKHwOZJ.js";import{i as No,a as ub,u as mb}from"./use-notification-prefs-42ajom2z.js";import{R as hb}from"./rotate-cw-BdJrGLyp.js";import{b as fb,u as pb,O as gb,c as xb}from"./OpenMeshSwitch-C5dCRdqs.js";import{u as bb,a as yb,C as vb,N as wb}from"./NewDirectMessageMenu-BOwmahin.js";import{P as jb,C as Sb,f as kb,a as Cb}from"./find-latest-widget-fence-BGZDFnjV.js";import{o as Nb}from"./owner-notice-DnYrX3mh.js";import{a as _l,C as Ab}from"./cpu-6HIzSTBv.js";import{U as Eb}from"./unplug-BCqRQfhH.js";import{c as Ib,H as Pl,a as Ll,b as Fl}from"./RuntimeSetupDialog-DsDi5RBn.js";import{P as Qs}from"./page-container-bbfE5uTV.js";import{S as Rb}from"./shield-check-zWzf9nt2.js";import{u as Tb}from"./use-roving-tab-list-H2EzOl9b.js";import{R as Db}from"./rotate-ccw-clock-BGYqHuYK.js";import{d as Ve,e as je,f as ya,g as $l,C as Bl,a as zl,b as Ul,c as Ob}from"./command-EveETx4P.js";import{A as Mb,M as _b}from"./McpAppFrame-BOhSmDHb.js";import{L as Pb}from"./layers-CIuBDynf.js";import{A as Lb}from"./AgentOptionRow-DcKMOkUs.js";import{R as Fb}from"./radio-kbMW2w1m.js";import{a as $b}from"./sound-D3r8dGFH.js";import{d as Bb}from"./connection-copy--MA7AN04.js";import{P as zb}from"./path-input-BhzVuKWq.js";import"./WidgetErrorCard-YpoGnbGt.js";import{a as Ub}from"./ComputerResourceView-C97PoLhs.js";import{u as Kl}from"./use-is-below-desktop-ByiGZk3p.js";import{a as Kb,u as Hb}from"./use-panel-tab-placements-CLIDc7_z.js";import{u as Wb}from"./ComputerViewer-DVaP4S-x.js";import{a as Gb}from"./use-local-browser-DL5b5JIK.js";import{F as qb}from"./file-text-DtcloCeg.js";import"./use-relay-config-CLeVWrpV.js";import"./use-external-adapter-catalog-x7pDUqmo.js";import"./use-adapter-catalog-ClW3m3Yz.js";import"./inline-code-BxjIkZsu.js";import"./useMutationState-BZZ5TO4d.js";import"./runtime-connect-Dn0T5YWv.js";import"./terminal-ub-ExeTA.js";import"./execution-config-e5c_6oSg.js";import"./settings-for-runtime-BoOa-ZFG.js";import"./shield-x-Bu5-LOse.js";import"./use-full-activity-feed-l9UhDUNU.js";import"./profile-errors-DDvyjpcQ.js";import"./use-mounted-ref-D_xUn22L.js";import"./ProfileFields-Bpe71duM.js";import"./use-mesh-topology-BYGYArKq.js";import"./card-B1UFbnvJ.js";import"./list-runtime-types-GVPyyQUh.js";import"./more-details-DN_gIeya.js";import"./index-LPr-pCZr.js";import"./markdown-content-siVxwwSU.js";import"./table-Bt_aJtoi.js";import"./package-b8MxCYZr.js";import"./heart-BKVGdKg5.js";import"./git-branch-B3IXXOlG.js";import"./file-CxdN5JO4.js";function Yb({children:e,isValidProp:t,...s}){t&&Ku(t);const r=l.useContext(Go);s={...r,...s},s.transition=Hu(s.transition,r.transition),s.isStatic=Yr(()=>s.isStatic);const o=l.useMemo(()=>s,[JSON.stringify(s.transition),s.transformPagePoint,s.reducedMotion,s.skipAnimations]);return n.jsx(Go.Provider,{value:o,children:e})}function Vb(e){e.values.forEach(t=>t.stop())}function Er(e,t){[...t].reverse().forEach(r=>{const o=e.getVariant(r);o&&qi(e,o),e.variantChildren&&e.variantChildren.forEach(a=>{Er(a,t)})})}function Qb(e,t){if(Array.isArray(t))return Er(e,t);if(typeof t=="string")return Er(e,[t]);qi(e,t)}function Xb(){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(Wu(a,s,{transitionOverride:r}))}),Promise.all(o)},set(s){return e.forEach(r=>{Qb(r,s)})},stop(){e.forEach(s=>{Vb(s)})},mount(){return()=>{t.stop()}}};return t}function Jb(){const e=Yr(Xb);return Gu(e.mount,[]),e}class Zb{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 ey=()=>new Zb;function ty(){return Yr(ey)}const ny=`${Vr.repo}/issues/new`,sy={"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"},ry={"runtimes.default":["claude-code","codex","opencode","doe"],"logging.level":["fatal","error","warn","info","debug","trace"],"ui.theme":["light","dark","system"]},oy=/^[a-z0-9][a-z0-9._-]{0,31}$/,ay={bug:["bug"],feature:["enhancement"],runtime:["bug"]},iy={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 Ao(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 ly(e,t){const s=ry[e];return s?s.includes(t):oy.test(t)&&Ao(t)===t}function dy(e){const t={};for(const[s,r]of Object.entries(sy)){const o=e[s];o!=null&&(r==="boolean"&&typeof o=="boolean"||r==="number"&&typeof o=="number"&&Number.isFinite(o)||r==="enum"&&typeof o=="string"&&ly(s,o))&&(t[s]=o)}return t}const uy=["details","summary"];function Eo(e){return Tx(Ao(e),uy)}function my(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 Ao(r.join(`
3
- `))}function hy(e){var s;const t=(s=e.body)==null?void 0:s.trim();return t?[Eo(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 fy(e){return["<details><summary>Environment</summary>","",my(e),"","</details>","","DorkOS filled in the details above. Please check them and remove anything you do not want to share.","","---","",...hy(e)].join(`
4
- `)}function Xs(e){var r;const t=(r=e.title)==null?void 0:r.trim(),s=new URLSearchParams({title:Eo(t||iy[e.kind]),body:fy(e),labels:ay[e.kind].join(",")});return`${ny}?${s.toString()}`}const py=6e3,va=`
5
-
6
- … (shortened to fit the link; paste the rest yourself)`;function wa(e){return new TextEncoder().encode(e).length}function ja(e,t){return Array.from(e).slice(0,t).join("")}function gy(e,t=py){var d;const s=Xs(e);if(wa(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:ja(r,u)+va};wa(Xs(m))<=t?a=u:i=u-1}const c={...e,body:ja(r,a)+va};return{url:Xs(c),truncated:!0,fullBody:Eo(r)}}function xy(e){return gy(e).url}function by(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 Hl(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?dy(by(t)):{}}}function yy(){const e=ce(),{data:t}=ke({queryKey:Me.current(),queryFn:()=>e.getConfig(),staleTime:300*1e3}),s=Ee({select:r=>r.location.pathname});return l.useCallback(r=>{const o=xy(Hl(r,t,s));In(o)},[t,s])}const vy=100;function wy({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&&(Ks(m[i.current]),i.current=(i.current+1)%m.length)},vy))},[]),u=l.useCallback(()=>{a.current&&(clearInterval(a.current),a.current=null),r.current&&Ks(r.current)},[]);l.useEffect(()=>{if(!e)return;const m=s??yr(e),p=qu(m);r.current=p,o.current=[],Ks(p);let f=!1;return Yu(p).then(h=>{f||(o.current=h,c.current&&d())}).catch(()=>{}),()=>{f=!0}},[e,s,d]),l.useEffect(()=>(t?d():u(),u),[t,d,u])}function jy(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 Sy(){const e=me();be("account_usage",t=>{const s=t;!s||typeof s.runtime!="string"||e.getQueryData(Vu.usage(s.runtime))!==void 0&&Qu(e,s.runtime,[s])})}function ky(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 Cy(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(p=>p.offsetTop===m).length)}function a(u){var p;const m=Math.max(0,Math.min(e-1,u));s(m),(p=r.current[m])==null||p.focus()}function i(u){return m=>{r.current[u]=m}}function c(u){return t===u?0:-1}function d(u,m){const p=ky(u.key,m,o(),e);p!==null&&(u.preventDefault(),a(p))}return{focusIndex:t,setRef:i,tabIndexFor:c,handleKeyDown:d,moveFocus:a}}function Wl(){const[e,t]=l.useState(Sa);return l.useEffect(()=>{const s=window.visualViewport,r=()=>{const o=Sa();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 Sa(){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 Gl={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"]};Gl.node;const Ny=Ie(Gl);/**
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 ql={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"}]]};ql.node;const Ay=Ie(ql);/**
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 Yl={name:"chevron-up",size:24,node:[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]]};Yl.node;const Ey=Ie(Yl);/**
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 Vl={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"]};Vl.node;const Iy=Ie(Vl);/**
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 Ql={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"}]]};Ql.node;const Xl=Ie(Ql);/**
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 Jl={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"}]]};Jl.node;const Ry=Ie(Jl);/**
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 Zl={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"}]]};Zl.node;const Ty=Ie(Zl);/**
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 ed={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"}]]};ed.node;const bs=Ie(ed);/**
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 td={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"}]]};td.node;const Dy=Ie(td);/**
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 nd={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"}]]};nd.node;const ka=Ie(nd);/**
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 sd={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"}]]};sd.node;const Oy=Ie(sd);/**
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 rd={name:"minus",size:24,node:[["path",{d:"M5 12h14",key:"1ays0h"}]]};rd.node;const My=Ie(rd);/**
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 od={name:"plug",size:24,node:[["path",{d:"M12 22v-5",key:"1ega77"}],["path",{d:"M15 8V2",key:"18g5xt"}],["path",{d:"M17 8a1 1 0 0 1 1 1v4a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V9a1 1 0 0 1 1-1z",key:"1xoxul"}],["path",{d:"M9 8V2",key:"14iosj"}]]};od.node;const _y=Ie(od);/**
72
- * @license lucide-react v1.48.0 - ISC
73
- *
74
- * This source code is licensed under the ISC license.
75
- * See the LICENSE file in the root directory of this source tree.
76
- */const ad={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"]};ad.node;const Py=Ie(ad);/**
77
- * @license lucide-react v1.48.0 - ISC
78
- *
79
- * This source code is licensed under the ISC license.
80
- * See the LICENSE file in the root directory of this source tree.
81
- */const id={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"}]]};id.node;const Ly=Ie(id),Ca=16,Fy=280,$y=180;function Na(e,t,s){const r=Math.max(t,window.innerWidth-Ca),o=Math.max(s,window.innerHeight-Ca),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 By(e,t){return e.x!==t.x||e.y!==t.y||e.width!==t.width||e.height!==t.height}function zy(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),p=i??Fy,f=c??$y;l.useEffect(()=>{const y=()=>{const C=Na(s,p,f);By(C,s)&&r(C)};return y(),window.addEventListener("resize",y),()=>window.removeEventListener("resize",y)},[s,p,f,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,C)=>{var D;y.preventDefault();const j=m.current;if(!j)return;const I=j;(D=h.current)==null||D.call(h);const v=y.clientX,N=y.clientY,O=s;let P=O,R=0;function A(){R=0,I.style.left=`${P.x}px`,I.style.top=`${P.y}px`,I.style.width=`${P.width}px`,I.style.height=`${P.height}px`}function w(T){P=C(T.clientX-v,T.clientY-N,O),R||(R=requestAnimationFrame(A))}function k(){R&&cancelAnimationFrame(R),R=0,document.removeEventListener("pointermove",w),document.removeEventListener("pointerup",E),document.removeEventListener("pointercancel",E),h.current=null}function E(){k(),r(Na(P,p,f))}document.addEventListener("pointermove",w),document.addEventListener("pointerup",E),document.addEventListener("pointercancel",E),h.current=k},[s,p,f,r]),x=l.useCallback(y=>{y.target.closest("button")||g(y,(C,j,I)=>({...I,x:I.x+C,y:I.y+j}))},[g]),b=l.useCallback(y=>{y.stopPropagation(),g(y,(C,j,I)=>({...I,width:Math.max(p,I.width+C),height:Math.max(f,I.height+j)}))},[g,p,f]);return Cs.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:H("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(F,{variant:"ghost",size:"icon-sm","aria-label":"Restore",onClick:a,className:"text-muted-foreground hover:text-foreground",children:n.jsx(jb,{})}):null,n.jsx(F,{variant:"ghost",size:"icon-sm","aria-label":"Close",onClick:o,className:"text-muted-foreground hover:text-foreground",children:n.jsx(_e,{})})]}),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 Uy({...e}){const{theme:t}=Yi();return n.jsx(Xu,{theme:t,className:"toaster group",icons:{success:n.jsx(Ns,{className:"size-4"}),info:n.jsx(Qi,{className:"size-4"}),warning:n.jsx(Vi,{className:"size-4"}),error:n.jsx(hx,{className:"size-4"}),loading:n.jsx(Ne,{})},style:{"--normal-bg":"var(--color-popover)","--normal-text":"var(--color-popover-foreground)","--normal-border":"var(--color-border)","--border-radius":"var(--radius)"},...e})}async function Ky(){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 cd="root";function ld(){return document.getElementById(cd)??document.body}const Aa=2e4;class Je extends Error{constructor(s,r){super(r);fn(this,"reason");this.name="AppCaptureError",this.reason=s}}function Hy(){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 Wy(){return new Promise(e=>{requestAnimationFrame(()=>requestAnimationFrame(()=>e()))})}function Gy(){const e=[];for(const t of Array.from(document.body.children)){if(!(t instanceof HTMLElement)||t.id===cd)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 qy(e){const t=await e().catch(s=>{throw new Je("failed",`The desktop bridge threw: ${String(s)}`)});if(!t.ok)throw new Je("failed",t.message);return{dataUrl:t.dataUrl,region:{left:0,top:0,width:window.innerWidth,height:window.innerHeight}}}async function Yy(){let e;try{({snapdom:e}=await Ju(()=>import("./snapdom-SRLjr6oU.js"),[]))}catch(r){const o=r instanceof Error?r.message:String(r);throw new Je("unsupported",`Loading the screenshot library failed: ${o}`)}const t=ld(),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 Je("failed",`Rendering the app to an image failed: ${o}`)}}async function Vy(e){let t;const s=new Promise((r,o)=>{t=setTimeout(()=>{o(new Je("failed",`The capture did not finish in ${Aa}ms.`))},Aa)});try{return await Promise.race([e,s])}finally{clearTimeout(t),e.catch(()=>{})}}async function Qy(){const e=Hy(),t=Gy();try{return await Wy(),await Vy(e?qy(e):Yy())}finally{t()}}let xn=null;function dd(){if(xn)return xn;const e=Qy();xn=e;const t=()=>{xn===e&&(xn=null)};return e.then(t,t),e}function Xy(){return dd().then(e=>e.dataUrl)}function Jy(){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 Zy(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone||void 0}catch{return}}function ev(e){const t=Jy(),s=typeof navigator<"u"?navigator.userAgent:void 0,r=typeof navigator<"u"?navigator.language:void 0,o=Zy();return{theme:e,shell:Ue()?"desktop-app":"browser",...t?{viewport:t}:{},...s?{browser:s.slice(0,Zu)}:{},...r?{locale:r.slice(0,qo)}:{},...o?{timezone:o.slice(0,qo)}:{}}}function Us(e){return t=>()=>{e(),t()}}const tv=2e3,nv=.8,sv=1400,rv=.6,is=6e5,ys=1e4,ov=["image/webp","image/jpeg","image/png"],av=/^data:image\/(webp|png|jpeg);base64,/;class Ft extends Error{constructor(s,r){super(r);fn(this,"reason");this.name="ImageCompressError",this.reason=s}}function iv(e){return av.test(e)&&e.length<=is}function cv(e){return new Promise((t,s)=>{const r=new Image,o=setTimeout(()=>{s(new Ft("unreadable",`Decoding timed out after ${ys}ms.`))},ys);r.onload=()=>{clearTimeout(o),t(r)},r.onerror=()=>{clearTimeout(o),s(new Ft("unreadable",`Could not decode the image at ${e.slice(0,32)}…`))},r.src=e})}function lv(e,t){for(const s of ov){const r=e.toDataURL(s,t);if(r.startsWith(`data:${s};base64,`))return r}throw new Ft("unsupported","This canvas produced no usable image encoding.")}function Ea(e,t,s=tv){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 Ia(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 Ft("unsupported","This browser gave no 2d canvas context.");return o.drawImage(e,0,0,t.width,t.height),lv(r,s)}async function Ir(e){const t=typeof e=="string"?null:URL.createObjectURL(e);let s;try{s=await cv(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 Ft("unreadable","The image decoded to zero pixels.");let a=Ia(s,Ea(r,o),nv);if(a.length>is&&(a=Ia(s,Ea(r,o,sv),rv)),a.length>is)throw new Ft("too-large",`Compressed to ${a.length} characters, over the ${is} cap.`);return a}const dv=500;function uv(e=dv){const t=me(),s=em({coalesceMs:e,shouldFlush:()=>t.isMutating({mutationKey:Xi})===0});be("config_changed",()=>{const r={queryKey:Me.current()};s([r])})}const ud="dorkbot",mv=["mesh","agent-paths"];function hv(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)||ud;return`${t}/${s}`}function fv(){var d;const e=Re(),t=ce(),{data:s}=Pe(),{data:r}=ke({queryKey:[...mv],queryFn:()=>t.listMeshAgentPaths(),staleTime:3e4}),o=((d=s==null?void 0:s.agents)==null?void 0:d.defaultAgent)||ud,a=r==null?void 0:r.agents.find(u=>u.name===o),i=(a==null?void 0:a.projectPath)??hv(s);return{startSession:l.useCallback(()=>{a?e(_t({agentId:a.id})):i&&tm(t,i).then(u=>e(u)).catch(u=>{Ji(t,u),ue.error("Couldn’t open the chat. Try again.")})},[e,i,a,t]),defaultAgentDir:i}}function pv(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 gv(){const e=me(),t=Fn();be("community_connections_changed",()=>{t&&e.invalidateQueries({queryKey:yt.connections(t),exact:!0})})}function md(e){const t=ce(),s=e!==null&&e.status!=="pending",r=Fn(s),o=(e==null?void 0:e.ref)??"";return ke({queryKey:r?yt.disconnectImpact(r,o):[...yt.all,"owner","unresolved",o,"disconnect-impact"],queryFn:()=>Zi(r,()=>t.getCommunityDisconnectImpact(o)),enabled:s&&r!==null,staleTime:0,refetchOnMount:"always"})}function hd(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 fd(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}: ${hd(t)}.`}function pd(e){return`Any agents you added from here will be removed from ${e}.`}function gd(e,{remoteRevoked:t,agentsNotRemoved:s}){const r=hd(s);return s.length===0?t?{tone:"success",message:`${e} is disconnected.`}:{tone:"warning",message:xv(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 xv(e){return`Disconnected here, but ${e} couldn’t be reached. Finish under Connected installations on ${e}.`}function bv(){const e=ce(),t=_(o=>o.selectedCwd),s=_(o=>o.setSelectedCwd),{data:r}=ke({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 Ra(e){e.invalidateQueries({queryKey:sn.recentRoot})}const yv=5e3;function vv(e,t=yv){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 Ta(e){e.invalidateQueries({queryKey:sn.dailyCountsRoot})}function wv(e,t){const s=Object.keys(e);return s.length!==Object.keys(t).length?!0:s.some(r=>!(r in t))}function jv(e,t){e.setQueryData(sn.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 Sv(e,t,s){e.setQueryData(sn.list(s),r=>r&&r.filter(o=>o.id!==t))}function Da(e,t,s){const r=new Set(Object.keys(t).filter(o=>!(o in s)));r.size!==0&&e.setQueriesData({queryKey:sn.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 Oa(e,t,s){const r=Date.now(),o=[];for(const[a,i]of Object.entries(t))s[a]!==i&&(jv(e,i),o.push(i));sm(e,o,r);for(const[a,i]of Object.entries(s))t[a]||Sv(e,a,i.cwd??null)}function kv(){const e=me();l.useEffect(()=>{nm();let t={},s={};const r=vv(()=>Ra(e)),o=vt.subscribe(c=>{c.sessions!==t&&(Oa(e,c.sessions,t),r.request(),wv(c.sessions,t)&&Ta(e),t=c.sessions),c.rekeys!==s&&(Da(e,c.rekeys,s),s=c.rekeys)}),a=ms.subscribeEvent("session_list_invalidated",()=>{vt.getState().dropSessions(),e.invalidateQueries({queryKey:sn.listRoot}),Ra(e),Ta(e)}),i=vt.getState();return Object.keys(i.sessions).length>0&&(Oa(e,i.sessions,t),t=i.sessions),Object.keys(i.rekeys).length>0&&(Da(e,i.rekeys,s),s=i.rekeys),ms.connectList(),()=>{o(),a(),r.dispose()}},[e])}function Kt(){const e=ce(),t=me(),{data:s,isLoading:r}=ke({queryKey:Me.current(),queryFn:()=>e.getConfig(),staleTime:ec}),o=Tl(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,p=!o&&c&&!d,f=Bt({mutationFn:b=>e.updateConfig({onboarding:b}),onSuccess:()=>{t.invalidateQueries({queryKey:Me.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 f.mutateAsync({dismissedAt:new Date().toISOString()})}function g(){i.completedAt||f.mutate({completedAt:new Date().toISOString()})}function x(){i.startedAt||f.mutate({startedAt:new Date().toISOString()})}return{state:i,config:s,isLoading:o,isOnboardingComplete:c,isOnboardingDismissed:d,shouldShowOnboarding:m,shouldShowGettingStarted:p,dismiss:h,completeOnboarding:g,startOnboarding:x}}function Cv(e){const{shouldShowOnboarding:t,onboardingHiddenForSession:s}=e,r=t&&!s,[o,a]=l.useState(!1);return r&&!o&&a(!0),o&&!s}function Nv(){const e=Qr(),t=rn(),s=Xr({strict:!1}).onboarding,r=Yo(s)?s:"welcome",o=l.useRef(!1),a=Ee({select:u=>u.status==="idle"}),i=l.useRef(!1);l.useEffect(()=>{if(i.current||!a||(i.current=!0,Yo(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=p=>({...p,onboarding:u});o.current=!0,e==null||e({search:m})},[e]),d=l.useCallback(u=>{if(o.current){t.history.back();return}const m=p=>({...p,onboarding:u});e==null||e({search:m})},[t,e]);return{stage:r,goToStage:c,goBack:d}}function Av(e){const{done:t,overlayVisible:s}=e,r=Qr(),o=Xr({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 xd(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 Ev=2500,Iv="Couldn’t finish setup. Try again.";function _n(e){return e instanceof Error&&e.message&&!/^HTTP \d+$/.test(e.message)?e.message:Iv}function Io(){const e=ce(),t=me();return Bt({mutationFn:s=>e.chooseFirstRunPath(s),onSettled:()=>{for(const s of[Me.all,rm,tc.status()])t.invalidateQueries({queryKey:s});t.invalidateQueries({queryKey:om})},meta:{suppressErrorToast:!0}})}function Rv(e){const t=ce(),{data:s}=ke({queryKey:tc.status(),queryFn:()=>t.getCloudCredits(),enabled:e,refetchInterval:e?Ev:!1,refetchIntervalInBackground:e,staleTime:0});if(s)return s.readiness??(s.linked?"linked":"unlinked")}function Tv(){const e=ce(),t=me();return Bt({mutationFn:()=>e.postOnboardingWelcome(),onSettled:()=>void t.invalidateQueries({queryKey:Me.all}),meta:{suppressErrorToast:!0}})}function Dv({link:e,waitingWindowRef:t,onReady:s}){const r=Io(),[o,a]=l.useState(null),[i,c]=l.useState(!1),d=Rv(i),u=i?d:void 0,m=l.useRef(e),p=l.useRef(r.mutateAsync),f=l.useRef(s);l.useEffect(()=>{m.current=e,p.current=r.mutateAsync,f.current=s});const h=l.useCallback(()=>{var j;(j=t.current)==null||j.close(),t.current=null},[t]),g=l.useCallback(async()=>{a(null);try{await p.current({path:"dorkos"})}catch(v){h(),a(_n(v));return}c(!0);const j=m.current;if(j.state==="linked"){h();return}if(j.state==="pending")return;await j.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 j=xd(b);j?t.current.go(j):t.current.close(),t.current=null},[b,t]);const y=l.useRef(!1);l.useEffect(()=>{u!=="ready"||y.current||(y.current=!0,f.current())},[u]);const C=l.useCallback(()=>{var j;if((j=t.current)==null||j.close(),t.current=Jr(),m.current.state==="expired"||m.current.state==="denied"){a(null),m.current.start();return}g()},[g,t]);return{phase:Ov(o,i,e,b,u),retry:C}}function Ov(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 Ro(){const e=l.useRef(null);return l.useEffect(()=>{var t;(t=e.current)==null||t.focus({preventScroll:!0})},[]),e}function bd({phase:e,link:t,onRetry:s,onCancel:r,onUseOwnAi:o}){const a=Ro();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(St,{size:72,className:"mb-6 opacity-90 dark:hidden"}),n.jsx(St,{variant:"white",size:72,className:"mb-6 hidden opacity-90 dark:block"}),n.jsx(Mv,{phase:e,link:t,onRetry:s,onUseOwnAi:o}),n.jsx(F,{variant:"ghost",size:"sm",className:"text-muted-foreground mt-8",onClick:r,children:"Cancel"})]})}function Mv({phase:e,link:t,onRetry:s,onUseOwnAi:r}){switch(e.kind){case"starting":return n.jsx(Ma,{heading:"Finish in your browser.",line:"Opening the DorkOS page…"});case"waiting":return n.jsxs(n.Fragment,{children:[n.jsx(Vt,{children:"Finish in your browser."}),n.jsx(Jn,{children:"Sign in, then come back. This screen moves on by itself."}),n.jsx(_v,{pending:e.pending})]});case"finishing":return n.jsx(Ma,{heading:"Signed in.",line:"Getting your account ready…"});case"needs-card":return n.jsxs(n.Fragment,{children:[n.jsx(Vt,{children:"Add a card to finish."}),n.jsx(Jn,{children:"Your agents start once a card is saved."}),n.jsxs(F,{className:"mt-6",onClick:()=>t==null?void 0:t.openBilling(),disabled:!t||t.billingPending,children:[(t==null?void 0:t.billingPending)&&n.jsx(Ne,{size:"xs"}),"Add a card"]}),(t==null?void 0:t.billingNotice)&&n.jsx(Rr,{children:t.billingNotice})]});case"refused":return n.jsxs(n.Fragment,{children:[n.jsx(Vt,{children:"Paid plans are US only."}),n.jsx(Jn,{children:"Use your own AI instead."}),n.jsx(F,{className:"mt-6",onClick:r,children:"Use my own AI"})]});case"expired":return n.jsxs(n.Fragment,{children:[n.jsx(Vt,{children:"Your code expired."}),n.jsx(Jn,{children:"Get a new one to finish signing in."}),n.jsx(F,{className:"mt-6",onClick:s,children:"Get a new code"})]});case"failed":return n.jsxs(n.Fragment,{children:[n.jsx(Vt,{children:"Couldn’t start signing in."}),n.jsx(Rr,{children:e.message}),n.jsx(F,{className:"mt-6",onClick:s,children:"Try again"})]})}}function Ma({heading:e,line:t}){return n.jsxs(n.Fragment,{children:[n.jsx(Vt,{children:e}),n.jsxs("p",{className:"text-muted-foreground mt-3 flex items-center gap-2 text-sm",role:"status",children:[n.jsx(Ne,{size:"xs"}),t]})]})}function Vt({children:e}){return n.jsx("h1",{id:"onboarding-connecting-heading",className:"text-2xl font-semibold tracking-tight text-balance",children:e})}function Jn({children:e}){return n.jsx("p",{className:"text-muted-foreground mt-3 text-sm text-balance",children:e})}function Rr({children:e}){return n.jsx("p",{className:"text-destructive mt-3 text-sm text-balance",role:"alert",children:e})}function _v({pending:e}){const{copied:t,failed:s,copy:r}=$n(),[o,a]=l.useState(!1),i=xd(e);return n.jsxs("div",{className:"mt-8 w-full space-y-4","data-testid":"onboarding-link-code",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("code",{className:"bg-muted min-w-0 flex-1 rounded-md px-3 py-3 text-center font-mono text-lg font-semibold tracking-[0.15em] whitespace-nowrap tabular-nums sm:text-xl",children:e.userCode}),n.jsx(F,{variant:"ghost",size:"icon-md",onClick:()=>void r(e.userCode),"aria-label":s?"Couldn’t copy code. Try again":"Copy code",children:t?n.jsx(zt,{className:"text-status-success size-4"}):s?n.jsx(_e,{className:"text-destructive size-4"}):n.jsx(Zr,{className:"size-4"})})]}),n.jsxs(F,{variant:"outline",className:"w-full",disabled:i===null,onClick:()=>a(i===null||!In(i)),children:[n.jsx(Zt,{className:"size-4"}),"Open the page again"]}),n.jsx("p",{className:"text-muted-foreground text-xs break-all",children:e.verificationUri}),o&&n.jsx(Rr,{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(Ne,{size:"xs"}),n.jsx("span",{role:"status",children:"Waiting for you to approve."})]})]})}function Pv({onComplete:e}){const t=Tv(),{completeOnboarding:s}=Kt(),r=Re(),[o,a]=l.useState(null),i=l.useCallback(()=>{s(),r({...ye.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(F,{onClick:()=>void c(),children:"Try again"}),n.jsx(F,{variant:"outline",onClick:i,children:"Go to #team"})]})]}):n.jsxs("p",{className:"text-muted-foreground flex items-center gap-2 text-sm",role:"status",children:[n.jsx(Ne,{size:"xs"}),"Opening #team…"]})})}const Lv="claude-code";function yd(e,t){return e.length===0?null:e.includes(t)?t:nc.find(r=>e.includes(r))??e[0]}function Fv({readyTypes:e,settled:t,settleToken:s}){var b,y;const{data:r}=Pe(),o=Yn(),a=me(),[i,c]=l.useState(null),[d,u]=l.useState(null),m=l.useRef(null),p=((b=r==null?void 0:r.executionDefaults)==null?void 0:b.runtime)??Lv,f=!!((y=r==null?void 0:r.onboarding)!=null&&y.runtimeDefaultSetAt),h=l.useCallback((C,j)=>{c(null),u(j),o.mutate(C,{onSuccess:()=>void a.invalidateQueries({queryKey:Me.all}),onError:I=>{u(null),c(I.message||"Couldn’t save that. Try again.")}})},[o,a]);l.useEffect(()=>{if(!t||e.length===0||!r||f)return;const C=yd(e,p);C&&m.current!==s&&(m.current=s,h({onboarding:{runtimeDefaultSetAt:new Date().toISOString()},...C===p?{}:{runtimes:{default:C}}},C))},[t,s,e,r,f,p,h]);const g=l.useCallback(C=>{C!==(d??p)&&h({runtimes:{default:C},...f?{}:{onboarding:{runtimeDefaultSetAt:new Date().toISOString()}}},C)},[h,d,p,f]);return{runtime:d??((f||d!==null)&&r?p:null),current:d??p,choose:g,error:i}}function $v({onContinue:e,renderConnect:t,simulated:s}){const r=sc(),{data:o}=rc(),{data:a}=oc(),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(()=>nc.filter(b=>(i==null?void 0:i.runtimes[b])!==void 0),[i]),m=l.useMemo(()=>i?u.filter(b=>am(i,b,!0).state==="ready"||s===void 0&&im(a,b)):[],[u,i,a,s]),p=Fv({readyTypes:m,settled:c&&s===void 0,settleToken:r.dataUpdatedAt}),[f,h]=l.useState(null),g=s!=null&&s.defaultRuntime?{runtime:f??s.defaultRuntime,current:f??s.defaultRuntime,choose:h,error:null}:p;if(!c)return n.jsxs("p",{className:"text-muted-foreground flex items-center gap-2 text-sm",role:"status",children:[n.jsx(Ne,{size:"xs"}),"Looking for AI apps…"]});if(s===void 0&&r.isError)return n.jsxs("div",{className:"space-y-2",role:"alert",children:[n.jsx("p",{className:"text-muted-foreground text-sm",children:"Couldn’t check for AI apps."}),n.jsx(F,{variant:"outline",size:"sm",onClick:()=>void r.refetch(),children:"Try again"})]});const x=m.length>0;return n.jsxs("div",{className:"space-y-4","data-testid":"onboarding-ai-apps",children:[x&&n.jsxs("div",{className:"space-y-1",children:[n.jsx("p",{className:"text-sm",children:zv(m,g.runtime)}),n.jsx(Bv,{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(Ib,{types:u,requirements:i,registeredTypes:d,renderConnect:t,onRecheck:s?void 0:()=>void r.refetch(),isRechecking:r.isFetching}),x&&n.jsx(F,{className:"w-full",onClick:e,"data-testid":"onboarding-ai-app-continue",children:"Continue"})]})}function Bv({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(Bn,{open:o,onOpenChange:a,children:[n.jsxs(zn,{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(Ut,{className:"size-3"})]}),n.jsxs(Un,{align:"start",className:"p-1",children:[n.jsx(Kn,{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:rt(c).label}),!t.includes(c)&&n.jsx("span",{className:"text-muted-foreground text-xs",children:"Not signed in yet"})]}),d&&n.jsx(zt,{className:"size-3.5 shrink-0","aria-hidden":!0})]},c)})})]})]})}function zv(e,t){const s=e.map(c=>rt(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=rt(t).label;if(e.includes(t))return`${r} New chats start with ${o}.`;const a=yd(e,t),i=a?rt(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 Uv=[{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."}],Kv={openai:"OpenAI API key",anthropic:"Anthropic API key",openrouter:"OpenRouter key"};function Hv({onSaved:e,beforePick:t,slots:s,initialRow:r,simulatedApps:o}){const[a,i]=l.useState(r??null),c=Io(),[d,u]=l.useState(null),m=async(f,h=!1)=>{u(null);try{return await(t==null?void 0:t()),(await c.mutateAsync({path:"own",choice:f})).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}},p=f=>{u(null);const h=a===f?null:f;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:Uv.map(f=>n.jsxs("section",{"data-testid":`own-ai-row-${f.id}`,children:[n.jsxs("button",{type:"button","aria-expanded":a===f.id,onClick:()=>p(f.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:f.title}),n.jsx("span",{className:"text-muted-foreground block text-xs",children:f.line})]}),n.jsx(on,{"aria-hidden":!0,className:H("text-muted-foreground size-4 shrink-0 transition-transform",a===f.id&&"rotate-90")})]}),a===f.id&&n.jsxs("div",{className:"px-4 pt-1 pb-4",children:[n.jsx(Wv,{row:f.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})]})]},f.id))})}function Wv({row:e,busy:t,save:s,onSaved:r,slots:o,simulatedApps:a}){switch(e){case"local":return n.jsxs(F,{onClick:async()=>{await s({kind:"local"})&&r()},disabled:t,children:[t&&n.jsx(Ne,{size:"xs"}),"Use this computer’s model"]});case"agent-app":return n.jsx($v,{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(Gv,{service:e,busy:t,save:s,onSaved:r})}}function Gv({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 p=a.trim();if(d(null),!p){d("Enter a key.");return}if(e==="anthropic"&&p.startsWith("sk-ant-oat")){d("Subscription tokens can’t run agents. Use an API key.");return}await s({kind:e,apiKey:p})&&(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(ze,{htmlFor:`${o}-key`,children:Kv[e]}),n.jsx(cm,{id:`${o}-key`,value:a,onChange:m=>i(m.target.value),autoComplete:"off"})]}),c&&n.jsx("p",{className:"text-destructive text-sm",role:"alert",children:c}),n.jsxs(F,{type:"submit",disabled:t,children:[t&&n.jsx(Ne,{size:"xs"}),"Save"]})]})}function qv({onBack:e,...t}){const s=Ro();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(Hv,{...t}),n.jsx(F,{variant:"ghost",size:"sm",className:"text-muted-foreground mt-6 self-start",onClick:e,children:"Back"})]})}function Yv({agentName:e,className:t}){var c;const s=Il(),r=e.trim()||"This agent";if(s.isPending)return n.jsx("p",{className:H("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:H("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?`${xa(d.toolkit)} · ${d.label}`:xa(d.toolkit),m=Bb(d.access.classifications);return`${u} (${d.lifecycle==="paused"?`${m}, paused`:m})`});return n.jsxs("div",{className:H("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(ac,{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 Vv({onContinueWithDorkos:e,onUseOwnAi:t,onContinueWithout:s,busy:r=null,error:o=null}){const a=ic(),i=Ro();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(St,{size:120,className:"mb-8 opacity-90 dark:hidden"}),n.jsx(St,{variant:"white",size:120,className:"mb-8 hidden opacity-90 dark:block"}),n.jsx("h1",{ref:i,tabIndex:-1,className:"text-3xl font-semibold tracking-tight text-balance outline-none sm:text-4xl",children:"You, Multiplied."}),n.jsx("p",{className:"text-muted-foreground mt-3 text-balance",children:"Build and run your business with an agent team."}),n.jsxs("div",{className:"mt-10 flex w-full max-w-xs flex-col items-center gap-3",children:[n.jsxs(F,{size:"lg",className:"w-full",onClick:e,disabled:r!==null,"data-testid":"onboarding-continue-dorkos",children:[r==="dorkos"&&n.jsx(Ne,{size:"xs"}),"Continue with DorkOS"]}),n.jsx(Co,{withSpaces:a,className:"text-balance"}),o&&n.jsx("p",{className:"text-destructive text-sm",role:"alert",children:o})]}),n.jsxs("div",{className:"mt-8 flex flex-col items-center gap-1 sm:flex-row sm:gap-2",children:[n.jsx(F,{variant:"ghost",size:"sm",className:"text-muted-foreground",onClick:t,disabled:r!==null,children:"Use my own AI"}),n.jsx("span",{"aria-hidden":!0,className:"text-muted-foreground/50 hidden sm:inline",children:"·"}),n.jsxs(F,{variant:"ghost",size:"sm",className:"text-muted-foreground",onClick:s,disabled:r!==null,children:[r==="none"&&n.jsx(Ne,{size:"xs"}),"Continue without an account"]})]})]})}function Qv({onComplete:e,slots:t}){const s=t==null?void 0:t.renderAccountLink,r=o=>n.jsx(Xv,{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 Xv({link:e,slots:t,onComplete:s}){var I;const{stage:r,goToStage:o,goBack:a}=Nv(),{startOnboarding:i}=Kt(),c=Io(),[d,u]=l.useState(null),m=l.useRef(null),p=l.useRef(!1);l.useEffect(()=>{p.current||(p.current=!0,i())},[i]),l.useEffect(()=>{var v;r!=="connecting"&&((v=m.current)==null||v.close(),m.current=null)},[r]);const f=l.useRef(e);l.useEffect(()=>{f.current=e});const h=l.useCallback(async()=>{var v;((v=f.current)==null?void 0:v.state)==="pending"&&await f.current.cancel()},[]),g=l.useCallback(()=>{m.current!==null||r==="connecting"||(u(null),m.current=e&&e.state!=="linked"?Jr():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]),C=l.useCallback(()=>a("welcome"),[a]);let j;return r==="connecting"?j=e?n.jsx(Jv,{link:e,waitingWindowRef:m,onReady:b,onCancel:()=>{h(),C()},onUseOwnAi:()=>{h(),y()}}):n.jsx(bd,{phase:{kind:"failed",message:"Signing in isn’t available here."},link:null,onRetry:C,onCancel:C,onUseOwnAi:y}):r==="own-ai"?j=n.jsx(qv,{onBack:C,onSaved:b,beforePick:h,slots:t}):r==="landing"?j=n.jsx(Pv,{onComplete:s}):j=n.jsx(Vv,{onContinueWithDorkos:g,onUseOwnAi:y,onContinueWithout:()=>void x(),busy:c.isPending&&((I=c.variables)==null?void 0:I.path)==="none"?"none":null,error:d}),j}function Jv({link:e,waitingWindowRef:t,onReady:s,onCancel:r,onUseOwnAi:o}){const{phase:a,retry:i}=Dv({link:e,waitingWindowRef:t,onReady:s});return n.jsx(bd,{phase:a,link:e,onRetry:i,onCancel:r,onUseOwnAi:o})}function Zv(){var u;const e=ce(),t=me(),{data:s}=ke({queryKey:Me.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}=Bt({mutationKey:Xi,mutationFn:async m=>{await e.updateConfig({mesh:{scanRoots:m}})},onSuccess:()=>{t.invalidateQueries({queryKey:Me.all})}}),d=l.useCallback(m=>i(m),[i]);return{roots:a,boundary:o,isSaving:c,setScanRoots:d}}const ew=50,bn=["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 tw(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 nw(e,t){const s=e.getQueryData($e.detail(t.threadId));return s===void 0||s.viewerAuthorId===t.userId}function sw(e,t){const s=e.isFetching({queryKey:$e.lists()})>0;e.cancelQueries({queryKey:$e.lists()}),e.setQueriesData({queryKey:$e.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($e.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($e.threads());r!=null&&r.some(o=>o.roomId===t.threadId&&o.unreadCount>0)&&e.invalidateQueries({queryKey:$e.threads()}),s&&e.invalidateQueries({queryKey:$e.lists()})}function rw(){const e=me(),t=()=>{e.invalidateQueries({queryKey:$e.lists()}),e.invalidateQueries({queryKey:$e.wellKnowns()}),e.invalidateQueries({queryKey:$e.threads()})};be(bn[0],t),be(bn[1],t),be(bn[2],t),be(bn[3],t),be(bn[4],t),be("room_updated",o=>{_a(o)&&e.invalidateQueries({queryKey:$e.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:$e.detail(i)})},ew)};be("room_member_added",r),be("room_member_removed",r),be("room_presence",o=>lm.getState().observe(o)),be("read_cursor",o=>{!tw(o)||!nw(e,o)||sw(e,o)})}function ow(){const e=me();be("tasks_changed",()=>{e.invalidateQueries({queryKey:[...dm],exact:!0})});const t=()=>{e.invalidateQueries({queryKey:[...um]})};be("task_run_failed",t),be("task_run_updated",t)}function aw(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 iw=4e3;function vd(){var o;const e=eo(),{identityPromptDismissedAt:t,isLoading:s}=zs();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&&sb(r)?"ask":"settled"}function cw(e={}){const{state:t,isLoading:s,shouldShowGettingStarted:r}=Kt(),o=e.gettingStartedCardShown??r,a=vd(),{dismissIdentityPrompt:i}=zs(),[c,d]=l.useState("ask");l.useEffect(()=>{if(c!=="saved")return;const f=setTimeout(()=>d("done"),iw);return()=>clearTimeout(f)},[c]);const u=t.completedAt!==null||t.dismissedAt!==null,m=!s&&u&&a==="ask"&&!o,p=()=>{i().catch(()=>{})};return{visible:c!=="done"&&(m||c==="saved"),phase:c,markSaved:()=>{d("saved"),p()},skip:()=>{d("done"),p()}}}function wd(){const{firstRunPath:e}=Kt().state,{offered:t,pending:s}=vl(),r=e==="dorkos"||e==="own";return{due:r&&t,pending:r&&s}}const lw=4e3,Js="Tell DorkBot your name",Pa="Tell DorkBot about your work";function dw({onDismiss:e}){const t=et(),s=Re(),{open:r}=tt(),o=to(),a=_(R=>R.requestTour),{startSession:i}=fv(),{roles:c,rolePromptDismissedAt:d,isLoading:u,saveRoles:m,dismissIdentityPrompt:p}=zs(),f=vd(),h=wd().due,[g,x]=l.useState("closed"),[b,y]=l.useState("closed"),[C,j]=l.useState([]),I=!u&&c.length===0&&d===null;l.useEffect(()=>{if(g!=="saved")return;const R=setTimeout(()=>x("closed"),lw);return()=>clearTimeout(R)},[g]);const v=()=>{x("saved"),p().catch(()=>{})},N=()=>{y("saving"),m(C).then(()=>y("closed")).catch(()=>y("error"))};let O="Save";b==="saving"?O="Saving…":b==="error"&&(O="Try again");const P=[{icon:As,label:"Talk to DorkBot",onClick:i},...f==="ask"||g==="saved"?[{icon:Ol,label:Js,onClick:()=>x(R=>R==="saved"?R:R==="closed"?"open":"closed"),expanded:g!=="closed"}]:[],...I?[{icon:no,label:Pa,onClick:()=>y(R=>R==="closed"?"open":"closed"),expanded:b!=="closed"}]:[],{icon:Ry,label:"Show me around",onClick:()=>a("general")},{icon:kt,label:"Create an agent",onClick:()=>Es.getState().open("new")},{icon:cc,label:"Schedule a task",onClick:()=>s({...ye.tasks()})},{icon:Ml,label:"Connect more runtimes",onClick:()=>r("runtimes")},{icon:_y,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(_e,{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:P.map(({icon:R,label:A,onClick:w,expanded:k})=>n.jsxs("li",{children:[n.jsxs("button",{onClick:w,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":k,children:[n.jsx(R,{className:"text-muted-foreground size-3.5 shrink-0"}),n.jsx("span",{className:"text-foreground flex-1 text-xs",children:A}),n.jsx(on,{className:"text-muted-foreground/40 group-hover:text-muted-foreground size-3.5 shrink-0 transition-colors"})]}),A===Js&&g==="open"&&n.jsx("div",{className:"px-1.5 py-2","data-testid":"progress-card-identity-form",children:n.jsx(Dl,{onSaved:v})}),A===Js&&g==="saved"&&n.jsx("p",{role:"status",className:"text-muted-foreground px-1.5 py-2 text-xs",children:ht.identityCardSaved}),A===Pa&&b!=="closed"&&n.jsx("div",{className:"px-1.5 py-2","data-testid":"progress-card-profile-picker",children:n.jsx(yl,{selected:C,onChange:j,onConfirm:N,confirmLabel:O,busy:b==="saving",error:b==="error"?ht.saveError:null})})]},A))}),h&&n.jsx(wl,{compact:!0,className:"border-border mt-2 border-t px-1.5 pt-2"})]})}const La=72;function jd({title:e,description:t,titleIsStatus:s}){return n.jsxs("div",{className:"flex flex-col gap-2",children:[n.jsxs("div",{children:[n.jsx(St,{size:La,className:"block dark:hidden"}),n.jsx(St,{variant:"white",size:La,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 uw({prompt:e}){const t=et(),{open:s}=tt(),{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(jd,{title:r==="saved"?ht.profileSaved:ht.profileCardPrompt[0],description:n.jsxs(n.Fragment,{children:[ht.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(yl,{selected:o,onChange:a,onConfirm:e.save,confirmLabel:i,onSkip:e.skip,skipLabel:"Don’t ask again",busy:r==="saving",error:c})]})}const mw=4e3;function hw(e={}){const{state:t,isLoading:s,shouldShowGettingStarted:r}=Kt(),o=e.gettingStartedCardShown??r,{roles:a,rolePromptDismissedAt:i,isLoading:c,saveRoles:d,dismissRolePrompt:u}=zs(),[m,p]=l.useState([]),[f,h]=l.useState("ask");l.useEffect(()=>{if(f!=="saved")return;const C=setTimeout(()=>h("done"),mw);return()=>clearTimeout(C)},[f]);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 f==="saving"?y="Saving…":f==="error"&&(y="Try again"),{visible:f!=="done"&&(b||f==="saved"),phase:f,selected:m,setSelected:p,confirmLabel:y,errorMessage:f==="error"?ht.saveError:null,save:()=>{h("saving"),d(m).then(()=>h("saved")).catch(()=>h("error"))},skip:()=>{h("done"),u().catch(()=>{})}}}function fw({prompt:e}){const t=et(),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(jd,{title:s?ht.identityCardSaved:ht.identityCardPrompt[0],description:s?void 0:ht.identityCardPrompt[1],titleIsStatus:s}),!s&&n.jsx(Dl,{onSaved:e.markSaved,onSkip:e.skip,skipLabel:"Don’t ask again"})]})}function pw(){const e=ce(),t=l.useRef(null),{startScan:s,addCandidate:r,addExistingAgent:o,setProgress:a,completeScan:i,setError:c}=so(),d=l.useCallback((m={roots:[]})=>{var f;(f=t.current)==null||f.abort();const p=new AbortController;t.current=p,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}},p.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 gw(){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 xw({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 p=new Set(m);return p.delete(u.path),p});try{await e(u),t(u)}catch{i(m=>new Set(m).add(u.path))}finally{s.current.delete(u.path),o(m=>{const p=new Set(m);return p.delete(u.path),p})}}},[t,e]),d=l.useCallback(()=>i(new Set),[]);return{failedPaths:a,pendingPaths:r,registerCandidate:c,resetFailures:d}}function bw(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 yw(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 vw={"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 ww(e){return vw[e]??`Found by the “${e}” check.`}const jw={"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 Sw(e){return jw[e]??"Found in the project’s files."}function kw({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:H("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(mm,{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(Pl,{openDelay:300,children:[n.jsx(Ll,{asChild:!0,children:n.jsx(Rn,{variant:"secondary",className:"hover:bg-secondary/80 cursor-default",children:m.detectedRuntime})}),n.jsxs(Fl,{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:ww(u)})]})]}),m.inferredCapabilities&&m.inferredCapabilities.length>0&&m.inferredCapabilities.map(p=>n.jsxs(an,{children:[n.jsx(cn,{asChild:!0,children:n.jsx(Rn,{size:"xs",variant:"outline",className:"cursor-default",children:p})}),n.jsx(ln,{side:"top",className:"max-w-48 text-center",children:Sw(p)})]},p))]}),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 Cw({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(Ns,{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:Oe(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 Nw=2;function Aw({agents:e}){const[t,s]=l.useState(e.length<=Nw);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(on,{className:H("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(Cw,{agent:r},r.path))})]})}function Ew({count:e,onAddAll:t,disabled:s}){return e===0?null:n.jsxs("div",{className:"flex items-center justify-between py-1",children:[n.jsxs("span",{className:"text-muted-foreground text-sm font-medium",children:[e," new project",e===1?"":"s"]}),n.jsx(F,{variant:"outline",size:"sm",onClick:t,disabled:s,children:"Add all"})]})}function Iw({roots:e,onChange:t}){const[s,r]=l.useState(""),[o,a]=l.useState(!1),i=l.useCallback(m=>{const p=m.trim();p&&!e.includes(p)&&t([...e,p])},[e,t]),c=l.useCallback(m=>{t(e.filter(p=>p!==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(Rn,{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(_e,{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(Is,{className:"size-4"})})]}),n.jsx(lc,{open:o,onOpenChange:a,onSelect:u})]})}function Rw(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 Tw(){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 Dw=[{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 Ow({fullBleed:e=!1,onRegistered:t}){var te;const{roots:s,setScanRoots:r}=Zv(),[o,a]=l.useState(null),[i,c]=l.useState(!1),[d,u]=l.useState(3),{startScan:m}=pw(),{candidates:p,existingAgents:f,isScanning:h,progress:g,error:x,lastScanAt:b}=so(),{mutateAsync:y}=hm(),{mutate:C}=fm(),{data:j}=pm(),{actedPaths:I,markActed:v,resetActed:N}=gw(),O=o??s,P=l.useCallback(M=>y({path:M.path,overrides:bw(M),scanRoot:Rw(M.path,O)}),[O,y]),R=l.useCallback(M=>{v(M.path),t==null||t()},[v,t]),{failedPaths:A,pendingPaths:w,registerCandidate:k,resetFailures:E}=xw({register:P,onSuccess:R});function D(M){a(M),r(M)}function T(){O.length>0&&(N(),E(),m({roots:O,maxDepth:d}))}const $=l.useMemo(()=>h?p:yw(p),[p,h]).filter(M=>!I.has(M.path)),B=(((te=j==null?void 0:j.agents)==null?void 0:te.length)??0)>0,q=f.length>0,oe=p.length>0,ie=q||oe,Y=!h&&b!==null,X=!h&&b===null;function ne(){for(const M of $)k(M)}const se=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(Ut,{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(Iw,{roots:O,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(Dy,{className:"size-3"}),"What it looks for"]}),n.jsx("ul",{className:"space-y-1 pl-4",children:Dw.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:X?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(Tw,{}),n.jsxs("div",{className:"text-center",children:[n.jsx("p",{className:"text-foreground text-sm font-medium",children:"Find your existing projects"}),n.jsx("p",{className:"text-muted-foreground mx-auto mt-1 max-w-[300px] text-xs leading-relaxed",children:"Find Claude Code, Cursor, Codex and other AI projects on this computer."})]}),x&&n.jsx("div",{className:"border-destructive/30 bg-destructive/5 text-destructive rounded-lg border px-4 py-3 text-sm",children:x}),n.jsxs(F,{onClick:T,disabled:O.length===0,className:"w-full",children:[n.jsx(hs,{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"}),se]})}):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:[se,n.jsxs(F,{onClick:T,disabled:h||O.length===0,children:[h?n.jsx(Ne,{}):n.jsx(hs,{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(Ne,{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}),Y&&!oe&&q&&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."})]}),Y&&!ie&&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."})]}),Y&&$.length>0&&n.jsxs(n.Fragment,{children:[n.jsx(Ew,{count:$.length,onAddAll:ne,disabled:w.size>0}),n.jsx(Qe,{mode:"popLayout",children:$.map(M=>n.jsx(kw,{candidate:M,className:"mb-2",registrationFailed:A.has(M.path),registrationPending:w.has(M.path),onApprove:z=>void k(z),onSkip:z=>v(z.path),onDeny:z=>C({path:z.path},{onSuccess:()=>v(z.path)})},M.path))})]}),Y&&q&&n.jsx("div",{className:"mt-3",children:n.jsx(Aw,{agents:f})})]})]})})}function Mw(){const e=Tn(f=>f.isOpen),t=Tn(f=>f.close),s=Re(),[r,o]=l.useState(0),[a,i]=l.useState(!1),[c,d]=l.useState(!1);e!==c&&(d(e),e&&(o(0),i(!1)));function u(f){f||t()}function m(){if(r>0&&!a){i(!0);return}t(),r>0&&s({...ye.team()})}const p=`${r} project${r===1?"":"s"} joined`;return n.jsx(pt,{open:e,onOpenChange:u,children:n.jsxs(gt,{className:"max-h-[85vh] !min-h-0 sm:max-w-2xl",children:[n.jsxs(ut,{className:"shrink-0",children:[n.jsx(Xe,{children:"Bring in existing projects"}),n.jsx(mt,{children:a?"Your projects are ready in DorkOS.":"Find projects on this computer to add."})]}),a?n.jsx(wt,{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(Ns,{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(wt,{className:"mt-2 overflow-y-auto",children:n.jsx(Ow,{onRegistered:()=>o(f=>f+1)})}),n.jsxs(Xt,{className:"shrink-0 sm:justify-between",children:[!a&&r>0?n.jsx("span",{className:"text-muted-foreground text-sm","data-testid":"import-joined-count",children:p}):n.jsx("span",{}),n.jsx(F,{onClick:m,"data-testid":"import-done",children:"Done"})]})]})})}function _w(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 Pw(){const e=gm(s=>s.record),t=px();be("marketplace_dev_link_reloaded",s=>{_w(s)&&(e(s),t())})}function Lw(){const e=me();be("relay_bindings_changed",()=>{e.invalidateQueries({queryKey:[...gx]})})}class Fa extends l.Component{constructor(){super(...arguments);fn(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 $a=new Set(["agent-profile","profile","files","room","computer"]),Ba=new Set(["pulse","session","canvas","browser","local-browser","terminal"]),Fw={};function $w(e,t){var Gt,qt,K;const s=_(S=>S.activeRightPanelTab),r=_(S=>S.setActiveRightPanelTab),o=_(S=>S.rightPanelLayoutKey),a=_(S=>S.selectedCwd),i=_(S=>S.explicitAgentPath),c=_(S=>S.sessionId),[d]=dc(),u=t==="/session"?d:null,m=u?`chat/${encodeURIComponent(u)}`:"human",{data:p}=Gb(e.some(S=>S.id==="local-browser")),f=(p==null?void 0:p.status)==="connected"&&p.connectionId&&p.sessionId===u?p:null,h=f?`resource/browser/${m}/${encodeURIComponent(f.connectionId)}`:"local-browser",g=_(S=>S.roomCanvasLiveRoomId),x=_(S=>S.openDocuments),b=_(S=>g?S.roomCanvasDocuments[g]:void 0),y=_(S=>g?S.roomCanvasUnread[g]:void 0),C=_(S=>g?S.roomCanvasPresence[g]:void 0),j=uc(g),I=ce(),v=_(S=>{var W;return g?(W=S.roomCanvasActive[g])==null?void 0:W.canvas:S.activeCanvasDocumentId}),N=_(S=>{var W;return g?(W=S.roomCanvasActive[g])==null?void 0:W.browser:S.activeBrowserDocumentId}),O=_(S=>S.activateCanvasDocument),P=_(S=>S.activateRoomCanvasDocument),R=Vo(S=>S.chrome),A=`${c??""}:${a}`,w=(R==null?void 0:R.scope)===A?R:null,[k,E]=l.useState(null);l.useEffect(()=>{if((k==null?void 0:k.scope)!==A||!w)return;const S=k.id?w.tabs.find(W=>`resource/terminal/${W.id}`===k.id):w.tabs.find(W=>W.id===w.activeId);S&&!S.closed&&E(null)},[w,k,A]);const D=Wb(),T=g?`room:${g}`:i??o??a??t,L=_(S=>S.canvasSessionId),$=_(S=>S.canvasSessionCwd),B=$!==void 0?L:L??c,q=$!==void 0?$:a,oe=g?`room:${g}`:xm(B,q),ie=g?`room:${g}`:vm(B,q),Y=_(S=>S.panelViewPreferences)??Fw,X=_(S=>S.updatePanelViewPreference),ne=_(S=>S.reopenPanelResourceView),se=l.useMemo(()=>new Set(Object.values(Y).flatMap(S=>S.closed)),[Y]),te=Y[T]??{opened:[],closed:[]},M=((Gt=D.data)==null?void 0:Gt.cwd)!=null&&(i?D.data.cwd.replace(/\/workspace\/?$/,"")===i:D.data.cwd===a)&&D.data.phase!=="disabled"&&D.data.phase!=="unsupported",z=l.useMemo(()=>e.filter(S=>S.id!=="computer"||M),[e,M]),G=S=>X==null?void 0:X(T,S),Q=S=>{var W;return((W=Z.find(ee=>ee.id===S))==null?void 0:W.resource)==="browser"},ge=S=>{var W;return Q(S)?S:(W=Z.find(ee=>ee.id===S))!=null&&W.resource?`${oe}:${S}`:S},qe=S=>{var W;return((W=Z.find(ee=>ee.id===S))==null?void 0:W.resource)==="document"?[ge(S),`${ie}:${S}`]:[ge(S)]},nt=S=>{var W;return((W=Z.find(ee=>ee.id===S))==null?void 0:W.resource)==="document"},Ke=S=>qe(S).some(W=>nt(S)||Q(S)?se.has(W):te.closed.includes(W)),Z=z.flatMap(S=>{const W=S.id;if(W==="local-browser"){if(!f)return[{...S,category:W,title:"Browser"}];const ee=f.tabs.find(pe=>pe.id===f.selectedTabId),ae=f.mode==="embedded"?"DorkOS browser":"New browser window";return[{...S,category:W,resource:"browser",id:h,title:(ee==null?void 0:ee.title)||ae,icon:fs}]}if(W==="browser"||W==="canvas"){const ee=g?bm(b??[],W):ym(x??[],W);if(ee.length)return ee.map(ae=>{var pe,ct,V;return{...S,category:W,resource:"document",id:`resource/${ae.id}`,title:"title"in ae&&ae.title||ae.sourceLabel||S.title,icon:W==="browser"?fs:qb,activate:()=>{g?P(g,ae.id):O(ae.id)},..."authorId"in ae?{author:(ct=(pe=j.data)==null?void 0:pe.members.find(he=>he.author.id===ae.authorId))==null?void 0:ct.author,unread:(V=y==null?void 0:y[W])==null?void 0:V.includes(ae.id),pinned:ae.pinned,watchers:Object.entries(C??{}).filter(([he,We])=>{var Fe;return We===ae.id&&he!==((Fe=j.data)==null?void 0:Fe.viewerAuthorId)}).flatMap(([he])=>{var We,Fe;return((Fe=(We=j.data)==null?void 0:We.members.find(Et=>Et.author.id===he))==null?void 0:Fe.author)??[]})}:{}}})}return W==="terminal"&&(w!=null&&w.tabs.length)?w.tabs.map(ee=>({...S,category:W,resource:"terminal",id:`resource/terminal/${ee.id}`,title:ee.title,closed:ee.closed,icon:mc,activate:ae=>w.activate(ee.id,ae)})):[{...S,category:W,...W==="browser"?{title:"Page previews"}:{}}]}),He=new Set;if(!g){const S=(x??[]).filter(W=>W.id.startsWith("pending:")&&Ke(`resource/${W.id}`));for(const W of x??[])W.id.startsWith("pending:")||W.openedHere||S.some(ee=>{var ae;return(ae=ee.pendingCandidateIds)==null?void 0:ae.includes(W.id)})&&He.add(`resource/${W.id}`)}const ot=Z.some(S=>$a.has(S.category)||!Ba.has(S.category)&&!S.isGlobal),Te=Z.filter(S=>(!S.closed||(k==null?void 0:k.scope)===A&&k.id===S.id)&&!Ke(S.id)&&!He.has(S.id)&&($a.has(S.category)||!Ba.has(S.category)||S.resource||S.extensionId||te.opened.includes(S.category)||S.category===s||!ot&&S.isGlobal&&S.category!=="local-browser"));if(s==="terminal"&&(k==null?void 0:k.scope)===A&&k.id===null&&!Te.some(S=>S.category==="terminal")){const S=z.find(W=>W.id==="terminal");S&&Te.push({...S,category:"terminal"})}const U=s==="terminal"?`resource/terminal/${w==null?void 0:w.activeId}`:s==="local-browser"?h:s==="browser"?`resource/${N}`:s==="canvas"?`resource/${v}`:s,le=((qt=Te.find(S=>S.id===U))==null?void 0:qt.id)??((K=Te.find(S=>S.category===s))==null?void 0:K.id)??null,xe=g?b==null?void 0:b.find(S=>`resource/${S.id}`===U):x==null?void 0:x.find(S=>`resource/${S.id}`===U),we=xe?`${xe.rev}:${xe.lastActiveAt}`:null,Le=_(S=>S.requestedRightPanel),at=(S,W="pointer")=>{var ae;const ee=Z.find(pe=>pe.id===S);ee&&(G(pe=>({opened:[...new Set([...pe.opened,ee.category])].slice(-100),closed:pe.closed.filter(ct=>!qe(S).includes(ct))})),(ee.resource==="document"||ee.resource==="browser")&&(ne==null||ne(qe(S))),E(ee.resource==="terminal"?{scope:A,id:ee.id}:null),(ae=ee.activate)==null||ae.call(ee,W),r(ee.category))},Ht=S=>{var ct;const W=x==null?void 0:x.find(V=>V.id.startsWith("pending:")&&`resource/${V.id}`===S),ee=W?Te.filter(V=>{var he;return!((he=W.pendingCandidateIds)!=null&&he.some(We=>{var Fe;return`resource/${We}`===V.id&&!((Fe=x==null?void 0:x.find(Et=>Et.id===We))!=null&&Fe.openedHere)}))}):Te,ae=ee[ee.findIndex(V=>V.id===S)+1]??ee[ee.findIndex(V=>V.id===S)-1],pe=Z.find(V=>V.id===S);if(E(null),(pe==null?void 0:pe.resource)==="terminal"&&(w!=null&&w.hide))w.hide(S.slice(18));else{const V=he=>({...he,closed:[...new Set([...he.closed,ge(S)])].slice(-100)});(pe==null?void 0:pe.resource)==="document"?X==null||X(`documents:${oe}`,V):(pe==null?void 0:pe.resource)==="browser"?X==null||X(`browsers:${m}`,V):G(V)}S===le&&((ct=ae==null?void 0:ae.activate)==null||ct.call(ae,"keyboard"),r((ae==null?void 0:ae.category)??null))};l.useEffect(()=>{if(!s)return;const S=U?qe(U):[];!te.closed.includes(s)&&(!U||!Ke(U))||(G(W=>({...W,closed:W.closed.filter(ee=>ee!==s&&!S.includes(ee))})),U&&(nt(U)||Q(U))&&(ne==null||ne(S)))},[s,U,we,Le,oe,m,T]);const At=s==="browser"?N:s==="canvas"?v:null,De=g?b==null?void 0:b.find(S=>S.id===At):x==null?void 0:x.find(S=>S.id===At),it=async S=>{try{await S()}catch{ue.error("Couldn’t update the canvas.")}},Wt=S=>{it(()=>g?I.openRoomCanvasDocument(g,S):_.getState().openCanvasDocument(S)),r(S.type==="url"?"browser":"canvas")};return{available:z,allViews:Z,visible:Te,activeId:le,activate:at,closeView:Ht,terminal:w,createTerminal:z.some(S=>S.id==="terminal")?()=>{E({scope:A,id:null}),G(S=>({opened:[...new Set([...S.opened,"terminal"])].slice(-100),closed:S.closed.filter(W=>W!=="terminal")})),w?w.create():Vo.getState().requestCreate(A),r("terminal")}:void 0,createBrowser:z.some(S=>S.id==="browser")?()=>Wt({type:"url",url:Vr.site,title:"Web Page"}):void 0,createDocument:z.some(S=>S.id==="canvas")?()=>Wt({type:"markdown",content:`# Untitled
82
-
83
- Start writing…`,title:"Document"}):void 0,removeDocument:De?()=>void it(()=>g?I.closeRoomCanvasDocument(g,De.id):_.getState().closeCanvasDocument(De.id)):void 0,pinDocument:g&&De?()=>void it(()=>I.updateRoomCanvasDocument(g,De.id,{pinned:!De.pinned})):void 0,documentPinned:(De==null?void 0:De.pinned)??!1}}function Bw({views:e,activeId:t,onActivate:s,onCreateTerminal:r,onStopTerminal:o,onCreateBrowser:a,onCreateDocument:i,onRemoveDocument:c,onPinDocument:d,documentPinned:u}){const m=e.find(f=>f.resource==="browser")??e.find(f=>f.category==="local-browser"),p=e.filter(f=>f.category!=="local-browser"||f===m);return n.jsxs(Rs,{children:[n.jsx(Ts,{asChild:!0,children:n.jsx(F,{variant:"ghost",size:"icon-md","aria-label":"Add view",className:"size-11 shrink-0 lg:size-7",children:n.jsx(kt,{className:"size-3.5"})})}),n.jsxs(Ds,{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(hc,{children:"Views"}),p.map(f=>n.jsxs(Ge,{"aria-current":f.id===t?"true":void 0,"data-view-category":f.category,"aria-label":f.category==="local-browser"?"Browser":void 0,onSelect:()=>s(f.id),children:[n.jsx(Hn,{icon:f.icon}),n.jsx("span",{className:"max-w-64 truncate",children:f.category==="local-browser"?"Browser":f.title}),f.category==="local-browser"&&f.resource==="browser"&&n.jsx("span",{"aria-hidden":"true",className:"text-muted-foreground max-w-40 truncate",children:f.title}),f.id===t&&n.jsx("span",{"aria-hidden":"true",className:"ml-auto",children:"✓"})]},f.id)),r&&n.jsxs(n.Fragment,{children:[n.jsx(os,{}),n.jsxs(Ge,{onSelect:r,children:[n.jsx(mc,{}),"New terminal"]})]}),a&&n.jsx(Ge,{onSelect:a,children:"New page preview"}),i&&n.jsx(Ge,{onSelect:i,children:"New document"}),d&&n.jsxs(n.Fragment,{children:[n.jsx(os,{}),n.jsx(Ge,{onSelect:d,children:u?"Unpin document":"Pin document"})]}),c&&n.jsx(Ge,{onSelect:c,children:"Remove document"}),o&&n.jsxs(n.Fragment,{children:[n.jsx(os,{}),n.jsx(Ge,{onSelect:o,children:"Stop terminal"})]})]})]})}function zw({active:e,hidden:t,here:s,saved:r}){const{setPlacement:o}=Kb(),a=_(x=>x.setActiveRightPanelTab),i=tt(),c=ro(),d=Kl(),u=_(x=>x.setRightPanelOpen),m=oo(),p=wm(s)!==null,f=x=>pc(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=p?t:[];return!e&&g.length===0?null:n.jsxs(Rs,{children:[n.jsx(Ts,{asChild:!0,children:n.jsx(F,{variant:"ghost",size:"icon-md","aria-label":"Add-on tab options",className:"size-11 shrink-0 lg:size-7","data-testid":"mini-app-tab-menu",children:n.jsx(jm,{className:"size-3.5"})})}),n.jsxs(Ds,{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(Ge,{onSelect:()=>{d&&u(!1),c({href:fc(h.extensionId,h.path)})},children:[n.jsx(Sm,{}),"Open full page"]}),p&&n.jsxs(Ge,{onSelect:()=>o(e.id,Cm(f(e),s)),children:[n.jsx(km,{}),"Hide here"]}),n.jsxs(Ge,{onSelect:()=>i.open("extensions",e.extensionId),children:[n.jsx(Nm,{}),"Where it shows…"]})]}),e&&g.length>0&&n.jsx(os,{}),g.length>0&&n.jsxs(n.Fragment,{children:[n.jsx(hc,{className:"text-muted-foreground text-xs font-normal",children:"Show here"}),g.map(x=>n.jsxs(Ge,{onSelect:()=>{o(x.id,Am(f(x),s)),a(x.id)},children:[x.icon?n.jsx(Hn,{icon:x.icon}):n.jsx(kt,{}),x.title]},x.id))]})]})]})}const Uw={canvas:"canvas",browser:"browser"};function Kw(e,t){return t==="attention"?`${e}, something needs you`:e}function Hw({contributionId:e}){const t=Uw[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 Em(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 Sd="right-panel-content";function cs(e){return`right-panel-tab-${e}`}function Ww({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(Gw,{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(F,{variant:"ghost",size:"icon-md","aria-label":"Close panel",className:"size-11 shrink-0 lg:size-7",onClick:()=>a(!1),children:n.jsx(_e,{className:"size-3.5"})})]})]})}function Gw({contributions:e,activeTab:t,onActivate:s,onCloseView:r}){const o=l.useRef(null),a=l.useRef("keyboard"),i=l.useRef(null),c=Im(f=>f.tabMarkers),d=Rm(o,"horizontal"),u=l.useCallback(()=>{const f=o.current;return!f||!t?null:f.querySelector(`#${CSS.escape(cs(t))}`)},[t]),m=l.useCallback(()=>{const f=o.current,h=u();!f||!h||Tm(f,h)},[u]),p=e.map(f=>f.id).join(",");return l.useEffect(()=>{if(m(),typeof ResizeObserver>"u")return;const f=new ResizeObserver(m);for(const h of[o.current,i.current,u()])h&&f.observe(h);return()=>f.disconnect()},[m,u,p]),n.jsx(Nl,{asChild:!0,value:t??"",onValueChange:f=>{s(f,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(Al,{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(f=>{var g,x;const h=f.id===t;return n.jsxs("div",{className:"group/view relative flex shrink-0 items-center py-2 md:py-0",children:[n.jsxs(an,{children:[n.jsx(cn,{asChild:!0,children:n.jsxs(as,{value:f.id,"data-view-category":f.category??f.id,onPointerDown:()=>{a.current="pointer"},onKeyDown:b=>{var y;if(a.current="keyboard",b.key==="Delete"&&r){b.preventDefault();const C=e.findIndex(v=>v.id===f.id),j=e[C+1]??e[C-1],I=(y=b.currentTarget.closest('[data-slot="right-panel-header"]'))==null?void 0:y.querySelector('[aria-label="Add view"]');r(f.id),requestAnimationFrame(()=>{var v;j?(v=document.getElementById(cs(j.id)))==null||v.focus():I==null||I.focus()})}},"aria-label":[Kw(f.title,c[f.id]??null),f.author&&`Posted by ${f.author.displayName}`,f.unread&&"Unread",((g=f.watchers)==null?void 0:g.length)&&`${f.watchers.map(b=>b.displayName).join(", ")} ${f.watchers.length===1?"is":"are"} looking at this.`].filter(Boolean).join(", "),id:cs(f.id),"aria-controls":h?Sd:void 0,className:H("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:f.icon,className:"size-3.5"}),f.author&&n.jsx("span",{title:`Posted by ${f.author.displayName}`,children:n.jsx(vr,{size:"xs",kind:f.author.kind,color:f.author.color??yr(f.author.id),emoji:f.author.emoji,imageUrl:f.author.imageUrl,fallback:Qo(f.author.displayName)})}),n.jsx("span",{className:"max-w-28 truncate",children:f.title}),f.pinned&&n.jsx("span",{"aria-label":"Pinned",children:"·"}),f.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=f.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:[f.watchers.slice(0,3).map(b=>n.jsx(vr,{size:"xs",className:"ring-background size-3.5 text-[8px] ring-1",kind:b.kind,color:b.color??yr(b.id),emoji:b.emoji,imageUrl:b.imageUrl,badge:null,fallback:Qo(b.displayName)},b.id)),f.watchers.length>3&&n.jsxs("span",{className:"text-3xs",children:["+",f.watchers.length-3]})]}),n.jsxs("span",{className:"sr-only",children:[f.watchers.map(b=>b.displayName).join(", ")," ",f.watchers.length===1?"is":"are"," looking at this."]})]}),n.jsx(Hw,{contributionId:f.id})]})}),n.jsx(ln,{side:"bottom",children:f.title})]}),r&&h&&n.jsx(F,{variant:"ghost",size:"icon-sm",tabIndex:-1,"aria-label":`Close ${f.title} view`,className:"relative size-6 after:absolute after:inset-x-0 after:-inset-y-2 md:after:hidden",onClick:()=>r(f.id),children:n.jsx(_e,{className:"size-3"})})]},f.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 Tr="app-shell-right-panel",qw=40,Yw=320,kd=20,Vw=50;function Qw(e){if(e<=0)return kd;const t=Yw/e*100;return Math.min(Math.round(t*10)/10,Vw)}function Xw(){const[e,t]=l.useState(kd);return l.useLayoutEffect(()=>{const s=document.querySelector(`[data-panel-group-id="${Tr}"]`);if(!(s instanceof HTMLElement))return;const r=()=>t(Qw(s.offsetWidth));r();const o=new ResizeObserver(r);return o.observe(s),()=>o.disconnect()},[]),{minPct:e,defaultPct:Math.max(qw,e)}}function Jw(e,t){var h;const s=Dm(e),r=Om(),o=_(g=>g.selectedCwd),a=s==="session",i=gc(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(()=>Zw(s,d,u,a),[s,d,u,a]),[p,f]=l.useState(null);return!c&&p!==m&&f(m),c?{status:"pending",last:p}:{status:"ready",here:m}}function Zw(e,t,s,r){const o={page:e};return t&&(o.roomId=t),r&&(o.agentId=s),o}const ej="cubic-bezier(0, 0, 0.2, 1)",tj="cubic-bezier(0.4, 0, 1, 1)";function za(e,t){return`${e} 300ms ${t?ej:tj}`}const nj=new Set(["pulse","files"]);function sj({pathname:e,isRemoteCommunityRoom:t=!1}){var te;const s=_(M=>M.rightPanelOpen),r=_(M=>M.setRightPanelOpen),o=_(M=>M.activeRightPanelTab),a=_(M=>M.setActiveRightPanelTabView),i=Kl(),c=Ae(),d=Wl(),u=l.useRef(null),[m,p]=l.useState(!1),[f,h]=l.useState(!1);l.useEffect(()=>{const M=requestAnimationFrame(()=>h(!0));return()=>cancelAnimationFrame(M)},[]);const g=ce(),x=_(M=>M.currentAgentId),b=_(M=>M.selectedCwd),y=_(M=>M.explicitAgentPath),C=Os("right-panel"),j=l.useMemo(()=>C.filter(M=>!M.visibleWhen||M.visibleWhen({pathname:e,transport:g,agentId:x,cwd:b,explicitAgentPath:y,isRemoteCommunityRoom:t})),[C,e,g,x,b,y,t]),I=Jw(e,t),v=I.status==="ready"?I.here:I.last,N=Hb(),O=Pe().data!==void 0,P=l.useMemo(()=>new Map(N.map(M=>[M.tab,M])),[N]),{visibleContributions:R,hiddenMiniAppTabs:A}=l.useMemo(()=>{const M=[],z=[];for(const G of j)G.extensionId?v&&Mm(pc(P.get(G.id),G.declaredPlacement),v)?M.push(G):z.push(G):M.push(G);return{visibleContributions:M,hiddenMiniAppTabs:z}},[j,v,P]),w=$w(R,e),k=w.visible,D=`${_(M=>M.sessionId)??""}:${b}`;l.useEffect(()=>{if(I.status!=="pending"&&k.length>0&&!k.some(z=>z.category===o)){const z=k.find(G=>!G.isGlobal);a((z??k[0]).category)}},[k,o,a,I.status]);const T=s,{minPct:L,defaultPct:$}=Xw();l.useEffect(()=>{const M=u.current;M&&(T&&M.isCollapsed()?M.expand($):!T&&M.isExpanded()&&M.collapse())},[T,$]);const B=w.available.find(M=>M.id===o&&k.some(z=>z.category===M.id)),q=w.available.find(M=>M.id==="terminal"),oe=q==null?void 0:q.component,ie=w.terminal!==null||o==="terminal",Y=B==null?void 0:B.component,X=B==null?void 0:B.headerActions,ne=n.jsxs(n.Fragment,{children:[n.jsx(Ww,{contributions:k,activeId:w.activeId,onActivate:w.activate,onCloseView:w.closeView,actions:n.jsxs(n.Fragment,{children:[n.jsx(Bw,{views:w.allViews,activeId:w.activeId,onActivate:w.activate,onCreateBrowser:w.createBrowser,onCreateDocument:w.createDocument,onRemoveDocument:w.removeDocument,onPinDocument:w.pinDocument,documentPinned:w.documentPinned,onCreateTerminal:w.createTerminal,onStopTerminal:o==="terminal"&&((te=w.terminal)!=null&&te.activeId)?()=>{var M;return(M=w.terminal)==null?void 0:M.stop(w.terminal.activeId,"pointer")}:void 0}),X?n.jsx(l.Suspense,{fallback:null,children:n.jsx(X,{})}):null,I.status==="ready"&&O&&n.jsx(zw,{active:B!=null&&B.extensionId?B:null,hidden:A,here:I.here,saved:P})]})}),n.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",...w.activeId&&k.some(M=>M.category===o)?{id:Sd,role:"tabpanel","aria-labelledby":cs(w.activeId)}:{},children:n.jsx(Fa,{tabId:o,children:n.jsx(l.Suspense,{fallback:null,children:n.jsxs(_m,{value:!0,children:[s&&o!=="terminal"&&Y?n.jsx(Y,{}):null,oe&&ie&&n.jsx("div",{hidden:o!=="terminal"||!s||!B,className:"h-full",children:n.jsx(Pm,{value:o==="terminal"&&s&&!!B,children:n.jsx(Fa,{tabId:o,children:n.jsx(oe,{})})})},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(Lm,{open:!0,onOpenChange:M=>!M&&r(!1),children:n.jsxs(Fm,{showCloseButton:!1,style:{top:d.top,bottom:"auto",height:d.height,maxHeight:d.height},className:H("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&&nj.has(o)&&"!bottom-auto !h-auto max-h-dvh overflow-y-auto"),children:[n.jsxs($m,{className:"sr-only",children:[n.jsx(Bm,{children:"Panel"}),n.jsx(zm,{children:"Right panel content."})]}),ne]})}):null;const se=f&&!m;return n.jsxs(n.Fragment,{children:[n.jsx(ib,{"aria-label":"Resize right panel",disabled:!T,onDragging:p,gripStyle:{opacity:T?1:0,pointerEvents:T?"auto":"none",...se&&{transition:za("opacity",T)}}}),n.jsx(xc,{ref:u,id:"right-panel",order:2,defaultSize:T?$:0,minSize:L,collapsible:!0,collapsedSize:0,onCollapse:()=>{f&&r(!1)},onExpand:()=>{s||r(!0)},style:se?{transition:za("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:ne})})]})}const Ua="inbox",rj="open";function oj({blocked:e=!1}={}){const t=Ms()[Ua],s=Qr(),r=t!==void 0,o=t==null?"":String(t).trim();l.useEffect(()=>{!r||!s||(o&&!e&&Um(void 0,o===rj?void 0:{focus:o}),s({search:a=>({...a,[Ua]:void 0}),replace:!0}))},[r,o,e,s]),l.useEffect(()=>{e&&Km()},[e])}function aj(){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 ij(){const e=me();be("capabilities_changed",()=>{e.invalidateQueries({queryKey:bc.all})})}function cj(){const e=ce(),t=me();return Bt({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:bc.all}),t.invalidateQueries({queryKey:["mesh","agents"]})}})}const Ka=new WeakMap;let lj=0;function dj(e){const t=Ka.get(e);if(t!==void 0)return t;const s=`bar-${lj++}`;return Ka.set(e,s),s}function uj(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:dj(r),Header:r}}return null}function mj(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 hj="/";function To(){const e=rn();return l.useMemo(()=>{const t=()=>yc(e),s=o=>{Se.getState().selectTab(o),t()},r=o=>{const{tabs:a}=Se.getState(),i=a[o];i&&s(i.id)};return{activate:s,activateIndex:r,activateLast:()=>r(Se.getState().tabs.length-1),activateRelative:o=>{const{tabs:a,activeTabId:i}=Se.getState();if(a.length<2)return;const c=a.findIndex(m=>m.id===i),u=(((c===-1?0:c)+o)%a.length+a.length)%a.length;s(a[u].id)},close:o=>{Se.getState().closeTab(o),t()},closeActive:()=>{const{tabs:o,activeTabId:a}=Se.getState();if(!a)return!1;const i=o.length;Se.getState().closeTab(a);const c=Se.getState().tabs.length<i;if(c)try{t()}catch(d){console.error("[dorkos:tabs] could not follow a closed tab",d)}return c},create:()=>Hm(e,hj),togglePin:o=>{const a=Se.getState().tabs.find(i=>i.id===o);a&&Se.getState().setTabPinned(o,!a.pinned)},duplicate:o=>{Se.getState().duplicateTab(o),t()},closeOthers:o=>{Se.getState().closeOtherTabs(o),t()},reorder:(o,a)=>Se.getState().moveTab(o,a)}},[e])}const fj={start:["Space"],cancel:["Escape"],end:["Space","Enter","Tab"]},pj=4,gj={draggable:"Press Space to move this tab. Arrows move it, Space drops it, Escape cancels."};function xj(e){return t=>{const s=e(String(t.active.id));return vc({...t,droppableContainers:t.droppableContainers.filter(r=>e(String(r.id))===s)})}}class bj extends Map{getEnabled(){return[...this.values()].filter(t=>!t.disabled)}toArray(){return[...this.values()]}}function yj(e){return(t,s)=>{const{context:r}=s;if(!r.active)return wr(t,s);const o=e(String(r.active.id)),a=new bj;for(const i of r.droppableContainers.toArray())e(String(i.id))===o&&a.set(i.id,i);return wr(t,{...s,context:{...r,droppableContainers:a}})}}function vj(e){return e.length===0?null:{left:Math.min(...e.map(t=>t.left)),right:Math.max(...e.map(t=>t.right))}}function wj(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 jj(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 Sj(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 kj=500;function Cj(e){const t=_s(new Date(e).toISOString());return`Last active ${t==="Just now"?"just now":t}`}function Nj({identity:e,className:t}){return n.jsxs("div",{className:H("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(ao,{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(io,{identity:e}),n.jsx("span",{children:e.statusSentence})]}),e.lastActiveAt!==void 0&&!Number.isNaN(e.lastActiveAt)&&n.jsx("p",{className:"text-muted-foreground",children:Cj(e.lastActiveAt)})]})}function Aj({identity:e,children:t}){return n.jsxs(Pl,{openDelay:kj,closeDelay:0,children:[n.jsx(Ll,{asChild:!0,children:t}),n.jsx(Fl,{side:"bottom",align:"start",sideOffset:6,className:"w-64 p-3",children:n.jsx(Nj,{identity:e})})]})}const Cd="app-tab-panel";function Ej({identity:e,isActive:t,canClose:s,collapseAgent:r=!1,pinned:o=!1,tabProps:a,onClose:i}){const c=Gm(e,{collapseAgent:r}),d=l.useRef(null);l.useEffect(()=>{var m,p;t&&((p=(m=d.current)==null?void 0:m.scrollIntoView)==null||p.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(Aj,{identity:e,children:n.jsxs("button",{type:"button",role:"tab","aria-selected":t,"aria-controls":t?Cd:void 0,"aria-label":qm(e,{collapseAgent:r}),...a,className:H("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-background text-foreground shadow-soft":"text-muted-foreground hover:bg-background/60 hover:text-foreground"),children:[n.jsx(ao,{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(io,{identity:e})]})}),u&&i&&n.jsx("button",{type:"button",tabIndex:-1,onClick:()=>i("pointer"),"aria-label":`Close ${e.primary}`,className:H("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(_e,{className:"size-3"})})]})}function Ij({tab:e,isActive:t,canClose:s,pinned:r,tabProps:o,onClose:a}){const i=co(e.href),c=Wm(i.agentKey);return n.jsx(Ej,{identity:i,isActive:t,canClose:s,collapseAgent:c,pinned:r??e.pinned??!1,tabProps:o,onClose:d=>a(e.id,d)})}function Rj({tabId:e,pinned:t,hasOthersToClose:s,canClose:r,actions:o,onClosed:a,children:i}){return n.jsxs(Ym,{children:[n.jsx(Vm,{asChild:!0,children:i}),n.jsxs(Qm,{className:"w-44",onCloseAutoFocus:a?c=>{c.preventDefault(),a()}:void 0,children:[n.jsxs(pn,{onSelect:()=>o.togglePin(e),children:[t?n.jsx(Xm,{className:"mr-2 size-4"}):n.jsx(Jm,{className:"mr-2 size-4"}),t?"Unpin":"Pin"]}),n.jsxs(pn,{onSelect:()=>o.duplicate(e),children:[n.jsx(Ty,{className:"mr-2 size-4"}),"Duplicate"]}),n.jsxs(pn,{onSelect:()=>o.copyLink(e),children:[n.jsx(Zm,{className:"mr-2 size-4"}),"Copy link"]}),n.jsx(eh,{}),n.jsxs(pn,{disabled:!s,onSelect:()=>o.closeOthers(e),children:[n.jsx(th,{className:"mr-2 size-4"}),"Close others"]}),n.jsxs(pn,{disabled:!r,onSelect:()=>o.close(e),children:[n.jsx(_e,{className:"mr-2 size-4"}),"Close"]})]})]})}const Sn="data-app-tab-id";function Tj({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:p,setActivatorNodeRef:f,attributes:h,listeners:g,transform:x,transition:b,isDragging:y}=nh({id:e.id,disabled:!a}),C=g==null?void 0:g.onPointerDown,j=g==null?void 0:g.onKeyDown,I={transform:x?`translate3d(${Math.round(x.x)}px, 0, 0)`:void 0,transition:b??void 0},{ref:v,onKeyDown:N}=r,O=l.useCallback(w=>{v(w),f(w)},[v,f]),P=l.useCallback(w=>{if(c&&(w.key==="ContextMenu"||w.shiftKey&&w.key==="F10")){w.preventDefault();const k=w.currentTarget,E=k.getBoundingClientRect();k.dispatchEvent(new MouseEvent("contextmenu",{bubbles:!0,cancelable:!0,clientX:E.left,clientY:E.bottom}));return}j==null||j(w),!(w.defaultPrevented||i)&&N(w)},[c,j,i,N]),R=l.useMemo(()=>({...r,ref:O,onKeyDown:P,...a?{"aria-describedby":h["aria-describedby"]}:{}}),[r,O,P,a,h]),A=n.jsx("div",{ref:p,role:"presentation",[Sn]:e.id,style:I,onPointerDown:C,className:H("flex shrink-0",y&&"bg-background shadow-soft relative z-10 rounded-md"),children:n.jsx(Ij,{tab:e,isActive:t,canClose:s,tabProps:R,onClose:o,pinned:m})});return c?n.jsx(Rj,{tabId:e.id,pinned:m,hasOthersToClose:d,canClose:s,actions:c,onClosed:u,children:A}):A}function Dj({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=wc(null),p=e.length>1,[f,h]=l.useState(!1),g=l.useMemo(()=>e.map(A=>A.id),[e]),x=Jt(e),{collisionDetection:b,coordinateGetter:y,modifiers:C,announcements:j}=l.useMemo(()=>{const A=k=>x.read().findIndex(E=>E.id===k),w=k=>{var E;return((E=x.read().find(D=>D.id===k))==null?void 0:E.pinned)??!1};return{collisionDetection:xj(w),coordinateGetter:yj(w),modifiers:[wj(m.read)],announcements:Sj({nameOf:k=>{var E,D,T;return((T=(D=(E=Array.from(document.querySelectorAll(`[${Sn}]`)).find(L=>L.getAttribute(Sn)===k))==null?void 0:E.querySelector('[role="tab"]'))==null?void 0:D.textContent)==null?void 0:T.trim())||"Tab"},indexOf:A,count:()=>x.read().length})}},[x,m]),I=jc(ps(Cc,{activationConstraint:{distance:pj}}),ps(kc,{coordinateGetter:y,keyboardCodes:fj})),v=({active:A})=>{var E,D;h(!0);const w=((E=e.find(T=>T.id===A.id))==null?void 0:E.pinned)??!1,k=Array.from(((D=u.current)==null?void 0:D.querySelectorAll(`[${Sn}]`))??[]).filter(T=>{var $;const L=T.getAttribute(Sn);return((($=e.find(B=>B.id===L))==null?void 0:$.pinned)??!1)===w}).map(T=>T.getBoundingClientRect());m.write(vj(k))},N=()=>{h(!1),m.write(null)},O=({active:A,over:w})=>{N();const k=jj(g,A.id,w==null?void 0:w.id);k&&i&&i(...k)},P=()=>{setTimeout(()=>{var A,w;(w=(A=u.current)==null?void 0:A.querySelector('[role="tab"][aria-selected="true"]'))==null||w.focus()},0)},{getTabProps:R}=Tb({orderedIds:e.map(A=>A.id),activeId:t,onActivate:s,onClose:p?r:void 0,getFallbackFocus:()=>d.current});return n.jsxs("div",{className:H("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(Sc,{sensors:I,collisionDetection:b,modifiers:C,accessibility:{announcements:j,screenReaderInstructions:gj},onDragStart:v,onDragEnd:O,onDragCancel:N,children:n.jsx(sh,{items:g,strategy:rh,children:n.jsx("div",{ref:u,role:"tablist","aria-label":"Open tabs",className:"flex items-stretch gap-1",children:e.map(A=>n.jsx(Tj,{tab:A,isActive:A.id===t,canClose:p,tabProps:R(A.id),onClose:r,sortable:i!==void 0,dragActive:f,menu:a,onMenuClosed:P,hasOthersToClose:e.some(w=>w.id!==A.id&&!w.pinned)},A.id))})})})}),n.jsx("button",{ref:d,type:"button",onClick:o,"aria-label":"New tab",title:`New tab (${en(Dn.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(kt,{className:"size-3.5"})})]})}function Oj({className:e}){const t=oh(),s=Se(f=>f.activeTabId),{activate:r,close:o,create:a,togglePin:i,duplicate:c,closeOthers:d,reorder:u}=To(),{copy:m}=$n({toastOnSettle:!0}),p=l.useMemo(()=>({togglePin:i,duplicate:c,closeOthers:d,close:o,copyLink:f=>{const h=Se.getState().tabs.find(g=>g.id===f);h&&m(mj(h.href))}}),[i,c,d,o,m]);return n.jsx(Dj,{tabs:t,activeId:s,onActivate:r,onClose:o,onCreate:a,menu:p,onReorder:u,className:e})}function vs(){var s;const{tabs:e,activeTabId:t}=Se.getState();return((s=e.find(r=>r.id===t))==null?void 0:s.cursor)??null}function Do(e,t){const s=vs();s!==null&&(Se.getState().goToHistoryIndex(t),vs()!==s&&yc(e))}function Nd(e){const t=vs();t!==null&&Do(e,t-1)}function Ad(e){const t=vs();t!==null&&Do(e,t+1)}function Mj(e,t){Do(e,t)}function Ha(e,t){const s=en(e);return Pt?s:`${s} or ${en(`alt+${t}`)}`}const Zs="size-7";function _j({href:e,isCurrent:t,onSelect:s}){const r=co(e);return n.jsxs(Ge,{disabled:t,"aria-current":t?"page":void 0,onSelect:s,"aria-label":r.accessibleName,className:"data-[disabled]:opacity-100",children:[n.jsx(ao,{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(io,{identity:r}),n.jsx(zt,{className:H("size-3.5 shrink-0",!t&&"invisible")})]})}function er({label:e,keys:t,children:s}){return n.jsxs(an,{children:[n.jsx(cn,{asChild:!0,children:s}),n.jsx(ln,{side:"bottom",className:"text-xs",children:t?`${e} (${t})`:e})]})}function Pj(){const e=rn(),{entries:t,cursor:s,canGoBack:r,canGoForward:o}=ah();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(er,{label:"Back",keys:Ha(Dn.HISTORY_BACK.key,"←"),children:n.jsx(F,{variant:"ghost",size:"icon-md",className:Zs,"aria-label":"Back",disabled:!r,onClick:()=>Nd(e),children:n.jsx(Nc,{})})}),n.jsx(er,{label:"Forward",keys:Ha(Dn.HISTORY_FORWARD.key,"→"),children:n.jsx(F,{variant:"ghost",size:"icon-md",className:Zs,"aria-label":"Forward",disabled:!o,onClick:()=>Ad(e),children:n.jsx(Ac,{})})}),n.jsxs(Rs,{children:[n.jsx(er,{label:"History",children:n.jsx(Ts,{asChild:!0,children:n.jsx(F,{variant:"ghost",size:"icon-md",className:Zs,"aria-label":"History",children:n.jsx(Db,{})})})}),n.jsx(Ds,{align:"start",className:"max-w-72 min-w-48",children:a.map(({href:i,index:c})=>n.jsx(_j,{href:i,isCurrent:c===s,onSelect:()=>Mj(e,c)},c))})]})]})}function Lj(){const e=rn(),t=Ee({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,Se.getState().syncLocation(t,{traversal:o,replace:a})},[t])}const Wa=9;function Fj(){const e=To();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));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>Wa||(s.preventDefault(),r===Wa?e.activateLast():e.activateIndex(r-1))};return document.addEventListener("keydown",t),()=>document.removeEventListener("keydown",t)},[e])}const Ga=3,$j=4;function Bj(e){return e instanceof Element?e.closest("input, textarea, select")?!0:e.closest('[contenteditable]:not([contenteditable="false"])')!==null:!1}function qa(e){return e instanceof Element&&e.closest('[role="dialog"], [role="alertdialog"], [role="menu"]')!==null}function zj(e){if(e.shiftKey)return null;if((Pt?e.metaKey&&!e.ctrlKey:e.ctrlKey&&!e.metaKey)&&!e.altKey)return e.code==="BracketLeft"?"back":e.code==="BracketRight"?"forward":null;if(!Pt&&e.altKey&&!e.ctrlKey&&!e.metaKey){if(Bj(e.target))return null;if(e.key==="ArrowLeft")return"back";if(e.key==="ArrowRight")return"forward"}return null}function Uj(){const e=rn();l.useEffect(()=>{if(!Ue())return;const t=i=>i==="back"?Nd(e):Ad(e),s=i=>{if(i.defaultPrevented||i.isComposing||qa(i.target))return;const c=zj(i);c&&(i.preventDefault(),t(c))},r=i=>i.button===Ga||i.button===$j,o=i=>{r(i)&&i.preventDefault()},a=i=>{r(i)&&(i.preventDefault(),!qa(i.target)&&t(i.button===Ga?"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 Kj(e){return e.displayName||e.name}function Oo(e,t){const s=On(r=>r.setRouteBadge);l.useEffect(()=>{s(e,t)},[e,t,s])}const Hj=5*6e4;function Wj(e){return e.status==="active"&&e.enabled}function Gj(e){const{enabled:t}=ch(),{data:s}=Ec(t),{data:r}=lh(t),o=On(c=>c.setSchedulesWaitingCount),a=l.useMemo(()=>{const c=aw(t?r??[]:[]),d=new Map((s??[]).filter(Wj).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?[Kj(m)]:[]})}},[t,r,s,e]),i=l.useMemo(()=>dh(a),[a]);Oo("/tasks",i),l.useEffect(()=>{o(e)},[e,o])}function qj(){const{count:e,more:t}=uh(),s=l.useMemo(()=>mh(e,t),[e,t]);Oo("/activity",s)}function Yj(){const{data:e,isSuccess:t}=ax("pending"),{data:s}=ix("pending",{enabled:t,refetchInterval:Hj}),r=((e==null?void 0:e.length)??0)+((s==null?void 0:s.length)??0),o=l.useMemo(()=>hh(r),[r]);Oo("/connections",o)}function Vj(){const{items:e,schedules:t}=ih(),s=On(r=>r.setNeedsYouCount);l.useEffect(()=>{s(e.length)},[e.length,s]),Gj(t.length),qj(),Yj()}function Ot(e){return"problem"in e?{problem:e.problem}:{message:e.message}}const Mt={message:"Couldn’t reach your DorkOS account. Try again."},Qj={message:"Finish signing in in your browser, then try again."},Xj={message:"Your browser blocked the window. Allow pop-ups, then try again."},tr={message:"Couldn’t connect this DorkOS to the space. Try again."},Jj={message:"The approval ran out. Connect again."};function Mo(e,t,s){var R,A;const r=ce(),o=me(),a=Fn(e!==null),{signsInWithAccount:i,linkFor:c}=Ic(e!==null),[d,u]=l.useState({opened:!1,busy:!1,notice:null}),[m,p]=l.useState(null),f=l.useRef(null),h=ke({queryKey:st.list(),queryFn:()=>r.listHostedCommunities(),enabled:e!==null&&m===null,refetchInterval:w=>{const k=w.state.data,E=(k==null?void 0:k.available)===!0?k.communities.find(D=>D.communityId===(e==null?void 0:e.communityId)):void 0;return(E==null?void 0:E.state)==="provisioning"?2e3:!1}}),g=((R=h.data)==null?void 0:R.available)===!0?h.data.communities.find(w=>w.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 w=Jr();if(w===null){u(k=>({...k,notice:Xj}));return}u(k=>({...k,busy:!0,notice:null})),r.getHostedCommunityClaimLink(e.communityId).then(k=>{if(!k.ok){w.close(),u(D=>({...D,busy:!1,notice:Ot(k)}));return}const E=w.go(c(k.claimUrl));u(D=>({opened:D.opened||E,busy:!1,notice:null}))}).catch(()=>{w.close(),u(k=>({...k,busy:!1,notice:Mt}))})},[e,d.busy,r,c]),y=l.useCallback(async()=>{if(e){if(!a||!It(a)){p({ref:null,approvalUrl:null,busy:!1,notice:tr});return}p({ref:null,approvalUrl:null,busy:!0,notice:null});try{const w=await r.startCommunityConnection({url:e.communityUrl,installName:t});p({ref:w.connection.ref,approvalUrl:w.approvalUrl,busy:!1,notice:null}),await o.invalidateQueries({queryKey:yt.connections(a)})}catch{p({ref:null,approvalUrl:null,busy:!1,notice:tr})}}},[e,a,r,t,o]),C=l.useCallback(()=>{!e||d.busy||(u(w=>({...w,busy:!0,notice:null})),r.listHostedCommunities().then(w=>{o.setQueryData(st.list(),w);const k=w.available===!0?w.communities.find(E=>E.communityId===e.communityId):void 0;if(!k||k.state==="pending_owner"||k.state==="provisioning"){u(E=>({...E,busy:!1,notice:Qj}));return}u(E=>({...E,busy:!1})),y()}).catch(()=>u(w=>({...w,busy:!1,notice:Mt}))))},[e,d.busy,r,o,y]),j=(m==null?void 0:m.ref)??null,I=ke({queryKey:a&&j?yt.approval(a,j):["cloud","no-approval"],queryFn:()=>Zi(a,()=>r.pollCommunityConnection(j)),enabled:a!==null&&j!==null,retry:!1,refetchInterval:w=>!w.state.error&&(!w.state.data||w.state.data.status==="pending")?2e3:!1}),v=j!==null?((A=I.data)==null?void 0:A.status)??"pending":"pending",N=v==="connected"?j:null;l.useEffect(()=>{N===null||f.current===N||(f.current=N,a&&o.invalidateQueries({queryKey:yt.connections(a)}),o.invalidateQueries({queryKey:st.all}),s(N))},[N,a,o,s]);const O=v==="expired"||v==="cancelled";return{state:N!==null?{kind:"done",ref:N}:m!==null?{kind:"connecting",approvalUrl:m.approvalUrl,busy:m.busy,notice:m.notice??(O?Jj:I.error?tr:null)}:x?{kind:"preparing"}:{kind:"claim",...d,withAccount:e!==null&&i(e.communityUrl)},openClaim:b,confirmClaimed:C,openApproval:()=>{m!=null&&m.approvalUrl&&jt(c(m.approvalUrl))},retryConnect:()=>void y()}}const bt=fh({offset:!0}).describe("An ISO-8601 instant with an explicit UTC offset."),Ze=ve().min(1).describe("An opaque server-issued identifier. Clients never parse or enumerate it.");ve().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 Zj=ve().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";un(["money","credit"]).describe("What an amount counts: money paid, refunded, offered or capped, or credits held, spent or priced.");const Ed=/^-?(0|[1-9][0-9]*)$/,eS=/^[1-9][0-9]*$/;ve().regex(Ed,"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"});ve().regex(eS,"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"});ve().regex(Ed,"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:ve().regex(/^[A-Z]{3}$/,"must be an ISO 4217 currency code").describe("An ISO 4217 code. Rendered, never enumerated."),microPerCredit:Zj.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 tS=ve().min(1).describe("A credential returned exactly once. Store it as a credential reference; never log it or persist it as configuration."),Id=ve().min(1).describe("An opaque pagination cursor, passed back verbatim from a previous page.");de({cursor:Id.optional(),limit:fe().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 Rd(e,t){return de({items:dn(e),nextCursor:Id.nullable().describe("The cursor for the next page, or null when this is the last page.")}).describe(t)}const nS=Rc({protocol:/^https$/}).regex(/^https:\/\//,"must be an https: link").describe("An absolute https: link. Any other scheme is refused."),Vn=Rc({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."),Td="x-dorkos-one-time-credential",sS="unrecognised";function ws(e){return ph([e,ve().transform(()=>sS).describe("A value this release does not know. It reads as unrecognised.")])}const hn=ve().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."),Dd=ve().trim().min(1).max(80).describe("The community`s display name. Trimmed, 1 to 80 characters."),Od=ve().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 rS(e){return Vn.meta({description:e,[Td]:!0})}const oS=un(["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."),aS=un(["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:ve().min(1).max(120).describe("A short summary, safe to show a person."),detail:ve().max(2e3).describe("The explanation, safe to show a person."),actionUrl:nS.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:ve().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."),cS=de({allowed:Tt().describe("The owner may choose this community as one to keep open."),wouldHold:dn(Ze).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."),Po=de({communityId:Ze.describe("The community`s permanent identifier on its Community server. Never changes, even across a rename."),orgId:Ze.describe("The organization whose account this community belongs to."),name:ve().min(1).max(80).describe("The community`s display name."),shortName:hn.nullable().describe("The community`s current short name, or null when it has none."),communityUrl:Vn.describe("The community`s canonical link on its Community server, built on its permanent identifier. A runtime value; pair a DorkOS installation with this."),state:ws(oS).describe("Where the community is in its lifecycle. A state this release does not know reads as unrecognised."),hold:de({reason:ws(aS).describe("Why the community is on hold. A reason this release does not know reads as unrecognised."),since:bt,deletionNoticeAt:bt.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:bt.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:Tt().describe("True when the owner chose this community to stay open while the account holds more communities than its allowance covers."),moveId:Ze.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:fe().int().positive().nullable().describe("The most people who may be active members at once. Null means no limit."),maxStorageBytes:fe().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:fe().int().nonnegative(),storageBytes:fe().int().nonnegative().describe("The bytes that count against the storage limit. Owner exports never count."),measuredAt:bt}).nullable().describe("The community`s last measured usage, or null before the first measurement."),actions:de({claimLink:Tt().describe("The service will issue a fresh owner-claim link for this community."),keep:cS,restore:Tt().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:bt}).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.");Rd(Po,"A page of the communities the caller has hosted.");de({name:hn}).describe("The short name to check.");const lS=un(["taken","reserved"]).describe("Why a short name cannot be used: another community has it, or the host reserves it.");de({name:hn,available:Tt(),reason:lS.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:Od,name:Dd,shortName:hn.optional().describe("The short name to give the community. Omitted means none."),orgId:Ze.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:Ze,claimUrl:rS("The owner-claim link. A single-use credential: open it in the person`s own browser and never log it."),expiresAt:bt.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:Po,claim:dS.nullable().describe("The owner-claim link, or null when this answer repeats an earlier request or the community is still provisioning."),replayed:Tt().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:dn(Ze).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:Po,heldCommunityIds:dn(Ze).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 uS=un(["awaiting_upload","importing","ready","failed","cancelled","claimed"]).describe("Where a move is: waiting for the export, importing it, ready to claim, or finished."),mS=un(["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."),hS=de({channels:fe().int().nonnegative(),entries:fe().int().nonnegative().describe("Messages and replies."),attachments:fe().int().nonnegative(),historicalMembers:fe().int().nonnegative().describe("People whose messages move. They join again by invitation."),historicalAgents:fe().int().nonnegative().describe("Agents whose messages move. Their owners pair them again."),attachmentBytes:fe().int().nonnegative(),countedBytes:fe().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."),Md=de({moveId:Ze,communityId:Ze.describe("The new community the export fills. It no longer exists once a move has failed or been cancelled."),communityUrl:Vn.describe("The new community`s canonical link. A runtime value."),name:ve().min(1).max(80).describe("The name the new community was given."),state:ws(uS).describe("Where the move is. A state this release does not know reads as unrecognised."),failureCode:ws(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:hS.nullable().describe("What the export holds, once it has been read. Null before then."),pollAfterMs:fe().int().nonnegative().nullable().describe("How long to wait before reading the move again. Null once it has finished."),updatedAt:bt}).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.");Rd(Md,"A page of the caller`s moves: every unfinished one, and those that finished within the last 7 days, newest first.");de({idempotencyKey:Od,name:Dd,shortName:hn.optional().describe("The short name to give the new community. Omitted means none."),orgId:Ze.optional().describe("The organization whose account the community belongs to. Omitted means the caller`s personal one."),archiveBytes:fe().int().positive().describe("The size of the export file, in bytes."),archiveSha256:ve().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 fS=de({url:Vn.describe("Where to send the export. A runtime value."),token:tS.meta({description:"The upload bearer credential. Returned once; never log it.",[Td]:!0}),expiresAt:bt.describe("When the upload window closes."),maxBytes:fe().int().positive().describe("The largest file the upload accepts."),parts:de({partBytes:fe().int().positive().describe("The largest part the upload accepts."),maxBytes:fe().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."),_d=ve().regex(/^[a-f0-9]{64}$/,"must be a lower-case hex SHA-256 digest"),Lo=1e4,pS=de({partNumber:fe().int().positive().max(Lo).describe("The number of the part, counting up from one."),byteSize:fe().int().positive().describe("The size of the part, in bytes."),sha256:_d.describe("The SHA-256 of the part, as lower-case hex.")}).describe("One part the Community server has received.");de({parts:dn(pS).max(Lo).describe("The parts received, in part order."),maxPartBytes:fe().int().positive().describe("The largest part the upload accepts."),maxArchiveBytes:fe().int().positive().describe("The largest file a parted upload accepts.")}).describe("The parts of a parted upload received so far.");de({parts:fe().int().positive().max(Lo).describe("How many parts make up the file."),archiveBytes:fe().int().positive().describe("The size of the whole file, in bytes."),archiveSha256:_d.describe("The SHA-256 of the whole file, as lower-case hex.")}).describe("Put the uploaded parts together into the declared file.");de({move:Md,upload:fS.nullable().describe("Where to send the export, or null when this answer repeats an earlier request."),replayed:Tt().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 gS=Vn.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."),xS=de({origin:gS}).describe("A Community server whose single sign-on is this account.");de({servers:dn(xS).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 Pd(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 yS(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 nr(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 Pn(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 Ld(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 Fd="Lower-case letters, numbers and single hyphens. 3 to 32 characters, starting with a letter.";function Qn(e){const t=e.trim().toLowerCase();return t===""?{value:t,valid:!0}:{value:t,valid:hn.safeParse(t).success}}const vS=80,$d="That web address is taken.",Bd="That web address can’t be used.";function zd(e){const t=ce(),{value:s,valid:r}=Qn(e),[o,a]=l.useState(s);l.useEffect(()=>{const d=setTimeout(()=>a(s),400);return()=>clearTimeout(d)},[s]);const i=ke({queryKey:st.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 wS(){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 jS(){const e=ce(),t=me(),s=wS(),[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:st.list()}),{community:m.community}):("problem"in m&&m.problem.code==="community_name_taken"?i({field:$d,notice:null}):"problem"in m&&m.problem.code==="community_name_reserved"?i({field:Bd,notice:null}):i({field:null,notice:Ot(m)}),null)}catch{return i({field:null,notice:Mt}),null}finally{o(!1)}}return{submitting:r,failure:a,clearFieldFailure:()=>i(d=>({...d,field:null})),submit:c}}function SS(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 kS(e){return e.state==="awaiting_upload"||e.state==="importing"||e.state==="ready"}function CS(e){var I;const t=ce(),s=me(),[r,o]=l.useState(e),[a,i]=l.useState(null),[c,d]=l.useState({field:null,notice:null}),[u,m]=l.useState(!1),p=l.useRef(null),f=l.useRef(null),h=ke({queryKey:st.move(r??""),queryFn:()=>t.getHostedCommunityMove(r),enabled:r!==null,refetchInterval:v=>{var O;const N=v.state.data;return(N==null?void 0:N.available)!==!0?!1:((O=N.move.upload)==null?void 0:O.state)==="sending"?1e3:N.move.pollAfterMs===null?!1:Math.max(1e3,N.move.pollAfterMs)}}),g=((I=h.data)==null?void 0:I.available)===!0?h.data.move:null,x=g?SS(g):null,b=l.useCallback(v=>{s.setQueryData(st.move(v.moveId),{available:!0,move:v})},[s]);async function y(v){var A;const N={name:v.name.trim(),...v.shortName?{shortName:v.shortName}:{},file:[v.file.name,v.file.size,v.file.lastModified]},O=JSON.stringify(N);((A=f.current)==null?void 0:A.body)!==O&&(f.current={body:O,key:crypto.randomUUID()});const P=f.current.key,R=new AbortController;p.current=R,d({field:null,notice:null}),i({loaded:0,total:v.file.size});try{const w=await t.checkHostedCommunityMoveRoom(v.file.size,R.signal);if(R.signal.aborted)return;const k=w.ok?await t.startHostedCommunityMove(v.file,{idempotencyKey:P,name:N.name,...v.shortName?{shortName:v.shortName}:{}},E=>i(E),R.signal):w;(k.ok||k.mayExist!==!0)&&(f.current=null),k.ok?(b(k.move),o(k.move.moveId),s.invalidateQueries({queryKey:st.list()})):"problem"in k&&k.problem.code==="community_name_taken"?d({field:$d,notice:null}):"problem"in k&&k.problem.code==="community_name_reserved"?d({field:Bd,notice:null}):d({field:null,notice:Ot(k)})}catch{R.signal.aborted?f.current=null:d({field:null,notice:Mt})}finally{p.current=null,i(null)}}async function C(){if(p.current){p.current.abort();return}if(r){m(!0);try{const v=await t.cancelHostedCommunityMove(r);v.ok?b(v.move):d({field:null,notice:Ot(v)}),s.invalidateQueries({queryKey:st.list()})}catch{d({field:null,notice:Mt})}finally{m(!1)}}}async function j(){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:Ot(v)})}catch{d({field:null,notice:Mt})}finally{m(!1)}}}return{step:x,sending:a,failure:c,clearFieldFailure:()=>d(v=>({...v,field:null})),busy:u,start:y,cancel:C,sendAgain:j,startOver:()=>{o(null),d({field:null,notice:null})}}}function NS(){var a,i,c;const e=ic(),t=bx(),s=jl(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(kS))==null?void 0:c.moveId)??null}}const AS={message:"Your spaces changed. Check the list again."};function ES(){const e=ce(),t=me(),[s,r]=l.useState(null),[o,a]=l.useState(null),[i,c]=l.useState({});function d(m,p){c(f=>{const h={...f};return p?h[m]=p:delete h[m],h})}async function u(m,p){a(m),d(m,null);try{d(m,await p())}catch{d(m,Mt)}finally{a(null),await t.invalidateQueries({queryKey:st.list()})}}return{confirmingKeep:s,busyId:o,notices:i,askKeep:r,cancelKeep:()=>r(null),keep:m=>u(m.communityId,async()=>{r(null);const p=await e.keepHostedCommunity(m.communityId,m.actions.keep.wouldHold);return p.ok?null:"problem"in p&&p.problem.code==="conflict"?AS:Ot(p)}),restore:m=>u(m.communityId,async()=>{const p=await e.restoreHostedCommunity(m.communityId);return p.ok?null:Ot(p)})}}function Fo({open:e,onOpenChange:t,step:s,locked:r}){return n.jsx(pt,{open:e,onOpenChange:o=>r&&!o?void 0:t(o),children:n.jsxs(gt,{className:"!min-h-0 sm:max-w-lg",children:[n.jsxs(ut,{children:[n.jsx(Xe,{children:s.title}),s.description!==void 0&&n.jsx(mt,{children:s.description})]}),s.body!==void 0&&n.jsx(wt,{className:"space-y-4 py-2",children:s.body}),n.jsx(Xt,{className:"gap-2 sm:gap-2",children:s.actions})]})})}function $t({notice:e}){if("message"in e)return n.jsx("p",{role:"alert",className:"text-destructive text-sm",children:e.message});const{title:t,detail:s,actionUrl:r,actionLabel:o}=e.problem;return n.jsxs("div",{role:"alert",className:"border-status-warning-border bg-status-warning-bg text-status-warning-fg space-y-2 rounded-md border p-3 text-sm",children:[n.jsx("p",{className:"font-medium break-words",children:t}),s&&n.jsx("p",{className:"break-words",children:s}),r&&n.jsxs(F,{type:"button",size:"sm",variant:"outline",onClick:()=>jt(r),children:[o??"Open your account",n.jsx(Zt,{className:"size-3.5","aria-hidden":!0})]})]})}function $o(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(Ne,{className:"size-4"})," Setting up…"]}),actions:n.jsx(F,{variant:"outline",onClick:e.onClose,children:"Close"})};case"claim":return{title:`Make ${s} yours`,description:t.withAccount?"Sign in with your DorkOS account in your browser, then come back.":"Sign in or create an account in your browser, then come back.",body:t.notice?n.jsx($t,{notice:t.notice}):void 0,actions:n.jsxs(n.Fragment,{children:[n.jsxs(F,{variant:t.opened?"outline":"default",disabled:t.busy,onClick:e.onOpenClaim,children:[t.opened?"Open it again":"Open in your browser",n.jsx(Zt,{className:"size-3.5","aria-hidden":!0})]}),n.jsx(F,{variant:t.opened?"default":"outline",disabled:t.busy,onClick:e.onConfirmClaimed,children:t.busy?"Checking…":"I’ve finished"})]})};case"connecting":return{title:`Connect this DorkOS to ${s}`,description:t.approvalUrl?`Approve this DorkOS on ${s}. This page then moves on.`:"Getting the approval page ready…",body:n.jsxs(n.Fragment,{children:[t.approvalUrl&&!t.notice&&n.jsxs("p",{role:"status",className:"text-muted-foreground flex items-center gap-2 text-sm",children:[n.jsx(Ne,{className:"size-4"})," Waiting for your approval"]}),t.notice&&n.jsx($t,{notice:t.notice})]}),actions:t.notice?n.jsx(F,{disabled:t.busy,onClick:e.onRetryConnect,children:"Connect again"}):n.jsxs(F,{disabled:t.busy||!t.approvalUrl,onClick:e.onOpenApproval,children:["Open approval page",n.jsx(Zt,{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(Ns,{className:"text-status-success-fg size-4","aria-hidden":!0}),"It’s selected in your spaces."]}),actions:n.jsx(F,{onClick:e.onClose,children:"Done"})}}}function IS(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=`${Pn(t.storageBytes)}${r!==null?` of ${Pn(r)}`:""} of files`;return`${o} · ${a}`}function RS({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=IS(e),u=e.actions.keep.wouldHold.map(p=>t.get(p)??"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(Rn,{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:yS(e.hold.reason)}),n.jsxs("p",{className:"text-muted-foreground",children:["On hold since ",nr(e.hold.since),"."]}),e.hold.deletionNoticeAt&&n.jsxs("p",{className:"text-destructive",children:["DorkOS may delete it after ",nr(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 ",nr(e.deletionAt),"."]}),e.notice&&n.jsxs("div",{className:"bg-muted/50 space-y-1 rounded-md p-2 text-sm",children:[n.jsx("p",{className:"font-medium break-words",children:e.notice.title}),e.notice.detail&&n.jsx("p",{className:"break-words",children:e.notice.detail}),e.notice.actionUrl&&n.jsxs(F,{size:"sm",variant:"outline",onClick:()=>jt(e.notice.actionUrl),children:[e.notice.actionLabel??"Learn more",n.jsx(Zt,{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(F,{size:"sm",variant:"outline",onClick:s.cancelKeep,children:"Cancel"}),n.jsx(F,{size:"sm",disabled:a,onClick:()=>void s.keep(e),children:"Keep it open"})]})]}),c&&n.jsx($t,{notice:c}),!i&&n.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.actions.claimLink&&n.jsx(F,{size:"sm",onClick:()=>r(e),children:"Finish setting up"}),e.moveId&&n.jsx(F,{size:"sm",variant:"outline",onClick:()=>o(e.moveId),children:"See the move"}),e.actions.keep.allowed&&n.jsx(F,{size:"sm",variant:"outline",disabled:a,onClick:()=>s.askKeep(e.communityId),children:"Keep this one open"}),e.actions.restore&&n.jsx(F,{size:"sm",variant:"outline",disabled:a,onClick:()=>void s.restore(e),children:a?"Reopening…":"Reopen"})]})]})}function TS(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=Pd(e.failureCode??"unrecognised");return{text:t.title,next:t.next}}default:return{text:"Unknown state. Update DorkOS to see more."}}}function DS(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(RS,{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=TS(s),o=s.state==="awaiting_upload"||s.state==="importing"||s.state==="ready";return n.jsxs("li",{className:"flex flex-wrap items-start justify-between gap-2 rounded-lg border p-3",children:[n.jsxs("div",{className:"min-w-0 space-y-0.5 text-sm",children:[n.jsx("p",{className:"truncate font-medium",children:s.name}),n.jsx("p",{className:s.state==="failed"?"text-destructive":"text-muted-foreground",children:r.text}),r.next&&n.jsx("p",{className:"text-muted-foreground",children:r.next})]}),o&&n.jsx(F,{size:"sm",variant:"outline",onClick:()=>e.onOpenMove(s.moveId),children:"Continue"})]},s.moveId)})})]})]})}function OS(e){return e.open?n.jsx(MS,{...e}):null}function MS({open:e,onOpenChange:t,installName:s,onOpenMove:r,onMoveHere:o,onConnected:a}){var h;const i=jl(!0),c=ES(),[d,u]=l.useState(null),m=Mo(d,s,a),p=()=>t(!1);let f;if(d)f=$o({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:p});else{const g=((h=i.data)==null?void 0:h.available)===!0?i.data:null;f={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(DS,{communities:g.communities,moves:g.moves,allowanceText:Ld(g.allowance),actions:c,onFinishSetup:u,onOpenMove:x=>{p(),r(x)}}):n.jsx($t,{notice:{message:"Couldn’t reach your DorkOS account. Try again."}}),actions:n.jsxs(n.Fragment,{children:[n.jsx(F,{variant:"outline",onClick:p,children:"Close"}),n.jsx(F,{variant:"outline",onClick:()=>{p(),o()},children:"Move one here"})]})}}return n.jsx(Fo,{open:e,onOpenChange:t,step:f})}function _S(e){switch(e.kind){case"invalid":return{text:Fd,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 Ud(e){const t=l.useId(),s=e.webAddressError?{text:e.webAddressError,error:!0}:_S(e.webAddressStatus);return n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{className:"space-y-1.5",children:[n.jsx(ze,{htmlFor:`${t}-name`,children:"Space name"}),n.jsx(ft,{id:`${t}-name`,required:!0,maxLength:vS,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(ze,{htmlFor:`${t}-address`,children:["Web address ",n.jsx("span",{className:"text-muted-foreground font-normal",children:"(optional)"})]}),n.jsx(ft,{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)??Fd})]})]})}const PS="Your history is here. Send invitations so people can join again.";function LS(e,t){return{title:"Move a space here",description:"This copies your space’s history and files to DorkOS.",body:n.jsxs("div",{className:"space-y-2 text-sm",children:[n.jsx("p",{children:"Everyone joins again and reconnects their DorkOS."}),n.jsx("p",{className:"text-muted-foreground",children:"Your old space keeps running until you delete it."}),n.jsx("p",{className:"font-medium",children:"First, export the old space:"}),n.jsxs("ol",{className:"text-muted-foreground list-decimal space-y-1 pl-5",children:[n.jsx("li",{children:"Sign in to the old space as its owner."}),n.jsx("li",{children:"Open its Settings."}),n.jsx("li",{children:"Choose Export."}),n.jsx("li",{children:"Enter your password."}),n.jsx("li",{children:"Save the .zip file."})]})]}),actions:n.jsxs(n.Fragment,{children:[n.jsx(F,{variant:"outline",onClick:t,children:"Cancel"}),n.jsx(F,{onClick:e,children:"I have the file"})]})}}function FS({file:e,onFileChange:t}){const s=l.useId();return n.jsxs("div",{className:"space-y-1.5",children:[n.jsx(ze,{htmlFor:s,children:"Export file"}),n.jsx(ft,{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,", ",Pn(e.size)]})]})}function $S(e){const t=Qn(e.webAddress),s=e.file===null||e.name.trim()===""||!t.valid||e.webAddressStatus.kind==="taken"||e.webAddressStatus.kind==="reserved";return{title:"Choose the export",description:"Pick the .zip file, then name the space.",body:n.jsxs("form",{id:e.formId,onSubmit:e.onSubmit,className:"space-y-4",noValidate:!0,children:[n.jsx(FS,{file:e.file,onFileChange:e.onFileChange}),n.jsx(Ud,{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($t,{notice:e.failure.notice}),n.jsx(Co,{})]}),actions:n.jsxs(n.Fragment,{children:[n.jsx(F,{type:"button",variant:"outline",onClick:e.onBack,children:"Back"}),n.jsx(F,{type:"submit",form:e.formId,disabled:s,children:"Start moving"})]})}}function Kd({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(db,{value:r,"aria-label":e}),n.jsxs("p",{className:"text-muted-foreground text-sm tabular-nums",children:[Pn(t)," of ",Pn(s)]})]})}function BS(e,t){return{title:"Getting the file ready",description:"Keep this open. The upload then starts on its own.",body:n.jsx(Kd,{label:"Getting the file ready",...e}),actions:n.jsx(F,{variant:"outline",onClick:t,children:"Cancel"})}}function zS(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 US(e,t){const{move:s}=e,r=t.notice?n.jsx($t,{notice:t.notice}):null,o=n.jsx(F,{variant:"outline",disabled:t.busy,onClick:t.onCancelMove,children:"Cancel move"}),a=n.jsx(F,{onClick:t.onStartOver,children:"Start again"}),i=n.jsx(F,{variant:"outline",onClick:t.onClose,children:"Close"});switch(e.kind){case"uploading":{const c=s.upload;return{title:`Uploading ${s.name}`,description:"You can close this window. Keep DorkOS running until it finishes.",body:n.jsxs(n.Fragment,{children:[n.jsx(Kd,{label:`Uploading ${s.name}`,loaded:c.sentBytes,total:c.totalBytes}),r]}),actions:o}}case"upload-failed":return e.why==="interrupted"?{title:"The upload didn’t finish",description:"DorkOS still has the file. Send it again to continue.",body:r,actions:n.jsxs(n.Fragment,{children:[o,n.jsx(F,{disabled:t.busy,onClick:t.onSendAgain,children:"Send again"})]})}:e.why==="refused"?{title:"DorkOS didn’t accept the file",description:"The file arrived changed or incomplete.",body:n.jsxs(n.Fragment,{children:[n.jsx("p",{className:"text-muted-foreground text-sm",children:"Cancel the move, export the old space again, then start again."}),r]}),actions:o}:e.why==="restarted"?{title:"This move has to start again",description:"DorkOS restarted, or the move began on another computer.",body:n.jsxs(n.Fragment,{children:[n.jsx("p",{className:"text-muted-foreground text-sm",children:"Cancel the move and start again with the same export."}),n.jsx("p",{className:"text-muted-foreground text-sm",children:"Or finish it on the computer that started it."}),n.jsx("p",{className:"text-muted-foreground text-sm",children:"For safety, uploads only work while DorkOS stays running."}),r]}),actions:o}:{title:"The time to upload ran out",description:"Cancel the move, then start again with the same export.",body:r,actions:o};case"importing":{const c=zS(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(Ne,{className:"size-4"})," Moving your history…"]}),c&&n.jsx("p",{className:"text-sm",children:c}),r]}),actions:n.jsxs(n.Fragment,{children:[o,n.jsx(F,{onClick:t.onClose,children:"Close"})]})}}case"failed":{const c=Pd(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 KS(e){return e.open?n.jsx(HS,{...e}):null}function HS({open:e,onOpenChange:t,installName:s,resumeMoveId:r,onConnected:o}){var I,v;const[a,i]=l.useState("explain"),[c,d]=l.useState(null),[u,m]=l.useState(""),[p,f]=l.useState(""),h=CS(r),g=zd(a==="choose"&&!h.step?p:""),x=((I=h.step)==null?void 0:I.kind)==="ready"?h.step.move:null,b=Mo(x?{communityId:x.communityId,name:x.name,communityUrl:x.communityUrl}:null,s,o),y=()=>t(!1);function C(N){N.preventDefault();const O=Qn(p);!c||u.trim()===""||!O.valid||h.start({file:c,name:u,shortName:O.value})}let j;return h.sending?j=BS(h.sending,()=>void h.cancel()):((v=h.step)==null?void 0:v.kind)==="ready"?j=$o({state:b.state,name:h.step.move.name,doneDetail:PS,onOpenClaim:b.openClaim,onConfirmClaimed:b.confirmClaimed,onOpenApproval:b.openApproval,onRetryConnect:b.retryConnect,onClose:y}):h.step?j=US(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"?j=LS(()=>i("choose"),y):j=$S({file:c,onFileChange:d,name:u,onNameChange:m,webAddress:p,onWebAddressChange:N=>{f(N),h.clearFieldFailure()},webAddressStatus:g,failure:h.failure,formId:"move-community-form",onSubmit:C,onBack:()=>i("explain")}),n.jsx(Fo,{open:e,onOpenChange:t,step:j,locked:h.sending!==null})}function WS(e){const t=Qn(e.webAddress),s=e.name.trim()===""||!t.valid||e.webAddressStatus.kind==="taken"||e.webAddressStatus.kind==="reserved",r=Ld(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(Ud,{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($t,{notice:e.failure.notice}),n.jsx(Co,{})]}),actions:n.jsxs(n.Fragment,{children:[n.jsx(F,{type:"button",variant:"outline",onClick:e.onCancel,children:"Cancel"}),n.jsx(F,{type:"submit",form:e.formId,disabled:s||e.submitting,children:e.submitting?"Starting…":"Start space"})]})}}function GS(e){return e.open?n.jsx(qS,{...e}):null}function qS({open:e,onOpenChange:t,installName:s,allowance:r,onConnected:o}){const[a,i]=l.useState(""),[c,d]=l.useState(""),[u,m]=l.useState(null),p=jS(),f=zd(u?"":c),h=Mo(u,s,o),g=()=>t(!1);async function x(y){y.preventDefault();const C=Qn(c);if(a.trim()===""||!C.valid||p.submitting)return;const j=await p.submit({name:a,shortName:C.value});j&&m({communityId:j.community.communityId,name:j.community.name,communityUrl:j.community.communityUrl})}const b=u?$o({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}):WS({name:a,webAddress:c,onNameChange:i,onWebAddressChange:y=>{d(y),p.clearFieldFailure()},webAddressStatus:f,submitting:p.submitting,failure:p.failure,allowance:r,formId:"start-community-form",onSubmit:y=>void x(y),onCancel:g});return n.jsx(Fo,{open:e,onOpenChange:t,step:b,locked:p.submitting})}function YS({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(GS,{open:(t==null?void 0:t.kind)==="start",onOpenChange:a,installName:r,allowance:e.allowance,onConnected:o}),n.jsx(KS,{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(OS,{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 VS=.1;function QS(e){if(!(e!=null&&e.available)||e.balance===null)return null;const{allowance:t,purchased:s,denomination:r}=e.balance,o=yx(t.remainingMicro,t.grantedMicro);if(o===null||o>=VS||!/^\d+$/.test(t.remainingMicro)||!/^\d+$/.test(s.remainingMicro)||BigInt(s.remainingMicro)>0n)return null;const a=vx(wx(t.remainingMicro,r));return a===null?null:`${a} left`}function XS(e){if(e.state!=="loading")return e.state==="signed-out"?"Not signed in":["Signed in",e.label,e.lowCredits].filter(Boolean).join(" · ")}function JS(){var r;const e=Tc(),t=((r=e.data)==null?void 0:r.linked)===!0,s=Dc({enabled:t});return e.data===void 0?{state:"loading"}:t?{state:"signed-in",label:e.data.accountLabel,lowCredits:QS(s.data)}:{state:"signed-out"}}function ZS(){const e=me();be("commands_changed",()=>{e.invalidateQueries({queryKey:["commands"]})})}function Hd(e){return e.kind==="agent"?Lt("agent",e.agent.projectPath):Lt("room",e.room.id)}function Dr(e){return e.kind==="agent"?Oe(e.agent):e.room.kind==="channel"&&e.room.slug?`#${e.room.slug}`:e.room.title}function Ya(e){return`Chats ${e.kind==="agent"?"with":"in"} ${Dr(e)}`}function e0(e){return e.kind==="agent"?`No chats with ${Dr(e)} yet.`:`No chats came from ${Dr(e)}.`}function t0(e){return e.kind==="channel"&&e.slug?`#${e.slug}`:e.title}function n0(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=t0(r);t.has(o)||t.set(o,r.id)}return t}function s0(e,t){const s=[];e.cwd!==null&&s.push(Lt("agent",e.cwd));const r=r0(e,t);return r!==void 0&&s.push(Lt("room",r)),s}function r0(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 o0(e,t){const s=Number(e.archived)-Number(t.archived);if(s!==0)return s;const r=Number(tn(t))-Number(tn(e));return r!==0?r:t.lastActivityAt.localeCompare(e.lastActivityAt)||t.id.localeCompare(e.id)}function sr(e){return[...e].sort(o0)}function Or(e){const t=[e.title];e.slug&&t.push(e.slug);for(const s of e.participants??[])t.push(s.displayName);return t}function a0(){const{data:e,isLoading:t,isError:s}=Ps({includeArchived:!0});return l.useMemo(()=>{const r=e??[],o=sr(r.filter(i=>i.kind==="channel")),a=sr(r.filter(i=>i.kind==="dm"));return{channels:o,dms:a,unread:sr([...o,...a].filter(i=>!i.archived&&tn(i))),isLoading:t,isError:s}},[e,t,s])}const i0=8;function c0(e,t){const s=new Set(gh(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 Va(e){const t=Date.parse(e.lastActivityAt);return Number.isNaN(t)?Number.NEGATIVE_INFINITY:t}function l0(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(l0).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}]:[]}),p=[],f=[];for(const g of[...c,...u,...m])g.kind==="room"&&s.has(g.room.id)?p.push(g):f.push(g);const h=(g,x)=>Va(x)-Va(g)||x.key.localeCompare(g.key);return[...p.sort(h),...f.sort(h)].slice(0,i)}const u0=50;function Wd(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 Qa(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?Oe(i):m0(a),title:Oc(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 h0(e,t,s,r){const{data:o}=Mc(u0),a=vt(f=>f.statuses),i=vt(_c(f=>Object.values(f.sessions))),c=l.useMemo(()=>Qa((o==null?void 0:o.sessions)??[],e,r),[o==null?void 0:o.sessions,e,r]),d=l.useMemo(()=>Qa(i,e,r),[i,e,r]),u=l.useMemo(()=>[...i,...(o==null?void 0:o.sessions)??[]],[i,o]),m=l.useMemo(()=>{const f=new Map;for(const h of d)f.set(h.id,h);for(const h of c)f.has(h.id)||f.set(h.id,h);return c0(a,u).flatMap(h=>{const g=f.get(h.sessionId);return g?[{session:g,verb:xh(h.lifecycle,h.activity),signal:h.lifecycle==="blocked"?"needs-you":"working"}]:[]})},[a,d,c,u]),p=l.useMemo(()=>{const f=new Set(bh((o==null?void 0:o.sessions)??[]).yours.map(h=>h.id));return d0({sessions:c.filter(h=>f.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:p,agentActivity:(o==null?void 0:o.agentActivity)??f0}}const f0=Object.freeze({});function p0(){const{data:e,dataUpdatedAt:t}=Pe(),s=e!==void 0&&t>nn,{status:r,url:o}=yh(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)&&(Xo.getState().consumeSuppression()||vh(Xo.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 dt={copyLink:"copyRemoteLink",showQr:"showRemoteQr",turnOn:"turnRemoteAccessOn",turnOff:"turnRemoteAccessOff"},yn={copyLink:11,showQr:12,turnOff:13,turnOn:11};function g0(e,t,s){return(e==="connected"||e==="reconnecting"||e==="asleep")&&t?[{id:"remote-access-copy",label:"Copy remote link",icon:"Copy",action:dt.copyLink,category:"quick-action",priority:yn.copyLink,keywords:["remote","tunnel","url","address","phone","share"]},{id:"remote-access-qr",label:"Show QR code",icon:"QrCode",action:dt.showQr,category:"quick-action",priority:yn.showQr,keywords:["remote","tunnel","scan","phone"]},{id:"remote-access-off",label:"Turn remote access off",icon:"Globe",action:dt.turnOff,category:"quick-action",priority:yn.turnOff,keywords:["remote","tunnel","ngrok","stop","disconnect"]}]:e==="asleep"||e==="blocked"?[{id:"remote-access-off",label:"Turn remote access off",icon:"Globe",action:dt.turnOff,category:"quick-action",priority:yn.turnOff,keywords:["remote","tunnel","ngrok","stop","disconnect"]}]:s&&(e==="off"||e==="error")?[{id:"remote-access-on",label:"Turn remote access on",icon:"Globe",action:dt.turnOn,category:"quick-action",priority:yn.turnOn,keywords:["remote","tunnel","ngrok","phone","start"]}]:[]}function x0(){const{state:e,url:t,isSetUp:s}=Pc();return l.useMemo(()=>g0(e,t,s),[e,t,s])}const Zn={usageKey:null,lastActivityAt:null,waiting:!1,demoted:!1,scopes:[]};function Xa(e){return{usageKey:Lt("room",e.id),lastActivityAt:e.lastActivityAt,waiting:tn(e),demoted:e.archived,scopes:[]}}function b0(e,t){const{data:s,isLoading:r}=Ls(),o=a0(),{sessions:a}=Lc(),i=l.useMemo(()=>!a||!e?null:wh(a,e)[0]??null,[a,e]),{data:c}=Gx(e,i==null?void 0:i.id,i==null?void 0:i.runtime),d=Os("command-palette.items"),u=oo(),m=l.useMemo(()=>u.map(A=>({id:A.id,label:A.title,href:fc(A.extensionId,A.path),icon:A.icon})),[u]),p=l.useMemo(()=>d.filter(A=>A.category==="feature"),[d]),f=x0(),h=l.useMemo(()=>[...d.filter(A=>A.category==="quick-action"),...f],[d,f]),g=l.useMemo(()=>jh.flatMap(A=>{const w=h.find(k=>k.id===A);return w?[w]:[]}),[h]),x=l.useMemo(()=>(s==null?void 0:s.agents)??[],[s]),b=l.useMemo(()=>new Set(o.unread.map(A=>A.id)),[o.unread]),y=l.useMemo(()=>[...o.channels,...o.dms],[o.channels,o.dms]),C=l.useMemo(()=>Sh(t),[t]),{sessions:j,continueRows:I,recent:v,agentActivity:N}=h0(x,y,b,C),O=l.useMemo(()=>n0(y),[y]),P=l.useMemo(()=>c?c.commands.map(A=>({name:A.fullCommand,description:A.description})):[],[c]),R=l.useMemo(()=>{const A=[];for(const w of x)A.push({id:w.id,name:w.name,type:"agent",keywords:[w.projectPath,w.id],usageKey:Lt("agent",w.projectPath),lastActivityAt:N[w.projectPath]??null,waiting:!1,demoted:!1,scopes:[],data:w});for(const w of j)A.push({id:w.id,name:w.title,type:"session",keywords:Wd(w),usageKey:Lt("session",w.id),lastActivityAt:w.lastActivityAt,waiting:!1,demoted:!1,scopes:s0(w,O),data:w});for(const w of p)A.push({id:w.id,name:w.label,type:"feature",keywords:w.keywords,...Zn,data:w});for(const w of P)A.push({id:`cmd-${w.name}`,name:w.name,type:"command",keywords:w.description?[w.description]:void 0,...Zn,data:w});for(const w of h)A.push({id:w.id,name:w.label,type:"quick-action",keywords:w.keywords,...Zn,data:w});for(const w of o.channels)A.push({id:w.id,name:kh(w),type:"room",keywords:Or(w),...Xa(w),data:w});for(const w of o.dms)A.push({id:w.id,name:w.title,type:"dm",keywords:Or(w),...Xa(w),data:w});for(const w of m)A.push({id:w.id,name:w.label,type:"page",keywords:["add-on","extension"],...Zn,data:w});return A},[x,N,j,P,p,h,o.channels,o.dms,O,m]);return{allAgents:x,newActions:g,rooms:o,sessions:j,continueRows:I,recent:v,searchableItems:R,isLoading:r}}function y0(){const e=_(a=>a.toggleGlobalPalette),t=_(a=>a.setGlobalPaletteOpen),s=_(a=>a.globalPaletteOpen),{close:r}=tt(),{close:o}=lo();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 Ct(e){return Array.isArray?Array.isArray(e):qd(e)==="[object Array]"}function v0(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 Mr(e){return e==null?"":v0(e)}function Ce(e){return typeof e=="string"}function ls(e){return typeof e=="number"}function w0(e){return e===!0||e===!1||j0(e)&&qd(e)=="[object Boolean]"}function Gd(e){return typeof e=="object"}function j0(e){return Gd(e)&&e!==null}function Be(e){return e!=null}function es(e){return!e.trim().length}function qd(e){return e==null?e===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(e)}const S0="Incorrect 'index' type",_r="Invalid doc index: must be a non-negative integer within the bounds of the docs array",k0=e=>`Invalid value for key ${e}`,C0=e=>`Pattern length exceeds max of ${e}.`,N0=e=>`Missing ${e} property in key`,A0=e=>`Property 'weight' in key '${e}' must be a positive integer`,E0="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.",Ja=Object.prototype.hasOwnProperty;var I0=class{constructor(e){this._keys=[],this._keyMap={};let t=0;e.forEach(s=>{const r=Yd(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 Yd(e){let t=null,s=null,r=null,o=1,a=null;if(Ce(e)||Ct(e))r=e,t=Za(e),s=ds(e);else{if(!Ja.call(e,"name"))throw new Error(N0("name"));const i=e.name;if(r=i,Ja.call(e,"weight")&&e.weight!==void 0&&(o=e.weight,o<=0))throw new Error(A0(ds(i)));t=Za(i),s=ds(i),a=e.getFn??null}return{path:t,id:s,weight:o,src:r,getFn:a}}function Za(e){return Ct(e)?e:e.split(".")}function ds(e){return Ct(e)?e.join("."):e}function R0(e,t){const s=[];let r=!1;const o=(a,i,c,d)=>{if(Be(a))if(!i[c])s.push(d!==void 0?{v:a,i:d}:a);else{const u=a[i[c]];if(!Be(u))return;if(c===i.length-1&&(Ce(u)||ls(u)||w0(u)||typeof u=="bigint"))s.push(d!==void 0?{v:Mr(u),i:d}:Mr(u));else if(Ct(u)){r=!0;for(let m=0,p=u.length;m<p;m+=1)o(u[m],i,c+1,m)}else i.length&&o(u,i,c+1,d)}};return o(e,Ce(t)?t.split("."):t,0),r?s:s[0]}const T0={includeMatches:!1,findAllMatches:!1,minMatchCharLength:1},D0={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},O0={location:0,threshold:.6,distance:100},M0={useExtendedSearch:!1,useTokenSearch:!1,tokenize:void 0,tokenMatch:"any",getFn:R0,ignoreLocation:!1,ignoreFieldNorm:!1,fieldNormWeight:1},J=Object.freeze({...D0,...T0,...O0,...M0});function _0(e){return e>=9&&e<=13||e===32||e===160}function P0(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++)_0(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 Bo=class{constructor({getFn:e=J.getFn,fieldNormWeight:t=J.fieldNormWeight}={}){this.norm=P0(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(Ce(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(Ce(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!Be(e)||es(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(Be(i)){if(Ct(i)){const c=[];for(let d=0,u=i.length;d<u;d+=1){const m=i[d];if(Be(m)){if(Ce(m)){if(!es(m)){const p={v:m,i:d,n:this.norm.get(m)};c.push(p)}}else if(Be(m.v)){const p=Ce(m.v)?m.v:Mr(m.v);if(!es(p)){const f={v:p,i:m.i,n:this.norm.get(p)};c.push(f)}}}}s.$[r]=c}else if(Ce(i)&&!es(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 Vd(e,t,{getFn:s=J.getFn,fieldNormWeight:r=J.fieldNormWeight}={}){const o=new Bo({getFn:s,fieldNormWeight:r});return o.setKeys(e.map(Yd)),o.setSources(t),o.create(),o}function L0(e,{getFn:t=J.getFn,fieldNormWeight:s=J.fieldNormWeight}={}){const{keys:r,records:o}=e,a=new Bo({getFn:t,fieldNormWeight:s});return a.setKeys(r),a.setIndexRecords(o),a}function F0(e=[],t=J.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 $0(e,t,s,{location:r=J.location,distance:o=J.distance,threshold:a=J.threshold,findAllMatches:i=J.findAllMatches,minMatchCharLength:c=J.minMatchCharLength,includeMatches:d=J.includeMatches,ignoreLocation:u=J.ignoreLocation}={}){if(t.length>32)throw new Error(C0(32));const m=t.length,p=e.length,f=Math.max(0,Math.min(r,p));let h=a,g=f;const x=(R,A)=>{const w=R/m;if(u)return w;const k=Math.abs(f-A);return o?w+k/o:k?1:w},b=c>1||d,y=b?Array(p):[];let C;for(;(C=e.indexOf(t,g))>-1;){const R=x(0,C);if(h=Math.min(R,h),g=C+m,b){let A=0;for(;A<m;)y[C+A]=1,A+=1}}g=-1;let j=[],I=1,v=0,N=m+p;const O=1<<m-1;for(let R=0;R<m;R+=1){let A=0,w=N;for(;A<w;)x(R,f+w)<=h?A=w:N=w,w=Math.floor((N-A)/2+A);N=w;let k=Math.max(1,f-w+1);const E=i?p:Math.min(f+w,p)+m,D=Array(E+2);D[E+1]=(1<<R)-1;for(let T=E;T>=k;T-=1){const L=T-1,$=s[e[L]];if(D[T]=(D[T+1]<<1|1)&$,R&&(D[T]|=(j[T+1]|j[T])<<1|1|j[T+1]),D[T]&O&&(I=x(R,L),I<=h)){if(h=I,g=L,v=R,g<=f)break;k=Math.max(1,2*f-g)}}if(x(R+1,f)>h)break;j=D}if(b&&g>=0){const R=Math.min(p-1,g+m-1+v);for(let A=g;A<=R;A+=1)s[e[A]]&&(y[A]=1)}const P={isMatch:g>=0,score:Math.max(.001,I)};if(b){const R=F0(y,c);R.length?d&&(P.indices=R):P.isMatch=!1}return P}function B0(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 zo(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 Qd={ł:"l",Ł:"L",đ:"d",Đ:"D",ø:"o",Ø:"O",ħ:"h",Ħ:"H",ŧ:"t",Ŧ:"T",ı:"i",ß:"ss"},z0=new RegExp("["+Object.keys(Qd).join("")+"]","g"),Ln=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(z0,t=>Qd[t]):e=>e;var Uo=class{constructor(e,{location:t=J.location,threshold:s=J.threshold,distance:r=J.distance,includeMatches:o=J.includeMatches,findAllMatches:a=J.findAllMatches,minMatchCharLength:i=J.minMatchCharLength,isCaseSensitive:c=J.isCaseSensitive,ignoreDiacritics:d=J.ignoreDiacritics,ignoreLocation:u=J.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?Ln(e):e,this.pattern=e,this.chunks=[],!this.pattern.length)return;const m=(f,h)=>{this.chunks.push({pattern:f,alphabet:B0(f),startIndex:h})},p=this.pattern.length;if(p>32){let f=0;const h=p%32,g=p-h;for(;f<g;)m(this.pattern.substr(f,32),f),f+=32;if(h){const x=p-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?Ln(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 p=0,f=!1;this.chunks.forEach(({pattern:g,alphabet:x,startIndex:b})=>{const{isMatch:y,score:C,indices:j}=$0(e,g,x,{location:o+b,distance:a,threshold:i,findAllMatches:c,minMatchCharLength:d,includeMatches:r,ignoreLocation:u});y&&(f=!0),p+=C,y&&j&&m.push(...j)});const h={isMatch:f,score:f?p/this.chunks.length:1};return f&&r&&(h.indices=zo(m)),h}};const U0=new Set(["fuzzy","include"]);function K0(e){return e.startsWith("inverse")}const Pr=[{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 Uo(e,{location:t.location??J.location,threshold:t.threshold??J.threshold,distance:t.distance??J.distance,includeMatches:t.includeMatches??J.includeMatches,findAllMatches:t.findAllMatches??J.findAllMatches,minMatchCharLength:t.minMatchCharLength??J.minMatchCharLength,isCaseSensitive:t.isCaseSensitive??J.isCaseSensitive,ignoreDiacritics:t.ignoreDiacritics??J.ignoreDiacritics,ignoreLocation:t.ignoreLocation??J.ignoreLocation});return{type:"fuzzy",search(r){return s.searchIn(r)}}}}],ei=Pr.length,H0="\0",W0="|";function G0(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 ti(e,t){const s=e.match(t);return s?s[1]:null}function q0(e,t={}){return e.replace(/\\\|/g,H0).split(W0).map(s=>{const r=G0(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<ei;){const m=Pr[u],p=ti(c,m.multiRegex);p&&(o.push(m.create(p,t)),d=!0)}if(!d)for(u=-1;++u<ei;){const m=Pr[u],p=ti(c,m.singleRegex);if(p){o.push(m.create(p,t));break}}}return o})}var Y0=class{constructor(e,{isCaseSensitive:t=J.isCaseSensitive,ignoreDiacritics:s=J.ignoreDiacritics,includeMatches:r=J.includeMatches,minMatchCharLength:o=J.minMatchCharLength,ignoreLocation:a=J.ignoreLocation,findAllMatches:i=J.findAllMatches,location:c=J.location,threshold:d=J.threshold,distance:u=J.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?Ln(e):e,this.pattern=e,this.query=q0(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?Ln(e):e;let a=0;const i=[];let c=0,d=!1;for(let u=0,m=t.length;u<m;u+=1){const p=t[u];i.length=0,a=0,d=!1;for(let f=0,h=p.length;f<h;f+=1){const g=p[f],{isMatch:x,indices:b,score:y}=g.search(e);if(x)a+=1,c+=y,K0(g.type)&&(d=!0),s&&(U0.has(g.type)?i.push(...b):i.push(b));else{c=0,a=0,i.length=0,d=!1;break}}if(a){const f={isMatch:!0,score:c/a};return d&&(f.hasInverse=!0),s&&(f.indices=zo(i)),f}}return{isMatch:!1,score:1}}};const Lr=[];function Ko(...e){Lr.push(...e)}function js(e,t){for(let s=0,r=Lr.length;s<r;s+=1){const o=Lr[s];if(o.condition(e,t))return new o(e,t)}return new Uo(e,t)}const Ss={AND:"$and",OR:"$or"},Fr={PATH:"$path",PATTERN:"$val"},$r=e=>!!(e[Ss.AND]||e[Ss.OR]),V0=e=>!!e[Fr.PATH],Q0=e=>!Ct(e)&&Gd(e)&&!$r(e),ni=e=>({[Ss.AND]:Object.keys(e).map(t=>({[t]:e[t]}))});function Xd(e,t,{auto:s=!0}={}){const r=o=>{if(Ce(o)){const d={keyId:null,pattern:o};return s&&(d.searcher=js(o,t)),d}const a=Object.keys(o),i=V0(o);if(!i&&a.length>1&&!$r(o))return r(ni(o));if(Q0(o)){const d=i?o[Fr.PATH]:a[0],u=i?o[Fr.PATTERN]:o[d];if(!Ce(u))throw new Error(k0(d));const m={keyId:ds(d),pattern:u};return s&&(m.searcher=js(u,t)),m}const c={children:[],operator:a[0]};return a.forEach(d=>{const u=o[d];Ct(u)&&u.forEach(m=>{c.children.push(r(m))})}),c};return $r(e)||(e=ni(e)),r(e)}function Br(e,{ignoreFieldNorm:t=J.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 X0(e,{ignoreFieldNorm:t=J.ignoreFieldNorm}){e.forEach(s=>{s.score=Br(s.matches,{ignoreFieldNorm:t})})}var J0=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 Z0(e){const t=[];return e.matches.forEach(s=>{if(!Be(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 ek(e,t,{includeMatches:s=J.includeMatches,includeScore:r=J.includeScore}={}){return e.map(o=>{const{idx:a}=o,i={item:t[a],refIndex:a};return s&&(i.matches=Z0(o)),r&&(i.score=o.score),i})}const tk=/[\p{L}\p{M}\p{N}_]+/gu,si=new WeakSet;function nk(e){si.has(e)||(si.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 sk(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(tk)||[]}function zr({isCaseSensitive:e=!1,ignoreDiacritics:t=!1,tokenize:s}={}){const r=sk(s);return{tokenize(o){return e||(o=o.toLowerCase()),t&&(o=Ln(o)),r(o)}}}var rk=class{static condition(e,t){return t.useTokenSearch}constructor(e,t){this.options=t,this.analyzer=zr({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 Uo(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),p=this.idfWeights[u];r+=p,m.isMatch&&(o++,s+=p*(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=zo(t)),this.combineAll&&(this.useMask?d.matchedMask=a:d.matchedTerms=i,d.termCount=this.numTerms),d}};function rr(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 Jd(e,t,s,r){const{i:o,v:a,$:i}=t;if(a!==void 0){rr(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)rr(e,u.v,o,r);else rr(e,d.v,o,r)}}function ok(e,t,s){const r={fieldCount:0,df:new Map,docFieldCount:new Map,docTermFieldHits:new Map};for(const o of e)Jd(r,o,t,s);return r}function ak(e,t,s,r){Jd(e,t,s,r)}function ik(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 ri(e,t){if(t.length===0)return;const s=Array.from(new Set(t)).sort((c,d)=>c-d);for(const c of s)ik(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 Nt=class{constructor(e,t,s){this.options={...J,...t},this.options.useExtendedSearch,this.options.useTokenSearch,this._keyStore=new I0(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=js(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 Bo))throw new Error(S0);if(this._myIndex=t||Vd(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight}),this.options.useTokenSearch){const s=zr({isCaseSensitive:this.options.isCaseSensitive,ignoreDiacritics:this.options.ignoreDiacritics,tokenize:this.options.tokenize});this._invertedIndex=ok(this._myIndex.records,this._myIndex.keys.length,s)}this._invalidateSearcherCache()}add(e){if(!Be(e))return;this._docs.push(e);const t=this._myIndex.add(e,this._docs.length-1);if(this._invertedIndex&&t){const s=zr({isCaseSensitive:this.options.isCaseSensitive,ignoreDiacritics:this.options.ignoreDiacritics,tokenize:this.options.tokenize});ak(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&&ri(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&&ri(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(Ce(e)&&!e.trim()){let f=this._docs.map((h,g)=>({item:h,refIndex:g}));return ls(s)&&s>-1&&(f=f.slice(0,s)),f}const d=a&&ls(s)&&s>0&&Ce(e),u=i,m=(f,h)=>u(f,h)||f.idx-h.idx;let p;if(d){const f=new J0(s,m);Ce(this._docs[0])?this._searchStringList(e,{heap:f,ignoreFieldNorm:c}):this._searchObjectList(e,{heap:f,ignoreFieldNorm:c}),p=f.extractSorted()}else p=Ce(e)?Ce(this._docs[0])?this._searchStringList(e):this._searchObjectList(e):this._searchLogical(e),X0(p,{ignoreFieldNorm:c}),a&&p.sort(Ce(e)?m:u),ls(s)&&s>-1&&(p=p.slice(0,s));return ek(p,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(!Be(c))return;const m=r.searchIn(c);if(m.isMatch){const p={score:m.score,value:c,norm:u,indices:m.indices};o&&(p.matchedMask=m.matchedMask,p.matchedTerms=m.matchedTerms,p.termCount=m.termCount);const f=[p];if(!o||this._coversAllTokens(f)){const h={item:c,idx:d,matches:f};t?(h.score=Br(h.matches,{ignoreFieldNorm:s}),t.insert(h)):i.push(h)}}}),i}_searchLogical(e){const t=Xd(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:p}=c,f=[];for(let h=0,g=m.length;h<g;h+=1){const x=m[h],b=r(x,d,u);if(b.length)f.push(...b);else if(p===Ss.AND)return[]}return f},o=this._myIndex.records,a=new Map,i=[];return o.forEach(({$:c,i:d})=>{if(Be(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(!Be(d))return;const m=[];let p=!1,f=!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&&(f=!0)):p=!0}),!(f&&p)&&m.length&&(!o||this._coversAllTokens(m))){const h={idx:u,item:d,matches:m};t?(h.score=Br(h.matches,{ignoreFieldNorm:s}),t.insert(h)):c.push(h)}}),c}_findMatches({key:e,value:t,searcher:s}){if(!Be(t))return[];const r=[];if(Ct(t))t.forEach(({v:o,i:a,n:i})=>{if(!Be(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}};Nt.version="7.5.0";Nt.createIndex=Vd;Nt.parseIndex=L0;Nt.config=J;Nt.match=function(e,t,s){if(s&&s.useTokenSearch)throw new Error(E0);return js(e,{...J,...s}).searchIn(t)};Nt.parseQuery=Xd;Ko(Y0);Ko(rk);Nt.use=function(...e){e.forEach(t=>Ko(t))};var ck=Nt;const lk=.02,Zd=.5,eu=.35,tu=.15,dk=1+Zd+eu+tu,uk=4320*60*1e3,mk=3,hk=1440*60*1e3,fk=.15,pk={lastUsedAt:null,useCount:0};function Ho(e){return!Number.isFinite(e)||e<0?0:e>1?1:e}function nu(e,t){return!Number.isFinite(e)||e<=0?1:Ho(Math.pow(2,-e/t))}function gk(e,t){const s=e.lastUsedAt===null?0:nu(t-e.lastUsedAt,uk),r=Math.max(0,e.useCount),o=r===0?0:r/(r+mk);return Ho((s+o)/2)}function xk(e,t){const s=e.distance===null?1:Ho(Math.pow(2,-Math.max(0,e.distance)/lk)),r=gk(e.usage,t),o=e.lastActivityAt===null?0:nu(t-e.lastActivityAt,hk),a=1+(e.waiting?Zd:0)+eu*r+tu*o;return{score:s*a/dk,signals:{relevance:s,frecency:r,recency:o}}}function bk(e,t){return e.map(s=>{const{score:r,signals:o}=xk(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 yk(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 vk(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 jk(e,t,s){const{usage:r,now:o,scope:a}=s,{prefix:i,term:c}=l.useMemo(()=>a===null?Sk(t):{prefix:null,term:t},[t,a]),d=l.useMemo(()=>{if(a===null)return e;const x=Hd(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 ck(u,wk),[u]),p=l.useMemo(()=>{const x=(b,y,C)=>{const j=b.lastActivityAt===null?NaN:Date.parse(b.lastActivityAt);return{key:`${b.type}:${b.id}`,item:{item:b,matches:y},distance:C,usage:(b.usageKey===null?void 0:r[b.usageKey])??pk,lastActivityAt:Number.isNaN(j)?null:j,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]),f=l.useMemo(()=>bk(p,o),[p,o]),{best:h,rest:g}=l.useMemo(()=>yk(f,{queried:c.length>0}),[f,c]);return{bestMatch:h,rows:g,prefix:i,term:c}}function Sk(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 kk(){const e=uo(),t=Ch();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 Ck=/^\/([A-Za-z0-9][\w.-]*(?::[\w.-]+)*)(?=\s|$)\s*/;function Nk(e,t){const s=t.trim().replace(Ck,"").trim();return s?`${e} ${s}`:`${e} `}function Ak(e){const[t,s]=Wn(),{setTheme:r,theme:o}=Yi(),a=Re(),i=me(),c=ce(),d=jn(E=>E.openFeedback),u=mo(),{url:m}=Pc(),{copy:p}=$n({toastOnSettle:!0}),{open:f}=tt(),{open:h}=lo(),g=to(),x=_(E=>E.setPickerOpen),b=_(E=>E.setCanvasOpen),y=_(E=>E.setRightPanelOpen),C=_(E=>E.setActiveRightPanelTab),j=l.useCallback(E=>{gs.getState().recordOpened("agent",E)},[]),I=l.useCallback(E=>{s(E.projectPath,{onOpened:()=>{j(E.projectPath)}}),e()},[j,s,e]),v=Fc(),N=l.useCallback(E=>{gs.getState().recordOpened("room",E.id),e(),a({...ye.channels(),search:{id:E.id}})},[e,a]),O=l.useCallback((E,D)=>{D&&j(D),e(),a(_t({session:E,dir:D??void 0}))},[e,a,j]),P=l.useCallback(E=>{e(),Nh({queryClient:i,transport:c},t).then(async D=>{if(D===null){Jo(t);return}t&&j(t);const T=Ah.getState(),L=T.getSession(D.sessionId).input;T.updateSession(D.sessionId,{input:Nk(E,L)}),a(D.isNew?await Eh(c,{session:D.sessionId,dir:t??void 0}):_t({session:D.sessionId}))}).catch(D=>{Ji(c,D),Jo(t)})},[e,a,i,c,t,j]),R=l.useCallback(E=>{e(),a({href:E})},[e,a]),A=l.useCallback(E=>{Ih(E)||console.warn(`[command-palette] no handler registered for action "${E}"`)},[]),w=l.useCallback(E=>{switch(e(),E){case"openTasks":h();return;case"openRelay":g();return;case"openMesh":a({...ye.team()});return;case"openSettings":f();return;case"discoverAgents":Tn.getState().open();return;case"browseFilesystem":x(!0);return;case"openAgentProfile":C(Th),y(!0);return;default:{const D=Rh(E);if(D){f(D);return}A(E);return}}},[e,a,h,g,f,x,C,y,A]),k=l.useCallback(E=>{switch(e(),E){case"navigateDashboard":a({...ye.home()});return;case"newSession":v();return;case"openDevPlayground":In("/dev");return;case"toggleDevtools":_.getState().toggleDevtools();return;case"toggleRouterDevtools":_.getState().toggleRouterDevtools();return;case"createAgent":Es.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({...ye.feedbackRequests()});return;case"openTasks":h();return;case"openRelay":g();return;case"openMesh":a({...ye.team()});return;case"discoverAgents":Tn.getState().open();return;case"openSettings":f();return;case"browseFilesystem":x(!0);return;case dt.copyLink:m&&p(m);return;case dt.showQr:_.getState().setRemoteAccessBeaconOpen(!0);return;case dt.turnOn:u.start();return;case dt.turnOff:u.stop();return;default:A(E);return}},[e,a,A,r,o,b,x,h,g,f,d,p,u,m,v]);return{handleAgentSelect:I,startNewSession:v,handleFeatureAction:w,handleQuickAction:k,handleRoomSelect:N,handleSessionSelect:O,handleCommandSelect:P,handlePageSelect:R,recordAgentOpened:j,setDir:s,selectedCwd:t}}const oi='[cmdk-item=""]:not([aria-disabled="true"])',Ek=new Set(["ArrowUp","ArrowDown","Home","End"]),Ik=new Set(["n","p","j","k"]);function Rk({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)}"] ${oi}`);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||(Ek.has(c.key)||c.ctrlKey&&Ik.has(c.key))&&(o.current=!0)},[]),i=l.useCallback(c=>{c.target instanceof Element&&c.target.closest(oi)&&(o.current=!0)},[]);return{onKeyDown:a,onPointerMove:i}}function Tk({scope:e,className:t}){return n.jsx("span",{"data-testid":"palette-scope-chip",className:H("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(ho,{...fo(e.agent),size:"xs",badge:null}),Oe(e.agent)]}):n.jsxs(n.Fragment,{children:[n.jsx($c,{room:e.room,participants:e.room.participants,size:"xs"}),n.jsx(Bc,{room:e.room})]})})}function Dk(e){const t=e.trim();return t.length===0?null:t}function su(e,t){const s=l.useDeferredValue(e),{sessions:r}=Dh(t),{data:o}=fb(s||null),a=l.useMemo(()=>r.slice(0,3).map(i=>({id:i.id,title:Oc(i.title),lastActive:i.updatedAt})),[r]);return{sessionCount:r.length,recentSessions:a,health:o??null}}function Ok({agent:e}){const{sessionCount:t,recentSessions:s,health:r}=su(e.id,e.projectPath),{color:o,emoji:a}=fo(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(ho,{color:o,emoji:a,size:"sm",className:"shrink-0"}),n.jsx("span",{className:"truncate text-sm font-semibold",children:Oe(e)})]}),n.jsx("p",{className:"text-muted-foreground truncate text-xs",children:zc(e.projectPath)}),n.jsxs("div",{className:"flex items-center gap-3 text-xs",children:[r&&n.jsx(Rn,{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 Mk({agent:e,onOpenHere:t,onOpenNewTab:s,onOpenNewWindow:r,onNewSession:o,onBrowseSessions:a,onEditSettings:i,recentSessions:c,onSelectSession:d}){const u=Pt?"⌘":"Ctrl+";return n.jsxs(n.Fragment,{children:[n.jsxs(Ve,{heading:`${Oe(e)} actions`,children:[n.jsxs(je,{value:"open-here",onSelect:t,children:[n.jsx(Is,{className:"size-4"}),n.jsx("span",{children:"Open here"}),n.jsx(ya,{children:"Enter"})]}),n.jsxs(je,{value:"open-new-tab",onSelect:s,children:[n.jsx(Mb,{className:"size-4"}),n.jsx("span",{children:"Open in a new tab"}),n.jsxs(ya,{children:[u,"Enter"]})]}),r&&n.jsxs(je,{value:"open-new-window",onSelect:r,children:[n.jsx(Py,{className:"size-4"}),n.jsx("span",{children:"Open in a new window"})]}),n.jsxs(je,{value:"new-session",onSelect:o,children:[n.jsx(kt,{className:"size-4"}),n.jsx("span",{children:"New chat"})]}),a&&n.jsxs(je,{value:"browse-sessions",onSelect:a,children:[n.jsx(Pb,{className:"size-4"}),n.jsx("span",{children:"Browse chats…"})]}),n.jsxs(je,{value:"edit-settings",onSelect:i,children:[n.jsx(Fs,{className:"size-4"}),n.jsxs("span",{children:["Edit ",Oe(e)," settings"]})]})]}),c.length>0&&n.jsx(Ve,{heading:"Recent chats",children:c.map(m=>n.jsxs(je,{value:m.id,onSelect:()=>d(m.id),children:[n.jsx(As,{className:"size-4"}),n.jsx("span",{className:"truncate",children:m.title}),n.jsx("span",{className:"text-muted-foreground ml-auto text-xs",children:_k(m.lastActive)})]},m.id))})]})}function _k(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 xt="bg-muted rounded px-1 py-0.5 font-mono text-3xs";function Pk({page:e,hasAgentSelected:t,canScope:s,isScoped:r}){const o=Pt?"⌘":"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:xt,children:"↑↓"}),"Navigate"]}),!e&&t&&n.jsxs("span",{className:"inline-flex items-center gap-1",children:[n.jsx("kbd",{className:xt,children:"Enter"}),"Open"]}),(!e&&t||e==="agent-actions")&&n.jsxs("span",{className:"inline-flex items-center gap-1",children:[n.jsxs("kbd",{className:xt,children:[o,"Enter"]}),"New tab"]}),e==="agent-actions"&&n.jsxs("span",{className:"inline-flex items-center gap-1",children:[n.jsx("kbd",{className:xt,children:"Enter"}),"Select"]}),e&&n.jsxs("span",{className:"inline-flex items-center gap-1",children:[n.jsx("kbd",{className:xt,children:"Backspace"}),"Back"]}),s&&n.jsxs("span",{className:"inline-flex items-center gap-1",children:[n.jsx("kbd",{className:xt,children:"Tab"}),"Search inside"]}),r&&n.jsxs("span",{className:"inline-flex items-center gap-1",children:[n.jsx("kbd",{className:xt,children:"Backspace"}),"Clear scope, at the start"]}),n.jsxs("span",{className:"ml-auto inline-flex items-center gap-1",children:[n.jsx("kbd",{className:xt,children:"esc"}),"Close"]})]})}const Lk=[{key:"#",means:"channels"},{key:"@",means:"agents and DMs"},{key:">",means:"commands"}];function ru({className:e}){return n.jsx("div",{className:H("text-muted-foreground flex flex-wrap items-center gap-x-3 gap-y-1 px-3 py-2 text-xs",e),children:Lk.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 Fk({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 ou({agent:e,isActive:t,onSelect:s,nameIndices:r,isSelected:o}){return n.jsxs(je,{value:Oe(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(Lb,{agent:e,name:r?n.jsx(Fk,{text:Oe(e),indices:r,className:"truncate text-sm font-semibold"}):n.jsx("span",{className:"truncate text-sm font-semibold",children:Oe(e)}),secondary:zc(e.projectPath),selected:t})})]})}function au(){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 iu({room:e,onSelect:t}){const s=tn(e);return n.jsxs(je,{value:e.id,keywords:Or(e),onSelect:t,className:"flex items-center gap-2 py-2",children:[n.jsx($c,{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(Bc,{room:e,className:"min-w-0 flex-1 text-sm"}),e.archived&&n.jsx(au,{}),s&&n.jsx("span",{className:"bg-brand/15 text-brand 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 $k=6e4;function Bk({lastActivityAt:e}){const t=po($k),s=l.useMemo(()=>Number.isNaN(Date.parse(e))?null:_s(e),[e,t]);return s===null?null:n.jsx("span",{className:"text-muted-foreground text-2xs font-normal",children:s})}function Ur({item:e,live:t,isSelected:s=!1,onSelect:r}){const o=Uc(e.agent,e.cwd??e.id),a=Oh(e.who,e.title),i=(t==null?void 0:t.verb)??null;return n.jsxs(je,{value:e.id,keywords:Wd(e),onSelect:r,title:a,className:H("flex gap-2 py-1.5",i!==null?"items-start":"items-center"),children:[n.jsx(ho,{color:o.color,emoji:o.emoji,size:"xs",className:H("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:Mh,children:e.who}),n.jsx("span",{"aria-hidden":!0,className:"text-muted-foreground/60 flex-none",children:_h})]}):null,n.jsx("span",{"data-slot":"palette-session-title",className:Ph,children:e.title}),n.jsxs("span",{className:H("flex items-center gap-1.5",Fh),children:[e.archived&&t===void 0&&n.jsx(au,{}),n.jsx(Lh,{origin:e.origin,label:e.originLabel,className:"text-muted-foreground"}),n.jsx(Bk,{lastActivityAt:e.lastActivityAt}),s&&n.jsx(zk,{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:H("size-1.5 shrink-0 rounded-full",$h(t.signal))}),i]})]})]})}function zk({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 Uk={session:"Conversations",agent:"Agents",room:"Channels",dm:"Direct messages",command:"Commands",feature:"Actions","quick-action":"Actions",page:"Add-ons"},Kk="Best match",Kr={Clock:cc,Radio:Fb,Globe:fs,Settings:Fs,Plus:kt,Search:hs,FolderOpen:Is,Moon:Jx,Shapes:zh,MessageSquarePlus:Kc,Inbox:Bh},Rt=[0,0,.2,1],Hk=[.4,0,1,1],cu={hidden:{opacity:0,scale:.96,y:-8},visible:{opacity:1,scale:1,y:0,transition:{duration:.2,ease:Rt}},exit:{opacity:0,scale:.96,y:-8,transition:{duration:.12,ease:Hk}}},Wk={hidden:{},visible:{transition:{staggerChildren:.035,delayChildren:.04}}},Nn={hidden:{opacity:0,y:-4},visible:{opacity:1,y:0,transition:{duration:.15,ease:Rt}}},or=8;function Gk({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(Ve,{heading:"Continue",children:e.map((u,m)=>n.jsx(re.div,{variants:m<or?Nn:void 0,children:n.jsx(Ur,{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(Ve,{heading:"Recent",children:t.map((u,m)=>n.jsxs(re.div,{variants:m<or?Nn:void 0,children:[u.kind==="session"&&n.jsx(Ur,{item:u.session,isSelected:o===u.session.id,onSelect:()=>a(u.session)}),u.kind==="room"&&n.jsx(iu,{room:u.room,onSelect:()=>i(u.room)}),u.kind==="agent"&&n.jsx(ou,{agent:u.agent,isActive:u.agent.projectPath===r,isSelected:o===Oe(u.agent),onSelect:()=>c(u.agent)})]},u.key))}),s.length>0&&n.jsxs(n.Fragment,{children:[(e.length>0||t.length>0)&&n.jsx($l,{}),n.jsx(Ve,{heading:"New",children:s.map((u,m)=>{const p=Kr[u.icon];return n.jsx(re.div,{variants:m<or?Nn:void 0,children:n.jsx(je,{value:u.label,onSelect:()=>d(u.action),children:n.jsxs(re.div,{whileHover:{x:2},transition:{duration:.1,ease:Rt},className:"flex w-full items-center gap-2",children:[p&&n.jsx(p,{className:"size-4"}),n.jsx("span",{children:u.label})]})})},u.id)})})]})]})}function ai({row:e,selectedCwd:t,selectedValue:s,onFeatureAction:r,onQuickAction:o,onGoToAgentActions:a,onRoomSelect:i,onSessionSelect:c,onCommandSelect:d,onPageSelect:u}){var f;const{item:m,matches:p}=e.item;switch(m.type){case"session":return n.jsx(Ur,{item:m.data,isSelected:s===m.data.id,onSelect:()=>c(m.data)});case"agent":return n.jsx(ou,{agent:m.data,isActive:m.data.projectPath===t,isSelected:s===Oe(m.data),onSelect:()=>a(m.data),nameIndices:(f=p==null?void 0:p.find(h=>h.key==="name"))==null?void 0:f.indices});case"room":case"dm":return n.jsx(iu,{room:m.data,onSelect:()=>i(m.data)});case"command":return n.jsx(je,{value:m.data.name,onSelect:()=>d(m.data.name),children:n.jsxs(re.div,{whileHover:{x:2},transition:{duration:.1,ease:Rt},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=Kr[m.data.icon];return n.jsx(je,{value:m.data.label,onSelect:()=>r(m.data.action),children:n.jsxs(re.div,{whileHover:{x:2},transition:{duration:.1,ease:Rt},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(je,{value:m.data.id,onSelect:()=>u(m.data.href),children:n.jsxs(re.div,{whileHover:{x:2},transition:{duration:.1,ease:Rt},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=Kr[m.data.icon];return n.jsx(je,{value:m.data.label,onSelect:()=>o(m.data.action),children:n.jsxs(re.div,{whileHover:{x:2},transition:{duration:.1,ease:Rt},className:"flex w-full items-center gap-2",children:[h&&n.jsx(h,{className:"size-4"}),n.jsx("span",{children:m.data.label})]})})}}}function qk({term:e,isScoped:t=!1,onSelect:s}){return n.jsxs(je,{value:"search-messages-handoff",onSelect:s,className:"flex items-center gap-2 py-2",children:[n.jsx(As,{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:Pt?"⌘⇧F":"Ctrl⇧F"})]})}const ii=8;function Yk({staggerKey:e,isZeroQuery:t,isRoomMode:s,scope:r,hasQuery:o,selectedCwd:a,selectedValue:i,continueRows:c,recent:d,newActions:u,bestMatch:m,rows:p,rooms:f,searchHandoff:h,onFeatureAction:g,onQuickAction:x,onGoToAgentActions:b,onRoomSelect:y,onSessionSelect:C,onCommandSelect:j,onPageSelect:I}){const v=s?f.isError?"Couldn’t load your channels.":f.isLoading?"Loading channels…":f.channels.length===0?"No channels yet.":null:null,N=vk(p,A=>r?Ya(r):Uk[A.item.item.type]),O=r&&!o&&p.length===0&&!m?e0(r):null,P=new Set(p.slice(0,m?ii-1:ii).map(A=>A.key)),R={selectedCwd:a,selectedValue:i,onFeatureAction:g,onQuickAction:x,onGoToAgentActions:b,onRoomSelect:y,onSessionSelect:C,onCommandSelect:j,onPageSelect:I};return n.jsxs(re.div,{variants:Wk,initial:"hidden",animate:"visible",children:[t&&n.jsx(Gk,{continueRows:c,recent:d,newActions:u,selectedCwd:a,selectedValue:i,onSessionSelect:C,onRoomSelect:y,onGoToAgentActions:b,onQuickAction:x}),!t&&m&&n.jsx(Ve,{heading:Kk,children:n.jsx(re.div,{variants:Nn,children:n.jsx(ai,{row:m,...R})})}),!t&&N.map((A,w)=>n.jsx(Ve,{heading:A.label,children:A.rows.map(k=>n.jsx(re.div,{variants:P.has(k.key)?Nn:void 0,children:n.jsx(ai,{row:k,...R})},k.key))},`${A.label}-${w}`)),O&&n.jsx(Ve,{heading:r?Ya(r):void 0,children:n.jsx(je,{disabled:!0,value:"scope-status",className:"text-muted-foreground text-sm",children:O})}),v&&n.jsx(Ve,{heading:"Channels",children:n.jsx(je,{disabled:!0,value:"rooms-status",className:"text-muted-foreground text-sm",children:v})}),h&&n.jsx(Ve,{children:n.jsx(qk,{term:h.term,isScoped:h.isScoped,onSelect:h.onSelect})}),t&&n.jsxs(n.Fragment,{children:[n.jsx($l,{}),n.jsx(ru,{})]})]},e)}function Vk(e,t){const s=Zx(),{dismissedIds:r}=Rl(),o=_(a=>a.promoEnabled);return l.useMemo(()=>o?eb(tb.filter(a=>a.placements.includes(e)),s,r,t):[],[e,t,s,r,o])}const Qk={initial:{opacity:0,y:12},animate:{opacity:1,y:0},exit:{opacity:0,scale:.95,transition:{duration:.15}}};function Xk({promo:e}){const{activate:t,dialog:s}=nb(e),{dismissPromo:r}=Rl(),o=et(),a=e.content.icon;return n.jsxs(re.div,{variants:o?void 0:Qk,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 block truncate text-[13px] font-medium",children:e.content.title}),n.jsx("span",{className:"text-2xs block truncate",children:e.content.shortDescription})]}),n.jsx(Ac,{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(_e,{className:"size-3.5"})}),s]})}const Jk=1;function Zk(e){const[t]=Vk(e,Jk);return l.useMemo(()=>t===void 0?{id:"promo",show:!1,render:()=>null}:{id:`promo:${t.id}`,show:!0,render:()=>n.jsx(Xk,{promo:t})},[t])}const eC=new Set(["downloading","downloaded","install-failed"]);function ci(e,t){return(e==null?void 0:e.state)==="install-failed"?t.state==="downloaded"&&No(t.version,e.version)?t:e:eC.has(t.state)||t.state==="error"?t:e&&(e.state==="downloading"||e.state==="downloaded")?e:t}function tC(){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=>ci(u,d))});return(c=a.getUpdateStatus)==null||c.call(a).then(d=>{d&&s(u=>ci(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:jr("/download/mac"),win32:jr("/download/windows")},sC=Vr.site;function rC(){var t;const e=typeof window>"u"||(t=window.electronAPI)==null?void 0:t.platform;jt((e&&nC[e])??sC)}function oC(){const{data:e}=Pe(),{isDesktop:t,status:s,restart:r}=tC(),o=Yn(),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(u=>{o.mutate({ui:{dismissedUpgradeVersions:[...c,u]}})},[c,o]);return l.useMemo(()=>t?(s==null?void 0:s.state)==="install-failed"?{kind:"desktop-install-failed",downloadFresh:rC}:(s==null?void 0:s.state)!=="downloaded"?{kind:"none"}:{kind:"desktop-restart",restart:r}:i!==null&&a!==void 0&&No(i,a)&&!c.includes(i)?{kind:"command",latestVersion:i,dismiss:()=>d(i)}:{kind:"none"},[t,s,r,i,a,c,d])}const aC="npm update -g dorkos",iC="The update couldn’t install itself. Download a fresh copy. Your settings and agents stay put.",ar="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 cC(e,t,s){return t?"Command copied":s?"Couldn’t copy":`Update ready: v${e}`}function lC({update:e}){const{copied:t,failed:s,copy:r}=$n(),o=l.useCallback(()=>{r(aC)},[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:ar,children:[n.jsx(hb,{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:iC}),n.jsxs("button",{type:"button",onClick:e.downloadFresh,"aria-label":"Download a fresh copy of DorkOS",className:H(ar,"self-start"),children:[n.jsx(Uh,{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:ar,children:[t?n.jsx(zt,{className:"size-3"}):n.jsx(Zr,{className:"size-3"}),cC(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(_e,{className:"size-3"})})]})}function lu({model:e}){const{shouldShowGettingStarted:t,dismiss:s}=Kt(),r=t&&!e.gettingStartedPending,o=oC(),a=cw({gettingStartedCardShown:r}),i=hw({gettingStartedCardShown:r}),c=wd(),d=Zk("dashboard-sidebar"),u=Gn(),m=[{id:"getting-started",show:r,render:()=>n.jsx(dw,{onDismiss:s})},{id:"update",show:o.kind!=="none",render:()=>n.jsx(lC,{update:o})},{id:"identity-prompt",show:a.visible,render:()=>n.jsx(fw,{prompt:a})},{id:"profile-prompt",show:i.visible,render:()=>n.jsx(uw,{prompt:i})},{id:"official-space-offer",show:c.due&&!r,render:()=>n.jsx(wl,{className:"bg-secondary/60 rounded-lg"})},{...d,show:d.show&&!c.pending}];return n.jsx(qx,{candidates:m,ready:u.settled})}const li="dorkos-pinned-agents";function du(){const{data:e}=Pe(),t=go(),{update:s}=mn(),r=t.pinned.length,o=l.useRef(!1);l.useEffect(()=>{if(o.current||e===void 0)return;const a=localStorage.getItem(li);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(li)},[e,r,s])}function uu(e){return l.useMemo(()=>Kh(e),[e])}const dC=1800*1e3,vn={finishedWhileAwayCount:0,idleWhileAwayCount:0};function di(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 uC(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 mC(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<dC||(i+=1)}return i}function hC(e){const{now:t,sessions:s,workingSessionIds:r,sessionStatuses:o,interactions:a,storedLastShownDate:i,settled:c}=e,d=jx(),{update:u}=mn(),[m,p]=l.useState(null),f=l.useRef(!1);l.useEffect(()=>{!c||f.current||(f.current=!0,p({value:i}))},[c,i]);const h=m==null?void 0:m.value,[g]=l.useState(()=>di(a)),x=di(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?vn:{finishedWhileAwayCount:uC(s,r,x,t),idleWhileAwayCount:mC(s,r,o,x,t)},[b,d.isAvailable,d.enabled,d.absenceThresholdMinutes,d.maxPosts,x,t,s,r,o]),C=Hh(t),j=m!==null&&y.finishedWhileAwayCount>0&&h!==C,I=l.useRef(!1);return l.useEffect(()=>{!j||I.current||(I.current=!0,u(v=>Wh(v,C)))},[j,C,u]),{digest:y,lastShownDate:h}}function fC(e,t){const{update:s}=mn(),r=l.useMemo(()=>t?Gh(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)=>qh(d,u),c))},[r,s])}const pC={discoveredUnregisteredPaths:[],nonSystemAgentCount:1,hasEverStartedSession:!0,hasPostedInTeam:!0,hasDorkBotSession:!0};function gC(e){const{agents:t,agentActivity:s,sessionCount:r,rooms:o,rosterResolved:a}=e,i=so(c=>c.candidates);return l.useMemo(()=>{if(!a)return{facts:pC,isResolved:!1};const c=new Set(t.map(p=>p.path)),d=i.map(p=>p.path).filter(p=>!c.has(p)),u=t.find(p=>p.isSystem)??null,m=o.find(p=>p.wellKnown===Yh);return{facts:{discoveredUnregisteredPaths:d,nonSystemAgentCount:t.filter(p=>!p.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 xC=6e4,bC=[],yC={};function mu(e,t){const s=wc(e),r=s.read();return r!==e&&!t(r,e)?(s.write(e),e):r}function vC(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 ts(e){return mu(e,vC)}function jC(e){return mu(e,wC)}function SC(e,t){const s=Ee({select:h=>h.location.pathname}),r=Zh(t,s),o=(r==null?void 0:r.extensionId)??null,a=(r==null?void 0:r.path)??null,i=Xr({strict:!1}),c=s==="/session"?i.session??null:null,d=ef(c),u=s==="/session"?(d==null?void 0:d.cwd)??i.dir??null:null,m=s==="/channels"?i.id??null:null,p=s==="/channels"||s==="/"?i.thread??null:null,f=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||f===null?null:p!==null?{kind:"room",roomId:m,roomKind:"thread",rootEntryId:p}:{kind:"room",roomId:m,roomKind:f},[c,u,o,a,m,f,p])}function hu(e={}){const{coveredSignalIds:t}=e,s=po(xC),r=Gn(),o=Mc(Vh),a=l.useMemo(()=>{var z;return((z=o.data)==null?void 0:z.sessions)??[]},[o.data]),i=vt(_c(z=>{const G={};for(const[Q,ge]of Object.entries(z.statuses))G[Q]=ge.lifecycle;return G})),c=l.useMemo(()=>Object.entries(i).filter(([,z])=>z==="streaming").map(([z])=>z),[i]),d=vt(l.useCallback(z=>z.statusCwds,[])),u=Ps(),m=l.useMemo(()=>{const z=u.data??[];return r.fleetKnown?z:z.filter(G=>G.kind!=="dm")},[u.data,r.fleetKnown]),p=Qh(),f=l.useMemo(()=>p.data??[],[p.data]),h=uo(),g=ts(l.useMemo(()=>{const z={};for(const[G,Q]of Object.entries(h)){if(!G.startsWith("agent:"))continue;const ge=Date.parse(Q);Number.isNaN(ge)||(z[G.slice(6)]=ge)}return z},[h])),b=Ls().data,y=jC(l.useMemo(()=>((b==null?void 0:b.agents)??[]).map(z=>z.projectPath),[b])),j=xo(y).data,{brokenPaths:I}=Sx(),v=ts(pb(y,I,g)),N=l.useMemo(()=>{var z;return((z=o.data)==null?void 0:z.agentActivity)??{}},[o.data]),O=r.fleetKnown?y:bC,P=l.useMemo(()=>O.map(z=>{const G=(j==null?void 0:j[z])??null,Q=N[z],ge=Q===void 0?NaN:Date.parse(Q);return{path:z,runtime:(G==null?void 0:G.runtime)??"claude-code",namespace:(G==null?void 0:G.namespace)??null,isSystem:(G==null?void 0:G.isSystem)??!1,lastActivityAt:Number.isNaN(ge)?null:ge,lastInteractionAt:g[z]??null,attention:v[z]??"inactive"}}),[O,j,N,v,g]),R=l.useMemo(()=>Hc(O,j??{}),[O,j]),A=ts(l.useMemo(()=>{const z={};for(const G of a){const Q=G.userLastMessageAt;Q!==void 0&&(z[`session:${G.id}`]=Q)}return z},[a])),w=ts(l.useMemo(()=>{const z={};for(const G of a){const Q=G.lastTouchedByYouAt;Q!==void 0&&(z[`session:${G.id}`]=Q)}return z},[a])),k=go(),E=l.useMemo(()=>pv(k),[k]),D=hC({now:s,sessions:a,workingSessionIds:c,sessionStatuses:i,interactions:h,storedLastShownDate:E.digest.lastShownDate,settled:r.settled}),T=l.useMemo(()=>({...E,digest:{lastShownDate:D.lastShownDate}}),[E,D.lastShownDate]),L=l.useMemo(()=>Xh(k.muted),[k.muted]),$=cb({mutedRoomIds:L}),B=l.useMemo(()=>({items:$.items,automated:$.automated}),[$.items,$.automated]),q=l.useMemo(()=>{const z=new Map;for(const G of m)z.set(G.id,G.kind==="dm"?"dm":"channel");return z},[m]),oe=l.useMemo(()=>z=>q.get(z)??"channel",[q]),ie=oo(),Y=l.useMemo(()=>ie.map(({id:z,extensionId:G,path:Q,title:ge})=>({id:z,extensionId:G,path:Q,title:ge})),[ie]),X=SC(oe,Y),ne=Jh(z=>z.automatedExpanded),se=Wc(),te=gC({agents:P,agentActivity:N,sessionCount:a.length,rooms:m,rosterResolved:r.phase!=="cold"}),M=l.useMemo(()=>({now:s,sessions:a,workingSessionIds:c,liveSessionCwds:d,sessionStatuses:i,rooms:m,threads:f,agents:P,displayNames:R,attention:se,recents:B,prefs:T,interactions:h,userLastMessageAt:A,lastTouchedByYouAt:w,mentions:yC,...t===void 0?{}:{coveredSignalIds:t},todayAutomatedExpanded:ne,addOns:Y,activeTarget:X,journey:te.facts,digest:D.digest}),[t,s,a,c,d,i,m,f,P,R,se,B,T,h,A,w,ne,Y,X,te.facts,D.digest]);return fC(M,te.isResolved),M}const kC="Heads up and Today fill themselves. Pin it to Library to keep it in place.",CC="Add-ons lists extension pages only.";function fu(e){return e==="addons"?CC:kC}const pu={channels:"Channels",dms:"Direct messages",agents:"Agents"};function ui(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 pu}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 NC(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 An(e){if(typeof e!="object"||e===null)return null;const t=e.type;if(t==="item"){const s=e.ref,r=e.container;return NC(s)&&ui(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 ui(s)?{type:"container",container:s}:null}return null}function gu(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 xu(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 bu(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 kn(e,t){return e.findIndex(s=>Gc(s,t))}function mi(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=kn(o.items,r);i>=0&&(a=i)}return{kind:"move-to-group",ref:t,groupId:s,toIndex:a}}function Wo(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}=bu(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=kn(e.pinned,r),d=kn(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 mi(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=kn(c.items,r),u=kn(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"?mi(e,r,a.groupId,i):{kind:"none"}}function AC(e,t){switch(t.kind){case"none":case"reject-smart-group":case"reject-computed-zone":return e;case"reorder-group":return rf(e,t.from,t.to);case"pin":return sf(e,t.ref);case"unpin":return nf(e,t.ref);case"remove-from-group":return Zo(e,t.ref,null);case"reorder-within-group":return ea(e,t.groupId,t.from,t.to);case"reorder-pinned":return tf(e,t.from,t.to);case"move-to-group":{const s=Zo(e,t.ref,t.groupId);if(t.toIndex===null)return s;const r=s.groups.find(o=>o.id===t.groupId);return r?ea(s,t.groupId,r.items.length-1,t.toIndex):s}}}function EC(e,t,s){return AC(e,Wo(e,t,s))}function IC(e,t){return e.type==="group"?`Picked up section ${t.groupName(e.groupId)}.`:`Picked up ${t.itemName(e.ref)}.`}function RC(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. ${fu(e.zone)}`;case"none":return""}}function TC(e,t){if(e===null)return"";const{container:s}=bu(e);switch(s.kind){case"pinned":return"Over Pinned.";case"ungrouped":return`Over ${s.section===void 0?"Agents":pu[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 DC(e){const t=r=>gu(An(r.active.data.current)),s=r=>{var o;return xu(An((o=r.over)==null?void 0:o.data.current))};return{onDragStart:r=>{const o=t(r);return o?IC(o,e()):void 0},onDragOver:r=>{if(t(r))return TC(s(r),e())||void 0},onDragEnd:r=>{const o=t(r);if(!o)return;const a=e(),i=Wo(a.prefs,o,s(r));return i.kind==="none"?"Movement cancelled. Item returned to its place.":RC(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 OC({label:e}){const t=et();return n.jsx(re.div,{initial:{scale:1},animate:{scale:t===!0?1:af},transition:{duration:t===!0?0:of},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 MC=60;function _C(e){const t=document.querySelectorAll(`[${ta}]`);for(const s of t)if(s.getAttribute(ta)===e)return s.querySelector(`[${cf}]`);return null}function PC(e,t=MC){let s=t;const r=()=>{const o=_C(e);if(o!==null){o.focus();return}s-- >0&&requestAnimationFrame(r)};requestAnimationFrame(r)}const LC={start:["Space"],cancel:["Escape"],end:["Space","Enter","Tab"]};function FC(e,t){switch(t.kind){case"move-to-group":return Hs(t.groupId,t.ref);case"remove-from-group":return Hs("ungrouped",t.ref);case"unpin":{const s=e.groups.find(r=>r.items.some(o=>Gc(o,t.ref)));return Hs((s==null?void 0:s.id)??"ungrouped",t.ref)}default:return null}}function $C({data:e,itemName:t,groupName:s}){const r=e.type==="group"?s(e.groupId):e.type==="item"?t(e.ref):"";return n.jsx(OC,{label:r})}function BC({children:e,displayNames:t,rooms:s}){const r=Ae(),o=go(),{update:a}=mn(),[i,c]=l.useState(null),d=Jt(o),u=Jt(t),m=l.useMemo(()=>Object.fromEntries(s.map(C=>[C.id,C.slug??C.title])),[s]),p=Jt(m),f=jc(ps(Cc,{activationConstraint:{distance:8}}),ps(kc,{coordinateGetter:wr,keyboardCodes:LC}));if(r)return n.jsx(n.Fragment,{children:e});const h=C=>{var j;return((j=d.read().groups.find(I=>I.id===C))==null?void 0:j.name)??"group"},g=C=>C.kind==="agent"?u.read()[C.path]??C.path.split("/").pop()??"Agent":p.read()[C.roomId]??"room",x=DC(()=>({prefs:d.read(),itemName:g,groupName:h})),b=C=>{c(An(C.active.data.current))},y=C=>{var O;c(null);const j=gu(An(C.active.data.current));if(j===null)return;const I=xu(An((O=C.over)==null?void 0:O.data.current)),v=Wo(d.read(),j,I);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(fu(v.zone),{description:g(v.ref)});return}if(v.kind==="none"||(a(P=>EC(P,j,I)),!(C.activatorEvent instanceof KeyboardEvent)))return;const N=FC(d.read(),v);N!==null&&PC(N)};return n.jsx(lf,{value:!0,children:n.jsxs(Sc,{sensors:f,collisionDetection:vc,accessibility:{announcements:x},onDragStart:b,onDragEnd:y,onDragCancel:()=>c(null),children:[e,n.jsx(df,{children:i?n.jsx($C,{data:i,itemName:g,groupName:h}):null})]})})}function zC(){var r;const e=$s(!0),t=Ms();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(F,{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(UC,{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 UC({connection:e}){var o,a,i;const t=uf(e.access),s=mf(e.ref,t.capabilities.read,t.fingerprint),r=Ms();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(F,{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(hf,{...ye.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."})]})}const KC=[2,3,3],hi=["w-14","w-10","w-16"];function HC(){return n.jsx("div",{className:"flex flex-col gap-1","data-testid":"sidebar-skeleton","aria-hidden":!0,children:KC.map((e,t)=>n.jsxs("div",{className:"flex flex-col",children:[n.jsx("div",{className:H("flex h-7 items-center",ff),children:n.jsx(Dt,{className:H("h-2.5 rounded-sm",hi[t])})}),Array.from({length:e},(s,r)=>n.jsx(pf,{showIcon:!0},r))]},hi[t]))})}const WC=.16,GC=4,qC=.03,YC={hidden:{},shown:{transition:{staggerChildren:qC}}},VC={hidden:{opacity:0,y:GC},shown:{opacity:1,y:0}};function fi(e){return{duration:e===!0?0:WC}}const QC=2500;function pi(e){var t;return((t=e.zones.find(s=>s.id==="now"))==null?void 0:t.needsYouCount)??0}function XC(e){const t=et(),[s,r]=l.useState(!1),o=l.useRef(pi(e)),a=pi(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),QC);return()=>clearTimeout(u)},[a,i,t]),s}function yu(){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 gi=5e3;function JC(e){const{inside:t,handlers:s}=yu(),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>=gi){c.current=!1,a(!0);return}const m=setTimeout(()=>{c.current=!1,a(!0)},gi-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 ZC=1e3;function vu(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)},ZC);return()=>clearTimeout(a)},[e]),t}function eN(){return n.jsxs("p",{"data-slot":"sidebar-all-clear",className:"text-sidebar-foreground/70 flex min-h-7 items-center gap-1.5 px-2 text-[13px]",children:[n.jsx(zt,{className:"text-status-success size-3.5 shrink-0","aria-hidden":!0}),"All clear"]})}const tN=1,xi=40;function nN({onCommit:e,onCancel:t}){const[s,r]=l.useState(""),o=l.useRef(null),a=l.useRef(!1),i=gf(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<tN||u.length>xi){t();return}e(u)},d=u=>{u.key==="Enter"?(u.preventDefault(),c()):u.key==="Escape"&&(u.preventDefault(),a.current=!0,t())};return n.jsx(xf,{children:n.jsxs("div",{className:"flex w-full items-center gap-2 rounded-md px-2 py-1.5",children:[n.jsx(bf,{className:"text-muted-foreground size-3.5 shrink-0"}),n.jsx("input",{ref:o,value:s,maxLength:xi,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:H("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 us({zone:e,onToggleAll:t,allClear:s=!1,lead:r,silenceLiveRegion:o=!1}){const a=vu(e.liveRegionText);return n.jsxs("section",{"aria-label":e.label,"data-sidebar-zone":e.id,className:H("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(eN,{}):n.jsxs(n.Fragment,{children:[e.id==="library"&&e.sections.length>0&&n.jsx(sN,{}),e.sections.map(i=>n.jsx(qc,{section:i,onToggleAll:t},i.id))]})]})}function sN(){const e=yf();return e.groupCreation===null?null:n.jsx(vf,{children:n.jsx(nN,{onCommit:e.commitNewGroup,onCancel:e.cancelNewGroup})})}const rN='[aria-current="page"]';function oN(e,t,s){const r=et(),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(rN);if(!(c instanceof HTMLElement))return;const d=!a&&r!==!0;c.scrollIntoView({block:"nearest",behavior:d?"smooth":"auto"})},[t,e,s])}function aN(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 iN(e,t){const{inside:s,handlers:r}=yu(),[o,a]=l.useState(null),[i,c]=l.useState(s);i!==s&&(c(s),a(s?e.map(p=>p.key):null));const[d,u]=l.useState(t);return d!==t&&(u(t),a(s?e.map(p=>p.key):null)),{rows:o===null?[...e]:aN(e,o),handlers:r}}const cN="anchor:active-session";function lN({zone:e,onToggleAll:t,silenceLiveRegion:s=!1}){var p;const r=l.useRef(null),o=e.sections.find(f=>f.id==="today"),a=l.useMemo(()=>(o==null?void 0:o.rows)??[],[o]),i=((p=a.find(f=>f.reason===cN))==null?void 0:p.key)??null,c=iN(a,i),d=Gn();oN(r,i,d.settled);const u=l.useMemo(()=>dN(a),[a]),m=l.useMemo(()=>({...e,sections:e.sections.map(f=>f.id==="today"?{...f,rows:c.rows}:f)}),[e,c.rows]);return n.jsx("div",{ref:r,...c.handlers,children:n.jsx(us,{zone:m,onToggleAll:t,silenceLiveRegion:s,lead:n.jsx(uN,{roomIds:u})})})}function dN(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 uN({roomIds:e}){const t=Ae(),s=wf();return!t||e.length===0?null:n.jsx(mN,{count:e.length,onCatchUp:()=>s(e)})}function mN({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:H("text-sidebar-foreground/80 hover:bg-sidebar-accent/70 hover:text-sidebar-foreground focus-ring","flex w-full items-center gap-2 rounded-md px-2 text-[13px] font-medium",Sf,qn),children:[n.jsx(jf,{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 bi={id:"now",label:Nf.now,sections:[],reason:"zone:now"};function hN(e){return e.collapsible?e.id.startsWith("group:")||Vc(e.id)!==null:!1}function Hr({model:e,zoneIds:t,nowSlot:s=null,silenceLiveRegion:r=!1}){var P;const{update:o}=mn(),a=kf(),i=xs(a.destination),d=Yc(i??void 0).visible?i:null,u=Gn(),m=et(),{model:p,handlers:f}=JC(e),h=e.zones.flatMap(R=>R.sections).filter(hN),g=l.useCallback(R=>t===void 0||t.includes(R),[t]),x=l.useCallback(()=>{if(h.length===0)return;const R=h.some(A=>!A.collapsed);o(A=>{let w=A;for(const k of h){if(k.id.startsWith("group:")){w=Cf(w,k.id.slice(6),R);continue}const E=Vc(k.id);E!==null&&(w=na(w,E,R))}return w})},[h,o]),b=g("library")?(P=e.zones.find(R=>R.id==="library"))==null?void 0:P.sections.find(R=>R.id==="addons"):void 0,y=(b==null?void 0:b.collapsed)??!1,C=l.useCallback(()=>o(R=>na(R,"addons",!y)),[y,o]),j=XC(e),I=e.zones.some(R=>R.id==="now"),v=I||e.zones.some(R=>R.id==="getting-started"),N=s!==null&&!I&&g("now"),O={variants:VC,transition:fi(m)};return d?n.jsxs("div",{className:"flex min-h-0 flex-col","data-community-context":d,children:[n.jsx(zC,{}),b!==void 0&&n.jsx(qc,{section:b,onToggleAll:C})]}):n.jsx("div",{className:"flex flex-col gap-1",...f,children:n.jsx(Qe,{mode:"wait",initial:!1,children:u.phase==="cold"?n.jsx(re.div,{exit:{opacity:0},transition:fi(m),children:n.jsx(HC,{})},"skeleton"):n.jsxs(re.div,{className:"flex flex-col gap-1",variants:YC,initial:u.startedWarm?!1:"hidden",animate:"shown",children:[N&&n.jsx(re.div,{...O,children:n.jsx(us,{zone:bi,onToggleAll:x,lead:s,silenceLiveRegion:r})}),j&&!v&&!N&&g("now")&&n.jsx(re.div,{...O,children:n.jsx(us,{zone:bi,onToggleAll:x,allClear:!0,silenceLiveRegion:r})}),p.zones.filter(R=>g(R.id)).map(R=>n.jsx(re.div,{...O,children:R.id==="today"?n.jsx(lN,{zone:R,onToggleAll:x,silenceLiveRegion:r}):n.jsx(us,{zone:R,onToggleAll:x,silenceLiveRegion:r,...R.id==="now"?{lead:s}:{}})},R.id))]},"zones")})})}function fN(){du();const e=hu(),t=uu(e),s=Gn();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(Af,{className:"sidebar-scroll-edges px-2 py-3",children:n.jsx(Qc,{activeTarget:e.activeTarget,children:n.jsx(BC,{displayNames:e.displayNames,rooms:e.rooms,children:n.jsx(Hr,{model:t})})})}),n.jsx(lu,{model:t})]})}const pN=2;function gN(){return{label:"Active now",rules:{statuses:["needs-attention","active"]}}}function xN(e){const t=new Map;for(const s of e)t.set(s.runtime,(t.get(s.runtime)??0)+1);return Array.from(t.entries()).filter(([,s])=>s>=pN).map(([s,r])=>({runtime:s,count:r,label:rt(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 yi="agent:";function bN(){const[e]=Wn(),t=uo(),{data:s}=Ls(),r=l.useMemo(()=>((s==null?void 0:s.agents)??[]).map(i=>i.projectPath),[s]),{data:o}=xo(r),a=l.useMemo(()=>Hc(r,o??{}),[r,o]);return l.useMemo(()=>{const i=new Set(r);let c=null,d=-1/0;for(const[m,p]of Object.entries(t)){if(!m.startsWith(yi))continue;const f=m.slice(yi.length);if(!i.has(f))continue;const h=Date.parse(p);Number.isNaN(h)||h<=d||(d=h,c=f)}const u=e!==null&&i.has(e)?e:c;return u===null?null:{path:u,displayName:a[u]??u}},[a,t,r,e])}function yN(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 vN(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:gn,opensInput:!1,run:()=>e.onCreatePresetSmartGroup(r)})),{kind:"action",id:"new-group-custom",label:"Custom rules",icon:gn,opensInput:!0,run:e.onOpenSmartGroupDialog}],s=[t.length===0?{kind:"action",id:"new-group",label:"Section",icon:gn,opensInput:!0,run:e.onNewGroup}:{kind:"submenu",id:"new-group",label:"Section",icon:gn,items:[{kind:"action",id:"new-group-empty",label:"Empty section",icon:gn,opensInput:!0,run:e.onNewGroup},...t]}];return[{kind:"action",id:"new-session",label:"Chat",icon:Kc,opensInput:!1,...e.showSessionShortcut?{hint:en(Dn.NEW_SESSION)}:{},run:e.onNewSession},...e.lastUsedAgentName===null?[]:[{kind:"note",id:"new-session-note",icon:Sb,text:`Starts with ${e.lastUsedAgentName} (last used)`}],{kind:"separator",id:"sep-rooms"},{kind:"action",id:"new-channel",label:"Channel",icon:bo,opensInput:!0,run:e.onNewChannel},{kind:"action",id:"new-message",label:"Group message",icon:Ol,opensInput:!0,run:e.onNewMessage},{kind:"separator",id:"sep-agents"},{kind:"action",id:"new-agent",label:"Agent",icon:Df,opensInput:!0,run:e.onNewAgent},...s]}function wN(){const e=Ae(),t=Xn(L=>L.menuOpen),s=Xn(L=>L.preselect),r=Xn(L=>L.setMenuOpen),o=Xn(L=>L.requestNewGroup),a=Re(),i=Fc(),[,c]=Wn(),d=bb(),u=bN(),{update:m}=mn(),[p,f]=l.useState(!1),[h,g]=l.useState(!1),[x,b]=l.useState(!1),{data:y}=Ls(),C=l.useMemo(()=>((y==null?void 0:y.agents)??[]).map(L=>L.projectPath),[y]),{data:j}=xo(C),I=l.useMemo(()=>C.map(L=>{var $,B;return{projectPath:L,runtime:(($=j==null?void 0:j[L])==null?void 0:$.runtime)??"claude-code",namespace:((B=j==null?void 0:j[L])==null?void 0:B.namespace)??null,attention:"inactive",lastActivityAt:null}}),[C,j]),v=Ef(I),N=l.useMemo(()=>v?[gN(),...xN(I)]:[],[I,v]),O=l.useMemo(()=>{const L=new Map;for(const $ of I)L.has($.runtime)||L.set($.runtime,rt($.runtime).label);return Array.from(L,([$,B])=>({value:$,label:B})).sort(($,B)=>$.label.localeCompare(B.label))},[I]),P=l.useMemo(()=>{const L=new Set;for(const $ of I)$.namespace&&L.add($.namespace);return Array.from(L).sort()},[I]),R=l.useCallback((L,$)=>m(B=>If(B,L,$).next),[m]),A=l.useCallback(L=>{gs.getState().recordOpened("room",L.id),a({...ye.channels(),search:{id:L.id}})},[a]),w=l.useCallback(()=>i(u==null?void 0:u.path),[u,i]);yN(w);const k=l.useCallback(L=>{const[$]=L;if($!==void 0&&yb(L)){c($.agentPath,{onOpened:()=>gs.getState().recordOpened("agent",$.agentPath)});return}const B=Rf(L.map(q=>q.displayName));d.mutate({agentPaths:L.map(q=>q.agentPath),title:B},{onSuccess:A})},[A,c,d]),E=vN({onNewSession:w,lastUsedAgentName:(u==null?void 0:u.displayName)??null,onNewChannel:()=>f(!0),onNewMessage:()=>g(!0),onNewAgent:()=>Es.getState().open(),onNewGroup:()=>o(),smartGroupPresets:N,onCreatePresetSmartGroup:L=>R(L.label,L.rules),onOpenSmartGroupDialog:()=>b(!0),showSessionShortcut:Ue()}),D=Xc(E),T=l.useRef(null);return l.useEffect(()=>{if(!t||s===null)return;const L=requestAnimationFrame(()=>{var $,B;(B=($=T.current)==null?void 0:$.querySelector(`[data-menu-item-id="${s}"]`))==null||B.focus()});return()=>cancelAnimationFrame(L)},[t,s]),n.jsxs(n.Fragment,{children:[n.jsxs(Rs,{open:t,onOpenChange:r,children:[n.jsx(Ts,{asChild:!0,children:n.jsxs("button",{type:"button","data-testid":"sidebar-new-button",className:H("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&&H(qn,"px-3")),children:[n.jsx(kt,{className:"size-3.5"}),"New"]})}),n.jsx(Ds,{ref:T,align:"end",className:"w-56",onCloseAutoFocus:D.onCloseAutoFocus,children:n.jsx(Sr,{variant:"dropdown",nodes:D.nodes})})]}),p&&n.jsx(vb,{open:!0,onOpenChange:L=>!L&&f(!1),onCreated:A}),n.jsx(wb,{open:h,onOpenChange:g,onStart:k,hideTrigger:!0}),n.jsx(Tf,{open:x,onOpenChange:b,mode:"create",runtimeOptions:O,namespaceOptions:P,onSubmit:({name:L,rules:$})=>R(L,$)})]})}function jN(){const e=_(s=>s.setGlobalPaletteOpen),t=Ae();return n.jsxs("button",{type:"button","data-testid":"sidebar-search-pill",onClick:()=>e(!0),className:H("bg-sidebar-accent/40 text-sidebar-foreground/60 hover:bg-sidebar-accent/70 hover:text-sidebar-foreground focus-visible:ring-sidebar-ring flex w-full items-center gap-1.5 rounded-md px-2 py-1.5 text-[13px] outline-hidden transition-colors duration-150 focus-visible:ring-2",t&&qn),children:[n.jsx(hs,{className:"size-(--size-icon-sm) shrink-0"}),n.jsx("span",{className:"truncate",children:"Jump to anything…"}),n.jsx(Jc,{className:"bg-sidebar-accent text-sidebar-foreground/70 ml-auto shrink-0 border-transparent",children:en(Dn.COMMAND_PALETTE)})]})}function SN(e){const t=[];return e.you!==null&&t.push({kind:"action",id:"you",label:e.you.name,description:"View profile",icon:no,leading:e.you.face,guardsFocus:!0,run:e.you.onOpen}),t.push({kind:"action",id:"dorkos-account",label:"DorkOS account",description:e.accountStatus,icon:_l,guardsFocus:!0,run:e.onOpenAccount},{kind:"action",id:"settings",label:"Settings",icon:Fs,guardsFocus:!0,run:e.onOpenSettings}),t}function kN(e){return e.isDevMode?[{kind:"separator",id:"sep-version"},{kind:"note",id:"version",icon:sa,text:"Development build"}]:e.version===null?[]:[{kind:"separator",id:"sep-version"},{kind:"action",id:"version",label:`v${e.version} beta`,icon:sa,opensInput:!1,hint:"Check for updates",run:e.onCheckForUpdates}]}function CN(e){const t=(e==null?void 0:e.trim())??"";return t.length===0||t===Of?"Your team":t.endsWith("s")?`${t}’ team`:`${t}’s team`}function NN(e,t){const s=Mf(e);return l.createElement(vr,{size:t,kind:s.kind,color:s.color,emoji:s.emoji,imageUrl:s.imageUrl,fallback:s.fallback,origin:s.origin})}function wu(e="xs"){var i;const t=eo(),{open:s}=tt(),{open:r}=yo(),o=JS(),a=((i=t.data)==null?void 0:i.members.find(c=>c.isSelf))??null;return{you:a===null?null:{name:a.displayName,face:NN(a,e),onOpen:()=>r(a.id)},accountStatus:XS(o),onOpenAccount:()=>s("account"),onOpenSettings:()=>s()}}function AN(e=[]){var u;const t=eo(),s=ce(),r=me(),o=wu(),a=((u=t.data)==null?void 0:u.members.find(m=>m.isSelf))??null,{data:i,refetch:c}=ke({queryKey:Me.current(),queryFn:()=>s.getConfig(),staleTime:ec}),d=l.useCallback(async()=>{var h,g;await r.invalidateQueries({queryKey:Me.all});const m=await c(),p=(h=m.data)==null?void 0:h.version,f=((g=m.data)==null?void 0:g.latestVersion)??null;if(p===void 0){ue.error("Couldn’t check for updates");return}if(f!==null&&No(f,p)){ue.success(`Version ${f} is available`);return}ue.success("You’re up to date")},[r,c]);return{teamName:CN((a==null?void 0:a.displayName)??null),nameUnknown:t.isPending,identityNodes:SN(o),nodes:[...e,...kN({version:(i==null?void 0:i.version)??null,isDevMode:(i==null?void 0:i.isDevMode)??!1,onCheckForUpdates:()=>void d()})]}}const EN=Zc("/self-hosting/space-server");function IN(e){const t=[];for(const s of e)s.hostOperator===!0&&!t.includes(s.pinnedOrigin)&&t.push(s.pinnedOrigin);return t}function RN(e){var o,a,i;const t=e.status!=="pending"&&((o=e.access)==null?void 0:o.state)!=="unverified",s=((i=(a=e.access)==null?void 0:a.lastKnown)==null?void 0:i.lifecycle)??null,r=e.status==="connected";return{hostReachable:t,canInvite:t&&r&&s==="active",canOpenSettings:t,canLeave:t&&r}}function ns(e){try{return new URL(e).host}catch{return e}}function TN(e){const t=[],s=e.selected;if(s){const{connection:i,availability:c}=s,d=[],u={host:ns(i.pinnedOrigin)};c.canInvite&&d.push({kind:"action",id:"community-invite",label:"Invite people",icon:Pf,external:u,run:e.onInvite}),c.canOpenSettings&&d.push({kind:"action",id:"community-settings",label:"Space settings",icon:Fs,external:u,run:e.onOpenSettings}),s.canMoveUp&&d.push({kind:"action",id:"community-move-up",label:"Move up",icon:Lf,run:()=>e.onMove("up")}),s.canMoveDown&&d.push({kind:"action",id:"community-move-down",label:"Move down",icon:Ff,run:()=>e.onMove("down")}),d.push({kind:"separator",id:"community-sep-end"}),d.push({kind:"action",id:"community-disconnect",label:"Disconnect",icon:Eb,opensInput:!0,destructive:!0,run:e.onDisconnect}),c.canLeave&&d.push({kind:"action",id:"community-leave",label:"Leave space",icon:$f,opensInput:!0,external:u,run:e.onLeave}),t.push({kind:"submenu",id:"community-actions",label:`Manage ${i.label}`,icon:Ar,items:d})}e.onJoinOfficial&&t.push({kind:"action",id:"join-official-space",label:"Join the DorkOS community",icon:kr,opensInput:!0,run:e.onJoinOfficial});const r=e.onJoin;if(!r)return t;const o=[...e.creationOrigins.map(i=>({kind:"action",id:e.creationOrigins.length===1?"add-community-create":`add-community-create-${ns(i)}`,label:e.creationOrigins.length===1?"Create a space on your server":`Create a space on ${ns(i)}`,icon:Iy,opensInput:!0,external:{host:ns(i)},run:()=>e.onCreate(i)})),{kind:"action",id:"add-community-deploy",label:"Run your own space server",icon:_f,run:e.onDeploy}],a=[];return e.hosting&&a.push({kind:"action",id:"add-community-start",label:"Start a space",icon:vo,opensInput:!0,run:e.hosting.onStart}),a.push({kind:"action",id:"add-community-join",label:"Join a space",icon:kr,opensInput:!0,run:r}),e.hosting&&a.push({kind:"action",id:"add-community-yours",label:"Your spaces",icon:Ny,guardsFocus:!0,run:e.hosting.onOpenYourSpaces}),a.push({kind:"separator",id:"add-community-sep-advanced"},{kind:"submenu",id:"add-community-advanced",label:"Advanced",icon:Ml,items:o}),t.push({kind:"submenu",id:"add-community",label:"Add a space",icon:kt,items:a}),t}function ju(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 DN(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=ju(e);if(s.membershipState!=="active")return s.membershipState.replace("-"," ");if(s.availability!=="online")return s.availability}function ON(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 MN(e){return e.charAt(0).toLowerCase()+e.slice(1)}function _N(e,t){const s=Bf(),r=Yc(e),o=vl();return{spaces:s.enabled,anySpace:s.anySpace,selectedRef:r.visible?e:void 0,visible:(t??[]).filter(a=>zf(a,s.enabled)),joinOfficial:o.link!==null&&!o.joined?o.join:null}}function PN(e){const t=ra(r=>r.url),s=ra(r=>r.take);l.useEffect(()=>{if(t===null)return;const r=s();r!==null&&e(r)},[t,s])}function LN({connection:e,onOpenChange:t,onDisconnected:s}){var f;const r=el(),o=md(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"?[]:(f=o.data)==null?void 0:f.agents,u=d===void 0&&o.fetchStatus==="fetching",m=d?fd(c,d):u?null:pd(c);function p(){e&&r.mutate(e,{onSuccess:h=>{t(!1);const g=gd(e.label,h);g.tone==="success"?ue.success(g.message):ue.warning(g.message,{duration:15e3}),s(e)}})}return n.jsx(Uf,{open:e!==null,onOpenChange:h=>{h||r.reset(),t(h)},children:n.jsxs(Kf,{children:[n.jsxs(Hf,{children:[n.jsxs(Wf,{children:["Disconnect this DorkOS from ",c,"?"]}),n.jsx(Gf,{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(F,{size:"sm",variant:"outline",onClick:()=>void o.refetch(),children:"Check again"})]}),r.isError&&n.jsx("p",{role:"alert",className:"text-destructive text-sm",children:"Couldn’t disconnect. Check DorkOS is running and try again."}),n.jsxs(qf,{children:[n.jsx(Yf,{disabled:r.isPending,children:"Keep connected"}),n.jsx(F,{variant:"destructive",disabled:r.isPending||u,onClick:p,children:r.isPending?"Disconnecting…":"Disconnect"})]})]})})}function FN(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 ${BN(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 ${Vf((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 $N(e){const t=typeof e=="object"&&e!==null?e.code:"";return t!=="COMMUNITY_RATE_LIMITED"&&t!=="COMMUNITY_UPGRADE_REQUIRED"}function BN(e){try{return`${new URL(e??"").origin}/your-space`}catch{return"https://example.com/acme"}}const zN="That invitation link is incomplete or isn’t secure. Copy the whole link again.";function UN(e){let t;try{t=new URL(e.trim())}catch{return!1}return/^\/(?:c\/[^/]+\/)?join\/?$/u.test(t.pathname)&&!Cr(e)}function KN(e){const t=new URL(e.trim()),s=/^(\/c\/[^/]+)\/join\/?$/u.exec(t.pathname);return s?`${t.origin}${s[1]}`:t.origin}function HN({request:e,onOpenChange:t,installName:s,onConnected:r}){var $;const o=Fn(!0),a=$s(!0),i=Qf(o),c=e!==null,d=Ws(B=>B.links),u=Ws(B=>B.rememberLink),m=Ws(B=>B.ending),p=(o==null?void 0:o.ownerKey)??null,[f,h]=l.useState(null),g=B=>h(B===null?null:{owner:p,ref:B}),[x,b]=l.useState(null),[y,C]=l.useState(null),[j,I]=l.useState((m==null?void 0:m.id)??0),[v,N]=l.useState(null),[O,P]=l.useState(null);e!==O&&(P(e),e&&(g(e.ref),b(null))),f!==null&&p!==null&&f.owner!==p&&(f.owner===null?h({owner:p,ref:f.ref}):(h(null),b(null),N(null)));const R=f!==null&&f.owner===p?f.ref:null,A=R===null||($=a.data)==null?void 0:$.find(B=>B.ref===R),w=!A&&y!==null&&!y.settled&&y.address===i&&y.connection.ref===R?y.connection:null,k=A??w;if(k&&p!==null&&((v==null?void 0:v.owner)!==p||v.ref!==k.ref||v.label!==k.label)&&N({owner:p,ref:k.ref,label:k.label}),m&&m.id!==j)I(m.id),m.ref===R&&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&&R!==null&&!k&&a.isSuccess){const B=(v==null?void 0:v.owner)===p&&v.ref===R?v.label:"this space";g(null),b({address:i,value:`Approval for ${B} ended somewhere else. Connect again to continue.`})}Xf(c&&(k==null?void 0:k.status)==="pending"?k.ref:null);const E=Jf((k==null?void 0:k.status)==="pending"?k:null),D=c&&(k==null?void 0:k.status)==="connected"?k.ref:null,T=l.useRef(r),L=l.useRef(t);return l.useEffect(()=>{T.current=r,L.current=t}),l.useEffect(()=>{D===null||!k||(ue.success(`${k.label} is connected.`,{id:`community-approval-${D}`}),L.current(!1),T.current(D))},[D]),n.jsx(pt,{open:c,onOpenChange:t,children:n.jsx(gt,{className:"!min-h-0 sm:max-w-md",children:n.jsx(WN,{authority:o,connection:k,check:E,approvalUrl:k&&(d==null?void 0:d.address)===i?d.urls[k.ref]:void 0,notice:(x==null?void 0:x.address)===i?x.value:"",installName:s,initialUrl:O==null?void 0:O.url,onStarted:B=>{u(i,B.connection.ref,B.approvalUrl),C({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=>C(q=>(q==null?void 0:q.connection.ref)===B?{...q,settled:!0}:q),onEnded:B=>{g(null),b({address:i,value:B})},onCancelled:B=>{t(!1),ue.success(`Approval for ${B} was cancelled.`)},onClose:()=>t(!1)})})})}function WN({authority:e,connection:t,check:s,approvalUrl:r,notice:o,installName:a,initialUrl:i,onStarted:c,onStartSettled:d,onEnded:u,onCancelled:m,onClose:p}){const f=ce(),h=me(),g=Ic(),x=l.useId(),[b,y]=l.useState(i??""),[C,j]=l.useState(null),[I,v]=l.useState(!1),[N,O]=l.useState(a),P=l.useRef(null),R=l.useRef(null),A=t===null?"form":t.status,w=l.useRef(A);l.useEffect(()=>{var X,ne;const Y=w.current;w.current=A,Y!==A&&(A==="form"?(X=P.current)==null||X.focus():A==="pending"&&((ne=R.current)==null||ne.focus()))},[A]);const k=Bt({mutationFn:async Y=>{if(!e||!It(e))throw new Error("Community owner is still loading.");const X=await f.startCommunityConnection({url:Y,installName:N.trim()});if(!It(e))throw new Error("Community owner changed.");return X},onSuccess:async Y=>{y(""),c(Y),e&&await h.invalidateQueries({queryKey:yt.connections(e)}),d(Y.connection.ref)}}),E=el(),D=md((t==null?void 0:t.status)==="reconnect-required"?t:null),T=k.error;l.useEffect(()=>{var Y;(T||I)&&((Y=P.current)==null||Y.focus())},[T,I]);const L=Cr(b),$=I?zN:k.error?FN(k.error,k.variables):null;function B(Y){if(Y.preventDefault(),!(!b.trim()||k.isPending)){if(UN(b)){k.reset(),v(!0);return}if(Cr(b)){if(!jt(g.linkFor(b.trim())))return;y(KN(b)),j({host:new URL(b.trim()).host,withAccount:g.signsInWithAccount(b)}),k.reset();return}N.trim()&&k.mutate(b.trim())}}function q(Y){E.mutate(Y,{onSuccess:X=>{if(Y.status==="pending")m(Y.label);else{const ne=gd(Y.label,X);u(ne.tone==="success"?`${Y.label} is disconnected. Connect again to continue.`:ne.message)}},onSettled:()=>{e&&h.invalidateQueries({queryKey:yt.connections(e)})}})}const oe=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(ut,{children:[n.jsx(Xe,{children:"Join a space"}),n.jsx(mt,{children:"Bring a space’s channels here. You approve it on the space’s site."})]}),n.jsxs(wt,{className:"space-y-4 py-4",children:[oe,n.jsxs("div",{className:"space-y-1.5",children:[n.jsx(ze,{htmlFor:`${x}-url`,children:"Space address or invitation link"}),n.jsx(ft,{ref:P,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":I||k.error&&$N(k.error)?!0:void 0,required:!0,autoComplete:"off",value:b,onChange:Y=>{y(Y.target.value),j(null),v(!1)},disabled:k.isPending||!e}),n.jsx("p",{id:`${x}-url-hint`,"aria-live":"polite",className:"text-muted-foreground text-xs",children:C?C.withAccount?`Join on ${C.host} with your DorkOS account in the new tab, then connect.`:`Finish joining on ${C.host} in the new tab, then connect.`:"Its link, short address or an invitation link."})]}),n.jsxs("div",{className:"space-y-1.5",children:[n.jsx(ze,{htmlFor:`${x}-name`,children:"Name for this installation"}),n.jsx(ft,{id:`${x}-name`,required:!0,maxLength:120,"aria-describedby":`${x}-name-hint`,value:N,onChange:Y=>O(Y.target.value),disabled:k.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(Xt,{children:[n.jsx(F,{type:"button",variant:"outline",onClick:p,children:"Cancel"}),n.jsx(F,{type:"submit",disabled:k.isPending||!b.trim()||!L&&(!e||!N.trim()),children:k.isPending?"Connecting…":L?"Open invitation":"Connect"})]})]});const ie=n.jsx("p",{className:"text-muted-foreground text-xs break-all",children:t.pinnedOrigin});if(t.status==="reconnect-required"){const Y=!D.data&&D.fetchStatus==="fetching",X=D.data?fd(t.label,D.data.agents):Y?null:pd(t.label);return n.jsxs(n.Fragment,{children:[n.jsxs(ut,{children:[n.jsxs(Xe,{children:["Reconnect ",t.label]}),n.jsxs(mt,{children:["DorkOS can’t reach ",t.label,"’s channels. Disconnect, then connect again."]})]}),n.jsxs(wt,{className:"space-y-3 py-4",children:[ie,X&&n.jsx("p",{className:"text-sm",children:X}),D.isError&&!D.data&&!Y&&n.jsxs("div",{role:"alert",className:"flex flex-col items-start gap-2 text-sm sm:flex-row sm:items-center sm:justify-between sm:gap-3",children:[n.jsxs("p",{className:"text-destructive",children:["Couldn’t check which of your agents are on ",t.label,"."]}),n.jsx(F,{size:"sm",variant:"outline",onClick:()=>void D.refetch(),children:"Check again"})]}),E.isError&&n.jsx("p",{role:"alert",className:"text-destructive text-sm",children:"Couldn’t disconnect. Check DorkOS is running and try again."})]}),n.jsxs(Xt,{children:[n.jsx(F,{type:"button",variant:"outline",onClick:p,children:"Close"}),n.jsx(F,{disabled:E.isPending||Y,onClick:()=>q(t),children:E.isPending?"Disconnecting…":"Disconnect"})]})]})}return n.jsxs(n.Fragment,{children:[n.jsxs(ut,{children:[n.jsxs(Xe,{children:["Approve on ",t.label]}),n.jsx(mt,{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(wt,{className:"space-y-3 py-4",children:[ie,oe,n.jsxs("p",{className:"flex items-center gap-2 text-sm",children:[n.jsx(Ne,{})," Waiting for your approval"]}),r?n.jsx(F,{asChild:!0,children:n.jsxs("a",{ref:R,href:g.linkFor(r),target:"_blank",rel:"noopener noreferrer",children:["Open ",t.label," to approve",n.jsx(Zt,{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."}),(E.isError||!!s.error)&&n.jsxs("div",{role:"alert",className:"space-y-2 text-sm",children:[n.jsx("p",{children:E.isError?"Couldn’t confirm it was cancelled. Refresh to check.":"Couldn’t check approval. Try again."}),!E.isError&&n.jsx(F,{size:"sm",variant:"outline",onClick:s.retry,disabled:s.isFetching,children:"Check approval"})]})]}),n.jsxs(Xt,{children:[n.jsx(F,{type:"button",variant:"outline",onClick:p,children:"Close"}),n.jsx(F,{variant:"outline",disabled:E.isPending,onClick:()=>q(t),children:E.isPending?"Cancelling…":"Cancel approval"})]})]})}function GN(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 vi({sheet:e,label:t="Actions",children:s}){return e?n.jsx("div",{role:"menu","aria-label":t,tabIndex:-1,onKeyDown:GN,children:s}):n.jsx(n.Fragment,{children:s})}function ir(){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 qN({trigger:e,selectedRef:t}){const s=ce(),r=Ae(),o=Re(),a=Ee({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=ir();ep({cancelled:y.acted}).finally(y.stop);return}const x=document.activeElement;(x===null||x===document.body)&&((b=e.current)==null||b.focus())}async function p(h){if(h.ref===t||i.current||h.status!=="connected")return;const g=oa();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=ir();i.current=!0,u(h.ref);let C=!1,j=null;try{await o({...ye.channels(),search:{community:h.ref}}),C=!0,j=Mn();const I=await s.resolveCommunityNavigation(h.ref),v=I?null:(await s.listRemoteCommunityRooms(h.ref)).rooms.find(O=>O.readable&&!O.archived)??null,N=(I==null?void 0:I.roomId)??(v==null?void 0:v.roomId);if(!It(x)||!j.isCurrent()){m(!1,y.acted());return}N&&await o({...ye.channels(),search:{community:h.ref,...N?{id:N}:{},...I!=null&&I.threadId?{thread:I.threadId}:{}}}),m(!0,y.acted())}catch{m(!1,y.acted()),C&&(j==null?void 0:j.isCurrent())===!0&&It(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 f(){if(t===void 0||i.current)return;const h=oa();if(h.ownerKey===null)return;const g={epoch:h.epoch,ownerKey:h.ownerKey},x=Mn();c.current=r;const b=ir();i.current=!0;try{const y=await s.getCommunityNavigation();if(y.ownerKey!==g.ownerKey||!It(g)||!x.isCurrent()){m(!1,b.acted());return}const C=Zf.safeParse(y.installationDestination);await o(C.success?{to:C.data.path,search:C.data.search}:{...ye.home()}),m(!0,b.acted())}catch{const y=It(g)&&x.isCurrent();y&&await o({...ye.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:p,selectInstallation:f}}function YN(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 Su({triggerClassName:e,compact:t=!1}){var Te;const s=Ae(),r=Re(),o=Ee({select:U=>U.location.search.community}),a=tp(),i=np(),c=$s(),{spaces:d,anySpace:u,selectedRef:m,visible:p,joinOfficial:f}=_N(o,c.data),h=l.useMemo(()=>{var U;return ON(p,((U=a.data)==null?void 0:U.order)??[])},[p,(Te=a.data)==null?void 0:Te.order]),g=h.find(U=>U.ref===m)??null,x=l.useRef(null),b=l.useRef(null),y=l.useRef(null),{pendingRef:C,isSelecting:j,holdCloseFocus:I,takeCloseFocusHold:v,selectCommunity:N,selectInstallation:O}=qN({trigger:y,selectedRef:m}),[P,R]=l.useState(""),[A,w]=l.useState(!1),[k,E]=l.useState(null),[D,T]=l.useState(null),L=NS(),[$,B]=l.useState(null),q=m?h.findIndex(U=>U.ref===m):-1;function oe(U,le){jt(new URL(cp(U.remoteCommunityId,le),U.pinnedOrigin).toString())}const ie=TN({selected:g?{connection:g,availability:RN(g),canMoveUp:q>0,canMoveDown:q>=0&&q<h.length-1}:null,onMove:U=>{g&&i.mutate({ref:g.ref,direction:U})},onInvite:()=>g&&oe(g,"community"),onOpenSettings:()=>g&&oe(g),onLeave:()=>g&&oe(g,"account"),onDisconnect:()=>T(g),onJoin:d?()=>E({ref:null}):null,onJoinOfficial:f,creationOrigins:d?IN(h):[],onCreate:U=>jt(new URL(ip,U).toString()),onDeploy:()=>jt(EN),hosting:d&&L?{onStart:()=>B({kind:"start"}),onOpenYourSpaces:()=>B({kind:"hosted"})}:null}),Y=u?ie:[];PN(U=>E({ref:null,url:U}));const X=AN(Y),ne=Xc([...X.identityNodes,...X.nodes]),se=ne.nodes.slice(0,X.identityNodes.length),te=ne.nodes.slice(X.identityNodes.length),M=X.teamName,z=X.nameUnknown,G=m!==void 0&&c.data===void 0,Q=m===void 0?z:G,ge=m===void 0?M:(g==null?void 0:g.label)??"Space",qe=s&&h.length>=8&&P.trim().length>0?h.filter(U=>U.label.toLocaleLowerCase().includes(P.trim().toLocaleLowerCase())):h;YN(U=>{b.current=U,w(!0)});function nt(U){if(j())return;if(b.current=null,U==="installation"){O();return}const le=h.find(xe=>`community:${xe.ref}`===U);if(le){if(le.status==="connected"){N(le);return}I(),E({ref:le.ref})}}function Ke(U){w(U),U||R("")}function Z(U){if(ne.onCloseAutoFocus(U),v()){U.preventDefault();return}const le=b.current;b.current=null,!(U.defaultPrevented||!(le!=null&&le.isConnected))&&(U.preventDefault(),le.focus())}l.useEffect(()=>{if(!A)return;const U=requestAnimationFrame(()=>{var le;return(le=x.current)==null?void 0:le.focus()});return()=>cancelAnimationFrame(U)},[A]);async function He(U){var we;const xe=(we=(await c.refetch()).data)==null?void 0:we.find(Le=>Le.ref===U&&Le.status==="connected");xe&&await N(xe)}function ot(U){xs(Mn().destination)===U.ref&&r({...ye.home(),replace:!0})}return n.jsxs(n.Fragment,{children:[n.jsxs(sp,{open:A,onOpenChange:Ke,children:[n.jsx(rp,{asChild:!0,children:n.jsxs("button",{ref:y,type:"button","data-testid":"sidebar-header-block","aria-label":Q?"Context menu":`${ge} menu`,"aria-busy":C!==null||void 0,className:e,children:[t?m===void 0?n.jsx(ka,{className:"size-4 shrink-0","aria-hidden":!0}):n.jsx(Ar,{className:"size-4 shrink-0","aria-hidden":!0}):Q?n.jsx(Dt,{className:"my-[3px] h-3.5 w-24 rounded-sm","data-testid":"sidebar-team-name-skeleton"}):n.jsx("span",{className:"truncate",children:ge}),n.jsx(Ut,{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(op,{align:"start",className:"max-h-(--radix-dropdown-menu-content-available-height) w-64 overflow-y-auto",onCloseAutoFocus:Z,children:[s&&n.jsx(aa,{children:u?"Switch context":"Menu"}),n.jsx(vi,{sheet:s,label:"You",children:n.jsx(Sr,{variant:s?"sheet":"dropdown",nodes:se,onSheetClose:()=>Ke(!1)})}),u&&n.jsx(ia,{}),u&&!s&&n.jsx(aa,{children:"Switch context"}),u&&s&&h.length>=8&&n.jsx("div",{className:"px-4 pb-2",children:n.jsx(ft,{type:"search",value:P,onChange:U=>R(U.target.value),placeholder:"Find a space","aria-label":"Find a space"})}),u&&n.jsxs(ap,{value:m?`community:${m}`:"installation",onValueChange:nt,children:[n.jsx(ca,{value:"installation",icon:ka,disabled:C!==null,itemRef:m===void 0?x:void 0,className:C!==null?"opacity-50":void 0,children:n.jsx("span",{className:"min-w-0 flex-1 truncate",children:M})}),qe.map(U=>{var at;const le=ju(U),xe=le.mentionCount??0,we=Math.max(0,(le.unreadCount??0)-xe),Le=[xe>0?`${xe} ${xe===1?"mention":"mentions"}`:null,we>0?`${we} other unread`:null,((at=U.attention)==null?void 0:at.state)==="stale"?`last checked ${MN(_s(U.attention.verifiedAt))}`:null].filter(Boolean).join(", ");return n.jsx(ca,{value:`community:${U.ref}`,icon:Ar,disabled:C!==null,itemRef:U.ref===m?x:void 0,description:[DN(U),Le].filter(Boolean).join(" · ")||void 0,className:C!==null?"opacity-50":void 0,children:n.jsxs("span",{className:"flex min-w-0 items-center gap-1.5",children:[n.jsx("span",{className:"min-w-0 truncate",children:U.label}),Nb(U)&&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"}),xe>0&&n.jsxs("span",{className:"bg-primary text-primary-foreground shrink-0 rounded-full px-1.5 text-xs","aria-label":`${xe} ${xe===1?"mention":"mentions"}`,children:["@",xe]}),we>0&&n.jsx("span",{className:"bg-muted text-muted-foreground shrink-0 rounded-full px-1.5 text-xs","aria-label":`${we} other unread`,children:we})]})},U.ref)})]}),te.length>0&&n.jsxs(n.Fragment,{children:[n.jsx(ia,{}),n.jsx(vi,{sheet:s,children:n.jsx(Sr,{variant:s?"sheet":"dropdown",nodes:te,onSheetClose:()=>Ke(!1)})})]})]})]}),n.jsx(HN,{request:k,onOpenChange:U=>{U||E(null)},installName:z?"My DorkOS":M,onConnected:U=>void He(U)}),n.jsx(YS,{entry:L,dialog:$,onDialogChange:B,installName:z?"My DorkOS":M,onConnected:U=>void He(U)}),n.jsx(LN,{connection:D,onOpenChange:U=>{U||T(null)},onDisconnected:ot})]})}function VN(){return n.jsx(Su,{compact:!0,triggerClassName:H("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",qn)})}function ku(){const e=Ae();return n.jsxs(lp,{className:"gap-2 px-2 py-3",children:[n.jsxs("div",{className:"flex items-center gap-1",children:[!e&&n.jsx(Su,{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-[13px] font-semibold outline-hidden transition-colors duration-150 focus-visible:ring-2"}),n.jsx(wN,{})]}),n.jsx(jN,{})]})}function QN(){const e=wu("sm");return n.jsxs("div",{className:"space-y-1 pb-2",children:[e.you!==null&&n.jsx(wi,{leading:e.you.face,label:e.you.name,description:"View profile",onClick:e.you.onOpen}),n.jsx(wi,{leading:n.jsx(_l,{className:"text-muted-foreground size-7 p-0.5","aria-hidden":!0}),label:"DorkOS account",description:e.accountStatus,onClick:e.onOpenAccount})]})}function wi({leading:e,label:t,description:s,onClick:r}){return n.jsxs("button",{type:"button",onClick:r,className:H("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",qn),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(on,{className:"text-muted-foreground size-4 shrink-0","aria-hidden":!0})]})}const XN=6e4;function JN(e){return e===null?!0:(e.selectionStart??0)===0&&(e.selectionEnd??0)===0}function ZN(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"&&Oe(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 eA(){const{globalPaletteOpen:e,setGlobalPaletteOpen:t}=y0(),s=_(K=>K.openMessageSearch),[r,o]=l.useState(""),a=l.useRef(null),[i,c]=l.useState(""),d=l.useRef(null),[u,m]=l.useState([]),[p,f]=l.useState(null),[h,g]=l.useState(null),[x,b]=l.useState(null),y=u[u.length-1],[C,j]=l.useState(0),I=Ae(),v=_(K=>K.globalPaletteInitialSearch),N=_(K=>K.clearGlobalPaletteInitialSearch),O=l.useCallback(()=>{t(!1),N(),o(""),c(""),m([]),f(null),b(null)},[t,N]),{handleAgentSelect:P,startNewSession:R,handleFeatureAction:A,handleQuickAction:w,handleRoomSelect:k,handleSessionSelect:E,handleCommandSelect:D,handlePageSelect:T,recordAgentOpened:L,selectedCwd:$}=Ak(O),B=me(),q=l.useCallback(K=>{const S=dp(B,K.projectPath);return up(S?{session:S}:{agentId:K.id})},[B]),oe=l.useCallback(K=>{if(!mp()){P(K);return}In(q(K),{target:"tab"}),L(K.projectPath),O()},[q,P,L,O]),ie=l.useCallback(K=>{In(q(K),{target:"window"}),L(K.projectPath),O()},[q,L,O]),Y=hp(),X=kk(),ne=po(XN),{allAgents:se,newActions:te,rooms:M,sessions:z,continueRows:G,recent:Q,searchableItems:ge}=b0($,ne);fp(se);const{bestMatch:qe,rows:nt,prefix:Ke,term:Z}=jk(ge,r,{usage:X,now:ne,scope:x}),He=Ke==="#",ot=Dk(Z),Te=ot?{term:ot,isScoped:x!==null,onSelect:()=>{O(),s(ot)}}:null,U=l.useMemo(()=>i?se.find(K=>K.name===i)??null:null,[i,se]),le=ZN(i,qe,nt),xe=l.useCallback(K=>{b(K),o(""),c("")},[]),we=!I&&U!==null,Le=l.useMemo(()=>{var K;return i?z.find(S=>S.id===i)??((K=G.find(S=>S.session.id===i))==null?void 0:K.session)??null:null},[i,z,G]),at=su((p==null?void 0:p.id)??"",(p==null?void 0:p.projectPath)??""),Ht=l.useCallback(()=>{m(K=>K.slice(0,-1)),f(K=>u.length<=1?null:K),c("")},[u.length]),At=l.useCallback(K=>{f(K),m(S=>[...S,"agent-actions"]),o(""),c(""),j(S=>S+1)},[]);l.useEffect(()=>{e&&v!=null&&(o(v),N(),requestAnimationFrame(()=>{const K=a.current;if(K){const S=v.length;K.setSelectionRange(S,S)}}))},[e,v,N]);const De=l.useCallback(K=>{t(K),K?j(S=>S+1):(o(""),c(""),m([]),f(null),b(null))},[t]),it=Rk({rootRef:d,activePage:y??"root",onPin:c,resetKey:JSON.stringify([e,y??null,r,x&&Hd(x)])}),Wt=!r&&x===null,Gt=l.useId(),qt=n.jsx(pt,{open:e,onOpenChange:De,children:n.jsx(gt,{className:H("!min-h-0 overflow-hidden p-0 transition-[max-width] duration-200","[&>button:last-child]:top-2 [&>button:last-child]:right-2.5",we?"max-w-[640px]":"max-w-[480px]",I&&"h-[85vh]"),children:n.jsxs(re.div,{variants:cu,initial:"hidden",animate:"visible",exit:"exit",className:H("flex overflow-hidden",I&&"h-full flex-col"),children:[n.jsxs(Bl,{ref:d,loop:!0,shouldFilter:!1,value:i,onValueChange:c,onPointerMove:it.onPointerMove,className:H("min-w-0 flex-1",I&&"flex flex-col [&_[cmdk-list]]:max-h-none [&_[cmdk-list]]:flex-1 [&_[cmdk-list]]:overflow-y-auto"),onKeyDown:K=>{if(it.onKeyDown(K),K.key==="Enter"&&(K.metaKey||K.ctrlKey)&&!y&&(Le==null?void 0:Le.cwd)!=null){K.preventDefault(),R(Le.cwd),O();return}if(K.key==="Enter"&&(K.metaKey||K.ctrlKey)&&!y&&U){K.preventDefault(),oe(U);return}if(K.key==="Enter"&&(K.metaKey||K.ctrlKey)&&y==="agent-actions"&&p){K.preventDefault(),oe(p);return}if(K.key==="Tab"&&!K.shiftKey&&!y&&le){K.preventDefault(),K.stopPropagation(),xe(le);return}if(K.key==="Backspace"&&x&&!y&&JN(a.current)){K.preventDefault(),b(null);return}K.key==="Backspace"&&!r&&u.length>0&&(K.preventDefault(),Ht()),K.key==="Escape"&&u.length>0&&(K.preventDefault(),K.stopPropagation(),Ht())},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([]),f(null),j(K=>K+1)},className:"hover:text-foreground transition-colors",children:"All"}),n.jsx("span",{children:"/"}),n.jsxs("span",{children:["Agent: ",p==null?void 0:p.name]})]}),n.jsx(zl,{ref:a,"data-testid":"command-palette-input",leading:x&&!y?n.jsx(Tk,{scope:x}):void 0,placeholder:y==="agent-actions"?`${(p==null?void 0:p.name)??"Agent"} actions…`:x&&!y?"Search within…":"Search rooms, agents, commands…",value:r,onValueChange:o}),n.jsx(Ul,{children:n.jsxs(Cn,{className:"h-full",children:[n.jsxs(Ob,{children:[n.jsx("p",{children:"No results found."}),n.jsx(ru,{className:"justify-center pb-0"})]}),n.jsx(Qe,{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(Yk,{staggerKey:C,isZeroQuery:Wt,isRoomMode:He,scope:x,hasQuery:Z.length>0,selectedCwd:$,selectedValue:i,continueRows:G,recent:Q,newActions:te,bestMatch:qe,rows:nt,rooms:M,searchHandoff:Te,onFeatureAction:A,onQuickAction:w,onGoToAgentActions:At,onRoomSelect:k,onSessionSelect:K=>E(K.id,K.cwd),onCommandSelect:D,onPageSelect:T}),y==="agent-actions"&&p&&n.jsx(Mk,{agent:p,onOpenHere:()=>P(p),onOpenNewTab:()=>oe(p),onOpenNewWindow:Y?()=>ie(p):void 0,onNewSession:()=>{R(p.projectPath),L(p.projectPath),O()},onEditSettings:()=>{pp.getState().openProfileDocked(p.projectPath),O()},onBrowseSessions:at.sessionCount>0?()=>{g(p),L(p.projectPath),O()}:void 0,recentSessions:at.recentSessions,onSelectSession:K=>E(K,p.projectPath)})]},y??"root")})]})}),n.jsx(Pk,{page:y,hasAgentSelected:we,canScope:!y&&le!==null,isScoped:x!==null})]}),n.jsx(Qe,{children:we&&U&&n.jsx(Ok,{agent:U},U.id)})]})})});return n.jsxs(n.Fragment,{children:[n.jsx(gp,{id:Gt,children:qt}),h!==null&&n.jsx(xp,{agentPath:h.projectPath,agentName:h.displayName??h.name,agentVisual:fo(h),open:!0,onOpenChange:K=>{K||g(null)},onSelectSession:K=>E(K,h.projectPath),onNewSession:()=>R(h.projectPath)})]})}const tA="",nA="";function sA(e){const t=[];let s=e,r=!1;for(;s.length>0;){const o=r?nA:tA,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 rA({excerpt:e,className:t}){const s=sA(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 Cu="rooms",oA=["claude-code","opencode"];function aA(e){if(e.source===Cu)return{kind:"room",...ye.channels(),search:{id:e.container,entry:e.ordinal}};if(e.sessionId===void 0)return{kind:"unopenable"};const t=e.messageId!==void 0&&oA.includes(e.source);return{kind:"session",..._t({session:e.sessionId,dir:e.containerPath??void 0,...t?{message:e.messageId}:{}})}}function iA(e,t){return e.source===Cu?t.get(e.container)??"Channel":e.containerPath===null?"Conversation":tl(e.containerPath)}function cA(e){return e==="user"?"You":"Agent"}function lA({hit:e,containerLabel:t,value:s,onSelect:r,openable:o}){const a=e.source==="rooms"?bo:Oy;return n.jsxs(je,{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:cA(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:_s(e.createdAt)})]}),n.jsx(rA,{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 dA=["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."],uA=["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."],mA="Searches channels, direct messages, and DorkOS, Claude Code, Codex and OpenCode chats. Not tool output.",hA=`Type at least ${nl} letters to search.`,fA="Search what was said…";function pA({detailOpen:e=!1,className:t}){const[s,r]=l.useState(null),o=s??e,a=uA;return n.jsxs(wo,{open:o,onOpenChange:r,className:H("px-3 py-2",t),children:[n.jsxs(jo,{className:H("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:mA}),n.jsx(Ut,{className:H("mt-0.5 size-3 shrink-0 transition-transform",!o&&"-rotate-90"),"aria-hidden":"true"})]}),n.jsx(So,{children:n.jsxs("ul",{className:"mt-2 space-y-1.5",children:[dA.map(i=>n.jsxs("li",{className:"text-muted-foreground flex gap-2 text-xs leading-relaxed",children:[n.jsx(zt,{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(My,{className:"mt-0.5 size-3.5 shrink-0 opacity-60","aria-hidden":"true"}),n.jsx("span",{children:i})]},i))]})})]})}const gA=3e4,xA=e=>["message-search",e];function cr(e){return bp(e).some(t=>t.length>=nl)}function bA(e,t){const s=ce(),r=yA(e,yp),o=t&&cr(e)&&cr(r),{data:a,isFetching:i,error:c}=ke({queryKey:xA(r),queryFn:()=>s.search({q:r}),enabled:o,staleTime:gA,placeholderData:u=>u,retry:!1});return{submitted:o?r:"",tooShort:t&&r.trim().length>0&&!cr(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 yA(e,t){const[s,r]=l.useState(e);return l.useEffect(()=>{const o=setTimeout(()=>r(e),t);return()=>clearTimeout(o)},[e,t]),s}function vA(){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 lr="bg-muted rounded px-1 py-0.5 font-mono text-3xs";function wA(){vA();const e=_(v=>v.messageSearchOpen),t=_(v=>v.messageSearchQuery),s=_(v=>v.setMessageSearchOpen),r=Ae(),o=Re(),a=ce(),[i,c]=l.useState("");l.useEffect(()=>{e&&c(t??"")},[e,t]);const{results:d,warnings:u,tooShort:m,isSearching:p,error:f,submitted:h}=bA(i,e),{data:g}=Ps({includeArchived:!0}),x=l.useMemo(()=>{const v=new Map;for(const N of g??[])v.set(N.id,N.kind==="channel"&&N.slug?`#${N.slug}`:N.title);return v},[g]),b=l.useCallback(()=>s(!1),[s]),y=l.useCallback((v,N)=>{if(N.kind!=="unopenable"&&(b(),o({to:N.to,search:N.search}),N.kind==="session"&&v.containerPath!==null)){const O=v.containerPath;a.browseDirectory(O).catch(P=>{if((P==null?void 0:P.status)===404){ue.info("That folder is gone",{description:`${O} 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 ${O}. The chat may not open.`})})}},[b,o,a]),C=d.length>0,j=!C&&!m&&!p&&h.trim().length>0&&f===null,I=!C&&!m&&h.trim().length>0&&f===null;return n.jsx(pt,{open:e,onOpenChange:s,children:n.jsxs(gt,{"data-testid":"message-search-dialog",className:H("!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(Xe,{className:"sr-only",children:"Search your messages"}),n.jsx(re.div,{variants:cu,initial:"hidden",animate:"visible",exit:"exit",className:H("flex overflow-hidden",r&&"h-full flex-col"),children:n.jsxs(Bl,{loop:!0,shouldFilter:!1,className:H("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(zl,{"data-testid":"message-search-input",placeholder:fA,value:i,onValueChange:c}),f!==null&&n.jsxs("p",{className:"text-destructive flex items-start gap-2 px-3 py-3 text-xs leading-relaxed",children:[n.jsx(vp,{className:"mt-0.5 size-3.5 shrink-0","aria-hidden":"true"}),n.jsx("span",{children:f.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(Qi,{className:"mt-0.5 size-3 shrink-0","aria-hidden":"true"}),n.jsx("span",{children:v.message})]},v.source)),n.jsx(Ul,{children:n.jsx(Cn,{className:"h-full",children:C&&n.jsx(Ve,{className:H("transition-opacity duration-150",p&&"opacity-60"),children:d.map(v=>{const N=`${v.source}:${v.container}:${v.ordinal}`,O=aA(v);return n.jsx(lA,{value:N,hit:v,containerLabel:iA(v,x),openable:O.kind!=="unopenable",onSelect:()=>y(v,O)},N)})})})}),f===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:hA}),j&&n.jsxs("p",{className:"text-muted-foreground px-3 pt-3 text-xs",children:["No messages match “",h.trim(),"”."]}),n.jsx(pA,{detailOpen:I})]}),n.jsxs("div",{className:"text-muted-foreground flex flex-shrink-0 items-center gap-3 border-t px-3 py-1.5 text-xs",children:[n.jsxs("span",{className:"inline-flex items-center gap-1",children:[n.jsx("kbd",{className:lr,children:"↑↓"}),"Navigate"]}),n.jsxs("span",{className:"inline-flex items-center gap-1",children:[n.jsx("kbd",{className:lr,children:"Enter"}),"Open"]}),n.jsxs("span",{className:"ml-auto inline-flex items-center gap-1",children:[n.jsx("kbd",{className:lr,children:"esc"}),"Close"]})]})]})})]})})}function jA(e){return`set${e.charAt(0).toUpperCase()}${e.slice(1)}`}function SA(e){const t=tt(),s=lo(),r=yo();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 kA({contribution:e,openStateKey:t}){const s=_(m=>m[t]),r=_(m=>m[jA(t)]),o=SA(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 CA({contribution:e,openState:t}){const s=l.useSyncExternalStore(t.subscribe,t.getSnapshot),r=e.component;return s?n.jsx(wp,{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 NA({contribution:e}){return e.openState?n.jsx(CA,{contribution:e,openState:e.openState}):n.jsx(kA,{contribution:e,openStateKey:e.openStateKey})}function AA(){const e=Os("dialog");return n.jsx(n.Fragment,{children:e.map(t=>n.jsx(NA,{contribution:t},t.id))})}const EA=["session","id","thread","entry","itemId","agent","profile","continuedFrom","pkg","view","region","detail","panel"];function IA(e,t){if(e.length>=Gs)return e.slice(0,Gs);const s=new URLSearchParams(t);let r="";for(const o of EA)for(const a of s.getAll(o)){const i=new URLSearchParams([[o,a]]).toString(),c=r?`${r}&${i}`:i;e.length+1+c.length<=Gs&&(r=c)}return r?`${e}?${r}`:e}const RA=6e4,TA={bug:"when it’s fixed",idea:"when it ships",feedback:"when the team acts on it"};function DA(e,t){var s;return JSON.stringify([e.kind,t,e.screenshotDataUrl??null,((s=e.element)==null?void 0:s.selector)??null])}function ji(e,t,s,r){const o=Hl("bug",e,t),a=[...Cp()];r&&a.push({at:new Date().toISOString(),kind:"console_error",message:Sp(r).slice(0,kp)});const i=a.slice(-Np);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])),...ev(s)},...i.length>0?{breadcrumbs:i}:{}}}function OA(){const e=ce(),t=Ee({select:h=>h.location.pathname}),s=Ee({select:h=>h.location.searchStr}),r=jp(),o=IA(t,s),a=Ee({select:h=>{const g=h.location.search;return typeof(g==null?void 0:g.session)=="string"?g.session:void 0}}),{data:i}=ke({queryKey:Me.current(),queryFn:()=>e.getConfig(),staleTime:300*1e3}),[c,d]=l.useState(!1),u=Re(),m=l.useRef(null),p=l.useCallback(h=>i?ji(i,t,r,h==null?void 0:h.crashStack):void 0,[i,t,r]),f=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=DA(h,g),y=m.current;if(y&&y.fingerprint===b&&Date.now()-y.at<RA)return ue.info("Already sent a moment ago."),!0;const C=h.includeDiagnostics?ji(i,t,r,h.crashStack):void 0,j=h.includeDiagnostics&&h.kind==="bug",I=!!(h.includeConversation&&a);d(!0);try{const N=C&&j?await Ky():void 0,{ok:O}=await e.sendFeedback({kind:h.kind,message:g,...x?{contact:x}:{},...o?{route:o}:{},...C?{diagnostics:{...C,...N?{shellLogExcerpt:N}:{}}}:{},...j?{includeServerLogs:!0}:{},...I?{sessionId:a,includeTranscript:!0}:{},...h.screenshotDataUrl?{screenshot:{dataUrl:h.screenshotDataUrl}}:{},...h.anonymous?{anonymous:!0}:{},...h.element?{element:h.element}:{}});return O?(m.current={fingerprint:b,at:Date.now()},ue.success("Sent. Thank you.",{...h.notifyEmail?{description:`DorkOS emails ${h.notifyEmail} ${TA[h.kind]}.`}:{},action:{label:"Your reports",onClick:()=>u(ye.feedbackRequests())}})):ue.error("Couldn’t send. Your words are still here. Try again or open a GitHub issue."),O}finally{d(!1)}},[e,t,o,a,i,r,u]);return{isSubmitting:c,sessionId:a,route:o,buildDiagnostics:p,send:f}}const MA=24;function Si(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 _A(e){const{element:t,viewport:s,region:r,image:o}=e,a=e.padding??MA;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=Si(i,{left:0,top:0,width:s.width,height:s.height});if(!c)return null;const d=Si(c,r);if(!d)return null;const u=o.width/r.width,m=o.height/r.height,p=Math.round((d.left-r.left)*u),f=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,p),Math.max(0,o.width-1)),b=Math.min(Math.max(0,f),Math.max(0,o.height-1));return{sx:x,sy:b,sw:Math.max(1,h-x),sh:Math.max(1,g-b)}}function PA(e){return new Promise((t,s)=>{const r=new Image,o=i=>{clearTimeout(a),s(new Je("failed",i))},a=setTimeout(()=>o(`The capture did not decode within ${ys}ms.`),ys);r.onload=()=>{clearTimeout(a),t(r)},r.onerror=()=>o("The capture did not decode, so it cannot be cropped."),r.src=e})}function LA(e,t){const s=document.createElement("canvas");s.width=t.sw,s.height=t.sh;const r=s.getContext("2d");if(!r)throw new Je("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 FA(e,t){const s=t.getBoundingClientRect();if(s.width===0&&s.height===0)throw new Je("failed","That element has no size to crop to.");if(!ld().contains(t))throw new Je("failed","That element is not part of the app that was captured.");const r=await PA(e.dataUrl),o=_A({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 Je("failed","That element is no longer inside the captured picture.");return Ir(LA(r,o))}const ki={"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."},$A={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 BA(e){return e instanceof Je?$A[e.reason]:e instanceof Ft?ki[e.reason]:ki.unreadable}const dr="Only images can be attached.",zA="Files";function wn(e){return e?Array.from(e.types).includes(zA):!1}function Ci(e){return e.find(t=>t.type.startsWith("image/"))}function UA(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 N=++u.current;a(!0);try{const O=await v();return N!==u.current?null:(r(O),O)}catch(O){return N!==u.current||ue.error(BA(O)),null}finally{N===u.current&&a(!1)}},[]),p=l.useCallback(async v=>{if(!v.type.startsWith("image/")){ue.error(dr);return}await m(()=>Ir(v))},[m]),f=l.useCallback(async()=>{await m(async()=>Ir(await Xy()))},[m]),h=l.useCallback(v=>m(async()=>FA(await dd(),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&&!iv(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=N=>{wn(N.dataTransfer)&&N.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 P;const N=Array.from(((P=v.clipboardData)==null?void 0:P.items)??[]).map(R=>R.getAsFile()).filter(R=>R!==null);if(N.length===0)return;const O=Ci(N);if(!O){ue.error(dr);return}v.preventDefault(),p(O)},[p]),y=l.useCallback(v=>{wn(v.dataTransfer)&&(v.preventDefault(),d.current+=1,c(!0))},[]),C=l.useCallback(v=>{wn(v.dataTransfer)&&(v.preventDefault(),v.dataTransfer.dropEffect="copy")},[]),j=l.useCallback(v=>{wn(v.dataTransfer)&&(d.current=Math.max(0,d.current-1),d.current===0&&c(!1))},[]),I=l.useCallback(v=>{if(!wn(v.dataTransfer))return;v.preventDefault(),d.current=0,c(!1);const N=Ci(Array.from(v.dataTransfer.files));if(!N){ue.error(dr);return}p(N)},[p]);return{dataUrl:s,isPreparing:o,isDraggingOver:i,attach:p,capture:f,captureElement:h,clear:g,reset:x,handlers:{onPaste:b,onDragEnter:y,onDragOver:C,onDragLeave:j,onDrop:I}}}const Ni=Ip,KA="root";function Nu(e){return typeof CSS<"u"&&typeof CSS.escape=="function"?CSS.escape(e):e.replace(/["'\\[\]]/g,t=>`\\${t}`)}function Ai(e,t){try{const s=t.ownerDocument.querySelectorAll(e);return s.length===1&&s[0]===t}catch{return!1}}function Au(e){return e.id?`#${Nu(e.id)}`:null}function Wr(e,t){const s=e.getAttribute(t);return s?`[${t}="${Nu(s)}"]`:null}function HA(e){const t=e.tagName;let s=1,r=e.previousElementSibling;for(;r;)r.tagName===t&&(s+=1),r=r.previousElementSibling;return s}function WA(e){const t=e.tagName.toLowerCase(),s=Au(e);if(s)return s;const r=Wr(e,"data-testid")??Wr(e,"data-slot"),o=`:nth-of-type(${HA(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 GA(e){for(const r of[Au(e),Wr(e,"data-testid")])if(r&&r.length<=Ni&&Ai(r,e))return r;const t=[];let s=e;for(;s&&s.id!==KA&&s.tagName!=="BODY";){t.unshift(WA(s));const r=t.join(" > ");if(r.length>Ni){t.shift();break}if(Ai(r,e))return r;s=s.parentElement}return t.join(" > ")||e.tagName.toLowerCase()}function Ei(e,t){var r;const s=(r=e.closest(`[${t}]`))==null?void 0:r.getAttribute(t);if(!(!s||s.length>Ap))return s}const qA=8;function Eu(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*qA?s:null}function YA(e){const t=Ei(e,"data-slot"),s=Eu(e,e),r=s?Ei(s,"data-testid"):void 0,o=Iu(e);return{selector:GA(e),...t?{slot:t}:{},...r?{testId:r}:{},...o?{label:o}:{}}}const ur=40,VA=["button","a[href]","summary","input","select","textarea",'[role="button"]','[role="link"]','[role="menuitem"]','[role="tab"]','[role="option"]','[role="checkbox"]','[role="switch"]'].join(", "),QA=new Set(["INPUT","SELECT","TEXTAREA"]),XA=['[contenteditable]:not([contenteditable="false"])','[role="textbox"]','[role="searchbox"]','[role="combobox"]'].join(", "),JA=["h1","h2","h3","h4","h5","h6",'[role="heading"]',"label","legend","th","dt"].join(", ");function ZA(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 En(e){const t=(e??"").replace(/\s+/g," ").trim();if(!t)return;const s=ZA(t);if(s.length<=ur)return t;const r=s.slice(0,ur-1),o=r.lastIndexOf(" ");return`${(o>ur/2?r.slice(0,o):r).join("").trimEnd()}…`}function e1(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 En(s)}function ss(e){return En(e.getAttribute("aria-label"))??e1(e)}function Iu(e){const t=t1(e);return t&&t.length<=Ep?t:void 0}function t1(e){var a,i;const t=e.closest(XA);if(t)return ss(t);const s=e.closest(VA);if(s){if(QA.has(s.tagName)){const c=s;return ss(s)??En((i=(a=c.labels)==null?void 0:a[0])==null?void 0:i.textContent)}return ss(s)??En(s.textContent)}const r=ss(e);if(r)return r;const o=e.closest(JA);return o?En(o.textContent):void 0}function Ii(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 n1(e){var d;const t=Iu(e);if(t)return{text:t,onScreen:!0};const s=e.getAttribute("data-testid")??e.getAttribute("data-slot"),r=s?Ii(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&&Eu(e,o)===o?o.getAttribute("data-testid"):null)??(o==null?void 0:o.getAttribute("data-slot")),c=i?Ii(i):null;return c?{text:c,onScreen:!1}:null}const s1="This part";function Ru(e){return(e==null?void 0:e.text)??s1}function r1(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 o1(e){return e!=null&&e.onScreen?`Remove “${e.text}”`:`Remove ${Ru(e).toLowerCase()}`}const Ri=500;function Ti(e){const t=e.trim();return t.length>Ri?`${t.slice(0,Ri)}… [trimmed]`:t}function a1(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: ${Ti(s.input)}`),s.result&&t.push(` result: ${Ti(s.result)}`);return t.join(`
84
- `)}function i1(e){const t=e.slice(-20),s=Rp(Tp(t.map(a1).join(`
85
-
86
- `))).trim();return s.length>la?`${s.slice(0,la-1)}…`:s}function c1(e,t){const s=ce(),[r]=Wn(),{data:o,isLoading:a,isError:i}=ke({queryKey:["feedback-transcript-preview",e,r],queryFn:async()=>{const{messages:c}=await s.getMessages(e,r??void 0);return i1(c)},enabled:t&&!!e,staleTime:30*1e3});return{text:o??"",isLoading:a,isError:i}}function l1(){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(sl,{className:"size-3 shrink-0","aria-hidden":!0}),"Private. Only the DorkOS core team sees these. Never public."]})})}function Ye({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 d1({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(Ye,{label:"Page",value:s}),n.jsx(Ye,{label:"Version",value:r.version}),n.jsx(Ye,{label:"Platform",value:r.platform}),n.jsx(Ye,{label:"Runtimes",value:r.runtimes.length?r.runtimes.join(", "):"none"}),a&&n.jsx(Ye,{label:"Window",value:`${a.width}×${a.height}${a.devicePixelRatio&&a.devicePixelRatio!==1?` @${a.devicePixelRatio}x`:""}`}),c&&n.jsx(Ye,{label:"Shell",value:c}),d&&n.jsx(Ye,{label:"Theme",value:d}),u&&n.jsx(Ye,{label:"Locale",value:u}),m&&n.jsx(Ye,{label:"Timezone",value:m}),i&&n.jsx(Ye,{label:"Browser",value:i}),Object.entries(r.flags).map(([p,f])=>n.jsx(Ye,{label:p,value:String(f)},p))]}),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((p,f)=>n.jsxs("li",{className:"text-foreground font-mono text-xs break-all",children:[n.jsx("span",{className:"text-muted-foreground",children:p.kind})," ",p.message]},f))}):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 u1({sessionId:e,active:t}){const{text:s,isLoading:r,isError:o}=c1(e,t);return r?n.jsxs("div",{className:"flex flex-col gap-2",children:[n.jsx(Dt,{className:"h-4 w-3/4"}),n.jsx(Dt,{className:"h-4 w-full"}),n.jsx(Dt,{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 m1({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 h1({open:e,onOpenChange:t,initialTab:s,diagnostics:r,kind:o,route:a,showConversation:i,sessionId:c,screenshotDataUrl:d}){const u=!Ae(),m=["diagnostics",...i?["conversation"]:[],...d?["screenshot"]:[]],p=m.includes(s)?s:"diagnostics";return n.jsx(pt,{open:e,onOpenChange:t,children:n.jsxs(gt,{className:H("max-h-[85vh]",u&&"max-w-lg"),children:[n.jsxs(ut,{children:[n.jsx(Xe,{className:"text-sm font-medium",children:"What will be sent"}),n.jsx(mt,{className:"text-muted-foreground text-xs",children:"Each part is sent only if its toggle is on."})]}),n.jsxs(Nl,{defaultValue:p,className:"flex min-h-0 flex-col gap-3 px-4 pb-4 sm:px-0",children:[n.jsxs(Al,{className:H("grid shrink-0",m.length===3&&"grid-cols-3",m.length===2&&"grid-cols-2",m.length===1&&"grid-cols-1"),children:[n.jsx(as,{value:"diagnostics",children:"Diagnostics"}),i&&n.jsx(as,{value:"conversation",children:"Chat"}),d&&n.jsx(as,{value:"screenshot",children:"Screenshot"})]}),n.jsx(Vs,{value:"diagnostics",className:"min-h-0",children:n.jsx(Cn,{className:"max-h-[45vh]",children:n.jsx(d1,{diagnostics:r,kind:o,route:a})})}),i&&n.jsx(Vs,{value:"conversation",className:"min-h-0",children:n.jsx(Cn,{className:"max-h-[45vh]",children:n.jsx(u1,{sessionId:c,active:e})})}),d&&n.jsx(Vs,{value:"screenshot",className:"min-h-0",children:n.jsx(Cn,{className:"max-h-[45vh]",children:n.jsx(m1,{dataUrl:d})})}),n.jsx(l1,{})]},p)]})})}const f1="0 0 0 9999px rgb(0 0 0 / 0.5)";function p1(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 g1(e){let t=e;for(;t;){if(/^(auto|scroll|overlay)$/.test(getComputedStyle(t).overflowY)&&t.scrollHeight>t.clientHeight)return t;t=t.parentElement}return null}function x1({phase:e,onSelect:t,onCancel:s}){const r=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 C=y.style.pointerEvents;y.style.pointerEvents="none";try{return document.elementFromPoint(x,b)}finally{y.style.pointerEvents=C}},[]),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:p1(b)})},[c,d,u]),p=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]),f=l.useCallback(x=>{if(!c)return;const b=g1(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 Cs.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:H("fixed inset-0 z-50 focus:outline-none",c?"cursor-crosshair":"cursor-wait"),onPointerMove:m,onPointerLeave:()=>i(null),onClick:p,onWheel:f,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:f1}}),n.jsx("div",{className:"bg-primary text-primary-foreground pointer-events-none absolute max-w-[60vw] truncate rounded-sm px-1.5 py-0.5 font-mono text-[11px] 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(bs,{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 Di="text-muted-foreground hover:text-foreground h-8 px-2 text-xs aria-disabled:pointer-events-none aria-disabled:opacity-50";function mr({tip:e,children:t}){return n.jsxs(an,{children:[n.jsx(cn,{asChild:!0,children:t}),n.jsx(ln,{className:"max-w-60 text-center",children:e})]})}function b1({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(),p=l.useId();function f(C){var I;const j=(I=C.target.files)==null?void 0:I[0];C.target.value="",j&&c(j)}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(mr,{tip:b,children:n.jsxs(F,{"aria-describedby":u,type:"button",variant:"ghost",size:"sm",onClick:()=>{t||a()},"aria-disabled":t||void 0,className:Di,children:[n.jsx(Ay,{className:"size-3.5","aria-hidden":!0}),"Capture app"]})}),!o&&n.jsx(mr,{tip:y,children:n.jsxs(F,{"aria-describedby":m,type:"button",variant:"ghost",size:"sm",onClick:()=>{t||i()},"aria-disabled":t||void 0,className:Di,children:[n.jsx(bs,{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:p,className:"sr-only",children:x}),n.jsx(mr,{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(_x,{className:"size-3.5","aria-hidden":!0}),n.jsx("input",{id:d,type:"file",accept:"image/*","aria-label":g,"aria-describedby":p,disabled:t,className:"sr-only",onChange:f})]})})]}),h&&n.jsxs("span",{className:"text-muted-foreground ml-auto pr-1.5 text-xs","aria-hidden":!0,children:[Pt?"⌘↵":"Ctrl+↵"," to send"]})]})}function Oi({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(bs,{className:"size-4","aria-hidden":!0})}),s&&n.jsxs("span",{className:"bg-background/85 absolute inset-x-0 bottom-0 flex items-center gap-1 truncate px-1.5 py-0.5 text-left text-[11px] leading-tight",children:[r&&n.jsx(bs,{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(an,{children:[n.jsx(cn,{asChild:!0,children:u}),n.jsx(ln,{className:"max-w-72 font-mono text-[11px] 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(_e,{className:"size-3","aria-hidden":!0})})]})}function Mi({label:e,summary:t,pressed:s,onPressedChange:r,onPreview:o}){return n.jsxs("span",{className:H("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(an,{children:[n.jsx(cn,{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:H("size-1.5 rounded-full transition-colors duration-150",s?"bg-primary":"bg-muted-foreground/40")}),e]})}),n.jsx(ln,{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(Dp,{className:"size-3.5","aria-hidden":!0})})]})}function y1({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(Ly,{className:"size-3.5 shrink-0","aria-hidden":!0}):n.jsx(Op,{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&&!rl(r);return n.jsxs("div",{className:"flex flex-col gap-1.5",children:[n.jsx(ze,{htmlFor:a,className:"text-xs",children:"Your email"}),n.jsx(ft,{id:a,type:"email",inputMode:"email",autoComplete:"email",value:r,onChange:d=>o(d.target.value),placeholder:"you@example.com",maxLength:Mp,"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 v1=[{value:"feedback",label:"Feedback",icon:As},{value:"bug",label:"Bug",icon:_p},{value:"idea",label:"Idea",icon:Px}];function w1({kind:e,onChange:t}){return n.jsx("div",{role:"radiogroup","aria-label":"What kind of feedback",className:"flex gap-1.5",children:v1.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:H("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 j1({needsWords:e,canSend:t,isSubmitting:s,onOpenGitHubIssue:r}){const o=l.useId();return n.jsxs(Xt,{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(sl,{className:"size-3 shrink-0","aria-hidden":!0}),"Only the DorkOS team sees this"]}),n.jsx(F,{type:"submit",disabled:!t,"aria-keyshortcuts":"Meta+Enter Control+Enter","aria-describedby":e?o:void 0,className:"shrink-0",children:s?"Sending…":"Send"})]}),n.jsxs("p",{className:"text-muted-foreground text-center text-xs",children:["Prefer a public GitHub issue?"," ",n.jsx("button",{type:"button",onClick:r,className:"hover:text-foreground focus-visible:ring-ring rounded-sm underline underline-offset-2 transition-colors duration-150 focus-visible:ring-2 focus-visible:outline-none",children:"Open one instead"})]})]})}const S1={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 k1({open:e,onOpenChange:t,initialKind:s,prefillMessage:r,crashStack:o,currentUser:a,initialScreenshotDataUrl:i}){const c=!Ae(),{isSubmitting:d,sessionId:u,route:m,buildDiagnostics:p,send:f}=OA(),h=yy(),g=!!u,x=!!a,b=l.useId(),[y,C]=l.useState(s??"feedback"),[j,I]=l.useState(r??""),[v,N]=l.useState(da),[O,P]=l.useState(!1),[R,A]=l.useState(!1),[w,k]=l.useState(!1),[E,D]=l.useState(!1),[T,L]=l.useState("diagnostics"),[$,B]=l.useState(null),[q,oe]=l.useState(null),[ie,Y]=l.useState(null),[X,ne]=l.useState(null),[se,te]=l.useState(0),M=l.useRef(se);l.useEffect(()=>{M.current=se},[se]);const[z,G]=l.useState(!1),[Q,ge]=l.useState(o),[qe,nt]=l.useState(u),Ke=l.useRef(null),Z=UA({enabled:e}),He=j.trim().length>0,ot=He||Z.dataUrl!==null||$!==null,[Te,U]=l.useState(e);if(e!==Te&&(U(e),e)){D(!1),ne(null);const V=i;if(!!(r||o||V)||!ot){const We=s??"feedback",Fe=_i(We,g,!!o);C(We),I(r??""),N(da()),P(!1),A(Fe.diagnostics),k(Fe.conversation),G(!1),B(null),oe(null),ge(o),nt(u),Z.reset(V),te(Et=>Et+1)}else u!==qe&&(k(!1),nt(u))}function le(V){const he=_i(V,g,!!Q);A(he.diagnostics),k(he.conversation)}function xe(V){C(V),le(V)}function we(V){L(V),D(!0)}async function Le(V){const he=M.current,We=YA(V),Fe=n1(V);q&&Z.dataUrl===q&&Z.clear(),oe(null),ne("capturing");const Et=await Z.captureElement(V);he===M.current&&(ne(null),B(We),Y(Fe),oe(Et),C("bug"),z||le("bug"))}function at(){q&&Z.dataUrl===q&&Z.clear(),B(null),oe(null)}function Ht(){I(""),B(null),oe(null),G(!1),ge(void 0),Z.clear()}const At=He&&!d&&!Z.isPreparing,De=x?O||a==null?void 0:a.email:rl(v)?v.trim():void 0;async function it(){!At||!await f({kind:y,message:j,...x?{}:{contact:v},includeDiagnostics:R,includeConversation:w,anonymous:O,...Q?{crashStack:Q}:{},...Z.dataUrl?{screenshotDataUrl:Z.dataUrl}:{},...$?{element:$}:{},...De?{notifyEmail:De}:{}})||(x||Fp(v),Ht(),t(!1))}function Wt(V){V.preventDefault(),it()}function Gt(V){const he=Ke.current;he&&(V.preventDefault(),he.focus(),he.setSelectionRange(he.value.length,he.value.length))}function qt(V){V.key!=="Enter"||!(V.metaKey||V.ctrlKey)||V.nativeEvent.isComposing||E||(V.preventDefault(),it())}const K=Z.handlers,S=X!==null,W=$?ie:null,ee=Ru(W),ae=!!($&&q&&Z.dataUrl===q),pe=!!Z.dataUrl&&!ae,ct=!He&&(!!Z.dataUrl||$!==null);return n.jsxs(n.Fragment,{children:[S&&n.jsx(x1,{phase:X,onSelect:V=>void Le(V),onCancel:()=>ne(null)}),n.jsx(pt,{open:e&&!S,onOpenChange:t,children:n.jsxs(gt,{...K,onKeyDown:qt,desktopProps:{className:"max-w-md",onOpenAutoFocus:Gt},className:H("max-h-[85vh] !min-h-0",Z.isDraggingOver&&"ring-primary ring-2"),children:[n.jsxs(ut,{children:[n.jsx(Xe,{className:"text-sm font-medium",children:"Send feedback"}),n.jsx(mt,{className:"text-muted-foreground text-xs",children:"Straight to the DorkOS team. Private."})]}),n.jsxs("form",{onSubmit:Wt,noValidate:!0,className:"flex min-h-0 flex-1 flex-col gap-4",children:[n.jsxs(wt,{alignWithHeader:!0,className:"flex flex-col gap-4",children:[n.jsx(w1,{kind:y,onChange:xe}),n.jsxs("div",{className:H("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]",Z.isDraggingOver&&"border-primary"),children:[n.jsx(ze,{htmlFor:b,className:"sr-only",children:"Your message"}),n.jsx(Pp,{ref:Ke,id:b,value:j,onChange:V=>I(V.target.value),placeholder:$?r1(W):S1[y],rows:4,maxLength:Lp,className:"min-h-24 resize-none rounded-lg border-0 bg-transparent shadow-none focus-visible:ring-0 dark:bg-transparent"}),($||pe||Z.isPreparing||Z.isDraggingOver)&&n.jsxs("div",{className:"flex flex-wrap items-center gap-2 px-2.5 pb-2.5",children:[$&&n.jsx(Oi,{imageUrl:ae?q??void 0:void 0,alt:`The part you pointed at: ${ee}`,caption:ee,pointed:!0,detail:$.selector,...ae?{onOpen:()=>we("screenshot")}:{},onRemove:at,removeLabel:o1(W)}),pe&&Z.dataUrl&&n.jsx(Oi,{imageUrl:Z.dataUrl,alt:"The screenshot you attached",onOpen:()=>we("screenshot"),onRemove:Z.clear,removeLabel:"Remove screenshot"}),(Z.isPreparing||Z.isDraggingOver)&&n.jsx("p",{role:"status","aria-live":"polite",className:"text-muted-foreground text-xs",children:Z.isDraggingOver?"Drop to attach":"Getting it ready…"})]}),n.jsx(b1,{showPictureTools:!0,isPreparing:Z.isPreparing,hasPointed:$!==null,hasWords:He,isMobile:!c,onCapture:()=>void Z.capture(),onPointAtElement:()=>ne("picking"),onPick:V=>void Z.attach(V)})]}),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(Mi,{label:"Diagnostics",summary:"Version, window size, browser, and recent errors.",pressed:R,onPressedChange:V=>{G(!0),A(V)},onPreview:()=>we("diagnostics")}),g&&n.jsx(Mi,{label:"This chat",summary:"Shows what led to the bug.",pressed:w,onPressedChange:V=>{G(!0),k(V)},onPreview:()=>we("conversation")})]}),n.jsx(y1,{currentUser:a??null,anonymous:O,onToggleAnonymous:()=>P(V=>!V),contact:v,onContactChange:N})]}),n.jsx(j1,{needsWords:ct,canSend:At,isSubmitting:d,onOpenGitHubIssue:()=>h(y==="idea"?"feature":"bug")})]}),n.jsx(h1,{open:E,onOpenChange:D,initialTab:T,diagnostics:p(Q?{crashStack:Q}:void 0),kind:y,route:m,showConversation:g,sessionId:u,...Z.dataUrl?{screenshotDataUrl:Z.dataUrl}:{}})]})})]})}function C1(){const e=jn(a=>a.open),t=jn(a=>a.prefill),s=jn(a=>a.openFeedback),r=jn(a=>a.setOpen),o=$p();return l.useEffect(()=>{const a=Bp();a&&s(a)},[s]),n.jsx(k1,{open:e,onOpenChange:r,initialKind:t.kind,prefillMessage:t.message,crashStack:t.crashStack,currentUser:o?{email:o.email,name:o.name}:null})}function N1(){const e=Re();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 A1(){const{closeActive:e}=To();l.useEffect(()=>{const t=window.electronAPI;if(t!=null&&t.onCloseTab)return t.onCloseTab(()=>e())},[e])}function E1(){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 Pi="window-blurred";function I1(){l.useEffect(()=>{var a,i,c;if(!zp||!((a=window.electronAPI)!=null&&a.onFocusChange))return;const e=document.documentElement,t=d=>{e.classList.toggle(Pi,!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(Pi)}},[])}const R1="/channels";function T1(){rw();const e=Up(),t=Ms(),s=e===R1&&!t.community?t.id??null:null,{data:r}=uc(s),{data:o}=Ps(),a=l.useMemo(()=>(o??[]).filter(tn).length,[o]);return{room:s&&r?r:null,unreadRoomCount:a}}function D1({unreadRoomCount:e}){Vj();const t=_(c=>c.isStreaming),s=_(c=>c.isWaitingForUser),r=On(c=>c.schedulesWaitingCount),o=On(c=>c.needsYouCount),a=Ee({select:c=>c.location.href}),i=co(a);return jy(c=>Kp(i,{...c,badgeCount:e+r,needsYou:s||o>0}),t),null}function O1(){const e=Fn(),t=$s(),s=me(),r=Re(),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:ua(u.ref)}]));if(o.current={owner:a,rows:c},!!i)for(const[u,m]of i){if(m.status!=="connected")continue;const p=c.get(u);if((p==null?void 0:p.status)==="connected")continue;const f=xs(Mn().destination)===u,h=ua(u)>m.generation,g=p===void 0?"removed":"revoked";(h?Promise.resolve():Hp(s,e,u,g)).then(()=>{f&&xs(Mn().destination)===u&&r({...ye.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 M1(){O1(),gv(),Wp()}function _1({isFullscreen:e}){return n.jsx("div",{className:H("desktop-darwin:block app-drag-region hidden shrink-0",!e&&"desktop-darwin:h-11"),"aria-hidden":"true"})}class P1 extends l.Component{constructor(){super(...arguments);fn(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 L1=5e3;function Tu({testId:e,headline:t,detail:s}){const{isFetching:r,refetch:o}=Pe({refetchInterval:L1});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(St,{size:120,className:"mb-8 opacity-80 dark:hidden"}),n.jsx(St,{variant:"white",size:120,className:"mb-8 hidden opacity-80 dark:block"}),n.jsx("h1",{className:"text-xl font-semibold tracking-tight",children:t}),n.jsx("p",{className:"text-muted-foreground mt-3 text-sm",children:s}),n.jsx(F,{variant:"outline",className:"mt-6",onClick:()=>void o(),disabled:r,children:r?"Trying…":"Try again"})]})})}function F1(){return n.jsx(Tu,{testId:"server-unreachable",headline:"DorkOS can’t reach its server",detail:"It may still be starting up. DorkOS keeps checking."})}const $1="onboarding";function B1({render:e}){const t=Gp(),s=qp(),{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:$1}),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 z1={renderAccountLink:e=>n.jsx(B1,{render:e}),renderRuntimeConnect:lx,renderOtherService:({onSave:e})=>n.jsx(dx,{onSave:e})},U1="HOST_NOT_ALLOWED",Li=240;function K1({status:e,message:t,code:s}){const r=s===U1&&t?t:void 0,o=r===void 0?`Your settings didn’t load (HTTP ${e}). DorkOS keeps trying.`:r.length>Li?`${r.slice(0,Li).trimEnd()}…`:r;return n.jsx(Tu,{testId:"server-error",headline:"The server answered with an error",detail:o})}function H1(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 hr={at:0};function W1(e,t){return e>hr.at&&(hr=t==null?{at:e}:{at:e,...H1(t)}),e>nn?hr:void 0}function G1(e){return e.state.dataUpdatedAt>nn?!0:"always"}function q1(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(Qe,{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 Q1=["memory-provider-status"],X1=6e4;function J1(){const e=ce(),{data:t}=ke({queryKey:[...Q1],queryFn:()=>e.getMemoryProviderStatus(),staleTime:X1,refetchOnWindowFocus:!0});return t}function Z1(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||eE(s,r))&&t.set(s.subject.id,s)}return[...t.entries()].filter(([,s])=>s.outcome!=="cleared").map(([s])=>s)}function eE(e,t){return e.createdAt!==t.createdAt?e.createdAt>t.createdAt:e.id>t.id}function tE({configuredId:e,benched:t}){return n.jsxs(bl,{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 nE="runtimes",sE=3;function rE({runtimes:e}){const{open:t}=tt(),s=Yp();if(e.length===0)return null;const r=e.slice(0,sE).map(ol),o=e.length-r.length,a=e.length===1?`${r[0]} sign-in`:`${aE(r)} sign-ins`,i=o>0?`, and ${o} more`:"";return n.jsxs(bl,{variant:"critical",icon:kr,actions:n.jsxs(n.Fragment,{children:[s&&n.jsx(oE,{runtimes:e,renderCreditsOffer:s}),n.jsx(F,{variant:"outline",size:"sm",onClick:()=>t(nE),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 oE({runtimes:e,renderCreditsOffer:t}){var d;const s=sc(),{data:r}=oc(),o=!ux(),a=((d=Tc().data)==null?void 0:d.linked)===!0,i=Vp(a,Dc({enabled:a}).data),c=e.find(u=>Qp(Xp(s.data,u),r,u)==="lead");return c?n.jsxs(Bn,{children:[n.jsx(zn,{asChild:!0,children:n.jsx(F,{size:"sm","data-testid":"signin-banner-credits",disabled:i===null,children:i===null?"DorkOS credits":`${i} DorkOS credits`})}),n.jsxs(Un,{align:"end",className:"w-80 p-4",children:[n.jsxs(Kn,{children:["Run ",ol(c)," on DorkOS credits"]}),n.jsxs("div",{className:"space-y-3",children:[t({runtime:c,origin:`signin-banner:${c}`,fullWidth:!0}),n.jsx(mx,{remote:o})]})]})]}):null}function aE(e){return e.length<=1?e[0]??"":`${e.slice(0,-1).join(", ")} and ${e[e.length-1]}`}const Du={critical:40,warning:30};function iE(){const e=J1();return!e||e.configuredId===e.activeId?null:{id:"memory-provider-benched",variant:"warning",priority:Du.warning,render:()=>n.jsx(tE,{configuredId:e.configuredId,benched:e.benched})}}const cE={kinds:["signin.required"]};function lE(){const{notifications:e}=Jp(cE),t=l.useMemo(()=>Z1(e),[e]);return t.length===0?null:{id:"runtime-signin",variant:"critical",priority:Du.critical,render:()=>n.jsx(rE,{runtimes:t})}}function dE(e){const t=iE(),s=lE();return[t,s].filter(r=>r!==null)}function uE(){const e=Yn(),[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(al,{children:[n.jsx(il,{children:"Share anonymous usage data?"}),n.jsx(cl,{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(kx,{open:t,onToggle:()=>s(a=>!a)}),n.jsx("a",{href:jr("/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(Cx,{})]}),n.jsxs(ll,{className:"items-center gap-2 sm:justify-between",children:[e.isError?n.jsx("p",{role:"alert",className:"text-destructive text-xs",children:"Couldn’t save your choice. Try again."}):n.jsx("span",{"aria-hidden":!0}),n.jsxs("div",{className:"flex justify-end gap-2",children:[n.jsx(F,{variant:"outline",size:"sm",onClick:r,disabled:e.isPending,children:"Don’t share"}),n.jsx(F,{size:"sm",onClick:o,disabled:e.isPending,children:"Share anonymously"})]})]})]})}function mE(e){return e.everyAgentLevel!==void 0?e.everyAgentLevel!==null:e.everyAgent!==null}function hE(e){const{data:t}=Kx(),s=new Set(e),r=((t==null?void 0:t.connections)??[]).filter(a=>s.has(a.connectionId)&&mE(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=Zp(a.toolkit);return{connectionId:a.connectionId,name:(o.get(a.toolkit)??0)>1?`${i} (${a.label})`:i}})}function fE({apps:e,onChooseAgents:t,disabled:s}){return n.jsxs("div",{className:"space-y-1 text-sm","data-testid":"trust-notice-shared-apps",children:[n.jsx("p",{className:"text-muted-foreground",children:"Shared with every agent:"}),n.jsx("ul",{className:"space-y-0.5",children:e.map(r=>n.jsxs("li",{className:"flex items-center justify-between gap-2",children:[n.jsx("span",{children:r.name}),n.jsx(F,{variant:"link",size:"sm",className:"h-auto p-0 text-xs",disabled:s,"aria-label":`Choose agents for ${r.name}`,onClick:()=>t(r.connectionId),children:"Choose agents"})]},r.connectionId))})]})}const pE=Zc("/guides/permissions#what-changed"),gE=["Everything they do is recorded in Activity. Anyone can pause an agent.","Messages and code from strangers still need your yes."],xE="Agents ask first again. Shared apps stay shared; change them in Connections.";function bE(e){return e instanceof Error&&e.message||"Couldn’t save that. Try again."}function yE({onClose:e,sharedConnectionIds:t=[]}){return t.length>0?n.jsx(vE,{onClose:e,connectionIds:t}):n.jsx(Ou,{onClose:e,sharedApps:[]})}function vE({onClose:e,connectionIds:t}){return n.jsx(Ou,{onClose:e,sharedApps:hE(t)})}function Ou({onClose:e,sharedApps:t}){const s=Re(),r=Yn(),o=Lx({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(bE(x)),i(!1);return}i(!1),h&&ue.success(t.length>0?xE:"Agents ask first again. Change it in Permissions."),e(),g==null||g()},p=h=>void s({...ye.connections(),search:{app:h,who:"picked"}}),f=h=>{if(t.length>1){e(),p(h);return}m(!1,()=>p(h))};return n.jsxs(n.Fragment,{children:[n.jsxs(al,{children:[n.jsx(il,{"data-testid":"trust-notice",children:"Agents now work without asking"}),n.jsx(cl,{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:gE.map(h=>n.jsx("p",{children:h},h))}),t.length>0&&n.jsx(fE,{apps:t,onChooseAgents:f,disabled:u}),c&&n.jsx("p",{role:"alert",className:"text-destructive text-xs",children:c}),n.jsxs(ll,{className:"items-center gap-2 sm:justify-between",children:[n.jsx(eg,{href:pE,className:"text-muted-foreground hover:text-foreground text-xs font-medium underline underline-offset-2",children:"What changed"}),n.jsxs("div",{className:"flex flex-wrap justify-end gap-2",children:[n.jsx(F,{variant:"outline",size:"sm",onClick:()=>m(!0),disabled:u,children:"Keep asking me"}),n.jsx(F,{size:"sm",onClick:()=>m(!1),disabled:u,children:"Got it"})]})]})]})}function wE(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:Hx((a=e.permissions)==null?void 0:a.preset)==="trusted"}const Mu={high:30,low:10};function jE(){var t;const{data:e}=Pe();return(t=e==null?void 0:e.telemetry)!=null&&t.userHasDecided?null:{id:"telemetry-consent",priority:Mu.low,render:()=>n.jsx(uE,{})}}function SE(){const{data:e}=Pe();return wE(e)?{id:"trust-notice",priority:Mu.high,render:({onClose:t})=>{var s;return n.jsx(yE,{onClose:t,sharedConnectionIds:((s=e==null?void 0:e.permissions)==null?void 0:s.sharedAtUpgrade)??[]})}}:null}function kE(){const e=SE(),t=jE();return _(r=>r.onboardingHiddenForSession)?[]:[e,t].filter(r=>r!==null)}function CE(e){return e.reduce((t,s)=>t===null||s.priority>t.priority?s:t,null)}function NE({onboardingOverlayVisible:e=!1}){const t=kE(),{data:s,dataUpdatedAt:r}=Pe(),o=_(y=>y.momentShownThisLaunch),a=_(y=>y.markMomentShown),[i,c]=l.useState(null),[d,u]=l.useState(null),m=l.useRef(null),p=(s==null?void 0:s.onboarding)!=null&&(s.onboarding.completedAt!=null||s.onboarding.dismissedAt!=null),f=r>nn,h=e||!f||!p,g=h?null:CE(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(tg,{open:x,onOpenChange:y=>{y||b()},children:d!==null&&n.jsx(ng,{ref:m,onOpenAutoFocus:y=>{var C;y.preventDefault(),(C=m.current)==null||C.focus()},children:d.render({onClose:b})},d.id)})}const AE=[];function EE(){const{approvals:e,isError:t,retry:s}=sg(),{interactions:r}=rg(),o=og(),a=ag(e),i=ig(r),c=Re(),d=l.useMemo(()=>[...e.map(m=>cg(m.approvalId)),...r.map(m=>lg(m.interaction.id))],[e,r]);return!t&&a.length===0&&r.length===0&&o.length===0?{slot:null,coveredSignalIds:AE}:{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(dg,{onRetry:s}),(r.length>0||o.length>0)&&n.jsx(ug,{asks:r,agentNames:i,onOpenSession:m=>{c(_t({session:m}))}}),a.length>0&&n.jsx(mg,{approvals:a})]})}}const _u=[{id:"home",label:"Home",icon:hg,badged:!0,kind:"panel"},{id:"library",label:"All",icon:bo,badged:!1,kind:"panel"},{id:"dorkbot",label:"DorkBot",icon:vo,badged:!1,kind:"action"},{id:"you",label:"You",icon:no,badged:!1,kind:"panel"}],IE=dl.filter(e=>e==="library"),RE=dl.filter(e=>e!=="library"),Gr="calc(3.5rem + env(safe-area-inset-bottom))",ks=fg(e=>({panelUp:!1,raise:()=>e({panelUp:!0}),lower:()=>e({panelUp:!1})}));function Fi(){ks.getState().lower()}function TE({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:Gr,paddingBottom:"env(safe-area-inset-bottom)"},children:_u.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:H("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 fr({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:H("absolute inset-0",!t&&"invisible"),children:s})}function DE({takeover:e}){du();const t=EE(),s=hu({coveredSignalIds:t.coveredSignalIds}),r=uu(s),{ask:o,ready:a}=pg(),[i,c]=l.useState("home"),d=ks(x=>x.panelUp),u=ks(x=>x.raise),m=rn();l.useEffect(()=>m.subscribe("onBeforeLoad",Fi),[m]),l.useEffect(()=>Fi,[]),l.useEffect(()=>(document.documentElement.style.setProperty("--mobile-tab-dock",Gr),()=>{document.documentElement.style.removeProperty("--mobile-tab-dock")}),[]);const p=l.useCallback(x=>{const b=_u.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]),f=r.zones.find(x=>x.id==="now"),h=(f==null?void 0:f.needsYouCount)??s.attention.length,g=vu((f==null?void 0:f.liveRegionText)??gg(h));return n.jsxs(Qc,{activeTarget:s.activeTarget,children:[n.jsxs("div",{"data-testid":"mobile-tab-panels",inert:!d,className:H("bg-background fixed inset-x-0 top-0 z-30",!d&&"pointer-events-none invisible"),style:{bottom:`calc(${Gr} + var(--pip-dock, 0px))`},children:[n.jsx(fr,{id:"home",active:i==="home",children:n.jsxs(Qs,{width:"full",className:"px-3 py-2",children:[n.jsx(ku,{}),n.jsx(Hr,{model:r,zoneIds:RE,nowSlot:t.slot,silenceLiveRegion:!0}),n.jsx(lu,{model:r})]})}),n.jsx(fr,{id:"library",active:i==="library",children:n.jsx(Qs,{width:"full",className:"px-3 py-2",children:e??n.jsx(Hr,{model:r,zoneIds:IE,silenceLiveRegion:!0})})}),n.jsx(fr,{id:"you",active:i==="you",children:n.jsxs(Qs,{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(QN,{}),n.jsx(ul,{})]})})]}),n.jsx("span",{"data-testid":"mobile-needs-you-live-region","aria-live":"polite","aria-atomic":"true",className:"sr-only",children:g}),n.jsx(TE,{current:d?i:null,needsYouCount:h,dorkBotReady:a,onSelect:p})]})}function OE(){const{open:e}=tt(),t=_(r=>r.setControlCenterOpen),s=Us(()=>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(Nx,{surface:"control-center"}),n.jsxs(F,{variant:"ghost",size:"sm",className:"text-muted-foreground h-7 self-start px-2 text-xs",onClick:s(()=>e("permissions")),children:["Edit permissions",n.jsx(on,{className:"size-3.5","aria-hidden":!0})]})]})}const Yt={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 ME(){var m,p;const e=Bs(),t=mo(),s=_(f=>f.setRemoteAccessOpen),r=_(f=>f.setControlCenterOpen),a=Us(()=>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:fl(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=Yt.draining:e.state==="reconnecting"?u=e.host?`On · ${e.host} · reconnecting…`:"Reconnecting…":e.state==="starting"?u=Yt.starting:e.state==="stopping"?u=Yt.stopping:u=Yt.off:u=Yt.unconfigured:u=Yt.off,d&&((p=e.managed)!=null&&p.cloudStale)&&typeof u=="string"&&(u=`${u} · Can’t reach DorkOS Cloud`),n.jsx(ml,{label:"Remote access",description:n.jsx("span",{"data-testid":"remote-access-row-description",className:H("block min-w-0",c&&"motion-safe:animate-breath"),children:u}),children:n.jsx(hl,{checked:i&&e.isChecked,disabled:!d||i&&e.isTransitioning,"aria-label":"Remote access",onCheckedChange:f=>{if(!i){a();return}t.toggle(f)}})})}const _E=1,PE=10,LE=4;function FE(){var d,u;const{data:e}=Pe(),t=Yn(),s=me(),{limits:r,setLimits:o}=xg(),a=()=>void s.invalidateQueries({queryKey:Me.all}),i=((d=e==null?void 0:e.claudeCode)==null?void 0:d.persistentSession)??!0,c=((u=e==null?void 0:e.scheduler)==null?void 0:u.maxConcurrentRuns)??LE;return n.jsx(bg,{children:n.jsxs(yg,{children:[n.jsx(ME,{}),n.jsx(gb,{}),n.jsx(ma,{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(ba,{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:m=>o({turnLimitsEnabled:m})}),n.jsx(ma,{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(ba,{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:i,disabled:t.isPending,onCheckedChange:m=>t.mutate({runtimes:{claudeCode:{persistentSession:m}}},{onSuccess:a})}),n.jsx(ml,{label:"Scheduled runs at once",description:"How many scheduled tasks run together.",children:n.jsx(Ax,{value:c,min:_E,max:PE,"aria-label":"Scheduled runs at once",onCommit:m=>t.mutate({scheduler:{maxConcurrentRuns:m}},{onSuccess:a})})})]})})}const $i="claude-code";function $E(){var O,P,R,A,w;const{data:e}=Pe(),{data:t}=rc(),{sessions:s}=Lc(),r=vg(),{data:o}=Ec(r),{data:a}=xx(),i=Fx(),c=i.data,d=cj(),u=ro(),{open:m}=tt(),{open:p}=yo(),f=to(),h=_(k=>k.setControlCenterOpen),g=Us(()=>h(!1)),x=i.isError,b=t===void 0||e===void 0||c===void 0&&!x,y=e==null?void 0:e.executionDefaults,C=(y==null?void 0:y.runtime)??$i,j=(O=t==null?void 0:t.capabilities[C])==null?void 0:O.permissionModes,I=((P=j==null?void 0:j.values.find(k=>k.id===j.default))==null?void 0:P.stop)??"ask",v=(y==null?void 0:y.trustStop)??I,N=[];if(!b){for(const E of(y==null?void 0:y.perRuntime)??[])E.trustStop===null||E.trustStop===v||N.push({key:`runtime:${E.runtime}`,kind:"runtime",name:rt(E.runtime).label,detail:qs(E.trustStop),onOpen:u?g(()=>m("runtimes")):null});for(const E of s){const D=(R=t==null?void 0:t.capabilities[E.runtime])==null?void 0:R.permissionModes,T=D==null?void 0:D.values.find($=>$.id===E.permissionMode),L=T==null?void 0:T.stop;!L||L===v||N.push({key:`session:${E.id}`,kind:"session",name:E.title||"Untitled chat",detail:(T==null?void 0:T.label)??Ys(E.permissionMode),onOpen:u?g(()=>u(_t({session:E.id,dir:E.cwd}))):null})}const k=((w=(A=t==null?void 0:t.capabilities[$i])==null?void 0:A.permissionModes)==null?void 0:w.values)??[];for(const E of o??[]){const D=k.find(L=>L.id===E.permissionMode),T=D==null?void 0:D.stop;!T||T===v||N.push({key:`task:${E.id}`,kind:"task",name:E.displayName??E.name,detail:(D==null?void 0:D.label)??Ys(E.permissionMode),onOpen:u?g(()=>u({...ye.tasks()})):null})}for(const E of a??[]){const D=k.find(L=>L.id===E.permissionMode),T=D==null?void 0:D.stop;!T||T===v||N.push({key:`binding:${E.id}`,kind:"binding",name:E.label||E.adapterId,detail:(D==null?void 0:D.label)??Ys(E.permissionMode),onOpen:u?g(()=>f({app:E.adapterId})):null})}}if(c){const k=new Map(c.areas.map(T=>[T.id,T.label])),E=new Map(c.areas.flatMap(T=>T.actions.map(L=>[L.id,L.title]))),D=T=>g(()=>p(T,"permissions"));for(const T of c.exceptions){const L=T.action?E.get(T.action)??T.action:k.get(T.area),$=$x[T.state];N.push({key:`agent-permission:${T.agentId}:${T.action??T.area}`,kind:"agent-permission",name:T.agentName,detail:`${L??T.area} ${$}`,why:{question:`Why is ${L??T.area} set to ${$} for ${T.agentName}?`,sentence:Bx({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)N.push({key:`agent-permission:${T.agentId}:files`,kind:"agent-permission",name:T.agentName,detail:`Files & commands ${qs(T.stop)}`,why:{question:`Why is Files & commands set to ${qs(T.stop)} for ${T.agentName}?`,sentence:zx(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:N,isEmpty:!b&&!x&&N.length===0,isResolving:b,permissionsUnreadable:x}}const BE={runtime:Ab,session:wg,task:ko,binding:ac,"agent-permission":Rb};function zE(){const{rows:e,isEmpty:t,isResolving:s,permissionsUnreadable:r}=$E();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=BE[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(on,{className:"text-muted-foreground/60 size-3.5 shrink-0","aria-hidden":!0})]}),o.why?n.jsx(Ux,{question:o.why.question,sentence:o.why.sentence,...o.why.lastChange?{lastChange:o.why.lastChange}:{},className:"shrink-0 px-1"}):null,o.onReset?n.jsxs(F,{variant:"ghost",size:"sm",className:"h-7 shrink-0 px-2 text-xs",disabled:o.resetting,"aria-label":`Reset ${o.name}: ${o.detail}`,onClick:o.onReset,children:[n.jsx(jg,{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 UE(){const e=Sl();return kl(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(Xl,{className:"mt-px size-3 shrink-0","aria-hidden":!0}),n.jsxs("span",{children:["Keeping this computer awake: ",Cl(e.working),"."]})]}):null}function KE(){return n.jsxs("div",{className:"flex flex-col gap-4","data-testid":"control-center-body",children:[n.jsx(OE,{}),n.jsx(FE,{}),n.jsx(zE,{}),n.jsx(UE,{})]})}function HE(){const e=_(r=>r.controlCenterOpen),t=_(r=>r.setControlCenterOpen),s=Ae();return n.jsxs(Bn,{open:e,onOpenChange:t,modal:!0,autoFocus:!0,children:[n.jsx(zn,{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(ha,{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(ha,{className:"text-status-success size-4 shrink-0","aria-hidden":!0}),n.jsx("h2",{className:"text-sm font-semibold",children:"Control Center"})]}),n.jsx(Kn,{children:"Control Center"}),n.jsx(KE,{})]})]})}function WE(){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 GE(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 qE({url:e}){const t=et();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(Sg,{url:e,size:168})}),n.jsx("p",{className:"text-muted-foreground mt-2 text-center text-xs",children:"Scan with your phone"})]})}function YE({url:e}){const{copied:t,failed:s,copy:r}=$n();let o,a;return t?(o=n.jsx(zt,{className:"size-3.5"}),a="Copied"):s?(o=n.jsx(_e,{className:"text-destructive size-3.5"}),a="Couldn’t copy"):(o=n.jsx(Zr,{className:"size-3.5"}),a="Copy link"),n.jsxs("div",{className:"bg-muted/40 rounded-lg border p-2.5","data-testid":"remote-access-link",children:[n.jsx("p",{className:"text-foreground truncate font-mono text-xs",title:e,children:e}),n.jsxs(F,{variant:"outline",size:"sm",className:"mt-2 w-full gap-1.5",onClick:()=>void r(e),children:[o,a]})]})}function VE(){const e=Bs(),t=e.managed;if(!t)return null;const s=[];return t.alwaysAvailable&&s.push("Always available"),e.state==="asleep"&&s.push("Your address stays the same."),t.reason&&s.push(t.reason),t.cloudStale&&s.push("Couldn’t reach DorkOS Cloud. Showing the last known state."),s.length===0?null:n.jsx("div",{className:"text-muted-foreground space-y-1 text-xs","data-testid":"remote-access-managed-note",children:s.map(r=>n.jsx("p",{children:r},r))})}function QE({onClose:e}){const t=Bs(),s=mo(),r=Ae(),o=_(p=>p.setRemoteAccessOpen),a=Us(e),i=t.url,c=t.mode==="managed",d=i?n.jsx(YE,{url:i},"link"):null,u=i?n.jsx(qE,{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:H("inline-block size-2 shrink-0 rounded-full",pl(t.state)),"aria-hidden":!0}),n.jsx("h2",{className:"text-sm font-semibold",children:gl(t.state)})]}),t.error!==null&&n.jsx("p",{role:"alert","data-testid":"remote-access-panel-error",className:"text-destructive text-xs",children:fl(t.error)}),c&&n.jsx(VE,{}),i===null&&t.state!=="asleep"&&n.jsx("p",{className:"text-muted-foreground text-xs",children:"Your link appears here when it’s ready."}),m,n.jsxs("div",{className:"flex items-center justify-between gap-3 pt-1",children:[n.jsx("span",{className:"text-muted-foreground text-sm",children:"Remote access"}),n.jsx(hl,{checked:t.isChecked,disabled:t.isTransitioning,"aria-label":"Remote access",onCheckedChange:p=>void s.toggle(p)})]}),n.jsx(F,{variant:"ghost",size:"sm",className:"text-muted-foreground hover:text-foreground -mx-1 justify-start",onClick:a(()=>o(!0)),children:"Manage…"})]})}function Pu(e,t){return e==="starting"?"Remote access is connecting":e==="reconnecting"?"Remote access is reconnecting":e==="stopping"?"Remote access is turning off":e==="draining"?"Remote access is closing":e==="asleep"?t?`Remote access is closed for now at ${t}`:"Remote access is closed for now":t?`Remote access is on at ${t}`:"Remote access is on"}function XE(e,t){const s=e==="starting"||e==="asleep"&&!t?"Open remote access":"Show link and QR code";return`${Pu(e,t)}. ${s}`}function JE(){const e=Bs(),t=_(i=>i.remoteAccessBeaconOpen),s=_(i=>i.setRemoteAccessBeaconOpen),r=et(),o=GE(e.state,e.hasServerReport);l.useEffect(()=>{!e.isLive&&t&&s(!1)},[e.isLive,t,s]);const a=e.isLive?Pu(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(Bn,{open:t,onOpenChange:s,modal:!0,children:[n.jsx(zn,{asChild:!0,children:n.jsxs("button",{type:"button","data-testid":"remote-access-beacon","data-state-name":e.state,"aria-label":XE(e.state,e.host),className:H("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(fs,{className:H("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:H("border-background absolute right-0.5 bottom-0.5 size-1.5 rounded-full border",pl(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(Kn,{children:gl(e.state)}),n.jsx(QE,{onClose:()=>s(!1)})]})]})]})}function ZE({work:e}){const{isDesktop:t}=kg();return t?n.jsxs("p",{className:"text-sm font-medium",children:["Keeping awake: ",e]}):n.jsxs(Kn,{className:"text-sm font-medium",children:["Keeping awake: ",e]})}function eI(){const e=Sl(),{open:t}=tt(),[s,r]=l.useState(!1);if(!kl(e))return null;const o=Cl(e.working);return n.jsxs(Bn,{open:s,onOpenChange:r,children:[n.jsx(zn,{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(Xl,{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(ZE,{work:o}),n.jsx("p",{className:"text-muted-foreground text-xs",children:Ex}),n.jsx(F,{variant:"outline",size:"sm",onClick:()=>{r(!1),t(ga.tab,ga.section)},children:"Sleep settings"})]})]})}function tI(){const e=ce(),t=me();return Bt({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 nI(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 sI({step:e,templateName:t,seedDisplayName:s=null,faceSeed:r=null,runtimeSeed:o="claude-code"}){var se;const a=ce(),{data:i}=ke({queryKey:Me.current(),queryFn:()=>a.getConfig(),staleTime:3e4}),c=((se=i==null?void 0:i.agents)==null?void 0:se.defaultDirectory)??"",[d,u]=l.useState(""),[m,p]=l.useState(!1),[f,h]=l.useState(""),[g,x]=l.useState(!1),[b,y]=l.useState(!1),[C,j]=l.useState(null),[I,v]=l.useState(""),[N,O]=l.useState(!1),[P,R]=l.useState(o),[A,w]=l.useState(s);s!==A&&(w(s),s&&(u(s),p(!1)));const[k,E]=l.useState(o);o!==k&&(E(o),R(o));const D=l.useMemo(()=>d?Cg(d):"",[d]),T=l.useMemo(()=>D?Ng(D):{valid:!1,error:void 0},[D]),L=d.length>0&&D.length>0&&!T.valid,$=f||(c&&D?`${c}/${D}`:""),B=e!=="naming"||!$?"idle":C!==null&&C.directory===$?C.status:"checking",q=d.length>0&&T.valid&&B!=="error",oe=l.useRef(null);l.useEffect(()=>{if(e!=="naming")return;const te=t?!d||m?t.replace(/^@[^/]+\//,""):null:m?"":null;if(te===null)return;const M=`${e}|${t??""}`;oe.current!==M&&(oe.current=M,u(te),p(!!t))},[e,t]);const ie=l.useRef(null);l.useEffect(()=>{if(e!=="naming"||N||!r)return;const te=`${e}|${r}`;ie.current!==te&&(ie.current=te,v(r))},[e,r]),l.useEffect(()=>{if(e!=="naming"||!$)return;const te=$,M=setTimeout(()=>{nI(a,te).then(z=>{j({directory:te,status:z})})},500);return()=>clearTimeout(M)},[e,$,a]);function Y(te){u(te),m&&p(!1)}function X(te){v(te),O(!0)}function ne(){oe.current=null,ie.current=null,u(""),p(!1),h(""),x(!1),y(!1),j(null),v(""),O(!1),R(o)}return{displayName:d,slug:D,handleNameChange:Y,nameAutoFilled:m,slugValidation:T,showSlugError:L,defaultDirectory:c,resolvedDirectory:$,directoryOverride:f,setDirectoryOverride:h,directoryOpen:g,setDirectoryOpen:x,directoryPickerOpen:b,setDirectoryPickerOpen:y,conflictStatus:B,canSubmit:q,icon:I,setIcon:X,runtime:P,setRuntime:R,reset:ne}}function rI(e){var a;const t=(e==null?void 0:e.packageName)??null,{data:s,isError:r,error:o}=Dx(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&&Ox(o)&&{refusal:o},...s!=null&&s.disclosed&&s.contentHash?{approval:{approvedDisclosure:s.disclosed,approvedContentHash:s.contentHash},packageAgentName:s.manifest.name}:{}}}const oI={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."}},pr={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"]},aI=[["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 iI(e){if(!e)return pr.default;const t=[e.name,e.description,e.category,...e.tags??[]].filter(Boolean).join(" ").toLowerCase();for(const[s,r]of aI)if(r.some(o=>t.includes(o)))return pr[s];return pr.default}function cI(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 lI=64,dI=16,Bi=3;function uI(e){return e.map(t=>t.replace(/[\u0000-\u001f\u007f]/g," ").replace(/\s+/g," ").trim().slice(0,lI)).filter(t=>t.length>0).slice(0,dI)}function mI(e){const t=uI(e.capabilities??[]),s=t.length>0?`
87
-
88
- 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 ${Qt.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 ${Qt.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(`
89
- `)}function hI(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 ${Qt.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 ${Bi} 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 ${Bi} 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 ${Qt.soul} now, using your file-editing tools. It lives at \`.dork/${Qt.soul}\` in your working directory and already contains a "Personality Traits" block fenced by \`${Ag}\` and \`${fa}\` — leave that fenced block exactly as it is. Replace only the prose BELOW the \`${fa}\` 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 ${Qt.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(`
90
- `)}const fI={template:mI,"design-your-own":hI};function pI(e,t){return fI[e](t)}function gI(e,t){return Yx(pI(e,t))}const Lu="🤖",xI=["🤖","🦾","🧭","🛰️","📡","🔭","🗺️","🧠","🦉","🦊","🐝","🐙","🚀","⚡","🌟","🔮","🛠️","🔧","📊","📋","✅","🗂️","🔔","🛡️"];function zi({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:H("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 bI(e){return{source:e.source,name:e.name,displayName:xl(e),description:e.description,icon:e.icon,tags:e.tags,category:e.category,packageName:e.name,...e.marketplace?{marketplace:e.marketplace}:{}}}function yI(e){return e.tags&&e.tags.length>0?e.tags.slice(0,2):e.category?[e.category]:[]}function vI(e){const t=e.replace(/\/+$/,"");return t.split("/").pop()??t}function wI({onDesignYourOwn:e,onSelectTemplate:t,onImport:s}){const{data:r,error:o,isLoading:a}=Eg(),i=Tl(a),[c,d]=l.useState(""),[u,m]=l.useState(!1),p=l.useMemo(()=>(r??[]).filter(h=>h.type==="agent"),[r]),f=Cy(p.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(zi,{ref:f.setRef(0),variant:"design",face:n.jsx(vo,{className:"text-primary size-7"}),title:"Design your own",subtitle:"Describe the job in your own words.",tabIndex:f.tabIndexFor(0),onSelect:e,onKeyDown:h=>f.handleKeyDown(h,0),"data-testid":"gallery-design-your-own"}),p.map((h,g)=>{const x=g+1;return n.jsx(zi,{ref:f.setRef(x),variant:"template",face:h.icon??Lu,title:xl(h),subtitle:h.description??"A ready-made agent.",chips:yI(h),tabIndex:f.tabIndexFor(x),onSelect:()=>t(bI(h)),onKeyDown:b=>f.handleKeyDown(b,x),"data-testid":`gallery-template-${h.name}`},h.name)}),i&&p.length===0&&Array.from({length:2}).map((h,g)=>n.jsx(Dt,{className:"h-28 rounded-xl","data-testid":"gallery-skeleton"},g))]}),!i&&p.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(wo,{open:u,onOpenChange:m,children:[n.jsx(jo,{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(Ut,{className:H("size-3.5 transition-transform",u&&"rotate-180")}),"Build from a template URL"]})}),n.jsx(So,{children:n.jsxs("div",{className:"flex items-center gap-2 pt-2",children:[n.jsx(ft,{value:c,onChange:h=>d(h.target.value),placeholder:"github.com/org/repo","data-testid":"custom-url-input",className:"flex-1"}),n.jsx(F,{size:"sm",disabled:!c,onClick:()=>{const h=vI(c);t({source:c,name:h,displayName:Ig(h)}),d("")},"data-testid":"custom-url-go",children:"Continue"})]})})]}),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(Rg,{className:"size-4"}),"Bring in an existing project folder",n.jsx("span",{"aria-hidden":!0,children:"→"})]})})]})}function jI({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:xI.map(s=>{const r=s===e;return n.jsx("button",{type:"button","aria-label":`Face ${s}`,"aria-pressed":r,onClick:()=>t(s),className:H("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 SI({value:e,onChange:t}){return n.jsx("div",{role:"radiogroup","aria-label":"Runs on",className:"flex gap-1.5","data-testid":"runtime-picker",children:Tg.map(s=>{const r=rt(s),o=r.icon,a=e===s;return n.jsxs("button",{type:"button",role:"radio","aria-checked":a,onClick:()=>t(s),className:H("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 kI({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:H("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:H("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 Fu({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(ko,{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}),": ",Mx(r)]},`${r.name}-${o}`))})]}),t&&n.jsxs("div",{className:"flex items-start gap-2","data-testid":`${s}-offer-check-failed`,children:[n.jsx(Vi,{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 Ui=4;function CI({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:p,packageDirectory:f,templateReview:h,inheritance:g,isCheckingInheritance:x=!1}){const b=l.useRef(null),[y,C]=l.useState(0),j=e.displayName.trim().toLowerCase(),I=t.filter(P=>P.toLowerCase()!==j),v=cI(I,y,Ui);l.useEffect(()=>{const P=setTimeout(()=>{var R;return(R=b.current)==null?void 0:R.focus()},160);return()=>clearTimeout(P)},[]);const N=e.displayName.trim(),O=c?`Creating ${N||"your agent"}…`:`Create ${N||"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(Nc,{className:"size-3.5"}),"Choose a different agent"]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(ze,{htmlFor:"agent-name",className:"text-sm",children:"Name"}),n.jsx(ft,{ref:b,id:"agent-name",placeholder:"Name your agent",value:e.displayName,onChange:P=>e.handleNameChange(P.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"}),n.jsx("button",{type:"button",className:"text-primary text-xs hover:underline",onClick:a,"data-testid":"import-instead-link",children:"Import it instead"})]})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx("span",{className:"text-muted-foreground text-xs",children:"Need a name?"}),n.jsx("button",{type:"button",onClick:()=>C(P=>P+Ui),"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(P=>n.jsx("button",{type:"button",onClick:()=>e.handleNameChange(P),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-${P}`,children:P},P))})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsxs("div",{className:"flex items-baseline gap-2",children:[n.jsx(ze,{className:"text-sm",children:"Face"}),!e.icon&&n.jsx("span",{className:"text-muted-foreground text-xs",children:"Picked for you if skipped"})]}),n.jsx(jI,{value:e.icon,onChange:e.setIcon})]}),n.jsxs(wo,{open:e.directoryOpen,onOpenChange:e.setDirectoryOpen,children:[n.jsx(jo,{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(Ut,{className:H("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(So,{children:n.jsxs("div",{className:"space-y-4 pt-3",children:[n.jsxs("div",{className:"space-y-1.5",children:[n.jsx(ze,{className:"text-muted-foreground text-xs",children:"Runs on"}),n.jsx(SI,{value:e.runtime,onChange:e.setRuntime})]}),f?n.jsxs("div",{className:"space-y-1.5","data-testid":"package-directory",children:[n.jsx(ze,{className:"text-muted-foreground text-xs",children:"Directory"}),n.jsx("p",{className:"font-mono text-xs [overflow-wrap:anywhere]",children:f}),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(ze,{htmlFor:"agent-directory",className:"text-muted-foreground text-xs",children:"Directory"}),n.jsx(zb,{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."})]}),!f&&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(kI,{face:e.icon||Lu,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(Fu,{schedules:d,checkFailed:u,testIdPrefix:"naming"})}),p!==void 0&&n.jsx(El,{error:p}),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(F,{size:"lg",onClick:i,disabled:!e.canSubmit||c||m||x||p!==void 0,"data-testid":"create-button",children:O})]})]})}function NI({seed:e,packageSchedules:t,isCheckingOffer:s,offerCheckFailed:r,offerRefusal:o,resolvedDirectory:a,canSubmit:i,isCreating:c,inheritance:d,isCheckingInheritance:u=!1,onCreate:m,onCustomize:p,onNotNow:f}){const{displayName:h,persona:g,runtime:x,capabilities:b,skills:y,schedule:C,icon:j}=e.template,I=rt(x??"claude-code").label,v=h.trim().charAt(0).toUpperCase()||"?",N=j&&Nr(j)?j:v,O=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:N}),n.jsxs("div",{className:"space-y-1",children:[n.jsxs(Xe,{className:"text-xl",children:["Meet ",h]}),n.jsx(mt,{children:O})]})]}),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(AI,{runtime:x}),n.jsx("dt",{className:"text-muted-foreground shrink-0",children:"Runs on"}),n.jsx("dd",{children:I})]}),n.jsxs("div",{className:"flex items-start gap-2",children:[n.jsx(Is,{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(Dt,{className:"h-3.5 w-48 max-w-full rounded"})})]}),C&&n.jsxs("div",{className:"flex items-start gap-2","data-testid":"arrival-schedule",children:[n.jsx(ko,{className:"text-muted-foreground mt-0.5 size-4 shrink-0"}),n.jsx("dt",{className:"text-muted-foreground shrink-0",children:"Runs on a schedule"}),n.jsx("dd",{children:C})]}),n.jsx(Fu,{schedules:t,checkFailed:r,testIdPrefix:"arrival"}),b&&b.length>0&&n.jsxs("div",{className:"flex items-start gap-2",children:[n.jsx(Ix,{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(Dg,{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(El,{error:o}),n.jsxs("div",{className:"flex flex-col gap-2",children:[!i&&n.jsx("p",{className:"text-status-warning-fg text-center text-xs","data-testid":"arrival-needs-name",children:"Needs a name. Choose “Customize first” to add one."}),s&&n.jsx("p",{className:"text-muted-foreground text-center text-xs","data-testid":"arrival-checking-offer",children:"Checking for scheduled work…"}),d,n.jsx(F,{size:"lg",onClick:m,disabled:c||!i||s||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(F,{variant:"ghost",size:"sm",onClick:p,className:"text-muted-foreground","data-testid":"arrival-customize",children:"Customize first"}),n.jsx(F,{variant:"ghost",size:"sm",onClick:f,className:"text-muted-foreground","data-testid":"arrival-not-now",children:"Not now"})]})]})]})}function AI({runtime:e}){const t=rt(e??"claude-code").icon;return n.jsx(t,{size:16,className:"text-muted-foreground shrink-0"})}function EI(e){const t=e==null?void 0:e.body;return(t==null?void 0:t.code)==="template_needs_review"?t.template:void 0}function II(e,t){const s=e.replace(/\/*$/,"/");return t.filter(r=>r.path===e||r.path.startsWith(s))}function RI(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 TI(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 DI(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:II(s.path,e.settings??[])})),...t.hooks.map((s,r)=>({key:`hook:${r}`,label:lt(s.command),detail:`Runs on ${s.event}${s.source?`, while ${lt(s.source)} is in use`:""}.`})),...(t.skillCommands??[]).map((s,r)=>({key:`command:${s.source}:${r}`,label:lt(s.command),detail:`Runs when skill “${lt(s.skill)}” is used (${lt(s.source)})`+(s.usesArguments?". Reads the text typed after it.":".")})),...t.mcpServers.map(s=>({key:`mcp:${s.name}`,label:s.command?Mg(s.command,s.args):lt(s.url??s.name),detail:`Starts the MCP server “${lt(s.name)}”.`})),...t.skillTools.map(s=>({key:`tools:${s.source}`,label:s.tools.map(lt).join(", "),detail:`Skill “${lt(s.skill)}” may use these without asking you.`}))]}function OI({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(Og,{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:DI(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:RI(i)})]},i.path))]},o.key)})}),n.jsxs("div",{className:"flex flex-wrap justify-end gap-2",children:[n.jsx(F,{variant:"ghost",size:"sm",onClick:s,disabled:r,children:"Don’t create it"}),n.jsx(F,{size:"sm",onClick:t,disabled:r,className:"h-auto max-w-full py-1.5 text-left [overflow-wrap:anywhere] whitespace-normal",children:r?"Creating…":TI(e)})]})]})}function MI(){const{isOpen:e,seed:t,onCreated:s,close:r}=Es(),o=Tn(ie=>ie.open),a=tI(),i=Re(),[c,d]=l.useState("gallery"),[u,m]=l.useState(null),[p,f]=l.useState(!1);e!==p&&(f(e),e&&(m(null),d(t?"arrival":"gallery")));const h=t!=null&&t.template.icon&&Nr(t.template.icon)?t.template.icon:void 0,g=u!=null&&u.icon&&Nr(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=rI(b),{data:C}=Pe(),j=b&&y.packageAgentName&&(C!=null&&C.dorkHome)?`${C.dorkHome}/agents/${y.packageAgentName}`:void 0,[I,v]=l.useState(null),N=sI({step:c,templateName:(u==null?void 0:u.displayName)??null,seedDisplayName:(t==null?void 0:t.template.displayName)??null,faceSeed:g,runtimeSeed:x}),O=iI(u?{name:u.name,description:u.description,category:u.category,tags:u.tags}:t?{name:t.template.displayName,description:t.template.persona}:void 0),P=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.",R=u?u.tags??[]:(t==null?void 0:t.template.capabilities)??[];function A(){N.reset(),v(null),m(null),d("gallery")}const w=l.useCallback(ie=>{m(ie),d("naming")},[]),k=l.useCallback(()=>{m(null),d("naming")},[]);function E(){d(t?"arrival":"gallery")}function D(){r(),A(),o()}function T(ie){var ne;if(!N.canSubmit||a.isPending)return;const Y=(b==null?void 0:b.packageName)!==void 0&&y.approval?{package:{name:b.packageName,...b.marketplace?{marketplace:b.marketplace}:{},...y.approval}}:void 0,X=Y?void 0:(u==null?void 0:u.source)??(t==null?void 0:t.template.source);a.mutate({name:N.slug,displayName:N.displayName.trim()||void 0,runtime:N.runtime,...!Y&&N.directoryOverride?{directory:N.directoryOverride}:{},...N.icon?{icon:N.icon}:{},...Y??{},...X?{template:X}:{},...ie?{approvedTemplateHash:ie}:{},...t!=null&&t.template.persona?{persona:t.template.persona}:{},...(ne=t==null?void 0:t.template.capabilities)!=null&&ne.length?{capabilities:t.template.capabilities}:{}},{onSuccess:se=>{const te=crypto.randomUUID(),M=se.displayName??se.name,z=u||t?"template":"design-your-own";_g.getState().register(te,{name:se.name,displayName:M,agentId:se.id,icon:se.icon,color:se.color,bornAt:se.registeredAt,path:se._path,runtime:se.runtime,kickoffMessage:gI(z,{displayName:M,capabilities:se.capabilities})}),$b();const G=s;if(r(),A(),G){G();return}i(_t({agentId:se.id,draft:"1",session:te,runtime:se.runtime}))},onError:se=>{const te=EI(se);te&&v(te)}})}function L(ie){ie||(r(),A())}const $=Il(e),B=n.jsx(Yv,{agentName:N.displayName||(t==null?void 0:t.template.displayName)||""}),q=oI[c],oe=c==="gallery"?"max-w-6xl":c==="naming"?"max-w-5xl":"max-w-2xl";return n.jsx(pt,{open:e,onOpenChange:L,defaultFullscreen:!0,children:n.jsxs(gt,{className:"flex flex-col gap-0 p-0",children:["title"in q&&n.jsxs(ut,{className:"shrink-0 border-b px-5 py-4",children:[n.jsx(Xe,{children:q.title}),n.jsx(mt,{children:q.description})]}),n.jsx("span",{className:"sr-only","aria-live":"polite","aria-atomic":"true",children:q.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 ${oe}`,children:[n.jsx(Qe,{mode:"wait",children:n.jsxs(re.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.15},children:[c==="gallery"&&n.jsx(wI,{onDesignYourOwn:k,onSelectTemplate:w,onImport:D}),c==="arrival"&&t&&n.jsx(NI,{seed:t,packageSchedules:y.schedules,isCheckingOffer:y.isChecking,offerCheckFailed:y.failed,offerRefusal:y.refusal,resolvedDirectory:j??N.resolvedDirectory,canSubmit:N.canSubmit,isCreating:a.isPending,inheritance:B,isCheckingInheritance:$.isPending,onCreate:()=>T(),onCustomize:()=>d("naming"),onNotNow:()=>L(!1)}),c==="naming"&&n.jsx(CI,{form:N,suggestionPool:O,jobLine:P,previewCapabilities:R,onBack:E,onImportInstead:D,onCreate:()=>T(),isCreating:a.isPending,packageSchedules:y.schedules,offerCheckFailed:y.failed,offerRefusal:y.refusal,isCheckingOffer:y.isChecking,packageDirectory:j,inheritance:B,isCheckingInheritance:$.isPending,templateReview:I?n.jsx(OI,{template:I,isCreating:a.isPending,onCreateAnyway:()=>T(I.contentHash),onCancel:()=>v(null)}):void 0})]},c)}),c!=="gallery"&&n.jsx(xb,{className:"mt-6"})]})}),n.jsx(lc,{open:N.directoryPickerOpen,onOpenChange:N.setDirectoryPickerOpen,initialPath:N.directoryOverride||N.defaultDirectory,onSelect:ie=>{N.setDirectoryOverride(ie),N.directoryOpen||N.setDirectoryOpen(!0)}})]})})}function _I({sessionId:e}){l.useEffect(()=>{var a;const r=vt.getState(),o=((a=r.sessions[e])==null?void 0:a.cwd)??r.statusCwds[e]??null;return ms.pinSession(e,o),pa.getState().setPinnedSession(e),()=>{ms.unpinSession(),pa.getState().setPinnedSession(null)}},[e]);const t=Pg(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(Cb,{code:s.code,isIncomplete:s.isIncomplete,sessionId:e,isLatestMessage:s.isLatest,isStreaming:s.isStreaming},s.sourceMessageKey)}function PI({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 gr=64,LI={type:"spring",stiffness:480,damping:44};function FI({content:e,onRestore:t,onClose:s}){l.useEffect(()=>(document.documentElement.style.setProperty("--pip-dock",`${gr}px`),()=>{document.documentElement.style.removeProperty("--pip-dock")}),[]);const r=lb();return Cs.createPortal(n.jsxs(re.div,{"data-slot":"pip-minibar",role:"complementary","aria-label":e.title,initial:{y:gr},animate:{y:0},exit:{y:gr},transition:LI,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(Ey,{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(_e,{className:"size-4"})})]}),document.body)}const rs={peek:.5,expanded:.94},$I=.4,BI=800,Ki=500,xr={type:"spring",stiffness:480,damping:44};function zI({content:e,onClose:t,onMinimize:s,children:r}){const o=ty(),a=Jb(),[i,c]=l.useState("peek"),d=Wl(),u=d.height,m=Math.max(0,window.innerHeight-d.top-d.height),p=rs.expanded*u,f=(rs.expanded-rs.peek)*u,h=i==="expanded"?0:f;l.useEffect(()=>{a.start({y:h,transition:xr})},[a,h]);const g=(b,y)=>{const C=h+y.offset.y,j=y.velocity.y,I=C-f,v=rs.peek*u;if(I>$I*v||I>0&&j>BI){s();return}let N;j<-Ki?N="expanded":j>Ki?N="peek":N=C<f/2?"expanded":"peek",N===i?a.start({y:h,transition:xr}):c(N)},x=b=>{b.target.closest("button")||o.start(b)};return Cs.createPortal(n.jsxs(re.div,{"data-slot":"pip-sheet",role:"complementary","aria-label":e.title,initial:{y:p},animate:a,exit:{y:p},transition:xr,drag:"y",dragListener:!1,dragControls:o,dragConstraints:{top:0,bottom:p},dragElastic:.1,dragMomentum:!1,onDragEnd:g,style:{height:p,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(Ut,{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(_e,{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 Hi=360,Wi=240,qr=16,br={demo:PI,mcp_app:UI,widget:KI};function UI({content:e}){return n.jsx(_b,{sessionId:e.sessionId,serverName:e.serverName,uri:e.uri,title:e.title,className:"h-full"})}function KI({content:e}){return n.jsx(_I,{sessionId:e.sessionId})}function HI(e){l.useEffect(()=>{},[e])}function Gi(){return{x:window.innerWidth-Hi-qr,y:window.innerHeight-Wi-qr,width:Hi,height:Wi}}function WI(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function $u(e){switch(e.kind){case"demo":{const t=br.demo;return n.jsx(t,{content:e})}case"mcp_app":{const t=br.mcp_app;return n.jsx(t,{content:e})}case"computer":return n.jsx(Ub,{content:e});case"widget":{const t=br.widget;return n.jsx(t,{content:e})}default:return e}}function GI({content:e,onClose:t}){const s=_(c=>c.pipGeometry),r=_(c=>c.setPipGeometry),[o,a]=l.useState(Gi);l.useEffect(()=>{if(s!==null)return;const c=()=>a(d=>{const u=Gi();return WI(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-qr),y:Math.max(0,window.innerHeight-360-80)}),[s,o,e==null?void 0:e.kind]);return n.jsx(Qe,{children:e!==null&&n.jsx(zy,{title:e.title,geometry:i,onGeometryChange:r,onClose:t,minWidth:e.kind==="computer"?360:void 0,minHeight:e.kind==="computer"?300:void 0,children:$u(e)},"pip-panel")})}function qI(){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=Ae();HI(a);const c=l.useRef(i);return l.useEffect(()=>{i&&!c.current&&e!==null&&r(),c.current=i},[i,e,r]),i?n.jsx(Qe,{children:e!==null&&(t?n.jsx(FI,{content:e,onRestore:o,onClose:s},"pip-minibar"):n.jsx(zI,{content:e,onClose:s,onMinimize:r,children:$u(e)},"pip-sheet"))}):n.jsx(GI,{content:e,onClose:s})}const YI=new Set(["permission-prompt","question","schedule-approval"]),VI={"permission-prompt":"Needs your approval to go on.",question:"Has a question for you.","schedule-approval":"Wants to run on a timer."};function Bu(e){const t=Wc(),s=Lg(),r=Jt(e),o=l.useRef(null);l.useEffect(()=>{var u,m,p,f;if(s)return;const a=new Map;for(const h of t)YI.has(h.kind)&&a.set(h.id,{id:h.id,who:h.primary,summary:VI[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&&((f=(p=r.read()).onDepart)==null||f.call(p,d,a.size))},[s,t,r])}function QI(){const{permission:e}=ub(),{prefs:t}=mb(),s=ro(),r=Ue(),o=l.useRef(new Map),a=Jt(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((p,f,h,g)=>{let x;try{x=new Notification(f,{body:h,tag:p,silent:!0})}catch{return}x.onclick=()=>{var b;window.focus(),x.close(),o.current.delete(p),g!==null&&((b=a.read())==null||b({href:g}))},x.onclose=()=>{o.current.delete(p)},o.current.set(p,{notification:x,href:g})},[a]),d=l.useCallback(p=>{if(i())for(const f of p)c(f.id,`${f.who} needs you`,f.summary,f.deepLink)},[i,c]),u=l.useCallback(p=>{for(const f of p){const h=o.current.get(f);h!==void 0&&(h.notification.close(),o.current.delete(f))}},[]);Bu({onArrive:d,onDepart:u});const m=t.notifyOnTurnCompleteWhileAway;be("notification",p=>{const f=Fg.safeParse(p);if(!f.success)return;const h=f.data.notification;if(h.tier!=="notable"||!m||!i())return;const g=$g(h),x=g===null?null:XI(g.to,g.search);c(h.id,h.title,h.body??"",x)}),l.useEffect(()=>{const p=o.current;return()=>{for(const{notification:f}of p.values())f.close();p.clear()}},[])}function XI(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 JI(){const{play:e}=Vx(),t=l.useCallback(()=>{e("knock"),Qx()},[e]),s=l.useCallback((r,o)=>{o===0&&e("settle")},[e]);return Bu({onArrive:t,onDepart:s}),QI(),null}function ZI(){const e=_(r=>r.shortcutsPanelOpen),t=_(r=>r.setShortcutsPanelOpen),s=Bg();return n.jsx(pt,{open:e,onOpenChange:t,children:n.jsxs(gt,{className:"sm:max-w-md",children:[n.jsx(ut,{children:n.jsx(Xe,{children:"Keyboard shortcuts"})}),n.jsx(wt,{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(Jc,{className:"inline-flex",children:en(i)})]},i.id))})]},r))})]})})}function eR(){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 tR=15e3;function nR(){const e=Ee({select:r=>r.location.pathname}),s=Os("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(P1,{contributionId:s.id,children:n.jsx(l.Suspense,{fallback:null,children:n.jsx(r,{})})}),direction:1,isTakeover:!0}}return{key:"dashboard",body:n.jsx(fN,{}),direction:-1,isTakeover:!1}}function sR(){const e=Ee({select:t=>t.matches});return uj(e)}function rR(){const{sidebarOpen:e,setSidebarOpen:t}=_(),s=Ae(),r=ks(Q=>Q.panelUp),[o]=dc(),a=Ee({select:Q=>Q.location.pathname}),i=Ee({select:Q=>Q.location.searchStr}),c=new URLSearchParams(i),d=a==="/channels"&&!!c.get("community")&&!!c.get("id"),u=q1(et()??!1),m=Ee({select:Q=>Y1(Q.matches)});bv();const[p]=Wn(),f=_(Q=>Q.isStreaming),{data:h}=gc(p),g=Uc(h??null,p??""),{room:x,unreadRoomCount:b}=T1();M1(),wy({cwd:p,isStreaming:f,color:h?g.color:void 0}),eR(),aj(),rb(),WE(),ob(),ab(),Xx(),Lj(),Fj(),Uj(),N1(),A1();const y=E1();I1(),kv(),ZS(),Pw(),Lw(),zg(),Rx(),ow(),Ug(),uv(),fx(),Sy(),Kg(),ij(),Hg(),p0(),Wx();const C=_(Q=>Q.onboardingHiddenForSession),j=_(Q=>Q.setOnboardingHiddenForSession),{shouldShowOnboarding:I,isLoading:v,isOnboardingComplete:N,isOnboardingDismissed:O}=Kt(),P=Cv({shouldShowOnboarding:I,onboardingHiddenForSession:C});Av({done:N||O,overlayVisible:P}),oj({blocked:P});const{dataUpdatedAt:R,errorUpdatedAt:A,error:w}=Pe({refetchOnMount:G1}),k=R>nn,E=A>nn,D=W1(A,w),[T,L]=l.useState(!1);l.useEffect(()=>{if(k)return;const Q=setTimeout(()=>L(!0),tR);return()=>clearTimeout(Q)},[k]);const $=(D==null?void 0:D.status)===void 0,B=!k&&$&&(E||T),q=k||(D==null?void 0:D.status)===void 0?void 0:D,[oe,ie]=l.useState(!1);l.useEffect(()=>{if(!v)return;const Q=setTimeout(()=>ie(!0),3e3);return()=>clearTimeout(Q)},[v]);const Y=l.useCallback(()=>j(!0),[j]),X=nR(),{origin:ne,originLabel:se}=Wg(o),{data:te}=Gg(o,{enabled:!1,select:Q=>Q.title}),M=sR(),z=l.useMemo(()=>({sessionId:o??void 0,agentName:h?Oe(h):void 0,agentVisual:h?g:void 0,origin:ne,originLabel:se,sessionTitle:te,sessionDirectoryName:p?tl(p):void 0,room:x,teamViewMode:qg(new URLSearchParams(i).get("view")??void 0)}),[o,h,g,ne,se,te,p,x,i]),G=dE();return B?n.jsx(F1,{}):(q==null?void 0:q.status)!==void 0?n.jsx(K1,{status:q.status,message:q.message,code:q.code}):v&&!oe?n.jsx("div",{className:"bg-background h-dvh"}):n.jsxs(Yg,{children:[n.jsx(D1,{unreadRoomCount:b}),n.jsxs(Yb,{reducedMotion:"user",children:[n.jsx(Qe,{mode:"wait",children:P?n.jsx(re.div,{initial:{opacity:1},exit:{opacity:0},transition:{duration:.2},className:"fixed inset-0 z-50",children:n.jsx(Qv,{onComplete:Y,slots:z1})},"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(Vg,{open:e,onOpenChange:t,className:H("flex-1 overflow-hidden",s&&"min-h-0"),style:{"--sidebar-width":"calc(272px + 1rem)"},children:[!s&&n.jsxs(Qg,{variant:"inset",children:[n.jsx(_1,{isFullscreen:y}),n.jsx(ku,{}),n.jsx("div",{className:"relative flex min-h-0 flex-1 flex-col overflow-hidden",children:n.jsx(Qe,{mode:"wait",initial:!1,custom:X.direction,children:n.jsx(re.div,{"data-testid":"sidebar-body-swap",custom:X.direction,initial:"enter",animate:"center",exit:"exit",variants:{enter:Q=>({x:`${Q*100}%`,opacity:0}),center:{x:0,opacity:1},exit:Q=>({x:`${Q*-100}%`,opacity:0})},transition:{duration:.2,ease:[.4,0,.2,1]},className:"flex min-h-0 flex-1 flex-col overflow-hidden",children:X.body},X.key)})}),n.jsx(Xg,{className:"px-2 py-3",children:n.jsx(ul,{})}),n.jsx(Jg,{})]}),n.jsxs(Zg,{className:"overflow-hidden",inert:s&&r,children:[Ue()&&n.jsx(Oj,{className:H("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(ex,{className:"-ml-0.5"}),n.jsx(Pj,{}),n.jsx(tx,{orientation:"vertical",className:"mr-1 h-4"})]}),s&&n.jsx(VN,{}),n.jsx(Qe,{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(nx,{value:z,children:n.jsx(M.Header,{})})},M.key)}),n.jsx(HE,{}),n.jsx(JE,{}),n.jsx(eI,{}),n.jsx(sx,{})]}),n.jsx(V1,{descriptors:G}),n.jsx("main",{id:Cd,className:"flex-1 overflow-hidden pb-[var(--pip-dock,0px)]",children:n.jsxs(rx,{direction:"horizontal",id:Tr,autoSaveId:Tr,children:[n.jsx(xc,{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(ox,{})},m)}),n.jsx(sj,{pathname:a,isRemoteCommunityRoom:d})]})})]})]}),s&&n.jsx(DE,{takeover:X.isTakeover?X.body:null})]})},"main-app")}),n.jsx(AA,{}),n.jsx(NE,{onboardingOverlayVisible:P}),n.jsx(C1,{}),n.jsx(eA,{}),n.jsx(wA,{}),n.jsx(MI,{}),n.jsx(Mw,{}),n.jsx(ZI,{}),n.jsx(Uy,{}),n.jsx(qI,{}),n.jsx(cx,{}),n.jsx(JI,{})]})]})}const DT=rR;export{DT as component};