dorkos 0.114.0 → 0.115.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 (270) hide show
  1. package/dist/bin/cli.js +39739 -38935
  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-mErbIY0l.js → AboutPage-Cz8ijNrK.js} +1 -1
  5. package/dist/client/assets/{ActivityErrorState-AlI4F82u.js → ActivityErrorState-BzmfwxSZ.js} +1 -1
  6. package/dist/client/assets/ActivityPage-BK7T3OiI.js +1 -0
  7. package/dist/client/assets/{ActivityRow-Baqdr6cP.js → ActivityRow-Ig5atv15.js} +1 -1
  8. package/dist/client/assets/AdapterIcon-BXPv5J8h.js +1 -0
  9. package/dist/client/assets/{AdapterSetupWizard-BL70qy2J.js → AdapterSetupWizard-BEziztL3.js} +2 -2
  10. package/dist/client/assets/AgentOptionRow-BqFQvFeN.js +1 -0
  11. package/dist/client/assets/AgentPicker-dCfEIsU-.js +1 -0
  12. package/dist/client/assets/{AgentRequestCard-CcMh6JyE.js → AgentRequestCard-BAhfGJxx.js} +3 -3
  13. package/dist/client/assets/AppearancePage-7qHhFeEv.js +1 -0
  14. package/dist/client/assets/ApplyToOverridesDialog-jqOFh0d1.js +1 -0
  15. package/dist/client/assets/AttentionSignalRow-3CgglXkd.js +1 -0
  16. package/dist/client/assets/{BaseTanStackRouterDevtoolsPanel-B-iktbLX-DHr_AhUv.js → BaseTanStackRouterDevtoolsPanel-B-iktbLX-BMKtHI0D.js} +3 -3
  17. package/dist/client/assets/BindingDialog-DSBxRyzA.js +1 -0
  18. package/dist/client/assets/{BlintzCanvas-Bq4e7n__.js → BlintzCanvas-CyRuqAJV.js} +1 -1
  19. package/dist/client/assets/{CanvasCsvContent-OR226CLS.js → CanvasCsvContent-Bd1c6TGx.js} +4 -4
  20. package/dist/client/assets/CanvasFileContent-DelYwSH8.js +2 -0
  21. package/dist/client/assets/CanvasModel3dContent-BExIu4RY.js +2 -0
  22. package/dist/client/assets/ChatAppsOff-SWemSaUp.js +6 -0
  23. package/dist/client/assets/{CodeMirrorDiff-D7BWMOim.js → CodeMirrorDiff-0WF4ITRZ.js} +1 -1
  24. package/dist/client/assets/{CodeMirrorEditor-BodwsIG7.js → CodeMirrorEditor-Bg7wC_Q8.js} +1 -1
  25. package/dist/client/assets/CommitmentList-CTvEGUV3.js +1 -0
  26. package/dist/client/assets/{CommitmentsPage-DL_jJQbw.js → CommitmentsPage-C68etoLe.js} +1 -1
  27. package/dist/client/assets/ConnectionAccessLists-9oeVn_GK.js +1 -0
  28. package/dist/client/assets/ConnectionsPage-CJOY4-kp.js +6 -0
  29. package/dist/client/assets/ConventionPage-DD-f5o6y.js +11 -0
  30. package/dist/client/assets/{ExtensionPageRoute-CzXGvVRm.js → ExtensionPageRoute-C6fW17AG.js} +2 -2
  31. package/dist/client/assets/{FloatingTanStackRouterDevtools-CqogiFob-BV3h0rFa.js → FloatingTanStackRouterDevtools-CqogiFob-Zccd0fv6.js} +1 -1
  32. package/dist/client/assets/HandlePage-DOxlquWl.js +1 -0
  33. package/dist/client/assets/HeartbeatPage-cJM6NuTD.js +1 -0
  34. package/dist/client/assets/KeyEntry-K5k_3TfU.js +6 -0
  35. package/dist/client/assets/{LexicalField-Cc6wFZAZ.js → LexicalField-DB5V20zv.js} +2 -2
  36. package/dist/client/assets/{ManagesPage-BxHSb65X.js → ManagesPage-Cj0-hwfr.js} +1 -1
  37. package/dist/client/assets/{Marketplace-EgG6JmBG.js → Marketplace-eWEtLmd9.js} +2 -2
  38. package/dist/client/assets/{MarketplaceSourcesView-D9kq9hl6.js → MarketplaceSourcesView-B1h70C20.js} +1 -1
  39. package/dist/client/assets/{McpAppFrame-6zxszx9A.js → McpAppFrame-BaJ_r-QR.js} +2 -2
  40. package/dist/client/assets/McpSigninBody-Coaq5Fkf.js +1 -0
  41. package/dist/client/assets/{Model3dViewer-CgeJ2v-F.js → Model3dViewer-cKa-Jnbl.js} +1 -1
  42. package/dist/client/assets/NamePage-W7Frb1yy.js +1 -0
  43. package/dist/client/assets/{NewDirectMessageMenu-BnBO4aGI.js → NewDirectMessageMenu-C4zNIv9x.js} +1 -1
  44. package/dist/client/assets/{NotificationsPage-C5aRITCd.js → NotificationsPage-gKNClvNU.js} +1 -1
  45. package/dist/client/assets/{OpenMeshSwitch-UKMQeS7-.js → OpenMeshSwitch-RzB2u6-Q.js} +2 -2
  46. package/dist/client/assets/OperatorIdentityForm-B_78Vqh8.js +1 -0
  47. package/dist/client/assets/PermissionHistory-DrtlA4YM.js +1 -0
  48. package/dist/client/assets/PermissionsPage-O7kUVaQv.js +1 -0
  49. package/dist/client/assets/{PersonalityPopover-vLDfndfo.js → PersonalityPopover-DiNuuoWu.js} +1 -1
  50. package/dist/client/assets/PhotoPage-DdBke3yj.js +1 -0
  51. package/dist/client/assets/PresetPicker-BUFwg8RS.js +19 -0
  52. package/dist/client/assets/{PreviewRefusedNotice-Dh3SCC_A.js → PreviewRefusedNotice-DXZp669C.js} +1 -1
  53. package/dist/client/assets/ProfileFields-BCfMzNcT.js +1 -0
  54. package/dist/client/assets/ProfilePanelContainer-BzC2MGdi.js +1 -0
  55. package/dist/client/assets/ProfileRolePicker-f0FKXLtu.js +1 -0
  56. package/dist/client/assets/PromptSuggestionChips-EgeMFibt.js +1 -0
  57. package/dist/client/assets/ReportsToPopover-CQ4Xxslu.js +1 -0
  58. package/dist/client/assets/RoomSurface-oDbc6jnO.js +44 -0
  59. package/dist/client/assets/{RoomsPage-pPw8vrsB.js → RoomsPage-D_EbiSZ3.js} +1 -1
  60. package/dist/client/assets/RunsOnPopover-LtmmbIsD.js +1 -0
  61. package/dist/client/assets/RuntimeConnectFlow-Kv2ytk2m.js +1 -0
  62. package/dist/client/assets/RuntimeSetupDialog-CiWxlcPc.js +1 -0
  63. package/dist/client/assets/{SessionsPage-BASybh9v.js → SessionsPage-1rDO0SGV.js} +1 -1
  64. package/dist/client/assets/SettingsDialog-_ctp2AfE.js +12 -0
  65. package/dist/client/assets/SkillsPage-gPuQHKps.js +1 -0
  66. package/dist/client/assets/TaskDialogWrapper-BPFpCgsN.js +1 -0
  67. package/dist/client/assets/TasksEmptyState-D0Jlzmed.js +3 -0
  68. package/dist/client/assets/TasksPage-DvGfg5Bk.js +1 -0
  69. package/dist/client/assets/{ToolsPage-C3xfGWdb.js → ToolsPage-B0qZ85pR.js} +2 -2
  70. package/dist/client/assets/{TopologyGraph-D7Ik1Xt6.js → TopologyGraph-q1ammgpG.js} +3 -3
  71. package/dist/client/assets/TourHost-Dc8qw1Ef.js +1 -0
  72. package/dist/client/assets/{UnlinkDialog-TTK5Z_QD.js → UnlinkDialog-DXdrLsGV.js} +1 -1
  73. package/dist/client/assets/{WidgetErrorCard-D--KcgW1.js → WidgetErrorCard-ChDNC060.js} +23 -23
  74. package/dist/client/assets/_shell-BxPza3Lx.js +88 -0
  75. package/dist/client/assets/{_shell._home-CzpVyTzo.js → _shell._home-DjGunhLV.js} +1 -1
  76. package/dist/client/assets/_shell._home.activity-B014dET1.js +1 -0
  77. package/dist/client/assets/_shell._home.index-DEmtTHZg.js +3 -0
  78. package/dist/client/assets/_shell._home.tasks-CnDEbUOd.js +1 -0
  79. package/dist/client/assets/_shell._home.workspaces-AQtMUWuu.js +1 -0
  80. package/dist/client/assets/{_shell.channels-CCGSs0Bn.js → _shell.channels-C8NOhmJd.js} +4 -4
  81. package/dist/client/assets/_shell.connections-Bxe0wxOB.js +1 -0
  82. package/dist/client/assets/{_shell.feedback-requests-C6alx2ox.js → _shell.feedback-requests-C6ku9F5_.js} +2 -2
  83. package/dist/client/assets/_shell.marketplace-CEnzWFmI.js +1 -0
  84. package/dist/client/assets/_shell.marketplace_.sources-BZq1d2ih.js +1 -0
  85. package/dist/client/assets/_shell.session-Dn0C0mEZ.js +66 -0
  86. package/dist/client/assets/{_shell.team-BIwJNdkd.js → _shell.team-DoLdOMoC.js} +4 -4
  87. package/dist/client/assets/_shell.x._extensionId-DhE3OYMF.js +1 -0
  88. package/dist/client/assets/_shell.x._extensionId_._-DhE3OYMF.js +1 -0
  89. package/dist/client/assets/access-copy-CBGtcTk0.js +1 -0
  90. package/dist/client/assets/{agent-browser-CO5haI5Y.js → agent-browser-DbcLtsAx.js} +1 -1
  91. package/dist/client/assets/{banner-Dh5mO27l.js → banner-rPsz3suJ.js} +2 -2
  92. package/dist/client/assets/{card-CKZCX8ol.js → card-BqN3lfJn.js} +1 -1
  93. package/dist/client/assets/command-ZTLTCj0l.js +1 -0
  94. package/dist/client/assets/cpu-D70xMHl2.js +11 -0
  95. package/dist/client/assets/dead-letter-reasons-DtBHju9v.js +1 -0
  96. package/dist/client/assets/empty-state-yl1dLwLN.js +1 -0
  97. package/dist/client/assets/execution-config-BbBEe6FO.js +1 -0
  98. package/dist/client/assets/{file-CMPbZedq.js → file-CGg2M6ED.js} +1 -1
  99. package/dist/client/assets/{file-exclamation-point-emLeXvmw.js → file-exclamation-point-DZrVsShR.js} +1 -1
  100. package/dist/client/assets/{file-text-9a0DChCq.js → file-text-BYq_4IAt.js} +1 -1
  101. package/dist/client/assets/{find-latest-widget-fence--3kWMT1F.js → find-latest-widget-fence-CWs9nr10.js} +3 -3
  102. package/dist/client/assets/form-vPuXuaYT.js +1 -0
  103. package/dist/client/assets/format-cron-D02Tnupo.js +1 -0
  104. package/dist/client/assets/{git-branch-hfu8isLA.js → git-branch-DbjXDO_F.js} +1 -1
  105. package/dist/client/assets/{heart-SRafwnSd.js → heart-Dblp_miM.js} +1 -1
  106. package/dist/client/assets/{highlighted-body-KPVGNVTW-Dxwd3mxT.js → highlighted-body-KPVGNVTW-CaMXMak-.js} +1 -1
  107. package/dist/client/assets/index-B-WvQ24u.js +23 -0
  108. package/dist/client/assets/{index-Ch41JOI2.js → index-BKuzoeSn.js} +1 -1
  109. package/dist/client/assets/{index-DdsKmfEH.js → index-BOL391En.js} +1 -1
  110. package/dist/client/assets/{index-DLZi_nae.js → index-BPqkuMIa.js} +1 -1
  111. package/dist/client/assets/{index-BTXBESRm.js → index-BPwUl0Bz.js} +1 -1
  112. package/dist/client/assets/{index-DIlV08Vw.js → index-BV0tZnYg.js} +1 -1
  113. package/dist/client/assets/{index-3GDQSKet.js → index-BW98owO8.js} +1 -1
  114. package/dist/client/assets/{index-BTreBsWa.js → index-Bd23EYYT.js} +2 -2
  115. package/dist/client/assets/{index-BYp9xcmS.js → index-BdVOtoFr.js} +1 -1
  116. package/dist/client/assets/{index-CpYs0Lli.js → index-Bi7Um5RU.js} +1 -1
  117. package/dist/client/assets/{index-BRGOMmOM.js → index-BiIbMZ6d.js} +36 -36
  118. package/dist/client/assets/{index-C7BTAdSc.js → index-BxqUb-n7.js} +1 -1
  119. package/dist/client/assets/{index-DmTI5Hye.js → index-BzczIyv5.js} +1 -1
  120. package/dist/client/assets/index-C6NUjpzQ.js +38 -0
  121. package/dist/client/assets/{index-D67aFWxz.js → index-C88NZagl.js} +1 -1
  122. package/dist/client/assets/{index-BDfoFNcA.js → index-CHvi6xUU.js} +1 -1
  123. package/dist/client/assets/{index-CbFo-7kM.js → index-CMWMhbec.js} +1 -1
  124. package/dist/client/assets/{index-BB18IeC2.js → index-CN9fywRC.js} +1 -1
  125. package/dist/client/assets/{index-iD0epmn3.js → index-CRZXSh_q.js} +1 -1
  126. package/dist/client/assets/{index-YswfjpmW.js → index-CWNsRK97.js} +1 -1
  127. package/dist/client/assets/index-CaLw69VE.js +1 -0
  128. package/dist/client/assets/index-CdKpQ1hI.js +1018 -0
  129. package/dist/client/assets/{index-Cp7oifSs.js → index-CrK4rKAq.js} +1 -1
  130. package/dist/client/assets/{index-D_Wc_qTa.js → index-D16KF-iC.js} +3 -3
  131. package/dist/client/assets/index-D6m2SWHr.js +1 -0
  132. package/dist/client/assets/index-DDYi817r.js +1 -0
  133. package/dist/client/assets/{index-BokDvdOG.js → index-Db2EOzA3.js} +1 -1
  134. package/dist/client/assets/index-DdbHrvr0.js +1 -0
  135. package/dist/client/assets/index-Dg_bax15.js +17 -0
  136. package/dist/client/assets/index-DwUdUliR.js +1 -0
  137. package/dist/client/assets/{index-D0Nd2LA-.js → index-DzeYt-GT.js} +1 -1
  138. package/dist/client/assets/{index-lJc8v0Z3.js → index-Gq3gqBhY.js} +1 -1
  139. package/dist/client/assets/index-O_HMols_.js +1 -0
  140. package/dist/client/assets/{index-Cow815Qa.js → index-P5j6zmcN.js} +1 -1
  141. package/dist/client/assets/{index-BNn3-chz.js → index-XE46wAj9.js} +1 -1
  142. package/dist/client/assets/{index-C4nEz6I-.js → index-Z8YcKwIB.js} +1 -1
  143. package/dist/client/assets/{index-DFEF2MFy.css → index-kktlr1TJ.css} +1 -1
  144. package/dist/client/assets/{index-CAlXjm0N.js → index-lNMJBFB0.js} +1 -1
  145. package/dist/client/assets/{index-DX7V94qe.js → index-oWLYcpm4.js} +1 -1
  146. package/dist/client/assets/{index-DRqEM5Wb.js → index-vRc1D4KI.js} +1 -1
  147. package/dist/client/assets/inline-code-Cvn43Gqu.js +1 -0
  148. package/dist/client/assets/{layers-Cy8Tme6i.js → layers-Bmz62WF4.js} +1 -1
  149. package/dist/client/assets/{lightbulb-tNm7gLYi.js → lightbulb-CAd6slmc.js} +1 -1
  150. package/dist/client/assets/link-2-C0mn8T24.js +6 -0
  151. package/dist/client/assets/list-runtime-types-DxwGcKLx.js +1 -0
  152. package/dist/client/assets/{markdown-content-CoK3F0c0.js → markdown-content-1-B7PdbY.js} +1 -1
  153. package/dist/client/assets/{mention-pill-Bgs_yujj.js → mention-pill-D_-KXznh.js} +1 -1
  154. package/dist/client/assets/{message-square-off-CF2Bzen3.js → message-square-off-Di7kQvfe.js} +1 -1
  155. package/dist/client/assets/more-details-C6UGVeDE.js +1 -0
  156. package/dist/client/assets/{owner-notice-cgCWG4hG.js → owner-notice-CudDDBX4.js} +1 -1
  157. package/dist/client/assets/{package-DE8sQpId.js → package-D2eMoFCI.js} +1 -1
  158. package/dist/client/assets/{page-container-BoXmmBSs.js → page-container-CDHAACRA.js} +1 -1
  159. package/dist/client/assets/{paperclip-IgDeVFea.js → paperclip-p0W24D54.js} +1 -1
  160. package/dist/client/assets/path-input-j04LMj9z.js +1 -0
  161. package/dist/client/assets/primer-trigger-DkCcHf2Q.js +3 -0
  162. package/dist/client/assets/profile-errors-CqflLCzu.js +1 -0
  163. package/dist/client/assets/progress-BcuH4Eod.js +6 -0
  164. package/dist/client/assets/query-error-state-CEZs7dhg.js +1 -0
  165. package/dist/client/assets/{radio-BzTkFBDD.js → radio-DGWfQ5Rf.js} +1 -1
  166. package/dist/client/assets/registry-ChxwU0f4.js +1 -0
  167. package/dist/client/assets/relay-trace-schemas-y0nd8fzi.js +6 -0
  168. package/dist/client/assets/{room-files-source-CIIDTSTA.js → room-files-source-C1TCg4W_.js} +2 -2
  169. package/dist/client/assets/{rotate-ccw-clock-CGcSqHnk.js → rotate-ccw-clock-DcBojy-0.js} +1 -1
  170. package/dist/client/assets/{rotate-cw-DaduzRfP.js → rotate-cw-D0vUyeR2.js} +1 -1
  171. package/dist/client/assets/runtime-connect-Dn0T5YWv.js +1 -0
  172. package/dist/client/assets/{scroll-area-DW0-Liri.js → scroll-area-CQ9lO56h.js} +1 -1
  173. package/dist/client/assets/{search-x-Sme5ElYi.js → search-x-EJGj73JB.js} +2 -2
  174. package/dist/client/assets/settings-for-runtime-BoOa-ZFG.js +1 -0
  175. package/dist/client/assets/shield-check-Bp58y9u7.js +6 -0
  176. package/dist/client/assets/{shield-x-Bh5xap8N.js → shield-x-jF_NCCvp.js} +1 -1
  177. package/dist/client/assets/soul-file-Cag2i87x.js +1 -0
  178. package/dist/client/assets/{table-BEtvgYmW.js → table-D89CWVJX.js} +1 -1
  179. package/dist/client/assets/terminal-BUhNMZAt.js +6 -0
  180. package/dist/client/assets/trust-posture-15DMDZTA.js +1 -0
  181. package/dist/client/assets/unplug-opnrSXAi.js +6 -0
  182. package/dist/client/assets/unverified-catalog-notice-DHM5Coia.js +1 -0
  183. package/dist/client/assets/use-adapter-catalog-ClMqVelU.js +1 -0
  184. package/dist/client/assets/use-bindings-Ch6UUBvz.js +1 -0
  185. package/dist/client/assets/use-composer-prefs-Qn7KRpYe.js +1 -0
  186. package/dist/client/assets/{use-connector-management-Cohvs7jD.js → use-connector-management-dX_4x0d3.js} +1 -1
  187. package/dist/client/assets/use-deep-link-scroll-BV2fY4gy.js +1 -0
  188. package/dist/client/assets/use-delete-binding-BklxjB_c.js +1 -0
  189. package/dist/client/assets/{use-dev-links-DRnLdl--.js → use-dev-links-D4Bqam6F.js} +1 -1
  190. package/dist/client/assets/use-external-adapter-catalog-nHiD8BKZ.js +1 -0
  191. package/dist/client/assets/use-full-activity-feed-vYU7wQWT.js +1 -0
  192. package/dist/client/assets/use-is-below-desktop-G-mTu2Ga.js +1 -0
  193. package/dist/client/assets/{use-jump-back-in-CkFErfWY.js → use-jump-back-in-BVunjzyr.js} +3 -3
  194. package/dist/client/assets/use-mesh-topology-NaUKSKol.js +1 -0
  195. package/dist/client/assets/use-mounted-ref-BWpQ8f91.js +1 -0
  196. package/dist/client/assets/use-notification-prefs-qO1zRRFN.js +1 -0
  197. package/dist/client/assets/{use-panel-tab-placements-AFrWTQ0a.js → use-panel-tab-placements-Db6p2vLD.js} +1 -1
  198. package/dist/client/assets/use-pending-read-DUqJZUza.js +1 -0
  199. package/dist/client/assets/use-personality-commit-DUEKxHt_.js +1 -0
  200. package/dist/client/assets/{use-promo-activation-Dxt-1yuT.js → use-promo-activation-CnGaw39P.js} +2 -2
  201. package/dist/client/assets/use-promo-dismissals-bkSHhGhj.js +1 -0
  202. package/dist/client/assets/{use-pulse-freshness-DRRM5Hza.js → use-pulse-freshness-Oc_1gs-Y.js} +1 -1
  203. package/dist/client/assets/use-relay-config-Ba-S4wxY.js +1 -0
  204. package/dist/client/assets/{use-room-follow-claim-huRfaa4e.js → use-room-follow-claim-DqE5b95Z.js} +1 -1
  205. package/dist/client/assets/{use-roving-tab-list-BZIBAGgJ.js → use-roving-tab-list-DnMqliqf.js} +1 -1
  206. package/dist/client/assets/{use-session-canvas-CZIsr9qL.js → use-session-canvas-OdljtBE8.js} +4 -4
  207. package/dist/client/assets/{use-session-diagnostics-C41hV7rK.js → use-session-diagnostics-CtjxsM8_.js} +4 -4
  208. package/dist/client/assets/use-unclaimed-chats-5RCD5wIp.js +1 -0
  209. package/dist/client/assets/use-update-config-xkznZMHr.js +1 -0
  210. package/dist/client/assets/useMutationState-Mjr_y4xX.js +1 -0
  211. package/dist/client/index.html +2 -2
  212. package/dist/server/index.js +11367 -9690
  213. package/dist/server/index.js.map +2 -2
  214. package/package.json +4 -4
  215. package/dist/client/assets/ActivityPage-CHUqb-8c.js +0 -1
  216. package/dist/client/assets/AdapterIcon-C_fBZXHQ.js +0 -1
  217. package/dist/client/assets/AppearancePage-t9SnSRs-.js +0 -1
  218. package/dist/client/assets/AttentionSignalRow-jlgWaSSd.js +0 -1
  219. package/dist/client/assets/CanvasFileContent-BejM-9Wg.js +0 -2
  220. package/dist/client/assets/CanvasModel3dContent-BD-eCVsX.js +0 -2
  221. package/dist/client/assets/CommitmentList-YVb3yTvO.js +0 -1
  222. package/dist/client/assets/ConnectionAccessLists-BPsgToSR.js +0 -1
  223. package/dist/client/assets/ConnectionsPage-D7vlYnjf.js +0 -6
  224. package/dist/client/assets/ConventionPage-BR7I3AdE.js +0 -11
  225. package/dist/client/assets/HandlePage-B33P0oh0.js +0 -1
  226. package/dist/client/assets/HeartbeatPage-CfjZuvtQ.js +0 -1
  227. package/dist/client/assets/McpSigninBody-DBWSc6bm.js +0 -1
  228. package/dist/client/assets/NamePage-MfybpnwN.js +0 -1
  229. package/dist/client/assets/OperatorIdentityForm-DH2au7QU.js +0 -1
  230. package/dist/client/assets/PermissionsPage-BgLLmdg2.js +0 -1
  231. package/dist/client/assets/PhotoPage-BgyB3B2_.js +0 -1
  232. package/dist/client/assets/PromptSuggestionChips-EO_0zbzq.js +0 -1
  233. package/dist/client/assets/ReportsToPopover-C9Ceg1AW.js +0 -1
  234. package/dist/client/assets/RoomSurface-B8ec3_at.js +0 -44
  235. package/dist/client/assets/RunsOnPopover-CJoSj8w7.js +0 -1
  236. package/dist/client/assets/RuntimeSetupDialog-Cqn_Grel.js +0 -1
  237. package/dist/client/assets/SkillsPage-DL0909et.js +0 -1
  238. package/dist/client/assets/TasksPage-BwUW6dia.js +0 -1
  239. package/dist/client/assets/TourHost-Db0fxAXo.js +0 -1
  240. package/dist/client/assets/_shell-CGWsN6Gs.js +0 -88
  241. package/dist/client/assets/_shell._home.activity-BbWquOK0.js +0 -1
  242. package/dist/client/assets/_shell._home.index-Cg0nRFMN.js +0 -3
  243. package/dist/client/assets/_shell._home.tasks-BpoOVihw.js +0 -1
  244. package/dist/client/assets/_shell._home.workspaces-DVF1rM3t.js +0 -1
  245. package/dist/client/assets/_shell.connections-0_34lXIQ.js +0 -1
  246. package/dist/client/assets/_shell.marketplace-Dp-p8E3V.js +0 -1
  247. package/dist/client/assets/_shell.marketplace_.sources-SN2Fb1eb.js +0 -1
  248. package/dist/client/assets/_shell.session-Bt3jdQdD.js +0 -66
  249. package/dist/client/assets/_shell.x._extensionId-Bjn-MKsP.js +0 -1
  250. package/dist/client/assets/_shell.x._extensionId_._-Bjn-MKsP.js +0 -1
  251. package/dist/client/assets/index-BBQMqcO_.js +0 -1
  252. package/dist/client/assets/index-BUVKya1M.js +0 -23
  253. package/dist/client/assets/index-C3xuhmPa.js +0 -38
  254. package/dist/client/assets/index-C63bLSO4.js +0 -1099
  255. package/dist/client/assets/index-CTxEG5rD.js +0 -1
  256. package/dist/client/assets/index-CkknQ52Q.js +0 -17
  257. package/dist/client/assets/index-DLNwEM2Q.js +0 -1
  258. package/dist/client/assets/index-DX-j3Ul0.js +0 -1
  259. package/dist/client/assets/index-g_5oOlG6.js +0 -1
  260. package/dist/client/assets/index-t7gsOfUI.js +0 -1
  261. package/dist/client/assets/kickoff-xkt4LpIP.js +0 -3
  262. package/dist/client/assets/soul-file-NcuTUIiB.js +0 -1
  263. package/dist/client/assets/use-delete-binding-C19umm_i.js +0 -1
  264. package/dist/client/assets/use-external-adapter-catalog-BOn9aj72.js +0 -1
  265. package/dist/client/assets/use-full-activity-feed-BpQANbns.js +0 -1
  266. package/dist/client/assets/use-is-below-desktop-5LlietdR.js +0 -1
  267. package/dist/client/assets/use-mesh-topology-CIsDeAY0.js +0 -1
  268. package/dist/client/assets/use-pending-read-Dol8yvIx.js +0 -1
  269. package/dist/client/assets/use-personality-commit-fUtuc2lC.js +0 -1
  270. package/dist/client/assets/use-unclaimed-chats-BMlFQ2v1.js +0 -1
@@ -0,0 +1,88 @@
1
+ var ku=Object.defineProperty;var Su=(e,t,s)=>t in e?ku(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s;var Jt=(e,t,s)=>Su(e,typeof t!="symbol"?t+"":t,s);import{qs as Cu,r as l,p8 as $o,qt as Nu,p7 as Lr,j as n,qu as Au,qv as Mi,p9 as Eu,hA as _i,a8 as oe,a9 as ye,aA as Ne,ep as ke,e_ as pn,qw as Ms,hw as Iu,qx as Ru,qy as Tu,aa as ie,aw as de,oe as Du,qz as Ou,a2 as Se,e5 as ms,W as X,B as P,X as Oe,Q as B,iz as Pi,qA as Mu,x as we,a7 as Li,bE as Fi,bk as hs,dd as De,b3 as _u,qB as Bo,qC as Pu,bQ as Lu,az as $i,cd as Ae,ay as Ee,s as vt,jA as Fu,jB as Bi,ae,qD as Sn,i4 as ot,qE as zi,b0 as $,qa as $u,ej as at,kk as es,hP as zt,qF as Bu,ab as Ct,ei as Ui,fn as Fr,cL as $r,aD as Ut,qG as zo,iR as zu,iU as Ki,iQ as Uu,qH as Br,iq as Cn,R as Nt,hg as zr,e4 as Lt,l as he,aP as Hi,dy as Wi,dz as Gi,dR as qi,dA as Ku,qI as Hu,dC as We,bG as Nn,bH as An,$ as At,bI as En,bK as In,C as Kt,e1 as Te,e2 as Wu,qJ as Gu,kc as Yi,h_ as Vi,bs as Ie,qK as qu,qL as Yu,bR as Vu,L as Ur,dD as Ue,f7 as Ke,g4 as Kr,ft as fs,ju as Hr,f as Et,bf as Qi,eh as ps,qM as Wr,d$ as Qu,a5 as gn,cU as Ht,cV as Wt,cW as Gt,ar as Ce,ax as gs,lB as Xi,qN as Xu,qO as Ju,cB as Zu,dp as ts,bF as Fe,jG as xn,cE as et,cF as tt,cH as Qe,cI as $e,cJ as Xe,dB as it,dh as _t,df as em,h as Gr,qP as qr,qQ as tm,fP as Yr,fQ as Vr,fR as nm,fS as Qr,fT as an,pq as sm,qR as Ji,iI as rm,qS as om,qT as am,fV as im,qU as cm,qV as xs,qW as lm,eJ as Zi,qX as dm,qY as um,hO as mm,qZ as hm,q_ as fm,aF as pm,gh as ec,ak as je,eH as bs,q$ as gm,gX as xm,ka as bm,gZ as ym,g_ as vm,g$ as wm,mr as tc,fm as ys,ec as jm,r0 as km,g6 as nc,r1 as pe,r2 as Sm,r3 as sc,r4 as dr,r5 as rc,r6 as Xr,r7 as Jr,be as vs,r8 as Zr,r9 as Cm,ra as Nm,rb as Am,rc as Em,rd as Im,re as Rm,rf as Zt,hx as Tm,hy as Dm,nu as Om,rg as Mm,bj as _m,rh as Pm,fr as oc,c4 as Pt,ri as ac,rj as ns,rk as ic,rl as Lm,rm as Fm,rn as Ft,ro as cc,rp as lc,rq as bn,rr as $m,rs as Bm,h0 as dc,h1 as uc,rt as wt,e8 as zm,ru as yn,rv as Um,b5 as mc,rw as Km,rx as Hm,ry as Wm,rz as Gm,rA as qm,rB as hc,rC as ft,fq as ct,rD as fc,rE as Ym,G as ue,fB as Vm,z as re,J as qt,_ as Yt,F as le,D as gt,I as Ze,nM as pc,nU as gc,fJ as jt,fI as $t,eN as ws,jp as Qm,fH as xc,ek as bc,lc as yc,mz as Xm,fG as Jm,rF as Zm,rG as Uo,rH as eh,rI as Bt,rJ as vc,bY as js,hm as wc,rK as th,rL as nh,rM as sh,eO as rh,b4 as eo,fK as to,rN as oh,gg as Rn,rO as cn,rP as no,q as ss,o as jc,rQ as ah,jC as Ko,kO as ih,mR as ch,rR as lh,rS as dh,ca as uh,aq as so,ap as ro,md as kc,mc as Sc,rT as mh,at as Cc,db as ks,j4 as Nc,rU as hh,rV as fh,rW as ph,rX as gh,rY as xh,rZ as bh,r_ as yh,gO as oo,on as vh,r$ as Ac,lE as wh,hl as Ec,hX as ur,s0 as jh,s1 as Tn,m8 as ao,s2 as Vt,s3 as kh,s4 as Sh,s5 as Ch,s6 as Nh,s7 as Ah,s8 as Eh,fL as Ih,s9 as Rh,hb as io,m9 as Ic,mb as Th,sa as Dh,sb as Rc,sc as Oh,kB as Mh,sd as Tc,se as Ho,sf as Wo,sg as _h,sh as Ph,si as Lh,sj as Fh,sk as $h,sl as Bh,sm as Go,sn as zh,so as Uh,sp as Kh,sq as _s,hV as Ss,ig as Hh,sr as Wh,jZ as Gh,e as xt,ss as qh,st as Yh,su as Vh,bc as Qh,iJ as Xh,sv as Dc,sw as Jh,bb as Zh,sx as ef,sy as tf,gf as Dn,T as nf,sz as sf,sA as rs,ir as Oc,sB as rf,sC as Mc,sD as qo,sE as of,sF as af,sG as _c,sH as zn,sI as cf,sJ as lf,sK as df,sL as Pc,sM as mr,sN as uf,ck as en,H as co,aY as mf,pm as Lc,dE as Yo,jr as lo,bp as hf,t as ff,g as pf,hp as hr,gW as gf,aT as uo,h4 as Fc,sO as xf,kJ as bf,k9 as yf,nR as vf,hU as wf,sP as jf,hW as Vo,im as $c,fY as kf,fZ as Sf,f_ as Cf,f$ as Nf,g0 as Af,g1 as Ef,g2 as If,sQ as Rf,sR as fr,sS as Tf,sT as Ps,sU as Df,sV as Of,sW as vn,sX as Mf,sY as Qo,ke as _f,ih as Pf,sZ as Lf,hB as Ff,hC as $f,hE as Bf,hF as Xo,kX as Jo,kV as zf,kW as Zo,s_ as Uf,s$ as Kf,t0 as Hf,t1 as Wf,eq as Gf,t2 as qf,t3 as Yf,t4 as Vf,b$ as Qf,t5 as Xf,t6 as Jf,t7 as Bc,t8 as zc,Y as mo,Z as ho,a0 as fo,t9 as Zf,ta as ep,bV as tp,fO as np,tb as Ls,b1 as sp,tc as rp,td as op,te as ap,tf as ip,tg as cp,th as lp,ti as dp,tj as up,tk as mp,tl as ea,bg as Uc,hD as hp,bU as fp,tm as Kc,tn as pp,fu as gp,to as ta,gV as xp,tp as bp,tq as yp,nP as vp,tr as wp,ts as jp,e6 as kp,hH as Sp,tt as Cp,tu as na,tv as Np,tw as Ap,nL as Ep,o0 as Ip,iY as Rp,ag as Hc,tx as Tp,iS as Dp,iT as Op,j5 as Mp,ew as Wc,ex as Gc,ey as qc,ez as Yc,e3 as _p,eu as Pp,ev as Lp,ja as Fp,jb as $p,jc as Bp,jf as zp,jd as Up,ty as Kp,tz as Hp,j9 as Wp,j7 as Gp,j8 as qp,hu as Yp,tA as Vc,hT as Vp,tB as Qp,tC as Xp,tD as Qc,tE as Cs,bo as Xc,a6 as Jc,tF as Zc,op as Jp,bm as Zp,bn as eg,en as sa,bl as tg,g7 as Fs,gx as $s,tG as po,n as ng,h5 as sg,aU as ra,tH as el,tI as tl,tJ as rg,bJ as og,tK as ag,tL as ig,tM as Mt,c$ as cg,tN as oa,lj as lg,ll as nl,dg,iP as ug,mQ as mg,tO as pr,eX as hg,ho as fg,lw as Ye,ly as pg,q9 as gg,no as aa,qb as xg,tP as bg,tQ as yg,tR as vg,tS as wg,ce as jg,tT as kg,tU as Sg,tV as Cg,tW as Ng,tX as Ag,kE as Eg,jP as Ig,k5 as Rg,tY as Tg,tZ as Dg,t_ as Og,t$ as Mg,u0 as _g,u1 as Pg,cf as Lg,u2 as Fg,u3 as $g,mq as Bg,cK as zg}from"./index-CdKpQ1hI.js";import{f as Ug,g as Kg}from"./use-connector-management-dX_4x0d3.js";import{D as Ge,a as Hg}from"./TourHost-Dc8qw1Ef.js";import{r as Wg,e as Gg,a as qg,K as Yg}from"./RuntimeConnectFlow-Kv2ytk2m.js";import{O as Vg,B as sl}from"./banner-rPsz3suJ.js";import{u as Ns,P as rl,a as Qg}from"./ProfileRolePicker-f0FKXLtu.js";import{u as Xg}from"./use-dev-links-D4Bqam6F.js";import{B as Jg,u as Zg}from"./use-bindings-Ch6UUBvz.js";import{C as go,l as ol,O as al,m as He,n as ex,u as il,r as tx,w as nx,b as sx,e as rx,k as ox,o as gr,T as ax,a as ix,P as cx,B as lx,g as cl,p as ll,q as dl,j as dx,S as ia,W as ux,s as mx}from"./PresetPicker-BUFwg8RS.js";import{d as hx}from"./untrusted-text-pHjcUwfI.js";import{S as un}from"./scroll-area-CQ9lO56h.js";import{T as ul,a as ml,b as Vn,c as Bs,u as fx,i as px,d as gx,P as hl}from"./PreviewRefusedNotice-DXZp669C.js";import{P as xx}from"./paperclip-p0W24D54.js";import{L as bx}from"./lightbulb-CAd6slmc.js";import{u as On}from"./use-update-config-xkznZMHr.js";import{a as yx,u as vx,S as wx,s as jx,b as kx,P as Sx}from"./ApplyToOverridesDialog-jqOFh0d1.js";import{t as Cx,I as ca}from"./trust-posture-15DMDZTA.js";import{a as Nx}from"./use-pulse-freshness-Oc_1gs-Y.js";import{c as Ax,B as Ex,w as Ix,b as Rx,a as Tx,e as Dx}from"./primer-trigger-DkCcHf2Q.js";import{M as Ox,u as Mx,s as _x,P as Px,a as Lx}from"./use-promo-activation-CnGaw39P.js";import{u as fl}from"./use-promo-dismissals-bkSHhGhj.js";import{u as pl}from"./use-pending-read-DUqJZUza.js";import{a as Je}from"./dorkbot-templates-8Yu9POWJ.js";import{i as Fx,O as gl,b as $x,u as Bx,a as zx}from"./OperatorIdentityForm-B_78Vqh8.js";import{A as xl,P as Ux,u as Kx,a as Hx}from"./use-jump-back-in-BVunjzyr.js";import{S as bl,P as Wx}from"./progress-BcuH4Eod.js";import{i as xo,a as Gx,u as qx}from"./use-notification-prefs-qO1zRRFN.js";import{R as Yx}from"./rotate-cw-D0vUyeR2.js";import{b as Vx,u as Qx,O as Xx,c as Jx}from"./OpenMeshSwitch-RzB2u6-Q.js";import{u as Zx,a as eb,C as tb,N as nb}from"./NewDirectMessageMenu-C4zNIv9x.js";import{P as sb,C as rb,f as ob,a as ab}from"./find-latest-widget-fence-CWs9nr10.js";import{o as ib}from"./owner-notice-CudDDBX4.js";import{a as yl,C as cb}from"./cpu-D70xMHl2.js";import{U as lb}from"./unplug-opnrSXAi.js";import{c as db,H as vl,a as wl,b as jl}from"./RuntimeSetupDialog-CiWxlcPc.js";import{P as zs}from"./page-container-CDHAACRA.js";import{S as ub}from"./shield-check-Bp58y9u7.js";import{u as mb}from"./use-roving-tab-list-DnMqliqf.js";import{R as hb}from"./rotate-ccw-clock-DcBojy-0.js";import{d as Le,e as me,f as la,g as kl,C as Sl,a as Cl,b as Nl,c as fb}from"./command-ZTLTCj0l.js";import{A as pb,M as gb}from"./McpAppFrame-BaJ_r-QR.js";import{L as xb}from"./layers-Bmz62WF4.js";import{A as bb}from"./AgentOptionRow-BqFQvFeN.js";import{R as yb}from"./radio-DGWfQ5Rf.js";import{a as vb}from"./sound-D3r8dGFH.js";import{r as Al,s as da}from"./access-copy-CBGtcTk0.js";import{P as wb}from"./path-input-j04LMj9z.js";import"./WidgetErrorCard-ChDNC060.js";import{u as jb}from"./use-is-below-desktop-G-mTu2Ga.js";import{a as kb,u as Sb}from"./use-panel-tab-placements-Db6p2vLD.js";import"./use-relay-config-Ba-S4wxY.js";import"./use-external-adapter-catalog-nHiD8BKZ.js";import"./use-adapter-catalog-ClMqVelU.js";import"./inline-code-Cvn43Gqu.js";import"./useMutationState-Mjr_y4xX.js";import"./runtime-connect-Dn0T5YWv.js";import"./terminal-BUhNMZAt.js";import"./execution-config-BbBEe6FO.js";import"./settings-for-runtime-BoOa-ZFG.js";import"./shield-x-jF_NCCvp.js";import"./use-full-activity-feed-vYU7wQWT.js";import"./profile-errors-CqflLCzu.js";import"./use-mounted-ref-BWpQ8f91.js";import"./ProfileFields-BCfMzNcT.js";import"./use-mesh-topology-NaUKSKol.js";import"./card-BqN3lfJn.js";import"./list-runtime-types-DxwGcKLx.js";import"./more-details-C6UGVeDE.js";import"./markdown-content-1-B7PdbY.js";import"./table-D89CWVJX.js";import"./package-D2eMoFCI.js";import"./heart-Dblp_miM.js";import"./git-branch-DbjXDO_F.js";import"./file-text-BYq_4IAt.js";import"./file-CGg2M6ED.js";function Cb({children:e,isValidProp:t,...s}){t&&Cu(t);const r=l.useContext($o);s={...r,...s},s.transition=Nu(s.transition,r.transition),s.isStatic=Lr(()=>s.isStatic);const o=l.useMemo(()=>s,[JSON.stringify(s.transition),s.transformPagePoint,s.reducedMotion,s.skipAnimations]);return n.jsx($o.Provider,{value:o,children:e})}function Nb(e){e.values.forEach(t=>t.stop())}function xr(e,t){[...t].reverse().forEach(r=>{const o=e.getVariant(r);o&&Mi(e,o),e.variantChildren&&e.variantChildren.forEach(a=>{xr(a,t)})})}function Ab(e,t){if(Array.isArray(t))return xr(e,t);if(typeof t=="string")return xr(e,[t]);Mi(e,t)}function Eb(){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(Au(a,s,{transitionOverride:r}))}),Promise.all(o)},set(s){return e.forEach(r=>{Ab(r,s)})},stop(){e.forEach(s=>{Nb(s)})},mount(){return()=>{t.stop()}}};return t}function Ib(){const e=Lr(Eb);return Eu(e.mount,[]),e}class Rb{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 Tb=()=>new Rb;function Db(){return Lr(Tb)}const Ob=`${_i.repo}/issues/new`,Mb={"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"},_b={"runtimes.default":["claude-code","codex","opencode","doe"],"logging.level":["fatal","error","warn","info","debug","trace"],"ui.theme":["light","dark","system"]},Pb=/^[a-z0-9][a-z0-9._-]{0,31}$/,Lb={bug:["bug"],feature:["enhancement"],runtime:["bug"]},Fb={bug:"Bug: (describe what went wrong)",feature:"Feature: (describe what you want)",runtime:"Runtime issue: (describe what went wrong)"};function $b(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 bo(e){return $b(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 Bb(e,t){const s=_b[e];return s?s.includes(t):Pb.test(t)&&bo(t)===t}function zb(e){const t={};for(const[s,r]of Object.entries(Mb)){const o=e[s];o!=null&&(r==="boolean"&&typeof o=="boolean"||r==="number"&&typeof o=="number"&&Number.isFinite(o)||r==="enum"&&typeof o=="string"&&Bb(s,o))&&(t[s]=o)}return t}const Ub=["details","summary"];function yo(e){return hx(bo(e),Ub)}function Kb(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 bo(r.join(`
3
+ `))}function Hb(e){var s;const t=(s=e.body)==null?void 0:s.trim();return t?[yo(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 Wb(e){return["<details><summary>Environment</summary>","",Kb(e),"","</details>","","DorkOS filled in the details above. Please check them and remove anything you do not want to share.","","---","",...Hb(e)].join(`
4
+ `)}function Us(e){var r;const t=(r=e.title)==null?void 0:r.trim(),s=new URLSearchParams({title:yo(t||Fb[e.kind]),body:Wb(e),labels:Lb[e.kind].join(",")});return`${Ob}?${s.toString()}`}const Gb=6e3,ua=`
5
+
6
+ … (shortened to fit the link; paste the rest yourself)`;function ma(e){return new TextEncoder().encode(e).length}function ha(e,t){return Array.from(e).slice(0,t).join("")}function qb(e,t=Gb){var d;const s=Us(e);if(ma(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 m=Math.ceil((a+i)/2),u={...e,body:ha(r,m)+ua};ma(Us(u))<=t?a=m:i=m-1}const c={...e,body:ha(r,a)+ua};return{url:Us(c),truncated:!0,fullBody:yo(r)}}function Yb(e){return qb(e).url}function Vb(e){var t,s,r,o,a,i,c,d,m,u;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":(m=e.auth)==null?void 0:m.enabled,"logging.level":(u=e.logging)==null?void 0:u.level}}function El(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?zb(Vb(t)):{}}}function Qb(){const e=oe(),{data:t}=ye({queryKey:Ne.current(),queryFn:()=>e.getConfig(),staleTime:300*1e3}),s=ke({select:r=>r.location.pathname});return l.useCallback(r=>{const o=Yb(El(r,t,s));pn(o)},[t,s])}const Xb=100;function Jb({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 u=o.current;u.length!==0&&(Ms(u[i.current]),i.current=(i.current+1)%u.length)},Xb))},[]),m=l.useCallback(()=>{a.current&&(clearInterval(a.current),a.current=null),r.current&&Ms(r.current)},[]);l.useEffect(()=>{if(!e)return;const u=s??Iu(e),f=Ru(u);r.current=f,o.current=[],Ms(f);let p=!1;return Tu(f).then(h=>{p||(o.current=h,c.current&&d())}).catch(()=>{}),()=>{p=!0}},[e,s,d]),l.useEffect(()=>(t?d():m(),m),[t,d,m])}function Zb(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 ey(){const e=ie();de("account_usage",t=>{const s=t;!s||typeof s.runtime!="string"||e.getQueryData(Du.usage(s.runtime))!==void 0&&Ou(e,s.runtime,[s])})}function ty(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 ny(e){const[t,s]=l.useState(0),r=l.useRef([]);function o(){const m=r.current.slice(0,e).filter(Boolean);if(m.length===0)return 1;const u=m[0].offsetTop;return Math.max(1,m.filter(f=>f.offsetTop===u).length)}function a(m){var f;const u=Math.max(0,Math.min(e-1,m));s(u),(f=r.current[u])==null||f.focus()}function i(m){return u=>{r.current[m]=u}}function c(m){return t===m?0:-1}function d(m,u){const f=ty(m.key,u,o(),e);f!==null&&(m.preventDefault(),a(f))}return{focusIndex:t,setRef:i,tabIndexFor:c,handleKeyDown:d,moveFocus:a}}/**
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 Il={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"]};Il.node;const sy=Se(Il);/**
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 Rl={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"}]]};Rl.node;const ry=Se(Rl);/**
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 Tl={name:"chevron-up",size:24,node:[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]]};Tl.node;const oy=Se(Tl);/**
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 Dl={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"]};Dl.node;const ay=Se(Dl);/**
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 Ol={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"}]]};Ol.node;const Ml=Se(Ol);/**
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 _l={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"}]]};_l.node;const iy=Se(_l);/**
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 Pl={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"}]]};Pl.node;const cy=Se(Pl);/**
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 Ll={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"}]]};Ll.node;const os=Se(Ll);/**
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 Fl={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"}]]};Fl.node;const ly=Se(Fl);/**
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 $l={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"}]]};$l.node;const fa=Se($l);/**
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 Bl={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"}]]};Bl.node;const dy=Se(Bl);/**
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 zl={name:"minus",size:24,node:[["path",{d:"M5 12h14",key:"1ays0h"}]]};zl.node;const uy=Se(zl);/**
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 Ul={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"}]]};Ul.node;const my=Se(Ul);/**
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 Kl={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"]};Kl.node;const hy=Se(Kl);/**
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 Hl={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"}]]};Hl.node;const fy=Se(Hl),pa=16,py=280,gy=180;function ga(e,t,s){const r=Math.max(t,window.innerWidth-pa),o=Math.max(s,window.innerHeight-pa),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 xy(e,t){return e.x!==t.x||e.y!==t.y||e.width!==t.width||e.height!==t.height}function by(e){const{title:t,geometry:s,onGeometryChange:r,onClose:o,onRestore:a,minWidth:i,minHeight:c,children:d,className:m}=e,u=l.useRef(null),f=i??py,p=c??gy;l.useEffect(()=>{const y=()=>{const k=ga(s,f,p);xy(k,s)&&r(k)};return y(),window.addEventListener("resize",y),()=>window.removeEventListener("resize",y)},[s,f,p,r]);const h=l.useRef(null);l.useEffect(()=>()=>{var y;return(y=h.current)==null?void 0:y.call(h)},[]);const g=l.useCallback((y,k)=>{var D;y.preventDefault();const w=u.current;if(!w)return;const I=w;(D=h.current)==null||D.call(h);const v=y.clientX,S=y.clientY,R=s;let M=R,E=0;function N(){E=0,I.style.left=`${M.x}px`,I.style.top=`${M.y}px`,I.style.width=`${M.width}px`,I.style.height=`${M.height}px`}function j(T){M=k(T.clientX-v,T.clientY-S,R),E||(E=requestAnimationFrame(N))}function A(){E&&cancelAnimationFrame(E),E=0,document.removeEventListener("pointermove",j),document.removeEventListener("pointerup",C),document.removeEventListener("pointercancel",C),h.current=null}function C(){A(),r(ga(M,f,p))}document.addEventListener("pointermove",j),document.addEventListener("pointerup",C),document.addEventListener("pointercancel",C),h.current=A},[s,f,p,r]),x=l.useCallback(y=>{y.target.closest("button")||g(y,(k,w,I)=>({...I,x:I.x+k,y:I.y+w}))},[g]),b=l.useCallback(y=>{y.stopPropagation(),g(y,(k,w,I)=>({...I,width:Math.max(f,I.width+k),height:Math.max(p,I.height+w)}))},[g,f,p]);return ms.createPortal(n.jsxs(X.div,{ref:u,"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:B("bg-card border-border shadow-floating fixed z-40 flex flex-col overflow-hidden rounded-lg border",m),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(P,{variant:"ghost",size:"icon-sm","aria-label":"Restore",onClick:a,className:"text-muted-foreground hover:text-foreground",children:n.jsx(sb,{})}):null,n.jsx(P,{variant:"ghost",size:"icon-sm","aria-label":"Close",onClick:o,className:"text-muted-foreground hover:text-foreground",children:n.jsx(Oe,{})})]}),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 yy({...e}){const{theme:t}=Pi();return n.jsx(Mu,{theme:t,className:"toaster group",icons:{success:n.jsx(hs,{className:"size-4"}),info:n.jsx(Fi,{className:"size-4"}),warning:n.jsx(Li,{className:"size-4"}),error:n.jsx(Vg,{className:"size-4"}),loading:n.jsx(we,{})},style:{"--normal-bg":"var(--color-popover)","--normal-text":"var(--color-popover-foreground)","--normal-border":"var(--color-border)","--border-radius":"var(--radius)"},...e})}async function vy(){var t;if(!De())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 Wl="root";function Gl(){return document.getElementById(Wl)??document.body}const xa=2e4;class Be extends Error{constructor(s,r){super(r);Jt(this,"reason");this.name="AppCaptureError",this.reason=s}}function wy(){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 jy(){return new Promise(e=>{requestAnimationFrame(()=>requestAnimationFrame(()=>e()))})}function ky(){const e=[];for(const t of Array.from(document.body.children)){if(!(t instanceof HTMLElement)||t.id===Wl)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 Sy(e){const t=await e().catch(s=>{throw new Be("failed",`The desktop bridge threw: ${String(s)}`)});if(!t.ok)throw new Be("failed",t.message);return{dataUrl:t.dataUrl,region:{left:0,top:0,width:window.innerWidth,height:window.innerHeight}}}async function Cy(){let e;try{({snapdom:e}=await _u(()=>import("./snapdom-SRLjr6oU.js"),[]))}catch(r){const o=r instanceof Error?r.message:String(r);throw new Be("unsupported",`Loading the screenshot library failed: ${o}`)}const t=Gl(),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 Be("failed",`Rendering the app to an image failed: ${o}`)}}async function Ny(e){let t;const s=new Promise((r,o)=>{t=setTimeout(()=>{o(new Be("failed",`The capture did not finish in ${xa}ms.`))},xa)});try{return await Promise.race([e,s])}finally{clearTimeout(t),e.catch(()=>{})}}async function Ay(){const e=wy(),t=ky();try{return await jy(),await Ny(e?Sy(e):Cy())}finally{t()}}let tn=null;function ql(){if(tn)return tn;const e=Ay();tn=e;const t=()=>{tn===e&&(tn=null)};return e.then(t,t),e}function Ey(){return ql().then(e=>e.dataUrl)}function Iy(){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 Ry(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone||void 0}catch{return}}function Ty(e){const t=Iy(),s=typeof navigator<"u"?navigator.userAgent:void 0,r=typeof navigator<"u"?navigator.language:void 0,o=Ry();return{theme:e,shell:De()?"desktop-app":"browser",...t?{viewport:t}:{},...s?{browser:s.slice(0,Pu)}:{},...r?{locale:r.slice(0,Bo)}:{},...o?{timezone:o.slice(0,Bo)}:{}}}function As(e){return t=>()=>{e(),t()}}const Dy=2e3,Oy=.8,My=1400,_y=.6,Qn=6e5,as=1e4,Py=["image/webp","image/jpeg","image/png"],Ly=/^data:image\/(webp|png|jpeg);base64,/;class kt extends Error{constructor(s,r){super(r);Jt(this,"reason");this.name="ImageCompressError",this.reason=s}}function Fy(e){return Ly.test(e)&&e.length<=Qn}function $y(e){return new Promise((t,s)=>{const r=new Image,o=setTimeout(()=>{s(new kt("unreadable",`Decoding timed out after ${as}ms.`))},as);r.onload=()=>{clearTimeout(o),t(r)},r.onerror=()=>{clearTimeout(o),s(new kt("unreadable",`Could not decode the image at ${e.slice(0,32)}…`))},r.src=e})}function By(e,t){for(const s of Py){const r=e.toDataURL(s,t);if(r.startsWith(`data:${s};base64,`))return r}throw new kt("unsupported","This canvas produced no usable image encoding.")}function ba(e,t,s=Dy){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 ya(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 kt("unsupported","This browser gave no 2d canvas context.");return o.drawImage(e,0,0,t.width,t.height),By(r,s)}async function br(e){const t=typeof e=="string"?null:URL.createObjectURL(e);let s;try{s=await $y(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 kt("unreadable","The image decoded to zero pixels.");let a=ya(s,ba(r,o),Oy);if(a.length>Qn&&(a=ya(s,ba(r,o,My),_y)),a.length>Qn)throw new kt("too-large",`Compressed to ${a.length} characters, over the ${Qn} cap.`);return a}const zy=500;function Uy(e=zy){const t=ie(),s=Lu({coalesceMs:e,shouldFlush:()=>t.isMutating({mutationKey:$i})===0});de("config_changed",()=>{const r={queryKey:Ne.current()};s([r])})}const Yl="dorkbot",Ky=["mesh","agent-paths"];function Hy(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)||Yl;return`${t}/${s}`}function Wy(){var d;const e=Ae(),t=oe(),{data:s}=Ee(),{data:r}=ye({queryKey:[...Ky],queryFn:()=>t.listMeshAgentPaths(),staleTime:3e4}),o=((d=s==null?void 0:s.agents)==null?void 0:d.defaultAgent)||Yl,a=r==null?void 0:r.agents.find(m=>m.name===o),i=(a==null?void 0:a.projectPath)??Hy(s);return{startSession:l.useCallback(()=>{a?e(vt({agentId:a.id})):i&&Fu(t,i).then(m=>e(m)).catch(m=>{Bi(t,m),ae.error("Couldn’t open the chat. Try again.")})},[e,i,a,t]),defaultAgentDir:i}}function Gy(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 qy(){const e=ie(),t=Sn();de("community_connections_changed",()=>{t&&e.invalidateQueries({queryKey:ot.connections(t),exact:!0})})}function Vl(e){const t=oe(),s=e!==null&&e.status!=="pending",r=Sn(s),o=(e==null?void 0:e.ref)??"";return ye({queryKey:r?ot.disconnectImpact(r,o):[...ot.all,"owner","unresolved",o,"disconnect-impact"],queryFn:()=>zi(r,()=>t.getCommunityDisconnectImpact(o)),enabled:s&&r!==null,staleTime:0,refetchOnMount:"always"})}function Ql(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 Xl(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}: ${Ql(t)}.`}function Jl(e){return`Any agents you added from here will be removed from ${e}.`}function Zl(e,{remoteRevoked:t,agentsNotRemoved:s}){const r=Ql(s);return s.length===0?t?{tone:"success",message:`${e} is disconnected.`}:{tone:"warning",message:Yy(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 Yy(e){return`Disconnected here, but ${e} couldn’t be reached. Finish under Connected installations on ${e}.`}function Vy(){const e=oe(),t=$(o=>o.selectedCwd),s=$(o=>o.setSelectedCwd),{data:r}=ye({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 va(e){e.invalidateQueries({queryKey:zt.recentRoot})}const Qy=5e3;function Xy(e,t=Qy){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 wa(e){e.invalidateQueries({queryKey:zt.dailyCountsRoot})}function Jy(e,t){const s=Object.keys(e);return s.length!==Object.keys(t).length?!0:s.some(r=>!(r in t))}function Zy(e,t){e.setQueryData(zt.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 ev(e,t,s){e.setQueryData(zt.list(s),r=>r&&r.filter(o=>o.id!==t))}function ja(e,t,s){const r=new Set(Object.keys(t).filter(o=>!(o in s)));r.size!==0&&e.setQueriesData({queryKey:zt.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 ka(e,t,s){const r=Date.now(),o=[];for(const[a,i]of Object.entries(t))s[a]!==i&&(Zy(e,i),o.push(i));Bu(e,o,r);for(const[a,i]of Object.entries(s))t[a]||ev(e,a,i.cwd??null)}function tv(){const e=ie();l.useEffect(()=>{$u();let t={},s={};const r=Xy(()=>va(e)),o=at.subscribe(c=>{c.sessions!==t&&(ka(e,c.sessions,t),r.request(),Jy(c.sessions,t)&&wa(e),t=c.sessions),c.rekeys!==s&&(ja(e,c.rekeys,s),s=c.rekeys)}),a=es.subscribeEvent("session_list_invalidated",()=>{at.getState().dropSessions(),e.invalidateQueries({queryKey:zt.listRoot}),va(e),wa(e)}),i=at.getState();return Object.keys(i.sessions).length>0&&(ka(e,i.sessions,t),t=i.sessions),Object.keys(i.rekeys).length>0&&(ja(e,i.rekeys,s),s=i.rekeys),es.connectList(),()=>{o(),a(),r.dispose()}},[e])}function It(){const e=oe(),t=ie(),{data:s,isLoading:r}=ye({queryKey:Ne.current(),queryFn:()=>e.getConfig(),staleTime:Ui}),o=pl(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,u=!o&&s!==void 0&&!c&&!d,f=!o&&c&&!d,p=Ct({mutationFn:b=>e.updateConfig({onboarding:b}),onSuccess:()=>{t.invalidateQueries({queryKey:Ne.all})},onError:(b,y)=>{console.error("[onboarding] could not save progress",{fields:Object.keys(y),error:b}),ae.error("Couldn’t save your setup progress",{description:"Keep going. DorkOS tries again."})},meta:{suppressErrorToast:!0}});function h(){return p.mutateAsync({dismissedAt:new Date().toISOString()})}function g(){i.completedAt||p.mutate({completedAt:new Date().toISOString()})}function x(){i.startedAt||p.mutate({startedAt:new Date().toISOString()})}return{state:i,config:s,isLoading:o,isOnboardingComplete:c,isOnboardingDismissed:d,shouldShowOnboarding:u,shouldShowGettingStarted:f,dismiss:h,completeOnboarding:g,startOnboarding:x}}function nv(e){const{shouldShowOnboarding:t,onboardingHiddenForSession:s}=e,r=t&&!s,[o,a]=l.useState(!1);return r&&!o&&a(!0),o&&!s}function sv(){const e=Fr(),t=Ut(),s=$r({strict:!1}).onboarding,r=zo(s)?s:"welcome",o=l.useRef(!1),a=ke({select:m=>m.status==="idle"}),i=l.useRef(!1);l.useEffect(()=>{if(i.current||!a||(i.current=!0,zo(s)))return;const m=u=>({...u,onboarding:"welcome"});e==null||e({search:m,replace:!0})},[a,s,e]);const c=l.useCallback(m=>{const u=f=>({...f,onboarding:m});o.current=!0,e==null||e({search:u})},[e]),d=l.useCallback(m=>{if(o.current){t.history.back();return}const u=f=>({...f,onboarding:m});e==null||e({search:u})},[t,e]);return{stage:r,goToStage:c,goBack:d}}function rv(e){const{done:t,overlayVisible:s}=e,r=Fr(),o=$r({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 ed(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 ov=2500,av="Couldn’t finish setup. Try again.";function wn(e){return e instanceof Error&&e.message&&!/^HTTP \d+$/.test(e.message)?e.message:av}function vo(){const e=oe(),t=ie();return Ct({mutationFn:s=>e.chooseFirstRunPath(s),onSettled:()=>{for(const s of[Ne.all,zu,Ki.status()])t.invalidateQueries({queryKey:s});t.invalidateQueries({queryKey:Uu})},meta:{suppressErrorToast:!0}})}function iv(e){const t=oe(),{data:s}=ye({queryKey:Ki.status(),queryFn:()=>t.getCloudCredits(),enabled:e,refetchInterval:e?ov:!1,refetchIntervalInBackground:e,staleTime:0});if(s)return s.readiness??(s.linked?"linked":"unlinked")}function cv(){const e=oe(),t=ie();return Ct({mutationFn:()=>e.postOnboardingWelcome(),onSettled:()=>void t.invalidateQueries({queryKey:Ne.all}),meta:{suppressErrorToast:!0}})}function lv({link:e,waitingWindowRef:t,onReady:s}){const r=vo(),[o,a]=l.useState(null),[i,c]=l.useState(!1),d=iv(i),m=i?d:void 0,u=l.useRef(e),f=l.useRef(r.mutateAsync),p=l.useRef(s);l.useEffect(()=>{u.current=e,f.current=r.mutateAsync,p.current=s});const h=l.useCallback(()=>{var w;(w=t.current)==null||w.close(),t.current=null},[t]),g=l.useCallback(async()=>{a(null);try{await f.current({path:"dorkos"})}catch(v){h(),a(wn(v));return}c(!0);const w=u.current;if(w.state==="linked"){h();return}if(w.state==="pending")return;await w.start()===null&&(h(),a(u.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 w=ed(b);w?t.current.go(w):t.current.close(),t.current=null},[b,t]);const y=l.useRef(!1);l.useEffect(()=>{m!=="ready"||y.current||(y.current=!0,p.current())},[m]);const k=l.useCallback(()=>{var w;if((w=t.current)==null||w.close(),t.current=Br(),u.current.state==="expired"||u.current.state==="denied"){a(null),u.current.start();return}g()},[g,t]);return{phase:dv(o,i,e,b,m),retry:k}}function dv(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 wo(){const e=l.useRef(null);return l.useEffect(()=>{var t;(t=e.current)==null||t.focus({preventScroll:!0})},[]),e}function td({phase:e,link:t,onRetry:s,onCancel:r,onUseOwnAi:o}){const a=wo();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(Ge,{size:72,className:"mb-6 opacity-90 dark:hidden"}),n.jsx(Ge,{variant:"white",size:72,className:"mb-6 hidden opacity-90 dark:block"}),n.jsx(uv,{phase:e,link:t,onRetry:s,onUseOwnAi:o}),n.jsx(P,{variant:"ghost",size:"sm",className:"text-muted-foreground mt-8",onClick:r,children:"Cancel"})]})}function uv({phase:e,link:t,onRetry:s,onUseOwnAi:r}){switch(e.kind){case"starting":return n.jsx(Sa,{heading:"Finish in your browser.",line:"Opening the DorkOS page…"});case"waiting":return n.jsxs(n.Fragment,{children:[n.jsx(Ot,{children:"Finish in your browser."}),n.jsx(Un,{children:"Sign in, then come back. This screen moves on by itself."}),n.jsx(mv,{pending:e.pending})]});case"finishing":return n.jsx(Sa,{heading:"Signed in.",line:"Getting your account ready…"});case"needs-card":return n.jsxs(n.Fragment,{children:[n.jsx(Ot,{children:"Add a card to finish."}),n.jsx(Un,{children:"Your agents start once a card is saved."}),n.jsxs(P,{className:"mt-6",onClick:()=>t==null?void 0:t.openBilling(),disabled:!t||t.billingPending,children:[(t==null?void 0:t.billingPending)&&n.jsx(we,{size:"xs"}),"Add a card"]}),(t==null?void 0:t.billingNotice)&&n.jsx(yr,{children:t.billingNotice})]});case"refused":return n.jsxs(n.Fragment,{children:[n.jsx(Ot,{children:"Paid plans are US only."}),n.jsx(Un,{children:"Use your own AI instead."}),n.jsx(P,{className:"mt-6",onClick:r,children:"Use my own AI"})]});case"expired":return n.jsxs(n.Fragment,{children:[n.jsx(Ot,{children:"Your code expired."}),n.jsx(Un,{children:"Get a new one to finish signing in."}),n.jsx(P,{className:"mt-6",onClick:s,children:"Get a new code"})]});case"failed":return n.jsxs(n.Fragment,{children:[n.jsx(Ot,{children:"Couldn’t start signing in."}),n.jsx(yr,{children:e.message}),n.jsx(P,{className:"mt-6",onClick:s,children:"Try again"})]})}}function Sa({heading:e,line:t}){return n.jsxs(n.Fragment,{children:[n.jsx(Ot,{children:e}),n.jsxs("p",{className:"text-muted-foreground mt-3 flex items-center gap-2 text-sm",role:"status",children:[n.jsx(we,{size:"xs"}),t]})]})}function Ot({children:e}){return n.jsx("h1",{id:"onboarding-connecting-heading",className:"text-2xl font-semibold tracking-tight text-balance",children:e})}function Un({children:e}){return n.jsx("p",{className:"text-muted-foreground mt-3 text-sm text-balance",children:e})}function yr({children:e}){return n.jsx("p",{className:"text-destructive mt-3 text-sm text-balance",role:"alert",children:e})}function mv({pending:e}){const{copied:t,failed:s,copy:r}=Cn(),[o,a]=l.useState(!1),i=ed(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(P,{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(Nt,{className:"text-status-success size-4"}):s?n.jsx(Oe,{className:"text-destructive size-4"}):n.jsx(zr,{className:"size-4"})})]}),n.jsxs(P,{variant:"outline",className:"w-full",disabled:i===null,onClick:()=>a(i===null||!pn(i)),children:[n.jsx(Lt,{className:"size-4"}),"Open the page again"]}),n.jsx("p",{className:"text-muted-foreground text-xs break-all",children:e.verificationUri}),o&&n.jsx(yr,{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(we,{size:"xs"}),n.jsx("span",{role:"status",children:"Waiting for you to approve."})]})]})}function hv({onComplete:e}){const t=cv(),{completeOnboarding:s}=It(),r=Ae(),[o,a]=l.useState(null),i=l.useCallback(()=>{s(),r({...he.home(),search:{}}),e()},[s,r,e]),c=l.useCallback(async()=>{a(null);try{await t.mutateAsync()}catch(m){a(wn(m));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(P,{onClick:()=>void c(),children:"Try again"}),n.jsx(P,{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(we,{size:"xs"}),"Opening #team…"]})})}const fv="claude-code";function nd(e,t){return e.length===0?null:e.includes(t)?t:Hi.find(r=>e.includes(r))??e[0]}function pv({readyTypes:e,settled:t,settleToken:s}){var b,y;const{data:r}=Ee(),o=On(),a=ie(),[i,c]=l.useState(null),[d,m]=l.useState(null),u=l.useRef(null),f=((b=r==null?void 0:r.executionDefaults)==null?void 0:b.runtime)??fv,p=!!((y=r==null?void 0:r.onboarding)!=null&&y.runtimeDefaultSetAt),h=l.useCallback((k,w)=>{c(null),m(w),o.mutate(k,{onSuccess:()=>void a.invalidateQueries({queryKey:Ne.all}),onError:I=>{m(null),c(I.message||"Couldn’t save that. Try again.")}})},[o,a]);l.useEffect(()=>{if(!t||e.length===0||!r||p)return;const k=nd(e,f);k&&u.current!==s&&(u.current=s,h({onboarding:{runtimeDefaultSetAt:new Date().toISOString()},...k===f?{}:{runtimes:{default:k}}},k))},[t,s,e,r,p,f,h]);const g=l.useCallback(k=>{k!==(d??f)&&h({runtimes:{default:k},...p?{}:{onboarding:{runtimeDefaultSetAt:new Date().toISOString()}}},k)},[h,d,f,p]);return{runtime:d??((p||d!==null)&&r?f:null),current:d??f,choose:g,error:i}}function gv({onContinue:e,renderConnect:t,simulated:s}){const r=Wi(),{data:o}=Gi(),{data:a}=qi(),i=(s==null?void 0:s.requirements)??r.data,c=s!==void 0||r.isSuccess,d=o?Object.keys(o.capabilities):void 0,m=l.useMemo(()=>Hi.filter(b=>(i==null?void 0:i.runtimes[b])!==void 0),[i]),u=l.useMemo(()=>i?m.filter(b=>Ku(i,b,!0).state==="ready"||s===void 0&&Hu(a,b)):[],[m,i,a,s]),f=pv({readyTypes:u,settled:c&&s===void 0,settleToken:r.dataUpdatedAt}),[p,h]=l.useState(null),g=s!=null&&s.defaultRuntime?{runtime:p??s.defaultRuntime,current:p??s.defaultRuntime,choose:h,error:null}:f;if(!c)return n.jsxs("p",{className:"text-muted-foreground flex items-center gap-2 text-sm",role:"status",children:[n.jsx(we,{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(P,{variant:"outline",size:"sm",onClick:()=>void r.refetch(),children:"Try again"})]});const x=u.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:bv(u,g.runtime)}),n.jsx(xv,{chosen:g.current,readyTypes:u,otherTypes:m.filter(b=>!u.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(db,{types:m,requirements:i,registeredTypes:d,renderConnect:t,onRecheck:s?void 0:()=>void r.refetch(),isRechecking:r.isFetching}),x&&n.jsx(P,{className:"w-full",onClick:e,"data-testid":"onboarding-ai-app-continue",children:"Continue"})]})}function xv({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(Nn,{open:o,onOpenChange:a,children:[n.jsxs(An,{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(At,{className:"size-3"})]}),n.jsxs(En,{align:"start",className:"p-1",children:[n.jsx(In,{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:We(c).label}),!t.includes(c)&&n.jsx("span",{className:"text-muted-foreground text-xs",children:"Not signed in yet"})]}),d&&n.jsx(Nt,{className:"size-3.5 shrink-0","aria-hidden":!0})]},c)})})]})]})}function bv(e,t){const s=e.map(c=>We(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=We(t).label;if(e.includes(t))return`${r} New chats start with ${o}.`;const a=nd(e,t),i=a?We(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 yv=[{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."}],vv={openai:"OpenAI API key",anthropic:"Anthropic API key",openrouter:"OpenRouter key"};function wv({onSaved:e,beforePick:t,slots:s,initialRow:r,simulatedApps:o}){const[a,i]=l.useState(r??null),c=vo(),[d,m]=l.useState(null),u=async(p,h=!1)=>{m(null);try{return await(t==null?void 0:t()),(await c.mutateAsync({path:"own",choice:p})).modelListed===!1&&ae("Using a default model. Change it in Settings."),!0}catch(g){if(h)throw new Error(wn(g),{cause:g});return m(wn(g)),!1}},f=p=>{m(null);const h=a===p?null:p;i(h),h==="agent-app"&&!o&&u({kind:"agent-app"})};return n.jsx("div",{className:"divide-border border-border w-full divide-y rounded-lg border text-left",children:yv.map(p=>n.jsxs("section",{"data-testid":`own-ai-row-${p.id}`,children:[n.jsxs("button",{type:"button","aria-expanded":a===p.id,onClick:()=>f(p.id),className:"hover:bg-muted/60 focus-visible:ring-ring flex w-full items-center gap-3 px-4 py-3 text-left transition-colors focus-visible:ring-2 focus-visible:outline-none",children:[n.jsxs("span",{className:"min-w-0 flex-1",children:[n.jsx("span",{className:"block text-sm font-medium",children:p.title}),n.jsx("span",{className:"text-muted-foreground block text-xs",children:p.line})]}),n.jsx(Kt,{"aria-hidden":!0,className:B("text-muted-foreground size-4 shrink-0 transition-transform",a===p.id&&"rotate-90")})]}),a===p.id&&n.jsxs("div",{className:"px-4 pt-1 pb-4",children:[n.jsx(jv,{row:p.id,busy:c.isPending,save:u,onSaved:e,slots:s,simulatedApps:o}),d&&n.jsx("p",{className:"text-destructive mt-3 text-sm",role:"alert",children:d})]})]},p.id))})}function jv({row:e,busy:t,save:s,onSaved:r,slots:o,simulatedApps:a}){switch(e){case"local":return n.jsxs(P,{onClick:async()=>{await s({kind:"local"})&&r()},disabled:t,children:[t&&n.jsx(we,{size:"xs"}),"Use this computer’s model"]});case"agent-app":return n.jsx(gv,{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(kv,{service:e,busy:t,save:s,onSaved:r})}}function kv({service:e,busy:t,save:s,onSaved:r}){const o=l.useId(),[a,i]=l.useState(""),[c,d]=l.useState(null),m=async u=>{u.preventDefault();const f=a.trim();if(d(null),!f){d("Enter a key.");return}if(e==="anthropic"&&f.startsWith("sk-ant-oat")){d("Subscription tokens can’t run agents. Use an API key.");return}await s({kind:e,apiKey:f})&&(i(""),r())};return n.jsxs("form",{onSubmit:u=>void m(u),className:"space-y-3",children:[n.jsxs("div",{className:"space-y-1.5",children:[n.jsx(Te,{htmlFor:`${o}-key`,children:vv[e]}),n.jsx(Wu,{id:`${o}-key`,value:a,onChange:u=>i(u.target.value),autoComplete:"off"})]}),c&&n.jsx("p",{className:"text-destructive text-sm",role:"alert",children:c}),n.jsxs(P,{type:"submit",disabled:t,children:[t&&n.jsx(we,{size:"xs"}),"Save"]})]})}function Sv({onBack:e,...t}){const s=wo();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(wv,{...t}),n.jsx(P,{variant:"ghost",size:"sm",className:"text-muted-foreground mt-6 self-start",onClick:e,children:"Back"})]})}function Cv({agentName:e,className:t}){var c;const s=Al(),r=e.trim()||"This agent";if(s.isPending)return n.jsx("p",{className:B("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:B("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 m=(a.get(d.toolkit)??0)>1?`${da(d.toolkit)} · ${d.label}`:da(d.toolkit),u=Gu(d.access.classifications);return`${m} (${d.lifecycle==="paused"?`${u}, paused`:u})`});return n.jsxs("div",{className:B("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(Yi,{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 Nv({onContinueWithDorkos:e,onUseOwnAi:t,onContinueWithout:s,busy:r=null,error:o=null}){const a=Vi(),i=wo();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(Ge,{size:120,className:"mb-8 opacity-90 dark:hidden"}),n.jsx(Ge,{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(P,{size:"lg",className:"w-full",onClick:e,disabled:r!==null,"data-testid":"onboarding-continue-dorkos",children:[r==="dorkos"&&n.jsx(we,{size:"xs"}),"Continue with DorkOS"]}),n.jsx(go,{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(P,{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(P,{variant:"ghost",size:"sm",className:"text-muted-foreground",onClick:s,disabled:r!==null,children:[r==="none"&&n.jsx(we,{size:"xs"}),"Continue without an account"]})]})]})}function Av({onComplete:e,slots:t}){const s=t==null?void 0:t.renderAccountLink,r=o=>n.jsx(Ev,{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 Ev({link:e,slots:t,onComplete:s}){var I;const{stage:r,goToStage:o,goBack:a}=sv(),{startOnboarding:i}=It(),c=vo(),[d,m]=l.useState(null),u=l.useRef(null),f=l.useRef(!1);l.useEffect(()=>{f.current||(f.current=!0,i())},[i]),l.useEffect(()=>{var v;r!=="connecting"&&((v=u.current)==null||v.close(),u.current=null)},[r]);const p=l.useRef(e);l.useEffect(()=>{p.current=e});const h=l.useCallback(async()=>{var v;((v=p.current)==null?void 0:v.state)==="pending"&&await p.current.cancel()},[]),g=l.useCallback(()=>{u.current!==null||r==="connecting"||(m(null),u.current=e&&e.state!=="linked"?Br():null,o("connecting"))},[o,e,r]),x=l.useCallback(async()=>{m(null);try{await h(),await c.mutateAsync({path:"none"}),o("landing")}catch(v){m(wn(v))}},[c,o,h]),b=l.useCallback(()=>o("landing"),[o]),y=l.useCallback(()=>o("own-ai"),[o]),k=l.useCallback(()=>a("welcome"),[a]);let w;return r==="connecting"?w=e?n.jsx(Iv,{link:e,waitingWindowRef:u,onReady:b,onCancel:()=>{h(),k()},onUseOwnAi:()=>{h(),y()}}):n.jsx(td,{phase:{kind:"failed",message:"Signing in isn’t available here."},link:null,onRetry:k,onCancel:k,onUseOwnAi:y}):r==="own-ai"?w=n.jsx(Sv,{onBack:k,onSaved:b,beforePick:h,slots:t}):r==="landing"?w=n.jsx(hv,{onComplete:s}):w=n.jsx(Nv,{onContinueWithDorkos:g,onUseOwnAi:y,onContinueWithout:()=>void x(),busy:c.isPending&&((I=c.variables)==null?void 0:I.path)==="none"?"none":null,error:d}),w}function Iv({link:e,waitingWindowRef:t,onReady:s,onCancel:r,onUseOwnAi:o}){const{phase:a,retry:i}=lv({link:e,waitingWindowRef:t,onReady:s});return n.jsx(td,{phase:a,link:e,onRetry:i,onCancel:r,onUseOwnAi:o})}function Rv(){var m;const e=oe(),t=ie(),{data:s}=ye({queryKey:Ne.current(),queryFn:()=>e.getConfig(),staleTime:300*1e3}),r=((m=s==null?void 0:s.mesh)==null?void 0:m.scanRoots)??[],o=(s==null?void 0:s.boundary)??"",a=r.length>0?r:o?[o]:[],{mutate:i,isPending:c}=Ct({mutationKey:$i,mutationFn:async u=>{await e.updateConfig({mesh:{scanRoots:u}})},onSuccess:()=>{t.invalidateQueries({queryKey:Ne.all})}}),d=l.useCallback(u=>i(u),[i]);return{roots:a,boundary:o,isSaving:c,setScanRoots:d}}const Tv=50,nn=["room_created","room_updated","room_member_added","room_member_removed","room_activity"];function Ca(e){if(typeof e!="object"||e===null)return!1;const{roomId:t}=e;return typeof t=="string"&&t.length>0}function Dv(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 Ov(e,t){const s=e.getQueryData(Ie.detail(t.threadId));return s===void 0||s.viewerAuthorId===t.userId}function Mv(e,t){const s=e.isFetching({queryKey:Ie.lists()})>0;e.cancelQueries({queryKey:Ie.lists()}),e.setQueriesData({queryKey:Ie.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(Ie.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(Ie.threads());r!=null&&r.some(o=>o.roomId===t.threadId&&o.unreadCount>0)&&e.invalidateQueries({queryKey:Ie.threads()}),s&&e.invalidateQueries({queryKey:Ie.lists()})}function _v(){const e=ie(),t=()=>{e.invalidateQueries({queryKey:Ie.lists()}),e.invalidateQueries({queryKey:Ie.wellKnowns()}),e.invalidateQueries({queryKey:Ie.threads()})};de(nn[0],t),de(nn[1],t),de(nn[2],t),de(nn[3],t),de(nn[4],t),de("room_updated",o=>{Ca(o)&&e.invalidateQueries({queryKey:Ie.detail(o.roomId)})});const s=l.useRef(new Set),r=o=>{if(!Ca(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:Ie.detail(i)})},Tv)};de("room_member_added",r),de("room_member_removed",r),de("room_presence",o=>qu.getState().observe(o)),de("read_cursor",o=>{!Dv(o)||!Ov(e,o)||Mv(e,o)})}function Pv(){const e=ie();de("tasks_changed",()=>{e.invalidateQueries({queryKey:[...Yu],exact:!0})});const t=()=>{e.invalidateQueries({queryKey:[...Vu]})};de("task_run_failed",t),de("task_run_updated",t)}function Lv(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 Fv=4e3;function sd(){var o;const e=Ur(),{identityPromptDismissedAt:t,isLoading:s}=Ns();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&&Fx(r)?"ask":"settled"}function $v(e={}){const{state:t,isLoading:s,shouldShowGettingStarted:r}=It(),o=e.gettingStartedCardShown??r,a=sd(),{dismissIdentityPrompt:i}=Ns(),[c,d]=l.useState("ask");l.useEffect(()=>{if(c!=="saved")return;const p=setTimeout(()=>d("done"),Fv);return()=>clearTimeout(p)},[c]);const m=t.completedAt!==null||t.dismissedAt!==null,u=!s&&m&&a==="ask"&&!o,f=()=>{i().catch(()=>{})};return{visible:c!=="done"&&(u||c==="saved"),phase:c,markSaved:()=>{d("saved"),f()},skip:()=>{d("done"),f()}}}function rd(){const{firstRunPath:e}=It().state,{offered:t,pending:s}=ol(),r=e==="dorkos"||e==="own";return{due:r&&t,pending:r&&s}}const Bv=4e3,Ks="Tell DorkBot your name",Na="Tell DorkBot about your work";function zv({onDismiss:e}){const t=Ue(),s=Ae(),{open:r}=Ke(),o=Kr(),a=$(E=>E.requestTour),{startSession:i}=Wy(),{roles:c,rolePromptDismissedAt:d,isLoading:m,saveRoles:u,dismissIdentityPrompt:f}=Ns(),p=sd(),h=rd().due,[g,x]=l.useState("closed"),[b,y]=l.useState("closed"),[k,w]=l.useState([]),I=!m&&c.length===0&&d===null;l.useEffect(()=>{if(g!=="saved")return;const E=setTimeout(()=>x("closed"),Bv);return()=>clearTimeout(E)},[g]);const v=()=>{x("saved"),f().catch(()=>{})},S=()=>{y("saving"),u(k).then(()=>y("closed")).catch(()=>y("error"))};let R="Save";b==="saving"?R="Saving…":b==="error"&&(R="Try again");const M=[{icon:fs,label:"Talk to DorkBot",onClick:i},...p==="ask"||g==="saved"?[{icon:xl,label:Ks,onClick:()=>x(E=>E==="saved"?E:E==="closed"?"open":"closed"),expanded:g!=="closed"}]:[],...I?[{icon:Hr,label:Na,onClick:()=>y(E=>E==="closed"?"open":"closed"),expanded:b!=="closed"}]:[],{icon:iy,label:"Show me around",onClick:()=>a("general")},{icon:Et,label:"Create an agent",onClick:()=>ps.getState().open("new")},{icon:Qi,label:"Schedule a task",onClick:()=>s({...he.tasks()})},{icon:bl,label:"Connect more runtimes",onClick:()=>r("runtimes")},{icon:my,label:"Connect a service",onClick:()=>o()}];return n.jsxs(X.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(Oe,{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:M.map(({icon:E,label:N,onClick:j,expanded:A})=>n.jsxs("li",{children:[n.jsxs("button",{onClick:j,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":A,children:[n.jsx(E,{className:"text-muted-foreground size-3.5 shrink-0"}),n.jsx("span",{className:"text-foreground flex-1 text-xs",children:N}),n.jsx(Kt,{className:"text-muted-foreground/40 group-hover:text-muted-foreground size-3.5 shrink-0 transition-colors"})]}),N===Ks&&g==="open"&&n.jsx("div",{className:"px-1.5 py-2","data-testid":"progress-card-identity-form",children:n.jsx(gl,{onSaved:v})}),N===Ks&&g==="saved"&&n.jsx("p",{role:"status",className:"text-muted-foreground px-1.5 py-2 text-xs",children:Je.identityCardSaved}),N===Na&&b!=="closed"&&n.jsx("div",{className:"px-1.5 py-2","data-testid":"progress-card-profile-picker",children:n.jsx(rl,{selected:k,onChange:w,onConfirm:S,confirmLabel:R,busy:b==="saving",error:b==="error"?Je.saveError:null})})]},N))}),h&&n.jsx(al,{compact:!0,className:"border-border mt-2 border-t px-1.5 pt-2"})]})}const Uv="pl-12";function Kv({prompt:e}){const t=Ue(),{open:s}=Ke(),{phase:r,selected:o,setSelected:a,confirmLabel:i,errorMessage:c}=e;return n.jsxs(X.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.jsxs("div",{className:"flex items-start gap-2",children:[n.jsxs("span",{className:"mt-0.5 shrink-0",children:[n.jsx(Ge,{size:40,className:"dark:hidden"}),n.jsx(Ge,{variant:"white",size:40,className:"hidden dark:block"})]}),n.jsxs("div",{className:"flex flex-col gap-0.5",children:[n.jsx("p",{className:"text-sm leading-relaxed",children:r==="saved"?Je.profileSaved:Je.profileCardPrompt[0]}),n.jsxs("p",{className:"text-muted-foreground text-xs leading-relaxed",children:[Je.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("div",{className:Uv,children:n.jsx(rl,{selected:o,onChange:a,onConfirm:e.save,confirmLabel:i,onSkip:e.skip,skipLabel:"Don’t ask again",busy:r==="saving",error:c})})]})}const Hv=4e3;function Wv(e={}){const{state:t,isLoading:s,shouldShowGettingStarted:r}=It(),o=e.gettingStartedCardShown??r,{roles:a,rolePromptDismissedAt:i,isLoading:c,saveRoles:d,dismissRolePrompt:m}=Ns(),[u,f]=l.useState([]),[p,h]=l.useState("ask");l.useEffect(()=>{if(p!=="saved")return;const k=setTimeout(()=>h("done"),Hv);return()=>clearTimeout(k)},[p]);const g=t.completedAt!==null||t.dismissedAt!==null,x=!t.completedSteps.includes("profile")&&!t.skippedSteps.includes("profile"),b=!s&&!c&&g&&a.length===0&&x&&i===null&&!o;let y="Save";return p==="saving"?y="Saving…":p==="error"&&(y="Try again"),{visible:p!=="done"&&(b||p==="saved"),phase:p,selected:u,setSelected:f,confirmLabel:y,errorMessage:p==="error"?Je.saveError:null,save:()=>{h("saving"),d(u).then(()=>h("saved")).catch(()=>h("error"))},skip:()=>{h("done"),m().catch(()=>{})}}}function Gv({prompt:e}){const t=Ue(),s=e.phase==="saved";return n.jsxs(X.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.jsxs("div",{className:"flex items-start gap-2",children:[n.jsxs("span",{className:"mt-0.5 shrink-0",children:[n.jsx(Ge,{size:40,className:"dark:hidden"}),n.jsx(Ge,{variant:"white",size:40,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:s?Je.identityCardSaved:Je.identityCardPrompt[0]}),!s&&n.jsx("p",{className:"text-muted-foreground text-xs leading-relaxed",children:Je.identityCardPrompt[1]})]})]}),!s&&n.jsx(gl,{onSaved:e.markSaved,onSkip:e.skip,skipLabel:"Don’t ask again"})]})}function qv(){const e=oe(),t=l.useRef(null),{startScan:s,addCandidate:r,addExistingAgent:o,setProgress:a,completeScan:i,setError:c}=Wr(),d=l.useCallback((u={roots:[]})=>{var p;(p=t.current)==null||p.abort();const f=new AbortController;t.current=f,s(),e.scan(u,h=>{switch(h.type){case"candidate":r(h.data);break;case"existing-agent":o(h.data);break;case"progress":a(h.data);break;case"complete":i(h.data);break;case"error":c(h.data.error);break}},f.signal).catch(h=>{h instanceof Error&&h.name!=="AbortError"&&c(h.message)})},[e,s,r,o,a,i,c]),m=l.useCallback(()=>{var u;(u=t.current)==null||u.abort(),t.current=null},[]);return{startScan:d,stopScan:m}}function Yv(){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 Vv({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 m=>{if(!s.current.has(m.path)){s.current.add(m.path),o(u=>new Set(u).add(m.path)),i(u=>{const f=new Set(u);return f.delete(m.path),f});try{await e(m),t(m)}catch{i(u=>new Set(u).add(m.path))}finally{s.current.delete(m.path),o(u=>{const f=new Set(u);return f.delete(m.path),f})}}},[t,e]),d=l.useCallback(()=>i(new Set),[]);return{failedPaths:a,pendingPaths:r,registerCandidate:c,resetFailures:d}}function Qv(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 Xv(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 Jv={"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 Zv(e){return Jv[e]??`Found by the “${e}” check.`}const ew={"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 tw(e){return ew[e]??"Found in the project’s files."}function nw({candidate:e,onApprove:t,onDeny:s,onSkip:r,registrationFailed:o=!1,registrationPending:a=!1,className:i,ref:c}){const{path:d,strategy:m,hints:u}=e;return n.jsxs(X.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:B("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:u.suggestedName||d.split("/").pop()||d,children:u.suggestedName||d.split("/").pop()||d}),n.jsxs("div",{className:"text-muted-foreground flex items-center gap-1.5 text-xs",children:[n.jsx(Qu,{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(vl,{openDelay:300,children:[n.jsx(wl,{asChild:!0,children:n.jsx(gn,{variant:"secondary",className:"hover:bg-secondary/80 cursor-default",children:u.detectedRuntime})}),n.jsxs(jl,{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:Zv(m)})]})]}),u.inferredCapabilities&&u.inferredCapabilities.length>0&&u.inferredCapabilities.map(f=>n.jsxs(Ht,{children:[n.jsx(Wt,{asChild:!0,children:n.jsx(gn,{size:"xs",variant:"outline",className:"cursor-default",children:f})}),n.jsx(Gt,{side:"top",className:"max-w-48 text-center",children:tw(f)})]},f))]}),o&&n.jsx("p",{role:"alert",className:"text-destructive text-xs",children:"Couldn’t add this project. Try again."})]}),n.jsxs("div",{className:"ml-4 flex shrink-0 items-center gap-1.5",children:[n.jsx("button",{type:"button",onClick:()=>t(e),disabled:a,className:"focus-visible:ring-ring rounded-md bg-green-600/10 px-2.5 py-1 text-xs font-medium text-green-700 hover:bg-green-600/20 focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50 dark:text-green-400",children:a?"Adding…":o?"Try again":"Add"}),r&&n.jsx("button",{type:"button",onClick:()=>r(e),disabled:a,className:"text-muted-foreground hover:bg-muted focus-visible:ring-ring rounded-md px-2.5 py-1 text-xs font-medium focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50",children:"Skip"}),s&&n.jsx("button",{type:"button",onClick:()=>s(e),disabled:a,className:"focus-visible:ring-ring rounded-md bg-red-600/10 px-2.5 py-1 text-xs font-medium text-red-700 hover:bg-red-600/20 focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50 dark:text-red-400",children:"Deny"})]})]})}function sw({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(hs,{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:Ce(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 rw=2;function ow({agents:e}){const[t,s]=l.useState(e.length<=rw);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(Kt,{className:B("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(sw,{agent:r},r.path))})]})}function aw({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(P,{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(u=>{const f=u.trim();f&&!e.includes(f)&&t([...e,f])},[e,t]),c=l.useCallback(u=>{t(e.filter(f=>f!==u))},[e,t]),d=l.useCallback(u=>{(u.key==="Enter"||u.key===",")&&(u.preventDefault(),s.trim()&&(i(s),r(""))),u.key==="Backspace"&&s===""&&e.length>0&&c(e[e.length-1])},[s,e,i,c]),m=l.useCallback(u=>{i(u)},[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(u=>n.jsxs(gn,{variant:"secondary",className:"gap-1 py-0.5 font-mono",children:[u,n.jsx("button",{type:"button",onClick:()=>c(u),className:"hover:bg-muted-foreground/20 ml-0.5 rounded-sm","aria-label":`Remove ${u}`,children:n.jsx(Oe,{className:"size-3"})})]},u)),n.jsx("input",{type:"text",value:s,onChange:u=>r(u.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(gs,{className:"size-4"})})]}),n.jsx(Xi,{open:o,onOpenChange:a,onSelect:m})]})}function cw(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 lw(){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 uw({fullBleed:e=!1,onRegistered:t}){var ee;const{roots:s,setScanRoots:r}=Rv(),[o,a]=l.useState(null),[i,c]=l.useState(!1),[d,m]=l.useState(3),{startScan:u}=qv(),{candidates:f,existingAgents:p,isScanning:h,progress:g,error:x,lastScanAt:b}=Wr(),{mutateAsync:y}=Xu(),{mutate:k}=Ju(),{data:w}=Zu(),{actedPaths:I,markActed:v,resetActed:S}=Yv(),R=o??s,M=l.useCallback(H=>y({path:H.path,overrides:Qv(H),scanRoot:cw(H.path,R)}),[R,y]),E=l.useCallback(H=>{v(H.path),t==null||t()},[v,t]),{failedPaths:N,pendingPaths:j,registerCandidate:A,resetFailures:C}=Vv({register:M,onSuccess:E});function D(H){a(H),r(H)}function T(){R.length>0&&(S(),C(),u({roots:R,maxDepth:d}))}const L=l.useMemo(()=>h?f:Xv(f),[f,h]).filter(H=>!I.has(H.path)),O=(((ee=w==null?void 0:w.agents)==null?void 0:ee.length)??0)>0,K=p.length>0,V=f.length>0,se=K||V,G=!h&&b!==null,Q=!h&&b===null;function ne(){for(const H of L)A(H)}const J=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(At,{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:R,onChange:D}),n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsx("label",{htmlFor:"scan-depth",className:"text-muted-foreground text-xs",children:"Scan depth"}),n.jsx("input",{id:"scan-depth",type:"range",min:1,max:5,value:d,onChange:H=>m(Number(H.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(ly,{className:"size-3"}),"What it looks for"]}),n.jsx("ul",{className:"space-y-1 pl-4",children:dw.map(H=>n.jsxs("li",{className:"flex items-baseline gap-1.5",children:[n.jsx("code",{className:"text-foreground/70 text-3xs",children:H.signal}),n.jsxs("span",{className:"text-muted-foreground text-3xs",children:["→ ",H.label]})]},H.name))})]})]})]});return n.jsx("div",{className:e?"flex h-full flex-col p-6":"space-y-4 p-4",children:Q?n.jsx("div",{className:e?"flex flex-1 items-center justify-center":"",children:n.jsxs("div",{className:e?"w-full max-w-sm space-y-5":"space-y-5",children:[n.jsx(lw,{}),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(P,{onClick:T,disabled:R.length===0,className:"w-full",children:[n.jsx(ts,{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"}),J]})}):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:[J,n.jsxs(P,{onClick:T,disabled:h||R.length===0,children:[h?n.jsx(we,{}):n.jsx(ts,{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(we,{size:"md",className:"text-muted-foreground",label:"Searching for projects"}),g&&n.jsxs("div",{className:"text-muted-foreground space-y-0.5 text-center text-xs",children:[n.jsxs("p",{children:["Scanned ",g.scannedDirs," directories"]}),n.jsxs("p",{children:["Found ",g.foundAgents," project",g.foundAgents===1?"":"s"]})]})]}),x&&n.jsx("div",{className:"border-destructive/30 bg-destructive/5 text-destructive mb-3 rounded-lg border px-4 py-3 text-sm",children:x}),G&&!V&&K&&n.jsxs("div",{className:"rounded-xl border border-dashed p-8 text-center",children:[n.jsx("p",{className:"text-sm font-medium",children:"All projects already added"}),n.jsx("p",{className:"text-muted-foreground mt-1 text-xs",children:"See them on the Agents tab."})]}),G&&!se&&n.jsxs("div",{className:"rounded-xl border border-dashed p-8 text-center",children:[n.jsx("p",{className:"text-sm font-medium",children:O?"No new projects found":"No projects found"}),n.jsx("p",{className:"text-muted-foreground mt-1 text-xs",children:O?"They’re already added. See the Agents tab.":"Try a deeper scan or other folders."})]}),G&&L.length>0&&n.jsxs(n.Fragment,{children:[n.jsx(aw,{count:L.length,onAddAll:ne,disabled:j.size>0}),n.jsx(Fe,{mode:"popLayout",children:L.map(H=>n.jsx(nw,{candidate:H,className:"mb-2",registrationFailed:N.has(H.path),registrationPending:j.has(H.path),onApprove:U=>void A(U),onSkip:U=>v(U.path),onDeny:U=>k({path:U.path},{onSuccess:()=>v(U.path)})},H.path))})]}),G&&K&&n.jsx("div",{className:"mt-3",children:n.jsx(ow,{agents:p})})]})]})})}function mw(){const e=xn(p=>p.isOpen),t=xn(p=>p.close),s=Ae(),[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 m(p){p||t()}function u(){if(r>0&&!a){i(!0);return}t(),r>0&&s({...he.team()})}const f=`${r} project${r===1?"":"s"} joined`;return n.jsx(et,{open:e,onOpenChange:m,children:n.jsxs(tt,{className:"max-h-[85vh] !min-h-0 sm:max-w-2xl",children:[n.jsxs(Qe,{className:"shrink-0",children:[n.jsx($e,{children:"Bring in existing projects"}),n.jsx(Xe,{children:a?"Your projects are ready in DorkOS.":"Find projects on this computer to add."})]}),a?n.jsx(it,{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(hs,{className:"text-primary size-12","aria-hidden":!0}),n.jsx("p",{className:"text-lg font-semibold","data-testid":"import-joined-summary",children:f}),n.jsx("p",{className:"text-muted-foreground text-sm",children:"Manage agents, tasks and chat apps from the Team page."})]})}):n.jsx(it,{className:"mt-2 overflow-y-auto",children:n.jsx(uw,{onRegistered:()=>o(p=>p+1)})}),n.jsxs(_t,{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:f}):n.jsx("span",{}),n.jsx(P,{onClick:u,"data-testid":"import-done",children:"Done"})]})]})})}function hw(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 fw(){const e=em(s=>s.record),t=Xg();de("marketplace_dev_link_reloaded",s=>{hw(s)&&(e(s),t())})}function pw(){const e=ie();de("relay_bindings_changed",()=>{e.invalidateQueries({queryKey:[...Jg]})})}class gw extends l.Component{constructor(){super(...arguments);Jt(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}}function xw({active:e,hidden:t,here:s,saved:r}){const{setPlacement:o}=kb(),a=$(h=>h.setActiveRightPanelTab),i=Ke(),c=Gr(),d=qr(),m=tm(s)!==null,u=h=>Zi(r.get(h.id),h.declaredPlacement),f=(e==null?void 0:e.extensionId)!=null?d.find(h=>h.extensionId===e.extensionId&&h.path==="")??d.find(h=>h.extensionId===e.extensionId)??null:null,p=m?t:[];return!e&&p.length===0?null:n.jsxs(Yr,{children:[n.jsx(Vr,{asChild:!0,children:n.jsx(P,{variant:"ghost",size:"icon-md","aria-label":"Add-on tab options",className:"size-7 shrink-0","data-testid":"mini-app-tab-menu",children:n.jsx(nm,{className:"size-3.5"})})}),n.jsxs(Qr,{align:"end",className:"min-w-48",children:[e&&n.jsxs(n.Fragment,{children:[f&&c&&n.jsxs(an,{onSelect:()=>void c({href:Ji(f.extensionId,f.path)}),children:[n.jsx(sm,{}),"Open full page"]}),m&&n.jsxs(an,{onSelect:()=>o(e.id,om(u(e),s)),children:[n.jsx(rm,{}),"Hide here"]}),n.jsxs(an,{onSelect:()=>i.open("extensions",e.extensionId),children:[n.jsx(am,{}),"Where it shows…"]})]}),e&&p.length>0&&n.jsx(im,{}),p.length>0&&n.jsxs(n.Fragment,{children:[n.jsx(cm,{className:"text-muted-foreground text-xs font-normal",children:"Show here"}),p.map(h=>n.jsxs(an,{onSelect:()=>{o(h.id,lm(u(h),s)),a(h.id)},children:[h.icon?n.jsx(xs,{icon:h.icon}):n.jsx(Et,{}),h.title]},h.id))]})]})]})}const bw={canvas:"canvas",browser:"browser"};function yw(e,t){return t==="attention"?`${e}, something needs you`:e}function vw({contributionId:e}){const t=bw[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 dm(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 od="right-panel-content";function vr(e){return`right-panel-tab-${e}`}function ww({contributions:e,actions:t}){const s=$(a=>a.setRightPanelOpen),r=$(a=>a.activeRightPanelTab),o=$(a=>a.setActiveRightPanelTab);return n.jsxs("div",{className:"flex w-full items-center justify-between border-b px-3 py-2","data-slot":"right-panel-header",children:[e.length>1?n.jsx(jw,{contributions:e,activeTab:r,onActivate: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(xs,{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(P,{variant:"ghost",size:"icon-md","aria-label":"Close panel",className:"size-7 shrink-0",onClick:()=>s(!1),children:n.jsx(Oe,{className:"size-3.5"})})]})]})}function jw({contributions:e,activeTab:t,onActivate:s}){const r=l.useRef(null),o=l.useRef(null),a=um(u=>u.tabMarkers),i=mm(r,"horizontal"),c=l.useCallback(()=>{const u=r.current;return!u||!t?null:u.querySelector(`#${CSS.escape(vr(t))}`)},[t]),d=l.useCallback(()=>{const u=r.current,f=c();!u||!f||hm(u,f)},[c]),m=e.map(u=>u.id).join(",");return l.useEffect(()=>{if(d(),typeof ResizeObserver>"u")return;const u=new ResizeObserver(d);for(const f of[r.current,o.current,c()])f&&u.observe(f);return()=>u.disconnect()},[d,c,m]),n.jsx(ul,{asChild:!0,value:t??"",onValueChange:s,children:n.jsxs("div",{className:"relative min-w-0 flex-1",children:[n.jsx("div",{ref:r,onScroll:i.onScroll,className:"-my-1 overflow-x-auto overflow-y-hidden py-1",children:n.jsx(ml,{ref:o,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(u=>{const f=u.id===t;return n.jsxs(Ht,{children:[n.jsx(Wt,{asChild:!0,children:n.jsxs(Vn,{value:u.id,"aria-label":yw(u.title,a[u.id]??null),id:vr(u.id),"aria-controls":f?od:void 0,className:B("text-muted-foreground hover:text-foreground text-3xs shrink-0 gap-1.5 rounded-md px-2.5 py-1",f&&"bg-background text-foreground shadow-sm"),children:[n.jsx(xs,{icon:u.icon,className:"size-3.5"}),n.jsx("span",{children:u.title}),n.jsx(vw,{contributionId:u.id})]})}),n.jsx(Gt,{side:"bottom",children:u.title})]},u.id)})})}),i.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"}),i.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 wr="app-shell-right-panel",kw=40,Sw=320,ad=20,Cw=50;function Nw(e){if(e<=0)return ad;const t=Sw/e*100;return Math.min(Math.round(t*10)/10,Cw)}function Aw(){const[e,t]=l.useState(ad);return l.useLayoutEffect(()=>{const s=document.querySelector(`[data-panel-group-id="${wr}"]`);if(!(s instanceof HTMLElement))return;const r=()=>t(Nw(s.offsetWidth));r();const o=new ResizeObserver(r);return o.observe(s),()=>o.disconnect()},[]),{minPct:e,defaultPct:Math.max(kw,e)}}function Ew(e,t){var h;const s=fm(e),r=pm(),o=$(g=>g.selectedCwd),a=s==="session",i=ec(a?o:null),c=r.status==="loading"||a&&o!==null&&i.isPending,d=r.status==="ready"&&!t?r.roomId:null,m=a?((h=i.data)==null?void 0:h.id)??null:null,u=l.useMemo(()=>Iw(s,d,m,a),[s,d,m,a]),[f,p]=l.useState(null);return!c&&f!==u&&p(u),c?{status:"pending",last:f}:{status:"ready",here:u}}function Iw(e,t,s,r){const o={page:e};return t&&(o.roomId=t),r&&(o.agentId=s),o}const Rw="cubic-bezier(0, 0, 0.2, 1)",Tw="cubic-bezier(0.4, 0, 1, 1)";function Aa(e,t){return`${e} 300ms ${t?Rw:Tw}`}const Dw=new Set(["pulse","files"]);function Ow({pathname:e,isRemoteCommunityRoom:t=!1}){const s=$(O=>O.rightPanelOpen),r=$(O=>O.setRightPanelOpen),o=$(O=>O.activeRightPanelTab),a=$(O=>O.setActiveRightPanelTabView),i=jb(),c=je(),d=l.useRef(null),[m,u]=l.useState(!1),[f,p]=l.useState(!1);l.useEffect(()=>{const O=requestAnimationFrame(()=>p(!0));return()=>cancelAnimationFrame(O)},[]);const h=oe(),g=$(O=>O.currentAgentId),x=$(O=>O.selectedCwd),b=$(O=>O.explicitAgentPath),y=bs("right-panel"),k=l.useMemo(()=>y.filter(O=>!O.visibleWhen||O.visibleWhen({pathname:e,transport:h,agentId:g,cwd:x,explicitAgentPath:b,isRemoteCommunityRoom:t})),[y,e,h,g,x,b,t]),w=Ew(e,t),I=w.status==="ready"?w.here:w.last,v=Sb(),S=Ee().data!==void 0,R=l.useMemo(()=>new Map(v.map(O=>[O.tab,O])),[v]),{visibleContributions:M,hiddenMiniAppTabs:E}=l.useMemo(()=>{const O=[],K=[];for(const V of k)V.extensionId?I&&gm(Zi(R.get(V.id),V.declaredPlacement),I)?O.push(V):K.push(V):O.push(V);return{visibleContributions:O,hiddenMiniAppTabs:K}},[k,I,R]);l.useEffect(()=>{if(w.status!=="pending"&&M.length>0&&!M.some(K=>K.id===o)){const K=M.find(V=>!V.isGlobal);a((K??M[0]).id)}},[M,o,a,w.status]);const N=s,{minPct:j,defaultPct:A}=Aw();l.useEffect(()=>{const O=d.current;O&&(N&&O.isCollapsed()?O.expand(A):!N&&O.isExpanded()&&O.collapse())},[N,A]);const C=M.find(O=>O.id===o),D=C==null?void 0:C.component,T=C==null?void 0:C.headerActions,_=n.jsxs(n.Fragment,{children:[n.jsx(ww,{contributions:M,actions:n.jsxs(n.Fragment,{children:[T?n.jsx(l.Suspense,{fallback:null,children:n.jsx(T,{})}):null,w.status==="ready"&&S&&n.jsx(xw,{active:C!=null&&C.extensionId?C:null,hidden:E,here:w.here,saved:R})]})}),n.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",...M.length>1&&o&&M.some(O=>O.id===o)?{id:od,role:"tabpanel","aria-labelledby":vr(o)}:{},children:n.jsx(gw,{tabId:o,children:n.jsx(l.Suspense,{fallback:null,children:D?n.jsx(D,{}):null})})})]});if(i)return N?n.jsx(xm,{open:!0,onOpenChange:O=>!O&&r(!1),children:n.jsxs(bm,{showCloseButton:!1,className:B("bg-sidebar text-sidebar-foreground flex w-full flex-col gap-0 p-0",c&&"sm:max-w-full",c&&o&&Dw.has(o)&&"!bottom-auto !h-auto max-h-dvh overflow-y-auto"),children:[n.jsxs(ym,{className:"sr-only",children:[n.jsx(vm,{children:"Panel"}),n.jsx(wm,{children:"Right panel content."})]}),_]})}):null;const L=f&&!m;return n.jsxs(n.Fragment,{children:[n.jsx(Ux,{"aria-label":"Resize right panel",disabled:!N,onDragging:u,gripStyle:{opacity:N?1:0,pointerEvents:N?"auto":"none",...L&&{transition:Aa("opacity",N)}}}),n.jsx(tc,{ref:d,id:"right-panel",order:2,defaultSize:N?A:0,minSize:j,collapsible:!0,collapsedSize:0,onCollapse:()=>{f&&r(!1)},onExpand:()=>{s||r(!0)},style:L?{transition:Aa("flex-grow",N)}:void 0,children:n.jsx("div",{className:"bg-sidebar text-sidebar-foreground flex h-full flex-col overflow-hidden border-l",children:_})})]})}const Ea="inbox",Mw="open";function _w({blocked:e=!1}={}){const t=ys()[Ea],s=Fr(),r=t!==void 0,o=t==null?"":String(t).trim();l.useEffect(()=>{!r||!s||(o&&!e&&jm(void 0,o===Mw?void 0:{focus:o}),s({search:a=>({...a,[Ea]:void 0}),replace:!0}))},[r,o,e,s]),l.useEffect(()=>{e&&km()},[e])}function Pw(){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 Lw(){const e=ie();de("capabilities_changed",()=>{e.invalidateQueries({queryKey:nc.all})})}function Fw(){const e=oe(),t=ie();return Ct({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:nc.all}),t.invalidateQueries({queryKey:["mesh","agents"]})}})}const Ia=new WeakMap;let $w=0;function Bw(e){const t=Ia.get(e);if(t!==void 0)return t;const s=`bar-${$w++}`;return Ia.set(e,s),s}function zw(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:Bw(r),Header:r}}return null}function Uw(e){const t=e.startsWith("/")?e:`/${e}`;if(De()){const s=t.slice(1);if(s.length>0&&!s.startsWith("?")&&!s.startsWith("#"))return`dorkos://${s}`}return`${window.location.origin}${t}`}const Kw="/";function jo(){const e=Ut();return l.useMemo(()=>{const t=()=>sc(e),s=o=>{pe.getState().selectTab(o),t()},r=o=>{const{tabs:a}=pe.getState(),i=a[o];i&&s(i.id)};return{activate:s,activateIndex:r,activateLast:()=>r(pe.getState().tabs.length-1),activateRelative:o=>{const{tabs:a,activeTabId:i}=pe.getState();if(a.length<2)return;const c=a.findIndex(u=>u.id===i),m=(((c===-1?0:c)+o)%a.length+a.length)%a.length;s(a[m].id)},close:o=>{pe.getState().closeTab(o),t()},closeActive:()=>{const{tabs:o,activeTabId:a}=pe.getState();if(!a)return!1;const i=o.length;pe.getState().closeTab(a);const c=pe.getState().tabs.length<i;if(c)try{t()}catch(d){console.error("[dorkos:tabs] could not follow a closed tab",d)}return c},create:()=>Sm(e,Kw),togglePin:o=>{const a=pe.getState().tabs.find(i=>i.id===o);a&&pe.getState().setTabPinned(o,!a.pinned)},duplicate:o=>{pe.getState().duplicateTab(o),t()},closeOthers:o=>{pe.getState().closeOtherTabs(o),t()},reorder:(o,a)=>pe.getState().moveTab(o,a)}},[e])}const Hw={start:["Space"],cancel:["Escape"],end:["Space","Enter","Tab"]},Ww=4,Gw={draggable:"Press Space to move this tab. Arrows move it, Space drops it, Escape cancels."};function qw(e){return t=>{const s=e(String(t.active.id));return rc({...t,droppableContainers:t.droppableContainers.filter(r=>e(String(r.id))===s)})}}class Yw extends Map{getEnabled(){return[...this.values()].filter(t=>!t.disabled)}toArray(){return[...this.values()]}}function Vw(e){return(t,s)=>{const{context:r}=s;if(!r.active)return dr(t,s);const o=e(String(r.active.id)),a=new Yw;for(const i of r.droppableContainers.toArray())e(String(i.id))===o&&a.set(i.id,i);return dr(t,{...s,context:{...r,droppableContainers:a}})}}function Qw(e){return e.length===0?null:{left:Math.min(...e.map(t=>t.left)),right:Math.max(...e.map(t=>t.right))}}function Xw(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 Jw(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 Zw(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 ej=500;function tj(e){const t=vs(new Date(e).toISOString());return`Last active ${t==="Just now"?"just now":t}`}function nj({identity:e,className:t}){return n.jsxs("div",{className:B("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(Xr,{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(Jr,{identity:e}),n.jsx("span",{children:e.statusSentence})]}),e.lastActiveAt!==void 0&&!Number.isNaN(e.lastActiveAt)&&n.jsx("p",{className:"text-muted-foreground",children:tj(e.lastActiveAt)})]})}function sj({identity:e,children:t}){return n.jsxs(vl,{openDelay:ej,closeDelay:0,children:[n.jsx(wl,{asChild:!0,children:t}),n.jsx(jl,{side:"bottom",align:"start",sideOffset:6,className:"w-64 p-3",children:n.jsx(nj,{identity:e})})]})}const id="app-tab-panel";function rj({identity:e,isActive:t,canClose:s,collapseAgent:r=!1,pinned:o=!1,tabProps:a,onClose:i}){const c=Nm(e,{collapseAgent:r}),d=l.useRef(null);l.useEffect(()=>{var u,f;t&&((f=(u=d.current)==null?void 0:u.scrollIntoView)==null||f.call(u,{block:"nearest",inline:"nearest"}))},[t]);const m=s&&!o;return n.jsxs("div",{ref:d,role:"presentation",className:"group relative flex shrink-0",children:[n.jsx(sj,{identity:e,children:n.jsxs("button",{type:"button",role:"tab","aria-selected":t,"aria-controls":t?id:void 0,"aria-label":Am(e,{collapseAgent:r}),...a,className:B("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&&(m?"pr-7":"pr-2"),t?"bg-background text-foreground shadow-soft":"text-muted-foreground hover:bg-background/60 hover:text-foreground"),children:[n.jsx(Xr,{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(Jr,{identity:e})]})}),m&&i&&n.jsx("button",{type:"button",tabIndex:-1,onClick:()=>i("pointer"),"aria-label":`Close ${e.primary}`,className:B("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(Oe,{className:"size-3"})})]})}function oj({tab:e,isActive:t,canClose:s,pinned:r,tabProps:o,onClose:a}){const i=Zr(e.href),c=Cm(i.agentKey);return n.jsx(rj,{identity:i,isActive:t,canClose:s,collapseAgent:c,pinned:r??e.pinned??!1,tabProps:o,onClose:d=>a(e.id,d)})}function aj({tabId:e,pinned:t,hasOthersToClose:s,canClose:r,actions:o,onClosed:a,children:i}){return n.jsxs(Em,{children:[n.jsx(Im,{asChild:!0,children:i}),n.jsxs(Rm,{className:"w-44",onCloseAutoFocus:a?c=>{c.preventDefault(),a()}:void 0,children:[n.jsxs(Zt,{onSelect:()=>o.togglePin(e),children:[t?n.jsx(Tm,{className:"mr-2 size-4"}):n.jsx(Dm,{className:"mr-2 size-4"}),t?"Unpin":"Pin"]}),n.jsxs(Zt,{onSelect:()=>o.duplicate(e),children:[n.jsx(cy,{className:"mr-2 size-4"}),"Duplicate"]}),n.jsxs(Zt,{onSelect:()=>o.copyLink(e),children:[n.jsx(Om,{className:"mr-2 size-4"}),"Copy link"]}),n.jsx(Mm,{}),n.jsxs(Zt,{disabled:!s,onSelect:()=>o.closeOthers(e),children:[n.jsx(_m,{className:"mr-2 size-4"}),"Close others"]}),n.jsxs(Zt,{disabled:!r,onSelect:()=>o.close(e),children:[n.jsx(Oe,{className:"mr-2 size-4"}),"Close"]})]})]})}const ln="data-app-tab-id";function ij({tab:e,isActive:t,canClose:s,tabProps:r,onClose:o,sortable:a,dragActive:i,menu:c,hasOthersToClose:d,onMenuClosed:m}){const u=e.pinned??!1,{setNodeRef:f,setActivatorNodeRef:p,attributes:h,listeners:g,transform:x,transition:b,isDragging:y}=Pm({id:e.id,disabled:!a}),k=g==null?void 0:g.onPointerDown,w=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:S}=r,R=l.useCallback(j=>{v(j),p(j)},[v,p]),M=l.useCallback(j=>{if(c&&(j.key==="ContextMenu"||j.shiftKey&&j.key==="F10")){j.preventDefault();const A=j.currentTarget,C=A.getBoundingClientRect();A.dispatchEvent(new MouseEvent("contextmenu",{bubbles:!0,cancelable:!0,clientX:C.left,clientY:C.bottom}));return}w==null||w(j),!(j.defaultPrevented||i)&&S(j)},[c,w,i,S]),E=l.useMemo(()=>({...r,ref:R,onKeyDown:M,...a?{"aria-describedby":h["aria-describedby"]}:{}}),[r,R,M,a,h]),N=n.jsx("div",{ref:f,role:"presentation",[ln]:e.id,style:I,onPointerDown:k,className:B("flex shrink-0",y&&"bg-background shadow-soft relative z-10 rounded-md"),children:n.jsx(oj,{tab:e,isActive:t,canClose:s,tabProps:E,onClose:o,pinned:u})});return c?n.jsx(aj,{tabId:e.id,pinned:u,hasOthersToClose:d,canClose:s,actions:c,onClosed:m,children:N}):N}function cj({tabs:e,activeId:t,onActivate:s,onClose:r,onCreate:o,menu:a,onReorder:i,className:c}){const d=l.useRef(null),m=l.useRef(null),u=oc(null),f=e.length>1,[p,h]=l.useState(!1),g=l.useMemo(()=>e.map(N=>N.id),[e]),x=Pt(e),{collisionDetection:b,coordinateGetter:y,modifiers:k,announcements:w}=l.useMemo(()=>{const N=A=>x.read().findIndex(C=>C.id===A),j=A=>{var C;return((C=x.read().find(D=>D.id===A))==null?void 0:C.pinned)??!1};return{collisionDetection:qw(j),coordinateGetter:Vw(j),modifiers:[Xw(u.read)],announcements:Zw({nameOf:A=>{var C,D,T;return((T=(D=(C=Array.from(document.querySelectorAll(`[${ln}]`)).find(_=>_.getAttribute(ln)===A))==null?void 0:C.querySelector('[role="tab"]'))==null?void 0:D.textContent)==null?void 0:T.trim())||"Tab"},indexOf:N,count:()=>x.read().length})}},[x,u]),I=ac(ns(lc,{activationConstraint:{distance:Ww}}),ns(cc,{coordinateGetter:y,keyboardCodes:Hw})),v=({active:N})=>{var C,D;h(!0);const j=((C=e.find(T=>T.id===N.id))==null?void 0:C.pinned)??!1,A=Array.from(((D=m.current)==null?void 0:D.querySelectorAll(`[${ln}]`))??[]).filter(T=>{var L;const _=T.getAttribute(ln);return(((L=e.find(O=>O.id===_))==null?void 0:L.pinned)??!1)===j}).map(T=>T.getBoundingClientRect());u.write(Qw(A))},S=()=>{h(!1),u.write(null)},R=({active:N,over:j})=>{S();const A=Jw(g,N.id,j==null?void 0:j.id);A&&i&&i(...A)},M=()=>{setTimeout(()=>{var N,j;(j=(N=m.current)==null?void 0:N.querySelector('[role="tab"][aria-selected="true"]'))==null||j.focus()},0)},{getTabProps:E}=mb({orderedIds:e.map(N=>N.id),activeId:t,onActivate:s,onClose:f?r:void 0,getFallbackFocus:()=>d.current});return n.jsxs("div",{className:B("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(ic,{sensors:I,collisionDetection:b,modifiers:k,accessibility:{announcements:w,screenReaderInstructions:Gw},onDragStart:v,onDragEnd:R,onDragCancel:S,children:n.jsx(Lm,{items:g,strategy:Fm,children:n.jsx("div",{ref:m,role:"tablist","aria-label":"Open tabs",className:"flex items-stretch gap-1",children:e.map(N=>n.jsx(ij,{tab:N,isActive:N.id===t,canClose:f,tabProps:E(N.id),onClose:r,sortable:i!==void 0,dragActive:p,menu:a,onMenuClosed:M,hasOthersToClose:e.some(j=>j.id!==N.id&&!j.pinned)},N.id))})})})}),n.jsx("button",{ref:d,type:"button",onClick:o,"aria-label":"New tab",title:`New tab (${Ft(bn.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(Et,{className:"size-3.5"})})]})}function lj({className:e}){const t=$m(),s=pe(p=>p.activeTabId),{activate:r,close:o,create:a,togglePin:i,duplicate:c,closeOthers:d,reorder:m}=jo(),{copy:u}=Cn({toastOnSettle:!0}),f=l.useMemo(()=>({togglePin:i,duplicate:c,closeOthers:d,close:o,copyLink:p=>{const h=pe.getState().tabs.find(g=>g.id===p);h&&u(Uw(h.href))}}),[i,c,d,o,u]);return n.jsx(cj,{tabs:t,activeId:s,onActivate:r,onClose:o,onCreate:a,menu:f,onReorder:m,className:e})}function is(){var s;const{tabs:e,activeTabId:t}=pe.getState();return((s=e.find(r=>r.id===t))==null?void 0:s.cursor)??null}function ko(e,t){const s=is();s!==null&&(pe.getState().goToHistoryIndex(t),is()!==s&&sc(e))}function cd(e){const t=is();t!==null&&ko(e,t-1)}function ld(e){const t=is();t!==null&&ko(e,t+1)}function dj(e,t){ko(e,t)}function Ra(e,t){const s=Ft(e);return wt?s:`${s} or ${Ft(`alt+${t}`)}`}const Hs="size-7";function uj({href:e,isCurrent:t,onSelect:s}){const r=Zr(e);return n.jsxs(an,{disabled:t,"aria-current":t?"page":void 0,onSelect:s,"aria-label":r.accessibleName,className:"data-[disabled]:opacity-100",children:[n.jsx(Xr,{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(Jr,{identity:r}),n.jsx(Nt,{className:B("size-3.5 shrink-0",!t&&"invisible")})]})}function Ws({label:e,keys:t,children:s}){return n.jsxs(Ht,{children:[n.jsx(Wt,{asChild:!0,children:s}),n.jsx(Gt,{side:"bottom",className:"text-xs",children:t?`${e} (${t})`:e})]})}function mj(){const e=Ut(),{entries:t,cursor:s,canGoBack:r,canGoForward:o}=Bm();if(!De())return null;const a=t.map((i,c)=>({href:i,index:c})).reverse();return n.jsxs("div",{className:"flex items-center",children:[n.jsx(Ws,{label:"Back",keys:Ra(bn.HISTORY_BACK.key,"←"),children:n.jsx(P,{variant:"ghost",size:"icon-md",className:Hs,"aria-label":"Back",disabled:!r,onClick:()=>cd(e),children:n.jsx(dc,{})})}),n.jsx(Ws,{label:"Forward",keys:Ra(bn.HISTORY_FORWARD.key,"→"),children:n.jsx(P,{variant:"ghost",size:"icon-md",className:Hs,"aria-label":"Forward",disabled:!o,onClick:()=>ld(e),children:n.jsx(uc,{})})}),n.jsxs(Yr,{children:[n.jsx(Ws,{label:"History",children:n.jsx(Vr,{asChild:!0,children:n.jsx(P,{variant:"ghost",size:"icon-md",className:Hs,"aria-label":"History",children:n.jsx(hb,{})})})}),n.jsx(Qr,{align:"start",className:"max-w-72 min-w-48",children:a.map(({href:i,index:c})=>n.jsx(uj,{href:i,isCurrent:c===s,onSelect:()=>dj(e,c)},c))})]})]})}function hj(){const e=Ut(),t=ke({select:o=>o.location.href}),s=l.useRef(!1),r=l.useRef(!0);l.useEffect(()=>{if(De())return e.history.subscribe(({action:o})=>{s.current=o.type!=="PUSH"&&o.type!=="REPLACE",r.current=o.type==="REPLACE"})},[e]),l.useEffect(()=>{if(!De())return;const o=s.current,a=r.current;s.current=!1,r.current=!1,pe.getState().syncLocation(t,{traversal:o,replace:a})},[t])}const Ta=9;function fj(){const e=jo();l.useEffect(()=>{if(!De())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>Ta||(s.preventDefault(),r===Ta?e.activateLast():e.activateIndex(r-1))};return document.addEventListener("keydown",t),()=>document.removeEventListener("keydown",t)},[e])}const Da=3,pj=4;function gj(e){return e instanceof Element?e.closest("input, textarea, select")?!0:e.closest('[contenteditable]:not([contenteditable="false"])')!==null:!1}function Oa(e){return e instanceof Element&&e.closest('[role="dialog"], [role="alertdialog"], [role="menu"]')!==null}function xj(e){if(e.shiftKey)return null;if((wt?e.metaKey&&!e.ctrlKey:e.ctrlKey&&!e.metaKey)&&!e.altKey)return e.code==="BracketLeft"?"back":e.code==="BracketRight"?"forward":null;if(!wt&&e.altKey&&!e.ctrlKey&&!e.metaKey){if(gj(e.target))return null;if(e.key==="ArrowLeft")return"back";if(e.key==="ArrowRight")return"forward"}return null}function bj(){const e=Ut();l.useEffect(()=>{if(!De())return;const t=i=>i==="back"?cd(e):ld(e),s=i=>{if(i.defaultPrevented||i.isComposing||Oa(i.target))return;const c=xj(i);c&&(i.preventDefault(),t(c))},r=i=>i.button===Da||i.button===pj,o=i=>{r(i)&&i.preventDefault()},a=i=>{r(i)&&(i.preventDefault(),!Oa(i.target)&&t(i.button===Da?"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 yj(e){return e.displayName||e.name}function So(e,t){const s=yn(r=>r.setRouteBadge);l.useEffect(()=>{s(e,t)},[e,t,s])}const vj=5*6e4;function wj(e){return e.status==="active"&&e.enabled}function jj(e){const{enabled:t}=Um(),{data:s}=mc(t),{data:r}=Km(t),o=yn(c=>c.setSchedulesWaitingCount),a=l.useMemo(()=>{const c=Lv(t?r??[]:[]),d=new Map((s??[]).filter(wj).map(m=>[m.id,m]));return{waiting:e,failed:c.failed.filter(m=>d.has(m)).length,running:c.running.flatMap(m=>{const u=d.get(m);return u?[yj(u)]:[]})}},[t,r,s,e]),i=l.useMemo(()=>Hm(a),[a]);So("/tasks",i),l.useEffect(()=>{o(e)},[e,o])}function kj(){const{count:e,more:t}=Wm(),s=l.useMemo(()=>Gm(e,t),[e,t]);So("/activity",s)}function Sj(){const{data:e,isSuccess:t}=Ug("pending"),{data:s}=Kg("pending",{enabled:t,refetchInterval:vj}),r=((e==null?void 0:e.length)??0)+((s==null?void 0:s.length)??0),o=l.useMemo(()=>qm(r),[r]);So("/connections",o)}function Cj(){const{items:e,schedules:t}=zm(),s=yn(r=>r.setNeedsYouCount);l.useEffect(()=>{s(e.length)},[e.length,s]),jj(t.length),kj(),Sj()}function bt(e){return"problem"in e?{problem:e.problem}:{message:e.message}}const yt={message:"Couldn’t reach your DorkOS account. Try again."},Nj={message:"Finish signing in in your browser, then try again."},Aj={message:"Your browser blocked the window. Allow pop-ups, then try again."},Gs={message:"Couldn’t connect this DorkOS to the space. Try again."},Ej={message:"The approval ran out. Connect again."};function Co(e,t,s){var E,N;const r=oe(),o=ie(),a=Sn(e!==null),{signsInWithAccount:i,linkFor:c}=hc(e!==null),[d,m]=l.useState({opened:!1,busy:!1,notice:null}),[u,f]=l.useState(null),p=l.useRef(null),h=ye({queryKey:He.list(),queryFn:()=>r.listHostedCommunities(),enabled:e!==null&&u===null,refetchInterval:j=>{const A=j.state.data,C=(A==null?void 0:A.available)===!0?A.communities.find(D=>D.communityId===(e==null?void 0:e.communityId)):void 0;return(C==null?void 0:C.state)==="provisioning"?2e3:!1}}),g=((E=h.data)==null?void 0:E.available)===!0?h.data.communities.find(j=>j.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 j=Br();if(j===null){m(A=>({...A,notice:Aj}));return}m(A=>({...A,busy:!0,notice:null})),r.getHostedCommunityClaimLink(e.communityId).then(A=>{if(!A.ok){j.close(),m(D=>({...D,busy:!1,notice:bt(A)}));return}const C=j.go(c(A.claimUrl));m(D=>({opened:D.opened||C,busy:!1,notice:null}))}).catch(()=>{j.close(),m(A=>({...A,busy:!1,notice:yt}))})},[e,d.busy,r,c]),y=l.useCallback(async()=>{if(e){if(!a||!ft(a)){f({ref:null,approvalUrl:null,busy:!1,notice:Gs});return}f({ref:null,approvalUrl:null,busy:!0,notice:null});try{const j=await r.startCommunityConnection({url:e.communityUrl,installName:t});f({ref:j.connection.ref,approvalUrl:j.approvalUrl,busy:!1,notice:null}),await o.invalidateQueries({queryKey:ot.connections(a)})}catch{f({ref:null,approvalUrl:null,busy:!1,notice:Gs})}}},[e,a,r,t,o]),k=l.useCallback(()=>{!e||d.busy||(m(j=>({...j,busy:!0,notice:null})),r.listHostedCommunities().then(j=>{o.setQueryData(He.list(),j);const A=j.available===!0?j.communities.find(C=>C.communityId===e.communityId):void 0;if(!A||A.state==="pending_owner"||A.state==="provisioning"){m(C=>({...C,busy:!1,notice:Nj}));return}m(C=>({...C,busy:!1})),y()}).catch(()=>m(j=>({...j,busy:!1,notice:yt}))))},[e,d.busy,r,o,y]),w=(u==null?void 0:u.ref)??null,I=ye({queryKey:a&&w?ot.approval(a,w):["cloud","no-approval"],queryFn:()=>zi(a,()=>r.pollCommunityConnection(w)),enabled:a!==null&&w!==null,retry:!1,refetchInterval:j=>!j.state.error&&(!j.state.data||j.state.data.status==="pending")?2e3:!1}),v=w!==null?((N=I.data)==null?void 0:N.status)??"pending":"pending",S=v==="connected"?w:null;l.useEffect(()=>{S===null||p.current===S||(p.current=S,a&&o.invalidateQueries({queryKey:ot.connections(a)}),o.invalidateQueries({queryKey:He.all}),s(S))},[S,a,o,s]);const R=v==="expired"||v==="cancelled";return{state:S!==null?{kind:"done",ref:S}:u!==null?{kind:"connecting",approvalUrl:u.approvalUrl,busy:u.busy,notice:u.notice??(R?Ej:I.error?Gs:null)}:x?{kind:"preparing"}:{kind:"claim",...d,withAccount:e!==null&&i(e.communityUrl)},openClaim:b,confirmClaimed:k,openApproval:()=>{u!=null&&u.approvalUrl&&ct(c(u.approvalUrl))},retryConnect:()=>void y()}}const rt=Ym({offset:!0}).describe("An ISO-8601 instant with an explicit UTC offset."),ze=ue().min(1).describe("An opaque server-issued identifier. Clients never parse or enumerate it.");ue().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 Ij=ue().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."),No="amountKind";Yt(["money","credit"]).describe("What an amount counts: money paid, refunded, offered or capped, or credits held, spent or priced.");const dd=/^-?(0|[1-9][0-9]*)$/,Rj=/^[1-9][0-9]*$/;ue().regex(dd,"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({[No]:"money"});ue().regex(Rj,"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({[No]:"money"});ue().regex(dd,"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({[No]:"credit"});re({currency:ue().regex(/^[A-Z]{3}$/,"must be an ISO 4217 currency code").describe("An ISO 4217 code. Rendered, never enumerated."),microPerCredit:Ij.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 Tj=ue().min(1).describe("A credential returned exactly once. Store it as a credential reference; never log it or persist it as configuration."),ud=ue().min(1).describe("An opaque pagination cursor, passed back verbatim from a previous page.");re({cursor:ud.optional(),limit:le().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 md(e,t){return re({items:qt(e),nextCursor:ud.nullable().describe("The cursor for the next page, or null when this is the last page.")}).describe(t)}const Dj=fc({protocol:/^https$/}).regex(/^https:\/\//,"must be an https: link").describe("An absolute https: link. Any other scheme is refused."),Mn=fc({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."),hd="x-dorkos-one-time-credential",Oj="unrecognised";function cs(e){return Vm([e,ue().transform(()=>Oj).describe("A value this release does not know. It reads as unrecognised.")])}const Qt=ue().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."),fd=ue().trim().min(1).max(80).describe("The community`s display name. Trimmed, 1 to 80 characters."),pd=ue().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 Mj(e){return Mn.meta({description:e,[hd]:!0})}const _j=Yt(["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."),Pj=Yt(["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."),Lj=re({title:ue().min(1).max(120).describe("A short summary, safe to show a person."),detail:ue().max(2e3).describe("The explanation, safe to show a person."),actionUrl:Dj.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:ue().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."),Fj=re({allowed:gt().describe("The owner may choose this community as one to keep open."),wouldHold:qt(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."),Ao=re({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:ue().min(1).max(80).describe("The community`s display name."),shortName:Qt.nullable().describe("The community`s current short name, or null when it has none."),communityUrl:Mn.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:cs(_j).describe("Where the community is in its lifecycle. A state this release does not know reads as unrecognised."),hold:re({reason:cs(Pj).describe("Why the community is on hold. A reason this release does not know reads as unrecognised."),since:rt,deletionNoticeAt:rt.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:rt.nullable().describe("When the Community server will delete the community for good. Always set when the state is deletion_pending."),notice:Lj.nullable().describe("What the service wants the owner to read about this community, or null when there is nothing."),kept:gt().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:re({maxActiveMembers:le().int().positive().nullable().describe("The most people who may be active members at once. Null means no limit."),maxStorageBytes:le().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:re({activeMembers:le().int().nonnegative(),storageBytes:le().int().nonnegative().describe("The bytes that count against the storage limit. Owner exports never count."),measuredAt:rt}).nullable().describe("The community`s last measured usage, or null before the first measurement."),actions:re({claimLink:gt().describe("The service will issue a fresh owner-claim link for this community."),keep:Fj,restore:gt().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:rt}).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.");md(Ao,"A page of the communities the caller has hosted.");re({name:Qt}).describe("The short name to check.");const $j=Yt(["taken","reserved"]).describe("Why a short name cannot be used: another community has it, or the host reserves it.");re({name:Qt,available:gt(),reason:$j.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.");re({idempotencyKey:pd,name:fd,shortName:Qt.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 Bj=re({communityId:ze,claimUrl:Mj("The owner-claim link. A single-use credential: open it in the person`s own browser and never log it."),expiresAt:rt.describe("When the link stops working.")}).describe("A one-time link that makes a person the owner of a new community. Returned once.");re({community:Ao,claim:Bj.nullable().describe("The owner-claim link, or null when this answer repeats an earlier request or the community is still provisioning."),replayed:gt().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.");re({expectedHeldCommunityIds:qt(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.");re({community:Ao,heldCommunityIds:qt(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 zj=Yt(["awaiting_upload","importing","ready","failed","cancelled","claimed"]).describe("Where a move is: waiting for the export, importing it, ready to claim, or finished."),Uj=Yt(["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."),Kj=re({channels:le().int().nonnegative(),entries:le().int().nonnegative().describe("Messages and replies."),attachments:le().int().nonnegative(),historicalMembers:le().int().nonnegative().describe("People whose messages move. They join again by invitation."),historicalAgents:le().int().nonnegative().describe("Agents whose messages move. Their owners pair them again."),attachmentBytes:le().int().nonnegative(),countedBytes:le().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."),gd=re({moveId:ze,communityId:ze.describe("The new community the export fills. It no longer exists once a move has failed or been cancelled."),communityUrl:Mn.describe("The new community`s canonical link. A runtime value."),name:ue().min(1).max(80).describe("The name the new community was given."),state:cs(zj).describe("Where the move is. A state this release does not know reads as unrecognised."),failureCode:cs(Uj).nullable().describe("Why the move failed. Always set when the state is failed. A code this release does not know reads as unrecognised."),report:Kj.nullable().describe("What the export holds, once it has been read. Null before then."),pollAfterMs:le().int().nonnegative().nullable().describe("How long to wait before reading the move again. Null once it has finished."),updatedAt:rt}).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.");md(gd,"A page of the caller`s moves: every unfinished one, and those that finished within the last 7 days, newest first.");re({idempotencyKey:pd,name:fd,shortName:Qt.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:le().int().positive().describe("The size of the export file, in bytes."),archiveSha256:ue().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 Hj=re({url:Mn.describe("Where to send the export. A runtime value."),token:Tj.meta({description:"The upload bearer credential. Returned once; never log it.",[hd]:!0}),expiresAt:rt.describe("When the upload window closes."),maxBytes:le().int().positive().describe("The largest file the upload accepts."),parts:re({partBytes:le().int().positive().describe("The largest part the upload accepts."),maxBytes:le().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."),xd=ue().regex(/^[a-f0-9]{64}$/,"must be a lower-case hex SHA-256 digest"),Eo=1e4,Wj=re({partNumber:le().int().positive().max(Eo).describe("The number of the part, counting up from one."),byteSize:le().int().positive().describe("The size of the part, in bytes."),sha256:xd.describe("The SHA-256 of the part, as lower-case hex.")}).describe("One part the Community server has received.");re({parts:qt(Wj).max(Eo).describe("The parts received, in part order."),maxPartBytes:le().int().positive().describe("The largest part the upload accepts."),maxArchiveBytes:le().int().positive().describe("The largest file a parted upload accepts.")}).describe("The parts of a parted upload received so far.");re({parts:le().int().positive().max(Eo).describe("How many parts make up the file."),archiveBytes:le().int().positive().describe("The size of the whole file, in bytes."),archiveSha256:xd.describe("The SHA-256 of the whole file, as lower-case hex.")}).describe("Put the uploaded parts together into the declared file.");re({move:gd,upload:Hj.nullable().describe("Where to send the export, or null when this answer repeats an earlier request."),replayed:gt().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 Gj=Mn.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."),qj=re({origin:Gj}).describe("A Community server whose single sign-on is this account.");re({servers:qt(qj).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 bd(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 Yj(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 Vj(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 qs(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 jn(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 yd(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 vd="Lower-case letters, numbers and single hyphens. 3 to 32 characters, starting with a letter.";function _n(e){const t=e.trim().toLowerCase();return t===""?{value:t,valid:!0}:{value:t,valid:Qt.safeParse(t).success}}const Qj=80,wd="That web address is taken.",jd="That web address can’t be used.";function kd(e){const t=oe(),{value:s,valid:r}=_n(e),[o,a]=l.useState(s);l.useEffect(()=>{const d=setTimeout(()=>a(s),400);return()=>clearTimeout(d)},[s]);const i=ye({queryKey:He.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 Xj(){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 Jj(){const e=oe(),t=ie(),s=Xj(),[r,o]=l.useState(!1),[a,i]=l.useState({field:null,notice:null});async function c(d){const m={name:d.name.trim(),...d.shortName?{shortName:d.shortName}:{}};o(!0),i({field:null,notice:null});try{const u=await e.startHostedCommunity({...m,idempotencyKey:s(m)});return u.ok?(t.invalidateQueries({queryKey:He.list()}),{community:u.community}):("problem"in u&&u.problem.code==="community_name_taken"?i({field:wd,notice:null}):"problem"in u&&u.problem.code==="community_name_reserved"?i({field:jd,notice:null}):i({field:null,notice:bt(u)}),null)}catch{return i({field:null,notice:yt}),null}finally{o(!1)}}return{submitting:r,failure:a,clearFieldFailure:()=>i(d=>({...d,field:null})),submit:c}}function Zj(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 ek(e){return e.state==="awaiting_upload"||e.state==="importing"||e.state==="ready"}function tk(e){var I;const t=oe(),s=ie(),[r,o]=l.useState(e),[a,i]=l.useState(null),[c,d]=l.useState({field:null,notice:null}),[m,u]=l.useState(!1),f=l.useRef(null),p=l.useRef(null),h=ye({queryKey:He.move(r??""),queryFn:()=>t.getHostedCommunityMove(r),enabled:r!==null,refetchInterval:v=>{var R;const S=v.state.data;return(S==null?void 0:S.available)!==!0?!1:((R=S.move.upload)==null?void 0:R.state)==="sending"?1e3:S.move.pollAfterMs===null?!1:Math.max(1e3,S.move.pollAfterMs)}}),g=((I=h.data)==null?void 0:I.available)===!0?h.data.move:null,x=g?Zj(g):null,b=l.useCallback(v=>{s.setQueryData(He.move(v.moveId),{available:!0,move:v})},[s]);async function y(v){var N;const S={name:v.name.trim(),...v.shortName?{shortName:v.shortName}:{},file:[v.file.name,v.file.size,v.file.lastModified]},R=JSON.stringify(S);((N=p.current)==null?void 0:N.body)!==R&&(p.current={body:R,key:crypto.randomUUID()});const M=p.current.key,E=new AbortController;f.current=E,d({field:null,notice:null}),i({loaded:0,total:v.file.size});try{const j=await t.checkHostedCommunityMoveRoom(v.file.size,E.signal);if(E.signal.aborted)return;const A=j.ok?await t.startHostedCommunityMove(v.file,{idempotencyKey:M,name:S.name,...v.shortName?{shortName:v.shortName}:{}},C=>i(C),E.signal):j;(A.ok||A.mayExist!==!0)&&(p.current=null),A.ok?(b(A.move),o(A.move.moveId),s.invalidateQueries({queryKey:He.list()})):"problem"in A&&A.problem.code==="community_name_taken"?d({field:wd,notice:null}):"problem"in A&&A.problem.code==="community_name_reserved"?d({field:jd,notice:null}):d({field:null,notice:bt(A)})}catch{E.signal.aborted?p.current=null:d({field:null,notice:yt})}finally{f.current=null,i(null)}}async function k(){if(f.current){f.current.abort();return}if(r){u(!0);try{const v=await t.cancelHostedCommunityMove(r);v.ok?b(v.move):d({field:null,notice:bt(v)}),s.invalidateQueries({queryKey:He.list()})}catch{d({field:null,notice:yt})}finally{u(!1)}}}async function w(){if(r){u(!0),d({field:null,notice:null});try{const v=await t.retryHostedCommunityMoveUpload(r);v.ok?b(v.move):d({field:null,notice:bt(v)})}catch{d({field:null,notice:yt})}finally{u(!1)}}}return{step:x,sending:a,failure:c,clearFieldFailure:()=>d(v=>({...v,field:null})),busy:m,start:y,cancel:k,sendAgain:w,startOver:()=>{o(null),d({field:null,notice:null})}}}function nk(){var a,i,c;const e=Vi(),t=ex(),s=il(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(ek))==null?void 0:c.moveId)??null}}const sk={message:"Your spaces changed. Check the list again."};function rk(){const e=oe(),t=ie(),[s,r]=l.useState(null),[o,a]=l.useState(null),[i,c]=l.useState({});function d(u,f){c(p=>{const h={...p};return f?h[u]=f:delete h[u],h})}async function m(u,f){a(u),d(u,null);try{d(u,await f())}catch{d(u,yt)}finally{a(null),await t.invalidateQueries({queryKey:He.list()})}}return{confirmingKeep:s,busyId:o,notices:i,askKeep:r,cancelKeep:()=>r(null),keep:u=>m(u.communityId,async()=>{r(null);const f=await e.keepHostedCommunity(u.communityId,u.actions.keep.wouldHold);return f.ok?null:"problem"in f&&f.problem.code==="conflict"?sk:bt(f)}),restore:u=>m(u.communityId,async()=>{const f=await e.restoreHostedCommunity(u.communityId);return f.ok?null:bt(f)})}}function Io({open:e,onOpenChange:t,step:s,locked:r}){return n.jsx(et,{open:e,onOpenChange:o=>r&&!o?void 0:t(o),children:n.jsxs(tt,{className:"!min-h-0 sm:max-w-lg",children:[n.jsxs(Qe,{children:[n.jsx($e,{children:s.title}),s.description!==void 0&&n.jsx(Xe,{children:s.description})]}),s.body!==void 0&&n.jsx(it,{className:"space-y-4 py-2",children:s.body}),n.jsx(_t,{className:"gap-2 sm:gap-2",children:s.actions})]})})}function St({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(P,{type:"button",size:"sm",variant:"outline",onClick:()=>ct(r),children:[o??"Open your account",n.jsx(Lt,{className:"size-3.5","aria-hidden":!0})]})]})}function Ro(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(we,{className:"size-4"})," Setting up…"]}),actions:n.jsx(P,{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(St,{notice:t.notice}):void 0,actions:n.jsxs(n.Fragment,{children:[n.jsxs(P,{variant:t.opened?"outline":"default",disabled:t.busy,onClick:e.onOpenClaim,children:[t.opened?"Open it again":"Open in your browser",n.jsx(Lt,{className:"size-3.5","aria-hidden":!0})]}),n.jsx(P,{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(we,{className:"size-4"})," Waiting for your approval"]}),t.notice&&n.jsx(St,{notice:t.notice})]}),actions:t.notice?n.jsx(P,{disabled:t.busy,onClick:e.onRetryConnect,children:"Connect again"}):n.jsxs(P,{disabled:t.busy||!t.approvalUrl,onClick:e.onOpenApproval,children:["Open approval page",n.jsx(Lt,{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(hs,{className:"text-status-success-fg size-4","aria-hidden":!0}),"It’s selected in your spaces."]}),actions:n.jsx(P,{onClick:e.onClose,children:"Done"})}}}function ok(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=`${jn(t.storageBytes)}${r!==null?` of ${jn(r)}`:""} of files`;return`${o} · ${a}`}function ak({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=ok(e),m=e.actions.keep.wouldHold.map(f=>t.get(f)??"another space"),u=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(gn,{variant:u?"outline":"secondary",className:u?"border-status-warning-border text-status-warning-fg shrink-0":"shrink-0",children:Yj(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:Vj(e.hold.reason)}),n.jsxs("p",{className:"text-muted-foreground",children:["On hold since ",qs(e.hold.since),"."]}),e.hold.deletionNoticeAt&&n.jsxs("p",{className:"text-destructive",children:["DorkOS may delete it after ",qs(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 ",qs(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(P,{size:"sm",variant:"outline",onClick:()=>ct(e.notice.actionUrl),children:[e.notice.actionLabel??"Learn more",n.jsx(Lt,{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:m.length===0?`Keep ${e.name} open? Nothing else changes.`:`Keeping ${e.name} open puts ${m.length===1?"this one":"these"} on hold: ${m.join(", ")}. People can still read ${m.length===1?"it":"them"}.`}),n.jsxs("div",{className:"flex flex-wrap gap-2",children:[n.jsx(P,{size:"sm",variant:"outline",onClick:s.cancelKeep,children:"Cancel"}),n.jsx(P,{size:"sm",disabled:a,onClick:()=>void s.keep(e),children:"Keep it open"})]})]}),c&&n.jsx(St,{notice:c}),!i&&n.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.actions.claimLink&&n.jsx(P,{size:"sm",onClick:()=>r(e),children:"Finish setting up"}),e.moveId&&n.jsx(P,{size:"sm",variant:"outline",onClick:()=>o(e.moveId),children:"See the move"}),e.actions.keep.allowed&&n.jsx(P,{size:"sm",variant:"outline",disabled:a,onClick:()=>s.askKeep(e.communityId),children:"Keep this one open"}),e.actions.restore&&n.jsx(P,{size:"sm",variant:"outline",disabled:a,onClick:()=>void s.restore(e),children:a?"Reopening…":"Reopen"})]})]})}function ik(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=bd(e.failureCode??"unrecognised");return{text:t.title,next:t.next}}default:return{text:"Unknown state. Update DorkOS to see more."}}}function ck(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(ak,{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=ik(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(P,{size:"sm",variant:"outline",onClick:()=>e.onOpenMove(s.moveId),children:"Continue"})]},s.moveId)})})]})]})}function lk(e){return e.open?n.jsx(dk,{...e}):null}function dk({open:e,onOpenChange:t,installName:s,onOpenMove:r,onMoveHere:o,onConnected:a}){var h;const i=il(!0),c=rk(),[d,m]=l.useState(null),u=Co(d,s,a),f=()=>t(!1);let p;if(d)p=Ro({state:u.state,name:d.name,doneDetail:"Invite people from the space’s own settings when you’re ready.",onOpenClaim:u.openClaim,onConfirmClaimed:u.confirmClaimed,onOpenApproval:u.openApproval,onRetryConnect:u.retryConnect,onClose:f});else{const g=((h=i.data)==null?void 0:h.available)===!0?i.data:null;p={title:"Your spaces",description:"Spaces hosted under your DorkOS account.",body:i.isPending?n.jsx("p",{className:"text-muted-foreground text-sm",children:"Loading…"}):g?n.jsx(ck,{communities:g.communities,moves:g.moves,allowanceText:yd(g.allowance),actions:c,onFinishSetup:m,onOpenMove:x=>{f(),r(x)}}):n.jsx(St,{notice:{message:"Couldn’t reach your DorkOS account. Try again."}}),actions:n.jsxs(n.Fragment,{children:[n.jsx(P,{variant:"outline",onClick:f,children:"Close"}),n.jsx(P,{variant:"outline",onClick:()=>{f(),o()},children:"Move one here"})]})}}return n.jsx(Io,{open:e,onOpenChange:t,step:p})}function uk(e){switch(e.kind){case"invalid":return{text:vd,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 Sd(e){const t=l.useId(),s=e.webAddressError?{text:e.webAddressError,error:!0}:uk(e.webAddressStatus);return n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{className:"space-y-1.5",children:[n.jsx(Te,{htmlFor:`${t}-name`,children:"Space name"}),n.jsx(Ze,{id:`${t}-name`,required:!0,maxLength:Qj,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(Te,{htmlFor:`${t}-address`,children:["Web address ",n.jsx("span",{className:"text-muted-foreground font-normal",children:"(optional)"})]}),n.jsx(Ze,{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)??vd})]})]})}const mk="Your history is here. Send invitations so people can join again.";function hk(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(P,{variant:"outline",onClick:t,children:"Cancel"}),n.jsx(P,{onClick:e,children:"I have the file"})]})}}function fk({file:e,onFileChange:t}){const s=l.useId();return n.jsxs("div",{className:"space-y-1.5",children:[n.jsx(Te,{htmlFor:s,children:"Export file"}),n.jsx(Ze,{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,", ",jn(e.size)]})]})}function pk(e){const t=_n(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(fk,{file:e.file,onFileChange:e.onFileChange}),n.jsx(Sd,{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(St,{notice:e.failure.notice}),n.jsx(go,{})]}),actions:n.jsxs(n.Fragment,{children:[n.jsx(P,{type:"button",variant:"outline",onClick:e.onBack,children:"Back"}),n.jsx(P,{type:"submit",form:e.formId,disabled:s,children:"Start moving"})]})}}function Cd({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(Wx,{value:r,"aria-label":e}),n.jsxs("p",{className:"text-muted-foreground text-sm tabular-nums",children:[jn(t)," of ",jn(s)]})]})}function gk(e,t){return{title:"Getting the file ready",description:"Keep this open. The upload then starts on its own.",body:n.jsx(Cd,{label:"Getting the file ready",...e}),actions:n.jsx(P,{variant:"outline",onClick:t,children:"Cancel"})}}function xk(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 bk(e,t){const{move:s}=e,r=t.notice?n.jsx(St,{notice:t.notice}):null,o=n.jsx(P,{variant:"outline",disabled:t.busy,onClick:t.onCancelMove,children:"Cancel move"}),a=n.jsx(P,{onClick:t.onStartOver,children:"Start again"}),i=n.jsx(P,{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(Cd,{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(P,{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=xk(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(we,{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(P,{onClick:t.onClose,children:"Close"})]})}}case"failed":{const c=bd(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 yk(e){return e.open?n.jsx(vk,{...e}):null}function vk({open:e,onOpenChange:t,installName:s,resumeMoveId:r,onConnected:o}){var I,v;const[a,i]=l.useState("explain"),[c,d]=l.useState(null),[m,u]=l.useState(""),[f,p]=l.useState(""),h=tk(r),g=kd(a==="choose"&&!h.step?f:""),x=((I=h.step)==null?void 0:I.kind)==="ready"?h.step.move:null,b=Co(x?{communityId:x.communityId,name:x.name,communityUrl:x.communityUrl}:null,s,o),y=()=>t(!1);function k(S){S.preventDefault();const R=_n(f);!c||m.trim()===""||!R.valid||h.start({file:c,name:m,shortName:R.value})}let w;return h.sending?w=gk(h.sending,()=>void h.cancel()):((v=h.step)==null?void 0:v.kind)==="ready"?w=Ro({state:b.state,name:h.step.move.name,doneDetail:mk,onOpenClaim:b.openClaim,onConfirmClaimed:b.confirmClaimed,onOpenApproval:b.openApproval,onRetryConnect:b.retryConnect,onClose:y}):h.step?w=bk(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"?w=hk(()=>i("choose"),y):w=pk({file:c,onFileChange:d,name:m,onNameChange:u,webAddress:f,onWebAddressChange:S=>{p(S),h.clearFieldFailure()},webAddressStatus:g,failure:h.failure,formId:"move-community-form",onSubmit:k,onBack:()=>i("explain")}),n.jsx(Io,{open:e,onOpenChange:t,step:w,locked:h.sending!==null})}function wk(e){const t=_n(e.webAddress),s=e.name.trim()===""||!t.valid||e.webAddressStatus.kind==="taken"||e.webAddressStatus.kind==="reserved",r=yd(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(Sd,{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(St,{notice:e.failure.notice}),n.jsx(go,{})]}),actions:n.jsxs(n.Fragment,{children:[n.jsx(P,{type:"button",variant:"outline",onClick:e.onCancel,children:"Cancel"}),n.jsx(P,{type:"submit",form:e.formId,disabled:s||e.submitting,children:e.submitting?"Starting…":"Start space"})]})}}function jk(e){return e.open?n.jsx(kk,{...e}):null}function kk({open:e,onOpenChange:t,installName:s,allowance:r,onConnected:o}){const[a,i]=l.useState(""),[c,d]=l.useState(""),[m,u]=l.useState(null),f=Jj(),p=kd(m?"":c),h=Co(m,s,o),g=()=>t(!1);async function x(y){y.preventDefault();const k=_n(c);if(a.trim()===""||!k.valid||f.submitting)return;const w=await f.submit({name:a,shortName:k.value});w&&u({communityId:w.community.communityId,name:w.community.name,communityUrl:w.community.communityUrl})}const b=m?Ro({state:h.state,name:m.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}):wk({name:a,webAddress:c,onNameChange:i,onWebAddressChange:y=>{d(y),f.clearFieldFailure()},webAddressStatus:p,submitting:f.submitting,failure:f.failure,allowance:r,formId:"start-community-form",onSubmit:y=>void x(y),onCancel:g});return n.jsx(Io,{open:e,onOpenChange:t,step:b,locked:f.submitting})}function Sk({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(jk,{open:(t==null?void 0:t.kind)==="start",onOpenChange:a,installName:r,allowance:e.allowance,onConnected:o}),n.jsx(yk,{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(lk,{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 Ck=.1;function Nk(e){if(!(e!=null&&e.available)||e.balance===null)return null;const{allowance:t,purchased:s,denomination:r}=e.balance,o=tx(t.remainingMicro,t.grantedMicro);if(o===null||o>=Ck||!/^\d+$/.test(t.remainingMicro)||!/^\d+$/.test(s.remainingMicro)||BigInt(s.remainingMicro)>0n)return null;const a=nx(sx(t.remainingMicro,r));return a===null?null:`${a} left`}function Ak(e){if(e.state!=="loading")return e.state==="signed-out"?"Not signed in":["Signed in",e.label,e.lowCredits].filter(Boolean).join(" · ")}function Ek(){var r;const e=pc(),t=((r=e.data)==null?void 0:r.linked)===!0,s=gc({enabled:t});return e.data===void 0?{state:"loading"}:t?{state:"signed-in",label:e.data.accountLabel,lowCredits:Nk(s.data)}:{state:"signed-out"}}function Ik(){const e=ie();de("commands_changed",()=>{e.invalidateQueries({queryKey:["commands"]})})}function Nd(e){return e.kind==="agent"?jt("agent",e.agent.projectPath):jt("room",e.room.id)}function jr(e){return e.kind==="agent"?Ce(e.agent):e.room.kind==="channel"&&e.room.slug?`#${e.room.slug}`:e.room.title}function Ma(e){return`Chats ${e.kind==="agent"?"with":"in"} ${jr(e)}`}function Rk(e){return e.kind==="agent"?`No chats with ${jr(e)} yet.`:`No chats came from ${jr(e)}.`}function Tk(e){return e.kind==="channel"&&e.slug?`#${e.slug}`:e.title}function Dk(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=Tk(r);t.has(o)||t.set(o,r.id)}return t}function Ok(e,t){const s=[];e.cwd!==null&&s.push(jt("agent",e.cwd));const r=Mk(e,t);return r!==void 0&&s.push(jt("room",r)),s}function Mk(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 _k(e,t){const s=Number(e.archived)-Number(t.archived);if(s!==0)return s;const r=Number($t(t))-Number($t(e));return r!==0?r:t.lastActivityAt.localeCompare(e.lastActivityAt)||t.id.localeCompare(e.id)}function Ys(e){return[...e].sort(_k)}function kr(e){const t=[e.title];e.slug&&t.push(e.slug);for(const s of e.participants??[])t.push(s.displayName);return t}function Pk(){const{data:e,isLoading:t,isError:s}=ws({includeArchived:!0});return l.useMemo(()=>{const r=e??[],o=Ys(r.filter(i=>i.kind==="channel")),a=Ys(r.filter(i=>i.kind==="dm"));return{channels:o,dms:a,unread:Ys([...o,...a].filter(i=>!i.archived&&$t(i))),isLoading:t,isError:s}},[e,t,s])}const Lk=8;function Fk(e,t){const s=new Set(Qm(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 _a(e){const t=Date.parse(e.lastActivityAt);return Number.isNaN(t)?Number.NEGATIVE_INFINITY:t}function $k(e){return!(e.unreadCount===null||e.archived||e.lastActivityAt===e.createdAt)}function Bk({sessions:e,rooms:t,unreadRoomIds:s,agents:r,agentActivity:o,excludeSessionIds:a=new Set,limit:i=Lk}){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]:[])),m=t.filter($k).map(g=>({kind:"room",key:`room:${g.id}`,lastActivityAt:g.lastActivityAt,room:g})),u=r.flatMap(g=>{if(d.has(g.projectPath))return[];const x=o[g.projectPath];return x?[{kind:"agent",key:`agent:${g.projectPath}`,lastActivityAt:x,agent:g}]:[]}),f=[],p=[];for(const g of[...c,...m,...u])g.kind==="room"&&s.has(g.room.id)?f.push(g):p.push(g);const h=(g,x)=>_a(x)-_a(g)||x.key.localeCompare(g.key);return[...f.sort(h),...p.sort(h)].slice(0,i)}const zk=50;function Ad(e){const t=[e.id];return e.who&&t.push(e.who),e.cwd&&t.push(e.cwd),t}function Uk(e){return e?e.split("/").filter(Boolean).pop()??null:null}function Pa(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?Ce(i):Uk(a),title:xc(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 Kk(e,t,s,r){const{data:o}=bc(zk),a=at(p=>p.statuses),i=at(yc(p=>Object.values(p.sessions))),c=l.useMemo(()=>Pa((o==null?void 0:o.sessions)??[],e,r),[o==null?void 0:o.sessions,e,r]),d=l.useMemo(()=>Pa(i,e,r),[i,e,r]),m=l.useMemo(()=>[...i,...(o==null?void 0:o.sessions)??[]],[i,o]),u=l.useMemo(()=>{const p=new Map;for(const h of d)p.set(h.id,h);for(const h of c)p.has(h.id)||p.set(h.id,h);return Fk(a,m).flatMap(h=>{const g=p.get(h.sessionId);return g?[{session:g,verb:Xm(h.lifecycle,h.activity),signal:h.lifecycle==="blocked"?"needs-you":"working"}]:[]})},[a,d,c,m]),f=l.useMemo(()=>{const p=new Set(Jm((o==null?void 0:o.sessions)??[]).yours.map(h=>h.id));return Bk({sessions:c.filter(h=>p.has(h.id)),rooms:t,unreadRoomIds:s,agents:e,agentActivity:(o==null?void 0:o.agentActivity)??{},excludeSessionIds:new Set(u.map(h=>h.session.id))})},[o,c,t,s,e,u]);return{sessions:c,continueRows:u,recent:f,agentActivity:(o==null?void 0:o.agentActivity)??Hk}}const Hk=Object.freeze({});function Wk(){const{data:e,dataUpdatedAt:t}=Ee(),s=e!==void 0&&t>Bt,{status:r,url:o}=Zm(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)&&(Uo.getState().consumeSuppression()||eh(Uo.getState().report)||(r==="reconnecting"?ae.warning("Remote access is reconnecting",{id:"tunnel-status",description:"Your other devices can’t reach DorkOS until then."}):r==="off"?ae.error("Remote access turned off",{id:"tunnel-status",description:"Your other devices can’t reach DorkOS now."}):o&&ae.success("Remote access is on",{id:"tunnel-status",description:o})))},[s,r,o])}const Ve={copyLink:"copyRemoteLink",showQr:"showRemoteQr",turnOn:"turnRemoteAccessOn",turnOff:"turnRemoteAccessOff"},sn={copyLink:11,showQr:12,turnOff:13,turnOn:11};function Gk(e,t,s){return(e==="connected"||e==="reconnecting"||e==="asleep")&&t?[{id:"remote-access-copy",label:"Copy remote link",icon:"Copy",action:Ve.copyLink,category:"quick-action",priority:sn.copyLink,keywords:["remote","tunnel","url","address","phone","share"]},{id:"remote-access-qr",label:"Show QR code",icon:"QrCode",action:Ve.showQr,category:"quick-action",priority:sn.showQr,keywords:["remote","tunnel","scan","phone"]},{id:"remote-access-off",label:"Turn remote access off",icon:"Globe",action:Ve.turnOff,category:"quick-action",priority:sn.turnOff,keywords:["remote","tunnel","ngrok","stop","disconnect"]}]:e==="asleep"||e==="blocked"?[{id:"remote-access-off",label:"Turn remote access off",icon:"Globe",action:Ve.turnOff,category:"quick-action",priority:sn.turnOff,keywords:["remote","tunnel","ngrok","stop","disconnect"]}]:s&&(e==="off"||e==="error")?[{id:"remote-access-on",label:"Turn remote access on",icon:"Globe",action:Ve.turnOn,category:"quick-action",priority:sn.turnOn,keywords:["remote","tunnel","ngrok","phone","start"]}]:[]}function qk(){const{state:e,url:t,isSetUp:s}=vc();return l.useMemo(()=>Gk(e,t,s),[e,t,s])}const Kn={usageKey:null,lastActivityAt:null,waiting:!1,demoted:!1,scopes:[]};function La(e){return{usageKey:jt("room",e.id),lastActivityAt:e.lastActivityAt,waiting:$t(e),demoted:e.archived,scopes:[]}}function Yk(e,t){const{data:s,isLoading:r}=js(),o=Pk(),{sessions:a}=wc(),i=l.useMemo(()=>!a||!e?null:th(a,e)[0]??null,[a,e]),{data:c}=Ax(e,i==null?void 0:i.id,i==null?void 0:i.runtime),d=bs("command-palette.items"),m=qr(),u=l.useMemo(()=>m.map(N=>({id:N.id,label:N.title,href:Ji(N.extensionId,N.path),icon:N.icon})),[m]),f=l.useMemo(()=>d.filter(N=>N.category==="feature"),[d]),p=qk(),h=l.useMemo(()=>[...d.filter(N=>N.category==="quick-action"),...p],[d,p]),g=l.useMemo(()=>nh.flatMap(N=>{const j=h.find(A=>A.id===N);return j?[j]:[]}),[h]),x=l.useMemo(()=>(s==null?void 0:s.agents)??[],[s]),b=l.useMemo(()=>new Set(o.unread.map(N=>N.id)),[o.unread]),y=l.useMemo(()=>[...o.channels,...o.dms],[o.channels,o.dms]),k=l.useMemo(()=>sh(t),[t]),{sessions:w,continueRows:I,recent:v,agentActivity:S}=Kk(x,y,b,k),R=l.useMemo(()=>Dk(y),[y]),M=l.useMemo(()=>c?c.commands.map(N=>({name:N.fullCommand,description:N.description})):[],[c]),E=l.useMemo(()=>{const N=[];for(const j of x)N.push({id:j.id,name:j.name,type:"agent",keywords:[j.projectPath,j.id],usageKey:jt("agent",j.projectPath),lastActivityAt:S[j.projectPath]??null,waiting:!1,demoted:!1,scopes:[],data:j});for(const j of w)N.push({id:j.id,name:j.title,type:"session",keywords:Ad(j),usageKey:jt("session",j.id),lastActivityAt:j.lastActivityAt,waiting:!1,demoted:!1,scopes:Ok(j,R),data:j});for(const j of f)N.push({id:j.id,name:j.label,type:"feature",keywords:j.keywords,...Kn,data:j});for(const j of M)N.push({id:`cmd-${j.name}`,name:j.name,type:"command",keywords:j.description?[j.description]:void 0,...Kn,data:j});for(const j of h)N.push({id:j.id,name:j.label,type:"quick-action",keywords:j.keywords,...Kn,data:j});for(const j of o.channels)N.push({id:j.id,name:rh(j),type:"room",keywords:kr(j),...La(j),data:j});for(const j of o.dms)N.push({id:j.id,name:j.title,type:"dm",keywords:kr(j),...La(j),data:j});for(const j of u)N.push({id:j.id,name:j.label,type:"page",keywords:["add-on","extension"],...Kn,data:j});return N},[x,S,w,M,f,h,o.channels,o.dms,R,u]);return{allAgents:x,newActions:g,rooms:o,sessions:w,continueRows:I,recent:v,searchableItems:E,isLoading:r}}function Vk(){const e=$(a=>a.toggleGlobalPalette),t=$(a=>a.setGlobalPaletteOpen),s=$(a=>a.globalPaletteOpen),{close:r}=Ke(),{close:o}=eo();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 lt(e){return Array.isArray?Array.isArray(e):Id(e)==="[object Array]"}function Qk(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 Sr(e){return e==null?"":Qk(e)}function ve(e){return typeof e=="string"}function Xn(e){return typeof e=="number"}function Xk(e){return e===!0||e===!1||Jk(e)&&Id(e)=="[object Boolean]"}function Ed(e){return typeof e=="object"}function Jk(e){return Ed(e)&&e!==null}function Re(e){return e!=null}function Hn(e){return!e.trim().length}function Id(e){return e==null?e===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(e)}const Zk="Incorrect 'index' type",Cr="Invalid doc index: must be a non-negative integer within the bounds of the docs array",eS=e=>`Invalid value for key ${e}`,tS=e=>`Pattern length exceeds max of ${e}.`,nS=e=>`Missing ${e} property in key`,sS=e=>`Property 'weight' in key '${e}' must be a positive integer`,rS="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.",Fa=Object.prototype.hasOwnProperty;var oS=class{constructor(e){this._keys=[],this._keyMap={};let t=0;e.forEach(s=>{const r=Rd(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 Rd(e){let t=null,s=null,r=null,o=1,a=null;if(ve(e)||lt(e))r=e,t=$a(e),s=Jn(e);else{if(!Fa.call(e,"name"))throw new Error(nS("name"));const i=e.name;if(r=i,Fa.call(e,"weight")&&e.weight!==void 0&&(o=e.weight,o<=0))throw new Error(sS(Jn(i)));t=$a(i),s=Jn(i),a=e.getFn??null}return{path:t,id:s,weight:o,src:r,getFn:a}}function $a(e){return lt(e)?e:e.split(".")}function Jn(e){return lt(e)?e.join("."):e}function aS(e,t){const s=[];let r=!1;const o=(a,i,c,d)=>{if(Re(a))if(!i[c])s.push(d!==void 0?{v:a,i:d}:a);else{const m=a[i[c]];if(!Re(m))return;if(c===i.length-1&&(ve(m)||Xn(m)||Xk(m)||typeof m=="bigint"))s.push(d!==void 0?{v:Sr(m),i:d}:Sr(m));else if(lt(m)){r=!0;for(let u=0,f=m.length;u<f;u+=1)o(m[u],i,c+1,u)}else i.length&&o(m,i,c+1,d)}};return o(e,ve(t)?t.split("."):t,0),r?s:s[0]}const iS={includeMatches:!1,findAllMatches:!1,minMatchCharLength:1},cS={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},lS={location:0,threshold:.6,distance:100},dS={useExtendedSearch:!1,useTokenSearch:!1,tokenize:void 0,tokenMatch:"any",getFn:aS,ignoreLocation:!1,ignoreFieldNorm:!1,fieldNormWeight:1},q=Object.freeze({...cS,...iS,...lS,...dS});function uS(e){return e>=9&&e<=13||e===32||e===160}function mS(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++)uS(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 To=class{constructor({getFn:e=q.getFn,fieldNormWeight:t=q.fieldNormWeight}={}){this.norm=mS(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(ve(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(Cr);if(ve(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(Cr);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!Re(e)||Hn(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(Re(i)){if(lt(i)){const c=[];for(let d=0,m=i.length;d<m;d+=1){const u=i[d];if(Re(u)){if(ve(u)){if(!Hn(u)){const f={v:u,i:d,n:this.norm.get(u)};c.push(f)}}else if(Re(u.v)){const f=ve(u.v)?u.v:Sr(u.v);if(!Hn(f)){const p={v:f,i:u.i,n:this.norm.get(f)};c.push(p)}}}}s.$[r]=c}else if(ve(i)&&!Hn(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 Td(e,t,{getFn:s=q.getFn,fieldNormWeight:r=q.fieldNormWeight}={}){const o=new To({getFn:s,fieldNormWeight:r});return o.setKeys(e.map(Rd)),o.setSources(t),o.create(),o}function hS(e,{getFn:t=q.getFn,fieldNormWeight:s=q.fieldNormWeight}={}){const{keys:r,records:o}=e,a=new To({getFn:t,fieldNormWeight:s});return a.setKeys(r),a.setIndexRecords(o),a}function fS(e=[],t=q.minMatchCharLength){const s=[];let r=-1,o=-1,a=0;for(let i=e.length;a<i;a+=1){const c=e[a];c&&r===-1?r=a:!c&&r!==-1&&(o=a-1,o-r+1>=t&&s.push([r,o]),r=-1)}return e[a-1]&&a-r>=t&&s.push([r,a-1]),s}function pS(e,t,s,{location:r=q.location,distance:o=q.distance,threshold:a=q.threshold,findAllMatches:i=q.findAllMatches,minMatchCharLength:c=q.minMatchCharLength,includeMatches:d=q.includeMatches,ignoreLocation:m=q.ignoreLocation}={}){if(t.length>32)throw new Error(tS(32));const u=t.length,f=e.length,p=Math.max(0,Math.min(r,f));let h=a,g=p;const x=(E,N)=>{const j=E/u;if(m)return j;const A=Math.abs(p-N);return o?j+A/o:A?1:j},b=c>1||d,y=b?Array(f):[];let k;for(;(k=e.indexOf(t,g))>-1;){const E=x(0,k);if(h=Math.min(E,h),g=k+u,b){let N=0;for(;N<u;)y[k+N]=1,N+=1}}g=-1;let w=[],I=1,v=0,S=u+f;const R=1<<u-1;for(let E=0;E<u;E+=1){let N=0,j=S;for(;N<j;)x(E,p+j)<=h?N=j:S=j,j=Math.floor((S-N)/2+N);S=j;let A=Math.max(1,p-j+1);const C=i?f:Math.min(p+j,f)+u,D=Array(C+2);D[C+1]=(1<<E)-1;for(let T=C;T>=A;T-=1){const _=T-1,L=s[e[_]];if(D[T]=(D[T+1]<<1|1)&L,E&&(D[T]|=(w[T+1]|w[T])<<1|1|w[T+1]),D[T]&R&&(I=x(E,_),I<=h)){if(h=I,g=_,v=E,g<=p)break;A=Math.max(1,2*p-g)}}if(x(E+1,p)>h)break;w=D}if(b&&g>=0){const E=Math.min(f-1,g+u-1+v);for(let N=g;N<=E;N+=1)s[e[N]]&&(y[N]=1)}const M={isMatch:g>=0,score:Math.max(.001,I)};if(b){const E=fS(y,c);E.length?d&&(M.indices=E):M.isMatch=!1}return M}function gS(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 Do(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 Dd={ł:"l",Ł:"L",đ:"d",Đ:"D",ø:"o",Ø:"O",ħ:"h",Ħ:"H",ŧ:"t",Ŧ:"T",ı:"i",ß:"ss"},xS=new RegExp("["+Object.keys(Dd).join("")+"]","g"),kn=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(xS,t=>Dd[t]):e=>e;var Oo=class{constructor(e,{location:t=q.location,threshold:s=q.threshold,distance:r=q.distance,includeMatches:o=q.includeMatches,findAllMatches:a=q.findAllMatches,minMatchCharLength:i=q.minMatchCharLength,isCaseSensitive:c=q.isCaseSensitive,ignoreDiacritics:d=q.ignoreDiacritics,ignoreLocation:m=q.ignoreLocation}={}){if(this.options={location:t,threshold:s,distance:r,includeMatches:o,findAllMatches:a,minMatchCharLength:i,isCaseSensitive:c,ignoreDiacritics:d,ignoreLocation:m},e=c?e:e.toLowerCase(),e=d?kn(e):e,this.pattern=e,this.chunks=[],!this.pattern.length)return;const u=(p,h)=>{this.chunks.push({pattern:p,alphabet:gS(p),startIndex:h})},f=this.pattern.length;if(f>32){let p=0;const h=f%32,g=f-h;for(;p<g;)u(this.pattern.substr(p,32),p),p+=32;if(h){const x=f-32;u(this.pattern.substr(x),x)}}else u(this.pattern,0)}searchIn(e){const{isCaseSensitive:t,ignoreDiacritics:s,includeMatches:r}=this.options;if(e=t?e:e.toLowerCase(),e=s?kn(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:m}=this.options,u=[];let f=0,p=!1;this.chunks.forEach(({pattern:g,alphabet:x,startIndex:b})=>{const{isMatch:y,score:k,indices:w}=pS(e,g,x,{location:o+b,distance:a,threshold:i,findAllMatches:c,minMatchCharLength:d,includeMatches:r,ignoreLocation:m});y&&(p=!0),f+=k,y&&w&&u.push(...w)});const h={isMatch:p,score:p?f/this.chunks.length:1};return p&&r&&(h.indices=Do(u)),h}};const bS=new Set(["fuzzy","include"]);function yS(e){return e.startsWith("inverse")}const Nr=[{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 Oo(e,{location:t.location??q.location,threshold:t.threshold??q.threshold,distance:t.distance??q.distance,includeMatches:t.includeMatches??q.includeMatches,findAllMatches:t.findAllMatches??q.findAllMatches,minMatchCharLength:t.minMatchCharLength??q.minMatchCharLength,isCaseSensitive:t.isCaseSensitive??q.isCaseSensitive,ignoreDiacritics:t.ignoreDiacritics??q.ignoreDiacritics,ignoreLocation:t.ignoreLocation??q.ignoreLocation});return{type:"fuzzy",search(r){return s.searchIn(r)}}}}],Ba=Nr.length,vS="\0",wS="|";function jS(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 za(e,t){const s=e.match(t);return s?s[1]:null}function kS(e,t={}){return e.replace(/\\\|/g,vS).split(wS).map(s=>{const r=jS(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,m=-1;for(;!d&&++m<Ba;){const u=Nr[m],f=za(c,u.multiRegex);f&&(o.push(u.create(f,t)),d=!0)}if(!d)for(m=-1;++m<Ba;){const u=Nr[m],f=za(c,u.singleRegex);if(f){o.push(u.create(f,t));break}}}return o})}var SS=class{constructor(e,{isCaseSensitive:t=q.isCaseSensitive,ignoreDiacritics:s=q.ignoreDiacritics,includeMatches:r=q.includeMatches,minMatchCharLength:o=q.minMatchCharLength,ignoreLocation:a=q.ignoreLocation,findAllMatches:i=q.findAllMatches,location:c=q.location,threshold:d=q.threshold,distance:m=q.distance}={}){this.query=null,this.options={isCaseSensitive:t,ignoreDiacritics:s,includeMatches:r,minMatchCharLength:o,findAllMatches:i,ignoreLocation:a,location:c,threshold:d,distance:m},e=t?e:e.toLowerCase(),e=s?kn(e):e,this.pattern=e,this.query=kS(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?kn(e):e;let a=0;const i=[];let c=0,d=!1;for(let m=0,u=t.length;m<u;m+=1){const f=t[m];i.length=0,a=0,d=!1;for(let p=0,h=f.length;p<h;p+=1){const g=f[p],{isMatch:x,indices:b,score:y}=g.search(e);if(x)a+=1,c+=y,yS(g.type)&&(d=!0),s&&(bS.has(g.type)?i.push(...b):i.push(b));else{c=0,a=0,i.length=0,d=!1;break}}if(a){const p={isMatch:!0,score:c/a};return d&&(p.hasInverse=!0),s&&(p.indices=Do(i)),p}}return{isMatch:!1,score:1}}};const Ar=[];function Mo(...e){Ar.push(...e)}function ls(e,t){for(let s=0,r=Ar.length;s<r;s+=1){const o=Ar[s];if(o.condition(e,t))return new o(e,t)}return new Oo(e,t)}const ds={AND:"$and",OR:"$or"},Er={PATH:"$path",PATTERN:"$val"},Ir=e=>!!(e[ds.AND]||e[ds.OR]),CS=e=>!!e[Er.PATH],NS=e=>!lt(e)&&Ed(e)&&!Ir(e),Ua=e=>({[ds.AND]:Object.keys(e).map(t=>({[t]:e[t]}))});function Od(e,t,{auto:s=!0}={}){const r=o=>{if(ve(o)){const d={keyId:null,pattern:o};return s&&(d.searcher=ls(o,t)),d}const a=Object.keys(o),i=CS(o);if(!i&&a.length>1&&!Ir(o))return r(Ua(o));if(NS(o)){const d=i?o[Er.PATH]:a[0],m=i?o[Er.PATTERN]:o[d];if(!ve(m))throw new Error(eS(d));const u={keyId:Jn(d),pattern:m};return s&&(u.searcher=ls(m,t)),u}const c={children:[],operator:a[0]};return a.forEach(d=>{const m=o[d];lt(m)&&m.forEach(u=>{c.children.push(r(u))})}),c};return Ir(e)||(e=Ua(e)),r(e)}function Rr(e,{ignoreFieldNorm:t=q.ignoreFieldNorm}){let s=1;return e.forEach(({key:r,norm:o,score:a})=>{const i=r?r.weight:null;s*=Math.pow(a===0&&i?Number.EPSILON:a,(i||1)*(t?1:o))}),s}function AS(e,{ignoreFieldNorm:t=q.ignoreFieldNorm}){e.forEach(s=>{s.score=Rr(s.matches,{ignoreFieldNorm:t})})}var ES=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 IS(e){const t=[];return e.matches.forEach(s=>{if(!Re(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 RS(e,t,{includeMatches:s=q.includeMatches,includeScore:r=q.includeScore}={}){return e.map(o=>{const{idx:a}=o,i={item:t[a],refIndex:a};return s&&(i.matches=IS(o)),r&&(i.score=o.score),i})}const TS=/[\p{L}\p{M}\p{N}_]+/gu,Ka=new WeakSet;function DS(e){Ka.has(e)||(Ka.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 OS(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||DS(e),t=>t.match(e)||[]):t=>t.match(TS)||[]}function Tr({isCaseSensitive:e=!1,ignoreDiacritics:t=!1,tokenize:s}={}){const r=OS(s);return{tokenize(o){return e||(o=o.toLowerCase()),t&&(o=kn(o)),r(o)}}}var MS=class{static condition(e,t){return t.useTokenSearch}constructor(e,t){this.options=t,this.analyzer=Tr({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 Oo(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 m=0;m<this.termSearchers.length;m++){const u=this.termSearchers[m].searchIn(e),f=this.idfWeights[m];r+=f,u.isMatch&&(o++,s+=f*(1-u.score),u.indices&&t.push(...u.indices),this.combineAll&&(this.useMask?a|=1<<m:i.add(m)))}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=Do(t)),this.combineAll&&(this.useMask?d.matchedMask=a:d.matchedTerms=i,d.termCount=this.numTerms),d}};function Vs(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 Md(e,t,s,r){const{i:o,v:a,$:i}=t;if(a!==void 0){Vs(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 m of d)Vs(e,m.v,o,r);else Vs(e,d.v,o,r)}}function _S(e,t,s){const r={fieldCount:0,df:new Map,docFieldCount:new Map,docTermFieldHits:new Map};for(const o of e)Md(r,o,t,s);return r}function PS(e,t,s,r){Md(e,t,s,r)}function LS(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 Ha(e,t){if(t.length===0)return;const s=Array.from(new Set(t)).sort((c,d)=>c-d);for(const c of s)LS(e,c);const r=c=>{let d=0,m=s.length;for(;d<m;){const u=d+m>>>1;s[u]<c?d=u+1:m=u}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 dt=class{constructor(e,t,s){this.options={...q,...t},this.options.useExtendedSearch,this.options.useTokenSearch,this._keyStore=new oS(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=ls(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 To))throw new Error(Zk);if(this._myIndex=t||Td(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight}),this.options.useTokenSearch){const s=Tr({isCaseSensitive:this.options.isCaseSensitive,ignoreDiacritics:this.options.ignoreDiacritics,tokenize:this.options.tokenize});this._invertedIndex=_S(this._myIndex.records,this._myIndex.keys.length,s)}this._invalidateSearcherCache()}add(e){if(!Re(e))return;this._docs.push(e);const t=this._myIndex.add(e,this._docs.length-1);if(this._invertedIndex&&t){const s=Tr({isCaseSensitive:this.options.isCaseSensitive,ignoreDiacritics:this.options.ignoreDiacritics,tokenize:this.options.tokenize});PS(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&&Ha(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(Cr);this._invertedIndex&&Ha(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(ve(e)&&!e.trim()){let p=this._docs.map((h,g)=>({item:h,refIndex:g}));return Xn(s)&&s>-1&&(p=p.slice(0,s)),p}const d=a&&Xn(s)&&s>0&&ve(e),m=i,u=(p,h)=>m(p,h)||p.idx-h.idx;let f;if(d){const p=new ES(s,u);ve(this._docs[0])?this._searchStringList(e,{heap:p,ignoreFieldNorm:c}):this._searchObjectList(e,{heap:p,ignoreFieldNorm:c}),f=p.extractSorted()}else f=ve(e)?ve(this._docs[0])?this._searchStringList(e):this._searchObjectList(e):this._searchLogical(e),AS(f,{ignoreFieldNorm:c}),a&&f.sort(ve(e)?u:m),Xn(s)&&s>-1&&(f=f.slice(0,s));return RS(f,this._docs,{includeMatches:r,includeScore:o})}_searchStringList(e,{heap:t,ignoreFieldNorm:s}={}){const r=this._getSearcher(e),o=this.options.useTokenSearch&&this.options.tokenMatch==="all",{records:a}=this._myIndex,i=t?null:[];return a.forEach(({v:c,i:d,n:m})=>{if(!Re(c))return;const u=r.searchIn(c);if(u.isMatch){const f={score:u.score,value:c,norm:m,indices:u.indices};o&&(f.matchedMask=u.matchedMask,f.matchedTerms=u.matchedTerms,f.termCount=u.termCount);const p=[f];if(!o||this._coversAllTokens(p)){const h={item:c,idx:d,matches:p};t?(h.score=Rr(h.matches,{ignoreFieldNorm:s}),t.insert(h)):i.push(h)}}}),i}_searchLogical(e){const t=Od(e,this.options),s=this._normalizedKeys(),r=(c,d,m)=>{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:m,item:d,matches:x}]:[]}const{children:u,operator:f}=c,p=[];for(let h=0,g=u.length;h<g;h+=1){const x=u[h],b=r(x,d,m);if(b.length)p.push(...b);else if(f===ds.AND)return[]}return p},o=this._myIndex.records,a=new Map,i=[];return o.forEach(({$:c,i:d})=>{if(Re(c)){const m=r(t,c,d);m.length&&(a.has(d)||(a.set(d,{idx:d,item:c,matches:[]}),i.push(a.get(d))),m.forEach(({matches:u})=>{a.get(d).matches.push(...u)}))}}),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:m})=>{if(!Re(d))return;const u=[];let f=!1,p=!1;if(i.forEach((h,g)=>{const x=this._findMatches({key:h,value:d[g],searcher:r});x.length?(u.push(...x),x[0].hasInverse&&(p=!0)):f=!0}),!(p&&f)&&u.length&&(!o||this._coversAllTokens(u))){const h={idx:m,item:d,matches:u};t?(h.score=Rr(h.matches,{ignoreFieldNorm:s}),t.insert(h)):c.push(h)}}),c}_findMatches({key:e,value:t,searcher:s}){if(!Re(t))return[];const r=[];if(lt(t))t.forEach(({v:o,i:a,n:i})=>{if(!Re(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}};dt.version="7.5.0";dt.createIndex=Td;dt.parseIndex=hS;dt.config=q;dt.match=function(e,t,s){if(s&&s.useTokenSearch)throw new Error(rS);return ls(e,{...q,...s}).searchIn(t)};dt.parseQuery=Od;Mo(SS);Mo(MS);dt.use=function(...e){e.forEach(t=>Mo(t))};var FS=dt;const $S=.02,_d=.5,Pd=.35,Ld=.15,BS=1+_d+Pd+Ld,zS=4320*60*1e3,US=3,KS=1440*60*1e3,HS=.15,WS={lastUsedAt:null,useCount:0};function _o(e){return!Number.isFinite(e)||e<0?0:e>1?1:e}function Fd(e,t){return!Number.isFinite(e)||e<=0?1:_o(Math.pow(2,-e/t))}function GS(e,t){const s=e.lastUsedAt===null?0:Fd(t-e.lastUsedAt,zS),r=Math.max(0,e.useCount),o=r===0?0:r/(r+US);return _o((s+o)/2)}function qS(e,t){const s=e.distance===null?1:_o(Math.pow(2,-Math.max(0,e.distance)/$S)),r=GS(e.usage,t),o=e.lastActivityAt===null?0:Fd(t-e.lastActivityAt,KS),a=1+(e.waiting?_d:0)+Pd*r+Ld*o;return{score:s*a/BS,signals:{relevance:s,frecency:r,recency:o}}}function YS(e,t){return e.map(s=>{const{score:r,signals:o}=qS(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 VS(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<HS?{best:null,rest:s}:{best:r,rest:s.slice(1)}:{best:null,rest:s}}function QS(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 XS={keys:["name","keywords"],includeMatches:!0,includeScore:!0,threshold:.3,distance:100,minMatchCharLength:1};function JS(e,t,s){const{usage:r,now:o,scope:a}=s,{prefix:i,term:c}=l.useMemo(()=>a===null?ZS(t):{prefix:null,term:t},[t,a]),d=l.useMemo(()=>{if(a===null)return e;const x=Nd(a);return e.filter(b=>b.scopes.includes(x))},[e,a]),m=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]),u=l.useMemo(()=>new FS(m,XS),[m]),f=l.useMemo(()=>{const x=(b,y,k)=>{const w=b.lastActivityAt===null?NaN:Date.parse(b.lastActivityAt);return{key:`${b.type}:${b.id}`,item:{item:b,matches:y},distance:k,usage:(b.usageKey===null?void 0:r[b.usageKey])??WS,lastActivityAt:Number.isNaN(w)?null:w,waiting:b.waiting,demoted:b.demoted}};return c?u.search(c).map(b=>x(b.item,b.matches,b.score??0)):m.map(b=>x(b,void 0,null))},[u,c,m,r]),p=l.useMemo(()=>YS(f,o),[f,o]),{best:h,rest:g}=l.useMemo(()=>VS(p,{queried:c.length>0}),[p,c]);return{bestMatch:h,rows:g,prefix:i,term:c}}function ZS(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 e0(){const e=to(),t=oh();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 t0=/^\/([A-Za-z0-9][\w.-]*(?::[\w.-]+)*)(?=\s|$)\s*/;function n0(e,t){const s=t.trim().replace(t0,"").trim();return s?`${e} ${s}`:`${e} `}function s0(e){const[t,s]=Rn(),{setTheme:r,theme:o}=Pi(),a=Ae(),i=ie(),c=oe(),d=cn(C=>C.openFeedback),m=no(),{url:u}=vc(),{copy:f}=Cn({toastOnSettle:!0}),{open:p}=Ke(),{open:h}=eo(),g=Kr(),x=$(C=>C.setPickerOpen),b=$(C=>C.setCanvasOpen),y=$(C=>C.setRightPanelOpen),k=$(C=>C.setActiveRightPanelTab),w=l.useCallback(C=>{ss.getState().recordOpened("agent",C)},[]),I=l.useCallback(C=>{s(C.projectPath,{onOpened:()=>{w(C.projectPath)}}),e()},[w,s,e]),v=jc(),S=l.useCallback(C=>{ss.getState().recordOpened("room",C.id),e(),a({...he.channels(),search:{id:C.id}})},[e,a]),R=l.useCallback((C,D)=>{D&&w(D),e(),a(vt({session:C,dir:D??void 0}))},[e,a,w]),M=l.useCallback(C=>{e(),ah({queryClient:i,transport:c},t).then(async D=>{if(D===null){Ko(t);return}t&&w(t);const T=ih.getState(),_=T.getSession(D.sessionId).input;T.updateSession(D.sessionId,{input:n0(C,_)}),a(D.isNew?await ch(c,{session:D.sessionId,dir:t??void 0}):vt({session:D.sessionId}))}).catch(D=>{Bi(c,D),Ko(t)})},[e,a,i,c,t,w]),E=l.useCallback(C=>{e(),a({href:C})},[e,a]),N=l.useCallback(C=>{lh(C)||console.warn(`[command-palette] no handler registered for action "${C}"`)},[]),j=l.useCallback(C=>{switch(e(),C){case"openTasks":h();return;case"openRelay":g();return;case"openMesh":a({...he.team()});return;case"openSettings":p();return;case"discoverAgents":xn.getState().open();return;case"browseFilesystem":x(!0);return;case"openAgentProfile":k(uh),y(!0);return;default:{const D=dh(C);if(D){p(D);return}N(C);return}}},[e,a,h,g,p,x,k,y,N]),A=l.useCallback(C=>{switch(e(),C){case"navigateDashboard":a({...he.home()});return;case"newSession":v();return;case"openDevPlayground":pn("/dev");return;case"toggleDevtools":$.getState().toggleDevtools();return;case"toggleRouterDevtools":$.getState().toggleRouterDevtools();return;case"createAgent":ps.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({...he.feedbackRequests()});return;case"openTasks":h();return;case"openRelay":g();return;case"openMesh":a({...he.team()});return;case"discoverAgents":xn.getState().open();return;case"openSettings":p();return;case"browseFilesystem":x(!0);return;case Ve.copyLink:u&&f(u);return;case Ve.showQr:$.getState().setRemoteAccessBeaconOpen(!0);return;case Ve.turnOn:m.start();return;case Ve.turnOff:m.stop();return;default:N(C);return}},[e,a,N,r,o,b,x,h,g,p,d,f,m,u,v]);return{handleAgentSelect:I,startNewSession:v,handleFeatureAction:j,handleQuickAction:A,handleRoomSelect:S,handleSessionSelect:R,handleCommandSelect:M,handlePageSelect:E,recordAgentOpened:w,setDir:s,selectedCwd:t}}const Wa='[cmdk-item=""]:not([aria-disabled="true"])',r0=new Set(["ArrowUp","ArrowDown","Home","End"]),o0=new Set(["n","p","j","k"]);function a0({rootRef:e,activePage:t,onPin:s,resetKey:r}){const o=l.useRef(!1);l.useLayoutEffect(()=>{o.current=!1},[r]),l.useLayoutEffect(()=>{var m;if(o.current)return;const c=(m=e.current)==null?void 0:m.querySelector(`[data-palette-page="${CSS.escape(t)}"] ${Wa}`);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||(r0.has(c.key)||c.ctrlKey&&o0.has(c.key))&&(o.current=!0)},[]),i=l.useCallback(c=>{c.target instanceof Element&&c.target.closest(Wa)&&(o.current=!0)},[]);return{onKeyDown:a,onPointerMove:i}}function i0({scope:e,className:t}){return n.jsx("span",{"data-testid":"palette-scope-chip",className:B("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(so,{...ro(e.agent),size:"xs",badge:null}),Ce(e.agent)]}):n.jsxs(n.Fragment,{children:[n.jsx(kc,{room:e.room,participants:e.room.participants,size:"xs"}),n.jsx(Sc,{room:e.room})]})})}function c0(e){const t=e.trim();return t.length===0?null:t}function $d(e,t){const s=l.useDeferredValue(e),{sessions:r}=mh(t),{data:o}=Vx(s||null),a=l.useMemo(()=>r.slice(0,3).map(i=>({id:i.id,title:xc(i.title),lastActive:i.updatedAt})),[r]);return{sessionCount:r.length,recentSessions:a,health:o??null}}function l0({agent:e}){const{sessionCount:t,recentSessions:s,health:r}=$d(e.id,e.projectPath),{color:o,emoji:a}=ro(e);return n.jsx(X.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(so,{color:o,emoji:a,size:"sm",className:"shrink-0"}),n.jsx("span",{className:"truncate text-sm font-semibold",children:Ce(e)})]}),n.jsx("p",{className:"text-muted-foreground truncate text-xs",children:Cc(e.projectPath)}),n.jsxs("div",{className:"flex items-center gap-3 text-xs",children:[r&&n.jsx(gn,{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 d0({agent:e,onOpenHere:t,onOpenNewTab:s,onOpenNewWindow:r,onNewSession:o,onBrowseSessions:a,onEditSettings:i,recentSessions:c,onSelectSession:d}){const m=wt?"⌘":"Ctrl+";return n.jsxs(n.Fragment,{children:[n.jsxs(Le,{heading:`${Ce(e)} actions`,children:[n.jsxs(me,{value:"open-here",onSelect:t,children:[n.jsx(gs,{className:"size-4"}),n.jsx("span",{children:"Open here"}),n.jsx(la,{children:"Enter"})]}),n.jsxs(me,{value:"open-new-tab",onSelect:s,children:[n.jsx(pb,{className:"size-4"}),n.jsx("span",{children:"Open in a new tab"}),n.jsxs(la,{children:[m,"Enter"]})]}),r&&n.jsxs(me,{value:"open-new-window",onSelect:r,children:[n.jsx(hy,{className:"size-4"}),n.jsx("span",{children:"Open in a new window"})]}),n.jsxs(me,{value:"new-session",onSelect:o,children:[n.jsx(Et,{className:"size-4"}),n.jsx("span",{children:"New chat"})]}),a&&n.jsxs(me,{value:"browse-sessions",onSelect:a,children:[n.jsx(xb,{className:"size-4"}),n.jsx("span",{children:"Browse chats…"})]}),n.jsxs(me,{value:"edit-settings",onSelect:i,children:[n.jsx(ks,{className:"size-4"}),n.jsxs("span",{children:["Edit ",Ce(e)," settings"]})]})]}),c.length>0&&n.jsx(Le,{heading:"Recent chats",children:c.map(u=>n.jsxs(me,{value:u.id,onSelect:()=>d(u.id),children:[n.jsx(fs,{className:"size-4"}),n.jsx("span",{className:"truncate",children:u.title}),n.jsx("span",{className:"text-muted-foreground ml-auto text-xs",children:u0(u.lastActive)})]},u.id))})]})}function u0(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 st="bg-muted rounded px-1 py-0.5 font-mono text-3xs";function m0({page:e,hasAgentSelected:t,canScope:s,isScoped:r}){const o=wt?"⌘":"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:st,children:"↑↓"}),"Navigate"]}),!e&&t&&n.jsxs("span",{className:"inline-flex items-center gap-1",children:[n.jsx("kbd",{className:st,children:"Enter"}),"Open"]}),(!e&&t||e==="agent-actions")&&n.jsxs("span",{className:"inline-flex items-center gap-1",children:[n.jsxs("kbd",{className:st,children:[o,"Enter"]}),"New tab"]}),e==="agent-actions"&&n.jsxs("span",{className:"inline-flex items-center gap-1",children:[n.jsx("kbd",{className:st,children:"Enter"}),"Select"]}),e&&n.jsxs("span",{className:"inline-flex items-center gap-1",children:[n.jsx("kbd",{className:st,children:"Backspace"}),"Back"]}),s&&n.jsxs("span",{className:"inline-flex items-center gap-1",children:[n.jsx("kbd",{className:st,children:"Tab"}),"Search inside"]}),r&&n.jsxs("span",{className:"inline-flex items-center gap-1",children:[n.jsx("kbd",{className:st,children:"Backspace"}),"Clear scope, at the start"]}),n.jsxs("span",{className:"ml-auto inline-flex items-center gap-1",children:[n.jsx("kbd",{className:st,children:"esc"}),"Close"]})]})}const h0=[{key:"#",means:"channels"},{key:"@",means:"agents and DMs"},{key:">",means:"commands"}];function Bd({className:e}){return n.jsx("div",{className:B("text-muted-foreground flex flex-wrap items-center gap-x-3 gap-y-1 px-3 py-2 text-xs",e),children:h0.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 f0({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 zd({agent:e,isActive:t,onSelect:s,nameIndices:r,isSelected:o}){return n.jsxs(me,{value:Ce(e),keywords:[e.name,e.projectPath,e.id],onSelect:()=>s(),className:"relative py-2",forceMount:t?!0:void 0,children:[o&&n.jsx(X.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(bb,{agent:e,name:r?n.jsx(f0,{text:Ce(e),indices:r,className:"truncate text-sm font-semibold"}):n.jsx("span",{className:"truncate text-sm font-semibold",children:Ce(e)}),secondary:Cc(e.projectPath),selected:t})})]})}function Ud(){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 Kd({room:e,onSelect:t}){const s=$t(e);return n.jsxs(me,{value:e.id,keywords:kr(e),onSelect:t,className:"flex items-center gap-2 py-2",children:[n.jsx(kc,{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(Sc,{room:e,className:"min-w-0 flex-1 text-sm"}),e.archived&&n.jsx(Ud,{}),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 p0=6e4;function g0({lastActivityAt:e}){const t=oo(p0),s=l.useMemo(()=>Number.isNaN(Date.parse(e))?null:vs(e),[e,t]);return s===null?null:n.jsx("span",{className:"text-muted-foreground text-2xs font-normal",children:s})}function Dr({item:e,live:t,isSelected:s=!1,onSelect:r}){const o=Nc(e.agent,e.cwd??e.id),a=hh(e.who,e.title),i=(t==null?void 0:t.verb)??null;return n.jsxs(me,{value:e.id,keywords:Ad(e),onSelect:r,title:a,className:B("flex gap-2 py-1.5",i!==null?"items-start":"items-center"),children:[n.jsx(so,{color:o.color,emoji:o.emoji,size:"xs",className:B("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:fh,children:e.who}),n.jsx("span",{"aria-hidden":!0,className:"text-muted-foreground/60 flex-none",children:ph})]}):null,n.jsx("span",{"data-slot":"palette-session-title",className:gh,children:e.title}),n.jsxs("span",{className:B("flex items-center gap-1.5",bh),children:[e.archived&&t===void 0&&n.jsx(Ud,{}),n.jsx(xh,{origin:e.origin,label:e.originLabel,className:"text-muted-foreground"}),n.jsx(g0,{lastActivityAt:e.lastActivityAt}),s&&n.jsx(x0,{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:B("size-1.5 shrink-0 rounded-full",yh(t.signal))}),i]})]})]})}function x0({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 b0={session:"Conversations",agent:"Agents",room:"Channels",dm:"Direct messages",command:"Commands",feature:"Actions","quick-action":"Actions",page:"Add-ons"},y0="Best match",Or={Clock:Qi,Radio:yb,Globe:Ec,Settings:ks,Plus:Et,Search:ts,FolderOpen:gs,Moon:Ox,Shapes:wh,MessageSquarePlus:Ac,Inbox:vh},pt=[0,0,.2,1],v0=[.4,0,1,1],Hd={hidden:{opacity:0,scale:.96,y:-8},visible:{opacity:1,scale:1,y:0,transition:{duration:.2,ease:pt}},exit:{opacity:0,scale:.96,y:-8,transition:{duration:.12,ease:v0}}},w0={hidden:{},visible:{transition:{staggerChildren:.035,delayChildren:.04}}},mn={hidden:{opacity:0,y:-4},visible:{opacity:1,y:0,transition:{duration:.15,ease:pt}}},Qs=8;function j0({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(Le,{heading:"Continue",children:e.map((m,u)=>n.jsx(X.div,{variants:u<Qs?mn:void 0,children:n.jsx(Dr,{item:m.session,live:{verb:m.verb,signal:m.signal},isSelected:o===m.session.id,onSelect:()=>a(m.session)})},m.session.id))}),t.length>0&&n.jsx(Le,{heading:"Recent",children:t.map((m,u)=>n.jsxs(X.div,{variants:u<Qs?mn:void 0,children:[m.kind==="session"&&n.jsx(Dr,{item:m.session,isSelected:o===m.session.id,onSelect:()=>a(m.session)}),m.kind==="room"&&n.jsx(Kd,{room:m.room,onSelect:()=>i(m.room)}),m.kind==="agent"&&n.jsx(zd,{agent:m.agent,isActive:m.agent.projectPath===r,isSelected:o===Ce(m.agent),onSelect:()=>c(m.agent)})]},m.key))}),s.length>0&&n.jsxs(n.Fragment,{children:[(e.length>0||t.length>0)&&n.jsx(kl,{}),n.jsx(Le,{heading:"New",children:s.map((m,u)=>{const f=Or[m.icon];return n.jsx(X.div,{variants:u<Qs?mn:void 0,children:n.jsx(me,{value:m.label,onSelect:()=>d(m.action),children:n.jsxs(X.div,{whileHover:{x:2},transition:{duration:.1,ease:pt},className:"flex w-full items-center gap-2",children:[f&&n.jsx(f,{className:"size-4"}),n.jsx("span",{children:m.label})]})})},m.id)})})]})]})}function Ga({row:e,selectedCwd:t,selectedValue:s,onFeatureAction:r,onQuickAction:o,onGoToAgentActions:a,onRoomSelect:i,onSessionSelect:c,onCommandSelect:d,onPageSelect:m}){var p;const{item:u,matches:f}=e.item;switch(u.type){case"session":return n.jsx(Dr,{item:u.data,isSelected:s===u.data.id,onSelect:()=>c(u.data)});case"agent":return n.jsx(zd,{agent:u.data,isActive:u.data.projectPath===t,isSelected:s===Ce(u.data),onSelect:()=>a(u.data),nameIndices:(p=f==null?void 0:f.find(h=>h.key==="name"))==null?void 0:p.indices});case"room":case"dm":return n.jsx(Kd,{room:u.data,onSelect:()=>i(u.data)});case"command":return n.jsx(me,{value:u.data.name,onSelect:()=>d(u.data.name),children:n.jsxs(X.div,{whileHover:{x:2},transition:{duration:.1,ease:pt},className:"flex w-full items-center gap-2",children:[n.jsx("span",{className:"font-mono text-xs",children:u.data.name}),u.data.description&&n.jsx("span",{className:"text-muted-foreground ml-2 text-xs",children:u.data.description})]})});case"feature":{const h=Or[u.data.icon];return n.jsx(me,{value:u.data.label,onSelect:()=>r(u.data.action),children:n.jsxs(X.div,{whileHover:{x:2},transition:{duration:.1,ease:pt},className:"flex w-full items-center gap-2",children:[h&&n.jsx(h,{className:"size-4"}),n.jsx("span",{children:u.data.label}),u.data.shortcut&&n.jsx("span",{className:"text-muted-foreground ml-auto text-xs",children:u.data.shortcut})]})})}case"page":return n.jsx(me,{value:u.data.id,onSelect:()=>m(u.data.href),children:n.jsxs(X.div,{whileHover:{x:2},transition:{duration:.1,ease:pt},className:"flex w-full items-center gap-2",children:[n.jsx(xs,{icon:u.data.icon,className:"size-4"}),n.jsx("span",{children:u.data.label})]})});case"quick-action":{const h=Or[u.data.icon];return n.jsx(me,{value:u.data.label,onSelect:()=>o(u.data.action),children:n.jsxs(X.div,{whileHover:{x:2},transition:{duration:.1,ease:pt},className:"flex w-full items-center gap-2",children:[h&&n.jsx(h,{className:"size-4"}),n.jsx("span",{children:u.data.label})]})})}}}function k0({term:e,isScoped:t=!1,onSelect:s}){return n.jsxs(me,{value:"search-messages-handoff",onSelect:s,className:"flex items-center gap-2 py-2",children:[n.jsx(fs,{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:wt?"⌘⇧F":"Ctrl⇧F"})]})}const qa=8;function S0({staggerKey:e,isZeroQuery:t,isRoomMode:s,scope:r,hasQuery:o,selectedCwd:a,selectedValue:i,continueRows:c,recent:d,newActions:m,bestMatch:u,rows:f,rooms:p,searchHandoff:h,onFeatureAction:g,onQuickAction:x,onGoToAgentActions:b,onRoomSelect:y,onSessionSelect:k,onCommandSelect:w,onPageSelect:I}){const v=s?p.isError?"Couldn’t load your channels.":p.isLoading?"Loading channels…":p.channels.length===0?"No channels yet.":null:null,S=QS(f,N=>r?Ma(r):b0[N.item.item.type]),R=r&&!o&&f.length===0&&!u?Rk(r):null,M=new Set(f.slice(0,u?qa-1:qa).map(N=>N.key)),E={selectedCwd:a,selectedValue:i,onFeatureAction:g,onQuickAction:x,onGoToAgentActions:b,onRoomSelect:y,onSessionSelect:k,onCommandSelect:w,onPageSelect:I};return n.jsxs(X.div,{variants:w0,initial:"hidden",animate:"visible",children:[t&&n.jsx(j0,{continueRows:c,recent:d,newActions:m,selectedCwd:a,selectedValue:i,onSessionSelect:k,onRoomSelect:y,onGoToAgentActions:b,onQuickAction:x}),!t&&u&&n.jsx(Le,{heading:y0,children:n.jsx(X.div,{variants:mn,children:n.jsx(Ga,{row:u,...E})})}),!t&&S.map((N,j)=>n.jsx(Le,{heading:N.label,children:N.rows.map(A=>n.jsx(X.div,{variants:M.has(A.key)?mn:void 0,children:n.jsx(Ga,{row:A,...E})},A.key))},`${N.label}-${j}`)),R&&n.jsx(Le,{heading:r?Ma(r):void 0,children:n.jsx(me,{disabled:!0,value:"scope-status",className:"text-muted-foreground text-sm",children:R})}),v&&n.jsx(Le,{heading:"Channels",children:n.jsx(me,{disabled:!0,value:"rooms-status",className:"text-muted-foreground text-sm",children:v})}),h&&n.jsx(Le,{children:n.jsx(k0,{term:h.term,isScoped:h.isScoped,onSelect:h.onSelect})}),t&&n.jsxs(n.Fragment,{children:[n.jsx(kl,{}),n.jsx(Bd,{})]})]},e)}function C0(e,t){const s=Mx(),{dismissedIds:r}=fl(),o=$(a=>a.promoEnabled);return l.useMemo(()=>o?_x(Px.filter(a=>a.placements.includes(e)),s,r,t):[],[e,t,s,r,o])}const N0={initial:{opacity:0,y:12},animate:{opacity:1,y:0},exit:{opacity:0,scale:.95,transition:{duration:.15}}};function A0({promo:e}){const{activate:t,dialog:s}=Lx(e),{dismissPromo:r}=fl(),o=Ue(),a=e.content.icon;return n.jsxs(X.div,{variants:o?void 0:N0,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(uc,{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(Oe,{className:"size-3.5"})}),s]})}const E0=1;function I0(e){const[t]=C0(e,E0);return l.useMemo(()=>t===void 0?{id:"promo",show:!1,render:()=>null}:{id:`promo:${t.id}`,show:!0,render:()=>n.jsx(A0,{promo:t})},[t])}const R0=new Set(["downloading","downloaded","install-failed"]);function Ya(e,t){return(e==null?void 0:e.state)==="install-failed"?t.state==="downloaded"&&xo(t.version,e.version)?t:e:R0.has(t.state)||t.state==="error"?t:e&&(e.state==="downloading"||e.state==="downloaded")?e:t}function T0(){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(m=>Ya(m,d))});return(c=a.getUpdateStatus)==null||c.call(a).then(d=>{d&&s(m=>Ya(m,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 D0={darwin:ur("/download/mac"),win32:ur("/download/windows")},O0=_i.site;function M0(){var t;const e=typeof window>"u"||(t=window.electronAPI)==null?void 0:t.platform;ct((e&&D0[e])??O0)}function _0(){const{data:e}=Ee(),{isDesktop:t,status:s,restart:r}=T0(),o=On(),a=e==null?void 0:e.version,i=(e==null?void 0:e.latestVersion)??null,c=l.useMemo(()=>(e==null?void 0:e.dismissedUpgradeVersions)??[],[e==null?void 0:e.dismissedUpgradeVersions]),d=l.useCallback(m=>{o.mutate({ui:{dismissedUpgradeVersions:[...c,m]}})},[c,o]);return l.useMemo(()=>t?(s==null?void 0:s.state)==="install-failed"?{kind:"desktop-install-failed",downloadFresh:M0}:(s==null?void 0:s.state)!=="downloaded"?{kind:"none"}:{kind:"desktop-restart",restart:r}:i!==null&&a!==void 0&&xo(i,a)&&!c.includes(i)?{kind:"command",latestVersion:i,dismiss:()=>d(i)}:{kind:"none"},[t,s,r,i,a,c,d])}const P0="npm update -g dorkos",L0="The update couldn’t install itself. Download a fresh copy. Your settings and agents stay put.",Xs="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 F0(e,t,s){return t?"Command copied":s?"Couldn’t copy":`Update ready: v${e}`}function $0({update:e}){const{copied:t,failed:s,copy:r}=Cn(),o=l.useCallback(()=>{r(P0)},[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:Xs,children:[n.jsx(Yx,{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:L0}),n.jsxs("button",{type:"button",onClick:e.downloadFresh,"aria-label":"Download a fresh copy of DorkOS",className:B(Xs,"self-start"),children:[n.jsx(jh,{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:Xs,children:[t?n.jsx(Nt,{className:"size-3"}):n.jsx(zr,{className:"size-3"}),F0(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(Oe,{className:"size-3"})})]})}function Wd({model:e}){const{shouldShowGettingStarted:t,dismiss:s}=It(),r=t&&!e.gettingStartedPending,o=_0(),a=$v({gettingStartedCardShown:r}),i=Wv({gettingStartedCardShown:r}),c=rd(),d=I0("dashboard-sidebar"),m=Tn(),u=[{id:"getting-started",show:r,render:()=>n.jsx(zv,{onDismiss:s})},{id:"update",show:o.kind!=="none",render:()=>n.jsx($0,{update:o})},{id:"identity-prompt",show:a.visible,render:()=>n.jsx(Gv,{prompt:a})},{id:"profile-prompt",show:i.visible,render:()=>n.jsx(Kv,{prompt:i})},{id:"official-space-offer",show:c.due&&!r,render:()=>n.jsx(al,{className:"bg-secondary/60 rounded-lg"})},{...d,show:d.show&&!c.pending}];return n.jsx(Ex,{candidates:u,ready:m.settled})}const Va="dorkos-pinned-agents";function Gd(){const{data:e}=Ee(),t=ao(),{update:s}=Vt(),r=t.pinned.length,o=l.useRef(!1);l.useEffect(()=>{if(o.current||e===void 0)return;const a=localStorage.getItem(Va);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(Va)},[e,r,s])}function qd(e){return l.useMemo(()=>kh(e),[e])}const B0=1800*1e3,rn={finishedWhileAwayCount:0,idleWhileAwayCount:0};function Qa(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 z0(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 U0(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 m=Date.parse(c.updatedAt);Number.isNaN(m)||m<=r||m>o||o-m<B0||(i+=1)}return i}function K0(e){const{now:t,sessions:s,workingSessionIds:r,sessionStatuses:o,interactions:a,storedLastShownDate:i,settled:c}=e,d=rx(),{update:m}=Vt(),[u,f]=l.useState(null),p=l.useRef(!1);l.useEffect(()=>{!c||p.current||(p.current=!0,f({value:i}))},[c,i]);const h=u==null?void 0:u.value,[g]=l.useState(()=>Qa(a)),x=Qa(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?rn:{finishedWhileAwayCount:z0(s,r,x,t),idleWhileAwayCount:U0(s,r,o,x,t)},[b,d.isAvailable,d.enabled,d.absenceThresholdMinutes,d.maxPosts,x,t,s,r,o]),k=Sh(t),w=u!==null&&y.finishedWhileAwayCount>0&&h!==k,I=l.useRef(!1);return l.useEffect(()=>{!w||I.current||(I.current=!0,m(v=>Ch(v,k)))},[w,k,m]),{digest:y,lastShownDate:h}}function H0(e,t){const{update:s}=Vt(),r=l.useMemo(()=>t?Nh(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,m)=>Ah(d,m),c))},[r,s])}const W0={discoveredUnregisteredPaths:[],nonSystemAgentCount:1,hasEverStartedSession:!0,hasPostedInTeam:!0,hasDorkBotSession:!0};function G0(e){const{agents:t,agentActivity:s,sessionCount:r,rooms:o,rosterResolved:a}=e,i=Wr(c=>c.candidates);return l.useMemo(()=>{if(!a)return{facts:W0,isResolved:!1};const c=new Set(t.map(f=>f.path)),d=i.map(f=>f.path).filter(f=>!c.has(f)),m=t.find(f=>f.isSystem)??null,u=o.find(f=>f.wellKnown===Eh);return{facts:{discoveredUnregisteredPaths:d,nonSystemAgentCount:t.filter(f=>!f.isSystem).length,hasEverStartedSession:r>0||Object.keys(s).length>0,hasPostedInTeam:(u==null?void 0:u.viewerHasPosted)??!0,hasDorkBotSession:m!==null&&s[m.path]!==void 0},isResolved:!0}},[t,s,r,o,a,i])}const q0=6e4,Y0=[],V0={};function Yd(e,t){const s=oc(e),r=s.read();return r!==e&&!t(r,e)?(s.write(e),e):r}function Q0(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 X0(e,t){return e.length===t.length&&t.every((s,r)=>e[r]===s)}function Wn(e){return Yd(e,Q0)}function J0(e){return Yd(e,X0)}function Z0(e,t){const s=ke({select:h=>h.location.pathname}),r=Oh(t,s),o=(r==null?void 0:r.extensionId)??null,a=(r==null?void 0:r.path)??null,i=$r({strict:!1}),c=s==="/session"?i.session??null:null,d=Mh(c),m=s==="/session"?(d==null?void 0:d.cwd)??i.dir??null:null,u=s==="/channels"?i.id??null:null,f=s==="/channels"||s==="/"?i.thread??null:null,p=u===null?null:e(u);return l.useMemo(()=>c!==null?{kind:"session",sessionId:c,agentPath:m??"",cwd:m}:o!==null&&a!==null?{kind:"add-on",extensionId:o,path:a}:u===null||p===null?null:f!==null?{kind:"room",roomId:u,roomKind:"thread",rootEntryId:f}:{kind:"room",roomId:u,roomKind:p},[c,m,o,a,u,p,f])}function Vd(e={}){const{coveredSignalIds:t}=e,s=oo(q0),r=Tn(),o=bc(Ih),a=l.useMemo(()=>{var U;return((U=o.data)==null?void 0:U.sessions)??[]},[o.data]),i=at(yc(U=>{const Y={};for(const[W,ge]of Object.entries(U.statuses))Y[W]=ge.lifecycle;return Y})),c=l.useMemo(()=>Object.entries(i).filter(([,U])=>U==="streaming").map(([U])=>U),[i]),d=at(l.useCallback(U=>U.statusCwds,[])),m=ws(),u=l.useMemo(()=>{const U=m.data??[];return r.fleetKnown?U:U.filter(Y=>Y.kind!=="dm")},[m.data,r.fleetKnown]),f=Rh(),p=l.useMemo(()=>f.data??[],[f.data]),h=to(),g=Wn(l.useMemo(()=>{const U={};for(const[Y,W]of Object.entries(h)){if(!Y.startsWith("agent:"))continue;const ge=Date.parse(W);Number.isNaN(ge)||(U[Y.slice(6)]=ge)}return U},[h])),b=js().data,y=J0(l.useMemo(()=>((b==null?void 0:b.agents)??[]).map(U=>U.projectPath),[b])),w=io(y).data,{brokenPaths:I}=ox(),v=Wn(Qx(y,I,g)),S=l.useMemo(()=>{var U;return((U=o.data)==null?void 0:U.agentActivity)??{}},[o.data]),R=r.fleetKnown?y:Y0,M=l.useMemo(()=>R.map(U=>{const Y=(w==null?void 0:w[U])??null,W=S[U],ge=W===void 0?NaN:Date.parse(W);return{path:U,runtime:(Y==null?void 0:Y.runtime)??"claude-code",namespace:(Y==null?void 0:Y.namespace)??null,isSystem:(Y==null?void 0:Y.isSystem)??!1,lastActivityAt:Number.isNaN(ge)?null:ge,lastInteractionAt:g[U]??null,attention:v[U]??"inactive"}}),[R,w,S,v,g]),E=l.useMemo(()=>Ic(R,w??{}),[R,w]),N=Wn(l.useMemo(()=>{const U={};for(const Y of a){const W=Y.userLastMessageAt;W!==void 0&&(U[`session:${Y.id}`]=W)}return U},[a])),j=Wn(l.useMemo(()=>{const U={};for(const Y of a){const W=Y.lastTouchedByYouAt;W!==void 0&&(U[`session:${Y.id}`]=W)}return U},[a])),A=ao(),C=l.useMemo(()=>Gy(A),[A]),D=K0({now:s,sessions:a,workingSessionIds:c,sessionStatuses:i,interactions:h,storedLastShownDate:C.digest.lastShownDate,settled:r.settled}),T=l.useMemo(()=>({...C,digest:{lastShownDate:D.lastShownDate}}),[C,D.lastShownDate]),_=l.useMemo(()=>Th(A.muted),[A.muted]),L=Kx({mutedRoomIds:_}),O=l.useMemo(()=>({items:L.items,automated:L.automated}),[L.items,L.automated]),K=l.useMemo(()=>{const U=new Map;for(const Y of u)U.set(Y.id,Y.kind==="dm"?"dm":"channel");return U},[u]),V=l.useMemo(()=>U=>K.get(U)??"channel",[K]),se=qr(),G=l.useMemo(()=>se.map(({id:U,extensionId:Y,path:W,title:ge})=>({id:U,extensionId:Y,path:W,title:ge})),[se]),Q=Z0(V,G),ne=Dh(U=>U.automatedExpanded),J=Rc(),ee=G0({agents:M,agentActivity:S,sessionCount:a.length,rooms:u,rosterResolved:r.phase!=="cold"}),H=l.useMemo(()=>({now:s,sessions:a,workingSessionIds:c,liveSessionCwds:d,sessionStatuses:i,rooms:u,threads:p,agents:M,displayNames:E,attention:J,recents:O,prefs:T,interactions:h,userLastMessageAt:N,lastTouchedByYouAt:j,mentions:V0,...t===void 0?{}:{coveredSignalIds:t},todayAutomatedExpanded:ne,addOns:G,activeTarget:Q,journey:ee.facts,digest:D.digest}),[t,s,a,c,d,i,u,p,M,E,J,O,T,h,N,j,ne,G,Q,ee.facts,D.digest]);return H0(H,ee.isResolved),H}const eC="Heads up and Today fill themselves. Pin it to Library to keep it in place.",tC="Add-ons lists extension pages only.";function Qd(e){return e==="addons"?tC:eC}const Xd={channels:"Channels",dms:"Direct messages",agents:"Agents"};function Xa(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 Xd}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 hn(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)&&Xa(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 Xa(s)?{type:"container",container:s}:null}return null}function Jd(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 Zd(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 eu(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 dn(e,t){return e.findIndex(s=>Tc(s,t))}function Ja(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=dn(o.items,r);i>=0&&(a=i)}return{kind:"move-to-group",ref:t,groupId:s,toIndex:a}}function Po(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(m=>m.id===t.groupId),d=e.groups.findIndex(m=>m.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}=eu(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=dn(e.pinned,r),d=dn(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 Ja(e,r,a.groupId,i);const c=e.groups.find(u=>u.id===o.groupId);if(!c||c.sortMode!=="manual"||i===void 0)return{kind:"none"};const d=dn(c.items,r),m=dn(c.items,i);return d<0||m<0||d===m?{kind:"none"}:{kind:"reorder-within-group",groupId:o.groupId,ref:r,from:d,to:m}}return a.kind==="pinned"?{kind:"pin",ref:r}:a.kind==="group"?Ja(e,r,a.groupId,i):{kind:"none"}}function sC(e,t){switch(t.kind){case"none":case"reject-smart-group":case"reject-computed-zone":return e;case"reorder-group":return Fh(e,t.from,t.to);case"pin":return Lh(e,t.ref);case"unpin":return Ph(e,t.ref);case"remove-from-group":return Ho(e,t.ref,null);case"reorder-within-group":return Wo(e,t.groupId,t.from,t.to);case"reorder-pinned":return _h(e,t.from,t.to);case"move-to-group":{const s=Ho(e,t.ref,t.groupId);if(t.toIndex===null)return s;const r=s.groups.find(o=>o.id===t.groupId);return r?Wo(s,t.groupId,r.items.length-1,t.toIndex):s}}}function rC(e,t,s){return sC(e,Po(e,t,s))}function oC(e,t){return e.type==="group"?`Picked up section ${t.groupName(e.groupId)}.`:`Picked up ${t.itemName(e.ref)}.`}function aC(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. ${Qd(e.zone)}`;case"none":return""}}function iC(e,t){if(e===null)return"";const{container:s}=eu(e);switch(s.kind){case"pinned":return"Over Pinned.";case"ungrouped":return`Over ${s.section===void 0?"Agents":Xd[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 cC(e){const t=r=>Jd(hn(r.active.data.current)),s=r=>{var o;return Zd(hn((o=r.over)==null?void 0:o.data.current))};return{onDragStart:r=>{const o=t(r);return o?oC(o,e()):void 0},onDragOver:r=>{if(t(r))return iC(s(r),e())||void 0},onDragEnd:r=>{const o=t(r);if(!o)return;const a=e(),i=Po(a.prefs,o,s(r));return i.kind==="none"?"Movement cancelled. Item returned to its place.":aC(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 lC({label:e}){const t=Ue();return n.jsx(X.div,{initial:{scale:1},animate:{scale:t===!0?1:Bh},transition:{duration:t===!0?0:$h},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 dC=60;function uC(e){const t=document.querySelectorAll(`[${Go}]`);for(const s of t)if(s.getAttribute(Go)===e)return s.querySelector(`[${zh}]`);return null}function mC(e,t=dC){let s=t;const r=()=>{const o=uC(e);if(o!==null){o.focus();return}s-- >0&&requestAnimationFrame(r)};requestAnimationFrame(r)}const hC={start:["Space"],cancel:["Escape"],end:["Space","Enter","Tab"]};function fC(e,t){switch(t.kind){case"move-to-group":return _s(t.groupId,t.ref);case"remove-from-group":return _s("ungrouped",t.ref);case"unpin":{const s=e.groups.find(r=>r.items.some(o=>Tc(o,t.ref)));return _s((s==null?void 0:s.id)??"ungrouped",t.ref)}default:return null}}function pC({data:e,itemName:t,groupName:s}){const r=e.type==="group"?s(e.groupId):e.type==="item"?t(e.ref):"";return n.jsx(lC,{label:r})}function gC({children:e,displayNames:t,rooms:s}){const r=je(),o=ao(),{update:a}=Vt(),[i,c]=l.useState(null),d=Pt(o),m=Pt(t),u=l.useMemo(()=>Object.fromEntries(s.map(k=>[k.id,k.slug??k.title])),[s]),f=Pt(u),p=ac(ns(lc,{activationConstraint:{distance:8}}),ns(cc,{coordinateGetter:dr,keyboardCodes:hC}));if(r)return n.jsx(n.Fragment,{children:e});const h=k=>{var w;return((w=d.read().groups.find(I=>I.id===k))==null?void 0:w.name)??"group"},g=k=>k.kind==="agent"?m.read()[k.path]??k.path.split("/").pop()??"Agent":f.read()[k.roomId]??"room",x=cC(()=>({prefs:d.read(),itemName:g,groupName:h})),b=k=>{c(hn(k.active.data.current))},y=k=>{var R;c(null);const w=Jd(hn(k.active.data.current));if(w===null)return;const I=Zd(hn((R=k.over)==null?void 0:R.data.current)),v=Po(d.read(),w,I);if(v.kind==="reject-smart-group"){ae.info("Membership is rule-based. Edit rules instead.",{description:h(v.groupId)});return}if(v.kind==="reject-computed-zone"){ae.info(Qd(v.zone),{description:g(v.ref)});return}if(v.kind==="none"||(a(M=>rC(M,w,I)),!(k.activatorEvent instanceof KeyboardEvent)))return;const S=fC(d.read(),v);S!==null&&mC(S)};return n.jsx(Uh,{value:!0,children:n.jsxs(ic,{sensors:p,collisionDetection:rc,accessibility:{announcements:x},onDragStart:b,onDragEnd:y,onDragCancel:()=>c(null),children:[e,n.jsx(Kh,{children:i?n.jsx(pC,{data:i,itemName:g,groupName:h}):null})]})})}function xC(){var r;const e=Ss(!0),t=ys();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(P,{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(bC,{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 bC({connection:e}){var o,a,i;const t=Hh(e.access),s=Wh(e.ref,t.capabilities.read,t.fingerprint),r=ys();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(P,{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(Gh,{...he.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 yC=[2,3,3],Za=["w-14","w-10","w-16"];function vC(){return n.jsx("div",{className:"flex flex-col gap-1","data-testid":"sidebar-skeleton","aria-hidden":!0,children:yC.map((e,t)=>n.jsxs("div",{className:"flex flex-col",children:[n.jsx("div",{className:B("flex h-7 items-center",qh),children:n.jsx(xt,{className:B("h-2.5 rounded-sm",Za[t])})}),Array.from({length:e},(s,r)=>n.jsx(Yh,{showIcon:!0},r))]},Za[t]))})}const wC=.16,jC=4,kC=.03,SC={hidden:{},shown:{transition:{staggerChildren:kC}}},CC={hidden:{opacity:0,y:jC},shown:{opacity:1,y:0}};function ei(e){return{duration:e===!0?0:wC}}const NC=2500;function ti(e){var t;return((t=e.zones.find(s=>s.id==="now"))==null?void 0:t.needsYouCount)??0}function AC(e){const t=Ue(),[s,r]=l.useState(!1),o=l.useRef(ti(e)),a=ti(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 m=setTimeout(()=>r(!1),NC);return()=>clearTimeout(m)},[a,i,t]),s}function tu(){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 ni=5e3;function EC(e){const{inside:t,handlers:s}=tu(),r=e.zones.some(m=>m.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 m=i.current===null?Number.POSITIVE_INFINITY:Date.now()-i.current;if(m>=ni){c.current=!1,a(!0);return}const u=setTimeout(()=>{c.current=!1,a(!0)},ni-m);return()=>clearTimeout(u)},[r,o,t]),{model:l.useMemo(()=>!r||o?e:{...e,zones:e.zones.filter(m=>m.id!=="getting-started")},[e,r,o]),handlers:s}}const IC=1e3;function nu(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)},IC);return()=>clearTimeout(a)},[e]),t}function RC(){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(Nt,{className:"text-status-success size-3.5 shrink-0","aria-hidden":!0}),"All clear"]})}const TC=1,si=40;function DC({onCommit:e,onCancel:t}){const[s,r]=l.useState(""),o=l.useRef(null),a=l.useRef(!1),i=Vh(o);l.useEffect(()=>{var m;(m=o.current)==null||m.focus()},[]);const c=()=>{if(a.current)return;a.current=!0;const m=s.trim();if(m.length<TC||m.length>si){t();return}e(m)},d=m=>{m.key==="Enter"?(m.preventDefault(),c()):m.key==="Escape"&&(m.preventDefault(),a.current=!0,t())};return n.jsx(Qh,{children:n.jsxs("div",{className:"flex w-full items-center gap-2 rounded-md px-2 py-1.5",children:[n.jsx(Xh,{className:"text-muted-foreground size-3.5 shrink-0"}),n.jsx("input",{ref:o,value:s,maxLength:si,placeholder:"Section name","aria-label":"New section name",onChange:m=>r(m.target.value),onKeyDown:d,onBlur:m=>{i.shouldHandleBlur(m)&&(a.current||t())},className:B("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 Zn({zone:e,onToggleAll:t,allClear:s=!1,lead:r,silenceLiveRegion:o=!1}){const a=nu(e.liveRegionText);return n.jsxs("section",{"aria-label":e.label,"data-sidebar-zone":e.id,className:B("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(RC,{}):n.jsxs(n.Fragment,{children:[e.id==="library"&&e.sections.length>0&&n.jsx(OC,{}),e.sections.map(i=>n.jsx(Dc,{section:i,onToggleAll:t},i.id))]})]})}function OC(){const e=Jh();return e.groupCreation===null?null:n.jsx(Zh,{children:n.jsx(DC,{onCommit:e.commitNewGroup,onCancel:e.cancelNewGroup})})}const MC='[aria-current="page"]';function _C(e,t,s){const r=Ue(),o=l.useRef(null);l.useLayoutEffect(()=>{var m,u;if(!s)return;const a=o.current===null,i=((m=o.current)==null?void 0:m.key)??null;if(o.current={key:t},!a&&(i===t||t===null)||t===null)return;const c=(u=e.current)==null?void 0:u.querySelector(MC);if(!(c instanceof HTMLElement))return;const d=!a&&r!==!0;c.scrollIntoView({block:"nearest",behavior:d?"smooth":"auto"})},[t,e,s])}function PC(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 LC(e,t){const{inside:s,handlers:r}=tu(),[o,a]=l.useState(null),[i,c]=l.useState(s);i!==s&&(c(s),a(s?e.map(f=>f.key):null));const[d,m]=l.useState(t);return d!==t&&(m(t),a(s?e.map(f=>f.key):null)),{rows:o===null?[...e]:PC(e,o),handlers:r}}const FC="anchor:active-session";function $C({zone:e,onToggleAll:t,silenceLiveRegion:s=!1}){var f;const r=l.useRef(null),o=e.sections.find(p=>p.id==="today"),a=l.useMemo(()=>(o==null?void 0:o.rows)??[],[o]),i=((f=a.find(p=>p.reason===FC))==null?void 0:f.key)??null,c=LC(a,i),d=Tn();_C(r,i,d.settled);const m=l.useMemo(()=>BC(a),[a]),u=l.useMemo(()=>({...e,sections:e.sections.map(p=>p.id==="today"?{...p,rows:c.rows}:p)}),[e,c.rows]);return n.jsx("div",{ref:r,...c.handlers,children:n.jsx(Zn,{zone:u,onToggleAll:t,silenceLiveRegion:s,lead:n.jsx(zC,{roomIds:m})})})}function BC(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 zC({roomIds:e}){const t=je(),s=ef();return!t||e.length===0?null:n.jsx(UC,{count:e.length,onCatchUp:()=>s(e)})}function UC({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:B("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",nf,Dn),children:[n.jsx(tf,{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 ri={id:"now",label:of.now,sections:[],reason:"zone:now"};function KC(e){return e.collapsible?e.id.startsWith("group:")||Mc(e.id)!==null:!1}function Mr({model:e,zoneIds:t,nowSlot:s=null,silenceLiveRegion:r=!1}){var M;const{update:o}=Vt(),a=sf(),i=rs(a.destination),d=Oc(i??void 0).visible?i:null,m=Tn(),u=Ue(),{model:f,handlers:p}=EC(e),h=e.zones.flatMap(E=>E.sections).filter(KC),g=l.useCallback(E=>t===void 0||t.includes(E),[t]),x=l.useCallback(()=>{if(h.length===0)return;const E=h.some(N=>!N.collapsed);o(N=>{let j=N;for(const A of h){if(A.id.startsWith("group:")){j=rf(j,A.id.slice(6),E);continue}const C=Mc(A.id);C!==null&&(j=qo(j,C,E))}return j})},[h,o]),b=g("library")?(M=e.zones.find(E=>E.id==="library"))==null?void 0:M.sections.find(E=>E.id==="addons"):void 0,y=(b==null?void 0:b.collapsed)??!1,k=l.useCallback(()=>o(E=>qo(E,"addons",!y)),[y,o]),w=AC(e),I=e.zones.some(E=>E.id==="now"),v=I||e.zones.some(E=>E.id==="getting-started"),S=s!==null&&!I&&g("now"),R={variants:CC,transition:ei(u)};return d?n.jsxs("div",{className:"flex min-h-0 flex-col","data-community-context":d,children:[n.jsx(xC,{}),b!==void 0&&n.jsx(Dc,{section:b,onToggleAll:k})]}):n.jsx("div",{className:"flex flex-col gap-1",...p,children:n.jsx(Fe,{mode:"wait",initial:!1,children:m.phase==="cold"?n.jsx(X.div,{exit:{opacity:0},transition:ei(u),children:n.jsx(vC,{})},"skeleton"):n.jsxs(X.div,{className:"flex flex-col gap-1",variants:SC,initial:m.startedWarm?!1:"hidden",animate:"shown",children:[S&&n.jsx(X.div,{...R,children:n.jsx(Zn,{zone:ri,onToggleAll:x,lead:s,silenceLiveRegion:r})}),w&&!v&&!S&&g("now")&&n.jsx(X.div,{...R,children:n.jsx(Zn,{zone:ri,onToggleAll:x,allClear:!0,silenceLiveRegion:r})}),f.zones.filter(E=>g(E.id)).map(E=>n.jsx(X.div,{...R,children:E.id==="today"?n.jsx($C,{zone:E,onToggleAll:x,silenceLiveRegion:r}):n.jsx(Zn,{zone:E,onToggleAll:x,silenceLiveRegion:r,...E.id==="now"?{lead:s}:{}})},E.id))]},"zones")})})}function HC(){Gd();const e=Vd(),t=qd(e),s=Tn();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(_c,{activeTarget:e.activeTarget,children:n.jsx(gC,{displayNames:e.displayNames,rooms:e.rooms,children:n.jsx(Mr,{model:t})})})}),n.jsx(Wd,{model:t})]})}const WC=2;function GC(){return{label:"Active now",rules:{statuses:["needs-attention","active"]}}}function qC(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>=WC).map(([s,r])=>({runtime:s,count:r,label:We(s).label})).sort((s,r)=>r.count-s.count||s.label.localeCompare(r.label)).map(({runtime:s,label:r})=>({label:`Runs on ${r}`,rules:{runtimes:[s]}}))}const oi="agent:";function YC(){const[e]=Rn(),t=to(),{data:s}=js(),r=l.useMemo(()=>((s==null?void 0:s.agents)??[]).map(i=>i.projectPath),[s]),{data:o}=io(r),a=l.useMemo(()=>Ic(r,o??{}),[r,o]);return l.useMemo(()=>{const i=new Set(r);let c=null,d=-1/0;for(const[u,f]of Object.entries(t)){if(!u.startsWith(oi))continue;const p=u.slice(oi.length);if(!i.has(p))continue;const h=Date.parse(f);Number.isNaN(h)||h<=d||(d=h,c=p)}const m=e!==null&&i.has(e)?e:c;return m===null?null:{path:m,displayName:a[m]??m}},[a,t,r,e])}function VC(e){l.useEffect(()=>{if(!De())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 QC(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:en,opensInput:!1,run:()=>e.onCreatePresetSmartGroup(r)})),{kind:"action",id:"new-group-custom",label:"Custom rules",icon:en,opensInput:!0,run:e.onOpenSmartGroupDialog}],s=[t.length===0?{kind:"action",id:"new-group",label:"Section",icon:en,opensInput:!0,run:e.onNewGroup}:{kind:"submenu",id:"new-group",label:"Section",icon:en,items:[{kind:"action",id:"new-group-empty",label:"Empty section",icon:en,opensInput:!0,run:e.onNewGroup},...t]}];return[{kind:"action",id:"new-session",label:"Chat",icon:Ac,opensInput:!1,...e.showSessionShortcut?{hint:Ft(bn.NEW_SESSION)}:{},run:e.onNewSession},...e.lastUsedAgentName===null?[]:[{kind:"note",id:"new-session-note",icon:rb,text:`Starts with ${e.lastUsedAgentName} (last used)`}],{kind:"separator",id:"sep-rooms"},{kind:"action",id:"new-channel",label:"Channel",icon:co,opensInput:!0,run:e.onNewChannel},{kind:"action",id:"new-message",label:"Group message",icon:xl,opensInput:!0,run:e.onNewMessage},{kind:"separator",id:"sep-agents"},{kind:"action",id:"new-agent",label:"Agent",icon:mf,opensInput:!0,run:e.onNewAgent},...s]}function XC(){const e=je(),t=zn(_=>_.menuOpen),s=zn(_=>_.preselect),r=zn(_=>_.setMenuOpen),o=zn(_=>_.requestNewGroup),a=Ae(),i=jc(),[,c]=Rn(),d=Zx(),m=YC(),{update:u}=Vt(),[f,p]=l.useState(!1),[h,g]=l.useState(!1),[x,b]=l.useState(!1),{data:y}=js(),k=l.useMemo(()=>((y==null?void 0:y.agents)??[]).map(_=>_.projectPath),[y]),{data:w}=io(k),I=l.useMemo(()=>k.map(_=>{var L,O;return{projectPath:_,runtime:((L=w==null?void 0:w[_])==null?void 0:L.runtime)??"claude-code",namespace:((O=w==null?void 0:w[_])==null?void 0:O.namespace)??null,attention:"inactive",lastActivityAt:null}}),[k,w]),v=cf(I),S=l.useMemo(()=>v?[GC(),...qC(I)]:[],[I,v]),R=l.useMemo(()=>{const _=new Map;for(const L of I)_.has(L.runtime)||_.set(L.runtime,We(L.runtime).label);return Array.from(_,([L,O])=>({value:L,label:O})).sort((L,O)=>L.label.localeCompare(O.label))},[I]),M=l.useMemo(()=>{const _=new Set;for(const L of I)L.namespace&&_.add(L.namespace);return Array.from(_).sort()},[I]),E=l.useCallback((_,L)=>u(O=>lf(O,_,L).next),[u]),N=l.useCallback(_=>{ss.getState().recordOpened("room",_.id),a({...he.channels(),search:{id:_.id}})},[a]),j=l.useCallback(()=>i(m==null?void 0:m.path),[m,i]);VC(j);const A=l.useCallback(_=>{const[L]=_;if(L!==void 0&&eb(_)){c(L.agentPath,{onOpened:()=>ss.getState().recordOpened("agent",L.agentPath)});return}const O=df(_.map(K=>K.displayName));d.mutate({agentPaths:_.map(K=>K.agentPath),title:O},{onSuccess:N})},[N,c,d]),C=QC({onNewSession:j,lastUsedAgentName:(m==null?void 0:m.displayName)??null,onNewChannel:()=>p(!0),onNewMessage:()=>g(!0),onNewAgent:()=>ps.getState().open(),onNewGroup:()=>o(),smartGroupPresets:S,onCreatePresetSmartGroup:_=>E(_.label,_.rules),onOpenSmartGroupDialog:()=>b(!0),showSessionShortcut:De()}),D=Pc(C),T=l.useRef(null);return l.useEffect(()=>{if(!t||s===null)return;const _=requestAnimationFrame(()=>{var L,O;(O=(L=T.current)==null?void 0:L.querySelector(`[data-menu-item-id="${s}"]`))==null||O.focus()});return()=>cancelAnimationFrame(_)},[t,s]),n.jsxs(n.Fragment,{children:[n.jsxs(Yr,{open:t,onOpenChange:r,children:[n.jsx(Vr,{asChild:!0,children:n.jsxs("button",{type:"button","data-testid":"sidebar-new-button",className:B("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&&B(Dn,"px-3")),children:[n.jsx(Et,{className:"size-3.5"}),"New"]})}),n.jsx(Qr,{ref:T,align:"end",className:"w-56",onCloseAutoFocus:D.onCloseAutoFocus,children:n.jsx(mr,{variant:"dropdown",nodes:D.nodes})})]}),f&&n.jsx(tb,{open:!0,onOpenChange:_=>!_&&p(!1),onCreated:N}),n.jsx(nb,{open:h,onOpenChange:g,onStart:A,hideTrigger:!0}),n.jsx(uf,{open:x,onOpenChange:b,mode:"create",runtimeOptions:R,namespaceOptions:M,onSubmit:({name:_,rules:L})=>E(_,L)})]})}function JC(){const e=$(s=>s.setGlobalPaletteOpen),t=je();return n.jsxs("button",{type:"button","data-testid":"sidebar-search-pill",onClick:()=>e(!0),className:B("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&&Dn),children:[n.jsx(ts,{className:"size-(--size-icon-sm) shrink-0"}),n.jsx("span",{className:"truncate",children:"Jump to anything…"}),n.jsx(Lc,{className:"bg-sidebar-accent text-sidebar-foreground/70 ml-auto shrink-0 border-transparent",children:Ft(bn.COMMAND_PALETTE)})]})}function ZC(e){const t=[];return e.you!==null&&t.push({kind:"action",id:"you",label:e.you.name,description:"View profile",icon:Hr,leading:e.you.face,guardsFocus:!0,run:e.you.onOpen}),t.push({kind:"action",id:"dorkos-account",label:"DorkOS account",description:e.accountStatus,icon:yl,guardsFocus:!0,run:e.onOpenAccount},{kind:"action",id:"settings",label:"Settings",icon:ks,guardsFocus:!0,run:e.onOpenSettings}),t}function eN(e){return e.isDevMode?[{kind:"separator",id:"sep-version"},{kind:"note",id:"version",icon:Yo,text:"Development build"}]:e.version===null?[]:[{kind:"separator",id:"sep-version"},{kind:"action",id:"version",label:`v${e.version} beta`,icon:Yo,opensInput:!1,hint:"Check for updates",run:e.onCheckForUpdates}]}function tN(e){const t=(e==null?void 0:e.trim())??"";return t.length===0||t===hf?"Your team":t.endsWith("s")?`${t}’ team`:`${t}’s team`}function nN(e,t){const s=ff(e);return l.createElement(pf,{size:t,kind:s.kind,color:s.color,emoji:s.emoji,imageUrl:s.imageUrl,fallback:s.fallback,origin:s.origin})}function su(e="xs"){var i;const t=Ur(),{open:s}=Ke(),{open:r}=lo(),o=Ek(),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:Ak(o),onOpenAccount:()=>s("account"),onOpenSettings:()=>s()}}function sN(e=[]){var m;const t=Ur(),s=oe(),r=ie(),o=su(),a=((m=t.data)==null?void 0:m.members.find(u=>u.isSelf))??null,{data:i,refetch:c}=ye({queryKey:Ne.current(),queryFn:()=>s.getConfig(),staleTime:Ui}),d=l.useCallback(async()=>{var h,g;await r.invalidateQueries({queryKey:Ne.all});const u=await c(),f=(h=u.data)==null?void 0:h.version,p=((g=u.data)==null?void 0:g.latestVersion)??null;if(f===void 0){ae.error("Couldn’t check for updates");return}if(p!==null&&xo(p,f)){ae.success(`Version ${p} is available`);return}ae.success("You’re up to date")},[r,c]);return{teamName:tN((a==null?void 0:a.displayName)??null),nameUnknown:t.isPending,identityNodes:ZC(o),nodes:[...e,...eN({version:(i==null?void 0:i.version)??null,isDevMode:(i==null?void 0:i.isDevMode)??!1,onCheckForUpdates:()=>void d()})]}}const rN=Fc("/self-hosting/space-server");function oN(e){const t=[];for(const s of e)s.hostOperator===!0&&!t.includes(s.pinnedOrigin)&&t.push(s.pinnedOrigin);return t}function aN(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 Gn(e){try{return new URL(e).host}catch{return e}}function iN(e){const t=[],s=e.selected;if(s){const{connection:i,availability:c}=s,d=[],m={host:Gn(i.pinnedOrigin)};c.canInvite&&d.push({kind:"action",id:"community-invite",label:"Invite people",icon:xf,external:m,run:e.onInvite}),c.canOpenSettings&&d.push({kind:"action",id:"community-settings",label:"Space settings",icon:ks,external:m,run:e.onOpenSettings}),s.canMoveUp&&d.push({kind:"action",id:"community-move-up",label:"Move up",icon:bf,run:()=>e.onMove("up")}),s.canMoveDown&&d.push({kind:"action",id:"community-move-down",label:"Move down",icon:yf,run:()=>e.onMove("down")}),d.push({kind:"separator",id:"community-sep-end"}),d.push({kind:"action",id:"community-disconnect",label:"Disconnect",icon:lb,opensInput:!0,destructive:!0,run:e.onDisconnect}),c.canLeave&&d.push({kind:"action",id:"community-leave",label:"Leave space",icon:vf,opensInput:!0,external:m,run:e.onLeave}),t.push({kind:"submenu",id:"community-actions",label:`Manage ${i.label}`,icon:gr,items:d})}e.onJoinOfficial&&t.push({kind:"action",id:"join-official-space",label:"Join the DorkOS community",icon:hr,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-${Gn(i)}`,label:e.creationOrigins.length===1?"Create a space on your server":`Create a space on ${Gn(i)}`,icon:ay,opensInput:!0,external:{host:Gn(i)},run:()=>e.onCreate(i)})),{kind:"action",id:"add-community-deploy",label:"Run your own space server",icon:gf,run:e.onDeploy}],a=[];return e.hosting&&a.push({kind:"action",id:"add-community-start",label:"Start a space",icon:uo,opensInput:!0,run:e.hosting.onStart}),a.push({kind:"action",id:"add-community-join",label:"Join a space",icon:hr,opensInput:!0,run:r}),e.hosting&&a.push({kind:"action",id:"add-community-yours",label:"Your spaces",icon:sy,guardsFocus:!0,run:e.hosting.onOpenYourSpaces}),a.push({kind:"separator",id:"add-community-sep-advanced"},{kind:"submenu",id:"add-community-advanced",label:"Advanced",icon:bl,items:o}),t.push({kind:"submenu",id:"add-community",label:"Add a space",icon:Et,items:a}),t}function ru(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 cN(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=ru(e);if(s.membershipState!=="active")return s.membershipState.replace("-"," ");if(s.availability!=="online")return s.availability}function lN(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 dN(e){return e.charAt(0).toLowerCase()+e.slice(1)}function uN(e,t){const s=wf(),r=Oc(e),o=ol();return{spaces:s.enabled,anySpace:s.anySpace,selectedRef:r.visible?e:void 0,visible:(t??[]).filter(a=>jf(a,s.enabled)),joinOfficial:o.link!==null&&!o.joined?o.join:null}}function mN(e){const t=Vo(r=>r.url),s=Vo(r=>r.take);l.useEffect(()=>{if(t===null)return;const r=s();r!==null&&e(r)},[t,s])}function hN({connection:e,onOpenChange:t,onDisconnected:s}){var p;const r=$c(),o=Vl(e),[a,i]=l.useState(e);e!==null&&e!==a&&i(e);const c=(a==null?void 0:a.label)??"this space",d=(a==null?void 0:a.status)==="pending"?[]:(p=o.data)==null?void 0:p.agents,m=d===void 0&&o.fetchStatus==="fetching",u=d?Xl(c,d):m?null:Jl(c);function f(){e&&r.mutate(e,{onSuccess:h=>{t(!1);const g=Zl(e.label,h);g.tone==="success"?ae.success(g.message):ae.warning(g.message,{duration:15e3}),s(e)}})}return n.jsx(kf,{open:e!==null,onOpenChange:h=>{h||r.reset(),t(h)},children:n.jsxs(Sf,{children:[n.jsxs(Cf,{children:[n.jsxs(Nf,{children:["Disconnect this DorkOS from ",c,"?"]}),n.jsx(Af,{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."}),u&&n.jsx("p",{className:"text-foreground",children:u}),m&&n.jsx("p",{children:"Checking for agents you added from here…"})]})})]}),o.isError&&d===void 0&&!m&&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(P,{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(Ef,{children:[n.jsx(If,{disabled:r.isPending,children:"Keep connected"}),n.jsx(P,{variant:"destructive",disabled:r.isPending||m,onClick:f,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 ${gN(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 ${Rf((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 pN(e){const t=typeof e=="object"&&e!==null?e.code:"";return t!=="COMMUNITY_RATE_LIMITED"&&t!=="COMMUNITY_UPGRADE_REQUIRED"}function gN(e){try{return`${new URL(e??"").origin}/your-space`}catch{return"https://example.com/acme"}}const xN="That invitation link is incomplete or isn’t secure. Copy the whole link again.";function bN(e){let t;try{t=new URL(e.trim())}catch{return!1}return/^\/(?:c\/[^/]+\/)?join\/?$/u.test(t.pathname)&&!fr(e)}function yN(e){const t=new URL(e.trim()),s=/^(\/c\/[^/]+)\/join\/?$/u.exec(t.pathname);return s?`${t.origin}${s[1]}`:t.origin}function vN({request:e,onOpenChange:t,installName:s,onConnected:r}){var L;const o=Sn(!0),a=Ss(!0),i=Tf(o),c=e!==null,d=Ps(O=>O.links),m=Ps(O=>O.rememberLink),u=Ps(O=>O.ending),f=(o==null?void 0:o.ownerKey)??null,[p,h]=l.useState(null),g=O=>h(O===null?null:{owner:f,ref:O}),[x,b]=l.useState(null),[y,k]=l.useState(null),[w,I]=l.useState((u==null?void 0:u.id)??0),[v,S]=l.useState(null),[R,M]=l.useState(null);e!==R&&(M(e),e&&(g(e.ref),b(null))),p!==null&&f!==null&&p.owner!==f&&(p.owner===null?h({owner:f,ref:p.ref}):(h(null),b(null),S(null)));const E=p!==null&&p.owner===f?p.ref:null,N=E===null||(L=a.data)==null?void 0:L.find(O=>O.ref===E),j=!N&&y!==null&&!y.settled&&y.address===i&&y.connection.ref===E?y.connection:null,A=N??j;if(A&&f!==null&&((v==null?void 0:v.owner)!==f||v.ref!==A.ref||v.label!==A.label)&&S({owner:f,ref:A.ref,label:A.label}),u&&u.id!==w)I(u.id),u.ref===E&&u.outcome!=="connected"&&(g(null),b({address:i,value:u.outcome==="expired"?`Approval for ${u.label} expired. Connect again to continue.`:`Approval for ${u.label} was cancelled.`}));else if(c&&E!==null&&!A&&a.isSuccess){const O=(v==null?void 0:v.owner)===f&&v.ref===E?v.label:"this space";g(null),b({address:i,value:`Approval for ${O} ended somewhere else. Connect again to continue.`})}Df(c&&(A==null?void 0:A.status)==="pending"?A.ref:null);const C=Of((A==null?void 0:A.status)==="pending"?A:null),D=c&&(A==null?void 0:A.status)==="connected"?A.ref:null,T=l.useRef(r),_=l.useRef(t);return l.useEffect(()=>{T.current=r,_.current=t}),l.useEffect(()=>{D===null||!A||(ae.success(`${A.label} is connected.`,{id:`community-approval-${D}`}),_.current(!1),T.current(D))},[D]),n.jsx(et,{open:c,onOpenChange:t,children:n.jsx(tt,{className:"!min-h-0 sm:max-w-md",children:n.jsx(wN,{authority:o,connection:A,check:C,approvalUrl:A&&(d==null?void 0:d.address)===i?d.urls[A.ref]:void 0,notice:(x==null?void 0:x.address)===i?x.value:"",installName:s,initialUrl:R==null?void 0:R.url,onStarted:O=>{m(i,O.connection.ref,O.approvalUrl),k({address:i,connection:O.connection,settled:!1}),g(O.connection.ref),b({address:i,value:`Next, approve this DorkOS on ${O.connection.label}.`})},onStartSettled:O=>k(K=>(K==null?void 0:K.connection.ref)===O?{...K,settled:!0}:K),onEnded:O=>{g(null),b({address:i,value:O})},onCancelled:O=>{t(!1),ae.success(`Approval for ${O} 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:m,onCancelled:u,onClose:f}){const p=oe(),h=ie(),g=hc(),x=l.useId(),[b,y]=l.useState(i??""),[k,w]=l.useState(null),[I,v]=l.useState(!1),[S,R]=l.useState(a),M=l.useRef(null),E=l.useRef(null),N=t===null?"form":t.status,j=l.useRef(N);l.useEffect(()=>{var Q,ne;const G=j.current;j.current=N,G!==N&&(N==="form"?(Q=M.current)==null||Q.focus():N==="pending"&&((ne=E.current)==null||ne.focus()))},[N]);const A=Ct({mutationFn:async G=>{if(!e||!ft(e))throw new Error("Community owner is still loading.");const Q=await p.startCommunityConnection({url:G,installName:S.trim()});if(!ft(e))throw new Error("Community owner changed.");return Q},onSuccess:async G=>{y(""),c(G),e&&await h.invalidateQueries({queryKey:ot.connections(e)}),d(G.connection.ref)}}),C=$c(),D=Vl((t==null?void 0:t.status)==="reconnect-required"?t:null),T=A.error;l.useEffect(()=>{var G;(T||I)&&((G=M.current)==null||G.focus())},[T,I]);const _=fr(b),L=I?xN:A.error?fN(A.error,A.variables):null;function O(G){if(G.preventDefault(),!(!b.trim()||A.isPending)){if(bN(b)){A.reset(),v(!0);return}if(fr(b)){if(!ct(g.linkFor(b.trim())))return;y(yN(b)),w({host:new URL(b.trim()).host,withAccount:g.signsInWithAccount(b)}),A.reset();return}S.trim()&&A.mutate(b.trim())}}function K(G){C.mutate(G,{onSuccess:Q=>{if(G.status==="pending")u(G.label);else{const ne=Zl(G.label,Q);m(ne.tone==="success"?`${G.label} is disconnected. Connect again to continue.`:ne.message)}},onSettled:()=>{e&&h.invalidateQueries({queryKey:ot.connections(e)})}})}const V=n.jsx("p",{role:"status","aria-live":"polite",className:o?"text-muted-foreground text-sm":"sr-only",children:o});if(t===null)return n.jsxs("form",{onSubmit:O,children:[n.jsxs(Qe,{children:[n.jsx($e,{children:"Join a space"}),n.jsx(Xe,{children:"Bring a space’s channels here. You approve it on the space’s site."})]}),n.jsxs(it,{className:"space-y-4 py-4",children:[V,n.jsxs("div",{className:"space-y-1.5",children:[n.jsx(Te,{htmlFor:`${x}-url`,children:"Space address or invitation link"}),n.jsx(Ze,{ref:M,id:`${x}-url`,type:"url",inputMode:"url",placeholder:"https://example.com/acme","aria-describedby":L?`${x}-url-hint ${x}-url-error`:`${x}-url-hint`,"aria-invalid":I||A.error&&pN(A.error)?!0:void 0,required:!0,autoComplete:"off",value:b,onChange:G=>{y(G.target.value),w(null),v(!1)},disabled:A.isPending||!e}),n.jsx("p",{id:`${x}-url-hint`,"aria-live":"polite",className:"text-muted-foreground text-xs",children:k?k.withAccount?`Join on ${k.host} with your DorkOS account in the new tab, then connect.`:`Finish joining on ${k.host} in the new tab, then connect.`:"Its link, short address or an invitation link."})]}),n.jsxs("div",{className:"space-y-1.5",children:[n.jsx(Te,{htmlFor:`${x}-name`,children:"Name for this installation"}),n.jsx(Ze,{id:`${x}-name`,required:!0,maxLength:120,"aria-describedby":`${x}-name-hint`,value:S,onChange:G=>R(G.target.value),disabled:A.isPending||!e}),n.jsx("p",{id:`${x}-name-hint`,className:"text-muted-foreground text-xs",children:"What the space calls this DorkOS."})]}),L&&n.jsx("p",{id:`${x}-url-error`,role:"alert",className:"text-destructive text-sm",children:L})]}),n.jsxs(_t,{children:[n.jsx(P,{type:"button",variant:"outline",onClick:f,children:"Cancel"}),n.jsx(P,{type:"submit",disabled:A.isPending||!b.trim()||!_&&(!e||!S.trim()),children:A.isPending?"Connecting…":_?"Open invitation":"Connect"})]})]});const se=n.jsx("p",{className:"text-muted-foreground text-xs break-all",children:t.pinnedOrigin});if(t.status==="reconnect-required"){const G=!D.data&&D.fetchStatus==="fetching",Q=D.data?Xl(t.label,D.data.agents):G?null:Jl(t.label);return n.jsxs(n.Fragment,{children:[n.jsxs(Qe,{children:[n.jsxs($e,{children:["Reconnect ",t.label]}),n.jsxs(Xe,{children:["DorkOS can’t reach ",t.label,"’s channels. Disconnect, then connect again."]})]}),n.jsxs(it,{className:"space-y-3 py-4",children:[se,Q&&n.jsx("p",{className:"text-sm",children:Q}),D.isError&&!D.data&&!G&&n.jsxs("div",{role:"alert",className:"flex flex-col items-start gap-2 text-sm sm:flex-row sm:items-center sm:justify-between sm:gap-3",children:[n.jsxs("p",{className:"text-destructive",children:["Couldn’t check which of your agents are on ",t.label,"."]}),n.jsx(P,{size:"sm",variant:"outline",onClick:()=>void D.refetch(),children:"Check again"})]}),C.isError&&n.jsx("p",{role:"alert",className:"text-destructive text-sm",children:"Couldn’t disconnect. Check DorkOS is running and try again."})]}),n.jsxs(_t,{children:[n.jsx(P,{type:"button",variant:"outline",onClick:f,children:"Close"}),n.jsx(P,{disabled:C.isPending||G,onClick:()=>K(t),children:C.isPending?"Disconnecting…":"Disconnect"})]})]})}return n.jsxs(n.Fragment,{children:[n.jsxs(Qe,{children:[n.jsxs($e,{children:["Approve on ",t.label]}),n.jsx(Xe,{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(it,{className:"space-y-3 py-4",children:[se,V,n.jsxs("p",{className:"flex items-center gap-2 text-sm",children:[n.jsx(we,{})," Waiting for your approval"]}),r?n.jsx(P,{asChild:!0,children:n.jsxs("a",{ref:E,href:g.linkFor(r),target:"_blank",rel:"noopener noreferrer",children:["Open ",t.label," to approve",n.jsx(Lt,{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."}),(C.isError||!!s.error)&&n.jsxs("div",{role:"alert",className:"space-y-2 text-sm",children:[n.jsx("p",{children:C.isError?"Couldn’t confirm it was cancelled. Refresh to check.":"Couldn’t check approval. Try again."}),!C.isError&&n.jsx(P,{size:"sm",variant:"outline",onClick:s.retry,disabled:s.isFetching,children:"Check approval"})]})]}),n.jsxs(_t,{children:[n.jsx(P,{type:"button",variant:"outline",onClick:f,children:"Close"}),n.jsx(P,{variant:"outline",disabled:C.isPending,onClick:()=>K(t),children:C.isPending?"Cancelling…":"Cancel approval"})]})]})}function jN(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 ai({sheet:e,label:t="Actions",children:s}){return e?n.jsx("div",{role:"menu","aria-label":t,tabIndex:-1,onKeyDown:jN,children:s}):n.jsx(n.Fragment,{children:s})}function Js(){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 kN({trigger:e,selectedRef:t}){const s=oe(),r=je(),o=Ae(),a=ke({select:h=>h.location}),i=l.useRef(!1),c=l.useRef(!1),[d,m]=l.useState(null);function u(h,g){var b;if(!r||(h||(c.current=!1),g))return;if(h){const y=Js();_f({cancelled:y.acted}).finally(y.stop);return}const x=document.activeElement;(x===null||x===document.body)&&((b=e.current)==null||b.focus())}async function f(h){if(h.ref===t||i.current||h.status!=="connected")return;const g=Qo();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=Js();i.current=!0,m(h.ref);let k=!1,w=null;try{await o({...he.channels(),search:{community:h.ref}}),k=!0,w=vn();const I=await s.resolveCommunityNavigation(h.ref),v=I?null:(await s.listRemoteCommunityRooms(h.ref)).rooms.find(R=>R.readable&&!R.archived)??null,S=(I==null?void 0:I.roomId)??(v==null?void 0:v.roomId);if(!ft(x)||!w.isCurrent()){u(!1,y.acted());return}S&&await o({...he.channels(),search:{community:h.ref,...S?{id:S}:{},...I!=null&&I.threadId?{thread:I.threadId}:{}}}),u(!0,y.acted())}catch{u(!1,y.acted()),k&&(w==null?void 0:w.isCurrent())===!0&&ft(x)&&await o({to:b.pathname,search:b.search,replace:!0}).then(()=>!0,()=>!1)&&ae.error(`Couldn’t open ${h.label}.`,{description:"You’re still where you were. Try again in a moment."})}finally{y.stop(),i.current=!1,m(null)}}async function p(){if(t===void 0||i.current)return;const h=Qo();if(h.ownerKey===null)return;const g={epoch:h.epoch,ownerKey:h.ownerKey},x=vn();c.current=r;const b=Js();i.current=!0;try{const y=await s.getCommunityNavigation();if(y.ownerKey!==g.ownerKey||!ft(g)||!x.isCurrent()){u(!1,b.acted());return}const k=Mf.safeParse(y.installationDestination);await o(k.success?{to:k.data.path,search:k.data.search}:{...he.home()}),u(!0,b.acted())}catch{const y=ft(g)&&x.isCurrent();y&&await o({...he.home()}),u(y,b.acted())}finally{b.stop(),i.current=!1}}return{pendingRef:d,isSelecting:()=>i.current,holdCloseFocus:()=>{c.current=!0},takeCloseFocusHold:()=>{const h=c.current;return c.current=!1,h},selectCommunity:f,selectInstallation:p}}function SN(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 ou({triggerClassName:e,compact:t=!1}){var Tt;const s=je(),r=Ae(),o=ke({select:z=>z.location.search.community}),a=Pf(),i=Lf(),c=Ss(),{spaces:d,anySpace:m,selectedRef:u,visible:f,joinOfficial:p}=uN(o,c.data),h=l.useMemo(()=>{var z;return lN(f,((z=a.data)==null?void 0:z.order)??[])},[f,(Tt=a.data)==null?void 0:Tt.order]),g=h.find(z=>z.ref===u)??null,x=l.useRef(null),b=l.useRef(null),y=l.useRef(null),{pendingRef:k,isSelecting:w,holdCloseFocus:I,takeCloseFocusHold:v,selectCommunity:S,selectInstallation:R}=kN({trigger:y,selectedRef:u}),[M,E]=l.useState(""),[N,j]=l.useState(!1),[A,C]=l.useState(null),[D,T]=l.useState(null),_=nk(),[L,O]=l.useState(null),K=u?h.findIndex(z=>z.ref===u):-1;function V(z,ce){ct(new URL(Kf(z.remoteCommunityId,ce),z.pinnedOrigin).toString())}const se=iN({selected:g?{connection:g,availability:aN(g),canMoveUp:K>0,canMoveDown:K>=0&&K<h.length-1}:null,onMove:z=>{g&&i.mutate({ref:g.ref,direction:z})},onInvite:()=>g&&V(g,"community"),onOpenSettings:()=>g&&V(g),onLeave:()=>g&&V(g,"account"),onDisconnect:()=>T(g),onJoin:d?()=>C({ref:null}):null,onJoinOfficial:p,creationOrigins:d?oN(h):[],onCreate:z=>ct(new URL(Uf,z).toString()),onDeploy:()=>ct(rN),hosting:d&&_?{onStart:()=>O({kind:"start"}),onOpenYourSpaces:()=>O({kind:"hosted"})}:null}),G=m?se:[];mN(z=>C({ref:null,url:z}));const Q=sN(G),ne=Pc([...Q.identityNodes,...Q.nodes]),J=ne.nodes.slice(0,Q.identityNodes.length),ee=ne.nodes.slice(Q.identityNodes.length),H=Q.teamName,U=Q.nameUnknown,Y=u!==void 0&&c.data===void 0,W=u===void 0?U:Y,ge=u===void 0?H:(g==null?void 0:g.label)??"Space",Rt=s&&h.length>=8&&M.trim().length>0?h.filter(z=>z.label.toLocaleLowerCase().includes(M.trim().toLocaleLowerCase())):h;SN(z=>{b.current=z,j(!0)});function ut(z){if(w())return;if(b.current=null,z==="installation"){R();return}const ce=h.find(xe=>`community:${xe.ref}`===z);if(ce){if(ce.status==="connected"){S(ce);return}I(),C({ref:ce.ref})}}function nt(z){j(z),z||E("")}function te(z){if(ne.onCloseAutoFocus(z),v()){z.preventDefault();return}const ce=b.current;b.current=null,!(z.defaultPrevented||!(ce!=null&&ce.isConnected))&&(z.preventDefault(),ce.focus())}l.useEffect(()=>{if(!N)return;const z=requestAnimationFrame(()=>{var ce;return(ce=x.current)==null?void 0:ce.focus()});return()=>cancelAnimationFrame(z)},[N]);async function qe(z){var be;const xe=(be=(await c.refetch()).data)==null?void 0:be.find(Me=>Me.ref===z&&Me.status==="connected");xe&&await S(xe)}function mt(z){rs(vn().destination)===z.ref&&r({...he.home(),replace:!0})}return n.jsxs(n.Fragment,{children:[n.jsxs(Ff,{open:N,onOpenChange:nt,children:[n.jsx($f,{asChild:!0,children:n.jsxs("button",{ref:y,type:"button","data-testid":"sidebar-header-block","aria-label":W?"Context menu":`${ge} menu`,"aria-busy":k!==null||void 0,className:e,children:[t?u===void 0?n.jsx(fa,{className:"size-4 shrink-0","aria-hidden":!0}):n.jsx(gr,{className:"size-4 shrink-0","aria-hidden":!0}):W?n.jsx(xt,{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(At,{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(Bf,{align:"start",className:"max-h-(--radix-dropdown-menu-content-available-height) w-64 overflow-y-auto",onCloseAutoFocus:te,children:[s&&n.jsx(Xo,{children:m?"Switch context":"Menu"}),n.jsx(ai,{sheet:s,label:"You",children:n.jsx(mr,{variant:s?"sheet":"dropdown",nodes:J,onSheetClose:()=>nt(!1)})}),m&&n.jsx(Jo,{}),m&&!s&&n.jsx(Xo,{children:"Switch context"}),m&&s&&h.length>=8&&n.jsx("div",{className:"px-4 pb-2",children:n.jsx(Ze,{type:"search",value:M,onChange:z=>E(z.target.value),placeholder:"Find a space","aria-label":"Find a space"})}),m&&n.jsxs(zf,{value:u?`community:${u}`:"installation",onValueChange:ut,children:[n.jsx(Zo,{value:"installation",icon:fa,disabled:k!==null,itemRef:u===void 0?x:void 0,className:k!==null?"opacity-50":void 0,children:n.jsx("span",{className:"min-w-0 flex-1 truncate",children:H})}),Rt.map(z=>{var ht;const ce=ru(z),xe=ce.mentionCount??0,be=Math.max(0,(ce.unreadCount??0)-xe),Me=[xe>0?`${xe} ${xe===1?"mention":"mentions"}`:null,be>0?`${be} other unread`:null,((ht=z.attention)==null?void 0:ht.state)==="stale"?`last checked ${dN(vs(z.attention.verifiedAt))}`:null].filter(Boolean).join(", ");return n.jsx(Zo,{value:`community:${z.ref}`,icon:gr,disabled:k!==null,itemRef:z.ref===u?x:void 0,description:[cN(z),Me].filter(Boolean).join(" · ")||void 0,className:k!==null?"opacity-50":void 0,children:n.jsxs("span",{className:"flex min-w-0 items-center gap-1.5",children:[n.jsx("span",{className:"min-w-0 truncate",children:z.label}),ib(z)&&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]}),be>0&&n.jsx("span",{className:"bg-muted text-muted-foreground shrink-0 rounded-full px-1.5 text-xs","aria-label":`${be} other unread`,children:be})]})},z.ref)})]}),ee.length>0&&n.jsxs(n.Fragment,{children:[n.jsx(Jo,{}),n.jsx(ai,{sheet:s,children:n.jsx(mr,{variant:s?"sheet":"dropdown",nodes:ee,onSheetClose:()=>nt(!1)})})]})]})]}),n.jsx(vN,{request:A,onOpenChange:z=>{z||C(null)},installName:U?"My DorkOS":H,onConnected:z=>void qe(z)}),n.jsx(Sk,{entry:_,dialog:L,onDialogChange:O,installName:U?"My DorkOS":H,onConnected:z=>void qe(z)}),n.jsx(hN,{connection:D,onOpenChange:z=>{z||T(null)},onDisconnected:mt})]})}function CN(){return n.jsx(ou,{compact:!0,triggerClassName:B("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",Dn)})}function au(){const e=je();return n.jsxs(Hf,{className:"gap-2 px-2 py-3",children:[n.jsxs("div",{className:"flex items-center gap-1",children:[!e&&n.jsx(ou,{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(XC,{})]}),n.jsx(JC,{})]})}function NN(){const e=su("sm");return n.jsxs("div",{className:"space-y-1 pb-2",children:[e.you!==null&&n.jsx(ii,{leading:e.you.face,label:e.you.name,description:"View profile",onClick:e.you.onOpen}),n.jsx(ii,{leading:n.jsx(yl,{className:"text-muted-foreground size-7 p-0.5","aria-hidden":!0}),label:"DorkOS account",description:e.accountStatus,onClick:e.onOpenAccount})]})}function ii({leading:e,label:t,description:s,onClick:r}){return n.jsxs("button",{type:"button",onClick:r,className:B("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",Dn),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(Kt,{className:"text-muted-foreground size-4 shrink-0","aria-hidden":!0})]})}const AN=6e4;function EN(e){return e===null?!0:(e.selectionStart??0)===0&&(e.selectionEnd??0)===0}function IN(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"&&Ce(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 RN(){const{globalPaletteOpen:e,setGlobalPaletteOpen:t}=Vk(),s=$(F=>F.openMessageSearch),[r,o]=l.useState(""),a=l.useRef(null),[i,c]=l.useState(""),d=l.useRef(null),[m,u]=l.useState([]),[f,p]=l.useState(null),[h,g]=l.useState(null),[x,b]=l.useState(null),y=m[m.length-1],[k,w]=l.useState(0),I=je(),v=$(F=>F.globalPaletteInitialSearch),S=$(F=>F.clearGlobalPaletteInitialSearch),R=l.useCallback(()=>{t(!1),S(),o(""),c(""),u([]),p(null),b(null)},[t,S]),{handleAgentSelect:M,startNewSession:E,handleFeatureAction:N,handleQuickAction:j,handleRoomSelect:A,handleSessionSelect:C,handleCommandSelect:D,handlePageSelect:T,recordAgentOpened:_,selectedCwd:L}=s0(R),O=ie(),K=l.useCallback(F=>{const fe=Wf(O,F.projectPath);return Gf(fe?{session:fe}:{agentId:F.id})},[O]),V=l.useCallback(F=>{if(!qf()){M(F);return}pn(K(F),{target:"tab"}),_(F.projectPath),R()},[K,M,_,R]),se=l.useCallback(F=>{pn(K(F),{target:"window"}),_(F.projectPath),R()},[K,_,R]),G=Yf(),Q=e0(),ne=oo(AN),{allAgents:J,newActions:ee,rooms:H,sessions:U,continueRows:Y,recent:W,searchableItems:ge}=Yk(L,ne);Vf(J);const{bestMatch:Rt,rows:ut,prefix:nt,term:te}=JS(ge,r,{usage:Q,now:ne,scope:x}),qe=nt==="#",mt=c0(te),Tt=mt?{term:mt,isScoped:x!==null,onSelect:()=>{R(),s(mt)}}:null,z=l.useMemo(()=>i?J.find(F=>F.name===i)??null:null,[i,J]),ce=IN(i,Rt,ut),xe=l.useCallback(F=>{b(F),o(""),c("")},[]),be=!I&&z!==null,Me=l.useMemo(()=>{var F;return i?U.find(fe=>fe.id===i)??((F=Y.find(fe=>fe.session.id===i))==null?void 0:F.session)??null:null},[i,U,Y]),ht=$d((f==null?void 0:f.id)??"",(f==null?void 0:f.projectPath)??""),Pn=l.useCallback(()=>{u(F=>F.slice(0,-1)),p(F=>m.length<=1?null:F),c("")},[m.length]),Ln=l.useCallback(F=>{p(F),u(fe=>[...fe,"agent-actions"]),o(""),c(""),w(fe=>fe+1)},[]);l.useEffect(()=>{e&&v!=null&&(o(v),S(),requestAnimationFrame(()=>{const F=a.current;if(F){const fe=v.length;F.setSelectionRange(fe,fe)}}))},[e,v,S]);const Fn=l.useCallback(F=>{t(F),F?w(fe=>fe+1):(o(""),c(""),u([]),p(null),b(null))},[t]),Xt=a0({rootRef:d,activePage:y??"root",onPin:c,resetKey:JSON.stringify([e,y??null,r,x&&Nd(x)])}),Es=!r&&x===null,Is=l.useId(),Rs=n.jsx(et,{open:e,onOpenChange:Fn,children:n.jsx(tt,{className:B("!min-h-0 overflow-hidden p-0 transition-[max-width] duration-200","[&>button:last-child]:top-2 [&>button:last-child]:right-2.5",be?"max-w-[640px]":"max-w-[480px]",I&&"h-[85vh]"),children:n.jsxs(X.div,{variants:Hd,initial:"hidden",animate:"visible",exit:"exit",className:B("flex overflow-hidden",I&&"h-full flex-col"),children:[n.jsxs(Sl,{ref:d,loop:!0,shouldFilter:!1,value:i,onValueChange:c,onPointerMove:Xt.onPointerMove,className:B("min-w-0 flex-1",I&&"flex flex-col [&_[cmdk-list]]:max-h-none [&_[cmdk-list]]:flex-1 [&_[cmdk-list]]:overflow-y-auto"),onKeyDown:F=>{if(Xt.onKeyDown(F),F.key==="Enter"&&(F.metaKey||F.ctrlKey)&&!y&&(Me==null?void 0:Me.cwd)!=null){F.preventDefault(),E(Me.cwd),R();return}if(F.key==="Enter"&&(F.metaKey||F.ctrlKey)&&!y&&z){F.preventDefault(),V(z);return}if(F.key==="Enter"&&(F.metaKey||F.ctrlKey)&&y==="agent-actions"&&f){F.preventDefault(),V(f);return}if(F.key==="Tab"&&!F.shiftKey&&!y&&ce){F.preventDefault(),F.stopPropagation(),xe(ce);return}if(F.key==="Backspace"&&x&&!y&&EN(a.current)){F.preventDefault(),b(null);return}F.key==="Backspace"&&!r&&m.length>0&&(F.preventDefault(),Pn()),F.key==="Escape"&&m.length>0&&(F.preventDefault(),F.stopPropagation(),Pn())},children:[m.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:()=>{u([]),p(null),w(F=>F+1)},className:"hover:text-foreground transition-colors",children:"All"}),n.jsx("span",{children:"/"}),n.jsxs("span",{children:["Agent: ",f==null?void 0:f.name]})]}),n.jsx(Cl,{ref:a,"data-testid":"command-palette-input",leading:x&&!y?n.jsx(i0,{scope:x}):void 0,placeholder:y==="agent-actions"?`${(f==null?void 0:f.name)??"Agent"} actions…`:x&&!y?"Search within…":"Search rooms, agents, commands…",value:r,onValueChange:o}),n.jsx(Nl,{children:n.jsxs(un,{className:"h-full",children:[n.jsxs(fb,{children:[n.jsx("p",{children:"No results found."}),n.jsx(Bd,{className:"justify-center pb-0"})]}),n.jsx(Fe,{mode:"wait",initial:!1,children:n.jsxs(X.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(S0,{staggerKey:k,isZeroQuery:Es,isRoomMode:qe,scope:x,hasQuery:te.length>0,selectedCwd:L,selectedValue:i,continueRows:Y,recent:W,newActions:ee,bestMatch:Rt,rows:ut,rooms:H,searchHandoff:Tt,onFeatureAction:N,onQuickAction:j,onGoToAgentActions:Ln,onRoomSelect:A,onSessionSelect:F=>C(F.id,F.cwd),onCommandSelect:D,onPageSelect:T}),y==="agent-actions"&&f&&n.jsx(d0,{agent:f,onOpenHere:()=>M(f),onOpenNewTab:()=>V(f),onOpenNewWindow:G?()=>se(f):void 0,onNewSession:()=>{E(f.projectPath),_(f.projectPath),R()},onEditSettings:()=>{Qf.getState().openProfileDocked(f.projectPath),R()},onBrowseSessions:ht.sessionCount>0?()=>{g(f),_(f.projectPath),R()}:void 0,recentSessions:ht.recentSessions,onSelectSession:F=>C(F,f.projectPath)})]},y??"root")})]})}),n.jsx(m0,{page:y,hasAgentSelected:be,canScope:!y&&ce!==null,isScoped:x!==null})]}),n.jsx(Fe,{children:be&&z&&n.jsx(l0,{agent:z},z.id)})]})})});return n.jsxs(n.Fragment,{children:[n.jsx(Xf,{id:Is,children:Rs}),h!==null&&n.jsx(Jf,{agentPath:h.projectPath,agentName:h.displayName??h.name,agentVisual:ro(h),open:!0,onOpenChange:F=>{F||g(null)},onSelectSession:F=>C(F,h.projectPath),onNewSession:()=>E(h.projectPath)})]})}const TN="",DN="";function ON(e){const t=[];let s=e,r=!1;for(;s.length>0;){const o=r?DN:TN,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 MN({excerpt:e,className:t}){const s=ON(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 iu="rooms",_N=["claude-code","opencode"];function PN(e){if(e.source===iu)return{kind:"room",...he.channels(),search:{id:e.container,entry:e.ordinal}};if(e.sessionId===void 0)return{kind:"unopenable"};const t=e.messageId!==void 0&&_N.includes(e.source);return{kind:"session",...vt({session:e.sessionId,dir:e.containerPath??void 0,...t?{message:e.messageId}:{}})}}function LN(e,t){return e.source===iu?t.get(e.container)??"Channel":e.containerPath===null?"Conversation":Bc(e.containerPath)}function FN(e){return e==="user"?"You":"Agent"}function $N({hit:e,containerLabel:t,value:s,onSelect:r,openable:o}){const a=e.source==="rooms"?co:dy;return n.jsxs(me,{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:FN(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:vs(e.createdAt)})]}),n.jsx(MN,{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 BN=["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."],zN=["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."],UN="Searches channels, direct messages, and DorkOS, Claude Code, Codex and OpenCode chats. Not tool output.",KN=`Type at least ${zc} letters to search.`,HN="Search what was said…";function WN({detailOpen:e=!1,className:t}){const[s,r]=l.useState(null),o=s??e,a=zN;return n.jsxs(mo,{open:o,onOpenChange:r,className:B("px-3 py-2",t),children:[n.jsxs(ho,{className:B("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:UN}),n.jsx(At,{className:B("mt-0.5 size-3 shrink-0 transition-transform",!o&&"-rotate-90"),"aria-hidden":"true"})]}),n.jsx(fo,{children:n.jsxs("ul",{className:"mt-2 space-y-1.5",children:[BN.map(i=>n.jsxs("li",{className:"text-muted-foreground flex gap-2 text-xs leading-relaxed",children:[n.jsx(Nt,{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(uy,{className:"mt-0.5 size-3.5 shrink-0 opacity-60","aria-hidden":"true"}),n.jsx("span",{children:i})]},i))]})})]})}const GN=3e4,qN=e=>["message-search",e];function Zs(e){return Zf(e).some(t=>t.length>=zc)}function YN(e,t){const s=oe(),r=VN(e,ep),o=t&&Zs(e)&&Zs(r),{data:a,isFetching:i,error:c}=ye({queryKey:qN(r),queryFn:()=>s.search({q:r}),enabled:o,staleTime:GN,placeholderData:m=>m,retry:!1});return{submitted:o?r:"",tooShort:t&&r.trim().length>0&&!Zs(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 VN(e,t){const[s,r]=l.useState(e);return l.useEffect(()=>{const o=setTimeout(()=>r(e),t);return()=>clearTimeout(o)},[e,t]),s}function QN(){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 er="bg-muted rounded px-1 py-0.5 font-mono text-3xs";function XN(){QN();const e=$(v=>v.messageSearchOpen),t=$(v=>v.messageSearchQuery),s=$(v=>v.setMessageSearchOpen),r=je(),o=Ae(),a=oe(),[i,c]=l.useState("");l.useEffect(()=>{e&&c(t??"")},[e,t]);const{results:d,warnings:m,tooShort:u,isSearching:f,error:p,submitted:h}=YN(i,e),{data:g}=ws({includeArchived:!0}),x=l.useMemo(()=>{const v=new Map;for(const S of g??[])v.set(S.id,S.kind==="channel"&&S.slug?`#${S.slug}`:S.title);return v},[g]),b=l.useCallback(()=>s(!1),[s]),y=l.useCallback((v,S)=>{if(S.kind!=="unopenable"&&(b(),o({to:S.to,search:S.search}),S.kind==="session"&&v.containerPath!==null)){const R=v.containerPath;a.browseDirectory(R).catch(M=>{if((M==null?void 0:M.status)===404){ae.info("That folder is gone",{description:`${R} is gone, so nothing new can run there. You can still read it.`});return}ae.info("Couldn’t open that folder",{description:`DorkOS couldn’t read ${R}. The chat may not open.`})})}},[b,o,a]),k=d.length>0,w=!k&&!u&&!f&&h.trim().length>0&&p===null,I=!k&&!u&&h.trim().length>0&&p===null;return n.jsx(et,{open:e,onOpenChange:s,children:n.jsxs(tt,{"data-testid":"message-search-dialog",className:B("!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($e,{className:"sr-only",children:"Search your messages"}),n.jsx(X.div,{variants:Hd,initial:"hidden",animate:"visible",exit:"exit",className:B("flex overflow-hidden",r&&"h-full flex-col"),children:n.jsxs(Sl,{loop:!0,shouldFilter:!1,className:B("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(Cl,{"data-testid":"message-search-input",placeholder:HN,value:i,onValueChange:c}),p!==null&&n.jsxs("p",{className:"text-destructive flex items-start gap-2 px-3 py-3 text-xs leading-relaxed",children:[n.jsx(tp,{className:"mt-0.5 size-3.5 shrink-0","aria-hidden":"true"}),n.jsx("span",{children:p.message})]}),m.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(Fi,{className:"mt-0.5 size-3 shrink-0","aria-hidden":"true"}),n.jsx("span",{children:v.message})]},v.source)),n.jsx(Nl,{children:n.jsx(un,{className:"h-full",children:k&&n.jsx(Le,{className:B("transition-opacity duration-150",f&&"opacity-60"),children:d.map(v=>{const S=`${v.source}:${v.container}:${v.ordinal}`,R=PN(v);return n.jsx($N,{value:S,hit:v,containerLabel:LN(v,x),openable:R.kind!=="unopenable",onSelect:()=>y(v,R)},S)})})})}),p===null&&n.jsxs("div",{className:"max-h-[45vh] min-h-0 shrink-0 overflow-y-auto",children:[u&&n.jsx("p",{className:"text-muted-foreground px-3 pt-3 text-xs",children:KN}),w&&n.jsxs("p",{className:"text-muted-foreground px-3 pt-3 text-xs",children:["No messages match “",h.trim(),"”."]}),n.jsx(WN,{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:er,children:"↑↓"}),"Navigate"]}),n.jsxs("span",{className:"inline-flex items-center gap-1",children:[n.jsx("kbd",{className:er,children:"Enter"}),"Open"]}),n.jsxs("span",{className:"ml-auto inline-flex items-center gap-1",children:[n.jsx("kbd",{className:er,children:"esc"}),"Close"]})]})]})})]})})}function JN(e){return`set${e.charAt(0).toUpperCase()}${e.slice(1)}`}function ZN(e){const t=Ke(),s=eo(),r=lo();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 eA({contribution:e,openStateKey:t}){const s=$(u=>u[t]),r=$(u=>u[JN(t)]),o=ZN(e.urlParam),a=o.isOpen,i=o.close,c=s||a,d=l.useCallback(u=>{r(u),!u&&a&&i()},[r,a,i]),m=e.component;return n.jsx(m,{open:c,onOpenChange:d})}function tA({contribution:e,openState:t}){const s=l.useSyncExternalStore(t.subscribe,t.getSnapshot),r=e.component;return s?n.jsx(np,{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(tA,{contribution:e,openState:e.openState}):n.jsx(eA,{contribution:e,openStateKey:e.openStateKey})}function sA(){const e=bs("dialog");return n.jsx(n.Fragment,{children:e.map(t=>n.jsx(nA,{contribution:t},t.id))})}const rA=["session","id","thread","entry","itemId","agent","profile","continuedFrom","pkg","view","region","detail","panel"];function oA(e,t){if(e.length>=Ls)return e.slice(0,Ls);const s=new URLSearchParams(t);let r="";for(const o of rA)for(const a of s.getAll(o)){const i=new URLSearchParams([[o,a]]).toString(),c=r?`${r}&${i}`:i;e.length+1+c.length<=Ls&&(r=c)}return r?`${e}?${r}`:e}const aA=6e4,iA={bug:"when it’s fixed",idea:"when it ships",feedback:"when the team acts on it"};function cA(e,t){var s;return JSON.stringify([e.kind,t,e.screenshotDataUrl??null,((s=e.element)==null?void 0:s.selector)??null])}function ci(e,t,s,r){const o=El("bug",e,t),a=[...ap()];r&&a.push({at:new Date().toISOString(),kind:"console_error",message:rp(r).slice(0,op)});const i=a.slice(-ip);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])),...Ty(s)},...i.length>0?{breadcrumbs:i}:{}}}function lA(){const e=oe(),t=ke({select:h=>h.location.pathname}),s=ke({select:h=>h.location.searchStr}),r=sp(),o=oA(t,s),a=ke({select:h=>{const g=h.location.search;return typeof(g==null?void 0:g.session)=="string"?g.session:void 0}}),{data:i}=ye({queryKey:Ne.current(),queryFn:()=>e.getConfig(),staleTime:300*1e3}),[c,d]=l.useState(!1),m=Ae(),u=l.useRef(null),f=l.useCallback(h=>i?ci(i,t,r,h==null?void 0:h.crashStack):void 0,[i,t,r]),p=l.useCallback(async h=>{var v;const g=h.message.trim();if(!g)return!1;const x=(v=h.contact)==null?void 0:v.trim(),b=cA(h,g),y=u.current;if(y&&y.fingerprint===b&&Date.now()-y.at<aA)return ae.info("Already sent a moment ago."),!0;const k=h.includeDiagnostics?ci(i,t,r,h.crashStack):void 0,w=h.includeDiagnostics&&h.kind==="bug",I=!!(h.includeConversation&&a);d(!0);try{const S=k&&w?await vy():void 0,{ok:R}=await e.sendFeedback({kind:h.kind,message:g,...x?{contact:x}:{},...o?{route:o}:{},...k?{diagnostics:{...k,...S?{shellLogExcerpt:S}:{}}}:{},...w?{includeServerLogs:!0}:{},...I?{sessionId:a,includeTranscript:!0}:{},...h.screenshotDataUrl?{screenshot:{dataUrl:h.screenshotDataUrl}}:{},...h.anonymous?{anonymous:!0}:{},...h.element?{element:h.element}:{}});return R?(u.current={fingerprint:b,at:Date.now()},ae.success("Sent. Thank you.",{...h.notifyEmail?{description:`DorkOS emails ${h.notifyEmail} ${iA[h.kind]}.`}:{},action:{label:"Your reports",onClick:()=>m(he.feedbackRequests())}})):ae.error("Couldn’t send. Your words are still here. Try again or open a GitHub issue."),R}finally{d(!1)}},[e,t,o,a,i,r,m]);return{isSubmitting:c,sessionId:a,route:o,buildDiagnostics:f,send:p}}const dA=24;function li(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 uA(e){const{element:t,viewport:s,region:r,image:o}=e,a=e.padding??dA;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=li(i,{left:0,top:0,width:s.width,height:s.height});if(!c)return null;const d=li(c,r);if(!d)return null;const m=o.width/r.width,u=o.height/r.height,f=Math.round((d.left-r.left)*m),p=Math.round((d.top-r.top)*u),h=Math.round((d.left+d.width-r.left)*m),g=Math.round((d.top+d.height-r.top)*u),x=Math.min(Math.max(0,f),Math.max(0,o.width-1)),b=Math.min(Math.max(0,p),Math.max(0,o.height-1));return{sx:x,sy:b,sw:Math.max(1,h-x),sh:Math.max(1,g-b)}}function mA(e){return new Promise((t,s)=>{const r=new Image,o=i=>{clearTimeout(a),s(new Be("failed",i))},a=setTimeout(()=>o(`The capture did not decode within ${as}ms.`),as);r.onload=()=>{clearTimeout(a),t(r)},r.onerror=()=>o("The capture did not decode, so it cannot be cropped."),r.src=e})}function hA(e,t){const s=document.createElement("canvas");s.width=t.sw,s.height=t.sh;const r=s.getContext("2d");if(!r)throw new Be("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 Be("failed","That element has no size to crop to.");if(!Gl().contains(t))throw new Be("failed","That element is not part of the app that was captured.");const r=await mA(e.dataUrl),o=uA({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 Be("failed","That element is no longer inside the captured picture.");return br(hA(r,o))}const di={"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."},pA={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 gA(e){return e instanceof Be?pA[e.reason]:e instanceof kt?di[e.reason]:di.unreadable}const tr="Only images can be attached.",xA="Files";function on(e){return e?Array.from(e.types).includes(xA):!1}function ui(e){return e.find(t=>t.type.startsWith("image/"))}function bA(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),m=l.useRef(0),u=l.useCallback(async v=>{const S=++m.current;a(!0);try{const R=await v();return S!==m.current?null:(r(R),R)}catch(R){return S!==m.current||ae.error(gA(R)),null}finally{S===m.current&&a(!1)}},[]),f=l.useCallback(async v=>{if(!v.type.startsWith("image/")){ae.error(tr);return}await u(()=>br(v))},[u]),p=l.useCallback(async()=>{await u(async()=>br(await Ey()))},[u]),h=l.useCallback(v=>u(async()=>fA(await ql(),v)),[u]),g=l.useCallback(()=>{m.current+=1,r(null),a(!1)},[]),x=l.useCallback(v=>{m.current+=1,d.current=0,v!==void 0&&!Fy(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=S=>{on(S.dataTransfer)&&S.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 M;const S=Array.from(((M=v.clipboardData)==null?void 0:M.items)??[]).map(E=>E.getAsFile()).filter(E=>E!==null);if(S.length===0)return;const R=ui(S);if(!R){ae.error(tr);return}v.preventDefault(),f(R)},[f]),y=l.useCallback(v=>{on(v.dataTransfer)&&(v.preventDefault(),d.current+=1,c(!0))},[]),k=l.useCallback(v=>{on(v.dataTransfer)&&(v.preventDefault(),v.dataTransfer.dropEffect="copy")},[]),w=l.useCallback(v=>{on(v.dataTransfer)&&(d.current=Math.max(0,d.current-1),d.current===0&&c(!1))},[]),I=l.useCallback(v=>{if(!on(v.dataTransfer))return;v.preventDefault(),d.current=0,c(!1);const S=ui(Array.from(v.dataTransfer.files));if(!S){ae.error(tr);return}f(S)},[f]);return{dataUrl:s,isPreparing:o,isDraggingOver:i,attach:f,capture:p,captureElement:h,clear:g,reset:x,handlers:{onPaste:b,onDragEnter:y,onDragOver:k,onDragLeave:w,onDrop:I}}}const mi=dp,yA="root";function cu(e){return typeof CSS<"u"&&typeof CSS.escape=="function"?CSS.escape(e):e.replace(/["'\\[\]]/g,t=>`\\${t}`)}function hi(e,t){try{const s=t.ownerDocument.querySelectorAll(e);return s.length===1&&s[0]===t}catch{return!1}}function lu(e){return e.id?`#${cu(e.id)}`:null}function _r(e,t){const s=e.getAttribute(t);return s?`[${t}="${cu(s)}"]`:null}function vA(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=lu(e);if(s)return s;const r=_r(e,"data-testid")??_r(e,"data-slot"),o=`:nth-of-type(${vA(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 jA(e){for(const r of[lu(e),_r(e,"data-testid")])if(r&&r.length<=mi&&hi(r,e))return r;const t=[];let s=e;for(;s&&s.id!==yA&&s.tagName!=="BODY";){t.unshift(wA(s));const r=t.join(" > ");if(r.length>mi){t.shift();break}if(hi(r,e))return r;s=s.parentElement}return t.join(" > ")||e.tagName.toLowerCase()}function fi(e,t){var r;const s=(r=e.closest(`[${t}]`))==null?void 0:r.getAttribute(t);if(!(!s||s.length>cp))return s}const kA=8;function du(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*kA?s:null}function SA(e){const t=fi(e,"data-slot"),s=du(e,e),r=s?fi(s,"data-testid"):void 0,o=uu(e);return{selector:jA(e),...t?{slot:t}:{},...r?{testId:r}:{},...o?{label:o}:{}}}const nr=40,CA=["button","a[href]","summary","input","select","textarea",'[role="button"]','[role="link"]','[role="menuitem"]','[role="tab"]','[role="option"]','[role="checkbox"]','[role="switch"]'].join(", "),NA=new Set(["INPUT","SELECT","TEXTAREA"]),AA=['[contenteditable]:not([contenteditable="false"])','[role="textbox"]','[role="searchbox"]','[role="combobox"]'].join(", "),EA=["h1","h2","h3","h4","h5","h6",'[role="heading"]',"label","legend","th","dt"].join(", ");function IA(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 fn(e){const t=(e??"").replace(/\s+/g," ").trim();if(!t)return;const s=IA(t);if(s.length<=nr)return t;const r=s.slice(0,nr-1),o=r.lastIndexOf(" ");return`${(o>nr/2?r.slice(0,o):r).join("").trimEnd()}…`}function RA(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 fn(s)}function qn(e){return fn(e.getAttribute("aria-label"))??RA(e)}function uu(e){const t=TA(e);return t&&t.length<=lp?t:void 0}function TA(e){var a,i;const t=e.closest(AA);if(t)return qn(t);const s=e.closest(CA);if(s){if(NA.has(s.tagName)){const c=s;return qn(s)??fn((i=(a=c.labels)==null?void 0:a[0])==null?void 0:i.textContent)}return qn(s)??fn(s.textContent)}const r=qn(e);if(r)return r;const o=e.closest(EA);return o?fn(o.textContent):void 0}function pi(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 DA(e){var d;const t=uu(e);if(t)return{text:t,onScreen:!0};const s=e.getAttribute("data-testid")??e.getAttribute("data-slot"),r=s?pi(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&&du(e,o)===o?o.getAttribute("data-testid"):null)??(o==null?void 0:o.getAttribute("data-slot")),c=i?pi(i):null;return c?{text:c,onScreen:!1}:null}const OA="This part";function mu(e){return(e==null?void 0:e.text)??OA}function MA(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 _A(e){return e!=null&&e.onScreen?`Remove “${e.text}”`:`Remove ${mu(e).toLowerCase()}`}const gi=500;function xi(e){const t=e.trim();return t.length>gi?`${t.slice(0,gi)}… [trimmed]`:t}function PA(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: ${xi(s.input)}`),s.result&&t.push(` result: ${xi(s.result)}`);return t.join(`
82
+ `)}function LA(e){const t=e.slice(-20),s=up(mp(t.map(PA).join(`
83
+
84
+ `))).trim();return s.length>ea?`${s.slice(0,ea-1)}…`:s}function FA(e,t){const s=oe(),[r]=Rn(),{data:o,isLoading:a,isError:i}=ye({queryKey:["feedback-transcript-preview",e,r],queryFn:async()=>{const{messages:c}=await s.getMessages(e,r??void 0);return LA(c)},enabled:t&&!!e,staleTime:30*1e3});return{text:o??"",isLoading:a,isError:i}}function $A(){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(Uc,{className:"size-3 shrink-0","aria-hidden":!0}),"Private. Only the DorkOS core team sees these. Never public."]})})}function Pe({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 BA({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:m,timezone:u}=r;return n.jsxs("div",{className:"flex flex-col gap-3",children:[n.jsxs("div",{className:"rounded-md border p-3",children:[n.jsx(Pe,{label:"Page",value:s}),n.jsx(Pe,{label:"Version",value:r.version}),n.jsx(Pe,{label:"Platform",value:r.platform}),n.jsx(Pe,{label:"Runtimes",value:r.runtimes.length?r.runtimes.join(", "):"none"}),a&&n.jsx(Pe,{label:"Window",value:`${a.width}×${a.height}${a.devicePixelRatio&&a.devicePixelRatio!==1?` @${a.devicePixelRatio}x`:""}`}),c&&n.jsx(Pe,{label:"Shell",value:c}),d&&n.jsx(Pe,{label:"Theme",value:d}),m&&n.jsx(Pe,{label:"Locale",value:m}),u&&n.jsx(Pe,{label:"Timezone",value:u}),i&&n.jsx(Pe,{label:"Browser",value:i}),Object.entries(r.flags).map(([f,p])=>n.jsx(Pe,{label:f,value:String(p)},f))]}),n.jsxs("div",{className:"flex flex-col gap-1.5",children:[n.jsxs("span",{className:"text-muted-foreground text-xs font-medium",children:["Recent events (",(o==null?void 0:o.length)??0,")"]}),o&&o.length>0?n.jsx("ul",{className:"flex flex-col gap-1",children:o.map((f,p)=>n.jsxs("li",{className:"text-foreground font-mono text-xs break-all",children:[n.jsx("span",{className:"text-muted-foreground",children:f.kind})," ",f.message]},p))}):n.jsx("p",{className:"text-muted-foreground text-xs",children:"No recent errors or warnings."})]}),t==="bug"&&n.jsxs("div",{className:"text-muted-foreground space-y-1 text-xs",children:[n.jsx("p",{children:De()?"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 zA({sessionId:e,active:t}){const{text:s,isLoading:r,isError:o}=FA(e,t);return r?n.jsxs("div",{className:"flex flex-col gap-2",children:[n.jsx(xt,{className:"h-4 w-3/4"}),n.jsx(xt,{className:"h-4 w-full"}),n.jsx(xt,{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 UA({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 KA({open:e,onOpenChange:t,initialTab:s,diagnostics:r,kind:o,route:a,showConversation:i,sessionId:c,screenshotDataUrl:d}){const m=!je(),u=["diagnostics",...i?["conversation"]:[],...d?["screenshot"]:[]],f=u.includes(s)?s:"diagnostics";return n.jsx(et,{open:e,onOpenChange:t,children:n.jsxs(tt,{className:B("max-h-[85vh]",m&&"max-w-lg"),children:[n.jsxs(Qe,{children:[n.jsx($e,{className:"text-sm font-medium",children:"What will be sent"}),n.jsx(Xe,{className:"text-muted-foreground text-xs",children:"Each part is sent only if its toggle is on."})]}),n.jsxs(ul,{defaultValue:f,className:"flex min-h-0 flex-col gap-3 px-4 pb-4 sm:px-0",children:[n.jsxs(ml,{className:B("grid shrink-0",u.length===3&&"grid-cols-3",u.length===2&&"grid-cols-2",u.length===1&&"grid-cols-1"),children:[n.jsx(Vn,{value:"diagnostics",children:"Diagnostics"}),i&&n.jsx(Vn,{value:"conversation",children:"Chat"}),d&&n.jsx(Vn,{value:"screenshot",children:"Screenshot"})]}),n.jsx(Bs,{value:"diagnostics",className:"min-h-0",children:n.jsx(un,{className:"max-h-[45vh]",children:n.jsx(BA,{diagnostics:r,kind:o,route:a})})}),i&&n.jsx(Bs,{value:"conversation",className:"min-h-0",children:n.jsx(un,{className:"max-h-[45vh]",children:n.jsx(zA,{sessionId:c,active:e})})}),d&&n.jsx(Bs,{value:"screenshot",className:"min-h-0",children:n.jsx(un,{className:"max-h-[45vh]",children:n.jsx(UA,{dataUrl:d})})}),n.jsx($A,{})]},f)]})})}const HA="0 0 0 9999px rgb(0 0 0 / 0.5)";function WA(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 GA(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 qA({phase:e,onSelect:t,onCancel:s}){const r=l.useRef(null),o=l.useRef(null),[a,i]=l.useState(null),c=e==="picking",d=l.useCallback((x,b)=>{const y=r.current;if(!y)return null;const k=y.style.pointerEvents;y.style.pointerEvents="none";try{return document.elementFromPoint(x,b)}finally{y.style.pointerEvents=k}},[]),m=l.useCallback(x=>{var b;return x instanceof Node&&!!((b=o.current)!=null&&b.contains(x))},[]),u=l.useCallback(x=>{if(!c)return;if(m(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:WA(b)})},[c,d,m]),f=l.useCallback(x=>{if(!c||m(x.target))return;const b=d(x.clientX,x.clientY)??(a==null?void 0:a.element);b&&t(b)},[c,d,m,t,a]),p=l.useCallback(x=>{if(!c)return;const b=GA(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 ms.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:B("fixed inset-0 z-50 focus:outline-none",c?"cursor-crosshair":"cursor-wait"),onPointerMove:u,onPointerLeave:()=>i(null),onClick:f,onWheel:p,onContextMenu:x=>{x.preventDefault(),c&&s()},children:[c&&(h?n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"border-primary pointer-events-none absolute rounded-sm border-2",style:{left:h.box.left,top:h.box.top,width:h.box.width,height:h.box.height,boxShadow:HA}}),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(os,{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 bi="text-muted-foreground hover:text-foreground h-8 px-2 text-xs aria-disabled:pointer-events-none aria-disabled:opacity-50";function sr({tip:e,children:t}){return n.jsxs(Ht,{children:[n.jsx(Wt,{asChild:!0,children:t}),n.jsx(Gt,{className:"max-w-60 text-center",children:e})]})}function YA({showPictureTools:e,isPreparing:t,hasPointed:s,hasWords:r,isMobile:o,onCapture:a,onPointAtElement:i,onPick:c}){const d=l.useId(),m=l.useId(),u=l.useId(),f=l.useId();function p(k){var I;const w=(I=k.target.files)==null?void 0:I[0];k.target.value="",w&&c(w)}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:m,className:"sr-only",children:b}),n.jsx(sr,{tip:b,children:n.jsxs(P,{"aria-describedby":m,type:"button",variant:"ghost",size:"sm",onClick:()=>{t||a()},"aria-disabled":t||void 0,className:bi,children:[n.jsx(ry,{className:"size-3.5","aria-hidden":!0}),"Capture app"]})}),!o&&n.jsx(sr,{tip:y,children:n.jsxs(P,{"aria-describedby":u,type:"button",variant:"ghost",size:"sm",onClick:()=>{t||i()},"aria-disabled":t||void 0,className:bi,children:[n.jsx(os,{className:"size-3.5","aria-hidden":!0}),s?"Point again":"Point at it"]})}),!o&&n.jsx("span",{id:u,className:"sr-only",children:y}),n.jsx("span",{id:f,className:"sr-only",children:x}),n.jsx(sr,{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(xx,{className:"size-3.5","aria-hidden":!0}),n.jsx("input",{id:d,type:"file",accept:"image/*","aria-label":g,"aria-describedby":f,disabled:t,className:"sr-only",onChange:p})]})})]}),h&&n.jsxs("span",{className:"text-muted-foreground ml-auto pr-1.5 text-xs","aria-hidden":!0,children:[wt?"⌘↵":"Ctrl+↵"," to send"]})]})}function yi({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(os,{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(os,{className:"size-3 shrink-0","aria-hidden":!0}),n.jsx("span",{className:"truncate",children:s})]})]}),m=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(Ht,{children:[n.jsx(Wt,{asChild:!0,children:m}),n.jsx(Gt,{className:"max-w-72 font-mono text-[11px] break-all",children:o})]}):m,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(Oe,{className:"size-3","aria-hidden":!0})})]})}function vi({label:e,summary:t,pressed:s,onPressedChange:r,onPreview:o}){return n.jsxs("span",{className:B("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(Ht,{children:[n.jsx(Wt,{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:B("size-1.5 rounded-full transition-colors duration-150",s?"bg-primary":"bg-muted-foreground/40")}),e]})}),n.jsx(Gt,{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(hp,{className:"size-3.5","aria-hidden":!0})})]})}function VA({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(fy,{className:"size-3.5 shrink-0","aria-hidden":!0}):n.jsx(fp,{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&&!Kc(r);return n.jsxs("div",{className:"flex flex-col gap-1.5",children:[n.jsx(Te,{htmlFor:a,className:"text-xs",children:"Your email"}),n.jsx(Ze,{id:a,type:"email",inputMode:"email",autoComplete:"email",value:r,onChange:d=>o(d.target.value),placeholder:"you@example.com",maxLength:pp,"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 QA=[{value:"feedback",label:"Feedback",icon:fs},{value:"bug",label:"Bug",icon:gp},{value:"idea",label:"Idea",icon:bx}];function XA({kind:e,onChange:t}){return n.jsx("div",{role:"radiogroup","aria-label":"What kind of feedback",className:"flex gap-1.5",children:QA.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:B("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 JA({needsWords:e,canSend:t,isSubmitting:s,onOpenGitHubIssue:r}){const o=l.useId();return n.jsxs(_t,{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(Uc,{className:"size-3 shrink-0","aria-hidden":!0}),"Only the DorkOS team sees this"]}),n.jsx(P,{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 ZA={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 wi(e,t,s){return{diagnostics:e==="bug"||s,conversation:e==="bug"&&t}}function e1({open:e,onOpenChange:t,initialKind:s,prefillMessage:r,crashStack:o,currentUser:a,initialScreenshotDataUrl:i}){const c=!je(),{isSubmitting:d,sessionId:m,route:u,buildDiagnostics:f,send:p}=lA(),h=Qb(),g=!!m,x=!!a,b=l.useId(),[y,k]=l.useState(s??"feedback"),[w,I]=l.useState(r??""),[v,S]=l.useState(ta),[R,M]=l.useState(!1),[E,N]=l.useState(!1),[j,A]=l.useState(!1),[C,D]=l.useState(!1),[T,_]=l.useState("diagnostics"),[L,O]=l.useState(null),[K,V]=l.useState(null),[se,G]=l.useState(null),[Q,ne]=l.useState(null),[J,ee]=l.useState(0),H=l.useRef(J);l.useEffect(()=>{H.current=J},[J]);const[U,Y]=l.useState(!1),[W,ge]=l.useState(o),[Rt,ut]=l.useState(m),nt=l.useRef(null),te=bA({enabled:e}),qe=w.trim().length>0,mt=qe||te.dataUrl!==null||L!==null,[Tt,z]=l.useState(e);if(e!==Tt&&(z(e),e)){D(!1),ne(null);const Z=i;if(!!(r||o||Z)||!mt){const $n=s??"feedback",Bn=wi($n,g,!!o);k($n),I(r??""),S(ta()),M(!1),N(Bn.diagnostics),A(Bn.conversation),Y(!1),O(null),V(null),ge(o),ut(m),te.reset(Z),ee(Os=>Os+1)}else m!==Rt&&(A(!1),ut(m))}function ce(Z){const _e=wi(Z,g,!!W);N(_e.diagnostics),A(_e.conversation)}function xe(Z){k(Z),ce(Z)}function be(Z){_(Z),D(!0)}async function Me(Z){const _e=H.current,$n=SA(Z),Bn=DA(Z);K&&te.dataUrl===K&&te.clear(),V(null),ne("capturing");const Os=await te.captureElement(Z);_e===H.current&&(ne(null),O($n),G(Bn),V(Os),k("bug"),U||ce("bug"))}function ht(){K&&te.dataUrl===K&&te.clear(),O(null),V(null)}function Pn(){I(""),O(null),V(null),Y(!1),ge(void 0),te.clear()}const Ln=qe&&!d&&!te.isPreparing,Fn=x?R||a==null?void 0:a.email:Kc(v)?v.trim():void 0;async function Xt(){!Ln||!await p({kind:y,message:w,...x?{}:{contact:v},includeDiagnostics:E,includeConversation:j,anonymous:R,...W?{crashStack:W}:{},...te.dataUrl?{screenshotDataUrl:te.dataUrl}:{},...L?{element:L}:{},...Fn?{notifyEmail:Fn}:{}})||(x||yp(v),Pn(),t(!1))}function Es(Z){Z.preventDefault(),Xt()}function Is(Z){const _e=nt.current;_e&&(Z.preventDefault(),_e.focus(),_e.setSelectionRange(_e.value.length,_e.value.length))}function Rs(Z){Z.key!=="Enter"||!(Z.metaKey||Z.ctrlKey)||Z.nativeEvent.isComposing||C||(Z.preventDefault(),Xt())}const F=te.handlers,fe=Q!==null,Ts=L?se:null,Lo=mu(Ts),Ds=!!(L&&K&&te.dataUrl===K),Fo=!!te.dataUrl&&!Ds,ju=!qe&&(!!te.dataUrl||L!==null);return n.jsxs(n.Fragment,{children:[fe&&n.jsx(qA,{phase:Q,onSelect:Z=>void Me(Z),onCancel:()=>ne(null)}),n.jsx(et,{open:e&&!fe,onOpenChange:t,children:n.jsxs(tt,{...F,onKeyDown:Rs,desktopProps:{className:"max-w-md",onOpenAutoFocus:Is},className:B("max-h-[85vh] !min-h-0",te.isDraggingOver&&"ring-primary ring-2"),children:[n.jsxs(Qe,{children:[n.jsx($e,{className:"text-sm font-medium",children:"Send feedback"}),n.jsx(Xe,{className:"text-muted-foreground text-xs",children:"Straight to the DorkOS team. Private."})]}),n.jsxs("form",{onSubmit:Es,noValidate:!0,className:"flex min-h-0 flex-1 flex-col gap-4",children:[n.jsxs(it,{alignWithHeader:!0,className:"flex flex-col gap-4",children:[n.jsx(XA,{kind:y,onChange:xe}),n.jsxs("div",{className:B("dark:bg-input/30 flex flex-col rounded-lg border transition-[border-color,box-shadow] duration-150","focus-within:border-ring focus-within:ring-ring focus-within:ring-[3px]",te.isDraggingOver&&"border-primary"),children:[n.jsx(Te,{htmlFor:b,className:"sr-only",children:"Your message"}),n.jsx(xp,{ref:nt,id:b,value:w,onChange:Z=>I(Z.target.value),placeholder:L?MA(Ts):ZA[y],rows:4,maxLength:bp,className:"min-h-24 resize-none rounded-lg border-0 bg-transparent shadow-none focus-visible:ring-0 dark:bg-transparent"}),(L||Fo||te.isPreparing||te.isDraggingOver)&&n.jsxs("div",{className:"flex flex-wrap items-center gap-2 px-2.5 pb-2.5",children:[L&&n.jsx(yi,{imageUrl:Ds?K??void 0:void 0,alt:`The part you pointed at: ${Lo}`,caption:Lo,pointed:!0,detail:L.selector,...Ds?{onOpen:()=>be("screenshot")}:{},onRemove:ht,removeLabel:_A(Ts)}),Fo&&te.dataUrl&&n.jsx(yi,{imageUrl:te.dataUrl,alt:"The screenshot you attached",onOpen:()=>be("screenshot"),onRemove:te.clear,removeLabel:"Remove screenshot"}),(te.isPreparing||te.isDraggingOver)&&n.jsx("p",{role:"status","aria-live":"polite",className:"text-muted-foreground text-xs",children:te.isDraggingOver?"Drop to attach":"Getting it ready…"})]}),n.jsx(YA,{showPictureTools:!0,isPreparing:te.isPreparing,hasPointed:L!==null,hasWords:qe,isMobile:!c,onCapture:()=>void te.capture(),onPointAtElement:()=>ne("picking"),onPick:Z=>void te.attach(Z)})]}),n.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[n.jsx("span",{className:"text-muted-foreground mr-0.5 text-xs",children:"Also send"}),n.jsx(vi,{label:"Diagnostics",summary:"Version, window size, browser, and recent errors.",pressed:E,onPressedChange:Z=>{Y(!0),N(Z)},onPreview:()=>be("diagnostics")}),g&&n.jsx(vi,{label:"This chat",summary:"Shows what led to the bug.",pressed:j,onPressedChange:Z=>{Y(!0),A(Z)},onPreview:()=>be("conversation")})]}),n.jsx(VA,{currentUser:a??null,anonymous:R,onToggleAnonymous:()=>M(Z=>!Z),contact:v,onContactChange:S})]}),n.jsx(JA,{needsWords:ju,canSend:Ln,isSubmitting:d,onOpenGitHubIssue:()=>h(y==="idea"?"feature":"bug")})]}),n.jsx(KA,{open:C,onOpenChange:D,initialTab:T,diagnostics:f(W?{crashStack:W}:void 0),kind:y,route:u,showConversation:g,sessionId:m,...te.dataUrl?{screenshotDataUrl:te.dataUrl}:{}})]})})]})}function t1(){const e=cn(a=>a.open),t=cn(a=>a.prefill),s=cn(a=>a.openFeedback),r=cn(a=>a.setOpen),o=vp();return l.useEffect(()=>{const a=wp();a&&s(a)},[s]),n.jsx(e1,{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=Ae();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 s1(){const{closeActive:e}=jo();l.useEffect(()=>{const t=window.electronAPI;if(t!=null&&t.onCloseTab)return t.onCloseTab(()=>e())},[e])}function r1(){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 ji="window-blurred";function o1(){l.useEffect(()=>{var a,i,c;if(!jp||!((a=window.electronAPI)!=null&&a.onFocusChange))return;const e=document.documentElement,t=d=>{e.classList.toggle(ji,!d)};let s=!0,r=!1;const o=window.electronAPI.onFocusChange(d=>{r=!0,t(d)});return(c=(i=window.electronAPI).getFocusState)==null||c.call(i).then(d=>{s&&!r&&t(d)}),()=>{s=!1,o(),e.classList.remove(ji)}},[])}const a1="/channels";function i1(){_v();const e=kp(),t=ys(),s=e===a1&&!t.community?t.id??null:null,{data:r}=Sp(s),{data:o}=ws(),a=l.useMemo(()=>(o??[]).filter($t).length,[o]);return{room:s&&r?r:null,unreadRoomCount:a}}function c1({unreadRoomCount:e}){Cj();const t=$(c=>c.isStreaming),s=$(c=>c.isWaitingForUser),r=yn(c=>c.schedulesWaitingCount),o=yn(c=>c.needsYouCount),a=ke({select:c=>c.location.href}),i=Zr(a);return Zb(c=>Cp(i,{...c,badgeCount:e+r,needsYou:s||o>0}),t),null}function l1(){const e=Sn(),t=Ss(),s=ie(),r=Ae(),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(m=>[m.ref,{status:m.status,label:m.label,generation:na(m.ref)}]));if(o.current={owner:a,rows:c},!!i)for(const[m,u]of i){if(u.status!=="connected")continue;const f=c.get(m);if((f==null?void 0:f.status)==="connected")continue;const p=rs(vn().destination)===m,h=na(m)>u.generation,g=f===void 0?"removed":"revoked";(h?Promise.resolve():Np(s,e,m,g)).then(()=>{p&&rs(vn().destination)===m&&r({...he.home(),replace:!0})}),g==="revoked"&&ae(`This DorkOS can no longer reach ${u.label}.`,{description:"Still a member? Pick it in the sidebar switcher to reconnect."})}},[e,t.data,r,s])}function d1(){l1(),qy(),Ap()}function u1({isFullscreen:e}){return n.jsx("div",{className:B("desktop-darwin:block app-drag-region hidden shrink-0",!e&&"desktop-darwin:h-11"),"aria-hidden":"true"})}class m1 extends l.Component{constructor(){super(...arguments);Jt(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 h1=5e3;function hu({testId:e,headline:t,detail:s}){const{isFetching:r,refetch:o}=Ee({refetchInterval:h1});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(Ge,{size:120,className:"mb-8 opacity-80 dark:hidden"}),n.jsx(Ge,{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(P,{variant:"outline",className:"mt-6",onClick:()=>void o(),disabled:r,children:r?"Trying…":"Try again"})]})})}function f1(){return n.jsx(hu,{testId:"server-unreachable",headline:"DorkOS can’t reach its server",detail:"It may still be starting up. DorkOS keeps checking."})}const p1="onboarding";function g1({render:e}){const t=Ep(),s=Ip(),{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:p1}),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 x1={renderAccountLink:e=>n.jsx(g1,{render:e}),renderRuntimeConnect:Wg,renderOtherService:({onSave:e})=>n.jsx(Gg,{onSave:e})},b1="HOST_NOT_ALLOWED",ki=240;function y1({status:e,message:t,code:s}){const r=s===b1&&t?t:void 0,o=r===void 0?`Your settings didn’t load (HTTP ${e}). DorkOS keeps trying.`:r.length>ki?`${r.slice(0,ki).trimEnd()}…`:r;return n.jsx(hu,{testId:"server-error",headline:"The server answered with an error",detail:o})}function v1(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 rr={at:0};function w1(e,t){return e>rr.at&&(rr=t==null?{at:e}:{at:e,...v1(t)}),e>Bt?rr:void 0}function j1(e){return e.state.dataUpdatedAt>Bt?!0:"always"}function k1(e){return!e}function S1(e){var t;return((t=e.at(-1))==null?void 0:t.pathname)??""}function C1({descriptors:e}){const t=e.reduce((s,r)=>s===null||r.priority>s.priority?r:s,null);return n.jsx(Fe,{mode:"wait",initial:!1,children:t&&n.jsx(X.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 N1=["memory-provider-status"],A1=6e4;function E1(){const e=oe(),{data:t}=ye({queryKey:[...N1],queryFn:()=>e.getMemoryProviderStatus(),staleTime:A1,refetchOnWindowFocus:!0});return t}function I1(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||R1(s,r))&&t.set(s.subject.id,s)}return[...t.entries()].filter(([,s])=>s.outcome!=="cleared").map(([s])=>s)}function R1(e,t){return e.createdAt!==t.createdAt?e.createdAt>t.createdAt:e.id>t.id}function T1({configuredId:e,benched:t}){return n.jsxs(sl,{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 D1="runtimes",O1=3;function M1({runtimes:e}){const{open:t}=Ke(),s=Rp();if(e.length===0)return null;const r=e.slice(0,O1).map(Hc),o=e.length-r.length,a=e.length===1?`${r[0]} sign-in`:`${P1(r)} sign-ins`,i=o>0?`, and ${o} more`:"";return n.jsxs(sl,{variant:"critical",icon:hr,actions:n.jsxs(n.Fragment,{children:[s&&n.jsx(_1,{runtimes:e,renderCreditsOffer:s}),n.jsx(P,{variant:"outline",size:"sm",onClick:()=>t(D1),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 _1({runtimes:e,renderCreditsOffer:t}){var d;const s=Wi(),{data:r}=qi(),o=!qg(),a=((d=pc().data)==null?void 0:d.linked)===!0,i=Tp(a,gc({enabled:a}).data),c=e.find(m=>Dp(Op(s.data,m),r,m)==="lead");return c?n.jsxs(Nn,{children:[n.jsx(An,{asChild:!0,children:n.jsx(P,{size:"sm","data-testid":"signin-banner-credits",disabled:i===null,children:i===null?"DorkOS credits":`${i} DorkOS credits`})}),n.jsxs(En,{align:"end",className:"w-80 p-4",children:[n.jsxs(In,{children:["Run ",Hc(c)," on DorkOS credits"]}),n.jsxs("div",{className:"space-y-3",children:[t({runtime:c,origin:`signin-banner:${c}`,fullWidth:!0}),n.jsx(Yg,{remote:o})]})]})]}):null}function P1(e){return e.length<=1?e[0]??"":`${e.slice(0,-1).join(", ")} and ${e[e.length-1]}`}const fu={critical:40,warning:30};function L1(){const e=E1();return!e||e.configuredId===e.activeId?null:{id:"memory-provider-benched",variant:"warning",priority:fu.warning,render:()=>n.jsx(T1,{configuredId:e.configuredId,benched:e.benched})}}const F1={kinds:["signin.required"]};function $1(){const{notifications:e}=Mp(F1),t=l.useMemo(()=>I1(e),[e]);return t.length===0?null:{id:"runtime-signin",variant:"critical",priority:fu.critical,render:()=>n.jsx(M1,{runtimes:t})}}function B1(e){const t=L1(),s=$1();return[t,s].filter(r=>r!==null)}function z1(){const e=On(),[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(Wc,{children:[n.jsx(Gc,{children:"Share anonymous usage data?"}),n.jsx(qc,{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(ax,{open:t,onToggle:()=>s(a=>!a)}),n.jsx("a",{href:ur("/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(ix,{})]}),n.jsxs(Yc,{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(P,{variant:"outline",size:"sm",onClick:r,disabled:e.isPending,children:"Don’t share"}),n.jsx(P,{size:"sm",onClick:o,disabled:e.isPending,children:"Share anonymously"})]})]})]})}const U1=Fc("/guides/permissions#what-changed"),K1=["Everything they do is recorded in Activity. Anyone can pause an agent.","Messages and code from strangers still need your yes."];function H1(e){return e instanceof Error&&e.message||"Couldn’t save that. Try again."}function W1({onClose:e}){const t=On(),s=yx({kind:"default"}),[r,o]=l.useState(!1),[a,i]=l.useState(null),c=r||t.isPending||s.isPending,d=async m=>{i(null),o(!0);try{m&&await s.mutateAsync({kind:"preset",preset:"careful",surface:"first-run"}),await t.mutateAsync({ui:{trustNoticeSeenAt:new Date().toISOString()}})}catch(u){i(H1(u)),o(!1);return}o(!1),m&&ae.success("Agents ask first again. Change it in Permissions."),e()};return n.jsxs(n.Fragment,{children:[n.jsxs(Wc,{children:[n.jsx(Gc,{"data-testid":"trust-notice",children:"Agents now work without asking"}),n.jsx(qc,{children:"They edit files, run commands and schedule work on their own."})]}),n.jsx("div",{className:"text-muted-foreground space-y-2 text-sm",children:K1.map(m=>n.jsx("p",{children:m},m))}),a&&n.jsx("p",{role:"alert",className:"text-destructive text-xs",children:a}),n.jsxs(Yc,{className:"items-center gap-2 sm:justify-between",children:[n.jsx(_p,{href:U1,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(P,{variant:"outline",size:"sm",onClick:()=>d(!0),disabled:c,children:"Keep asking me"}),n.jsx(P,{size:"sm",onClick:()=>d(!1),disabled:c,children:"Got it"})]})]})]})}function G1(e){var s,r,o,a;return!e||!(((s=e.onboarding)==null?void 0:s.completedAt)!=null||((r=e.onboarding)==null?void 0:r.dismissedAt)!=null)||((o=e.ui)==null?void 0:o.trustNoticeSeenAt)!=null?!1:Cx((a=e.permissions)==null?void 0:a.preset)==="trusted"}const pu={high:30,low:10};function q1(){var t;const{data:e}=Ee();return(t=e==null?void 0:e.telemetry)!=null&&t.userHasDecided?null:{id:"telemetry-consent",priority:pu.low,render:()=>n.jsx(z1,{})}}function Y1(){const{data:e}=Ee();return G1(e)?{id:"trust-notice",priority:pu.high,render:({onClose:t})=>n.jsx(W1,{onClose:t})}:null}function V1(){const e=Y1(),t=q1();return $(r=>r.onboardingHiddenForSession)?[]:[e,t].filter(r=>r!==null)}function Q1(e){return e.reduce((t,s)=>t===null||s.priority>t.priority?s:t,null)}function X1({onboardingOverlayVisible:e=!1}){const t=V1(),{data:s,dataUpdatedAt:r}=Ee(),o=$(y=>y.momentShownThisLaunch),a=$(y=>y.markMomentShown),[i,c]=l.useState(null),[d,m]=l.useState(null),u=l.useRef(null),f=(s==null?void 0:s.onboarding)!=null&&(s.onboarding.completedAt!=null||s.onboarding.dismissedAt!=null),p=r>Bt,h=e||!p||!f,g=h?null:Q1(t);i===null&&g!==null&&!o&&(c(g.id),m(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(Pp,{open:x,onOpenChange:y=>{y||b()},children:d!==null&&n.jsx(Lp,{ref:u,onOpenAutoFocus:y=>{var k;y.preventDefault(),(k=u.current)==null||k.focus()},children:d.render({onClose:b})},d.id)})}const J1=[];function Z1(){const{approvals:e,isError:t,retry:s}=Fp(),{interactions:r}=$p(),o=Bp(),a=zp(e),i=Up(r),c=Ae(),d=l.useMemo(()=>[...e.map(u=>Kp(u.approvalId)),...r.map(u=>Hp(u.interaction.id))],[e,r]);return!t&&a.length===0&&r.length===0&&o.length===0?{slot:null,coveredSignalIds:J1}:{coveredSignalIds:d,slot:n.jsxs("div",{"data-testid":"mobile-now-attention",className:"flex flex-col gap-2 px-2 pt-0.5 pb-1",children:[t&&n.jsx(Wp,{onRetry:s}),(r.length>0||o.length>0)&&n.jsx(Gp,{asks:r,agentNames:i,onOpenSession:u=>{c(vt({session:u}))}}),a.length>0&&n.jsx(qp,{approvals:a})]})}}const gu=[{id:"home",label:"Home",icon:Yp,badged:!0,kind:"panel"},{id:"library",label:"All",icon:co,badged:!1,kind:"panel"},{id:"dorkbot",label:"DorkBot",icon:uo,badged:!1,kind:"action"},{id:"you",label:"You",icon:Hr,badged:!1,kind:"panel"}],eE=Vc.filter(e=>e==="library"),tE=Vc.filter(e=>e!=="library"),Pr="calc(3.5rem + env(safe-area-inset-bottom))",us=Vp(e=>({panelUp:!1,raise:()=>e({panelUp:!0}),lower:()=>e({panelUp:!1})}));function Si(){us.getState().lower()}function nE({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:Pr,paddingBottom:"env(safe-area-inset-bottom)"},children:gu.map(a=>{const i=a.icon,c=a.id===e,d=a.badged&&t>0?t:null,m=a.kind==="action"&&!s;return n.jsxs("button",{type:"button",onClick:()=>r(a.id),disabled:m,"aria-current":c?"page":void 0,"data-testid":`mobile-tab-${a.id}`,"data-mobile-tab":"",className:B("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 or({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:B("absolute inset-0",!t&&"invisible"),children:s})}function sE({takeover:e}){Gd();const t=Z1(),s=Vd({coveredSignalIds:t.coveredSignalIds}),r=qd(s),{ask:o,ready:a}=Qp(),[i,c]=l.useState("home"),d=us(x=>x.panelUp),m=us(x=>x.raise),u=Ut();l.useEffect(()=>u.subscribe("onBeforeLoad",Si),[u]),l.useEffect(()=>Si,[]),l.useEffect(()=>(document.documentElement.style.setProperty("--mobile-tab-dock",Pr),()=>{document.documentElement.style.removeProperty("--mobile-tab-dock")}),[]);const f=l.useCallback(x=>{const b=gu.find(y=>y.id===x);if(b!==void 0){if(b.kind==="action"){if(!a)return;c(x),o();return}c(x),m()}},[o,a,m]),p=r.zones.find(x=>x.id==="now"),h=(p==null?void 0:p.needsYouCount)??s.attention.length,g=nu((p==null?void 0:p.liveRegionText)??Xp(h));return n.jsxs(_c,{activeTarget:s.activeTarget,children:[n.jsxs("div",{"data-testid":"mobile-tab-panels",inert:!d,className:B("bg-background fixed inset-x-0 top-0 z-30",!d&&"pointer-events-none invisible"),style:{bottom:`calc(${Pr} + var(--pip-dock, 0px))`},children:[n.jsx(or,{id:"home",active:i==="home",children:n.jsxs(zs,{width:"full",className:"px-3 py-2",children:[n.jsx(au,{}),n.jsx(Mr,{model:r,zoneIds:tE,nowSlot:t.slot,silenceLiveRegion:!0}),n.jsx(Wd,{model:r})]})}),n.jsx(or,{id:"library",active:i==="library",children:n.jsx(zs,{width:"full",className:"px-3 py-2",children:e??n.jsx(Mr,{model:r,zoneIds:eE,silenceLiveRegion:!0})})}),n.jsx(or,{id:"you",active:i==="you",children:n.jsxs(zs,{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(NN,{}),n.jsx(Qc,{})]})})]}),n.jsx("span",{"data-testid":"mobile-needs-you-live-region","aria-live":"polite","aria-atomic":"true",className:"sr-only",children:g}),n.jsx(nE,{current:d?i:null,needsYouCount:h,dorkBotReady:a,onSelect:f})]})}function rE(){const{open:e}=Ke(),t=$(r=>r.setControlCenterOpen),s=As(()=>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(cx,{surface:"control-center"}),n.jsxs(P,{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(Kt,{className:"size-3.5","aria-hidden":!0})]})]})}const Dt={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 oE(){var u,f;const e=Cs(),t=no(),s=$(p=>p.setRemoteAccessOpen),r=$(p=>p.setControlCenterOpen),a=As(()=>r(!1))(()=>s(!0)),i=e.isSetUp,c=e.state==="starting"||e.state==="stopping",d=e.hasServerReport;let m;return d?i?e.error!==null?m=n.jsxs("span",{className:"flex min-w-0 items-baseline gap-1.5",children:[n.jsx("span",{className:"text-destructive truncate",children:Zc(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"?m=n.jsxs("span",{className:"flex min-w-0 items-baseline gap-1.5",children:[n.jsx("span",{className:"text-status-warning-fg truncate",children:((u=e.managed)==null?void 0:u.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"?m=`On · ${e.host??"connected"}`:e.state==="asleep"?m=e.host?`Closed for now · ${e.host}`:"Closed for now":e.state==="draining"?m=Dt.draining:e.state==="reconnecting"?m=e.host?`On · ${e.host} · reconnecting…`:"Reconnecting…":e.state==="starting"?m=Dt.starting:e.state==="stopping"?m=Dt.stopping:m=Dt.off:m=Dt.unconfigured:m=Dt.off,d&&((f=e.managed)!=null&&f.cloudStale)&&typeof m=="string"&&(m=`${m} · Can’t reach DorkOS Cloud`),n.jsx(Xc,{label:"Remote access",description:n.jsx("span",{"data-testid":"remote-access-row-description",className:B("block min-w-0",c&&"motion-safe:animate-breath"),children:m}),children:n.jsx(Jc,{checked:i&&e.isChecked,disabled:!d||i&&e.isTransitioning,"aria-label":"Remote access",onCheckedChange:p=>{if(!i){a();return}t.toggle(p)}})})}const aE=1,iE=10,cE=4;function lE(){var d,m;const{data:e}=Ee(),t=On(),s=ie(),{limits:r,setLimits:o}=Jp(),a=()=>void s.invalidateQueries({queryKey:Ne.all}),i=((d=e==null?void 0:e.claudeCode)==null?void 0:d.persistentSession)??!0,c=((m=e==null?void 0:e.scheduler)==null?void 0:m.maxConcurrentRuns)??cE;return n.jsx(Zp,{children:n.jsxs(eg,{children:[n.jsx(oE,{}),n.jsx(Xx,{}),n.jsx(sa,{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(ca,{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:u=>o({turnLimitsEnabled:u})}),n.jsx(sa,{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(ca,{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:u=>t.mutate({runtimes:{claudeCode:{persistentSession:u}}},{onSuccess:a})}),n.jsx(Xc,{label:"Scheduled runs at once",description:"How many scheduled tasks run together.",children:n.jsx(lx,{value:c,min:aE,max:iE,"aria-label":"Scheduled runs at once",onCommit:u=>t.mutate({scheduler:{maxConcurrentRuns:u}},{onSuccess:a})})})]})})}const Ci="claude-code";function dE(){var R,M,E,N,j;const{data:e}=Ee(),{data:t}=Gi(),{sessions:s}=wc(),r=tg(),{data:o}=mc(r),{data:a}=Zg(),i=vx(),c=i.data,d=Fw(),m=Gr(),{open:u}=Ke(),{open:f}=lo(),p=Kr(),h=$(A=>A.setControlCenterOpen),g=As(()=>h(!1)),x=i.isError,b=t===void 0||e===void 0||c===void 0&&!x,y=e==null?void 0:e.executionDefaults,k=(y==null?void 0:y.runtime)??Ci,w=(R=t==null?void 0:t.capabilities[k])==null?void 0:R.permissionModes,I=((M=w==null?void 0:w.values.find(A=>A.id===w.default))==null?void 0:M.stop)??"ask",v=(y==null?void 0:y.trustStop)??I,S=[];if(!b){for(const C of(y==null?void 0:y.perRuntime)??[])C.trustStop===null||C.trustStop===v||S.push({key:`runtime:${C.runtime}`,kind:"runtime",name:We(C.runtime).label,detail:Fs(C.trustStop),onOpen:m?g(()=>u("runtimes")):null});for(const C of s){const D=(E=t==null?void 0:t.capabilities[C.runtime])==null?void 0:E.permissionModes,T=D==null?void 0:D.values.find(L=>L.id===C.permissionMode),_=T==null?void 0:T.stop;!_||_===v||S.push({key:`session:${C.id}`,kind:"session",name:C.title||"Untitled chat",detail:(T==null?void 0:T.label)??$s(C.permissionMode),onOpen:m?g(()=>m(vt({session:C.id,dir:C.cwd}))):null})}const A=((j=(N=t==null?void 0:t.capabilities[Ci])==null?void 0:N.permissionModes)==null?void 0:j.values)??[];for(const C of o??[]){const D=A.find(_=>_.id===C.permissionMode),T=D==null?void 0:D.stop;!T||T===v||S.push({key:`task:${C.id}`,kind:"task",name:C.displayName??C.name,detail:(D==null?void 0:D.label)??$s(C.permissionMode),onOpen:m?g(()=>m({...he.tasks()})):null})}for(const C of a??[]){const D=A.find(_=>_.id===C.permissionMode),T=D==null?void 0:D.stop;!T||T===v||S.push({key:`binding:${C.id}`,kind:"binding",name:C.label||C.adapterId,detail:(D==null?void 0:D.label)??$s(C.permissionMode),onOpen:m?g(()=>p({app:C.adapterId})):null})}}if(c){const A=new Map(c.areas.map(T=>[T.id,T.label])),C=new Map(c.areas.flatMap(T=>T.actions.map(_=>[_.id,_.title]))),D=T=>g(()=>f(T,"permissions"));for(const T of c.exceptions){const _=T.action?C.get(T.action)??T.action:A.get(T.area),L=wx[T.state];S.push({key:`agent-permission:${T.agentId}:${T.action??T.area}`,kind:"agent-permission",name:T.agentName,detail:`${_??T.area} ${L}`,why:{question:`Why is ${_??T.area} set to ${L} for ${T.agentName}?`,sentence:jx({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)S.push({key:`agent-permission:${T.agentId}:files`,kind:"agent-permission",name:T.agentName,detail:`Files & commands ${Fs(T.stop)}`,why:{question:`Why is Files & commands set to ${Fs(T.stop)} for ${T.agentName}?`,sentence:kx(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:S,isEmpty:!b&&!x&&S.length===0,isResolving:b,permissionsUnreadable:x}}const uE={runtime:cb,session:ng,task:po,binding:Yi,"agent-permission":ub};function mE(){const{rows:e,isEmpty:t,isResolving:s,permissionsUnreadable:r}=dE();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=uE[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(Kt,{className:"text-muted-foreground/60 size-3.5 shrink-0","aria-hidden":!0})]}),o.why?n.jsx(Sx,{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(P,{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(sg,{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 hE(){const e=cl();return ll(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(Ml,{className:"mt-px size-3 shrink-0","aria-hidden":!0}),n.jsxs("span",{children:["Keeping this computer awake: ",dl(e.working),"."]})]}):null}function fE(){return n.jsxs("div",{className:"flex flex-col gap-4","data-testid":"control-center-body",children:[n.jsx(rE,{}),n.jsx(lE,{}),n.jsx(mE,{}),n.jsx(hE,{})]})}function pE(){const e=$(r=>r.controlCenterOpen),t=$(r=>r.setControlCenterOpen),s=je();return n.jsxs(Nn,{open:e,onOpenChange:t,modal:!0,autoFocus:!0,children:[n.jsx(An,{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(ra,{className:"size-4","aria-hidden":!0})})}),n.jsxs(En,{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(ra,{className:"text-status-success size-4 shrink-0","aria-hidden":!0}),n.jsx("h2",{className:"text-sm font-semibold",children:"Control Center"})]}),n.jsx(In,{children:"Control Center"}),n.jsx(fE,{})]})]})}function gE(){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 xE(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 bE({url:e}){const t=Ue();return n.jsxs("div",{"data-testid":"remote-access-qr",children:[n.jsx(X.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(rg,{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}=Cn();let o,a;return t?(o=n.jsx(Nt,{className:"size-3.5"}),a="Copied"):s?(o=n.jsx(Oe,{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(P,{variant:"outline",size:"sm",className:"mt-2 w-full gap-1.5",onClick:()=>void r(e),children:[o,a]})]})}function vE(){const e=Cs(),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 wE({onClose:e}){const t=Cs(),s=no(),r=je(),o=$(f=>f.setRemoteAccessOpen),a=As(e),i=t.url,c=t.mode==="managed",d=i?n.jsx(yE,{url:i},"link"):null,m=i?n.jsx(bE,{url:i},"qr"):null,u=r?[d,m]:[m,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:B("inline-block size-2 shrink-0 rounded-full",el(t.state)),"aria-hidden":!0}),n.jsx("h2",{className:"text-sm font-semibold",children:tl(t.state)})]}),t.error!==null&&n.jsx("p",{role:"alert","data-testid":"remote-access-panel-error",className:"text-destructive text-xs",children:Zc(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."}),u,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(Jc,{checked:t.isChecked,disabled:t.isTransitioning,"aria-label":"Remote access",onCheckedChange:f=>void s.toggle(f)})]}),n.jsx(P,{variant:"ghost",size:"sm",className:"text-muted-foreground hover:text-foreground -mx-1 justify-start",onClick:a(()=>o(!0)),children:"Manage…"})]})}function xu(e,t){return e==="starting"?"Remote access is connecting":e==="reconnecting"?"Remote access is reconnecting":e==="stopping"?"Remote access is turning off":e==="draining"?"Remote access is closing":e==="asleep"?t?`Remote access is closed for now at ${t}`:"Remote access is closed for now":t?`Remote access is on at ${t}`:"Remote access is on"}function jE(e,t){const s=e==="starting"||e==="asleep"&&!t?"Open remote access":"Show link and QR code";return`${xu(e,t)}. ${s}`}function kE(){const e=Cs(),t=$(i=>i.remoteAccessBeaconOpen),s=$(i=>i.setRemoteAccessBeaconOpen),r=Ue(),o=xE(e.state,e.hasServerReport);l.useEffect(()=>{!e.isLive&&t&&s(!1)},[e.isLive,t,s]);const a=e.isLive?xu(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(Nn,{open:t,onOpenChange:s,modal:!0,children:[n.jsx(An,{asChild:!0,children:n.jsxs("button",{type:"button","data-testid":"remote-access-beacon","data-state-name":e.state,"aria-label":jE(e.state,e.host),className:B("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(Ec,{className:B("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:B("border-background absolute right-0.5 bottom-0.5 size-1.5 rounded-full border",el(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(En,{side:"bottom",align:"end","aria-label":"Remote access",className:"w-72 max-w-[calc(100vw-1.5rem)] p-3",children:[n.jsx(In,{children:tl(e.state)}),n.jsx(wE,{onClose:()=>s(!1)})]})]})]})}function SE({work:e}){const{isDesktop:t}=og();return t?n.jsxs("p",{className:"text-sm font-medium",children:["Keeping awake: ",e]}):n.jsxs(In,{className:"text-sm font-medium",children:["Keeping awake: ",e]})}function CE(){const e=cl(),{open:t}=Ke(),[s,r]=l.useState(!1);if(!ll(e))return null;const o=dl(e.working);return n.jsxs(Nn,{open:s,onOpenChange:r,children:[n.jsx(An,{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(Ml,{className:"size-4","aria-hidden":!0})})}),n.jsxs(En,{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(SE,{work:o}),n.jsx("p",{className:"text-muted-foreground text-xs",children:dx}),n.jsx(P,{variant:"outline",size:"sm",onClick:()=>{r(!1),t(ia.tab,ia.section)},children:"Sleep settings"})]})]})}function NE(){const e=oe(),t=ie();return Ct({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 AE(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 EE({step:e,templateName:t,seedDisplayName:s=null,faceSeed:r=null,runtimeSeed:o="claude-code"}){var J;const a=oe(),{data:i}=ye({queryKey:Ne.current(),queryFn:()=>a.getConfig(),staleTime:3e4}),c=((J=i==null?void 0:i.agents)==null?void 0:J.defaultDirectory)??"",[d,m]=l.useState(""),[u,f]=l.useState(!1),[p,h]=l.useState(""),[g,x]=l.useState(!1),[b,y]=l.useState(!1),[k,w]=l.useState(null),[I,v]=l.useState(""),[S,R]=l.useState(!1),[M,E]=l.useState(o),[N,j]=l.useState(s);s!==N&&(j(s),s&&(m(s),f(!1)));const[A,C]=l.useState(o);o!==A&&(C(o),E(o));const D=l.useMemo(()=>d?ag(d):"",[d]),T=l.useMemo(()=>D?ig(D):{valid:!1,error:void 0},[D]),_=d.length>0&&D.length>0&&!T.valid,L=p||(c&&D?`${c}/${D}`:""),O=e!=="naming"||!L?"idle":k!==null&&k.directory===L?k.status:"checking",K=d.length>0&&T.valid&&O!=="error",V=l.useRef(null);l.useEffect(()=>{if(e!=="naming")return;const ee=t?!d||u?t.replace(/^@[^/]+\//,""):null:u?"":null;if(ee===null)return;const H=`${e}|${t??""}`;V.current!==H&&(V.current=H,m(ee),f(!!t))},[e,t]);const se=l.useRef(null);l.useEffect(()=>{if(e!=="naming"||S||!r)return;const ee=`${e}|${r}`;se.current!==ee&&(se.current=ee,v(r))},[e,r]),l.useEffect(()=>{if(e!=="naming"||!L)return;const ee=L,H=setTimeout(()=>{AE(a,ee).then(U=>{w({directory:ee,status:U})})},500);return()=>clearTimeout(H)},[e,L,a]);function G(ee){m(ee),u&&f(!1)}function Q(ee){v(ee),R(!0)}function ne(){V.current=null,se.current=null,m(""),f(!1),h(""),x(!1),y(!1),w(null),v(""),R(!1),E(o)}return{displayName:d,slug:D,handleNameChange:G,nameAutoFilled:u,slugValidation:T,showSlugError:_,defaultDirectory:c,resolvedDirectory:L,directoryOverride:p,setDirectoryOverride:h,directoryOpen:g,setDirectoryOpen:x,directoryPickerOpen:b,setDirectoryPickerOpen:y,conflictStatus:O,canSubmit:K,icon:I,setIcon:Q,runtime:M,setRuntime:E,reset:ne}}function IE(e){var a;const t=(e==null?void 0:e.packageName)??null,{data:s,isError:r,error:o}=fx(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&&px(o)&&{refusal:o},...s!=null&&s.disclosed&&s.contentHash?{approval:{approvedDisclosure:s.disclosed,approvedContentHash:s.contentHash},packageAgentName:s.manifest.name}:{}}}const RE={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."}},ar={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"]},TE=[["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 DE(e){if(!e)return ar.default;const t=[e.name,e.description,e.category,...e.tags??[]].filter(Boolean).join(" ").toLowerCase();for(const[s,r]of TE)if(r.some(o=>t.includes(o)))return ar[s];return ar.default}function OE(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 ME=64,_E=16,Ni=3;function PE(e){return e.map(t=>t.replace(/[\u0000-\u001f\u007f]/g," ").replace(/\s+/g," ").trim().slice(0,ME)).filter(t=>t.length>0).slice(0,_E)}function LE(e){const t=PE(e.capabilities??[]),s=t.length>0?`
85
+
86
+ 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 ${Mt.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 ${Mt.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(`
87
+ `)}function FE(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 ${Mt.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 ${Ni} 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 ${Ni} 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 ${Mt.soul} now, using your file-editing tools. It lives at \`.dork/${Mt.soul}\` in your working directory and already contains a "Personality Traits" block fenced by \`${cg}\` and \`${oa}\` — leave that fenced block exactly as it is. Replace only the prose BELOW the \`${oa}\` 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 ${Mt.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(`
88
+ `)}const $E={template:LE,"design-your-own":FE};function BE(e,t){return $E[e](t)}function zE(e,t){return Ix(BE(e,t))}const bu="🤖",UE=["🤖","🦾","🧭","🛰️","📡","🔭","🗺️","🧠","🦉","🦊","🐝","🐙","🚀","⚡","🌟","🔮","🛠️","🔧","📊","📋","✅","🗂️","🔔","🛡️"];function Ai({face:e,title:t,subtitle:s,chips:r,variant:o,tabIndex:a,onSelect:i,onKeyDown:c,ref:d,"data-testid":m}){return n.jsxs("button",{ref:d,type:"button",tabIndex:a,onClick:i,onKeyDown:c,"data-gallery-card":"","data-testid":m,className:B("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(u=>n.jsx("span",{className:"bg-muted text-muted-foreground text-2xs rounded-full px-2 py-0.5",children:u},u))})]})}function KE(e){return{source:e.source,name:e.name,displayName:nl(e),description:e.description,icon:e.icon,tags:e.tags,category:e.category,packageName:e.name,...e.marketplace?{marketplace:e.marketplace}:{}}}function HE(e){return e.tags&&e.tags.length>0?e.tags.slice(0,2):e.category?[e.category]:[]}function WE(e){const t=e.replace(/\/+$/,"");return t.split("/").pop()??t}function GE({onDesignYourOwn:e,onSelectTemplate:t,onImport:s}){const{data:r,error:o,isLoading:a}=lg(),i=pl(a),[c,d]=l.useState(""),[m,u]=l.useState(!1),f=l.useMemo(()=>(r??[]).filter(h=>h.type==="agent"),[r]),p=ny(f.length+1);return n.jsxs("div",{className:"space-y-5",children:[n.jsxs("div",{role:"group","aria-label":"Choose what your agent will do",className:"grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4","data-testid":"agent-gallery",children:[n.jsx(Ai,{ref:p.setRef(0),variant:"design",face:n.jsx(uo,{className:"text-primary size-7"}),title:"Design your own",subtitle:"Describe the job in your own words.",tabIndex:p.tabIndexFor(0),onSelect:e,onKeyDown:h=>p.handleKeyDown(h,0),"data-testid":"gallery-design-your-own"}),f.map((h,g)=>{const x=g+1;return n.jsx(Ai,{ref:p.setRef(x),variant:"template",face:h.icon??bu,title:nl(h),subtitle:h.description??"A ready-made agent.",chips:HE(h),tabIndex:p.tabIndexFor(x),onSelect:()=>t(KE(h)),onKeyDown:b=>p.handleKeyDown(b,x),"data-testid":`gallery-template-${h.name}`},h.name)}),i&&f.length===0&&Array.from({length:2}).map((h,g)=>n.jsx(xt,{className:"h-28 rounded-xl","data-testid":"gallery-skeleton"},g))]}),!i&&f.length===0&&n.jsx("p",{className:"text-muted-foreground text-center text-xs","data-testid":"gallery-templates-note",children:o?"Couldn’t load ready-made agents. Check marketplace sources in Settings.":"No ready-made agents yet. Add a marketplace source in Settings."}),n.jsxs(mo,{open:m,onOpenChange:u,children:[n.jsx(ho,{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(At,{className:B("size-3.5 transition-transform",m&&"rotate-180")}),"Build from a template URL"]})}),n.jsx(fo,{children:n.jsxs("div",{className:"flex items-center gap-2 pt-2",children:[n.jsx(Ze,{value:c,onChange:h=>d(h.target.value),placeholder:"github.com/org/repo","data-testid":"custom-url-input",className:"flex-1"}),n.jsx(P,{size:"sm",disabled:!c,onClick:()=>{const h=WE(c);t({source:c,name:h,displayName:dg(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(ug,{className:"size-4"}),"Bring in an existing project folder",n.jsx("span",{"aria-hidden":!0,children:"→"})]})})]})}function qE({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:UE.map(s=>{const r=s===e;return n.jsx("button",{type:"button","aria-label":`Face ${s}`,"aria-pressed":r,onClick:()=>t(s),className:B("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 YE({value:e,onChange:t}){return n.jsx("div",{role:"radiogroup","aria-label":"Runs on",className:"flex gap-1.5","data-testid":"runtime-picker",children:mg.map(s=>{const r=We(s),o=r.icon,a=e===s;return n.jsxs("button",{type:"button",role:"radio","aria-checked":a,onClick:()=>t(s),className:B("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 VE({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:B("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:B("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 yu({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(po,{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}),": ",gx(r)]},`${r.name}-${o}`))})]}),t&&n.jsxs("div",{className:"flex items-start gap-2","data-testid":`${s}-offer-check-failed`,children:[n.jsx(Li,{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 Ei=4;function QE({form:e,suggestionPool:t,jobLine:s,previewCapabilities:r,onBack:o,onImportInstead:a,onCreate:i,isCreating:c,packageSchedules:d=[],offerCheckFailed:m=!1,isCheckingOffer:u=!1,offerRefusal:f,packageDirectory:p,templateReview:h,inheritance:g,isCheckingInheritance:x=!1}){const b=l.useRef(null),[y,k]=l.useState(0),w=e.displayName.trim().toLowerCase(),I=t.filter(M=>M.toLowerCase()!==w),v=OE(I,y,Ei);l.useEffect(()=>{const M=setTimeout(()=>{var E;return(E=b.current)==null?void 0:E.focus()},160);return()=>clearTimeout(M)},[]);const S=e.displayName.trim(),R=c?`Creating ${S||"your agent"}…`:`Create ${S||"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(dc,{className:"size-3.5"}),"Choose a different agent"]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(Te,{htmlFor:"agent-name",className:"text-sm",children:"Name"}),n.jsx(Ze,{ref:b,id:"agent-name",placeholder:"Name your agent",value:e.displayName,onChange:M=>e.handleNameChange(M.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:()=>k(M=>M+Ei),"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(M=>n.jsx("button",{type:"button",onClick:()=>e.handleNameChange(M),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-${M}`,children:M},M))})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsxs("div",{className:"flex items-baseline gap-2",children:[n.jsx(Te,{className:"text-sm",children:"Face"}),!e.icon&&n.jsx("span",{className:"text-muted-foreground text-xs",children:"Picked for you if skipped"})]}),n.jsx(qE,{value:e.icon,onChange:e.setIcon})]}),n.jsxs(mo,{open:e.directoryOpen,onOpenChange:e.setDirectoryOpen,children:[n.jsx(ho,{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(At,{className:B("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(fo,{children:n.jsxs("div",{className:"space-y-4 pt-3",children:[n.jsxs("div",{className:"space-y-1.5",children:[n.jsx(Te,{className:"text-muted-foreground text-xs",children:"Runs on"}),n.jsx(YE,{value:e.runtime,onChange:e.setRuntime})]}),p?n.jsxs("div",{className:"space-y-1.5","data-testid":"package-directory",children:[n.jsx(Te,{className:"text-muted-foreground text-xs",children:"Directory"}),n.jsx("p",{className:"font-mono text-xs [overflow-wrap:anywhere]",children:p}),n.jsx("p",{className:"text-muted-foreground text-xs",children:"Kept in its package’s folder so updates reach it."})]}):n.jsxs("div",{className:"space-y-1.5",children:[n.jsx(Te,{htmlFor:"agent-directory",className:"text-muted-foreground text-xs",children:"Directory"}),n.jsx(wb,{id:"agent-directory",placeholder:e.resolvedDirectory||(e.defaultDirectory?`${e.defaultDirectory}/…`:""),value:e.directoryOverride,onChange:e.setDirectoryOverride,onBrowse:()=>e.setDirectoryPickerOpen(!0),browseTestId:"browse-directory-button","data-testid":"directory-preview"}),e.conflictStatus==="no-path"&&n.jsx("p",{className:"text-muted-foreground text-xs","data-testid":"conflict-status",children:"Creates a new folder"}),e.conflictStatus==="exists-no-dork"&&n.jsx("p",{className:"text-muted-foreground text-xs","data-testid":"conflict-status",children:"That folder is already there. The project goes inside it."}),e.conflictStatus==="error"&&n.jsx("p",{className:"text-destructive text-xs","data-testid":"conflict-status",children:"Can’t open this folder. Pick another."})]}),!p&&e.slug&&!e.showSlugError&&n.jsxs("p",{className:"text-muted-foreground text-xs",children:["Folder name:"," ",n.jsx("code",{className:"bg-muted rounded px-1 py-0.5 font-mono text-xs",children:e.slug})]})]})})]})]}),n.jsxs("div",{className:"flex flex-col gap-4 self-start",children:[n.jsx(VE,{face:e.icon||bu,name:e.displayName,jobLine:s,capabilities:r}),(d.length>0||m)&&n.jsx("dl",{className:"bg-muted/30 space-y-2.5 rounded-lg border p-3.5 text-sm",children:n.jsx(yu,{schedules:d,checkFailed:m,testIdPrefix:"naming"})}),f!==void 0&&n.jsx(hl,{error:f}),h,u&&n.jsx("p",{className:"text-muted-foreground text-center text-xs","data-testid":"naming-checking-offer",children:"Checking for scheduled work…"}),g,n.jsx(P,{size:"lg",onClick:i,disabled:!e.canSubmit||c||u||x||f!==void 0,"data-testid":"create-button",children:R})]})]})}function XE({seed:e,packageSchedules:t,isCheckingOffer:s,offerCheckFailed:r,offerRefusal:o,resolvedDirectory:a,canSubmit:i,isCreating:c,inheritance:d,isCheckingInheritance:m=!1,onCreate:u,onCustomize:f,onNotNow:p}){const{displayName:h,persona:g,runtime:x,capabilities:b,skills:y,schedule:k,icon:w}=e.template,I=We(x??"claude-code").label,v=h.trim().charAt(0).toUpperCase()||"?",S=w&&pr(w)?w:v,R=e.sourceLabel?`Offered by ${e.sourceLabel}.`:"A ready-made agent.";return n.jsxs("div",{className:"mx-auto max-w-md space-y-6","data-testid":"arrival-confirm",children:[n.jsxs("div",{className:"flex flex-col items-center gap-3 text-center",children:[n.jsx("span",{className:"bg-primary/10 text-primary flex size-20 items-center justify-center rounded-full text-4xl font-semibold","aria-hidden":"true",children:S}),n.jsxs("div",{className:"space-y-1",children:[n.jsxs($e,{className:"text-xl",children:["Meet ",h]}),n.jsx(Xe,{children:R})]})]}),g&&n.jsx("p",{className:"text-foreground text-sm leading-relaxed whitespace-pre-line",children:g}),n.jsxs("dl",{className:"bg-muted/30 space-y-2.5 rounded-lg border p-3.5 text-sm",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(JE,{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(gs,{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(xt,{className:"h-3.5 w-48 max-w-full rounded"})})]}),k&&n.jsxs("div",{className:"flex items-start gap-2","data-testid":"arrival-schedule",children:[n.jsx(po,{className:"text-muted-foreground mt-0.5 size-4 shrink-0"}),n.jsx("dt",{className:"text-muted-foreground shrink-0",children:"Runs on a schedule"}),n.jsx("dd",{children:k})]}),n.jsx(yu,{schedules:t,checkFailed:r,testIdPrefix:"arrival"}),b&&b.length>0&&n.jsxs("div",{className:"flex items-start gap-2",children:[n.jsx(ux,{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(hg,{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(hl,{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(P,{size:"lg",onClick:u,disabled:c||!i||s||m||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(P,{variant:"ghost",size:"sm",onClick:f,className:"text-muted-foreground","data-testid":"arrival-customize",children:"Customize first"}),n.jsx(P,{variant:"ghost",size:"sm",onClick:p,className:"text-muted-foreground","data-testid":"arrival-not-now",children:"Not now"})]})]})]})}function JE({runtime:e}){const t=We(e??"claude-code").icon;return n.jsx(t,{size:16,className:"text-muted-foreground shrink-0"})}function ZE(e){const t=e==null?void 0:e.body;return(t==null?void 0:t.code)==="template_needs_review"?t.template:void 0}function eI(e,t){const s=e.replace(/\/*$/,"/");return t.filter(r=>r.path===e||r.path.startsWith(s))}function tI(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 nI(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 sI(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:eI(s.path,e.settings??[])})),...t.hooks.map((s,r)=>({key:`hook:${r}`,label:Ye(s.command),detail:`Runs on ${s.event}${s.source?`, while ${Ye(s.source)} is in use`:""}.`})),...(t.skillCommands??[]).map((s,r)=>({key:`command:${s.source}:${r}`,label:Ye(s.command),detail:`Runs when skill “${Ye(s.skill)}” is used (${Ye(s.source)})`+(s.usesArguments?". Reads the text typed after it.":".")})),...t.mcpServers.map(s=>({key:`mcp:${s.name}`,label:s.command?pg(s.command,s.args):Ye(s.url??s.name),detail:`Starts the MCP server “${Ye(s.name)}”.`})),...t.skillTools.map(s=>({key:`tools:${s.source}`,label:s.tools.map(Ye).join(", "),detail:`Skill “${Ye(s.skill)}” may use these without asking you.`}))]}function rI({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(fg,{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:sI(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:tI(i)})]},i.path))]},o.key)})}),n.jsxs("div",{className:"flex flex-wrap justify-end gap-2",children:[n.jsx(P,{variant:"ghost",size:"sm",onClick:s,disabled:r,children:"Don’t create it"}),n.jsx(P,{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…":nI(e)})]})]})}function oI(){const{isOpen:e,seed:t,onCreated:s,close:r}=ps(),o=xn(se=>se.open),a=NE(),i=Ae(),[c,d]=l.useState("gallery"),[m,u]=l.useState(null),[f,p]=l.useState(!1);e!==f&&(p(e),e&&(u(null),d(t?"arrival":"gallery")));const h=t!=null&&t.template.icon&&pr(t.template.icon)?t.template.icon:void 0,g=m!=null&&m.icon&&pr(m.icon)?m.icon:h??null,x=(t==null?void 0:t.template.runtime)??"claude-code",b=(t==null?void 0:t.packageName)!==void 0?t:(m==null?void 0:m.packageName)!==void 0?{packageName:m.packageName,marketplace:m.marketplace}:null,y=IE(b),{data:k}=Ee(),w=b&&y.packageAgentName&&(k!=null&&k.dorkHome)?`${k.dorkHome}/agents/${y.packageAgentName}`:void 0,[I,v]=l.useState(null),S=EE({step:c,templateName:(m==null?void 0:m.displayName)??null,seedDisplayName:(t==null?void 0:t.template.displayName)??null,faceSeed:g,runtimeSeed:x}),R=DE(m?{name:m.name,description:m.description,category:m.category,tags:m.tags}:t?{name:t.template.displayName,description:t.template.persona}:void 0),M=m?m.description??"A ready-made agent.":t!=null&&t.template.persona?t.template.persona:"You’ll define the job together in your first chat.",E=m?m.tags??[]:(t==null?void 0:t.template.capabilities)??[];function N(){S.reset(),v(null),u(null),d("gallery")}const j=l.useCallback(se=>{u(se),d("naming")},[]),A=l.useCallback(()=>{u(null),d("naming")},[]);function C(){d(t?"arrival":"gallery")}function D(){r(),N(),o()}function T(se){var ne;if(!S.canSubmit||a.isPending)return;const G=(b==null?void 0:b.packageName)!==void 0&&y.approval?{package:{name:b.packageName,...b.marketplace?{marketplace:b.marketplace}:{},...y.approval}}:void 0,Q=G?void 0:(m==null?void 0:m.source)??(t==null?void 0:t.template.source);a.mutate({name:S.slug,displayName:S.displayName.trim()||void 0,runtime:S.runtime,...!G&&S.directoryOverride?{directory:S.directoryOverride}:{},...S.icon?{icon:S.icon}:{},...G??{},...Q?{template:Q}:{},...se?{approvedTemplateHash:se}:{},...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:J=>{const ee=crypto.randomUUID(),H=J.displayName??J.name,U=m||t?"template":"design-your-own";gg.getState().register(ee,{name:J.name,displayName:H,agentId:J.id,icon:J.icon,color:J.color,bornAt:J.registeredAt,path:J._path,runtime:J.runtime,kickoffMessage:zE(U,{displayName:H,capabilities:J.capabilities})}),vb();const Y=s;if(r(),N(),Y){Y();return}i(vt({agentId:J.id,draft:"1",session:ee,runtime:J.runtime}))},onError:J=>{const ee=ZE(J);ee&&v(ee)}})}function _(se){se||(r(),N())}const L=Al(e),O=n.jsx(Cv,{agentName:S.displayName||(t==null?void 0:t.template.displayName)||""}),K=RE[c],V=c==="gallery"?"max-w-6xl":c==="naming"?"max-w-5xl":"max-w-2xl";return n.jsx(et,{open:e,onOpenChange:_,defaultFullscreen:!0,children:n.jsxs(tt,{className:"flex flex-col gap-0 p-0",children:["title"in K&&n.jsxs(Qe,{className:"shrink-0 border-b px-5 py-4",children:[n.jsx($e,{children:K.title}),n.jsx(Xe,{children:K.description})]}),n.jsx("span",{className:"sr-only","aria-live":"polite","aria-atomic":"true",children:K.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 ${V}`,children:[n.jsx(Fe,{mode:"wait",children:n.jsxs(X.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.15},children:[c==="gallery"&&n.jsx(GE,{onDesignYourOwn:A,onSelectTemplate:j,onImport:D}),c==="arrival"&&t&&n.jsx(XE,{seed:t,packageSchedules:y.schedules,isCheckingOffer:y.isChecking,offerCheckFailed:y.failed,offerRefusal:y.refusal,resolvedDirectory:w??S.resolvedDirectory,canSubmit:S.canSubmit,isCreating:a.isPending,inheritance:O,isCheckingInheritance:L.isPending,onCreate:()=>T(),onCustomize:()=>d("naming"),onNotNow:()=>_(!1)}),c==="naming"&&n.jsx(QE,{form:S,suggestionPool:R,jobLine:M,previewCapabilities:E,onBack:C,onImportInstead:D,onCreate:()=>T(),isCreating:a.isPending,packageSchedules:y.schedules,offerCheckFailed:y.failed,offerRefusal:y.refusal,isCheckingOffer:y.isChecking,packageDirectory:w,inheritance:O,isCheckingInheritance:L.isPending,templateReview:I?n.jsx(rI,{template:I,isCreating:a.isPending,onCreateAnyway:()=>T(I.contentHash),onCancel:()=>v(null)}):void 0})]},c)}),c!=="gallery"&&n.jsx(Jx,{className:"mt-6"})]})}),n.jsx(Xi,{open:S.directoryPickerOpen,onOpenChange:S.setDirectoryPickerOpen,initialPath:S.directoryOverride||S.defaultDirectory,onSelect:se=>{S.setDirectoryOverride(se),S.directoryOpen||S.setDirectoryOpen(!0)}})]})})}function aI({sessionId:e}){l.useEffect(()=>{var a;const r=at.getState(),o=((a=r.sessions[e])==null?void 0:a.cwd)??r.statusCwds[e]??null;return es.pinSession(e,o),aa.getState().setPinnedSession(e),()=>{es.unpinSession(),aa.getState().setPinnedSession(null)}},[e]);const t=xg(e),s=l.useMemo(()=>ob(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(ab,{code:s.code,isIncomplete:s.isIncomplete,sessionId:e,isLatestMessage:s.isLatest,isStreaming:s.isStreaming},s.sourceMessageKey)}function iI({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 ir=64,cI={type:"spring",stiffness:480,damping:44};function lI({content:e,onRestore:t,onClose:s}){l.useEffect(()=>(document.documentElement.style.setProperty("--pip-dock",`${ir}px`),()=>{document.documentElement.style.removeProperty("--pip-dock")}),[]);const r=Hx();return ms.createPortal(n.jsxs(X.div,{"data-slot":"pip-minibar",role:"complementary","aria-label":e.title,initial:{y:ir},animate:{y:0},exit:{y:ir},transition:cI,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(oy,{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 shrink-0 rounded-md p-2 transition-colors",children:n.jsx(Oe,{className:"size-4"})})]}),document.body)}const Yn={peek:.5,expanded:.94},dI=.4,uI=800,Ii=500,cr={type:"spring",stiffness:480,damping:44};function mI({content:e,onClose:t,onMinimize:s,children:r}){const o=Db(),a=Ib(),[i,c]=l.useState("peek"),[d,m]=l.useState(()=>window.innerHeight);l.useEffect(()=>{const x=()=>m(window.innerHeight);return window.addEventListener("resize",x),()=>window.removeEventListener("resize",x)},[]);const u=Yn.expanded*d,f=(Yn.expanded-Yn.peek)*d,p=i==="expanded"?0:f;l.useEffect(()=>{a.start({y:p,transition:cr})},[a,p]);const h=(x,b)=>{const y=p+b.offset.y,k=b.velocity.y,w=y-f,I=Yn.peek*d;if(w>dI*I||w>0&&k>uI){s();return}let v;k<-Ii?v="expanded":k>Ii?v="peek":v=y<f/2?"expanded":"peek",v===i?a.start({y:p,transition:cr}):c(v)},g=x=>{x.target.closest("button")||o.start(x)};return ms.createPortal(n.jsxs(X.div,{"data-slot":"pip-sheet",role:"complementary","aria-label":e.title,initial:{y:u},animate:a,exit:{y:u},transition:cr,drag:"y",dragListener:!1,dragControls:o,dragConstraints:{top:0,bottom:u},dragElastic:.1,dragMomentum:!1,onDragEnd:h,style:{height:u},className:"bg-background border-border shadow-modal fixed inset-x-0 bottom-0 z-40 flex flex-col rounded-t-lg border-t",children:[n.jsxs("div",{onPointerDown:g,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 px-4 pt-1 pb-2",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 shrink-0 rounded-md p-1 transition-colors",children:n.jsx(At,{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 shrink-0 rounded-md p-1 transition-colors",children:n.jsx(Oe,{className:"size-4"})})]})]}),n.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto p-3",children:r})]}),document.body)}const Ri=360,Ti=240,Di=16,lr={demo:iI,mcp_app:hI,widget:fI};function hI({content:e}){return n.jsx(gb,{sessionId:e.sessionId,serverName:e.serverName,uri:e.uri,title:e.title,className:"h-full"})}function fI({content:e}){return n.jsx(aI,{sessionId:e.sessionId})}function pI(e){l.useEffect(()=>{},[e])}function Oi(){return{x:window.innerWidth-Ri-Di,y:window.innerHeight-Ti-Di,width:Ri,height:Ti}}function gI(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function vu(e){switch(e.kind){case"demo":{const t=lr.demo;return n.jsx(t,{content:e})}case"mcp_app":{const t=lr.mcp_app;return n.jsx(t,{content:e})}case"widget":{const t=lr.widget;return n.jsx(t,{content:e})}default:return e}}function xI({content:e,onClose:t}){const s=$(c=>c.pipGeometry),r=$(c=>c.setPipGeometry),[o,a]=l.useState(Oi);l.useEffect(()=>{if(s!==null)return;const c=()=>a(d=>{const m=Oi();return gI(d,m)?d:m});return c(),window.addEventListener("resize",c),()=>window.removeEventListener("resize",c)},[s]);const i=s??o;return n.jsx(Fe,{children:e!==null&&n.jsx(by,{title:e.title,geometry:i,onGeometryChange:r,onClose:t,children:vu(e)},"pip-panel")})}function bI(){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=je();pI(a);const c=l.useRef(i);return l.useEffect(()=>{i&&!c.current&&e!==null&&r(),c.current=i},[i,e,r]),i?n.jsx(Fe,{children:e!==null&&(t?n.jsx(lI,{content:e,onRestore:o,onClose:s},"pip-minibar"):n.jsx(mI,{content:e,onClose:s,onMinimize:r,children:vu(e)},"pip-sheet"))}):n.jsx(xI,{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 wu(e){const t=Rc(),s=bg(),r=Pt(e),o=l.useRef(null);l.useEffect(()=>{var m,u,f,p;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&&((u=(m=r.read()).onArrive)==null||u.call(m,c)),d.length>0&&((p=(f=r.read()).onDepart)==null||p.call(f,d,a.size))},[s,t,r])}function wI(){const{permission:e}=Gx(),{prefs:t}=qx(),s=Gr(),r=De(),o=l.useRef(new Map),a=Pt(s),i=l.useCallback(()=>r||e!=="granted"||typeof document>"u"||!document.hidden?!1:typeof window<"u"&&typeof window.Notification<"u",[r,e]),c=l.useCallback((f,p,h,g)=>{let x;try{x=new Notification(p,{body:h,tag:f,silent:!0})}catch{return}x.onclick=()=>{var b;window.focus(),x.close(),o.current.delete(f),g!==null&&((b=a.read())==null||b({href:g}))},x.onclose=()=>{o.current.delete(f)},o.current.set(f,{notification:x,href:g})},[a]),d=l.useCallback(f=>{if(i())for(const p of f)c(p.id,`${p.who} needs you`,p.summary,p.deepLink)},[i,c]),m=l.useCallback(f=>{for(const p of f){const h=o.current.get(p);h!==void 0&&(h.notification.close(),o.current.delete(p))}},[]);wu({onArrive:d,onDepart:m});const u=t.notifyOnTurnCompleteWhileAway;de("notification",f=>{const p=yg.safeParse(f);if(!p.success)return;const h=p.data.notification;if(h.tier!=="notable"||!u||!i())return;const g=vg(h),x=g===null?null:jI(g.to,g.search);c(h.id,h.title,h.body??"",x)}),l.useEffect(()=>{const f=o.current;return()=>{for(const{notification:p}of f.values())p.close();f.clear()}},[])}function jI(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 kI(){const{play:e}=Rx(),t=l.useCallback(()=>{e("knock"),Tx()},[e]),s=l.useCallback((r,o)=>{o===0&&e("settle")},[e]);return wu({onArrive:t,onDepart:s}),wI(),null}function SI(){const e=$(r=>r.shortcutsPanelOpen),t=$(r=>r.setShortcutsPanelOpen),s=wg();return n.jsx(et,{open:e,onOpenChange:t,children:n.jsxs(tt,{className:"sm:max-w-md",children:[n.jsx(Qe,{children:n.jsx($e,{children:"Keyboard shortcuts"})}),n.jsx(it,{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(Lc,{className:"inline-flex",children:Ft(i)})]},i.id))})]},r))})]})})}function CI(){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 NI=15e3;function AI(){const e=ke({select:r=>r.location.pathname}),s=bs("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(m1,{contributionId:s.id,children:n.jsx(l.Suspense,{fallback:null,children:n.jsx(r,{})})}),direction:1,isTakeover:!0}}return{key:"dashboard",body:n.jsx(HC,{}),direction:-1,isTakeover:!1}}function EI(){const e=ke({select:t=>t.matches});return zw(e)}function II(){const{sidebarOpen:e,setSidebarOpen:t}=$(),s=je(),r=us(W=>W.panelUp),[o]=jg(),a=ke({select:W=>W.location.pathname}),i=ke({select:W=>W.location.searchStr}),c=new URLSearchParams(i),d=a==="/channels"&&!!c.get("community")&&!!c.get("id"),m=k1(Ue()??!1),u=ke({select:W=>S1(W.matches)});Vy();const[f]=Rn(),p=$(W=>W.isStreaming),{data:h}=ec(f),g=Nc(h??null,f??""),{room:x,unreadRoomCount:b}=i1();d1(),Jb({cwd:f,isStreaming:p,color:h?g.color:void 0}),CI(),Pw(),$x(),gE(),Bx(),zx(),Dx(),hj(),fj(),bj(),n1(),s1();const y=r1();o1(),tv(),Ik(),fw(),pw(),kg(),mx(),Pv(),Sg(),Uy(),Qg(),ey(),Cg(),Lw(),Ng(),Wk(),Nx();const k=$(W=>W.onboardingHiddenForSession),w=$(W=>W.setOnboardingHiddenForSession),{shouldShowOnboarding:I,isLoading:v,isOnboardingComplete:S,isOnboardingDismissed:R}=It(),M=nv({shouldShowOnboarding:I,onboardingHiddenForSession:k});rv({done:S||R,overlayVisible:M}),_w({blocked:M});const{dataUpdatedAt:E,errorUpdatedAt:N,error:j}=Ee({refetchOnMount:j1}),A=E>Bt,C=N>Bt,D=w1(N,j),[T,_]=l.useState(!1);l.useEffect(()=>{if(A)return;const W=setTimeout(()=>_(!0),NI);return()=>clearTimeout(W)},[A]);const L=(D==null?void 0:D.status)===void 0,O=!A&&L&&(C||T),K=A||(D==null?void 0:D.status)===void 0?void 0:D,[V,se]=l.useState(!1);l.useEffect(()=>{if(!v)return;const W=setTimeout(()=>se(!0),3e3);return()=>clearTimeout(W)},[v]);const G=l.useCallback(()=>w(!0),[w]),Q=AI(),{origin:ne,originLabel:J}=Ag(o),{data:ee}=Eg(o,{enabled:!1,select:W=>W.title}),H=EI(),U=l.useMemo(()=>({sessionId:o??void 0,agentName:h?Ce(h):void 0,agentVisual:h?g:void 0,origin:ne,originLabel:J,sessionTitle:ee,sessionDirectoryName:f?Bc(f):void 0,room:x,teamViewMode:Ig(new URLSearchParams(i).get("view")??void 0)}),[o,h,g,ne,J,ee,f,x,i]),Y=B1();return O?n.jsx(f1,{}):(K==null?void 0:K.status)!==void 0?n.jsx(y1,{status:K.status,message:K.message,code:K.code}):v&&!V?n.jsx("div",{className:"bg-background h-dvh"}):n.jsxs(Rg,{children:[n.jsx(c1,{unreadRoomCount:b}),n.jsxs(Cb,{reducedMotion:"user",children:[n.jsx(Fe,{mode:"wait",children:M?n.jsx(X.div,{initial:{opacity:1},exit:{opacity:0},transition:{duration:.2},className:"fixed inset-0 z-50",children:n.jsx(Av,{onComplete:G,slots:x1})},"onboarding"):n.jsx(X.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(Tg,{open:e,onOpenChange:t,className:B("flex-1 overflow-hidden",s&&"min-h-0"),style:{"--sidebar-width":"calc(272px + 1rem)"},children:[!s&&n.jsxs(Dg,{variant:"inset",children:[n.jsx(u1,{isFullscreen:y}),n.jsx(au,{}),n.jsx("div",{className:"relative flex min-h-0 flex-1 flex-col overflow-hidden",children:n.jsx(Fe,{mode:"wait",initial:!1,custom:Q.direction,children:n.jsx(X.div,{"data-testid":"sidebar-body-swap",custom:Q.direction,initial:"enter",animate:"center",exit:"exit",variants:{enter:W=>({x:`${W*100}%`,opacity:0}),center:{x:0,opacity:1},exit:W=>({x:`${W*-100}%`,opacity:0})},transition:{duration:.2,ease:[.4,0,.2,1]},className:"flex min-h-0 flex-1 flex-col overflow-hidden",children:Q.body},Q.key)})}),n.jsx(Og,{className:"px-2 py-3",children:n.jsx(Qc,{})}),n.jsx(Mg,{})]}),n.jsxs(_g,{className:"overflow-hidden",inert:s&&r,children:[De()&&n.jsx(lj,{className:B("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(Pg,{className:"-ml-0.5"}),n.jsx(mj,{}),n.jsx(Lg,{orientation:"vertical",className:"mr-1 h-4"})]}),s&&n.jsx(CN,{}),n.jsx(Fe,{mode:"wait",initial:!1,children:H&&n.jsx(X.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(Fg,{value:U,children:n.jsx(H.Header,{})})},H.key)}),n.jsx(pE,{}),n.jsx(kE,{}),n.jsx(CE,{}),n.jsx($g,{})]}),n.jsx(C1,{descriptors:Y}),n.jsx("main",{id,className:"flex-1 overflow-hidden pb-[var(--pip-dock,0px)]",children:n.jsxs(Bg,{direction:"horizontal",id:wr,autoSaveId:wr,children:[n.jsx(tc,{id:"main-content",order:1,minSize:30,defaultSize:100,children:n.jsx(X.div,{initial:m?{opacity:0}:!1,animate:{opacity:1},transition:m?{duration:.12,ease:"easeOut"}:{duration:0},"data-route-fade":m,className:"h-full",children:n.jsx(zg,{})},u)}),n.jsx(Ow,{pathname:a,isRemoteCommunityRoom:d})]})})]})]}),s&&n.jsx(sE,{takeover:Q.isTakeover?Q.body:null})]})},"main-app")}),n.jsx(sA,{}),n.jsx(X1,{onboardingOverlayVisible:M}),n.jsx(t1,{}),n.jsx(RN,{}),n.jsx(XN,{}),n.jsx(oI,{}),n.jsx(mw,{}),n.jsx(SI,{}),n.jsx(yy,{}),n.jsx(bI,{}),n.jsx(Hg,{}),n.jsx(kI,{})]})]})}const JR=II;export{JR as component};