dorkos 0.128.0 → 0.129.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 (359) hide show
  1. package/dist/bin/cli.js +84 -16
  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-CmQERFxo.js → AboutPage-CML_SdU1.js} +1 -1
  5. package/dist/client/assets/{ActivityErrorState-Dw231W2w.js → ActivityErrorState-TuQRJopr.js} +1 -1
  6. package/dist/client/assets/{ActivityPage-DVfeyA9u.js → ActivityPage-CmSxeVSK.js} +1 -1
  7. package/dist/client/assets/ActivityRow-DJhDehIR.js +1 -0
  8. package/dist/client/assets/{AdapterIcon-NqCDzgCI.js → AdapterIcon-CeRDpZGz.js} +1 -1
  9. package/dist/client/assets/AdapterSetupWizard-B6KkTuJo.js +2 -0
  10. package/dist/client/assets/{AgentOptionRow-BRJfZo2y.js → AgentOptionRow-388OJkPc.js} +1 -1
  11. package/dist/client/assets/{AgentPicker-B7upjYRk.js → AgentPicker-C51wqToQ.js} +1 -1
  12. package/dist/client/assets/{AgentRequestCard-DXJnLk6q.js → AgentRequestCard-Bz31ewIs.js} +4 -4
  13. package/dist/client/assets/AppearancePage-DSVeowGb.js +1 -0
  14. package/dist/client/assets/{ApplyToOverridesDialog-C_QQhNIf.js → ApplyToOverridesDialog-DRtcLrVY.js} +1 -1
  15. package/dist/client/assets/AttentionSignalRow-CqKZyoxB.js +1 -0
  16. package/dist/client/assets/{BaseTanStackRouterDevtoolsPanel-B-iktbLX-G7vrCqeA.js → BaseTanStackRouterDevtoolsPanel-B-iktbLX-DA1jhqFy.js} +3 -3
  17. package/dist/client/assets/BindingDialog-D25PAed0.js +1 -0
  18. package/dist/client/assets/{BlintzCanvas-DruVZcDU.js → BlintzCanvas-BgIQdpTx.js} +3 -3
  19. package/dist/client/assets/{CanvasCsvContent-CtLpZnTs.js → CanvasCsvContent-ZWHWmb88.js} +4 -4
  20. package/dist/client/assets/CanvasFileContent-DR5pUgca.js +2 -0
  21. package/dist/client/assets/CanvasModel3dContent-OP1ZOMui.js +2 -0
  22. package/dist/client/assets/ChannelComposer-BJ0nNzQb.js +45 -0
  23. package/dist/client/assets/{ChatAppsOff-CCZUzDIH.js → ChatAppsOff-ByitL4Xt.js} +2 -2
  24. package/dist/client/assets/{CodeMirrorDiff-BCpYdhgZ.js → CodeMirrorDiff-JsV_vWBa.js} +1 -1
  25. package/dist/client/assets/{CodeMirrorEditor-BeCubxHV.js → CodeMirrorEditor-BfCJG9hQ.js} +1 -1
  26. package/dist/client/assets/{CommitmentList-BZtfTnwg.js → CommitmentList-yFV3_m00.js} +1 -1
  27. package/dist/client/assets/{CommitmentsPage-DmurDgxV.js → CommitmentsPage-DeERVg-2.js} +1 -1
  28. package/dist/client/assets/{ComputerResourceView-Bik6GLKp.js → ComputerResourceView-CYMMSE8Y.js} +1 -1
  29. package/dist/client/assets/{ComputerViewer-CksBDqdu.js → ComputerViewer-H7kJSIj7.js} +1 -1
  30. package/dist/client/assets/ConnectionAccessLists-SRkf7-Y6.js +1 -0
  31. package/dist/client/assets/{ConnectionsPage-Cgg36gDY.js → ConnectionsPage-D6e3hd4L.js} +2 -2
  32. package/dist/client/assets/{ConventionPage-CNhpF6Z1.js → ConventionPage-CpvRMcSG.js} +2 -2
  33. package/dist/client/assets/{ExtensionPageRoute-C2zue_Pw.js → ExtensionPageRoute-CiFv6we8.js} +2 -2
  34. package/dist/client/assets/{FloatingTanStackRouterDevtools-CqogiFob-3v1TfY1P.js → FloatingTanStackRouterDevtools-CqogiFob-D-8CeYC7.js} +1 -1
  35. package/dist/client/assets/{ForwardConsentHost-Mbo0D-zk.js → ForwardConsentHost-ml3b_fsX.js} +1 -1
  36. package/dist/client/assets/HandlePage-Bq5qdCfY.js +1 -0
  37. package/dist/client/assets/HeartbeatPage-C0zSvWH4.js +1 -0
  38. package/dist/client/assets/{KeyEntry-C43vkwpA.js → KeyEntry-Dq6eKAbX.js} +1 -1
  39. package/dist/client/assets/{LexicalField-iAHcvRmI.js → LexicalField-CYOqOLpV.js} +1 -1
  40. package/dist/client/assets/{ManagesPage-BUIJvLmv.js → ManagesPage-DZTMD3Al.js} +1 -1
  41. package/dist/client/assets/Marketplace-buSfuVrY.js +36 -0
  42. package/dist/client/assets/{MarketplaceSourcesView-BZODwhxu.js → MarketplaceSourcesView-BxwvBWgh.js} +1 -1
  43. package/dist/client/assets/{McpAppFrame-D15nxVaI.js → McpAppFrame-CWiRFp8o.js} +2 -2
  44. package/dist/client/assets/{McpSigninBody-DmBxqgxN.js → McpSigninBody-BpYSAV1h.js} +1 -1
  45. package/dist/client/assets/{Model3dViewer-RGXeJd6a.js → Model3dViewer-B2KTvx6d.js} +1 -1
  46. package/dist/client/assets/NamePage-_yT2RQvT.js +1 -0
  47. package/dist/client/assets/{NewDirectMessageMenu-DBAdvv5p.js → NewDirectMessageMenu-CMp4ppiH.js} +1 -1
  48. package/dist/client/assets/{NotificationsPage-NRfyiinS.js → NotificationsPage-CWXIghVM.js} +1 -1
  49. package/dist/client/assets/{OpenMeshSwitch-CgQ6uefo.js → OpenMeshSwitch-C9hiAEHP.js} +2 -2
  50. package/dist/client/assets/OperatorIdentityForm-CjmMoP6n.js +1 -0
  51. package/dist/client/assets/{PermissionHistory-DPEPq8D9.js → PermissionHistory-D_Imuq02.js} +1 -1
  52. package/dist/client/assets/{PermissionsPage--k-xutbJ.js → PermissionsPage-QMLV8PfB.js} +1 -1
  53. package/dist/client/assets/{PersonalityPopover-DMMptmPS.js → PersonalityPopover-BL9DLK0Q.js} +1 -1
  54. package/dist/client/assets/PhotoPage-Djh4IZBF.js +1 -0
  55. package/dist/client/assets/PreviewRefusedNotice-Dt2hV0aJ.js +1 -0
  56. package/dist/client/assets/{ProfileFields-DbPJ7fvN.js → ProfileFields-DD6X85w2.js} +1 -1
  57. package/dist/client/assets/{ProfilePanelContainer-CzwhrIlw.js → ProfilePanelContainer-DuFEpNJ3.js} +1 -1
  58. package/dist/client/assets/{ProfileRolePicker-CZEXvlJm.js → ProfileRolePicker-CT9eJ1J0.js} +1 -1
  59. package/dist/client/assets/PromptSuggestionChips-C8V611-5.js +1 -0
  60. package/dist/client/assets/{ReportsToPopover-YOwGLJy5.js → ReportsToPopover-Bs55bP7b.js} +1 -1
  61. package/dist/client/assets/RoomSurface-DXZ36tmU.js +1 -0
  62. package/dist/client/assets/{RoomsPage-CoXjZMWL.js → RoomsPage-CDiSwt-I.js} +1 -1
  63. package/dist/client/assets/RunsOnPopover-CFBDa9DO.js +1 -0
  64. package/dist/client/assets/RuntimeConnectFlow-DsawxJN7.js +1 -0
  65. package/dist/client/assets/RuntimeSetupDialog-bdf844gx.js +1 -0
  66. package/dist/client/assets/{SeenDevices-Bh2yh-PW.js → SeenDevices-Cix5nnGQ.js} +2 -2
  67. package/dist/client/assets/{SessionsPage-CFvkbT9X.js → SessionsPage-CCu8rM-J.js} +1 -1
  68. package/dist/client/assets/SettingsDialog-D7sVluoe.js +12 -0
  69. package/dist/client/assets/SkillsPage-SSq7ofgp.js +1 -0
  70. package/dist/client/assets/TaskDialogWrapper-CBIuIbmj.js +1 -0
  71. package/dist/client/assets/TasksEmptyState-C0K_NOA3.js +3 -0
  72. package/dist/client/assets/{TasksPage-D0Zi6Mve.js → TasksPage-BpSn7GmR.js} +1 -1
  73. package/dist/client/assets/{TeamComputerEntry-CY9eLVad.js → TeamComputerEntry-BAi9omUC.js} +1 -1
  74. package/dist/client/assets/{ToolsPage-0_vx5P-F.js → ToolsPage-nkGWy6MR.js} +2 -2
  75. package/dist/client/assets/{TopologyGraph-DUZLZZrB.js → TopologyGraph-D6SSv0kC.js} +14 -14
  76. package/dist/client/assets/TourHost-CrZciWIf.js +1 -0
  77. package/dist/client/assets/{UnlinkDialog-ptZy3IN4.js → UnlinkDialog-B9zw8r6F.js} +1 -1
  78. package/dist/client/assets/{UnreadDivider-Ckey1IWn.js → UnreadDivider-BnJ06LmP.js} +1 -1
  79. package/dist/client/assets/WidgetErrorCard-CQKYI7oK.js +108 -0
  80. package/dist/client/assets/{WithheldExtensionsNotice-7Vu1Jctn.js → WithheldExtensionsNotice-VMM5NjL5.js} +1 -1
  81. package/dist/client/assets/WorkView-D5d8DDxS.js +51 -0
  82. package/dist/client/assets/_shell-CTKp94uQ.js +80 -0
  83. package/dist/client/assets/{_shell._home-BRIXhYLg.js → _shell._home-CcfELPIk.js} +1 -1
  84. package/dist/client/assets/_shell._home.activity-CGKsuLq8.js +1 -0
  85. package/dist/client/assets/_shell._home.index-DrJRgJCb.js +3 -0
  86. package/dist/client/assets/_shell._home.tasks-B_lv_-fX.js +1 -0
  87. package/dist/client/assets/_shell._home.workspaces-CjBJymCW.js +1 -0
  88. package/dist/client/assets/{_shell.channels-Bx6q9xVH.js → _shell.channels-CzQFR6pU.js} +4 -4
  89. package/dist/client/assets/_shell.connections-B5hafeep.js +1 -0
  90. package/dist/client/assets/{_shell.feedback-requests-DFznTGbN.js → _shell.feedback-requests-DtD2bH-4.js} +2 -2
  91. package/dist/client/assets/_shell.marketplace-DUpaCb0r.js +1 -0
  92. package/dist/client/assets/_shell.marketplace_.sources-C3pA7zZW.js +1 -0
  93. package/dist/client/assets/_shell.session-DH_9f3AK.js +1 -0
  94. package/dist/client/assets/{_shell.team-DmA09abY.js → _shell.team-BrGo-IxK.js} +6 -6
  95. package/dist/client/assets/_shell.threads-Ceq_tmNk.js +1 -0
  96. package/dist/client/assets/_shell.x._extensionId-DaXLhYNr.js +1 -0
  97. package/dist/client/assets/_shell.x._extensionId_._-DaXLhYNr.js +1 -0
  98. package/dist/client/assets/{abnfDiagram-WEYOIA3C-DxgtVd9I.js → abnfDiagram-WEYOIA3C-BN5bqwbu.js} +1 -1
  99. package/dist/client/assets/{access-copy-Dqct36mi.js → access-copy-BAhTOOsG.js} +1 -1
  100. package/dist/client/assets/{arc-C-67Ef0p.js → arc-BfTE_VoF.js} +1 -1
  101. package/dist/client/assets/{architectureDiagram-ZHVYKT53-B7TjdT-_.js → architectureDiagram-ZHVYKT53-Dc6keeDz.js} +1 -1
  102. package/dist/client/assets/{banner-C9qTs6-C.js → banner-DOgGDCJ5.js} +2 -2
  103. package/dist/client/assets/{blockDiagram-RJAE7QA3-DNqxJ3Ww.js → blockDiagram-RJAE7QA3-B4c6U-ob.js} +1 -1
  104. package/dist/client/assets/{c4Diagram-XDPPPE54-D3jNLV0j.js → c4Diagram-XDPPPE54-CCtD8QC8.js} +1 -1
  105. package/dist/client/assets/channel-CF9_Q7CV.js +1 -0
  106. package/dist/client/assets/{chunk-2E7WHVMD-C6OKx0ty.js → chunk-2E7WHVMD-DcDNqIJG.js} +1 -1
  107. package/dist/client/assets/{chunk-2Q5K7J3B-Dr_6hHrZ.js → chunk-2Q5K7J3B-DOVVK0B8.js} +1 -1
  108. package/dist/client/assets/{chunk-4EMNKR2T-CSrZVDEt.js → chunk-4EMNKR2T-Cg-Do982.js} +1 -1
  109. package/dist/client/assets/{chunk-55XCU76K-CIazeRXO.js → chunk-55XCU76K-CDmULSeY.js} +1 -1
  110. package/dist/client/assets/{chunk-5VM5RSS4-C8IJ3zTR.js → chunk-5VM5RSS4-Bi0yIWW1.js} +1 -1
  111. package/dist/client/assets/{chunk-JWPE2WC7-D9DGXb79.js → chunk-JWPE2WC7-ZHaJh6CV.js} +1 -1
  112. package/dist/client/assets/{chunk-VQ5W62QI-B0LNYdif.js → chunk-VQ5W62QI-DZi6GyW_.js} +1 -1
  113. package/dist/client/assets/{chunk-XXDRQBXY-C7IAIbvZ.js → chunk-XXDRQBXY-D18oZOrd.js} +1 -1
  114. package/dist/client/assets/{chunk-ZCHMQSOR-C79hvjlu.js → chunk-ZCHMQSOR-BkZ0l0fE.js} +2 -2
  115. package/dist/client/assets/{classDiagram-v2-4MYWR3UA-0Di1C2ZB.js → classDiagram-v2-4MYWR3UA-BfmK1buF.js} +1 -1
  116. package/dist/client/assets/{command-BVQb6I3_.js → command-CZqA020F.js} +1 -1
  117. package/dist/client/assets/copy-button-ByA00JGh.js +1 -0
  118. package/dist/client/assets/{cose-bilkent-JH36ORCC-rZumaV4b.js → cose-bilkent-JH36ORCC-B1NTVSbk.js} +1 -1
  119. package/dist/client/assets/{cpu-DeRuDMl4.js → cpu-DNvpMmNN.js} +1 -1
  120. package/dist/client/assets/{cynefin-EF2NZ3EQ-CI9l9xhM.js → cynefin-EF2NZ3EQ-CB_HMIZ8.js} +1 -1
  121. package/dist/client/assets/{cynefinDiagram-WF24UDRP-C8CdorJJ.js → cynefinDiagram-WF24UDRP-MmIWYdc2.js} +1 -1
  122. package/dist/client/assets/{dagre-NK4GIZVX-AHpsTq1O.js → dagre-NK4GIZVX-BQay0k4e.js} +1 -1
  123. package/dist/client/assets/detail-row-290qyusq.js +1 -0
  124. package/dist/client/assets/{diagram-CBK3MWTC-BpPLL30n.js → diagram-CBK3MWTC-C1lRH4cb.js} +1 -1
  125. package/dist/client/assets/{diagram-I5XIIV2D-D6loMn3G.js → diagram-I5XIIV2D-CnANa27A.js} +1 -1
  126. package/dist/client/assets/{diagram-ODIL2UCW-BaGNd5eN.js → diagram-ODIL2UCW-Cwt7hxes.js} +1 -1
  127. package/dist/client/assets/{diagram-PFBEJUXE-BnDdKu_g.js → diagram-PFBEJUXE-DZtAER77.js} +1 -1
  128. package/dist/client/assets/{diagram-RJA3I4VV-UXagB0_c.js → diagram-RJA3I4VV-CbVXbiGs.js} +1 -1
  129. package/dist/client/assets/{diagram-TYUNFSNR-C-whBP-S.js → diagram-TYUNFSNR-D-AcGdsL.js} +1 -1
  130. package/dist/client/assets/{ebnfDiagram-V4P3TTPT-BbG481iS.js → ebnfDiagram-V4P3TTPT-DLkrFSAy.js} +1 -1
  131. package/dist/client/assets/{elk-QONTBCTQ-FtssIxOc.js → elk-QONTBCTQ-DQM6Glxa.js} +1 -1
  132. package/dist/client/assets/{empty-state-CACt-76q.js → empty-state-BnuM8oop.js} +1 -1
  133. package/dist/client/assets/{erDiagram-KYQIGQAA-PpFgUf4C.js → erDiagram-KYQIGQAA-C1qgB1Mn.js} +1 -1
  134. package/dist/client/assets/{execution-config-CGL73sRn.js → execution-config-BjLHHc9x.js} +1 -1
  135. package/dist/client/assets/{file-D80JE_L0.js → file-D7_QdH_S.js} +1 -1
  136. package/dist/client/assets/{file-exclamation-point-CcJ_e4_m.js → file-exclamation-point-Cdt8YqyQ.js} +1 -1
  137. package/dist/client/assets/{file-text-Ds9edaTZ.js → file-text-CB9l6Ur-.js} +1 -1
  138. package/dist/client/assets/{find-latest-widget-fence-BtqFMP_f.js → find-latest-widget-fence-SQB9WgjN.js} +5 -5
  139. package/dist/client/assets/{flowDiagram-IUGLLWBU-BIva66g9.js → flowDiagram-IUGLLWBU-DH-ePeFu.js} +1 -1
  140. package/dist/client/assets/form--HjBAzX8.js +1 -0
  141. package/dist/client/assets/{format-cron-BpGrgPLu.js → format-cron-svkfKW5b.js} +1 -1
  142. package/dist/client/assets/format-tokens-DymkROvy.js +1 -0
  143. package/dist/client/assets/{ganttDiagram-R7GPNTJY-CZqips_4.js → ganttDiagram-R7GPNTJY-fjb_iAW1.js} +1 -1
  144. package/dist/client/assets/{git-branch-B8JNwQ6q.js → git-branch-CPOwiT8a.js} +1 -1
  145. package/dist/client/assets/{gitGraphDiagram-PDYL7XHY-DoIc3lda.js → gitGraphDiagram-PDYL7XHY-CcCqH5T3.js} +1 -1
  146. package/dist/client/assets/{graph-yizM0vwL.js → graph-DS3J2jnN.js} +1 -1
  147. package/dist/client/assets/{heart-BavUIV45.js → heart-C6uRnXx3.js} +1 -1
  148. package/dist/client/assets/{highlighted-body-KPVGNVTW-CGr3AgaU.js → highlighted-body-KPVGNVTW-CNygKq0i.js} +1 -1
  149. package/dist/client/assets/image-lightbox-BQV3i0WJ.js +1 -0
  150. package/dist/client/assets/{image-off-C1uTDs9-.js → image-off-B88WBkcV.js} +1 -1
  151. package/dist/client/assets/{index-SOKlO1zZ.js → index-3CJSEcZE.js} +1 -1
  152. package/dist/client/assets/index-3JL8A9YZ.css +1 -0
  153. package/dist/client/assets/{index-BJEt9R_G.js → index-57qzL_5b.js} +1 -1
  154. package/dist/client/assets/index-5RD9flqf.js +1 -0
  155. package/dist/client/assets/{index-FhWMRBQP.js → index-B6pmysqs.js} +1 -1
  156. package/dist/client/assets/{index-DEiSJbvu.js → index-BIZNH5u1.js} +1 -1
  157. package/dist/client/assets/{index-BOhSPP-6.js → index-BKdXHSbr.js} +1 -1
  158. package/dist/client/assets/{index-B36osK_S.js → index-BN3zOTbR.js} +3 -3
  159. package/dist/client/assets/{index-DYEmUa5t.js → index-BNq_mnok.js} +1 -1
  160. package/dist/client/assets/index-BPp-rj-W.js +1 -0
  161. package/dist/client/assets/{index-DW4KUPHp.js → index-BTqJGL1_.js} +1 -1
  162. package/dist/client/assets/{index-CJXMgnYp.js → index-B_YZ5cyn.js} +1 -1
  163. package/dist/client/assets/{index-Dcd4NqFB.js → index-B_rc9Pb1.js} +1 -1
  164. package/dist/client/assets/{index-56EOd-zy.js → index-B_v2l2ND.js} +1 -1
  165. package/dist/client/assets/{index-QSXJR98z.js → index-Bktc0aFV.js} +1 -1
  166. package/dist/client/assets/index-BtTqA4_d.js +1 -0
  167. package/dist/client/assets/{index-CiGYtR9O.js → index-BxsALYNM.js} +1 -1
  168. package/dist/client/assets/index-C4Uak2ha.js +1 -0
  169. package/dist/client/assets/{index-FI_y_dND.js → index-C7I0BjyX.js} +1 -1
  170. package/dist/client/assets/{index-CoNMlH37.js → index-CEicS7Zi.js} +1 -1
  171. package/dist/client/assets/{index-1QfQImuJ.js → index-CLTrC-a-.js} +3 -3
  172. package/dist/client/assets/{index-CXBYgGja.js → index-CLVvKY2v.js} +1 -1
  173. package/dist/client/assets/{index-BKWJiERs.js → index-COXdXByr.js} +1 -1
  174. package/dist/client/assets/{index-CoKNU2F9.js → index-CTJA-mZu.js} +1 -1
  175. package/dist/client/assets/{index-BOEPL6hN.js → index-CZmU-67J.js} +1 -1
  176. package/dist/client/assets/{index-LwL5BpE4.js → index-Cbbw2ByB.js} +1 -1
  177. package/dist/client/assets/{index-C4t0UTU-.js → index-Cbk19RQp.js} +1 -1
  178. package/dist/client/assets/{index-DqkFtcGQ.js → index-D0QV18E0.js} +1 -1
  179. package/dist/client/assets/{index-7XeZCCDI.js → index-D5fV4hrl.js} +1 -1
  180. package/dist/client/assets/{index-CeDn1Ak1.js → index-DBAPfYwE.js} +1 -1
  181. package/dist/client/assets/{index-Cdod8zEY.js → index-DK8zHloW.js} +1 -1
  182. package/dist/client/assets/index-DO8NbOqk.js +1 -0
  183. package/dist/client/assets/{index-C8ZpJXTQ.js → index-DXZ-w0Z9.js} +1 -1
  184. package/dist/client/assets/{index-n_pnc-CO.js → index-DYQjub9g.js} +1 -1
  185. package/dist/client/assets/index-Daoy3TZ8.js +1 -0
  186. package/dist/client/assets/{index-tgbcsB6H.js → index-DdBvjuc4.js} +1 -1
  187. package/dist/client/assets/{index-X282DRZf.js → index-DhqeMM58.js} +2 -2
  188. package/dist/client/assets/{index-YSHcMqHa.js → index-Ds9wPt9M.js} +1 -1
  189. package/dist/client/assets/{index-Br6xDNvu.js → index-RQhQx8gq.js} +1 -1
  190. package/dist/client/assets/{index-CrTmY12y.js → index-UJpgX--l.js} +2 -2
  191. package/dist/client/assets/index-YUtEyz7O.js +1053 -0
  192. package/dist/client/assets/{index-BkJlIXqM.js → index-oc-yQ5Q4.js} +1 -1
  193. package/dist/client/assets/index-tRdq7FGO.js +1 -0
  194. package/dist/client/assets/{index-ZR5f82z2.js → index-um-0KSur.js} +1 -1
  195. package/dist/client/assets/{index.esm-CAeUe7uQ.js → index.esm-B10OaB6F.js} +1 -1
  196. package/dist/client/assets/{infoDiagram-MVDRKAX5-DweUdYSy.js → infoDiagram-MVDRKAX5-CGtvYWtj.js} +1 -1
  197. package/dist/client/assets/{inline-code-SYHTKcle.js → inline-code-BL-6EKVP.js} +1 -1
  198. package/dist/client/assets/{ishikawaDiagram-HPEHV2GE-DKNQIv7P.js → ishikawaDiagram-HPEHV2GE-ICsVVT2t.js} +1 -1
  199. package/dist/client/assets/{journeyDiagram-BOSHW7O7-DPD7F4VO.js → journeyDiagram-BOSHW7O7-DEmSX2Hn.js} +1 -1
  200. package/dist/client/assets/{kanban-definition-FNSA4HC5-B_uPSwxC.js → kanban-definition-FNSA4HC5-SAV5PQOr.js} +1 -1
  201. package/dist/client/assets/{layers-F4mvrI2l.js → layers-Bfdpn7ZM.js} +1 -1
  202. package/dist/client/assets/{lightbulb-a6nNsrzy.js → lightbulb-CSPTiZoi.js} +1 -1
  203. package/dist/client/assets/{link-2-yI2Tlm7Q.js → link-2-ZzmN9B9k.js} +1 -1
  204. package/dist/client/assets/{list-runtime-types-CsGil5te.js → list-runtime-types-7qV7HQ7K.js} +1 -1
  205. package/dist/client/assets/{markdown-content-Cjhsscbn.js → markdown-content-CiDXslQf.js} +1 -1
  206. package/dist/client/assets/mention-pill-CuSUdpn7.js +1 -0
  207. package/dist/client/assets/{mermaid.core-9PwG-9fN.js → mermaid.core-C-qvGQ5g.js} +4 -4
  208. package/dist/client/assets/{message-square-off-aV4NMCjd.js → message-square-off-BehEHG9c.js} +1 -1
  209. package/dist/client/assets/{mindmap-definition-6OY57UG3-BRbWmQkj.js → mindmap-definition-6OY57UG3-DzU2APoo.js} +1 -1
  210. package/dist/client/assets/{more-details-CRLU2HN4.js → more-details-DF2dJXMV.js} +1 -1
  211. package/dist/client/assets/{owner-notice-CTJbhUak.js → owner-notice-DoH-_Veh.js} +1 -1
  212. package/dist/client/assets/{package-sPggO7Dr.js → package-Fm_v1gMn.js} +1 -1
  213. package/dist/client/assets/{page-container-CnfDuiDC.js → page-container-Bcz5wJVR.js} +1 -1
  214. package/dist/client/assets/{pane-resize-handle-63OC5vfI.js → pane-resize-handle-_EuIpxzc.js} +1 -1
  215. package/dist/client/assets/{paperclip-WhPo3_WD.js → paperclip-AGN67YEM.js} +1 -1
  216. package/dist/client/assets/path-input-jrT0Ap4j.js +1 -0
  217. package/dist/client/assets/{pegDiagram-ECIUJNBX-Ct9Li_PA.js → pegDiagram-ECIUJNBX-CAyGJ7fm.js} +1 -1
  218. package/dist/client/assets/{pieDiagram-GNMPY74T-BAB5RA5v.js → pieDiagram-GNMPY74T-tmLJe1p-.js} +1 -1
  219. package/dist/client/assets/{plug-_q5iqunq.js → plug-C-4o4Kb8.js} +1 -1
  220. package/dist/client/assets/primer-trigger-CmE4Ib-X.js +3 -0
  221. package/dist/client/assets/{profile-errors-COcBx7w5.js → profile-errors-vJU1kT3U.js} +1 -1
  222. package/dist/client/assets/{progress-77FCPL2y.js → progress-BTu_QWg8.js} +1 -1
  223. package/dist/client/assets/{quadrantDiagram-D57K4MC3-BqPJVmMS.js → quadrantDiagram-D57K4MC3-CUr2zJoz.js} +1 -1
  224. package/dist/client/assets/{query-error-state-5236P3z0.js → query-error-state-BCX32dab.js} +1 -1
  225. package/dist/client/assets/{radio-C8xmfoqO.js → radio-DBitPjM1.js} +1 -1
  226. package/dist/client/assets/{railroadDiagram-Y72NRBL7-B8U11nT6.js → railroadDiagram-Y72NRBL7-Bk9OMEWz.js} +1 -1
  227. package/dist/client/assets/registry-DVPRVi8T.js +34 -0
  228. package/dist/client/assets/registry-DiFfRDdW.js +1 -0
  229. package/dist/client/assets/{relay-trace-schemas-B80E4EUn.js → relay-trace-schemas-C-1Js81V.js} +2 -2
  230. package/dist/client/assets/{repeat-CHmB_vD7.js → repeat-B1wCYWXI.js} +1 -1
  231. package/dist/client/assets/{requirementDiagram-EQYSW5RA-CzJ1gzTh.js → requirementDiagram-EQYSW5RA-B2pkljrw.js} +1 -1
  232. package/dist/client/assets/{room-files-source-B0gc97Ri.js → room-files-source-BDkq0-fd.js} +2 -2
  233. package/dist/client/assets/{rotate-ccw-clock-CCU6SVnv.js → rotate-ccw-clock-Ds8cHkxD.js} +1 -1
  234. package/dist/client/assets/{rotate-cw-B8WQa8O-.js → rotate-cw-hUzouNTK.js} +1 -1
  235. package/dist/client/assets/{sankeyDiagram-SY24JHO5-D4vQwyve.js → sankeyDiagram-SY24JHO5-DEW9eIPS.js} +1 -1
  236. package/dist/client/assets/scroll-area-RSd8NjrE.js +1 -0
  237. package/dist/client/assets/{sequenceDiagram-BLEHNHQU-BVnIsPQe.js → sequenceDiagram-BLEHNHQU-CoiCdD1D.js} +1 -1
  238. package/dist/client/assets/{shield-x-ijIbRppV.js → shield-x-KL4ZbHfz.js} +1 -1
  239. package/dist/client/assets/signed-in-Dzxe2378.js +1 -0
  240. package/dist/client/assets/{sizeCapture-INFHLROL-DGb1rAJL.js → sizeCapture-INFHLROL-BWGf0Ghs.js} +1 -1
  241. package/dist/client/assets/{soul-file-CXgYs25S.js → soul-file-BQXbWArv.js} +1 -1
  242. package/dist/client/assets/{stateDiagram-v2-A6IESKWZ-DeX3IKTm.js → stateDiagram-v2-A6IESKWZ-aeqwGZMB.js} +1 -1
  243. package/dist/client/assets/{swimlanes-B3ENRKFQ-DN5ljYhG.js → swimlanes-B3ENRKFQ-BkWhAAlV.js} +1 -1
  244. package/dist/client/assets/swimlanesDiagram-AYQRV4AK-CS2DMvLi.js +8 -0
  245. package/dist/client/assets/{table-D9ww_3Ij.js → table-CfLst6CF.js} +1 -1
  246. package/dist/client/assets/{timeline-definition-JXYKGLGB-DpRthC3r.js → timeline-definition-JXYKGLGB-C1BUxIfq.js} +1 -1
  247. package/dist/client/assets/{trust-posture-Dn2ciEE0.js → trust-posture-CfEIPM4Z.js} +1 -1
  248. package/dist/client/assets/{unplug-BZ8zSvfB.js → unplug-B3eDst8L.js} +1 -1
  249. package/dist/client/assets/{unverified-catalog-notice-CGy05tAO.js → unverified-catalog-notice-BqIWxQuN.js} +1 -1
  250. package/dist/client/assets/{use-bindings-BLAWQRpe.js → use-bindings-DhOKnybh.js} +1 -1
  251. package/dist/client/assets/{use-composer-prefs-ICOpilWK.js → use-composer-prefs-_rlNL0D8.js} +1 -1
  252. package/dist/client/assets/{use-connector-management-DEMGZy9N.js → use-connector-management-CHLdhBhC.js} +1 -1
  253. package/dist/client/assets/{use-deep-link-scroll-DxGYrks3.js → use-deep-link-scroll-BVkszEn2.js} +1 -1
  254. package/dist/client/assets/{use-delete-binding-Bnv3J5Fu.js → use-delete-binding-BET7vH2R.js} +1 -1
  255. package/dist/client/assets/{use-dev-links-BOcktLiE.js → use-dev-links-BjLPuSUC.js} +1 -1
  256. package/dist/client/assets/{use-direct-message-panel-D38tSozW.js → use-direct-message-panel-ClXVf94w.js} +1 -1
  257. package/dist/client/assets/{use-external-adapter-catalog-9qiNBqpc.js → use-external-adapter-catalog-D1INoacX.js} +1 -1
  258. package/dist/client/assets/use-filter-state-BRlb3qG3.js +6 -0
  259. package/dist/client/assets/use-full-activity-feed-GWBg-_1B.js +1 -0
  260. package/dist/client/assets/use-is-below-desktop-BjWA-tqP.js +1 -0
  261. package/dist/client/assets/{use-local-browser-B1huJhdg.js → use-local-browser-C-V2n_wd.js} +1 -1
  262. package/dist/client/assets/{use-mesh-topology-BTYAy6zc.js → use-mesh-topology-BzSFyR_s.js} +1 -1
  263. package/dist/client/assets/{use-mounted-ref-CaPc6Prv.js → use-mounted-ref-1T3JbkY1.js} +1 -1
  264. package/dist/client/assets/{use-notification-prefs-u76DPoP0.js → use-notification-prefs-qcYeVmLQ.js} +1 -1
  265. package/dist/client/assets/use-pending-read-C1oA2H00.js +1 -0
  266. package/dist/client/assets/use-personality-commit-CJb-rqmM.js +1 -0
  267. package/dist/client/assets/{use-promo-activation-5HG08FlB.js → use-promo-activation-CAJItujg.js} +3 -3
  268. package/dist/client/assets/{use-promo-dismissals-CO7-qhEl.js → use-promo-dismissals-C6bPU5Rm.js} +1 -1
  269. package/dist/client/assets/{use-pulse-freshness-D07Mv-Sa.js → use-pulse-freshness-Y11Ibit1.js} +1 -1
  270. package/dist/client/assets/{use-room-follow-claim-DRQBuAIe.js → use-room-follow-claim-Di-yvoJD.js} +1 -1
  271. package/dist/client/assets/{use-room-sessions-Bzk7rM40.js → use-room-sessions-CPDRbQAW.js} +1 -1
  272. package/dist/client/assets/{use-roving-tab-list-CcznVldj.js → use-roving-tab-list-DK0OzOUz.js} +1 -1
  273. package/dist/client/assets/{use-session-canvas-CpgE7tFb.js → use-session-canvas-DA2i9Mdm.js} +6 -6
  274. package/dist/client/assets/use-status-budget-jMg_w0rF.js +21 -0
  275. package/dist/client/assets/{use-transform-ByJGn3hq.js → use-transform-BX3r518L.js} +1 -1
  276. package/dist/client/assets/{use-unclaimed-chats-C-z5fstJ.js → use-unclaimed-chats-B0nk8b84.js} +1 -1
  277. package/dist/client/assets/use-update-config-Ce7sHmp2.js +1 -0
  278. package/dist/client/assets/{useMutationState-BF1EFtIZ.js → useMutationState-Rlga1GBT.js} +1 -1
  279. package/dist/client/assets/{usecaseDiagram-WPOLBNNX-efVKbRIX.js → usecaseDiagram-WPOLBNNX-mjIwRNL1.js} +1 -1
  280. package/dist/client/assets/{vennDiagram-Q3Y3IDCW-Bravmwce.js → vennDiagram-Q3Y3IDCW-BcDIpVa6.js} +1 -1
  281. package/dist/client/assets/{wardleyDiagram-IVAIDKWA-fR77zByv.js → wardleyDiagram-IVAIDKWA-NFX31kox.js} +1 -1
  282. package/dist/client/assets/{xychartDiagram-4URNHDU4-BphORSLh.js → xychartDiagram-4URNHDU4-DZZY7dL1.js} +1 -1
  283. package/dist/client/index.html +2 -2
  284. package/dist/drizzle/20261031012841_dor3309_file_turn_on_offer.sql +2 -0
  285. package/dist/drizzle/20261101122330_schedule_declined_content_key.sql +1 -0
  286. package/dist/drizzle/meta/20261031012841_snapshot.json +14116 -0
  287. package/dist/drizzle/meta/20261101122330_snapshot.json +14123 -0
  288. package/dist/drizzle/meta/_journal.json +14 -0
  289. package/dist/server/index.js +6424 -4548
  290. package/dist/server/index.js.map +2 -2
  291. package/package.json +5 -5
  292. package/dist/client/assets/ActivityRow-DIBH4v9c.js +0 -1
  293. package/dist/client/assets/AdapterSetupWizard-Dle_b9qc.js +0 -2
  294. package/dist/client/assets/AppearancePage-DXbhUt2e.js +0 -1
  295. package/dist/client/assets/AttentionSignalRow-5E7TkG98.js +0 -1
  296. package/dist/client/assets/BindingDialog-q--8SDJF.js +0 -1
  297. package/dist/client/assets/CanvasFileContent-BThy5fjD.js +0 -2
  298. package/dist/client/assets/CanvasModel3dContent-BbgR73jh.js +0 -2
  299. package/dist/client/assets/ChannelComposer-qhk0KtW7.js +0 -44
  300. package/dist/client/assets/ConnectionAccessLists-DRwO1v0V.js +0 -1
  301. package/dist/client/assets/HandlePage-B4qbFi40.js +0 -1
  302. package/dist/client/assets/HeartbeatPage-BnNbQLCW.js +0 -1
  303. package/dist/client/assets/Marketplace-DbdLWz0-.js +0 -36
  304. package/dist/client/assets/NamePage-fhxyWDDY.js +0 -1
  305. package/dist/client/assets/OperatorIdentityForm-Bls5Vo_u.js +0 -1
  306. package/dist/client/assets/PhotoPage-CNHcXbz4.js +0 -1
  307. package/dist/client/assets/PreviewRefusedNotice-Ds4IO32o.js +0 -1
  308. package/dist/client/assets/PromptSuggestionChips-BXxC799Q.js +0 -1
  309. package/dist/client/assets/RoomSurface-DgH3a_Fv.js +0 -1
  310. package/dist/client/assets/RunsOnPopover-CEkkjrGg.js +0 -1
  311. package/dist/client/assets/RuntimeConnectFlow-DXWGgvCW.js +0 -1
  312. package/dist/client/assets/RuntimeSetupDialog-D6L1QhMF.js +0 -1
  313. package/dist/client/assets/SettingsDialog-BOOqWKcj.js +0 -12
  314. package/dist/client/assets/SkillsPage-ntCEhUIM.js +0 -1
  315. package/dist/client/assets/TaskDialogWrapper-vBWAWwTY.js +0 -1
  316. package/dist/client/assets/TasksEmptyState-C_3UkAbA.js +0 -3
  317. package/dist/client/assets/TourHost-B69XAKpE.js +0 -1
  318. package/dist/client/assets/WidgetErrorCard-BlqaIsPK.js +0 -108
  319. package/dist/client/assets/WorkView-BekLkR4O.js +0 -51
  320. package/dist/client/assets/_shell-Du0F-5fK.js +0 -80
  321. package/dist/client/assets/_shell._home.activity-5rihXoYF.js +0 -1
  322. package/dist/client/assets/_shell._home.index-BsLNqt4f.js +0 -3
  323. package/dist/client/assets/_shell._home.tasks-Cxs5tLWA.js +0 -1
  324. package/dist/client/assets/_shell._home.workspaces-CEHDdfbP.js +0 -1
  325. package/dist/client/assets/_shell.connections-Bm0WmgXH.js +0 -1
  326. package/dist/client/assets/_shell.marketplace-CsQ60Mlc.js +0 -1
  327. package/dist/client/assets/_shell.marketplace_.sources-DNyShS1x.js +0 -1
  328. package/dist/client/assets/_shell.session-BN42bV3w.js +0 -1
  329. package/dist/client/assets/_shell.threads-HH4EvufJ.js +0 -1
  330. package/dist/client/assets/_shell.x._extensionId-3ZlJV1iu.js +0 -1
  331. package/dist/client/assets/_shell.x._extensionId_._-3ZlJV1iu.js +0 -1
  332. package/dist/client/assets/card-DUmTNXJJ.js +0 -1
  333. package/dist/client/assets/channel-B7zgJbnU.js +0 -1
  334. package/dist/client/assets/form-D93N5lrK.js +0 -1
  335. package/dist/client/assets/image-lightbox-vgPEvSCc.js +0 -1
  336. package/dist/client/assets/index-B446r3dL.js +0 -1
  337. package/dist/client/assets/index-BGo1YiUE.js +0 -1
  338. package/dist/client/assets/index-BO3yPJt-.js +0 -1
  339. package/dist/client/assets/index-DE6uOpn4.js +0 -1
  340. package/dist/client/assets/index-Dag1qeZI.js +0 -1
  341. package/dist/client/assets/index-Dm0Tav7v.js +0 -1
  342. package/dist/client/assets/index-Dry_agqN.css +0 -1
  343. package/dist/client/assets/index-OQuvRZTD.js +0 -1058
  344. package/dist/client/assets/index-eVrGefuq.js +0 -1
  345. package/dist/client/assets/mention-pill-BsOeTJ2f.js +0 -1
  346. package/dist/client/assets/path-input-C2KIXdON.js +0 -1
  347. package/dist/client/assets/primer-trigger-B2tjuHBx.js +0 -3
  348. package/dist/client/assets/registry-BzXBOE9h.js +0 -34
  349. package/dist/client/assets/registry-sfhDu9q2.js +0 -1
  350. package/dist/client/assets/scroll-area-FwZwM74Q.js +0 -1
  351. package/dist/client/assets/search-x-Q18Wm-C5.js +0 -6
  352. package/dist/client/assets/signed-in-DEOMBWVX.js +0 -1
  353. package/dist/client/assets/swimlanesDiagram-AYQRV4AK-D8kHFWtL.js +0 -8
  354. package/dist/client/assets/use-full-activity-feed-CtQquOBW.js +0 -1
  355. package/dist/client/assets/use-is-below-desktop-CAGEAsCC.js +0 -1
  356. package/dist/client/assets/use-pending-read-D0y6i7G9.js +0 -1
  357. package/dist/client/assets/use-personality-commit-C3h8upDo.js +0 -1
  358. package/dist/client/assets/use-status-budget-Xn2sIeM1.js +0 -16
  359. package/dist/client/assets/use-update-config-L5NCTj3t.js +0 -1
@@ -0,0 +1,80 @@
1
+ var Xu=Object.defineProperty;var Ju=(e,t,s)=>t in e?Xu(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s;var yn=(e,t,s)=>Ju(e,typeof t!="symbol"?t+"":t,s);import{O as We,s5 as Zu,r as u,f7 as Vo,s6 as em,f5 as Jr,j as n,s7 as tm,s8 as Ji,f8 as nm,k6 as Zr,a5 as ae,a6 as Ee,aJ as Fe,f3 as De,fV as Tn,s9 as Qs,k3 as ds,sa as sm,sb as rm,a7 as le,ar as fe,jQ as Qo,sc as om,eq as Ns,_ as se,B as L,X as Be,G as K,jt as Zi,sd as am,x as Oe,a4 as ec,bx as tc,bf as As,dE as $e,a_ as im,se as Xo,sf as cm,bR as lm,aI as nc,ct as Me,aO as _e,s as Kt,ko as dm,kp as sc,dB as ce,ls as $n,lt as Ct,lu as rc,aZ as P,rI as um,eQ as Nt,dT as us,iX as ln,sg as mm,a8 as Vt,eD as oc,fv as eo,d6 as to,av as Qt,sh as Jo,jP as hm,jU as ac,jO as fm,pX as no,Y as Bn,J as Xt,$ as so,ep as on,l as ve,aK as ic,eN as cc,e7 as lc,e8 as dc,eO as pm,si as gm,ec as ct,by as dn,bz as un,U as Jt,bA as mn,bC as hn,C as fn,el as He,em as xm,mO as uc,l5 as mc,aQ as Ue,sj as bm,gM as hc,bS as Zo,sk as ym,g as ms,k2 as Sr,z as ro,e1 as ut,hI as at,gc as oo,fB as Es,kh as ao,f as Rt,ba as fc,eC as Is,sl as pc,ej as vm,ao as io,a2 as Dn,dh as pn,di as gn,dj as xn,am as Le,as as Rs,nQ as gc,sm as wm,sn as jm,cV as km,dS as hs,Z as Ye,kv as Ts,ku as sn,cY as bt,cZ as yt,c$ as ft,d0 as st,d1 as pt,eA as At,dL as rn,dJ as Sm,cn as zn,ew as xc,so as Cm,cl as bc,gu as yc,h6 as ea,sp as Nm,ih as fs,kd as Am,kf as Em,h4 as vc,sq as Im,f$ as Ds,g0 as Os,g2 as Ms,sr as wc,g3 as qe,ss as Un,g5 as ss,h as co,st as lo,su as Rm,g1 as Tm,qV as Dm,sv as jc,jF as Om,sw as Mm,sx as _m,sy as Pm,hn as kc,sz as Lm,sA as Fm,iW as Sc,sB as Cc,sC as $m,ay as Bm,gl as Nc,af as Pe,hl as _s,sD as zm,sE as Um,gm as Km,r$ as ta,i1 as Hm,mM as Wm,i3 as Gm,i4 as qm,i5 as Ym,jj as Ac,sF as Vm,sG as ue,sH as Qm,sI as Ec,sJ as uo,sK as Cr,sL as Ic,sM as mo,sN as ho,b9 as Kn,sO as Ps,sP as Xm,sQ as Jm,sR as Zm,sS as eh,sT as th,sU as nh,sV as sh,sW as _t,k4 as rh,jy as oh,oa as ah,sX as na,be as ih,hU as Rc,sY as Ht,sZ as an,s_ as ch,s$ as lh,t0 as dh,t1 as uh,fA as Tc,c5 as Lt,t2 as Dc,t3 as ps,t4 as Oc,t5 as mh,t6 as hh,t7 as Mc,t8 as _c,t9 as fh,ta as ph,i9 as Pc,ia as Lc,tb as Wt,tc as gh,td as xh,es as bh,te as On,tf as yh,b0 as Fc,tg as vh,th as wh,ti as jh,tj as kh,tk as Sh,tl as $c,tm as Ft,fy as Et,fH as lt,fF as Hn,fG as me,fK as Wn,fJ as Bt,fN as be,I as xt,pi as Bc,ps as zc,nj as Gt,ni as Mn,cp as Ls,kZ as Ch,nh as Uc,eR as Kc,rS as Hc,oE as Nh,ng as Ah,tn as Eh,to as sa,tp as Ih,tq as cn,tr as Wc,bZ as Fs,ii as Gc,ts as Rh,qe as Th,tt as Dh,tu as qc,tv as Oh,tw as Mh,gv as _h,a$ as fo,nk as po,tx as Ph,go as $s,ty as Cn,tz as go,q as gs,lx as Yc,tA as Lh,o as Vc,tB as Fh,kq as ra,me as $h,oV as Bh,tC as zh,cb as Uh,tD as Kh,al as xo,ak as bo,nr as Qc,nq as Xc,tE as Hh,dC as Bs,nU as zs,tF as Nn,tG as rs,kK as Jc,tH as Wh,tI as Gh,tJ as qh,tK as Yh,tL as Vh,tM as Qh,tN as Xh,hh as yo,pW as Jh,tO as Zc,nT as Zh,l3 as Nr,e3 as ef,tP as vo,nm as Us,tQ as Ks,tR as tf,nl as nf,im as wo,nn as el,tS as sf,qP as rf,tT as of,tU as af,tV as oa,tW as cf,tX as lf,tY as df,tZ as uf,t_ as aa,t$ as mf,u0 as hf,u1 as ff,u2 as pf,u3 as ia,e as dt,u4 as gf,u5 as xf,l1 as Hs,lJ as tl,u6 as bf,gq as nl,lE as yf,lQ as vf,u7 as wf,b7 as jf,jG as kf,u8 as Sf,u9 as xs,lZ as sl,ua as rl,ub as Cf,uc as Nf,ud as ol,ue as ca,uf as la,ug as al,b6 as Af,uh as Ef,ui as If,uj as il,uk as cl,ul as Qn,um as Rf,un as Tf,uo as Df,up as ll,gn as Ws,uq as Ar,ur as Of,cz as vn,H as dl,aW as Mf,us as ul,eP as da,kj as jo,bk as _f,t as Pf,ix as Er,i0 as Lf,aR as ko,ie as ml,ut as Ff,m5 as $f,m6 as Bf,pm as zf,l0 as Uf,uu as Kf,l2 as ua,lR as hl,bI as Hf,bJ as Wf,bK as Gf,bL as qf,bM as Yf,bN as Vf,bO as Qf,uv as Xf,uw as Ir,ux as Jf,uy as Xs,uz as Zf,uA as ep,uB as _n,uC as tp,uD as ma,mY as np,lK as sp,uE as rp,k7 as op,k8 as ap,bb as bs,k9 as ip,ka as ha,mn as fa,ml as cp,mm as pa,uF as lp,lY as dp,uG as up,uH as mp,fc as hp,uI as fp,uJ as pp,uK as gp,c0 as xp,uL as bp,uM as fl,uN as pl,Q as So,T as Co,V as No,uO as yp,uP as vp,bW as wp,fZ as jp,uQ as Js,ha as kp,gz as Sp,uR as Cp,uS as Np,uT as Ap,uU as Ep,uV as Ip,uW as Rp,uX as ga,uY as Tp,uZ as Dp,u_ as Op,u$ as gl,jE as Mp,bV as _p,v0 as xl,v1 as Pp,fC as Lp,v2 as xa,h$ as Fp,v3 as $p,v4 as Bp,pn as zp,v5 as Up,v6 as Kp,ck as Hp,v7 as Wp,v8 as ba,v9 as Gp,va as qp,vb as Gs,bj as bl,a3 as yl,vc as vl,pZ as Yp,bh as Vp,bi as Qp,eU as ya,bg as Xp,gO as Zs,gW as er,en as Jp,vd as Ao,n as Zp,aT as va,pl as eg,bB as wl,ve as jl,vf as kl,q8 as tg,vg as ng,ph as sg,pA as rg,jY as og,ea as ag,vh as ig,ab as Sl,vi as cg,jS as lg,jT as dg,kL as ug,fi as Cl,fj as Nl,fk as Al,fl as El,dF as mg,eo as hg,fg,fh as pg,j7 as gg,je as xg,kP as bg,j8 as yg,vj as vg,eu as wg,kQ as jg,vk as Il,vl as kg,vm as Sg,kO as Cg,kN as Ng,j9 as Ag,ex as Eg,k1 as Ig,i_ as Rg,vn as Tg,vo as Rl,vp as Dg,vq as Og,vr as nn,dp as Mg,vs as wa,ny as _g,nA as Tl,dK as Pg,jN as Lg,oU as Fg,vt as Rr,f_ as $g,iw as Bg,nL as mt,nN as zg,rH as Ug,o4 as ja,cQ as Kg,vu as Hg,vv as Wg,vw as Gg,vx as qg,vy as Yg,vz as Vg,vA as Qg,vB as Xg,vC as Jg,s4 as Zg,kE as ex,h8 as tx,vD as nx,vE as sx,vF as rx,vG as ox,vH as ax,vI as ix,cw as cx,vJ as lx,ji as dx,d5 as ux}from"./index-YUtEyz7O.js";import{u as mx,g as hx}from"./use-connector-management-CHLdhBhC.js";import{D as It,a as fx}from"./TourHost-CrZciWIf.js";import{C as Eo,o as Dl,O as Ol,p as it,H as px,q as St,I as rt,t as ys,s as Gn,v as Ml,x as gx,y as _l,z as xx,u as Pl,r as bx,w as yx,b as vx,j as wx,D as Tr,P as jx,B as kx,e as Ll,E as Fl,F as $l,G as Sx,J as Cx,h as Nx,S as ka,A as Ax,T as Ex,a as Ix,n as Rx,L as Tx}from"./SeenDevices-Cix5nnGQ.js";import{I as Sa,t as Dx}from"./trust-posture-CfEIPM4Z.js";import{u as qn}from"./use-update-config-Ce7sHmp2.js";import{b as Ox,u as Mx,O as _x,c as Px}from"./OpenMeshSwitch-C9hiAEHP.js";import{u as Lx,S as Fx,s as $x,b as Bx,P as zx,a as Ux}from"./ApplyToOverridesDialog-DRtcLrVY.js";import{B as Kx,u as Hx}from"./use-bindings-DhOKnybh.js";import{a as Bl,C as Wx}from"./cpu-DNvpMmNN.js";import{r as Gx,f as qx,b as Yx,K as Vx}from"./RuntimeConnectFlow-DsawxJN7.js";import{O as Qx,B as zl}from"./banner-DOgGDCJ5.js";import{u as qs,P as Ul,a as Xx}from"./ProfileRolePicker-CT9eJ1J0.js";import{u as Jx}from"./use-dev-links-BjLPuSUC.js";import{d as Zx}from"./untrusted-text-BDygHCRk.js";import{S as An}from"./scroll-area-RSd8NjrE.js";import{T as Kl,a as Hl,b as os,c as tr,u as eb,i as tb,d as nb,P as Wl}from"./PreviewRefusedNotice-Dt2hV0aJ.js";import{P as sb}from"./paperclip-AGN67YEM.js";import{L as rb}from"./lightbulb-CSPTiZoi.js";import{r as Gl,s as Ca,e as ob}from"./access-copy-BAhTOOsG.js";import{a as ab}from"./use-pulse-freshness-Y11Ibit1.js";import{c as ib,B as cb,w as lb,b as db,a as ub,e as mb}from"./primer-trigger-CmE4Ib-X.js";import{M as hb,u as fb,s as pb,P as gb,a as xb}from"./use-promo-activation-CAJItujg.js";import{u as ql}from"./use-promo-dismissals-C6bPU5Rm.js";import{u as Yl}from"./use-pending-read-C1oA2H00.js";import{a as gt}from"./dorkbot-templates-8Yu9POWJ.js";import{i as bb,O as Vl,c as yb,b as vb}from"./OperatorIdentityForm-CjmMoP6n.js";import{A as Ql}from"./repeat-B1wCYWXI.js";import{S as Xl,P as wb}from"./progress-BTu_QWg8.js";import{P as jb,M as kb}from"./plug-C-4o4Kb8.js";import{i as Io,a as Sb,u as Cb}from"./use-notification-prefs-qcYeVmLQ.js";import{R as Nb}from"./rotate-cw-hUzouNTK.js";import{u as Ab,a as Eb,C as Ib,N as Rb}from"./NewDirectMessageMenu-CMp4ppiH.js";import{P as Tb,C as Db,f as Ob,a as Mb}from"./find-latest-widget-fence-SQB9WgjN.js";import{o as _b}from"./owner-notice-DoH-_Veh.js";import{U as Pb}from"./unplug-B3eDst8L.js";import{c as Lb,H as Jl,a as Zl,b as ed}from"./RuntimeSetupDialog-bdf844gx.js";import{u as td}from"./use-is-below-desktop-BjWA-tqP.js";import{P as Fb,u as $b}from"./pane-resize-handle-_EuIpxzc.js";import{a as Bb,u as zb,F as Ub}from"./ForwardConsentHost-ml3b_fsX.js";import{W as Kb}from"./WithheldExtensionsNotice-VMM5NjL5.js";import{u as Hb}from"./use-direct-message-panel-ClXVf94w.js";import{u as Wb}from"./ComputerViewer-H7kJSIj7.js";import{a as Gb}from"./use-local-browser-C-V2n_wd.js";import{F as qb}from"./file-text-CB9l6Ur-.js";import{P as Na}from"./page-container-Bcz5wJVR.js";import{A as Yb}from"./AttentionSignalRow-CqKZyoxB.js";import{u as Vb}from"./use-roving-tab-list-DK0OzOUz.js";import{R as nd}from"./rotate-ccw-clock-Ds8cHkxD.js";import{d as nt,e as Ae,f as Aa,g as sd,C as rd,a as od,b as ad,c as Qb}from"./command-CZqA020F.js";import{A as Xb,M as Jb}from"./McpAppFrame-CWiRFp8o.js";import{L as Zb}from"./layers-Bfdpn7ZM.js";import{A as ey}from"./AgentOptionRow-388OJkPc.js";import{R as ty}from"./radio-DBitPjM1.js";import{a as ny}from"./sound-D3r8dGFH.js";import{d as sy}from"./connection-copy--MA7AN04.js";import{P as ry}from"./path-input-jrT0Ap4j.js";import"./WidgetErrorCard-CQKYI7oK.js";import{a as oy}from"./ComputerResourceView-CYMMSE8Y.js";import"./use-external-adapter-catalog-D1INoacX.js";import"./execution-config-BjLHHc9x.js";import"./settings-for-runtime-BoOa-ZFG.js";import"./use-mesh-topology-BzSFyR_s.js";import"./copy-button-ByA00JGh.js";import"./inline-code-BL-6EKVP.js";import"./useMutationState-Rlga1GBT.js";import"./runtime-connect-Dn0T5YWv.js";import"./shield-x-KL4ZbHfz.js";import"./use-full-activity-feed-GWBg-_1B.js";import"./profile-errors-vJU1kT3U.js";import"./use-mounted-ref-1T3JbkY1.js";import"./ProfileFields-DD6X85w2.js";import"./list-runtime-types-7qV7HQ7K.js";import"./more-details-DF2dJXMV.js";import"./index-CTJA-mZu.js";import"./markdown-content-CiDXslQf.js";import"./table-CfLst6CF.js";import"./package-Fm_v1gMn.js";import"./heart-C6uRnXx3.js";import"./git-branch-CPOwiT8a.js";import"./file-D7_QdH_S.js";/**
2
+ * @license lucide-react v1.48.0 - ISC
3
+ *
4
+ * This source code is licensed under the ISC license.
5
+ * See the LICENSE file in the root directory of this source tree.
6
+ */const id={name:"building-complex",size:24,node:[["path",{d:"M10 12h4",key:"a56b0p"}],["path",{d:"M10 8h4",key:"1sr2af"}],["path",{d:"M14 21v-3a2 2 0 0 0-4 0v3",key:"1rgiei"}],["path",{d:"M6 10H4a2 2 0 0 0-2 2v7a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2h-2",key:"secmi2"}],["path",{d:"M6 21V5a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v16",key:"16ra0t"}]],aliases:["building-2"]};id.node;const ay=We(id);/**
7
+ * @license lucide-react v1.48.0 - ISC
8
+ *
9
+ * This source code is licensed under the ISC license.
10
+ * See the LICENSE file in the root directory of this source tree.
11
+ */const cd={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"}]]};cd.node;const iy=We(cd);/**
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 ld={name:"chevron-up",size:24,node:[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]]};ld.node;const cy=We(ld);/**
17
+ * @license lucide-react v1.48.0 - ISC
18
+ *
19
+ * This source code is licensed under the ISC license.
20
+ * See the LICENSE file in the root directory of this source tree.
21
+ */const dd={name:"circle-plus",size:24,node:[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 12h8",key:"1wcyev"}],["path",{d:"M12 8v8",key:"napkw2"}]],aliases:["plus-circle"]};dd.node;const ly=We(dd);/**
22
+ * @license lucide-react v1.48.0 - ISC
23
+ *
24
+ * This source code is licensed under the ISC license.
25
+ * See the LICENSE file in the root directory of this source tree.
26
+ */const ud={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"}]]};ud.node;const md=We(ud);/**
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 hd={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"}]]};hd.node;const dy=We(hd);/**
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 fd={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"}]]};fd.node;const uy=We(fd);/**
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 pd={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"}]]};pd.node;const vs=We(pd);/**
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 gd={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"}]]};gd.node;const my=We(gd);/**
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 xd={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"}]]};xd.node;const hy=We(xd);/**
52
+ * @license lucide-react v1.48.0 - ISC
53
+ *
54
+ * This source code is licensed under the ISC license.
55
+ * See the LICENSE file in the root directory of this source tree.
56
+ */const bd={name:"message-square-text",size:24,node:[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}],["path",{d:"M7 11h10",key:"1twpyw"}],["path",{d:"M7 15h6",key:"d9of3u"}],["path",{d:"M7 7h8",key:"af5zfr"}]]};bd.node;const fy=We(bd);/**
57
+ * @license lucide-react v1.48.0 - ISC
58
+ *
59
+ * This source code is licensed under the ISC license.
60
+ * See the LICENSE file in the root directory of this source tree.
61
+ */const yd={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"]};yd.node;const py=We(yd);/**
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 vd={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"}]]};vd.node;const gy=We(vd);function xy({children:e,isValidProp:t,...s}){t&&Zu(t);const r=u.useContext(Vo);s={...r,...s},s.transition=em(s.transition,r.transition),s.isStatic=Jr(()=>s.isStatic);const o=u.useMemo(()=>s,[JSON.stringify(s.transition),s.transformPagePoint,s.reducedMotion,s.skipAnimations]);return n.jsx(Vo.Provider,{value:o,children:e})}function by(e){e.values.forEach(t=>t.stop())}function Dr(e,t){[...t].reverse().forEach(r=>{const o=e.getVariant(r);o&&Ji(e,o),e.variantChildren&&e.variantChildren.forEach(a=>{Dr(a,t)})})}function yy(e,t){if(Array.isArray(t))return Dr(e,t);if(typeof t=="string")return Dr(e,[t]);Ji(e,t)}function vy(){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(tm(a,s,{transitionOverride:r}))}),Promise.all(o)},set(s){return e.forEach(r=>{yy(r,s)})},stop(){e.forEach(s=>{by(s)})},mount(){return()=>{t.stop()}}};return t}function wy(){const e=Jr(vy);return nm(e.mount,[]),e}class jy{constructor(){this.componentControls=new Set}subscribe(t){return this.componentControls.add(t),()=>this.componentControls.delete(t)}start(t,s){this.componentControls.forEach(r=>{r.start(t.nativeEvent||t,s)})}cancel(){this.componentControls.forEach(t=>{t.cancel()})}stop(){this.componentControls.forEach(t=>{t.stop()})}}const ky=()=>new jy;function Sy(){return Jr(ky)}const Cy=`${Zr.repo}/issues/new`,Ny={"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"},Ay={"runtimes.default":["claude-code","codex","opencode","doe"],"logging.level":["fatal","error","warn","info","debug","trace"],"ui.theme":["light","dark","system"]},Ey=/^[a-z0-9][a-z0-9._-]{0,31}$/,Iy={bug:["bug"],feature:["enhancement"],runtime:["bug"]},Ry={bug:"Bug: (describe what went wrong)",feature:"Feature: (describe what you want)",runtime:"Runtime issue: (describe what went wrong)"};function Ty(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 Ro(e){return Ty(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 Dy(e,t){const s=Ay[e];return s?s.includes(t):Ey.test(t)&&Ro(t)===t}function Oy(e){const t={};for(const[s,r]of Object.entries(Ny)){const o=e[s];o!=null&&(r==="boolean"&&typeof o=="boolean"||r==="number"&&typeof o=="number"&&Number.isFinite(o)||r==="enum"&&typeof o=="string"&&Dy(s,o))&&(t[s]=o)}return t}const My=["details","summary"];function To(e){return Zx(Ro(e),My)}function _y(e){const t=e.runtimes.length>0?e.runtimes.join(", "):"none configured",s=Object.entries(e.flags).map(([o,a])=>`- ${o}: ${String(a)}`).join(`
67
+ `),r=[`- DorkOS version: ${e.version}`,`- OS / arch: ${e.platform}`,`- Runtimes configured: ${t}`,`- Reported from: ${e.surface}`,"","Settings (on/off values only, no secrets or file paths):",s.length>0?s:"- (none available)"];return Ro(r.join(`
68
+ `))}function Py(e){var s;const t=(s=e.body)==null?void 0:s.trim();return t?[To(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 Ly(e){return["<details><summary>Environment</summary>","",_y(e),"","</details>","","DorkOS filled in the details above. Please check them and remove anything you do not want to share.","","---","",...Py(e)].join(`
69
+ `)}function nr(e){var r;const t=(r=e.title)==null?void 0:r.trim(),s=new URLSearchParams({title:To(t||Ry[e.kind]),body:Ly(e),labels:Iy[e.kind].join(",")});return`${Cy}?${s.toString()}`}const Fy=6e3,Ea=`
70
+
71
+ … (shortened to fit the link; paste the rest yourself)`;function Ia(e){return new TextEncoder().encode(e).length}function Ra(e,t){return Array.from(e).slice(0,t).join("")}function $y(e,t=Fy){var d;const s=nr(e);if(Ia(s)<=t)return{url:s,truncated:!1};const r=((d=e.body)==null?void 0:d.trim())??"";if(!r)return{url:s,truncated:!1};const o=Array.from(r).length;let a=0,i=o;for(;a<i;){const l=Math.ceil((a+i)/2),m={...e,body:Ra(r,l)+Ea};Ia(nr(m))<=t?a=l:i=l-1}const c={...e,body:Ra(r,a)+Ea};return{url:nr(c),truncated:!0,fullBody:To(r)}}function By(e){return $y(e).url}function zy(e){var t,s,r,o,a,i,c,d,l,m;return{"tunnel.enabled":(t=e.tunnel)==null?void 0:t.enabled,"tasks.enabled":(s=e.tasks)==null?void 0:s.enabled,"relay.enabled":(r=e.relay)==null?void 0:r.enabled,"mesh.enabled":(o=e.mesh)==null?void 0:o.enabled,"mcp.enabled":(a=e.mcp)==null?void 0:a.enabled,"telemetry.install":(i=e.telemetry)==null?void 0:i.install,"telemetry.heartbeat":(c=e.telemetry)==null?void 0:c.heartbeat,"telemetry.errorReporting":(d=e.telemetry)==null?void 0:d.errorReporting,"auth.enabled":(l=e.auth)==null?void 0:l.enabled,"logging.level":(m=e.logging)==null?void 0:m.level}}function wd(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?Oy(zy(t)):{}}}function Uy(){const e=ae(),{data:t}=Ee({queryKey:Fe.current(),queryFn:()=>e.getConfig(),staleTime:300*1e3}),s=De({select:r=>r.location.pathname});return u.useCallback(r=>{const o=By(wd(r,t,s));Tn(o)},[t,s])}const Ky=100;function Hy({cwd:e,isStreaming:t,color:s}){const r=u.useRef(""),o=u.useRef([]),a=u.useRef(null),i=u.useRef(0),c=u.useRef(t);u.useEffect(()=>{c.current=t},[t]);const d=u.useCallback(()=>{a.current&&(clearInterval(a.current),a.current=null),o.current.length!==0&&(i.current=0,a.current=window.setInterval(()=>{const m=o.current;m.length!==0&&(Qs(m[i.current]),i.current=(i.current+1)%m.length)},Ky))},[]),l=u.useCallback(()=>{a.current&&(clearInterval(a.current),a.current=null),r.current&&Qs(r.current)},[]);u.useEffect(()=>{if(!e)return;const m=s??ds(e),h=sm(m);r.current=h,o.current=[],Qs(h);let p=!1;return rm(h).then(f=>{p||(o.current=f,c.current&&d())}).catch(()=>{}),()=>{p=!0}},[e,s,d]),u.useEffect(()=>(t?d():l(),l),[t,d,l])}function Wy(e,t){const[s,r]=u.useState(()=>document.hidden),[o,a]=u.useState(!1);u.useEffect(()=>{const d=()=>{r(document.hidden),document.hidden||a(!1)};return document.addEventListener("visibilitychange",d),()=>document.removeEventListener("visibilitychange",d)},[]);const i=u.useRef(t);u.useEffect(()=>{i.current&&!t&&document.hidden&&a(!0),i.current=t},[t]);const c=e({hidden:s,unseenReply:o});u.useEffect(()=>{document.title=c},[c])}function Gy(){const e=le();fe("notification",t=>{(t==null?void 0:t.kind)==="signin.required"&&e.invalidateQueries({queryKey:Qo.all})}),fe("account_usage",t=>{const s=t;!s||typeof s.runtime!="string"||e.getQueryData(Qo.usage(s.runtime))!==void 0&&om(e,s.runtime,[s])})}function qy(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 Yy(e){const[t,s]=u.useState(0),r=u.useRef([]);function o(){const l=r.current.slice(0,e).filter(Boolean);if(l.length===0)return 1;const m=l[0].offsetTop;return Math.max(1,l.filter(h=>h.offsetTop===m).length)}function a(l){var h;const m=Math.max(0,Math.min(e-1,l));s(m),(h=r.current[m])==null||h.focus()}function i(l){return m=>{r.current[l]=m}}function c(l){return t===l?0:-1}function d(l,m){const h=qy(l.key,m,o(),e);h!==null&&(l.preventDefault(),a(h))}return{focusIndex:t,setRef:i,tabIndexFor:c,handleKeyDown:d,moveFocus:a}}function jd(){const[e,t]=u.useState(Ta);return u.useEffect(()=>{const s=window.visualViewport,r=()=>{const o=Ta();t(a=>a.top===o.top&&a.height===o.height?a:o)};return window.addEventListener("resize",r),s==null||s.addEventListener("resize",r),s==null||s.addEventListener("scroll",r),()=>{window.removeEventListener("resize",r),s==null||s.removeEventListener("resize",r),s==null||s.removeEventListener("scroll",r)}},[]),e}function Ta(){if(typeof window>"u")return{top:0,height:0};const e=window.visualViewport;return e&&e.scale<=1?{top:Math.max(0,e.offsetTop),height:e.height}:{top:0,height:window.innerHeight}}const Da=16,Vy=280,Qy=180;function Oa(e,t,s){const r=Math.max(t,window.innerWidth-Da),o=Math.max(s,window.innerHeight-Da),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 Jy(e){const{title:t,geometry:s,onGeometryChange:r,onClose:o,onRestore:a,minWidth:i,minHeight:c,children:d,className:l}=e,m=u.useRef(null),h=i??Vy,p=c??Qy;u.useEffect(()=>{const b=()=>{const C=Oa(s,h,p);Xy(C,s)&&r(C)};return b(),window.addEventListener("resize",b),()=>window.removeEventListener("resize",b)},[s,h,p,r]);const f=u.useRef(null);u.useEffect(()=>()=>{var b;return(b=f.current)==null?void 0:b.call(f)},[]);const g=u.useCallback((b,C)=>{var N;b.preventDefault();const S=m.current;if(!S)return;const I=S;(N=f.current)==null||N.call(f);const v=b.clientX,E=b.clientY,R=s;let M=R,O=0;function _(){O=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 D(w){M=C(w.clientX-v,w.clientY-E,R),O||(O=requestAnimationFrame(_))}function k(){O&&cancelAnimationFrame(O),O=0,document.removeEventListener("pointermove",D),document.removeEventListener("pointerup",j),document.removeEventListener("pointercancel",j),f.current=null}function j(){k(),r(Oa(M,h,p))}document.addEventListener("pointermove",D),document.addEventListener("pointerup",j),document.addEventListener("pointercancel",j),f.current=k},[s,h,p,r]),x=u.useCallback(b=>{b.target.closest("button")||g(b,(C,S,I)=>({...I,x:I.x+C,y:I.y+S}))},[g]),y=u.useCallback(b=>{b.stopPropagation(),g(b,(C,S,I)=>({...I,width:Math.max(h,I.width+C),height:Math.max(p,I.height+S)}))},[g,h,p]);return Ns.createPortal(n.jsxs(se.div,{ref:m,"data-slot":"floating-panel",role:"complementary","aria-label":t,initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.95},transition:{duration:.15,ease:[0,0,.2,1]},style:{left:s.x,top:s.y,width:s.width,height:s.height},className:K("bg-card border-border shadow-floating fixed z-40 flex flex-col overflow-hidden rounded-lg border",l),children:[n.jsxs("div",{onPointerDown:x,className:"border-border flex cursor-grab items-center gap-1 border-b px-3 py-2 select-none active:cursor-grabbing",children:[n.jsx("span",{className:"min-w-0 flex-1 truncate text-sm font-medium",children:t}),a?n.jsx(L,{variant:"ghost",size:"icon-sm","aria-label":"Restore",onClick:a,className:"text-muted-foreground hover:text-foreground",children:n.jsx(Tb,{})}):null,n.jsx(L,{variant:"ghost",size:"icon-sm","aria-label":"Close",onClick:o,className:"text-muted-foreground hover:text-foreground",children:n.jsx(Be,{})})]}),n.jsx("div",{className:"min-h-0 flex-1 overflow-auto",children:d}),n.jsx("div",{"aria-hidden":!0,onPointerDown:y,className:"absolute right-0 bottom-0 size-4 cursor-nwse-resize"})]}),document.body)}function Zy({...e}){const{theme:t}=Zi();return n.jsx(am,{theme:t,className:"toaster group",icons:{success:n.jsx(As,{className:"size-4"}),info:n.jsx(tc,{className:"size-4"}),warning:n.jsx(ec,{className:"size-4"}),error:n.jsx(Qx,{className:"size-4"}),loading:n.jsx(Oe,{})},style:{"--normal-bg":"var(--color-popover)","--normal-text":"var(--color-popover-foreground)","--normal-border":"var(--color-border)","--border-radius":"var(--radius)"},...e})}async function ev(){var t;if(!$e())return;const e=(t=window.electronAPI)==null?void 0:t.getShellLogExcerpt;if(typeof e=="function")try{const s=await e();return s&&s.length>0?s:void 0}catch{return}}const kd="root";function Sd(){return document.getElementById(kd)??document.body}const Ma=2e4;class ot extends Error{constructor(s,r){super(r);yn(this,"reason");this.name="AppCaptureError",this.reason=s}}function tv(){const e=typeof window<"u"?window.electronAPI:void 0;if(typeof(e==null?void 0:e.captureAppView)!="function")return null;const{captureAppView:t}=e;return()=>t()}function nv(){return new Promise(e=>{requestAnimationFrame(()=>requestAnimationFrame(()=>e()))})}function sv(){const e=[];for(const t of Array.from(document.body.children)){if(!(t instanceof HTMLElement)||t.id===kd)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 rv(e){const t=await e().catch(s=>{throw new ot("failed",`The desktop bridge threw: ${String(s)}`)});if(!t.ok)throw new ot("failed",t.message);return{dataUrl:t.dataUrl,region:{left:0,top:0,width:window.innerWidth,height:window.innerHeight}}}async function ov(){let e;try{({snapdom:e}=await im(()=>import("./snapdom-SRLjr6oU.js"),[]))}catch(r){const o=r instanceof Error?r.message:String(r);throw new ot("unsupported",`Loading the screenshot library failed: ${o}`)}const t=Sd(),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 ot("failed",`Rendering the app to an image failed: ${o}`)}}async function av(e){let t;const s=new Promise((r,o)=>{t=setTimeout(()=>{o(new ot("failed",`The capture did not finish in ${Ma}ms.`))},Ma)});try{return await Promise.race([e,s])}finally{clearTimeout(t),e.catch(()=>{})}}async function iv(){const e=tv(),t=sv();try{return await nv(),await av(e?rv(e):ov())}finally{t()}}let wn=null;function Cd(){if(wn)return wn;const e=iv();wn=e;const t=()=>{wn===e&&(wn=null)};return e.then(t,t),e}function cv(){return Cd().then(e=>e.dataUrl)}function lv(){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 dv(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone||void 0}catch{return}}function uv(e){const t=lv(),s=typeof navigator<"u"?navigator.userAgent:void 0,r=typeof navigator<"u"?navigator.language:void 0,o=dv();return{theme:e,shell:$e()?"desktop-app":"browser",...t?{viewport:t}:{},...s?{browser:s.slice(0,cm)}:{},...r?{locale:r.slice(0,Xo)}:{},...o?{timezone:o.slice(0,Xo)}:{}}}function Ys(e){return t=>()=>{e(),t()}}const mv=2e3,hv=.8,fv=1400,pv=.6,as=6e5,ws=1e4,gv=["image/webp","image/jpeg","image/png"],xv=/^data:image\/(webp|png|jpeg);base64,/;class qt extends Error{constructor(s,r){super(r);yn(this,"reason");this.name="ImageCompressError",this.reason=s}}function bv(e){return xv.test(e)&&e.length<=as}function yv(e){return new Promise((t,s)=>{const r=new Image,o=setTimeout(()=>{s(new qt("unreadable",`Decoding timed out after ${ws}ms.`))},ws);r.onload=()=>{clearTimeout(o),t(r)},r.onerror=()=>{clearTimeout(o),s(new qt("unreadable",`Could not decode the image at ${e.slice(0,32)}…`))},r.src=e})}function vv(e,t){for(const s of gv){const r=e.toDataURL(s,t);if(r.startsWith(`data:${s};base64,`))return r}throw new qt("unsupported","This canvas produced no usable image encoding.")}function _a(e,t,s=mv){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 Pa(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 qt("unsupported","This browser gave no 2d canvas context.");return o.drawImage(e,0,0,t.width,t.height),vv(r,s)}async function Or(e){const t=typeof e=="string"?null:URL.createObjectURL(e);let s;try{s=await yv(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 qt("unreadable","The image decoded to zero pixels.");let a=Pa(s,_a(r,o),hv);if(a.length>as&&(a=Pa(s,_a(r,o,fv),pv)),a.length>as)throw new qt("too-large",`Compressed to ${a.length} characters, over the ${as} cap.`);return a}const wv=500;function jv(e=wv){const t=le(),s=lm({coalesceMs:e,shouldFlush:()=>t.isMutating({mutationKey:nc})===0});fe("config_changed",()=>{const r={queryKey:Fe.current()};s([r])})}const Nd="dorkbot",kv=["mesh","agent-paths"];function Sv(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)||Nd;return`${t}/${s}`}function Cv(){var d;const e=Me(),t=ae(),{data:s}=_e(),{data:r}=Ee({queryKey:[...kv],queryFn:()=>t.listMeshAgentPaths(),staleTime:3e4}),o=((d=s==null?void 0:s.agents)==null?void 0:d.defaultAgent)||Nd,a=r==null?void 0:r.agents.find(l=>l.name===o),i=(a==null?void 0:a.projectPath)??Sv(s);return{startSession:u.useCallback(()=>{a?e(Kt({agentId:a.id})):i&&dm(t,i).then(l=>e(l)).catch(l=>{sc(t,l),ce.error("Couldn’t open the chat. Try again.")})},[e,i,a,t]),defaultAgentDir:i}}function Nv(e){return{pinned:e.pinned??[],groups:e.groups??[],muted:e.muted??[],sections:e.sections??{}}}function Av(){const e=le(),t=$n();fe("community_connections_changed",()=>{t&&e.invalidateQueries({queryKey:Ct.connections(t),exact:!0})})}function Ad(e){const t=ae(),s=e!==null&&e.status!=="pending",r=$n(s),o=(e==null?void 0:e.ref)??"";return Ee({queryKey:r?Ct.disconnectImpact(r,o):[...Ct.all,"owner","unresolved",o,"disconnect-impact"],queryFn:()=>rc(r,()=>t.getCommunityDisconnectImpact(o)),enabled:s&&r!==null,staleTime:0,refetchOnMount:"always"})}function Ed(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 Id(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}: ${Ed(t)}.`}function Rd(e){return`Any agents you added from here will be removed from ${e}.`}function Td(e,{remoteRevoked:t,agentsNotRemoved:s}){const r=Ed(s);return s.length===0?t?{tone:"success",message:`${e} is disconnected.`}:{tone:"warning",message:Ev(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 Ev(e){return`Disconnected here, but ${e} couldn’t be reached. Finish under Connected installations on ${e}.`}function Iv(){const e=ae(),t=P(o=>o.selectedCwd),s=P(o=>o.setSelectedCwd),{data:r}=Ee({queryKey:["defaultCwd"],queryFn:()=>e.getDefaultCwd(),enabled:t===null,staleTime:1/0,refetchOnMount:!1,refetchOnReconnect:!1,networkMode:"always"});u.useEffect(()=>{r!=null&&r.path&&P.getState().selectedCwd===null&&s(r.path)},[r,t,s])}function La(e){e.invalidateQueries({queryKey:ln.recentRoot})}const Rv=5e3;function Tv(e,t=Rv){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 Fa(e){e.invalidateQueries({queryKey:ln.dailyCountsRoot})}function Dv(e,t){const s=Object.keys(e);return s.length!==Object.keys(t).length?!0:s.some(r=>!(r in t))}function Ov(e,t){e.setQueryData(ln.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 Mv(e,t,s){e.setQueryData(ln.list(s),r=>r&&r.filter(o=>o.id!==t))}function $a(e,t,s){const r=new Set(Object.keys(t).filter(o=>!(o in s)));r.size!==0&&e.setQueriesData({queryKey:ln.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 Ba(e,t,s){const r=Date.now(),o=[];for(const[a,i]of Object.entries(t))s[a]!==i&&(Ov(e,i),o.push(i));mm(e,o,r);for(const[a,i]of Object.entries(s))t[a]||Mv(e,a,i.cwd??null)}function _v(){const e=le();u.useEffect(()=>{um();let t={},s={};const r=Tv(()=>La(e)),o=Nt.subscribe(c=>{c.sessions!==t&&(Ba(e,c.sessions,t),r.request(),Dv(c.sessions,t)&&Fa(e),t=c.sessions),c.rekeys!==s&&($a(e,c.rekeys,s),s=c.rekeys)}),a=us.subscribeEvent("session_list_invalidated",()=>{Nt.getState().dropSessions(),e.invalidateQueries({queryKey:ln.listRoot}),La(e),Fa(e)}),i=Nt.getState();return Object.keys(i.sessions).length>0&&(Ba(e,i.sessions,t),t=i.sessions),Object.keys(i.rekeys).length>0&&($a(e,i.rekeys,s),s=i.rekeys),us.connectList(),()=>{o(),a(),r.dispose()}},[e])}function Zt(){const e=ae(),t=le(),{data:s,isLoading:r}=Ee({queryKey:Fe.current(),queryFn:()=>e.getConfig(),staleTime:oc}),o=Yl(r),a={completedSteps:[],skippedSteps:[],startedAt:null,dismissedAt:null,completedAt:null,runtimeDefaultSetAt:null,firstRunPath:null,welcomeEntryId:null,priorRuntime:null},i=s!=null&&s.onboarding?{completedSteps:s.onboarding.completedSteps,skippedSteps:s.onboarding.skippedSteps,startedAt:s.onboarding.startedAt,dismissedAt:s.onboarding.dismissedAt,completedAt:s.onboarding.completedAt??null,runtimeDefaultSetAt:s.onboarding.runtimeDefaultSetAt,firstRunPath:s.onboarding.firstRunPath??null,welcomeEntryId:s.onboarding.welcomeEntryId??null,priorRuntime:s.onboarding.priorRuntime??null}:a,c=i.completedAt!==null,d=i.dismissedAt!==null,m=!o&&s!==void 0&&!c&&!d,h=!o&&c&&!d,p=Vt({mutationFn:y=>e.updateConfig({onboarding:y}),onSuccess:()=>{t.invalidateQueries({queryKey:Fe.all})},onError:(y,b)=>{console.error("[onboarding] could not save progress",{fields:Object.keys(b),error:y}),ce.error("Couldn’t save your setup progress",{description:"Keep going. DorkOS tries again."})},meta:{suppressErrorToast:!0}});function f(){return p.mutateAsync({dismissedAt:new Date().toISOString()})}function g(){i.completedAt||p.mutate({completedAt:new Date().toISOString()})}function x(){i.startedAt||p.mutate({startedAt:new Date().toISOString()})}return{state:i,config:s,isLoading:o,isOnboardingComplete:c,isOnboardingDismissed:d,shouldShowOnboarding:m,shouldShowGettingStarted:h,dismiss:f,completeOnboarding:g,startOnboarding:x}}function Pv(e){const{shouldShowOnboarding:t,onboardingHiddenForSession:s}=e,r=t&&!s,[o,a]=u.useState(!1);return r&&!o&&a(!0),o&&!s}function Lv(){const e=eo(),t=Qt(),s=to({strict:!1}).onboarding,r=Jo(s)?s:"welcome",o=u.useRef(!1),a=De({select:l=>l.status==="idle"}),i=u.useRef(!1);u.useEffect(()=>{if(i.current||!a||(i.current=!0,Jo(s)))return;const l=m=>({...m,onboarding:"welcome"});e==null||e({search:l,replace:!0})},[a,s,e]);const c=u.useCallback(l=>{const m=h=>({...h,onboarding:l});o.current=!0,e==null||e({search:m})},[e]),d=u.useCallback(l=>{if(o.current){t.history.back();return}const m=h=>({...h,onboarding:l});e==null||e({search:m})},[t,e]);return{stage:r,goToStage:c,goBack:d}}function Fv(e){const{done:t,overlayVisible:s}=e,r=eo(),o=to({strict:!1}).onboarding;u.useEffect(()=>{if(!o||!t||s)return;const a=i=>({...i,onboarding:void 0});r==null||r({search:a,replace:!0})},[o,t,s,r])}function Dd(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 $v=2500,Bv="Couldn’t finish setup. Try again.";function Pn(e){return e instanceof Error&&e.message&&!/^HTTP \d+$/.test(e.message)?e.message:Bv}function Do(){const e=ae(),t=le();return Vt({mutationFn:s=>e.chooseFirstRunPath(s),onSettled:()=>{for(const s of[Fe.all,hm,ac.status()])t.invalidateQueries({queryKey:s});t.invalidateQueries({queryKey:fm})},meta:{suppressErrorToast:!0}})}function zv(e){const t=ae(),{data:s}=Ee({queryKey:ac.status(),queryFn:()=>t.getCloudCredits(),enabled:e,refetchInterval:e?$v:!1,refetchIntervalInBackground:e,staleTime:0});if(s)return s.readiness??(s.linked?"linked":"unlinked")}function Uv(){const e=ae(),t=le();return Vt({mutationFn:()=>e.postOnboardingWelcome(),onSettled:()=>void t.invalidateQueries({queryKey:Fe.all}),meta:{suppressErrorToast:!0}})}function Kv({link:e,waitingWindowRef:t,onReady:s}){const r=Do(),[o,a]=u.useState(null),[i,c]=u.useState(!1),d=zv(i),l=i?d:void 0,m=u.useRef(e),h=u.useRef(r.mutateAsync),p=u.useRef(s);u.useEffect(()=>{m.current=e,h.current=r.mutateAsync,p.current=s});const f=u.useCallback(()=>{var S;(S=t.current)==null||S.close(),t.current=null},[t]),g=u.useCallback(async()=>{a(null);try{await h.current({path:"dorkos"})}catch(v){f(),a(Pn(v));return}c(!0);const S=m.current;if(S.state==="linked"){f();return}if(S.state==="pending")return;await S.start()===null&&(f(),a(m.current.startError??"Couldn’t reach DorkOS. Try again."))},[f]),x=u.useRef(!1);u.useEffect(()=>{x.current||e.state==="loading"||(x.current=!0,g())},[e.state,g]);const y=e.state==="pending"?e.pending:null;u.useEffect(()=>{if(!y||!t.current)return;const S=Dd(y);S?t.current.go(S):t.current.close(),t.current=null},[y,t]);const b=u.useRef(!1);u.useEffect(()=>{l!=="ready"||b.current||(b.current=!0,p.current())},[l]);const C=u.useCallback(()=>{var S;if((S=t.current)==null||S.close(),t.current=no(),m.current.state==="expired"||m.current.state==="denied"){a(null),m.current.start();return}g()},[g,t]);return{phase:Hv(o,i,e,y,l),retry:C}}function Hv(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 Oo(){const e=u.useRef(null);return u.useEffect(()=>{var t;(t=e.current)==null||t.focus({preventScroll:!0})},[]),e}function Od({phase:e,link:t,onRetry:s,onCancel:r,onUseOwnAi:o}){const a=Oo();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(It,{size:72,className:"mb-6 opacity-90 dark:hidden"}),n.jsx(It,{variant:"white",size:72,className:"mb-6 hidden opacity-90 dark:block"}),n.jsx(Wv,{phase:e,link:t,onRetry:s,onUseOwnAi:o}),n.jsx(L,{variant:"ghost",size:"sm",className:"text-muted-foreground mt-8",onClick:r,children:"Cancel"})]})}function Wv({phase:e,link:t,onRetry:s,onUseOwnAi:r}){switch(e.kind){case"starting":return n.jsx(za,{heading:"Finish in your browser.",line:"Opening the DorkOS page…"});case"waiting":return n.jsxs(n.Fragment,{children:[n.jsx(tn,{children:"Finish in your browser."}),n.jsx(Xn,{children:"Sign in, then come back. This screen moves on by itself."}),n.jsx(Gv,{pending:e.pending})]});case"finishing":return n.jsx(za,{heading:"Signed in.",line:"Getting your account ready…"});case"needs-card":return n.jsxs(n.Fragment,{children:[n.jsx(tn,{children:"Add a card to finish."}),n.jsx(Xn,{children:"Your agents start once a card is saved."}),n.jsxs(L,{className:"mt-6",onClick:()=>t==null?void 0:t.openBilling(),disabled:!t||t.billingPending,children:[(t==null?void 0:t.billingPending)&&n.jsx(Oe,{size:"xs"}),"Add a card"]}),(t==null?void 0:t.billingNotice)&&n.jsx(Mr,{children:t.billingNotice})]});case"refused":return n.jsxs(n.Fragment,{children:[n.jsx(tn,{children:"Paid plans are US only."}),n.jsx(Xn,{children:"Use your own AI instead."}),n.jsx(L,{className:"mt-6",onClick:r,children:"Use my own AI"})]});case"expired":return n.jsxs(n.Fragment,{children:[n.jsx(tn,{children:"Your code expired."}),n.jsx(Xn,{children:"Get a new one to finish signing in."}),n.jsx(L,{className:"mt-6",onClick:s,children:"Get a new code"})]});case"failed":return n.jsxs(n.Fragment,{children:[n.jsx(tn,{children:"Couldn’t start signing in."}),n.jsx(Mr,{children:e.message}),n.jsx(L,{className:"mt-6",onClick:s,children:"Try again"})]})}}function za({heading:e,line:t}){return n.jsxs(n.Fragment,{children:[n.jsx(tn,{children:e}),n.jsxs("p",{className:"text-muted-foreground mt-3 flex items-center gap-2 text-sm",role:"status",children:[n.jsx(Oe,{size:"xs"}),t]})]})}function tn({children:e}){return n.jsx("h1",{id:"onboarding-connecting-heading",className:"text-2xl font-semibold tracking-tight text-balance",children:e})}function Xn({children:e}){return n.jsx("p",{className:"text-muted-foreground mt-3 text-sm text-balance",children:e})}function Mr({children:e}){return n.jsx("p",{className:"text-destructive mt-3 text-sm text-balance",role:"alert",children:e})}function Gv({pending:e}){const{copied:t,failed:s,copy:r}=Bn(),[o,a]=u.useState(!1),i=Dd(e);return n.jsxs("div",{className:"mt-8 w-full space-y-4","data-testid":"onboarding-link-code",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("code",{className:"bg-muted min-w-0 flex-1 rounded-md px-3 py-3 text-center font-mono text-lg font-semibold tracking-[0.15em] whitespace-nowrap tabular-nums sm:text-xl",children:e.userCode}),n.jsx(L,{variant:"ghost",size:"icon-md",onClick:()=>void r(e.userCode),"aria-label":s?"Couldn’t copy code. Try again":"Copy code",children:t?n.jsx(Xt,{className:"text-status-success size-4"}):s?n.jsx(Be,{className:"text-destructive size-4"}):n.jsx(so,{className:"size-4"})})]}),n.jsxs(L,{variant:"outline",className:"w-full",disabled:i===null,onClick:()=>a(i===null||!Tn(i)),children:[n.jsx(on,{className:"size-4"}),"Open the page again"]}),n.jsx("p",{className:"text-muted-foreground text-xs break-all",children:e.verificationUri}),o&&n.jsx(Mr,{children:"Couldn’t open the page. Copy the code instead."}),n.jsxs("p",{className:"text-muted-foreground flex items-center justify-center gap-2 text-sm",children:[n.jsx(Oe,{size:"xs"}),n.jsx("span",{role:"status",children:"Waiting for you to approve."})]})]})}function qv({onComplete:e}){const t=Uv(),{completeOnboarding:s}=Zt(),r=Me(),[o,a]=u.useState(null),i=u.useCallback(()=>{s(),r({...ve.home(),search:{}}),e()},[s,r,e]),c=u.useCallback(async()=>{a(null);try{await t.mutateAsync()}catch(l){a(Pn(l));return}i()},[t,i]),d=u.useRef(!1);return u.useEffect(()=>{d.current||(d.current=!0,c())},[c]),n.jsx("div",{className:"mx-auto flex w-full max-w-sm flex-col items-center px-4 text-center","data-testid":"onboarding-landing",children:o?n.jsxs(n.Fragment,{children:[n.jsx("p",{className:"text-destructive text-sm",role:"alert",children:o}),n.jsxs("div",{className:"mt-4 flex flex-wrap justify-center gap-2",children:[n.jsx(L,{onClick:()=>void c(),children:"Try again"}),n.jsx(L,{variant:"outline",onClick:i,children:"Go to #team"})]})]}):n.jsxs("p",{className:"text-muted-foreground flex items-center gap-2 text-sm",role:"status",children:[n.jsx(Oe,{size:"xs"}),"Opening #team…"]})})}const Yv="claude-code";function Md(e,t){return e.length===0?null:e.includes(t)?t:ic.find(r=>e.includes(r))??e[0]}function Vv({readyTypes:e,settled:t,settleToken:s}){var y,b;const{data:r}=_e(),o=qn(),a=le(),[i,c]=u.useState(null),[d,l]=u.useState(null),m=u.useRef(null),h=((y=r==null?void 0:r.executionDefaults)==null?void 0:y.runtime)??Yv,p=!!((b=r==null?void 0:r.onboarding)!=null&&b.runtimeDefaultSetAt),f=u.useCallback((C,S)=>{c(null),l(S),o.mutate(C,{onSuccess:()=>void a.invalidateQueries({queryKey:Fe.all}),onError:I=>{l(null),c(I.message||"Couldn’t save that. Try again.")}})},[o,a]);u.useEffect(()=>{if(!t||e.length===0||!r||p)return;const C=Md(e,h);C&&m.current!==s&&(m.current=s,f({onboarding:{runtimeDefaultSetAt:new Date().toISOString()},...C===h?{}:{runtimes:{default:C}}},C))},[t,s,e,r,p,h,f]);const g=u.useCallback(C=>{C!==(d??h)&&f({runtimes:{default:C},...p?{}:{onboarding:{runtimeDefaultSetAt:new Date().toISOString()}}},C)},[f,d,h,p]);return{runtime:d??((p||d!==null)&&r?h:null),current:d??h,choose:g,error:i}}function Qv({onContinue:e,renderConnect:t,simulated:s}){const r=cc(),{data:o}=lc(),{data:a}=dc(),i=(s==null?void 0:s.requirements)??r.data,c=s!==void 0||r.isSuccess,d=o?Object.keys(o.capabilities):void 0,l=u.useMemo(()=>ic.filter(y=>(i==null?void 0:i.runtimes[y])!==void 0),[i]),m=u.useMemo(()=>i?l.filter(y=>pm(i,y,!0).state==="ready"||s===void 0&&gm(a,y)):[],[l,i,a,s]),h=Vv({readyTypes:m,settled:c&&s===void 0,settleToken:r.dataUpdatedAt}),[p,f]=u.useState(null),g=s!=null&&s.defaultRuntime?{runtime:p??s.defaultRuntime,current:p??s.defaultRuntime,choose:f,error:null}:h;if(!c)return n.jsxs("p",{className:"text-muted-foreground flex items-center gap-2 text-sm",role:"status",children:[n.jsx(Oe,{size:"xs"}),"Looking for AI apps…"]});if(s===void 0&&r.isError)return n.jsxs("div",{className:"space-y-2",role:"alert",children:[n.jsx("p",{className:"text-muted-foreground text-sm",children:"Couldn’t check for AI apps."}),n.jsx(L,{variant:"outline",size:"sm",onClick:()=>void r.refetch(),children:"Try again"})]});const x=m.length>0;return n.jsxs("div",{className:"space-y-4","data-testid":"onboarding-ai-apps",children:[x&&n.jsxs("div",{className:"space-y-1",children:[n.jsx("p",{className:"text-sm",children:Jv(m,g.runtime)}),n.jsx(Xv,{chosen:g.current,readyTypes:m,otherTypes:l.filter(y=>!m.includes(y)),onChoose:g.choose}),g.error&&n.jsx("p",{className:"text-destructive text-xs","data-testid":"default-runtime-error",children:g.error})]}),n.jsx(Lb,{types:l,requirements:i,registeredTypes:d,renderConnect:t,onRecheck:s?void 0:()=>void r.refetch(),isRechecking:r.isFetching}),x&&n.jsx(L,{className:"w-full",onClick:e,"data-testid":"onboarding-ai-app-continue",children:"Continue"})]})}function Xv({chosen:e,readyTypes:t,otherTypes:s,onChoose:r}){const[o,a]=u.useState(!1),i=[...t,...s];return i.includes(e)||i.unshift(e),n.jsxs(dn,{open:o,onOpenChange:a,children:[n.jsxs(un,{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(Jt,{className:"size-3"})]}),n.jsxs(mn,{align:"start",className:"p-1",children:[n.jsx(hn,{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:ct(c).label}),!t.includes(c)&&n.jsx("span",{className:"text-muted-foreground text-xs",children:"Not signed in yet"})]}),d&&n.jsx(Xt,{className:"size-3.5 shrink-0","aria-hidden":!0})]},c)})})]})]})}function Jv(e,t){const s=e.map(c=>ct(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=ct(t).label;if(e.includes(t))return`${r} New chats start with ${o}.`;const a=Md(e,t),i=a?ct(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 Zv=[{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."}],ew={openai:"OpenAI API key",anthropic:"Anthropic API key",openrouter:"OpenRouter key"};function tw({onSaved:e,beforePick:t,slots:s,initialRow:r,simulatedApps:o}){const[a,i]=u.useState(r??null),c=Do(),[d,l]=u.useState(null),m=async(p,f=!1)=>{l(null);try{return await(t==null?void 0:t()),(await c.mutateAsync({path:"own",choice:p})).modelListed===!1&&ce("Using a default model. Change it in Settings."),!0}catch(g){if(f)throw new Error(Pn(g),{cause:g});return l(Pn(g)),!1}},h=p=>{l(null);const f=a===p?null:p;i(f),f==="agent-app"&&!o&&m({kind:"agent-app"})};return n.jsx("div",{className:"divide-border border-border w-full divide-y rounded-lg border text-left",children:Zv.map(p=>n.jsxs("section",{"data-testid":`own-ai-row-${p.id}`,children:[n.jsxs("button",{type:"button","aria-expanded":a===p.id,onClick:()=>h(p.id),className:"hover:bg-muted/60 focus-visible:ring-ring flex w-full items-center gap-3 px-4 py-3 text-left transition-colors focus-visible:ring-2 focus-visible:outline-none",children:[n.jsxs("span",{className:"min-w-0 flex-1",children:[n.jsx("span",{className:"block text-sm font-medium",children:p.title}),n.jsx("span",{className:"text-muted-foreground block text-xs",children:p.line})]}),n.jsx(fn,{"aria-hidden":!0,className:K("text-muted-foreground size-4 shrink-0 transition-transform",a===p.id&&"rotate-90")})]}),a===p.id&&n.jsxs("div",{className:"px-4 pt-1 pb-4",children:[n.jsx(nw,{row:p.id,busy:c.isPending,save:m,onSaved:e,slots:s,simulatedApps:o}),d&&n.jsx("p",{className:"text-destructive mt-3 text-sm",role:"alert",children:d})]})]},p.id))})}function nw({row:e,busy:t,save:s,onSaved:r,slots:o,simulatedApps:a}){switch(e){case"local":return n.jsxs(L,{onClick:async()=>{await s({kind:"local"})&&r()},disabled:t,children:[t&&n.jsx(Oe,{size:"xs"}),"Use this computer’s model"]});case"agent-app":return n.jsx(Qv,{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(sw,{service:e,busy:t,save:s,onSaved:r})}}function sw({service:e,busy:t,save:s,onSaved:r}){const o=u.useId(),[a,i]=u.useState(""),[c,d]=u.useState(null),l=async m=>{m.preventDefault();const h=a.trim();if(d(null),!h){d("Enter a key.");return}if(e==="anthropic"&&h.startsWith("sk-ant-oat")){d("Subscription tokens can’t run agents. Use an API key.");return}await s({kind:e,apiKey:h})&&(i(""),r())};return n.jsxs("form",{onSubmit:m=>void l(m),className:"space-y-3",children:[n.jsxs("div",{className:"space-y-1.5",children:[n.jsx(He,{htmlFor:`${o}-key`,children:ew[e]}),n.jsx(xm,{id:`${o}-key`,value:a,onChange:m=>i(m.target.value),autoComplete:"off"})]}),c&&n.jsx("p",{className:"text-destructive text-sm",role:"alert",children:c}),n.jsxs(L,{type:"submit",disabled:t,children:[t&&n.jsx(Oe,{size:"xs"}),"Save"]})]})}function rw({onBack:e,...t}){const s=Oo();return n.jsxs("div",{className:"mx-auto flex w-full max-w-md flex-col px-4","data-testid":"onboarding-own-ai",children:[n.jsx("h1",{ref:s,tabIndex:-1,className:"text-2xl font-semibold tracking-tight outline-none",children:"Use my own AI"}),n.jsx("p",{className:"text-muted-foreground mt-2 mb-6 text-sm",children:"Your agents run on a key, a local model or an AI app."}),n.jsx(tw,{...t}),n.jsx(L,{variant:"ghost",size:"sm",className:"text-muted-foreground mt-6 self-start",onClick:e,children:"Back"})]})}function ow({agentName:e,className:t}){var c;const s=Gl(),r=e.trim()||"This agent";if(s.isPending)return n.jsx("p",{className:K("text-muted-foreground text-center text-xs",t),"data-testid":"every-agent-access-checking",children:"Checking apps every agent can use…"});if(s.isError)return n.jsxs("p",{className:K("text-muted-foreground text-xs",t),"data-testid":"every-agent-access-unknown",children:["Couldn’t check apps shared with every agent. ",r," gets them too."]});const o=((c=s.data)==null?void 0:c.connections)??[];if(o.length===0)return null;const a=new Map;for(const d of o)a.set(d.toolkit,(a.get(d.toolkit)??0)+1);const i=o.map(d=>{const l=(a.get(d.toolkit)??0)>1?`${Ca(d.toolkit)} · ${d.label}`:Ca(d.toolkit),m=sy(d.access.classifications);return`${l} (${d.lifecycle==="paused"?`${m}, paused`:m})`});return n.jsxs("div",{className:K("bg-muted/40 flex items-start gap-3 rounded-xl px-4 py-3 text-sm",t),"data-testid":"every-agent-access-notice",children:[n.jsx(uc,{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 aw({onContinueWithDorkos:e,onUseOwnAi:t,onContinueWithout:s,busy:r=null,error:o=null}){const a=mc(),i=Oo();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(It,{size:120,className:"mb-8 opacity-90 dark:hidden"}),n.jsx(It,{variant:"white",size:120,className:"mb-8 hidden opacity-90 dark:block"}),n.jsx("h1",{ref:i,tabIndex:-1,className:"text-3xl font-semibold tracking-tight text-balance outline-none sm:text-4xl",children:"You, Multiplied."}),n.jsx("p",{className:"text-muted-foreground mt-3 text-balance",children:"Build and run your business with an agent team."}),n.jsxs("div",{className:"mt-10 flex w-full max-w-xs flex-col items-center gap-3",children:[n.jsxs(L,{size:"lg",className:"w-full",onClick:e,disabled:r!==null,"data-testid":"onboarding-continue-dorkos",children:[r==="dorkos"&&n.jsx(Oe,{size:"xs"}),"Continue with DorkOS"]}),n.jsx(Eo,{withSpaces:a,className:"text-balance"}),o&&n.jsx("p",{className:"text-destructive text-sm",role:"alert",children:o})]}),n.jsxs("div",{className:"mt-8 flex flex-col items-center gap-1 sm:flex-row sm:gap-2",children:[n.jsx(L,{variant:"ghost",size:"sm",className:"text-muted-foreground",onClick:t,disabled:r!==null,children:"Use my own AI"}),n.jsx("span",{"aria-hidden":!0,className:"text-muted-foreground/50 hidden sm:inline",children:"·"}),n.jsxs(L,{variant:"ghost",size:"sm",className:"text-muted-foreground",onClick:s,disabled:r!==null,children:[r==="none"&&n.jsx(Oe,{size:"xs"}),"Continue without an account"]})]})]})}function iw({onComplete:e,slots:t}){const s=t==null?void 0:t.renderAccountLink,r=o=>n.jsx(cw,{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 cw({link:e,slots:t,onComplete:s}){var I;const{stage:r,goToStage:o,goBack:a}=Lv(),{startOnboarding:i}=Zt(),c=Do(),[d,l]=u.useState(null),m=u.useRef(null),h=u.useRef(!1);u.useEffect(()=>{h.current||(h.current=!0,i())},[i]),u.useEffect(()=>{var v;r!=="connecting"&&((v=m.current)==null||v.close(),m.current=null)},[r]);const p=u.useRef(e);u.useEffect(()=>{p.current=e});const f=u.useCallback(async()=>{var v;((v=p.current)==null?void 0:v.state)==="pending"&&await p.current.cancel()},[]),g=u.useCallback(()=>{m.current!==null||r==="connecting"||(l(null),m.current=e&&e.state!=="linked"?no():null,o("connecting"))},[o,e,r]),x=u.useCallback(async()=>{l(null);try{await f(),await c.mutateAsync({path:"none"}),o("landing")}catch(v){l(Pn(v))}},[c,o,f]),y=u.useCallback(()=>o("landing"),[o]),b=u.useCallback(()=>o("own-ai"),[o]),C=u.useCallback(()=>a("welcome"),[a]);let S;return r==="connecting"?S=e?n.jsx(lw,{link:e,waitingWindowRef:m,onReady:y,onCancel:()=>{f(),C()},onUseOwnAi:()=>{f(),b()}}):n.jsx(Od,{phase:{kind:"failed",message:"Signing in isn’t available here."},link:null,onRetry:C,onCancel:C,onUseOwnAi:b}):r==="own-ai"?S=n.jsx(rw,{onBack:C,onSaved:y,beforePick:f,slots:t}):r==="landing"?S=n.jsx(qv,{onComplete:s}):S=n.jsx(aw,{onContinueWithDorkos:g,onUseOwnAi:b,onContinueWithout:()=>void x(),busy:c.isPending&&((I=c.variables)==null?void 0:I.path)==="none"?"none":null,error:d}),S}function lw({link:e,waitingWindowRef:t,onReady:s,onCancel:r,onUseOwnAi:o}){const{phase:a,retry:i}=Kv({link:e,waitingWindowRef:t,onReady:s});return n.jsx(Od,{phase:a,link:e,onRetry:i,onCancel:r,onUseOwnAi:o})}function dw(){var l;const e=ae(),t=le(),{data:s}=Ee({queryKey:Fe.current(),queryFn:()=>e.getConfig(),staleTime:300*1e3}),r=((l=s==null?void 0:s.mesh)==null?void 0:l.scanRoots)??[],o=(s==null?void 0:s.boundary)??"",a=r.length>0?r:o?[o]:[],{mutate:i,isPending:c}=Vt({mutationKey:nc,mutationFn:async m=>{await e.updateConfig({mesh:{scanRoots:m}})},onSuccess:()=>{t.invalidateQueries({queryKey:Fe.all})}}),d=u.useCallback(m=>i(m),[i]);return{roots:a,boundary:o,isSaving:c,setScanRoots:d}}const uw=50,jn=["room_created","room_updated","room_member_added","room_member_removed","room_activity"];function Ua(e){if(typeof e!="object"||e===null)return!1;const{roomId:t}=e;return typeof t=="string"&&t.length>0}function mw(e){if(typeof e!="object"||e===null)return!1;const{userId:t,threadKind:s,threadId:r,lastReadSeq:o,unreadCount:a}=e;return s==="room"&&typeof t=="string"&&t.length>0&&typeof r=="string"&&r.length>0&&typeof o=="number"&&typeof a=="number"}function hw(e,t){const s=e.getQueryData(Ue.detail(t.threadId));return s===void 0||s.viewerAuthorId===t.userId}function fw(e,t){const s=e.isFetching({queryKey:Ue.lists()})>0;e.cancelQueries({queryKey:Ue.lists()}),e.setQueriesData({queryKey:Ue.lists()},o=>Array.isArray(o)?o.map(a=>{if(a.id!==t.threadId||a.unreadCount===null)return a;const i=Math.min(a.unreadCount,t.unreadCount);return a.mentionCount===void 0?{...a,unreadCount:i}:{...a,unreadCount:i,mentionCount:Math.min(a.mentionCount,i)}}):o),e.setQueryData(Ue.detail(t.threadId),o=>o&&{...o,members:o.members.map(a=>a.authorId===t.userId?{...a,lastReadSeq:Math.max(a.lastReadSeq,t.lastReadSeq)}:a)});const r=e.getQueryData(Ue.threads());r!=null&&r.some(o=>o.roomId===t.threadId&&o.unreadCount>0)&&e.invalidateQueries({queryKey:Ue.threads()}),s&&e.invalidateQueries({queryKey:Ue.lists()})}function pw(){const e=le(),t=()=>{e.invalidateQueries({queryKey:Ue.lists()}),e.invalidateQueries({queryKey:Ue.wellKnowns()}),e.invalidateQueries({queryKey:Ue.threads()})};fe(jn[0],t),fe(jn[1],t),fe(jn[2],t),fe(jn[3],t),fe(jn[4],t),fe("room_awaiting",t),fe("room_updated",o=>{Ua(o)&&e.invalidateQueries({queryKey:Ue.detail(o.roomId)})});const s=u.useRef(new Set),r=o=>{if(!Ua(o))return;const a=s.current;if(a.has(o.roomId))return;a.add(o.roomId);const i=o.roomId;setTimeout(()=>{a.delete(i),e.invalidateQueries({queryKey:Ue.detail(i)})},uw)};fe("room_member_added",r),fe("room_member_removed",r),fe("room_presence",o=>bm.getState().observe(o)),fe("read_cursor",o=>{!mw(o)||!hw(e,o)||fw(e,o)})}function gw(){const e=le();fe("capabilities_changed",()=>{e.invalidateQueries({queryKey:hc.all})})}function xw(){const e=ae(),t=le();return Vt({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:hc.all}),t.invalidateQueries({queryKey:["mesh","agents"]})}})}function bw(){const e=le(),t=()=>{e.invalidateQueries({queryKey:[...ym],exact:!0})};fe("tasks_changed",t),fe("task_run_finished",()=>{t(),e.invalidateQueries({queryKey:[...Zo]})});const s=()=>{e.invalidateQueries({queryKey:[...Zo]})};fe("task_run_failed",s),fe("task_run_updated",s)}function yw(e){const t=new Set,s=[],r=[];for(const o of e){if(o.status==="running"){s.includes(o.scheduleId)||s.push(o.scheduleId),t.add(o.scheduleId);continue}t.has(o.scheduleId)||o.status==="skipped"||o.status==="cancelled"||(t.add(o.scheduleId),(o.status==="failed"||o.status==="needs_attention")&&r.push(o.scheduleId))}return{running:s,failed:r}}function vw({members:e}){var d;const t=P(l=>l.explicitAgentPath),s=P(l=>l.setExplicitAgentPath),r=e.some(l=>l.agentPath===t),o=((d=e[0])==null?void 0:d.agentPath)??null;u.useEffect(()=>{!r&&o!==null&&s(o)},[r,o,s]);const a=u.useRef([]);if(e.length===0)return null;const i=Math.max(0,e.findIndex(l=>l.agentPath===t)),c=l=>{var p;const m=e.length-1,h=l.key==="ArrowRight"||l.key==="ArrowDown"?i===m?0:i+1:l.key==="ArrowLeft"||l.key==="ArrowUp"?i===0?m:i-1:l.key==="Home"?0:l.key==="End"?m:null;h!==null&&(l.preventDefault(),s(e[h].agentPath),(p=a.current[h])==null||p.focus())};return n.jsx("div",{role:"radiogroup","aria-label":"Show the panel for","data-testid":"group-dm-member-picker",onKeyDown:c,className:"flex shrink-0 flex-wrap gap-1.5 border-b px-3 py-2",children:e.map((l,m)=>{const h=l.agentPath===t;return n.jsxs("button",{type:"button",ref:p=>{a.current[m]=p},role:"radio","aria-checked":h,tabIndex:m===i?0:-1,onClick:()=>s(l.agentPath),className:K("focus-ring flex h-7 max-w-40 items-center gap-1.5 rounded-full border px-2 text-xs transition-colors",h?"bg-accent text-foreground border-transparent":"text-muted-foreground hover:bg-accent/60 hover:text-foreground"),children:[n.jsx(ms,{"aria-hidden":!0,size:"xs",className:"size-4 shrink-0 text-[9px]",kind:"agent",color:l.color??ds(l.authorId),emoji:l.emoji,badge:null,fallback:Sr(l.displayName)}),n.jsx("span",{className:"truncate",children:l.displayName})]},l.authorId)})})}const ww=4e3;function _d(){var o;const e=ro(),{identityPromptDismissedAt:t,isLoading:s}=qs();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&&bb(r)?"ask":"settled"}function jw(){const{state:e,isLoading:t,shouldShowGettingStarted:s}=Zt(),r=_d(),{dismissIdentityPrompt:o}=qs(),[a,i]=u.useState("ask");u.useEffect(()=>{if(a!=="saved")return;const m=setTimeout(()=>i("done"),ww);return()=>clearTimeout(m)},[a]);const c=e.completedAt!==null||e.dismissedAt!==null,d=!t&&c&&r==="ask"&&!s,l=()=>{o().catch(()=>{})};return{visible:a!=="done"&&(d||a==="saved"),phase:a,markSaved:()=>{i("saved"),l()},skip:()=>{i("done"),l()}}}function Pd(){const{firstRunPath:e}=Zt().state,{offered:t,pending:s}=Dl(),r=e==="dorkos"||e==="own";return{due:r&&t,pending:r&&s}}const kw=4e3,sr="Tell DorkBot your name",Ka="Tell DorkBot about your work";function Sw({onDismiss:e}){const t=ut(),s=Me(),{open:r}=at(),o=oo(),a=P(O=>O.requestTour),{startSession:i}=Cv(),{roles:c,rolePromptDismissedAt:d,isLoading:l,saveRoles:m,dismissIdentityPrompt:h}=qs(),p=_d(),f=Pd().due,[g,x]=u.useState("closed"),[y,b]=u.useState("closed"),[C,S]=u.useState([]),I=!l&&c.length===0&&d===null;u.useEffect(()=>{if(g!=="saved")return;const O=setTimeout(()=>x("closed"),kw);return()=>clearTimeout(O)},[g]);const v=()=>{x("saved"),h().catch(()=>{})},E=()=>{b("saving"),m(C).then(()=>b("closed")).catch(()=>b("error"))};let R="Save";y==="saving"?R="Saving…":y==="error"&&(R="Try again");const M=[{icon:Es,label:"Talk to DorkBot",onClick:i},...p==="ask"||g==="saved"?[{icon:Ql,label:sr,onClick:()=>x(O=>O==="saved"?O:O==="closed"?"open":"closed"),expanded:g!=="closed"}]:[],...I?[{icon:ao,label:Ka,onClick:()=>b(O=>O==="closed"?"open":"closed"),expanded:y!=="closed"}]:[],{icon:dy,label:"Show me around",onClick:()=>a("general")},{icon:Rt,label:"Create an agent",onClick:()=>Is.getState().open("new")},{icon:fc,label:"Schedule a task",onClick:()=>s({...ve.tasks()})},{icon:Xl,label:"Connect more runtimes",onClick:()=>r("runtimes")},{icon:jb,label:"Connect a service",onClick:()=>o()}];return n.jsxs(se.div,{initial:t?!1:{opacity:0,y:8},animate:{opacity:1,y:0},transition:{duration:.3},className:"border-border bg-card relative rounded-lg border p-3",children:[n.jsx("button",{onClick:e,className:"text-muted-foreground/50 hover:text-muted-foreground absolute top-1.5 right-1.5 rounded-md p-0.5 transition-colors duration-150","aria-label":"Dismiss getting started",children:n.jsx(Be,{className:"size-3.5"})}),n.jsx("h3",{className:"mb-2 text-xs font-medium",children:"Getting started"}),n.jsx("ul",{className:"space-y-0.5",children:M.map(({icon:O,label:_,onClick:D,expanded:k})=>n.jsxs("li",{children:[n.jsxs("button",{onClick:D,className:"hover:bg-accent group flex w-full items-center gap-2 rounded-md px-1.5 py-1 text-left transition-colors duration-150","aria-expanded":k,children:[n.jsx(O,{className:"text-muted-foreground size-3.5 shrink-0"}),n.jsx("span",{className:"text-foreground flex-1 text-xs",children:_}),n.jsx(fn,{className:"text-muted-foreground/40 group-hover:text-muted-foreground size-3.5 shrink-0 transition-colors"})]}),_===sr&&g==="open"&&n.jsx("div",{className:"px-1.5 py-2","data-testid":"progress-card-identity-form",children:n.jsx(Vl,{onSaved:v})}),_===sr&&g==="saved"&&n.jsx("p",{role:"status",className:"text-muted-foreground px-1.5 py-2 text-xs",children:gt.identityCardSaved}),_===Ka&&y!=="closed"&&n.jsx("div",{className:"px-1.5 py-2","data-testid":"progress-card-profile-picker",children:n.jsx(Ul,{selected:C,onChange:S,onConfirm:E,confirmLabel:R,busy:y==="saving",error:y==="error"?gt.saveError:null})})]},_))}),f&&n.jsx(Ol,{compact:!0,className:"border-border mt-2 border-t px-1.5 pt-2"})]})}const Ha=72;function Ld({title:e,description:t,titleIsStatus:s}){return n.jsxs("div",{className:"flex flex-col gap-2",children:[n.jsxs("div",{children:[n.jsx(It,{size:Ha,className:"block dark:hidden"}),n.jsx(It,{variant:"white",size:Ha,className:"hidden dark:block"})]}),n.jsxs("div",{className:"flex flex-col gap-0.5",children:[n.jsx("p",{className:"text-sm leading-relaxed",role:s?"status":void 0,children:e}),t!==void 0&&n.jsx("p",{className:"text-muted-foreground text-xs leading-relaxed",children:t})]})]})}function Cw({prompt:e}){const t=ut(),{open:s}=at(),{phase:r,selected:o,setSelected:a,confirmLabel:i,errorMessage:c}=e;return n.jsxs(se.div,{initial:t?!1:{opacity:0,y:8},animate:{opacity:1,y:0},transition:{duration:.2},role:"group","aria-label":"DorkBot suggestion","data-testid":"profile-prompt-card",className:"bg-secondary/60 flex flex-col gap-2 rounded-lg border p-3",children:[n.jsx(Ld,{title:r==="saved"?gt.profileSaved:gt.profileCardPrompt[0],description:n.jsxs(n.Fragment,{children:[gt.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(Ul,{selected:o,onChange:a,onConfirm:e.save,confirmLabel:i,onSkip:e.skip,skipLabel:"Don’t ask again",busy:r==="saving",error:c})]})}const Nw=4e3;function Aw(){const{state:e,isLoading:t,shouldShowGettingStarted:s}=Zt(),{roles:r,rolePromptDismissedAt:o,isLoading:a,saveRoles:i,dismissRolePrompt:c}=qs(),[d,l]=u.useState([]),[m,h]=u.useState("ask");u.useEffect(()=>{if(m!=="saved")return;const y=setTimeout(()=>h("done"),Nw);return()=>clearTimeout(y)},[m]);const p=e.completedAt!==null||e.dismissedAt!==null,f=!e.completedSteps.includes("profile")&&!e.skippedSteps.includes("profile"),g=!t&&!a&&p&&r.length===0&&f&&o===null&&!s;let x="Save";return m==="saving"?x="Saving…":m==="error"&&(x="Try again"),{visible:m!=="done"&&(g||m==="saved"),phase:m,selected:d,setSelected:l,confirmLabel:x,errorMessage:m==="error"?gt.saveError:null,save:()=>{h("saving"),i(d).then(()=>h("saved")).catch(()=>h("error"))},skip:()=>{h("done"),c().catch(()=>{})}}}function Ew({prompt:e}){const t=ut(),s=e.phase==="saved";return n.jsxs(se.div,{initial:t?!1:{opacity:0,y:8},animate:{opacity:1,y:0},transition:{duration:.2},role:"group","aria-label":"DorkBot suggestion","data-testid":"identity-prompt-card",className:"bg-secondary/60 flex flex-col gap-3 rounded-lg border p-3",children:[n.jsx(Ld,{title:s?gt.identityCardSaved:gt.identityCardPrompt[0],description:s?void 0:gt.identityCardPrompt[1],titleIsStatus:s}),!s&&n.jsx(Vl,{onSaved:e.markSaved,onSkip:e.skip,skipLabel:"Don’t ask again"})]})}function Iw(){const e=ae(),t=u.useRef(null),{startScan:s,addCandidate:r,addExistingAgent:o,setProgress:a,completeScan:i,setError:c}=pc(),d=u.useCallback((m={roots:[]})=>{var p;(p=t.current)==null||p.abort();const h=new AbortController;t.current=h,s(),e.scan(m,f=>{switch(f.type){case"candidate":r(f.data);break;case"existing-agent":o(f.data);break;case"progress":a(f.data);break;case"complete":i(f.data);break;case"error":c(f.data.error);break}},h.signal).catch(f=>{f instanceof Error&&f.name!=="AbortError"&&c(f.message)})},[e,s,r,o,a,i,c]),l=u.useCallback(()=>{var m;(m=t.current)==null||m.abort(),t.current=null},[]);return{startScan:d,stopScan:l}}function Rw(){const[e,t]=u.useState(new Set),s=u.useCallback(o=>{t(a=>new Set(a).add(o))},[]),r=u.useCallback(()=>{t(new Set)},[]);return{actedPaths:e,markActed:s,resetActed:r}}function Tw({register:e,onSuccess:t}){const s=u.useRef(new Set),[r,o]=u.useState(new Set),[a,i]=u.useState(new Set),c=u.useCallback(async l=>{if(!s.current.has(l.path)){s.current.add(l.path),o(m=>new Set(m).add(l.path)),i(m=>{const h=new Set(m);return h.delete(l.path),h});try{await e(l),t(l)}catch{i(m=>new Set(m).add(l.path))}finally{s.current.delete(l.path),o(m=>{const h=new Set(m);return h.delete(l.path),h})}}},[t,e]),d=u.useCallback(()=>i(new Set),[]);return{failedPaths:a,pendingPaths:r,registerCandidate:c,resetFailures:d}}function Dw(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 Ow(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 Mw={"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 _w(e){return Mw[e]??`Found by the “${e}” check.`}const Pw={"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 Lw(e){return Pw[e]??"Found in the project’s files."}function Fw({candidate:e,onApprove:t,onDeny:s,onSkip:r,registrationFailed:o=!1,registrationPending:a=!1,className:i,ref:c}){const{path:d,strategy:l,hints:m}=e;return n.jsxs(se.div,{ref:c,"data-slot":"candidate-card","aria-busy":a,layout:!0,initial:{opacity:0,y:6},animate:{opacity:1,y:0},exit:{opacity:0,y:-6},transition:{duration:.15,ease:"easeOut"},className:K("flex items-start justify-between rounded-xl border p-4",i),children:[n.jsxs("div",{className:"min-w-0 flex-1 space-y-2",children:[n.jsx("p",{className:"truncate text-sm leading-tight font-semibold",title:m.suggestedName||d.split("/").pop()||d,children:m.suggestedName||d.split("/").pop()||d}),n.jsxs("div",{className:"text-muted-foreground flex items-center gap-1.5 text-xs",children:[n.jsx(vm,{className:"size-3 shrink-0"}),n.jsx("span",{className:"truncate font-mono",title:d,children:io(d)})]}),n.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[n.jsxs(Jl,{openDelay:300,children:[n.jsx(Zl,{asChild:!0,children:n.jsx(Dn,{variant:"secondary",className:"hover:bg-secondary/80 cursor-default",children:m.detectedRuntime})}),n.jsxs(ed,{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:_w(l)})]})]}),m.inferredCapabilities&&m.inferredCapabilities.length>0&&m.inferredCapabilities.map(h=>n.jsxs(pn,{children:[n.jsx(gn,{asChild:!0,children:n.jsx(Dn,{size:"xs",variant:"outline",className:"cursor-default",children:h})}),n.jsx(xn,{side:"top",className:"max-w-48 text-center",children:Lw(h)})]},h))]}),o&&n.jsx("p",{role:"alert",className:"text-destructive text-xs",children:"Couldn’t add this project. Try again."})]}),n.jsxs("div",{className:"ml-4 flex shrink-0 items-center gap-1.5",children:[n.jsx("button",{type:"button",onClick:()=>t(e),disabled:a,className:"focus-visible:ring-ring rounded-md bg-green-600/10 px-2.5 py-1 text-xs font-medium text-green-700 hover:bg-green-600/20 focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50 dark:text-green-400",children:a?"Adding…":o?"Try again":"Add"}),r&&n.jsx("button",{type:"button",onClick:()=>r(e),disabled:a,className:"text-muted-foreground hover:bg-muted focus-visible:ring-ring rounded-md px-2.5 py-1 text-xs font-medium focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50",children:"Skip"}),s&&n.jsx("button",{type:"button",onClick:()=>s(e),disabled:a,className:"focus-visible:ring-ring rounded-md bg-red-600/10 px-2.5 py-1 text-xs font-medium text-red-700 hover:bg-red-600/20 focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50 dark:text-red-400",children:"Deny"})]})]})}function $w({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(As,{className:"text-muted-foreground size-4 shrink-0"}),n.jsxs("div",{className:"min-w-0 flex-1",children:[n.jsx("p",{className:"truncate text-sm font-medium",children:Le(e)}),n.jsx("p",{className:"text-muted-foreground truncate text-xs",children:e.path})]}),n.jsx("span",{className:"text-muted-foreground shrink-0 text-xs",children:"Imported"})]})}const Bw=2;function zw({agents:e}){const[t,s]=u.useState(e.length<=Bw);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(fn,{className:K("size-3 transition-transform",t&&"rotate-90")}),e.length," project",e.length===1?"":"s"," already in DorkOS"]}),t&&n.jsx("div",{className:"mt-2 space-y-2",children:e.map(r=>n.jsx($w,{agent:r},r.path))})]})}function Uw({count:e,onAddAll:t,disabled:s}){return e===0?null:n.jsxs("div",{className:"flex items-center justify-between py-1",children:[n.jsxs("span",{className:"text-muted-foreground text-sm font-medium",children:[e," new project",e===1?"":"s"]}),n.jsx(L,{variant:"outline",size:"sm",onClick:t,disabled:s,children:"Add all"})]})}function Kw({roots:e,onChange:t}){const[s,r]=u.useState(""),[o,a]=u.useState(!1),i=u.useCallback(m=>{const h=m.trim();h&&!e.includes(h)&&t([...e,h])},[e,t]),c=u.useCallback(m=>{t(e.filter(h=>h!==m))},[e,t]),d=u.useCallback(m=>{(m.key==="Enter"||m.key===",")&&(m.preventDefault(),s.trim()&&(i(s),r(""))),m.key==="Backspace"&&s===""&&e.length>0&&c(e[e.length-1])},[s,e,i,c]),l=u.useCallback(m=>{i(m)},[i]);return n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"focus-within:ring-ring flex min-h-[40px] flex-wrap items-center gap-1.5 rounded-md border bg-transparent px-3 py-1.5 focus-within:ring-2",children:[e.map(m=>n.jsxs(Dn,{variant:"secondary",className:"gap-1 py-0.5 font-mono",children:[m,n.jsx("button",{type:"button",onClick:()=>c(m),className:"hover:bg-muted-foreground/20 ml-0.5 rounded-sm","aria-label":`Remove ${m}`,children:n.jsx(Be,{className:"size-3"})})]},m)),n.jsx("input",{type:"text",value:s,onChange:m=>r(m.target.value),onKeyDown:d,placeholder:e.length===0?"Type a folder, then press Enter":"Add more…",className:"placeholder:text-muted-foreground min-w-[120px] flex-1 bg-transparent text-sm focus-visible:outline-none"}),n.jsx("button",{type:"button",onClick:()=>a(!0),className:"text-muted-foreground hover:bg-accent hover:text-foreground shrink-0 rounded p-1","aria-label":"Browse for a folder",children:n.jsx(Rs,{className:"size-4"})})]}),n.jsx(gc,{open:o,onOpenChange:a,onSelect:l})]})}function Hw(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 Ww(){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 Gw=[{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 qw({fullBleed:e=!1,onRegistered:t}){var V;const{roots:s,setScanRoots:r}=dw(),[o,a]=u.useState(null),[i,c]=u.useState(!1),[d,l]=u.useState(3),{startScan:m}=Iw(),{candidates:h,existingAgents:p,isScanning:f,progress:g,error:x,lastScanAt:y}=pc(),{mutateAsync:b}=wm(),{mutate:C}=jm(),{data:S}=km(),{actedPaths:I,markActed:v,resetActed:E}=Rw(),R=o??s,M=u.useCallback(G=>b({path:G.path,overrides:Dw(G),scanRoot:Hw(G.path,R)}),[R,b]),O=u.useCallback(G=>{v(G.path),t==null||t()},[v,t]),{failedPaths:_,pendingPaths:D,registerCandidate:k,resetFailures:j}=Tw({register:M,onSuccess:O});function N(G){a(G),r(G)}function w(){R.length>0&&(E(),j(),m({roots:R,maxDepth:d}))}const F=u.useMemo(()=>f?h:Ow(h),[h,f]).filter(G=>!I.has(G.path)),$=(((V=S==null?void 0:S.agents)==null?void 0:V.length)??0)>0,W=p.length>0,X=h.length>0,ie=W||X,B=!f&&y!==null,Y=!f&&y===null;function oe(){for(const G of F)k(G)}const pe=n.jsxs("div",{children:[n.jsxs("button",{type:"button",onClick:()=>c(!i),className:"text-muted-foreground hover:text-foreground flex items-center gap-1 text-xs",children:[n.jsx(Jt,{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(Kw,{roots:R,onChange:N}),n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsx("label",{htmlFor:"scan-depth",className:"text-muted-foreground text-xs",children:"Scan depth"}),n.jsx("input",{id:"scan-depth",type:"range",min:1,max:5,value:d,onChange:G=>l(Number(G.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(my,{className:"size-3"}),"What it looks for"]}),n.jsx("ul",{className:"space-y-1 pl-4",children:Gw.map(G=>n.jsxs("li",{className:"flex items-baseline gap-1.5",children:[n.jsx("code",{className:"text-foreground/70 text-3xs",children:G.signal}),n.jsxs("span",{className:"text-muted-foreground text-3xs",children:["→ ",G.label]})]},G.name))})]})]})]});return n.jsx("div",{className:e?"flex h-full flex-col p-6":"space-y-4 p-4",children:Y?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(Ww,{}),n.jsxs("div",{className:"text-center",children:[n.jsx("p",{className:"text-foreground text-sm font-medium",children:"Find your existing projects"}),n.jsx("p",{className:"text-muted-foreground mx-auto mt-1 max-w-[300px] text-xs leading-relaxed",children:"Find Claude Code, Cursor, Codex and other AI projects on this computer."})]}),x&&n.jsx("div",{className:"border-destructive/30 bg-destructive/5 text-destructive rounded-lg border px-4 py-3 text-sm",children:x}),n.jsxs(L,{onClick:w,disabled:R.length===0,className:"w-full",children:[n.jsx(hs,{className:"size-4"}),"Search for projects"]}),n.jsx("p",{className:"text-muted-foreground/60 text-center text-xs",children:"Read-only scan. Nothing changes until you approve"}),pe]})}):n.jsxs(n.Fragment,{children:[e&&n.jsxs("div",{className:"mb-4 space-y-1",children:[n.jsx("h2",{className:"text-lg font-semibold",children:"Bring in existing projects"}),n.jsx("p",{className:"text-muted-foreground text-sm",children:"Search for existing projects to bring into DorkOS."})]}),n.jsxs("div",{className:"space-y-3",children:[pe,n.jsxs(L,{onClick:w,disabled:f||R.length===0,children:[f?n.jsx(Oe,{}):n.jsx(hs,{className:"size-4"}),"Search for projects"]})]}),n.jsxs("div",{className:e?"mt-4 flex-1 overflow-y-auto":"",children:[f&&n.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 p-8",children:[n.jsx(Oe,{size:"md",className:"text-muted-foreground",label:"Searching for projects"}),g&&n.jsxs("div",{className:"text-muted-foreground space-y-0.5 text-center text-xs",children:[n.jsxs("p",{children:["Scanned ",g.scannedDirs," directories"]}),n.jsxs("p",{children:["Found ",g.foundAgents," project",g.foundAgents===1?"":"s"]})]})]}),x&&n.jsx("div",{className:"border-destructive/30 bg-destructive/5 text-destructive mb-3 rounded-lg border px-4 py-3 text-sm",children:x}),B&&!X&&W&&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."})]}),B&&!ie&&n.jsxs("div",{className:"rounded-xl border border-dashed p-8 text-center",children:[n.jsx("p",{className:"text-sm font-medium",children:$?"No new projects found":"No projects found"}),n.jsx("p",{className:"text-muted-foreground mt-1 text-xs",children:$?"They’re already added. See the Agents tab.":"Try a deeper scan or other folders."})]}),B&&F.length>0&&n.jsxs(n.Fragment,{children:[n.jsx(Uw,{count:F.length,onAddAll:oe,disabled:D.size>0}),n.jsx(Ye,{mode:"popLayout",children:F.map(G=>n.jsx(Fw,{candidate:G,className:"mb-2",registrationFailed:_.has(G.path),registrationPending:D.has(G.path),onApprove:te=>void k(te),onSkip:te=>v(te.path),onDeny:te=>C({path:te.path},{onSuccess:()=>v(te.path)})},G.path))})]}),B&&W&&n.jsx("div",{className:"mt-3",children:n.jsx(zw,{agents:p})})]})]})})}function Yw(){const e=Ts(),t=sn(f=>f.isOpen)&&!e,s=sn(f=>f.close);u.useEffect(()=>{e&&sn.getState().isOpen&&s()},[e,s]);const r=Me(),[o,a]=u.useState(0),[i,c]=u.useState(!1),[d,l]=u.useState(!1);t!==d&&(l(t),t&&(a(0),c(!1)));function m(f){f||s()}function h(){if(o>0&&!i){c(!0);return}s(),o>0&&r({...ve.team()})}const p=`${o} project${o===1?"":"s"} joined`;return n.jsx(bt,{open:t,onOpenChange:m,children:n.jsxs(yt,{className:"max-h-[85vh] !min-h-0 sm:max-w-2xl",children:[n.jsxs(ft,{className:"shrink-0",children:[n.jsx(st,{children:"Bring in existing projects"}),n.jsx(pt,{children:i?"Your projects are ready in DorkOS.":"Find projects on this computer to add."})]}),i?n.jsx(At,{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(As,{className:"text-primary size-12","aria-hidden":!0}),n.jsx("p",{className:"text-lg font-semibold","data-testid":"import-joined-summary",children:p}),n.jsx("p",{className:"text-muted-foreground text-sm",children:"Manage agents, tasks and chat apps from the Team page."})]})}):n.jsx(At,{className:"mt-2 overflow-y-auto",children:n.jsx(qw,{onRegistered:()=>a(f=>f+1)})}),n.jsxs(rn,{className:"shrink-0 sm:justify-between",children:[!i&&o>0?n.jsx("span",{className:"text-muted-foreground text-sm","data-testid":"import-joined-count",children:p}):n.jsx("span",{}),n.jsx(L,{onClick:h,"data-testid":"import-done",children:"Done"})]})]})})}function Vw(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 Qw(){const e=Sm(s=>s.record),t=Jx();fe("marketplace_dev_link_reloaded",s=>{Vw(s)&&(e(s),t())})}function Xw(){const e=le();fe("relay_bindings_changed",()=>{e.invalidateQueries({queryKey:[...Kx]})})}const Wa="inbox",Jw="open";function Zw({blocked:e=!1}={}){const t=zn()[Wa],s=eo(),r=t!==void 0,o=t==null?"":String(t).trim();u.useEffect(()=>{!r||!s||(o&&!e&&xc(void 0,o===Jw?void 0:{focus:o}),s({search:a=>({...a,[Wa]:void 0}),replace:!0}))},[r,o,e,s]),u.useEffect(()=>{e&&Cm()},[e])}class Ga extends u.Component{constructor(){super(...arguments);yn(this,"state",{hasError:!1})}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(s,r){console.error("[RightPanel] Tab component error:",s,r)}componentDidUpdate(s){s.tabId!==this.props.tabId&&this.state.hasError&&this.setState({hasError:!1})}render(){return this.state.hasError?n.jsx("div",{className:"flex h-full items-center justify-center p-4",children:n.jsx("p",{className:"text-muted-foreground text-sm",children:"This panel stopped working. Switch tabs to try again."})}):this.props.children}}const qa=new Set(["agent-profile","profile","files","room","computer"]),Ya=new Set(["pulse","session","canvas","browser","local-browser","terminal"]),ej={};function tj(e,t){var Mt,z,Se;const s=P(A=>A.activeRightPanelTab),r=P(A=>A.setActiveRightPanelTab),o=P(A=>A.rightPanelLayoutKey),a=P(A=>A.selectedCwd),i=P(A=>A.explicitAgentPath),c=P(A=>A.sessionId),[d]=bc(),l=t==="/session"?d:null,m=l?`chat/${encodeURIComponent(l)}`:"human",{data:h}=Gb(e.some(A=>A.id==="local-browser")),p=(h==null?void 0:h.status)==="connected"&&h.connectionId&&h.sessionId===l?h:null,f=p?`resource/browser/${m}/${encodeURIComponent(p.connectionId)}`:"local-browser",g=P(A=>A.roomCanvasLiveRoomId),x=P(A=>A.openDocuments),y=P(A=>g?A.roomCanvasDocuments[g]:void 0),b=P(A=>g?A.roomCanvasUnread[g]:void 0),C=P(A=>g?A.roomCanvasPresence[g]:void 0),S=yc(g),I=ae(),v=P(A=>{var H;return g?(H=A.roomCanvasActive[g])==null?void 0:H.canvas:A.activeCanvasDocumentId}),E=P(A=>{var H;return g?(H=A.roomCanvasActive[g])==null?void 0:H.browser:A.activeBrowserDocumentId}),R=P(A=>A.activateCanvasDocument),M=P(A=>A.activateRoomCanvasDocument),O=ea(A=>A.chrome),_=`${c??""}:${a}`,D=(O==null?void 0:O.scope)===_?O:null,[k,j]=u.useState(null);u.useEffect(()=>{if((k==null?void 0:k.scope)!==_||!D)return;const A=k.id?D.tabs.find(H=>`resource/terminal/${H.id}`===k.id):D.tabs.find(H=>H.id===D.activeId);A&&!A.closed&&j(null)},[D,k,_]);const N=Wb(),w=g?`room:${g}`:i??o??a??t,T=P(A=>A.canvasSessionId),F=P(A=>A.canvasSessionCwd),$=F!==void 0?T:T??c,W=F!==void 0?F:a,X=g?`room:${g}`:Nm($,W),ie=g?`room:${g}`:Im($,W),B=P(A=>A.panelViewPreferences)??ej,Y=P(A=>A.updatePanelViewPreference),oe=P(A=>A.reopenPanelResourceView),pe=u.useMemo(()=>new Set(Object.values(B).flatMap(A=>A.closed)),[B]),V=B[w]??{opened:[],closed:[]},G=((Mt=N.data)==null?void 0:Mt.cwd)!=null&&(i?N.data.cwd.replace(/\/workspace\/?$/,"")===i:N.data.cwd===a)&&N.data.phase!=="disabled"&&N.data.phase!=="unsupported",te=u.useMemo(()=>e.filter(A=>A.id!=="computer"||G),[e,G]),we=A=>Y==null?void 0:Y(w,A),ne=A=>{var H;return((H=Re.find(Z=>Z.id===A))==null?void 0:H.resource)==="browser"},q=A=>{var H;return ne(A)?A:(H=Re.find(Z=>Z.id===A))!=null&&H.resource?`${X}:${A}`:A},he=A=>{var H;return((H=Re.find(Z=>Z.id===A))==null?void 0:H.resource)==="document"?[q(A),`${ie}:${A}`]:[q(A)]},ge=A=>{var H;return((H=Re.find(Z=>Z.id===A))==null?void 0:H.resource)==="document"},Ve=A=>A==="profile"&&t==="/session",Qe=A=>!Ve(A)&&he(A).some(H=>ge(A)||ne(A)?pe.has(H):V.closed.includes(H)),Re=te.flatMap(A=>{const H=A.id;if(H==="local-browser"){if(!p)return[{...A,category:H,title:"Browser"}];const Z=p.tabs.find(xe=>xe.id===p.selectedTabId),re=p.mode==="embedded"?"DorkOS browser":"New browser window";return[{...A,category:H,resource:"browser",id:f,title:(Z==null?void 0:Z.title)||re,icon:fs}]}if(H==="browser"||H==="canvas"){const Z=g?Am(y??[],H):Em(x??[],H);if(Z.length)return Z.map(re=>{var xe,et,Ce;return{...A,category:H,resource:"document",id:`resource/${re.id}`,title:"title"in re&&re.title||re.sourceLabel||A.title,icon:H==="browser"?fs:qb,activate:()=>{g?M(g,re.id):R(re.id)},..."authorId"in re?{author:(et=(xe=S.data)==null?void 0:xe.members.find(ze=>ze.author.id===re.authorId))==null?void 0:et.author,unread:(Ce=b==null?void 0:b[H])==null?void 0:Ce.includes(re.id),pinned:re.pinned,watchers:Object.entries(C??{}).filter(([ze,J])=>{var Ne;return J===re.id&&ze!==((Ne=S.data)==null?void 0:Ne.viewerAuthorId)}).flatMap(([ze])=>{var J,Ne;return((Ne=(J=S.data)==null?void 0:J.members.find(jt=>jt.author.id===ze))==null?void 0:Ne.author)??[]})}:{}}})}return H==="terminal"&&(D!=null&&D.tabs.length)?D.tabs.map(Z=>({...A,category:H,resource:"terminal",id:`resource/terminal/${Z.id}`,title:Z.title,closed:Z.closed,icon:vc,activate:re=>D.activate(Z.id,re)})):[{...A,category:H,...H==="browser"?{title:"Page previews"}:{},...Ve(H)?{permanent:!0}:{}}]}),Xe=new Set;if(!g){const A=(x??[]).filter(H=>H.id.startsWith("pending:")&&Qe(`resource/${H.id}`));for(const H of x??[])H.id.startsWith("pending:")||H.openedHere||A.some(Z=>{var re;return(re=Z.pendingCandidateIds)==null?void 0:re.includes(H.id)})&&Xe.add(`resource/${H.id}`)}const ee=Re.some(A=>qa.has(A.category)||!Ya.has(A.category)&&!A.isGlobal),ye=Re.filter(A=>(!A.closed||(k==null?void 0:k.scope)===_&&k.id===A.id)&&!Qe(A.id)&&!Xe.has(A.id)&&(qa.has(A.category)||!Ya.has(A.category)||A.resource||A.extensionId||V.opened.includes(A.category)||A.category===s||!ee&&A.isGlobal&&A.category!=="local-browser"));if(s==="terminal"&&(k==null?void 0:k.scope)===_&&k.id===null&&!ye.some(A=>A.category==="terminal")){const A=te.find(H=>H.id==="terminal");A&&ye.push({...A,category:"terminal"})}const je=s==="terminal"?`resource/terminal/${D==null?void 0:D.activeId}`:s==="local-browser"?f:s==="browser"?`resource/${E}`:s==="canvas"?`resource/${v}`:s,vt=((z=ye.find(A=>A.id===je))==null?void 0:z.id)??((Se=ye.find(A=>A.category===s))==null?void 0:Se.id)??null,Ge=g?y==null?void 0:y.find(A=>`resource/${A.id}`===je):x==null?void 0:x.find(A=>`resource/${A.id}`===je),U=Ge?`${Ge.rev}:${Ge.lastActiveAt}`:null,de=P(A=>A.requestedRightPanel),ke=(A,H="pointer")=>{var re;const Z=Re.find(xe=>xe.id===A);Z&&(we(xe=>({opened:[...new Set([...xe.opened,Z.category])].slice(-100),closed:xe.closed.filter(et=>!he(A).includes(et))})),(Z.resource==="document"||Z.resource==="browser")&&(oe==null||oe(he(A))),j(Z.resource==="terminal"?{scope:_,id:Z.id}:null),(re=Z.activate)==null||re.call(Z,H),r(Z.category))},Je=A=>{var et;if(Ve(A))return;const H=x==null?void 0:x.find(Ce=>Ce.id.startsWith("pending:")&&`resource/${Ce.id}`===A),Z=H?ye.filter(Ce=>{var ze;return!((ze=H.pendingCandidateIds)!=null&&ze.some(J=>{var Ne;return`resource/${J}`===Ce.id&&!((Ne=x==null?void 0:x.find(jt=>jt.id===J))!=null&&Ne.openedHere)}))}):ye,re=Z[Z.findIndex(Ce=>Ce.id===A)+1]??Z[Z.findIndex(Ce=>Ce.id===A)-1],xe=Re.find(Ce=>Ce.id===A);if(j(null),(xe==null?void 0:xe.resource)==="terminal"&&(D!=null&&D.hide))D.hide(A.slice(18));else{const Ce=ze=>({...ze,closed:[...new Set([...ze.closed,q(A)])].slice(-100)});(xe==null?void 0:xe.resource)==="document"?Y==null||Y(`documents:${X}`,Ce):(xe==null?void 0:xe.resource)==="browser"?Y==null||Y(`browsers:${m}`,Ce):we(Ce)}A===vt&&((et=re==null?void 0:re.activate)==null||et.call(re,"keyboard"),r((re==null?void 0:re.category)??null))};u.useEffect(()=>{if(!s)return;const A=je?he(je):[];!V.closed.includes(s)&&(!je||!Qe(je))||(we(H=>({...H,closed:H.closed.filter(Z=>Z!==s&&!A.includes(Z))})),je&&(ge(je)||ne(je))&&(oe==null||oe(A)))},[s,je,U,de,X,m,w]);const Ze=s==="browser"?E:s==="canvas"?v:null,Ie=g?y==null?void 0:y.find(A=>A.id===Ze):x==null?void 0:x.find(A=>A.id===Ze),wt=async A=>{try{await A()}catch{ce.error("Couldn’t update the canvas.")}},Ot=A=>{wt(()=>g?I.openRoomCanvasDocument(g,A):P.getState().openCanvasDocument(A)),r(A.type==="url"?"browser":"canvas")};return{available:te,allViews:Re,visible:ye,activeId:vt,activate:ke,closeView:Je,terminal:D,createTerminal:te.some(A=>A.id==="terminal")?()=>{j({scope:_,id:null}),we(A=>({opened:[...new Set([...A.opened,"terminal"])].slice(-100),closed:A.closed.filter(H=>H!=="terminal")})),D?D.create():ea.getState().requestCreate(_),r("terminal")}:void 0,createBrowser:te.some(A=>A.id==="browser")?()=>Ot({type:"url",url:Zr.site,title:"Web Page"}):void 0,createDocument:te.some(A=>A.id==="canvas")?()=>Ot({type:"markdown",content:`# Untitled
72
+
73
+ Start writing…`,title:"Document"}):void 0,removeDocument:Ie?()=>void wt(()=>g?I.closeRoomCanvasDocument(g,Ie.id):P.getState().closeCanvasDocument(Ie.id)):void 0,pinDocument:g&&Ie?()=>void wt(()=>I.updateRoomCanvasDocument(g,Ie.id,{pinned:!Ie.pinned})):void 0,documentPinned:(Ie==null?void 0:Ie.pinned)??!1}}function nj({views:e,activeId:t,onActivate:s,onCreateTerminal:r,onStopTerminal:o,onCreateBrowser:a,onCreateDocument:i,onRemoveDocument:c,onPinDocument:d,documentPinned:l}){const m=e.find(p=>p.resource==="browser")??e.find(p=>p.category==="local-browser"),h=e.filter(p=>p.category!=="local-browser"||p===m);return n.jsxs(Ds,{children:[n.jsx(Os,{asChild:!0,children:n.jsx(L,{variant:"ghost",size:"icon-md","aria-label":"Add view",className:"size-11 shrink-0 lg:size-7",children:n.jsx(Rt,{className:"size-3.5"})})}),n.jsxs(Ms,{align:"end",className:"max-h-[70dvh] min-w-48 overflow-y-auto [&_[role=menuitem]]:min-h-11 lg:[&_[role=menuitem]]:min-h-0",children:[n.jsx(wc,{children:"Views"}),h.map(p=>n.jsxs(qe,{"aria-current":p.id===t?"true":void 0,"data-view-category":p.category,"aria-label":p.category==="local-browser"?"Browser":void 0,onSelect:()=>s(p.id),children:[n.jsx(Un,{icon:p.icon}),n.jsx("span",{className:"max-w-64 truncate",children:p.category==="local-browser"?"Browser":p.title}),p.category==="local-browser"&&p.resource==="browser"&&n.jsx("span",{"aria-hidden":"true",className:"text-muted-foreground max-w-40 truncate",children:p.title}),p.id===t&&n.jsx("span",{"aria-hidden":"true",className:"ml-auto",children:"✓"})]},p.id)),r&&n.jsxs(n.Fragment,{children:[n.jsx(ss,{}),n.jsxs(qe,{onSelect:r,children:[n.jsx(vc,{}),"New terminal"]})]}),a&&n.jsx(qe,{onSelect:a,children:"New page preview"}),i&&n.jsx(qe,{onSelect:i,children:"New document"}),d&&n.jsxs(n.Fragment,{children:[n.jsx(ss,{}),n.jsx(qe,{onSelect:d,children:l?"Unpin document":"Pin document"})]}),c&&n.jsx(qe,{onSelect:c,children:"Remove document"}),o&&n.jsxs(n.Fragment,{children:[n.jsx(ss,{}),n.jsx(qe,{onSelect:o,children:"Stop terminal"})]})]})]})}function sj({active:e,hidden:t,here:s,saved:r}){const{setPlacement:o}=Bb(),a=P(x=>x.setActiveRightPanelTab),i=at(),c=co(),d=td(),l=P(x=>x.setRightPanelOpen),m=lo(),h=Rm(s)!==null,p=x=>kc(r.get(x.id),x.declaredPlacement),f=(e==null?void 0:e.extensionId)!=null?m.find(x=>x.extensionId===e.extensionId&&x.path==="")??m.find(x=>x.extensionId===e.extensionId)??null:null,g=h?t:[];return!e&&g.length===0?null:n.jsxs(Ds,{children:[n.jsx(Os,{asChild:!0,children:n.jsx(L,{variant:"ghost",size:"icon-md","aria-label":"Add-on tab options",className:"size-11 shrink-0 lg:size-7","data-testid":"mini-app-tab-menu",children:n.jsx(Tm,{className:"size-3.5"})})}),n.jsxs(Ms,{align:"end",className:"max-h-[70dvh] min-w-48 overflow-y-auto [&_[role=menuitem]]:min-h-11 lg:[&_[role=menuitem]]:min-h-0",children:[e&&n.jsxs(n.Fragment,{children:[f&&c&&n.jsxs(qe,{onSelect:()=>{d&&l(!1),c({href:jc(f.extensionId,f.path)})},children:[n.jsx(Dm,{}),"Open full page"]}),h&&n.jsxs(qe,{onSelect:()=>o(e.id,Mm(p(e),s)),children:[n.jsx(Om,{}),"Hide here"]}),n.jsxs(qe,{onSelect:()=>i.open("extensions",e.extensionId),children:[n.jsx(_m,{}),"Where it shows…"]})]}),e&&g.length>0&&n.jsx(ss,{}),g.length>0&&n.jsxs(n.Fragment,{children:[n.jsx(wc,{className:"text-muted-foreground text-xs font-normal",children:"Show here"}),g.map(x=>n.jsxs(qe,{onSelect:()=>{o(x.id,Pm(p(x),s)),a(x.id)},children:[x.icon?n.jsx(Un,{icon:x.icon}):n.jsx(Rt,{}),x.title]},x.id))]})]})]})}const rj={canvas:"canvas",browser:"browser"};function oj(e,t){return t==="attention"?`${e}, something needs you`:e}function aj({contributionId:e}){const t=rj[e],s=P(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 Lm(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 Mo="right-panel-content";function is(e){return`right-panel-tab-${e}`}function ij({contributions:e,actions:t,activeId:s,onActivate:r,onCloseView:o}){const a=P(d=>d.setRightPanelOpen),i=P(d=>d.activeRightPanelTab),c=P(d=>d.setActiveRightPanelTab);return n.jsxs("div",{className:"flex w-full items-center justify-between px-3 py-2","data-slot":"right-panel-header",children:[e.length>1||r?n.jsx(cj,{contributions:e,activeTab:s===void 0?i:s,onActivate:r??c,onCloseView:o}):e.length===1?n.jsxs("div",{className:"text-foreground flex items-center gap-1.5 px-1 text-xs font-medium",children:[n.jsx(Un,{icon:e[0].icon,className:"text-muted-foreground size-3.5"}),n.jsx("span",{children:e[0].title})]}):n.jsx("div",{}),n.jsxs("div",{className:"flex shrink-0 items-center gap-1 pl-1",children:[t,n.jsx(L,{variant:"ghost",size:"icon-md","aria-label":"Close panel",className:"size-11 shrink-0 lg:size-7",onClick:()=>a(!1),children:n.jsx(Be,{className:"size-3.5"})})]})]})}function cj({contributions:e,activeTab:t,onActivate:s,onCloseView:r}){const o=u.useRef(null),a=u.useRef("keyboard"),i=u.useRef(null),c=Fm(p=>p.tabMarkers),d=Sc(o,"horizontal"),l=u.useCallback(()=>{const p=o.current;return!p||!t?null:p.querySelector(`#${CSS.escape(is(t))}`)},[t]),m=u.useCallback(()=>{const p=o.current,f=l();!p||!f||Cc(p,f)},[l]),h=e.map(p=>p.id).join(",");return u.useEffect(()=>{if(m(),typeof ResizeObserver>"u")return;const p=new ResizeObserver(m);for(const f of[o.current,i.current,l()])f&&p.observe(f);return()=>p.disconnect()},[m,l,h]),n.jsx(Kl,{asChild:!0,value:t??"",onValueChange:p=>{s(p,a.current),a.current="keyboard"},children:n.jsxs("div",{className:"relative min-w-0 flex-1",children:[n.jsx("div",{ref:o,onScroll:d.onScroll,"data-testid":"right-panel-tabs-scroller",className:"-my-1 overflow-x-auto overflow-y-hidden py-1 max-lg:snap-x max-lg:snap-proximity max-lg:scroll-px-6 max-lg:pe-6",children:n.jsx(Hl,{ref:i,responsive:!1,"aria-label":"Right panel tabs",className:"bg-accent/60 h-auto justify-start gap-0.5 rounded-lg p-0.5",children:e.map(p=>{var g,x;const f=p.id===t;return n.jsxs("div",{className:"group/view relative flex shrink-0 items-center py-2 max-lg:snap-start md:py-0",children:[n.jsxs(pn,{children:[n.jsx(gn,{asChild:!0,children:n.jsxs(os,{value:p.id,"data-view-category":p.category??p.id,onPointerDown:()=>{a.current="pointer"},onKeyDown:y=>{var b;if(a.current="keyboard",y.key==="Delete"&&r&&!p.permanent){y.preventDefault();const C=e.findIndex(v=>v.id===p.id),S=e[C+1]??e[C-1],I=(b=y.currentTarget.closest('[data-slot="right-panel-header"]'))==null?void 0:b.querySelector('[aria-label="Add view"]');r(p.id),requestAnimationFrame(()=>{var v;S?(v=document.getElementById(is(S.id)))==null||v.focus():I==null||I.focus()})}},"aria-label":[oj(p.title,c[p.id]??null),p.author&&`Posted by ${p.author.displayName}`,p.unread&&"Unread",((g=p.watchers)==null?void 0:g.length)&&`${p.watchers.map(y=>y.displayName).join(", ")} ${p.watchers.length===1?"is":"are"} looking at this.`].filter(Boolean).join(", "),id:is(p.id),"aria-controls":f?Mo:void 0,className:K("text-muted-foreground hover:text-foreground text-3xs shrink-0 gap-1.5 rounded-md px-2.5 py-1",f&&"bg-background text-foreground shadow-sm"),children:[n.jsx(Un,{icon:p.icon,className:"size-3.5"}),p.author&&n.jsx("span",{title:`Posted by ${p.author.displayName}`,children:n.jsx(ms,{size:"xs",kind:p.author.kind,color:p.author.color??ds(p.author.id),emoji:p.author.emoji,imageUrl:p.author.imageUrl,fallback:Sr(p.author.displayName)})}),n.jsx("span",{className:"max-w-28 truncate",children:p.title}),p.pinned&&n.jsx("span",{"aria-label":"Pinned",children:"·"}),p.unread&&n.jsx("span",{"data-testid":"canvas-tab-unread","data-slot":"canvas-tab-unread","aria-label":"Unread",className:"bg-primary size-1.5 rounded-full"}),!!((x=p.watchers)!=null&&x.length)&&n.jsxs(n.Fragment,{children:[n.jsxs("span",{"data-slot":"canvas-tab-watchers","aria-hidden":!0,className:"flex shrink-0 -space-x-1",children:[p.watchers.slice(0,3).map(y=>n.jsx(ms,{size:"xs",className:"ring-background text-3xs size-3.5 ring-1",kind:y.kind,color:y.color??ds(y.id),emoji:y.emoji,imageUrl:y.imageUrl,badge:null,fallback:Sr(y.displayName)},y.id)),p.watchers.length>3&&n.jsxs("span",{className:"text-3xs",children:["+",p.watchers.length-3]})]}),n.jsxs("span",{className:"sr-only",children:[p.watchers.map(y=>y.displayName).join(", ")," ",p.watchers.length===1?"is":"are"," looking at this."]})]}),n.jsx(aj,{contributionId:p.id})]})}),n.jsx(xn,{side:"bottom",children:p.title})]}),r&&f&&!p.permanent&&n.jsx(L,{variant:"ghost",size:"icon-sm",tabIndex:-1,"aria-label":`Close ${p.title} view`,className:"relative size-6 after:absolute after:inset-x-0 after:-inset-y-2 md:after:hidden",onClick:()=>r(p.id),children:n.jsx(Be,{className:"size-3"})})]},p.id)})})}),d.start&&n.jsx("div",{"aria-hidden":!0,"data-testid":"right-panel-tabs-fade-start",className:"from-sidebar via-sidebar/70 pointer-events-none absolute inset-y-0 left-0 w-6 bg-gradient-to-r to-transparent"}),d.end&&n.jsx("div",{"aria-hidden":!0,"data-testid":"right-panel-tabs-fade-end",className:"from-sidebar via-sidebar/70 pointer-events-none absolute inset-y-0 right-0 w-6 bg-gradient-to-l to-transparent"})]})})}const _r="app-shell-right-panel",lj=40,dj=320,Fd=20,uj=50;function mj(e){if(e<=0)return Fd;const t=dj/e*100;return Math.min(Math.round(t*10)/10,uj)}function hj(){const[e,t]=u.useState(Fd);return u.useLayoutEffect(()=>{const s=document.querySelector(`[data-panel-group-id="${_r}"]`);if(!(s instanceof HTMLElement))return;const r=()=>t(mj(s.offsetWidth));r();const o=new ResizeObserver(r);return o.observe(s),()=>o.disconnect()},[]),{minPct:e,defaultPct:Math.max(lj,e)}}function fj(e,t){var f;const s=$m(e),r=Bm(),o=P(g=>g.selectedCwd),a=s==="session",i=Nc(a?o:null),c=r.status==="loading"||a&&o!==null&&i.isPending,d=r.status==="ready"&&!t?r.roomId:null,l=a?((f=i.data)==null?void 0:f.id)??null:null,m=u.useMemo(()=>pj(s,d,l,a),[s,d,l,a]),[h,p]=u.useState(null);return!c&&h!==m&&p(m),c?{status:"pending",last:h}:{status:"ready",here:m}}function pj(e,t,s,r){const o={page:e};return t&&(o.roomId=t),r&&(o.agentId=s),o}const gj="cubic-bezier(0, 0, 0.2, 1)",xj="cubic-bezier(0.4, 0, 1, 1)";function Va(e,t){return`${e} 300ms ${t?gj:xj}`}const bj=new Set(["pulse","files"]);function yj(e){e.preventDefault();const t=document.getElementById(Mo);t&&!t.contains(document.activeElement)&&t.focus({preventScroll:!0})}function vj({pathname:e,isRemoteCommunityRoom:t=!1}){var ne;const s=P(q=>q.rightPanelOpen),r=P(q=>q.setRightPanelOpen),o=P(q=>q.activeRightPanelTab),a=P(q=>q.setActiveRightPanelTabView),i=td(),c=Pe(),d=jd(),l=u.useRef(null),[m,h]=u.useState(!1),[p,f]=u.useState(!1);u.useEffect(()=>{const q=requestAnimationFrame(()=>f(!0));return()=>cancelAnimationFrame(q)},[]);const g=ae(),x=P(q=>q.currentAgentId),y=P(q=>q.selectedCwd),b=P(q=>q.explicitAgentPath),C=Hb(),S=(C==null?void 0:C.kind)??null,I=(C==null?void 0:C.showSessions)??!1,v=u.useMemo(()=>S===null?null:{kind:S,showSessions:I},[S,I]),E=_s("right-panel"),R=u.useMemo(()=>E.filter(q=>!q.visibleWhen||q.visibleWhen({pathname:e,transport:g,agentId:x,cwd:y,explicitAgentPath:b,isRemoteCommunityRoom:t,directMessage:v})),[E,e,g,x,y,b,t,v]),M=fj(e,t),O=M.status==="ready"?M.here:M.last,_=zb(),D=_e().data!==void 0,k=u.useMemo(()=>new Map(_.map(q=>[q.tab,q])),[_]),{visibleContributions:j,hiddenMiniAppTabs:N}=u.useMemo(()=>{const q=[],he=[];for(const ge of R)ge.extensionId?O&&zm(kc(k.get(ge.id),ge.declaredPlacement),O)?q.push(ge):he.push(ge):q.push(ge);return{visibleContributions:q,hiddenMiniAppTabs:he}},[R,O,k]),w=tj(j,e),T=w.visible,$=`${P(q=>q.sessionId)??""}:${y}`;u.useEffect(()=>{if(M.status!=="pending"&&T.length>0&&!T.some(he=>he.category===o)){const he=T.find(ge=>!ge.isGlobal);a((he??T[0]).category)}},[T,o,a,M.status]);const W=s,{minPct:X,defaultPct:ie}=hj();u.useEffect(()=>{const q=l.current;q&&(W&&q.isCollapsed()?q.expand(ie):!W&&q.isExpanded()&&q.collapse())},[W,ie]);const B=w.available.find(q=>q.id===o&&T.some(he=>he.category===q.id)),Y=w.available.find(q=>q.id==="terminal"),oe=Y==null?void 0:Y.component,pe=w.terminal!==null||o==="terminal",V=B==null?void 0:B.component,G=B==null?void 0:B.headerActions,te=n.jsxs(n.Fragment,{children:[n.jsx(ij,{contributions:T,activeId:w.activeId,onActivate:w.activate,onCloseView:w.closeView,actions:n.jsxs(n.Fragment,{children:[n.jsx(nj,{views:w.allViews,activeId:w.activeId,onActivate:w.activate,onCreateBrowser:w.createBrowser,onCreateDocument:w.createDocument,onRemoveDocument:w.removeDocument,onPinDocument:w.pinDocument,documentPinned:w.documentPinned,onCreateTerminal:w.createTerminal,onStopTerminal:o==="terminal"&&((ne=w.terminal)!=null&&ne.activeId)?()=>{var q;return(q=w.terminal)==null?void 0:q.stop(w.terminal.activeId,"pointer")}:void 0}),G?n.jsx(u.Suspense,{fallback:null,children:n.jsx(G,{})}):null,M.status==="ready"&&D&&n.jsx(sj,{active:B!=null&&B.extensionId?B:null,hidden:N,here:M.here,saved:k})]})}),(C==null?void 0:C.kind)==="group"&&s&&n.jsx(vw,{members:C.members}),n.jsx(Kb,{slot:"right-panel",onReview:()=>xc(),className:"border-b px-2 py-1.5"}),n.jsx("div",{className:"min-h-0 flex-1 overflow-hidden outline-none",...o===ta?{tabIndex:-1}:{},...w.activeId&&T.some(q=>q.category===o)?{id:Mo,role:"tabpanel","aria-labelledby":is(w.activeId)}:{},children:n.jsx(Ga,{tabId:o,children:n.jsx(u.Suspense,{fallback:null,children:n.jsxs(Um,{value:!0,children:[s&&o!=="terminal"&&V?n.jsx(V,{}):null,oe&&pe&&n.jsx("div",{hidden:o!=="terminal"||!s||!B,className:"h-full",children:n.jsx(Km,{value:o==="terminal"&&s&&!!B,children:n.jsx(Ga,{tabId:o,children:n.jsx(oe,{})})})},$),!B&&n.jsx("div",{className:"text-muted-foreground flex h-full items-center justify-center p-6 text-sm",children:"Add a view to this panel."})]})})})})]});if(i)return W?n.jsx(Hm,{open:!0,onOpenChange:q=>!q&&r(!1),children:n.jsxs(Wm,{showCloseButton:!1,...o===ta?{onOpenAutoFocus:yj}:{},style:{top:d.top,bottom:"auto",height:d.height,maxHeight:d.height},className:K("bg-sidebar text-sidebar-foreground flex w-full flex-col gap-0 pt-[env(safe-area-inset-top)] pr-[env(safe-area-inset-right)] pb-[env(safe-area-inset-bottom)] pl-[env(safe-area-inset-left)]",c&&"sm:max-w-full",c&&o&&bj.has(o)&&"!bottom-auto !h-auto max-h-dvh overflow-y-auto"),children:[n.jsxs(Gm,{className:"sr-only",children:[n.jsx(qm,{children:"Panel"}),n.jsx(Ym,{children:"Right panel content."})]}),te]})}):null;const we=p&&!m;return n.jsxs(n.Fragment,{children:[n.jsx(Fb,{"aria-label":"Resize right panel",disabled:!W,onDragging:h,gripStyle:{opacity:W?1:0,pointerEvents:W?"auto":"none",...we&&{transition:Va("opacity",W)}}}),n.jsx(Ac,{ref:l,id:"right-panel",order:2,defaultSize:W?ie:0,minSize:X,collapsible:!0,collapsedSize:0,onCollapse:()=>{p&&r(!1)},onExpand:()=>{s||r(!0)},style:we?{transition:Va("flex-grow",W)}:void 0,children:n.jsx("div",{inert:!W,className:"bg-sidebar text-sidebar-foreground flex h-full flex-col overflow-hidden border-l",children:te})})]})}function wj(){const e=P(t=>t.toggleRightPanel);u.useEffect(()=>{const t=s=>{(s.metaKey||s.ctrlKey)&&s.key==="."&&(s.preventDefault(),e())};return document.addEventListener("keydown",t),()=>document.removeEventListener("keydown",t)},[e])}const Qa=new WeakMap;let jj=0;function kj(e){const t=Qa.get(e);if(t!==void 0)return t;const s=`bar-${jj++}`;return Qa.set(e,s),s}function Sj(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:kj(r),Header:r}}return null}function Cj(e){const t=e.startsWith("/")?e:`/${e}`;if($e()){const s=t.slice(1);if(s.length>0&&!s.startsWith("?")&&!s.startsWith("#"))return`dorkos://${s}`}return`${window.location.origin}${t}`}const Nj="/";function _o(){const e=Qt();return u.useMemo(()=>{const t=()=>uo(e),s=a=>{ue.getState().selectTab(a),t()},r=a=>{const i=ue.getState().tabs;a(),Ec(i,ue.getState().tabs)},o=a=>{const{tabs:i}=ue.getState(),c=i[a];c&&s(c.id)};return{activate:s,activateIndex:o,activateLast:()=>o(ue.getState().tabs.length-1),activateRelative:a=>{const{tabs:i,activeTabId:c}=ue.getState();if(i.length<2)return;const d=i.findIndex(h=>h.id===c),m=(((d===-1?0:d)+a)%i.length+i.length)%i.length;s(i[m].id)},close:a=>{r(()=>ue.getState().closeTab(a)),t()},closeActive:()=>{const{tabs:a,activeTabId:i}=ue.getState();if(!i)return!1;const c=a.length;r(()=>ue.getState().closeTab(i));const d=ue.getState().tabs.length<c;if(d)try{t()}catch(l){console.error("[dorkos:tabs] could not follow a closed tab",l)}return d},create:()=>Qm(e,Nj),togglePin:a=>{const i=ue.getState().tabs.find(c=>c.id===a);i&&ue.getState().setTabPinned(a,!i.pinned)},duplicate:a=>{ue.getState().duplicateTab(a),t()},closeOthers:a=>{r(()=>ue.getState().closeOtherTabs(a)),t()},reorder:(a,i)=>ue.getState().moveTab(a,i),reopenClosed:a=>{Vm(e,a).catch(i=>{console.error("[dorkos:tabs] could not reopen a closed tab",i)})}}},[e])}const Aj={start:["Space"],cancel:["Escape"],end:["Space","Enter","Tab"]},Ej=4,Ij={draggable:"Press Space to move this tab. Arrows move it, Space drops it, Escape cancels."};function Rj(e){return t=>{const s=e(String(t.active.id));return Ic({...t,droppableContainers:t.droppableContainers.filter(r=>e(String(r.id))===s)})}}class Tj extends Map{getEnabled(){return[...this.values()].filter(t=>!t.disabled)}toArray(){return[...this.values()]}}function Dj(e){return(t,s)=>{const{context:r}=s;if(!r.active)return Cr(t,s);const o=e(String(r.active.id)),a=new Tj;for(const i of r.droppableContainers.toArray())e(String(i.id))===o&&a.set(i.id,i);return Cr(t,{...s,context:{...r,droppableContainers:a}})}}function Oj(e){return e.length===0?null:{left:Math.min(...e.map(t=>t.left)),right:Math.max(...e.map(t=>t.right))}}function Mj(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 _j(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 Pj(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 Lj=500;function Fj(e){const t=Kn(new Date(e).toISOString());return`Last active ${t==="Just now"?"just now":t}`}function $j({identity:e,className:t}){return n.jsxs("div",{className:K("flex min-w-0 flex-col gap-1.5 text-xs",t),children:[n.jsxs("div",{className:"flex min-w-0 items-start gap-2",children:[n.jsx(mo,{icon:e.icon,className:"mt-px"}),n.jsxs("p",{className:"min-w-0 font-medium break-words",children:[e.primary,e.secondary&&n.jsxs("span",{className:"text-muted-foreground font-normal",children:[" · ",e.secondary]})]})]}),e.origin&&n.jsx("p",{className:"text-muted-foreground",children:e.origin}),e.statusSentence&&n.jsxs("p",{className:"flex items-start gap-1.5",children:[n.jsx(ho,{identity:e,className:"mt-[5px]"}),n.jsx("span",{children:e.statusSentence})]}),e.lastActiveAt!==void 0&&!Number.isNaN(e.lastActiveAt)&&n.jsx("p",{className:"text-muted-foreground",children:Fj(e.lastActiveAt)})]})}function Bj({identity:e,children:t}){return n.jsxs(Jl,{openDelay:Lj,closeDelay:0,children:[n.jsx(Zl,{asChild:!0,children:t}),n.jsx(ed,{side:"bottom",align:"start",sideOffset:6,className:"w-64 p-3",children:n.jsx($j,{identity:e})})]})}const $d="app-tab-panel";function zj({identity:e,isActive:t,canClose:s,collapseAgent:r=!1,pinned:o=!1,tabProps:a,onClose:i}){const c=Jm(e,{collapseAgent:r}),d=s&&!o;return n.jsxs("div",{role:"presentation",className:"group relative flex shrink-0",children:[n.jsx(Bj,{identity:e,children:n.jsxs("button",{type:"button",role:"tab","aria-selected":t,"aria-controls":t?$d:void 0,"aria-label":Zm(e,{collapseAgent:r}),...a,className:K("focus-ring flex min-w-0 items-center gap-1.5 rounded-md py-1 text-xs transition-colors",o?"px-2":t?"max-w-72 pl-2":"max-w-52 pl-2",!o&&(d?"pr-7":"pr-2"),t?"bg-secondary text-foreground contrast-more:ring-foreground/40 contrast-more:ring-1":"text-muted-foreground/80 hover:bg-secondary/50 hover:text-foreground contrast-more:text-muted-foreground"),children:[n.jsx(mo,{icon:e.icon}),!o&&n.jsxs("span",{className:"min-w-0 truncate",children:[n.jsx("span",{className:"font-medium",children:c.lead}),c.trail&&n.jsxs("span",{className:"opacity-70",children:[" · ",c.trail]})]}),n.jsx(ho,{identity:e})]})}),d&&i&&n.jsx("button",{type:"button",tabIndex:-1,onClick:()=>i("pointer"),"aria-label":`Close ${e.primary}`,className:K("focus-ring hover:bg-muted absolute top-1/2 right-1 -translate-y-1/2 rounded-sm p-0.5","opacity-0 transition-opacity group-hover:opacity-70 hover:opacity-100",t&&"opacity-70"),children:n.jsx(Be,{className:"size-3"})})]})}function Uj({tab:e,isActive:t,canClose:s,pinned:r,tabProps:o,onClose:a}){const i=Ps(e.href),c=Xm(i.agentKey);return n.jsx(zj,{identity:i,isActive:t,canClose:s,collapseAgent:c,pinned:r??e.pinned??!1,tabProps:o,onClose:d=>a(e.id,d)})}function Kj({href:e,onSelect:t}){const s=Ps(e);return n.jsxs(_t,{onSelect:t,children:[n.jsx("span",{className:"truncate",children:s.primary}),s.secondary&&n.jsx("span",{className:"text-muted-foreground ml-1.5 truncate",children:s.secondary})]})}function Hj({tabId:e,pinned:t,hasOthersToClose:s,canClose:r,actions:o,onClosed:a,children:i}){const c=eh(),{reopenClosed:d}=o;return n.jsxs(th,{children:[n.jsx(nh,{asChild:!0,children:i}),n.jsxs(sh,{className:"w-56",onCloseAutoFocus:a?l=>{l.preventDefault(),a()}:void 0,children:[n.jsxs(_t,{onSelect:()=>o.togglePin(e),children:[t?n.jsx(rh,{className:"mr-2 size-4"}):n.jsx(oh,{className:"mr-2 size-4"}),t?"Unpin":"Pin"]}),n.jsxs(_t,{onSelect:()=>o.duplicate(e),children:[n.jsx(uy,{className:"mr-2 size-4"}),"Duplicate"]}),n.jsxs(_t,{onSelect:()=>o.copyLink(e),children:[n.jsx(ah,{className:"mr-2 size-4"}),"Copy link"]}),n.jsx(na,{}),n.jsxs(_t,{disabled:!s,onSelect:()=>o.closeOthers(e),children:[n.jsx(ih,{className:"mr-2 size-4"}),"Close others"]}),n.jsxs(_t,{disabled:!r,onSelect:()=>o.close(e),children:[n.jsx(Be,{className:"mr-2 size-4"}),"Close"]}),d&&n.jsxs(n.Fragment,{children:[n.jsx(na,{}),n.jsxs(_t,{disabled:c.length===0,onSelect:()=>d(),children:[n.jsx(Rc,{className:"mr-2 size-4"}),"Reopen closed tab",n.jsx("kbd",{className:"text-muted-foreground ml-auto pl-4 text-xs",children:Ht(an.REOPEN_CLOSED_TAB)})]}),n.jsxs(ch,{children:[n.jsxs(lh,{disabled:c.length===0,children:[n.jsx(nd,{className:"mr-2 size-4"}),"Recently closed"]}),n.jsx(dh,{className:"max-h-96 w-64 overflow-y-auto",children:c.map(l=>n.jsx(Kj,{href:l.tab.href,onSelect:()=>d({tabId:l.tab.id,closedAt:l.closedAt})},`${l.tab.id}-${l.closedAt}`))})]})]})]})]})}const Pt="data-app-tab-id";function Wj({tab:e,isActive:t,canClose:s,tabProps:r,onClose:o,sortable:a,dragActive:i,menu:c,hasOthersToClose:d,onMenuClosed:l}){const m=e.pinned??!1,{setNodeRef:h,setActivatorNodeRef:p,attributes:f,listeners:g,transform:x,transition:y,isDragging:b}=uh({id:e.id,disabled:!a}),C=g==null?void 0:g.onPointerDown,S=g==null?void 0:g.onKeyDown,I={transform:x?`translate3d(${Math.round(x.x)}px, 0, 0)`:void 0,transition:y??void 0},{ref:v,onKeyDown:E}=r,R=u.useCallback(D=>{v(D),p(D)},[v,p]),M=u.useCallback(D=>{if(c&&(D.key==="ContextMenu"||D.shiftKey&&D.key==="F10")){D.preventDefault();const k=D.currentTarget,j=k.getBoundingClientRect();k.dispatchEvent(new MouseEvent("contextmenu",{bubbles:!0,cancelable:!0,clientX:j.left,clientY:j.bottom}));return}S==null||S(D),!(D.defaultPrevented||i)&&E(D)},[c,S,i,E]),O=u.useMemo(()=>({...r,ref:R,onKeyDown:M,...a?{"aria-describedby":f["aria-describedby"]}:{}}),[r,R,M,a,f]),_=n.jsx("div",{ref:h,role:"presentation",[Pt]:e.id,style:I,onPointerDown:C,className:K("flex shrink-0",b&&"bg-background shadow-soft relative z-10 rounded-md"),children:n.jsx(Uj,{tab:e,isActive:t,canClose:s,tabProps:O,onClose:o,pinned:m})});return c?n.jsx(Hj,{tabId:e.id,pinned:m,hasOthersToClose:d,canClose:s,actions:c,onClosed:l,children:_}):_}const Gj=32;function qj({tabs:e,activeId:t,onActivate:s,onClose:r,onCreate:o,menu:a,onReorder:i,className:c}){const d=u.useRef(null),l=u.useRef(null),m=u.useRef(null),h=Tc(null),p=e.length>1,[f,g]=u.useState(!1),x=u.useMemo(()=>e.map(j=>j.id),[e]),y=Lt(e),{collisionDetection:b,coordinateGetter:C,modifiers:S,announcements:I}=u.useMemo(()=>{const j=w=>y.read().findIndex(T=>T.id===w),N=w=>{var T;return((T=y.read().find(F=>F.id===w))==null?void 0:T.pinned)??!1};return{collisionDetection:Rj(N),coordinateGetter:Dj(N),modifiers:[Mj(h.read)],announcements:Pj({nameOf:w=>{var T,F,$;return(($=(F=(T=Array.from(document.querySelectorAll(`[${Pt}]`)).find(W=>W.getAttribute(Pt)===w))==null?void 0:T.querySelector('[role="tab"]'))==null?void 0:F.textContent)==null?void 0:$.trim())||"Tab"},indexOf:j,count:()=>y.read().length})}},[y,h]);u.useEffect(()=>{const j=m.current;if(!j)return;const N=w=>{Math.abs(w.deltaY)<=Math.abs(w.deltaX)||j.scrollWidth<=j.clientWidth||(w.preventDefault(),j.scrollLeft+=w.deltaY)};return j.addEventListener("wheel",N,{passive:!1}),()=>j.removeEventListener("wheel",N)},[]);const v=Sc(m,"horizontal"),E=u.useCallback(()=>{const j=m.current;if(!j||t===null)return;const N=Array.from(j.querySelectorAll(`[${Pt}]`)).find(w=>w.getAttribute(Pt)===t);N&&Cc(j,N,Gj)},[t]);u.useEffect(()=>{if(E(),typeof ResizeObserver>"u")return;const j=m.current;if(!j)return;const N=new ResizeObserver(E);return N.observe(j),l.current&&N.observe(l.current),()=>N.disconnect()},[E]);const R=Dc(ps(_c,{activationConstraint:{distance:Ej}}),ps(Mc,{coordinateGetter:C,keyboardCodes:Aj})),M=({active:j})=>{var T,F;g(!0);const N=((T=e.find($=>$.id===j.id))==null?void 0:T.pinned)??!1,w=Array.from(((F=l.current)==null?void 0:F.querySelectorAll(`[${Pt}]`))??[]).filter($=>{var X;const W=$.getAttribute(Pt);return(((X=e.find(ie=>ie.id===W))==null?void 0:X.pinned)??!1)===N}).map($=>$.getBoundingClientRect());h.write(Oj(w))},O=()=>{g(!1),h.write(null)},_=({active:j,over:N})=>{O();const w=_j(x,j.id,N==null?void 0:N.id);w&&i&&i(...w)},D=()=>{setTimeout(()=>{var j,N;(N=(j=l.current)==null?void 0:j.querySelector('[role="tab"][aria-selected="true"]'))==null||N.focus()},0)},{getTabProps:k}=Vb({orderedIds:e.map(j=>j.id),activeId:t,onActivate:s,onClose:p?r:void 0,getFallbackFocus:()=>d.current});return n.jsxs("div",{className:K("bg-muted/40 flex shrink-0 items-stretch border-b px-2 py-1",c),children:[n.jsx("div",{ref:m,"data-slot":"app-tab-strip","data-fade-start":v.start||void 0,"data-fade-end":v.end||void 0,onScroll:v.onScroll,className:"flex min-w-0 flex-1 items-stretch overflow-x-auto",children:n.jsx(Oc,{sensors:R,collisionDetection:b,modifiers:S,accessibility:{announcements:I,screenReaderInstructions:Ij},onDragStart:M,onDragEnd:_,onDragCancel:O,children:n.jsx(mh,{items:x,strategy:hh,children:n.jsx("div",{ref:l,role:"tablist","aria-label":"Open tabs",className:"flex items-stretch gap-1",children:e.map(j=>n.jsx(Wj,{tab:j,isActive:j.id===t,canClose:p,tabProps:k(j.id),onClose:r,sortable:i!==void 0,dragActive:f,menu:a,onMenuClosed:D,hasOthersToClose:e.some(N=>N.id!==j.id&&!N.pinned)},j.id))})})})}),n.jsx("button",{ref:d,type:"button",onClick:o,"aria-label":"New tab",title:`New tab (${Ht(an.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(Rt,{className:"size-3.5"})})]})}function Yj({className:e}){const t=fh(),s=ue(f=>f.activeTabId),{activate:r,close:o,create:a,togglePin:i,duplicate:c,closeOthers:d,reorder:l,reopenClosed:m}=_o(),{copy:h}=Bn({toastOnSettle:!0}),p=u.useMemo(()=>({togglePin:i,duplicate:c,closeOthers:d,close:o,reopenClosed:m,copyLink:f=>{const g=ue.getState().tabs.find(x=>x.id===f);g&&h(Cj(g.href))}}),[i,c,d,o,m,h]);return n.jsx(qj,{tabs:t,activeId:s,onActivate:r,onClose:o,onCreate:a,menu:p,onReorder:l,className:e})}function js(){var s;const{tabs:e,activeTabId:t}=ue.getState();return((s=e.find(r=>r.id===t))==null?void 0:s.cursor)??null}function Po(e,t){const s=js();s!==null&&(ue.getState().goToHistoryIndex(t),js()!==s&&uo(e))}function Bd(e){const t=js();t!==null&&Po(e,t-1)}function zd(e){const t=js();t!==null&&Po(e,t+1)}function Vj(e,t){Po(e,t)}function Xa(e,t){const s=Ht(e);return Wt?s:`${s} or ${Ht(`alt+${t}`)}`}const rr="size-7";function Qj({href:e,isCurrent:t,onSelect:s}){const r=Ps(e);return n.jsxs(qe,{disabled:t,"aria-current":t?"page":void 0,onSelect:s,"aria-label":r.accessibleName,className:"data-[disabled]:opacity-100",children:[n.jsx(mo,{icon:r.icon}),n.jsxs("span",{className:"min-w-0 flex-1 truncate",children:[r.primary,r.secondary&&n.jsxs("span",{className:"text-muted-foreground",children:[" · ",r.secondary]})]}),n.jsx(ho,{identity:r}),n.jsx(Xt,{className:K("size-3.5 shrink-0",!t&&"invisible")})]})}function or({label:e,keys:t,children:s}){return n.jsxs(pn,{children:[n.jsx(gn,{asChild:!0,children:s}),n.jsx(xn,{side:"bottom",className:"text-xs",children:t?`${e} (${t})`:e})]})}function Xj(){const e=Qt(),{entries:t,cursor:s,canGoBack:r,canGoForward:o}=ph();if(!$e())return null;const a=t.map((i,c)=>({href:i,index:c})).reverse();return n.jsxs("div",{className:"flex items-center",children:[n.jsx(or,{label:"Back",keys:Xa(an.HISTORY_BACK.key,"←"),children:n.jsx(L,{variant:"ghost",size:"icon-md",className:rr,"aria-label":"Back",disabled:!r,onClick:()=>Bd(e),children:n.jsx(Pc,{})})}),n.jsx(or,{label:"Forward",keys:Xa(an.HISTORY_FORWARD.key,"→"),children:n.jsx(L,{variant:"ghost",size:"icon-md",className:rr,"aria-label":"Forward",disabled:!o,onClick:()=>zd(e),children:n.jsx(Lc,{})})}),n.jsxs(Ds,{children:[n.jsx(or,{label:"History",children:n.jsx(Os,{asChild:!0,children:n.jsx(L,{variant:"ghost",size:"icon-md",className:rr,"aria-label":"History",children:n.jsx(nd,{})})})}),n.jsx(Ms,{align:"start",className:"max-w-72 min-w-48",children:a.map(({href:i,index:c})=>n.jsx(Qj,{href:i,isCurrent:c===s,onSelect:()=>Vj(e,c)},c))})]})]})}function Jj(){const e=Qt(),t=De({select:o=>o.location.href}),s=u.useRef(!1),r=u.useRef(!0);u.useEffect(()=>{if($e())return e.history.subscribe(({action:o})=>{s.current=o.type!=="PUSH"&&o.type!=="REPLACE",r.current=o.type==="REPLACE"})},[e]),u.useEffect(()=>{if(!$e())return;const o=s.current,a=r.current;s.current=!1,r.current=!1,ue.getState().syncLocation(t,{traversal:o,replace:a})},[t])}const Ja=9;function Zj(){const e=_o();u.useEffect(()=>{if(!$e())return;const t=s=>{if(!(s.metaKey||s.ctrlKey)||s.altKey)return;if(s.shiftKey){s.code==="BracketLeft"?(s.preventDefault(),e.activateRelative(-1)):s.code==="BracketRight"?(s.preventDefault(),e.activateRelative(1)):s.key.toLowerCase()==="t"&&(s.preventDefault(),e.reopenClosed());return}if(s.key==="t"||s.key==="T"){s.preventDefault(),e.create();return}if(!s.code.startsWith("Digit"))return;const r=Number(s.code.slice(5));!Number.isInteger(r)||r<1||r>Ja||(s.preventDefault(),r===Ja?e.activateLast():e.activateIndex(r-1))};return document.addEventListener("keydown",t),()=>document.removeEventListener("keydown",t)},[e])}const Za=3,ek=4;function tk(e){return e instanceof Element?e.closest("input, textarea, select")?!0:e.closest('[contenteditable]:not([contenteditable="false"])')!==null:!1}function ei(e){return e instanceof Element&&e.closest('[role="dialog"], [role="alertdialog"], [role="menu"]')!==null}function nk(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(tk(e.target))return null;if(e.key==="ArrowLeft")return"back";if(e.key==="ArrowRight")return"forward"}return null}function sk(){const e=Qt();u.useEffect(()=>{if(!$e())return;const t=i=>i==="back"?Bd(e):zd(e),s=i=>{if(i.defaultPrevented||i.isComposing||ei(i.target))return;const c=nk(i);c&&(i.preventDefault(),t(c))},r=i=>i.button===Za||i.button===ek,o=i=>{r(i)&&i.preventDefault()},a=i=>{r(i)&&(i.preventDefault(),!ei(i.target)&&t(i.button===Za?"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 rk(e){return typeof e=="object"&&e!==null&&e.status===404}async function ok(e){try{return await e(),!1}catch(t){return rk(t)}}async function ak(e,t){const s=new Map,r=(a,i)=>{let c=s.get(a);return c||(c=ok(i),s.set(a,c)),c},o=await Promise.all(e.map(async a=>{const i=gh(a.href);if(i.pathname==="/session"&&i.sessionId&&!i.draft){const c=i.sessionId;return await r(`session:${c}`,()=>t.getSession(c))?a.id:null}if(i.pathname==="/channels"&&i.roomId&&!i.community){const c=i.roomId;return await r(`room:${c}`,()=>t.getRoom(c))?a.id:null}return null}));return new Set(o.filter(a=>a!==null))}function ik(){const e=ae(),t=Qt();u.useEffect(()=>{if(!$e())return;let s=!1;const r=ue.getState().tabs;return ak(r,{getSession:o=>e.getSession(o),getRoom:o=>e.getRoom(o)}).then(o=>{if(s||o.size===0)return;const{tabs:a,activeTabId:i}=ue.getState();ue.getState().dropTabs(o),Ec(a,ue.getState().tabs),ue.getState().activeTabId!==i&&uo(t)}).catch(o=>{console.error("[dorkos:tabs] could not check restored tabs",o)}),()=>{s=!0}},[])}function ck(){Jj(),Zj(),xh(),ik(),sk()}function lk(e){return e.displayName||e.name}function Lo(e,t){const s=On(r=>r.setRouteBadge);u.useEffect(()=>{s(e,t)},[e,t,s])}const dk=5*6e4;function uk(e){return e.status==="active"&&e.enabled}function mk(e){const{enabled:t}=yh(),{data:s}=Fc(t),{data:r}=vh(t),o=On(c=>c.setSchedulesWaitingCount),a=u.useMemo(()=>{const c=yw(t?r??[]:[]),d=new Map((s??[]).filter(uk).map(l=>[l.id,l]));return{waiting:e,failed:c.failed.filter(l=>d.has(l)).length,running:c.running.flatMap(l=>{const m=d.get(l);return m?[lk(m)]:[]})}},[t,r,s,e]),i=u.useMemo(()=>wh(a),[a]);Lo("/tasks",i),u.useEffect(()=>{o(e)},[e,o])}function hk(){const{count:e,more:t}=jh(),s=u.useMemo(()=>kh(e,t),[e,t]);Lo("/activity",s)}function fk(){const{data:e,isSuccess:t}=mx("pending"),{data:s}=hx("pending",{enabled:t,refetchInterval:dk}),r=((e==null?void 0:e.length)??0)+((s==null?void 0:s.length)??0),o=u.useMemo(()=>Sh(r),[r]);Lo("/connections",o)}function pk(){const{items:e,schedules:t}=bh(),s=On(r=>r.setNeedsYouCount);u.useEffect(()=>{s(e.length)},[e.length,s]),mk(t.length),hk(),fk()}function zt(e){return"problem"in e?{problem:e.problem}:{message:e.message}}const Ut={message:"Couldn’t reach your DorkOS account. Try again."},gk={message:"Finish signing in in your browser, then try again."},xk={message:"Your browser blocked the window. Allow pop-ups, then try again."},ar={message:"Couldn’t connect this DorkOS to the space. Try again."},bk={message:"The approval ran out. Connect again."};function Fo(e,t,s){var O,_;const r=ae(),o=le(),a=$n(e!==null),{signsInWithAccount:i,linkFor:c}=$c(e!==null),[d,l]=u.useState({opened:!1,busy:!1,notice:null}),[m,h]=u.useState(null),p=u.useRef(null),f=Ee({queryKey:it.list(),queryFn:()=>r.listHostedCommunities(),enabled:e!==null&&m===null,refetchInterval:D=>{const k=D.state.data,j=(k==null?void 0:k.available)===!0?k.communities.find(N=>N.communityId===(e==null?void 0:e.communityId)):void 0;return(j==null?void 0:j.state)==="provisioning"?2e3:!1}}),g=((O=f.data)==null?void 0:O.available)===!0?f.data.communities.find(D=>D.communityId===(e==null?void 0:e.communityId)):void 0,x=(g==null?void 0:g.state)==="provisioning",y=u.useCallback(()=>{if(!e||d.busy)return;const D=no();if(D===null){l(k=>({...k,notice:xk}));return}l(k=>({...k,busy:!0,notice:null})),r.getHostedCommunityClaimLink(e.communityId).then(k=>{if(!k.ok){D.close(),l(N=>({...N,busy:!1,notice:zt(k)}));return}const j=D.go(c(k.claimUrl));l(N=>({opened:N.opened||j,busy:!1,notice:null}))}).catch(()=>{D.close(),l(k=>({...k,busy:!1,notice:Ut}))})},[e,d.busy,r,c]),b=u.useCallback(async()=>{if(e){if(!a||!Ft(a)){h({ref:null,approvalUrl:null,busy:!1,notice:ar});return}h({ref:null,approvalUrl:null,busy:!0,notice:null});try{const D=await r.startCommunityConnection({url:e.communityUrl,installName:t});h({ref:D.connection.ref,approvalUrl:D.approvalUrl,busy:!1,notice:null}),await o.invalidateQueries({queryKey:Ct.connections(a)})}catch{h({ref:null,approvalUrl:null,busy:!1,notice:ar})}}},[e,a,r,t,o]),C=u.useCallback(()=>{!e||d.busy||(l(D=>({...D,busy:!0,notice:null})),r.listHostedCommunities().then(D=>{o.setQueryData(it.list(),D);const k=D.available===!0?D.communities.find(j=>j.communityId===e.communityId):void 0;if(!k||k.state==="pending_owner"||k.state==="provisioning"){l(j=>({...j,busy:!1,notice:gk}));return}l(j=>({...j,busy:!1})),b()}).catch(()=>l(D=>({...D,busy:!1,notice:Ut}))))},[e,d.busy,r,o,b]),S=(m==null?void 0:m.ref)??null,I=Ee({queryKey:a&&S?Ct.approval(a,S):["cloud","no-approval"],queryFn:()=>rc(a,()=>r.pollCommunityConnection(S)),enabled:a!==null&&S!==null,retry:!1,refetchInterval:D=>!D.state.error&&(!D.state.data||D.state.data.status==="pending")?2e3:!1}),v=S!==null?((_=I.data)==null?void 0:_.status)??"pending":"pending",E=v==="connected"?S:null;u.useEffect(()=>{E===null||p.current===E||(p.current=E,a&&o.invalidateQueries({queryKey:Ct.connections(a)}),o.invalidateQueries({queryKey:it.all}),s(E))},[E,a,o,s]);const R=v==="expired"||v==="cancelled";return{state:E!==null?{kind:"done",ref:E}:m!==null?{kind:"connecting",approvalUrl:m.approvalUrl,busy:m.busy,notice:m.notice??(R?bk:I.error?ar:null)}:x?{kind:"preparing"}:{kind:"claim",...d,withAccount:e!==null&&i(e.communityUrl)},openClaim:y,confirmClaimed:C,openApproval:()=>{m!=null&&m.approvalUrl&&Et(c(m.approvalUrl))},retryConnect:()=>void b()}}const bn=lt().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."),Ud=lt().trim().min(1).max(80).describe("The community`s display name. Trimmed, 1 to 80 characters."),Kd=lt().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 yk(e){return Gn.meta({description:e,[_l]:!0})}const vk=Hn(["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."),wk=Hn(["over_limit","inactive","host"]).describe("Why a hosted community is on hold: the account holds more than its allowance covers, nobody has posted in a long time, or the host placed the hold itself."),jk=me({title:lt().min(1).max(120).describe("A short summary, safe to show a person."),detail:lt().max(2e3).describe("The explanation, safe to show a person."),actionUrl:px.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:lt().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."),kk=me({allowed:Bt().describe("The owner may choose this community as one to keep open."),wouldHold:Wn(rt).describe("The caller`s other communities that keeping this one would put on hold.")}).describe("Whether the owner may keep this community open, and which others it would hold."),$o=me({communityId:rt.describe("The community`s permanent identifier on its Community server. Never changes, even across a rename."),orgId:rt.describe("The organization whose account this community belongs to."),name:lt().min(1).max(80).describe("The community`s display name."),shortName:bn.nullable().describe("The community`s current short name, or null when it has none."),communityUrl:Gn.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:ys(vk).describe("Where the community is in its lifecycle. A state this release does not know reads as unrecognised."),hold:me({reason:ys(wk).describe("Why the community is on hold. A reason this release does not know reads as unrecognised."),since:St,deletionNoticeAt:St.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:St.nullable().describe("When the Community server will delete the community for good. Always set when the state is deletion_pending."),notice:jk.nullable().describe("What the service wants the owner to read about this community, or null when there is nothing."),kept:Bt().describe("True when the owner chose this community to stay open while the account holds more communities than its allowance covers."),moveId:rt.nullable().describe("The move filling this community from an owner export, while that move is unfinished. Null otherwise. Lets the app pick up a move after a restart."),limits:me({maxActiveMembers:be().int().positive().nullable().describe("The most people who may be active members at once. Null means no limit."),maxStorageBytes:be().int().nonnegative().nullable().describe("The most bytes of files the community may store. Null means no per-community limit.")}).describe("The limits the host enforces on this community. Agents and history never count."),usage:me({activeMembers:be().int().nonnegative(),storageBytes:be().int().nonnegative().describe("The bytes that count against the storage limit. Owner exports never count."),measuredAt:St}).nullable().describe("The community`s last measured usage, or null before the first measurement."),actions:me({claimLink:Bt().describe("The service will issue a fresh owner-claim link for this community."),keep:kk,restore:Bt().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:St}).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.");Ml($o,"A page of the communities the caller has hosted.");me({name:bn}).describe("The short name to check.");const Sk=Hn(["taken","reserved"]).describe("Why a short name cannot be used: another community has it, or the host reserves it.");me({name:bn,available:Bt(),reason:Sk.nullable().describe("Why the name cannot be used. Null exactly when it is available.")}).superRefine((e,t)=>{e.available!==(e.reason===null)&&t.addIssue({code:"custom",path:["reason"],message:"reason is null exactly when the name is available"})}).describe("Whether a short name is free right now. Advisory; starting a community checks again.");me({idempotencyKey:Kd,name:Ud,shortName:bn.optional().describe("The short name to give the community. Omitted means none."),orgId:rt.optional().describe("The organization whose account the community belongs to. Omitted means the caller`s personal one.")}).describe("Start a hosted community. Idempotent on the caller`s key.");const Ck=me({communityId:rt,claimUrl:yk("The owner-claim link. A single-use credential: open it in the person`s own browser and never log it."),expiresAt:St.describe("When the link stops working.")}).describe("A one-time link that makes a person the owner of a new community. Returned once.");me({community:$o,claim:Ck.nullable().describe("The owner-claim link, or null when this answer repeats an earlier request or the community is still provisioning."),replayed:Bt().describe("True when this answer repeats an earlier request with the same key.")}).superRefine((e,t)=>{e.claim!==null&&(e.replayed||e.community.state!=="pending_owner")&&t.addIssue({code:"custom",path:["claim"],message:"a claim link comes only on the first answer, for a pending_owner community"})}).describe("The started community and, the first time only, its owner-claim link.");me({expectedHeldCommunityIds:Wn(rt).describe("The communities the owner was told this choice would hold, in any order.")}).describe("Keep this community open, confirming which others the owner agreed to hold.");me({community:$o,heldCommunityIds:Wn(rt).describe("Other communities of the caller`s that this choice put on hold. Often empty.")}).describe("The kept community, and every other community the choice put on hold.");const Nk=Hn(["awaiting_upload","importing","ready","failed","cancelled","claimed"]).describe("Where a move is: waiting for the export, importing it, ready to claim, or finished."),Ak=Hn(["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."),Ek=me({channels:be().int().nonnegative(),entries:be().int().nonnegative().describe("Messages and replies."),attachments:be().int().nonnegative(),historicalMembers:be().int().nonnegative().describe("People whose messages move. They join again by invitation."),historicalAgents:be().int().nonnegative().describe("Agents whose messages move. Their owners pair them again."),attachmentBytes:be().int().nonnegative(),countedBytes:be().int().nonnegative().describe("The bytes that will count against the community`s storage limit.")}).describe("What an owner export holds, in counts and sizes only."),Hd=me({moveId:rt,communityId:rt.describe("The new community the export fills. It no longer exists once a move has failed or been cancelled."),communityUrl:Gn.describe("The new community`s canonical link. A runtime value."),name:lt().min(1).max(80).describe("The name the new community was given."),state:ys(Nk).describe("Where the move is. A state this release does not know reads as unrecognised."),failureCode:ys(Ak).nullable().describe("Why the move failed. Always set when the state is failed. A code this release does not know reads as unrecognised."),report:Ek.nullable().describe("What the export holds, once it has been read. Null before then."),pollAfterMs:be().int().nonnegative().nullable().describe("How long to wait before reading the move again. Null once it has finished."),updatedAt:St}).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.");Ml(Hd,"A page of the caller`s moves: every unfinished one, and those that finished within the last 7 days, newest first.");me({idempotencyKey:Kd,name:Ud,shortName:bn.optional().describe("The short name to give the new community. Omitted means none."),orgId:rt.optional().describe("The organization whose account the community belongs to. Omitted means the caller`s personal one."),archiveBytes:be().int().positive().describe("The size of the export file, in bytes."),archiveSha256:lt().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 Ik=me({url:Gn.describe("Where to send the export. A runtime value."),token:gx.meta({description:"The upload bearer credential. Returned once; never log it.",[_l]:!0}),expiresAt:St.describe("When the upload window closes."),maxBytes:be().int().positive().describe("The largest file the upload accepts."),parts:me({partBytes:be().int().positive().describe("The largest part the upload accepts."),maxBytes:be().int().positive().describe("The largest file a parted upload accepts.")}).optional().describe("Present when the Community server accepts the file in parts.")}).describe("Where and how to send the export file. The token is returned once."),Wd=lt().regex(/^[a-f0-9]{64}$/,"must be a lower-case hex SHA-256 digest"),Bo=1e4,Rk=me({partNumber:be().int().positive().max(Bo).describe("The number of the part, counting up from one."),byteSize:be().int().positive().describe("The size of the part, in bytes."),sha256:Wd.describe("The SHA-256 of the part, as lower-case hex.")}).describe("One part the Community server has received.");me({parts:Wn(Rk).max(Bo).describe("The parts received, in part order."),maxPartBytes:be().int().positive().describe("The largest part the upload accepts."),maxArchiveBytes:be().int().positive().describe("The largest file a parted upload accepts.")}).describe("The parts of a parted upload received so far.");me({parts:be().int().positive().max(Bo).describe("How many parts make up the file."),archiveBytes:be().int().positive().describe("The size of the whole file, in bytes."),archiveSha256:Wd.describe("The SHA-256 of the whole file, as lower-case hex.")}).describe("Put the uploaded parts together into the declared file.");me({move:Hd,upload:Ik.nullable().describe("Where to send the export, or null when this answer repeats an earlier request."),replayed:Bt().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 Tk=Gn.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."),Dk=me({origin:Tk}).describe("A Community server whose single sign-on is this account.");me({servers:Wn(Dk).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 Gd(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 Ok(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 Mk(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 ir(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 Ln(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 qd(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 Yd="Lower-case letters, numbers and single hyphens. 3 to 32 characters, starting with a letter.";function Yn(e){const t=e.trim().toLowerCase();return t===""?{value:t,valid:!0}:{value:t,valid:bn.safeParse(t).success}}const _k=80,Vd="That web address is taken.",Qd="That web address can’t be used.";function Xd(e){const t=ae(),{value:s,valid:r}=Yn(e),[o,a]=u.useState(s);u.useEffect(()=>{const d=setTimeout(()=>a(s),400);return()=>clearTimeout(d)},[s]);const i=Ee({queryKey:it.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 Pk(){const e=u.useRef(null);return t=>{var r;const s=JSON.stringify(t);return((r=e.current)==null?void 0:r.body)!==s&&(e.current={body:s,key:crypto.randomUUID()}),e.current.key}}function Lk(){const e=ae(),t=le(),s=Pk(),[r,o]=u.useState(!1),[a,i]=u.useState({field:null,notice:null});async function c(d){const l={name:d.name.trim(),...d.shortName?{shortName:d.shortName}:{}};o(!0),i({field:null,notice:null});try{const m=await e.startHostedCommunity({...l,idempotencyKey:s(l)});return m.ok?(t.invalidateQueries({queryKey:it.list()}),{community:m.community}):("problem"in m&&m.problem.code==="community_name_taken"?i({field:Vd,notice:null}):"problem"in m&&m.problem.code==="community_name_reserved"?i({field:Qd,notice:null}):i({field:null,notice:zt(m)}),null)}catch{return i({field:null,notice:Ut}),null}finally{o(!1)}}return{submitting:r,failure:a,clearFieldFailure:()=>i(d=>({...d,field:null})),submit:c}}function Fk(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 $k(e){return e.state==="awaiting_upload"||e.state==="importing"||e.state==="ready"}function Bk(e){var I;const t=ae(),s=le(),[r,o]=u.useState(e),[a,i]=u.useState(null),[c,d]=u.useState({field:null,notice:null}),[l,m]=u.useState(!1),h=u.useRef(null),p=u.useRef(null),f=Ee({queryKey:it.move(r??""),queryFn:()=>t.getHostedCommunityMove(r),enabled:r!==null,refetchInterval:v=>{var R;const E=v.state.data;return(E==null?void 0:E.available)!==!0?!1:((R=E.move.upload)==null?void 0:R.state)==="sending"?1e3:E.move.pollAfterMs===null?!1:Math.max(1e3,E.move.pollAfterMs)}}),g=((I=f.data)==null?void 0:I.available)===!0?f.data.move:null,x=g?Fk(g):null,y=u.useCallback(v=>{s.setQueryData(it.move(v.moveId),{available:!0,move:v})},[s]);async function b(v){var _;const E={name:v.name.trim(),...v.shortName?{shortName:v.shortName}:{},file:[v.file.name,v.file.size,v.file.lastModified]},R=JSON.stringify(E);((_=p.current)==null?void 0:_.body)!==R&&(p.current={body:R,key:crypto.randomUUID()});const M=p.current.key,O=new AbortController;h.current=O,d({field:null,notice:null}),i({loaded:0,total:v.file.size});try{const D=await t.checkHostedCommunityMoveRoom(v.file.size,O.signal);if(O.signal.aborted)return;const k=D.ok?await t.startHostedCommunityMove(v.file,{idempotencyKey:M,name:E.name,...v.shortName?{shortName:v.shortName}:{}},j=>i(j),O.signal):D;(k.ok||k.mayExist!==!0)&&(p.current=null),k.ok?(y(k.move),o(k.move.moveId),s.invalidateQueries({queryKey:it.list()})):"problem"in k&&k.problem.code==="community_name_taken"?d({field:Vd,notice:null}):"problem"in k&&k.problem.code==="community_name_reserved"?d({field:Qd,notice:null}):d({field:null,notice:zt(k)})}catch{O.signal.aborted?p.current=null:d({field:null,notice:Ut})}finally{h.current=null,i(null)}}async function C(){if(h.current){h.current.abort();return}if(r){m(!0);try{const v=await t.cancelHostedCommunityMove(r);v.ok?y(v.move):d({field:null,notice:zt(v)}),s.invalidateQueries({queryKey:it.list()})}catch{d({field:null,notice:Ut})}finally{m(!1)}}}async function S(){if(r){m(!0),d({field:null,notice:null});try{const v=await t.retryHostedCommunityMoveUpload(r);v.ok?y(v.move):d({field:null,notice:zt(v)})}catch{d({field:null,notice:Ut})}finally{m(!1)}}}return{step:x,sending:a,failure:c,clearFieldFailure:()=>d(v=>({...v,field:null})),busy:l,start:b,cancel:C,sendAgain:S,startOver:()=>{o(null),d({field:null,notice:null})}}}function zk(){var a,i,c;const e=mc(),t=xx(),s=Pl(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($k))==null?void 0:c.moveId)??null}}const Uk={message:"Your spaces changed. Check the list again."};function Kk(){const e=ae(),t=le(),[s,r]=u.useState(null),[o,a]=u.useState(null),[i,c]=u.useState({});function d(m,h){c(p=>{const f={...p};return h?f[m]=h:delete f[m],f})}async function l(m,h){a(m),d(m,null);try{d(m,await h())}catch{d(m,Ut)}finally{a(null),await t.invalidateQueries({queryKey:it.list()})}}return{confirmingKeep:s,busyId:o,notices:i,askKeep:r,cancelKeep:()=>r(null),keep:m=>l(m.communityId,async()=>{r(null);const h=await e.keepHostedCommunity(m.communityId,m.actions.keep.wouldHold);return h.ok?null:"problem"in h&&h.problem.code==="conflict"?Uk:zt(h)}),restore:m=>l(m.communityId,async()=>{const h=await e.restoreHostedCommunity(m.communityId);return h.ok?null:zt(h)})}}function zo({open:e,onOpenChange:t,step:s,locked:r}){return n.jsx(bt,{open:e,onOpenChange:o=>r&&!o?void 0:t(o),children:n.jsxs(yt,{className:"!min-h-0 sm:max-w-lg",children:[n.jsxs(ft,{children:[n.jsx(st,{children:s.title}),s.description!==void 0&&n.jsx(pt,{children:s.description})]}),s.body!==void 0&&n.jsx(At,{className:"space-y-4 py-2",children:s.body}),n.jsx(rn,{className:"gap-2 sm:gap-2",children:s.actions})]})})}function Yt({notice:e}){if("message"in e)return n.jsx("p",{role:"alert",className:"text-destructive text-sm",children:e.message});const{title:t,detail:s,actionUrl:r,actionLabel:o}=e.problem;return n.jsxs("div",{role:"alert",className:"border-status-warning-border bg-status-warning-bg text-status-warning-fg space-y-2 rounded-md border p-3 text-sm",children:[n.jsx("p",{className:"font-medium break-words",children:t}),s&&n.jsx("p",{className:"break-words",children:s}),r&&n.jsxs(L,{type:"button",size:"sm",variant:"outline",onClick:()=>Et(r),children:[o??"Open your account",n.jsx(on,{className:"size-3.5","aria-hidden":!0})]})]})}function Uo(e){const{state:t,name:s}=e;switch(t.kind){case"preparing":return{title:`Setting up ${s}`,description:"Keep this open, or come back later.",body:n.jsxs("p",{role:"status",className:"text-muted-foreground flex items-center gap-2 text-sm",children:[n.jsx(Oe,{className:"size-4"})," Setting up…"]}),actions:n.jsx(L,{variant:"outline",onClick:e.onClose,children:"Close"})};case"claim":return{title:`Make ${s} yours`,description:t.withAccount?"Sign in with your DorkOS account in your browser, then come back.":"Sign in or create an account in your browser, then come back.",body:t.notice?n.jsx(Yt,{notice:t.notice}):void 0,actions:n.jsxs(n.Fragment,{children:[n.jsxs(L,{variant:t.opened?"outline":"default",disabled:t.busy,onClick:e.onOpenClaim,children:[t.opened?"Open it again":"Open in your browser",n.jsx(on,{className:"size-3.5","aria-hidden":!0})]}),n.jsx(L,{variant:t.opened?"default":"outline",disabled:t.busy,onClick:e.onConfirmClaimed,children:t.busy?"Checking…":"I’ve finished"})]})};case"connecting":return{title:`Connect this DorkOS to ${s}`,description:t.approvalUrl?`Approve this DorkOS on ${s}. This page then moves on.`:"Getting the approval page ready…",body:n.jsxs(n.Fragment,{children:[t.approvalUrl&&!t.notice&&n.jsxs("p",{role:"status",className:"text-muted-foreground flex items-center gap-2 text-sm",children:[n.jsx(Oe,{className:"size-4"})," Waiting for your approval"]}),t.notice&&n.jsx(Yt,{notice:t.notice})]}),actions:t.notice?n.jsx(L,{disabled:t.busy,onClick:e.onRetryConnect,children:"Connect again"}):n.jsxs(L,{disabled:t.busy||!t.approvalUrl,onClick:e.onOpenApproval,children:["Open approval page",n.jsx(on,{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(As,{className:"text-status-success-fg size-4","aria-hidden":!0}),"It’s selected in your spaces."]}),actions:n.jsx(L,{onClick:e.onClose,children:"Done"})}}}function Hk(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=`${Ln(t.storageBytes)}${r!==null?` of ${Ln(r)}`:""} of files`;return`${o} · ${a}`}function Wk({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=Hk(e),l=e.actions.keep.wouldHold.map(h=>t.get(h)??"another space"),m=e.state==="held"||e.state==="deletion_pending"||e.state==="suspended";return n.jsxs("li",{className:"space-y-2 rounded-lg border p-3",children:[n.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-2",children:[n.jsxs("div",{className:"min-w-0",children:[n.jsx("p",{className:"truncate text-sm font-medium",children:e.name}),e.shortName&&n.jsx("p",{className:"text-muted-foreground truncate font-mono text-xs",children:e.shortName})]}),n.jsx(Dn,{variant:m?"outline":"secondary",className:m?"border-status-warning-border text-status-warning-fg shrink-0":"shrink-0",children:Ok(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:Mk(e.hold.reason)}),n.jsxs("p",{className:"text-muted-foreground",children:["On hold since ",ir(e.hold.since),"."]}),e.hold.deletionNoticeAt&&n.jsxs("p",{className:"text-destructive",children:["DorkOS may delete it after ",ir(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 ",ir(e.deletionAt),"."]}),e.notice&&n.jsxs("div",{className:"bg-muted/50 space-y-1 rounded-md p-2 text-sm",children:[n.jsx("p",{className:"font-medium break-words",children:e.notice.title}),e.notice.detail&&n.jsx("p",{className:"break-words",children:e.notice.detail}),e.notice.actionUrl&&n.jsxs(L,{size:"sm",variant:"outline",onClick:()=>Et(e.notice.actionUrl),children:[e.notice.actionLabel??"Learn more",n.jsx(on,{className:"size-3.5","aria-hidden":!0})]})]}),d&&n.jsx("p",{className:"text-muted-foreground text-xs tabular-nums",children:d}),i&&n.jsxs("div",{role:"group","aria-label":`Keep ${e.name} open`,className:"space-y-2 text-sm",children:[n.jsx("p",{children:l.length===0?`Keep ${e.name} open? Nothing else changes.`:`Keeping ${e.name} open puts ${l.length===1?"this one":"these"} on hold: ${l.join(", ")}. People can still read ${l.length===1?"it":"them"}.`}),n.jsxs("div",{className:"flex flex-wrap gap-2",children:[n.jsx(L,{size:"sm",variant:"outline",onClick:s.cancelKeep,children:"Cancel"}),n.jsx(L,{size:"sm",disabled:a,onClick:()=>void s.keep(e),children:"Keep it open"})]})]}),c&&n.jsx(Yt,{notice:c}),!i&&n.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.actions.claimLink&&n.jsx(L,{size:"sm",onClick:()=>r(e),children:"Finish setting up"}),e.moveId&&n.jsx(L,{size:"sm",variant:"outline",onClick:()=>o(e.moveId),children:"See the move"}),e.actions.keep.allowed&&n.jsx(L,{size:"sm",variant:"outline",disabled:a,onClick:()=>s.askKeep(e.communityId),children:"Keep this one open"}),e.actions.restore&&n.jsx(L,{size:"sm",variant:"outline",disabled:a,onClick:()=>void s.restore(e),children:a?"Reopening…":"Reopen"})]})]})}function Gk(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=Gd(e.failureCode??"unrecognised");return{text:t.title,next:t.next}}default:return{text:"Unknown state. Update DorkOS to see more."}}}function qk(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(Wk,{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=Gk(s),o=s.state==="awaiting_upload"||s.state==="importing"||s.state==="ready";return n.jsxs("li",{className:"flex flex-wrap items-start justify-between gap-2 rounded-lg border p-3",children:[n.jsxs("div",{className:"min-w-0 space-y-0.5 text-sm",children:[n.jsx("p",{className:"truncate font-medium",children:s.name}),n.jsx("p",{className:s.state==="failed"?"text-destructive":"text-muted-foreground",children:r.text}),r.next&&n.jsx("p",{className:"text-muted-foreground",children:r.next})]}),o&&n.jsx(L,{size:"sm",variant:"outline",onClick:()=>e.onOpenMove(s.moveId),children:"Continue"})]},s.moveId)})})]})]})}function Yk(e){return e.open?n.jsx(Vk,{...e}):null}function Vk({open:e,onOpenChange:t,installName:s,onOpenMove:r,onMoveHere:o,onConnected:a}){var f;const i=Pl(!0),c=Kk(),[d,l]=u.useState(null),m=Fo(d,s,a),h=()=>t(!1);let p;if(d)p=Uo({state:m.state,name:d.name,doneDetail:"Invite people from the space’s own settings when you’re ready.",onOpenClaim:m.openClaim,onConfirmClaimed:m.confirmClaimed,onOpenApproval:m.openApproval,onRetryConnect:m.retryConnect,onClose:h});else{const g=((f=i.data)==null?void 0:f.available)===!0?i.data:null;p={title:"Your spaces",description:"Spaces hosted under your DorkOS account.",body:i.isPending?n.jsx("p",{className:"text-muted-foreground text-sm",children:"Loading…"}):g?n.jsx(qk,{communities:g.communities,moves:g.moves,allowanceText:qd(g.allowance),actions:c,onFinishSetup:l,onOpenMove:x=>{h(),r(x)}}):n.jsx(Yt,{notice:{message:"Couldn’t reach your DorkOS account. Try again."}}),actions:n.jsxs(n.Fragment,{children:[n.jsx(L,{variant:"outline",onClick:h,children:"Close"}),n.jsx(L,{variant:"outline",onClick:()=>{h(),o()},children:"Move one here"})]})}}return n.jsx(zo,{open:e,onOpenChange:t,step:p})}function Qk(e){switch(e.kind){case"invalid":return{text:Yd,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 Jd(e){const t=u.useId(),s=e.webAddressError?{text:e.webAddressError,error:!0}:Qk(e.webAddressStatus);return n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{className:"space-y-1.5",children:[n.jsx(He,{htmlFor:`${t}-name`,children:"Space name"}),n.jsx(xt,{id:`${t}-name`,required:!0,maxLength:_k,autoComplete:"off",value:e.name,disabled:e.disabled,onChange:r=>e.onNameChange(r.target.value)})]}),n.jsxs("div",{className:"space-y-1.5",children:[n.jsxs(He,{htmlFor:`${t}-address`,children:["Web address ",n.jsx("span",{className:"text-muted-foreground font-normal",children:"(optional)"})]}),n.jsx(xt,{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)??Yd})]})]})}const Xk="Your history is here. Send invitations so people can join again.";function Jk(e,t){return{title:"Move a space here",description:"This copies your space’s history and files to DorkOS.",body:n.jsxs("div",{className:"space-y-2 text-sm",children:[n.jsx("p",{children:"Everyone joins again and reconnects their DorkOS."}),n.jsx("p",{className:"text-muted-foreground",children:"Your old space keeps running until you delete it."}),n.jsx("p",{className:"font-medium",children:"First, export the old space:"}),n.jsxs("ol",{className:"text-muted-foreground list-decimal space-y-1 pl-5",children:[n.jsx("li",{children:"Sign in to the old space as its owner."}),n.jsx("li",{children:"Open its Settings."}),n.jsx("li",{children:"Choose Export."}),n.jsx("li",{children:"Enter your password."}),n.jsx("li",{children:"Save the .zip file."})]})]}),actions:n.jsxs(n.Fragment,{children:[n.jsx(L,{variant:"outline",onClick:t,children:"Cancel"}),n.jsx(L,{onClick:e,children:"I have the file"})]})}}function Zk({file:e,onFileChange:t}){const s=u.useId();return n.jsxs("div",{className:"space-y-1.5",children:[n.jsx(He,{htmlFor:s,children:"Export file"}),n.jsx(xt,{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,", ",Ln(e.size)]})]})}function eS(e){const t=Yn(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(Zk,{file:e.file,onFileChange:e.onFileChange}),n.jsx(Jd,{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(Yt,{notice:e.failure.notice}),n.jsx(Eo,{})]}),actions:n.jsxs(n.Fragment,{children:[n.jsx(L,{type:"button",variant:"outline",onClick:e.onBack,children:"Back"}),n.jsx(L,{type:"submit",form:e.formId,disabled:s,children:"Start moving"})]})}}function Zd({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(wb,{value:r,"aria-label":e}),n.jsxs("p",{className:"text-muted-foreground text-sm tabular-nums",children:[Ln(t)," of ",Ln(s)]})]})}function tS(e,t){return{title:"Getting the file ready",description:"Keep this open. The upload then starts on its own.",body:n.jsx(Zd,{label:"Getting the file ready",...e}),actions:n.jsx(L,{variant:"outline",onClick:t,children:"Cancel"})}}function nS(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 sS(e,t){const{move:s}=e,r=t.notice?n.jsx(Yt,{notice:t.notice}):null,o=n.jsx(L,{variant:"outline",disabled:t.busy,onClick:t.onCancelMove,children:"Cancel move"}),a=n.jsx(L,{onClick:t.onStartOver,children:"Start again"}),i=n.jsx(L,{variant:"outline",onClick:t.onClose,children:"Close"});switch(e.kind){case"uploading":{const c=s.upload;return{title:`Uploading ${s.name}`,description:"You can close this window. Keep DorkOS running until it finishes.",body:n.jsxs(n.Fragment,{children:[n.jsx(Zd,{label:`Uploading ${s.name}`,loaded:c.sentBytes,total:c.totalBytes}),r]}),actions:o}}case"upload-failed":return e.why==="interrupted"?{title:"The upload didn’t finish",description:"DorkOS still has the file. Send it again to continue.",body:r,actions:n.jsxs(n.Fragment,{children:[o,n.jsx(L,{disabled:t.busy,onClick:t.onSendAgain,children:"Send again"})]})}:e.why==="refused"?{title:"DorkOS didn’t accept the file",description:"The file arrived changed or incomplete.",body:n.jsxs(n.Fragment,{children:[n.jsx("p",{className:"text-muted-foreground text-sm",children:"Cancel the move, export the old space again, then start again."}),r]}),actions:o}:e.why==="restarted"?{title:"This move has to start again",description:"DorkOS restarted, or the move began on another computer.",body:n.jsxs(n.Fragment,{children:[n.jsx("p",{className:"text-muted-foreground text-sm",children:"Cancel the move and start again with the same export."}),n.jsx("p",{className:"text-muted-foreground text-sm",children:"Or finish it on the computer that started it."}),n.jsx("p",{className:"text-muted-foreground text-sm",children:"For safety, uploads only work while DorkOS stays running."}),r]}),actions:o}:{title:"The time to upload ran out",description:"Cancel the move, then start again with the same export.",body:r,actions:o};case"importing":{const c=nS(s);return{title:`Moving ${s.name}`,description:"You can close this window or quit. The move keeps going.",body:n.jsxs(n.Fragment,{children:[n.jsxs("p",{role:"status",className:"text-muted-foreground flex items-center gap-2 text-sm",children:[n.jsx(Oe,{className:"size-4"})," Moving your history…"]}),c&&n.jsx("p",{className:"text-sm",children:c}),r]}),actions:n.jsxs(n.Fragment,{children:[o,n.jsx(L,{onClick:t.onClose,children:"Close"})]})}}case"failed":{const c=Gd(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 rS(e){return e.open?n.jsx(oS,{...e}):null}function oS({open:e,onOpenChange:t,installName:s,resumeMoveId:r,onConnected:o}){var I,v;const[a,i]=u.useState("explain"),[c,d]=u.useState(null),[l,m]=u.useState(""),[h,p]=u.useState(""),f=Bk(r),g=Xd(a==="choose"&&!f.step?h:""),x=((I=f.step)==null?void 0:I.kind)==="ready"?f.step.move:null,y=Fo(x?{communityId:x.communityId,name:x.name,communityUrl:x.communityUrl}:null,s,o),b=()=>t(!1);function C(E){E.preventDefault();const R=Yn(h);!c||l.trim()===""||!R.valid||f.start({file:c,name:l,shortName:R.value})}let S;return f.sending?S=tS(f.sending,()=>void f.cancel()):((v=f.step)==null?void 0:v.kind)==="ready"?S=Uo({state:y.state,name:f.step.move.name,doneDetail:Xk,onOpenClaim:y.openClaim,onConfirmClaimed:y.confirmClaimed,onOpenApproval:y.openApproval,onRetryConnect:y.retryConnect,onClose:b}):f.step?S=sS(f.step,{busy:f.busy,notice:f.failure.notice,onCancelMove:()=>void f.cancel(),onSendAgain:()=>void f.sendAgain(),onStartOver:()=>{f.startOver(),i("choose")},onClose:b}):a==="explain"?S=Jk(()=>i("choose"),b):S=eS({file:c,onFileChange:d,name:l,onNameChange:m,webAddress:h,onWebAddressChange:E=>{p(E),f.clearFieldFailure()},webAddressStatus:g,failure:f.failure,formId:"move-community-form",onSubmit:C,onBack:()=>i("explain")}),n.jsx(zo,{open:e,onOpenChange:t,step:S,locked:f.sending!==null})}function aS(e){const t=Yn(e.webAddress),s=e.name.trim()===""||!t.valid||e.webAddressStatus.kind==="taken"||e.webAddressStatus.kind==="reserved",r=qd(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(Jd,{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(Yt,{notice:e.failure.notice}),n.jsx(Eo,{})]}),actions:n.jsxs(n.Fragment,{children:[n.jsx(L,{type:"button",variant:"outline",onClick:e.onCancel,children:"Cancel"}),n.jsx(L,{type:"submit",form:e.formId,disabled:s||e.submitting,children:e.submitting?"Starting…":"Start space"})]})}}function iS(e){return e.open?n.jsx(cS,{...e}):null}function cS({open:e,onOpenChange:t,installName:s,allowance:r,onConnected:o}){const[a,i]=u.useState(""),[c,d]=u.useState(""),[l,m]=u.useState(null),h=Lk(),p=Xd(l?"":c),f=Fo(l,s,o),g=()=>t(!1);async function x(b){b.preventDefault();const C=Yn(c);if(a.trim()===""||!C.valid||h.submitting)return;const S=await h.submit({name:a,shortName:C.value});S&&m({communityId:S.community.communityId,name:S.community.name,communityUrl:S.community.communityUrl})}const y=l?Uo({state:f.state,name:l.name,doneDetail:"Invite people from the space’s own settings when you’re ready.",onOpenClaim:f.openClaim,onConfirmClaimed:f.confirmClaimed,onOpenApproval:f.openApproval,onRetryConnect:f.retryConnect,onClose:g}):aS({name:a,webAddress:c,onNameChange:i,onWebAddressChange:b=>{d(b),h.clearFieldFailure()},webAddressStatus:p,submitting:h.submitting,failure:h.failure,allowance:r,formId:"start-community-form",onSubmit:b=>void x(b),onCancel:g});return n.jsx(zo,{open:e,onOpenChange:t,step:y,locked:h.submitting})}function lS({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(iS,{open:(t==null?void 0:t.kind)==="start",onOpenChange:a,installName:r,allowance:e.allowance,onConnected:o}),n.jsx(rS,{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(Yk,{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 dS=.1;function uS(e){if(!(e!=null&&e.available)||e.balance===null)return null;const{allowance:t,purchased:s,denomination:r}=e.balance,o=bx(t.remainingMicro,t.grantedMicro);if(o===null||o>=dS||!/^\d+$/.test(t.remainingMicro)||!/^\d+$/.test(s.remainingMicro)||BigInt(s.remainingMicro)>0n)return null;const a=yx(vx(t.remainingMicro,r));return a===null?null:`${a} left`}function mS(e){if(e.state!=="loading")return e.state==="signed-out"?"Not signed in":["Signed in",e.label,e.lowCredits].filter(Boolean).join(" · ")}function hS(){var r;const e=Bc(),t=((r=e.data)==null?void 0:r.linked)===!0,s=zc({enabled:t});return e.data===void 0?{state:"loading"}:t?{state:"signed-in",label:e.data.accountLabel,lowCredits:uS(s.data)}:{state:"signed-out"}}function fS(){const e=le();fe("commands_changed",()=>{e.invalidateQueries({queryKey:["commands"]})})}function eu(e){return e.kind==="agent"?Gt("agent",e.agent.projectPath):Gt("room",e.room.id)}function Pr(e){return e.kind==="agent"?Le(e.agent):e.room.kind==="channel"&&e.room.slug?`#${e.room.slug}`:e.room.title}function ti(e){return`Chats ${e.kind==="agent"?"with":"in"} ${Pr(e)}`}function pS(e){return e.kind==="agent"?`No chats with ${Pr(e)} yet.`:`No chats came from ${Pr(e)}.`}function gS(e){return e.kind==="channel"&&e.slug?`#${e.slug}`:e.title}function xS(e){const t=new Map,s=[...e].sort((r,o)=>{const a=+(r.kind==="dm")-+(o.kind==="dm");return a!==0?a:Number(r.archived)-Number(o.archived)});for(const r of s){const o=gS(r);t.has(o)||t.set(o,r.id)}return t}function bS(e,t){const s=[];e.cwd!==null&&s.push(Gt("agent",e.cwd));const r=yS(e,t);return r!==void 0&&s.push(Gt("room",r)),s}function yS(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 vS(e,t){const s=Number(e.archived)-Number(t.archived);if(s!==0)return s;const r=Number(Mn(t))-Number(Mn(e));return r!==0?r:t.lastActivityAt.localeCompare(e.lastActivityAt)||t.id.localeCompare(e.id)}function cr(e){return[...e].sort(vS)}function Lr(e){const t=[e.title];e.slug&&t.push(e.slug);for(const s of e.participants??[])t.push(s.displayName);return t}function wS(){const{data:e,isLoading:t,isError:s}=Ls({includeArchived:!0});return u.useMemo(()=>{const r=e??[],o=cr(r.filter(i=>i.kind==="channel")),a=cr(r.filter(i=>i.kind==="dm"));return{channels:o,dms:a,unread:cr([...o,...a].filter(i=>!i.archived&&Mn(i))),isLoading:t,isError:s}},[e,t,s])}const jS=8;function kS(e,t){const s=new Set(Ch(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 ni(e){const t=Date.parse(e.lastActivityAt);return Number.isNaN(t)?Number.NEGATIVE_INFINITY:t}function SS(e){return!(e.unreadCount===null||e.archived||e.lastActivityAt===e.createdAt)}function CS({sessions:e,rooms:t,unreadRoomIds:s,agents:r,agentActivity:o,excludeSessionIds:a=new Set,limit:i=jS}){const c=e.filter(g=>!a.has(g.id)).map(g=>({kind:"session",key:`session:${g.id}`,lastActivityAt:g.lastActivityAt,session:g})),d=new Set(e.flatMap(g=>g.cwd?[g.cwd]:[])),l=t.filter(SS).map(g=>({kind:"room",key:`room:${g.id}`,lastActivityAt:g.lastActivityAt,room:g})),m=r.flatMap(g=>{if(d.has(g.projectPath))return[];const x=o[g.projectPath];return x?[{kind:"agent",key:`agent:${g.projectPath}`,lastActivityAt:x,agent:g}]:[]}),h=[],p=[];for(const g of[...c,...l,...m])g.kind==="room"&&s.has(g.room.id)?h.push(g):p.push(g);const f=(g,x)=>ni(x)-ni(g)||x.key.localeCompare(g.key);return[...h.sort(f),...p.sort(f)].slice(0,i)}const NS=50;function tu(e){const t=[e.id];return e.who&&t.push(e.who),e.cwd&&t.push(e.cwd),t}function AS(e){return e?e.split("/").filter(Boolean).pop()??null:null}function si(e,t,s){const r=new Map(t.map(o=>[o.projectPath,o]));return e.map(o=>{const a=o.cwd??null,i=a?r.get(a)??null:null,c=Date.parse(o.updatedAt);return{id:o.id,who:i?Le(i):AS(a),title:Uc(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 ES(e,t,s,r){const{data:o}=Kc(NS),a=Nt(p=>p.statuses),i=Nt(Hc(p=>Object.values(p.sessions))),c=u.useMemo(()=>si((o==null?void 0:o.sessions)??[],e,r),[o==null?void 0:o.sessions,e,r]),d=u.useMemo(()=>si(i,e,r),[i,e,r]),l=u.useMemo(()=>[...i,...(o==null?void 0:o.sessions)??[]],[i,o]),m=u.useMemo(()=>{const p=new Map;for(const f of d)p.set(f.id,f);for(const f of c)p.has(f.id)||p.set(f.id,f);return kS(a,l).flatMap(f=>{const g=p.get(f.sessionId);return g?[{session:g,verb:Nh(f.lifecycle,f.activity),signal:f.lifecycle==="blocked"?"needs-you":"working"}]:[]})},[a,d,c,l]),h=u.useMemo(()=>{const p=new Set(Ah((o==null?void 0:o.sessions)??[]).yours.map(f=>f.id));return CS({sessions:c.filter(f=>p.has(f.id)),rooms:t,unreadRoomIds:s,agents:e,agentActivity:(o==null?void 0:o.agentActivity)??{},excludeSessionIds:new Set(m.map(f=>f.session.id))})},[o,c,t,s,e,m]);return{sessions:c,continueRows:m,recent:h,agentActivity:(o==null?void 0:o.agentActivity)??IS}}const IS=Object.freeze({});function RS(){const{data:e,dataUpdatedAt:t}=_e(),s=e!==void 0&&t>cn,{status:r,url:o}=Eh(e==null?void 0:e.tunnel),a=u.useRef(void 0);u.useEffect(()=>{if(!s)return;const i=a.current;a.current=r,!(i===void 0||i===r)&&(sa.getState().consumeSuppression()||Ih(sa.getState().report)||(r==="reconnecting"?ce.warning("Remote access is reconnecting",{id:"tunnel-status",description:"Your other devices can’t reach DorkOS until then."}):r==="off"?ce.error("Remote access turned off",{id:"tunnel-status",description:"Your other devices can’t reach DorkOS now."}):o&&ce.success("Remote access is on",{id:"tunnel-status",description:o})))},[s,r,o])}const ht={copyLink:"copyRemoteLink",showQr:"showRemoteQr",turnOn:"turnRemoteAccessOn",turnOff:"turnRemoteAccessOff"},kn={copyLink:11,showQr:12,turnOff:13,turnOn:11};function TS(e,t,s){return(e==="connected"||e==="reconnecting"||e==="asleep")&&t?[{id:"remote-access-copy",label:"Copy remote link",icon:"Copy",action:ht.copyLink,category:"quick-action",priority:kn.copyLink,keywords:["remote","tunnel","url","address","phone","share"]},{id:"remote-access-qr",label:"Show QR code",icon:"QrCode",action:ht.showQr,category:"quick-action",priority:kn.showQr,keywords:["remote","tunnel","scan","phone"]},{id:"remote-access-off",label:"Turn remote access off",icon:"Globe",action:ht.turnOff,category:"quick-action",priority:kn.turnOff,keywords:["remote","tunnel","ngrok","stop","disconnect"]}]:e==="asleep"||e==="blocked"?[{id:"remote-access-off",label:"Turn remote access off",icon:"Globe",action:ht.turnOff,category:"quick-action",priority:kn.turnOff,keywords:["remote","tunnel","ngrok","stop","disconnect"]}]:s&&(e==="off"||e==="error")?[{id:"remote-access-on",label:"Turn remote access on",icon:"Globe",action:ht.turnOn,category:"quick-action",priority:kn.turnOn,keywords:["remote","tunnel","ngrok","phone","start"]}]:[]}function DS(){const{state:e,url:t,isSetUp:s}=Wc();return u.useMemo(()=>TS(e,t,s),[e,t,s])}const OS=new Set(["discover","browse"]),Jn={usageKey:null,lastActivityAt:null,waiting:!1,demoted:!1,scopes:[]};function ri(e){return{usageKey:Gt("room",e.id),lastActivityAt:e.lastActivityAt,waiting:Mn(e),demoted:e.archived,scopes:[]}}const MS=[];function _S(e,t){const{data:s,isLoading:r}=Fs(),o=wS(),{sessions:a}=Gc(),i=u.useMemo(()=>!a||!e?null:Rh(a,e)[0]??null,[a,e]),{data:c}=ib(e,i==null?void 0:i.id,i==null?void 0:i.runtime),d=_s("command-palette.items"),l=lo(),m=u.useMemo(()=>l.map(k=>({id:k.id,label:k.title,href:jc(k.extensionId,k.path),icon:k.icon})),[l]),h=Ts(),p=u.useMemo(()=>{const k=new Set(Th(h).map(N=>N.id)),j=new Set(Dh.map(N=>N.id).filter(N=>!k.has(N)));return d.filter(N=>{if(N.category!=="feature")return!1;const w=qc(N.action);return w===null||!j.has(w)})},[d,h]),f=DS(),g=h?MS:f,x=u.useMemo(()=>[...d.filter(k=>k.category==="quick-action"&&!(h&&OS.has(k.id))),...g],[d,g,h]),y=u.useMemo(()=>Oh.flatMap(k=>{const j=x.find(N=>N.id===k);return j?[j]:[]}),[x]),b=u.useMemo(()=>(s==null?void 0:s.agents)??[],[s]),C=u.useMemo(()=>new Set(o.unread.map(k=>k.id)),[o.unread]),S=u.useMemo(()=>[...o.channels,...o.dms],[o.channels,o.dms]),I=u.useMemo(()=>Mh(t),[t]),{sessions:v,continueRows:E,recent:R,agentActivity:M}=ES(b,S,C,I),O=u.useMemo(()=>xS(S),[S]),_=u.useMemo(()=>c?c.commands.map(k=>({name:k.fullCommand,description:k.description})):[],[c]),D=u.useMemo(()=>{const k=[];for(const j of b)k.push({id:j.id,name:j.name,type:"agent",keywords:[j.projectPath,j.id],usageKey:Gt("agent",j.projectPath),lastActivityAt:M[j.projectPath]??null,waiting:!1,demoted:!1,scopes:[],data:j});for(const j of v)k.push({id:j.id,name:j.title,type:"session",keywords:tu(j),usageKey:Gt("session",j.id),lastActivityAt:j.lastActivityAt,waiting:!1,demoted:!1,scopes:bS(j,O),data:j});for(const j of p)k.push({id:j.id,name:j.label,type:"feature",keywords:j.keywords,...Jn,data:j});for(const j of _)k.push({id:`cmd-${j.name}`,name:j.name,type:"command",keywords:j.description?[j.description]:void 0,...Jn,data:j});for(const j of x)k.push({id:j.id,name:j.label,type:"quick-action",keywords:j.keywords,...Jn,data:j});for(const j of o.channels)k.push({id:j.id,name:_h(j),type:"room",keywords:Lr(j),...ri(j),data:j});for(const j of o.dms)k.push({id:j.id,name:j.title,type:"dm",keywords:Lr(j),...ri(j),data:j});for(const j of m)k.push({id:j.id,name:j.label,type:"page",keywords:["add-on","extension"],...Jn,data:j});return k},[b,M,v,_,p,x,o.channels,o.dms,O,m]);return{allAgents:b,newActions:y,rooms:o,sessions:v,continueRows:E,recent:R,searchableItems:D,isLoading:r}}function PS(){const e=P(a=>a.toggleGlobalPalette),t=P(a=>a.setGlobalPaletteOpen),s=P(a=>a.globalPaletteOpen),{close:r}=at(),{close:o}=fo();return u.useEffect(()=>{const a=i=>{(i.metaKey||i.ctrlKey)&&i.key==="k"&&(i.preventDefault(),s||(r(),o()),e())};return document.addEventListener("keydown",a),()=>document.removeEventListener("keydown",a)},[e,r,o,s]),{globalPaletteOpen:s,setGlobalPaletteOpen:t,toggleGlobalPalette:e}}function Tt(e){return Array.isArray?Array.isArray(e):su(e)==="[object Array]"}function LS(e){if(typeof e=="string")return e;if(typeof e=="bigint")return e.toString();const t=e+"";return t=="0"&&1/e==-1/0?"-0":t}function Fr(e){return e==null?"":LS(e)}function Te(e){return typeof e=="string"}function cs(e){return typeof e=="number"}function FS(e){return e===!0||e===!1||$S(e)&&su(e)=="[object Boolean]"}function nu(e){return typeof e=="object"}function $S(e){return nu(e)&&e!==null}function Ke(e){return e!=null}function Zn(e){return!e.trim().length}function su(e){return e==null?e===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(e)}const BS="Incorrect 'index' type",$r="Invalid doc index: must be a non-negative integer within the bounds of the docs array",zS=e=>`Invalid value for key ${e}`,US=e=>`Pattern length exceeds max of ${e}.`,KS=e=>`Missing ${e} property in key`,HS=e=>`Property 'weight' in key '${e}' must be a positive integer`,WS="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.",oi=Object.prototype.hasOwnProperty;var GS=class{constructor(e){this._keys=[],this._keyMap={};let t=0;e.forEach(s=>{const r=ru(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 ru(e){let t=null,s=null,r=null,o=1,a=null;if(Te(e)||Tt(e))r=e,t=ai(e),s=ls(e);else{if(!oi.call(e,"name"))throw new Error(KS("name"));const i=e.name;if(r=i,oi.call(e,"weight")&&e.weight!==void 0&&(o=e.weight,o<=0))throw new Error(HS(ls(i)));t=ai(i),s=ls(i),a=e.getFn??null}return{path:t,id:s,weight:o,src:r,getFn:a}}function ai(e){return Tt(e)?e:e.split(".")}function ls(e){return Tt(e)?e.join("."):e}function qS(e,t){const s=[];let r=!1;const o=(a,i,c,d)=>{if(Ke(a))if(!i[c])s.push(d!==void 0?{v:a,i:d}:a);else{const l=a[i[c]];if(!Ke(l))return;if(c===i.length-1&&(Te(l)||cs(l)||FS(l)||typeof l=="bigint"))s.push(d!==void 0?{v:Fr(l),i:d}:Fr(l));else if(Tt(l)){r=!0;for(let m=0,h=l.length;m<h;m+=1)o(l[m],i,c+1,m)}else i.length&&o(l,i,c+1,d)}};return o(e,Te(t)?t.split("."):t,0),r?s:s[0]}const YS={includeMatches:!1,findAllMatches:!1,minMatchCharLength:1},VS={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},QS={location:0,threshold:.6,distance:100},XS={useExtendedSearch:!1,useTokenSearch:!1,tokenize:void 0,tokenMatch:"any",getFn:qS,ignoreLocation:!1,ignoreFieldNorm:!1,fieldNormWeight:1},Q=Object.freeze({...VS,...YS,...QS,...XS});function JS(e){return e>=9&&e<=13||e===32||e===160}function ZS(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++)JS(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 Ko=class{constructor({getFn:e=Q.getFn,fieldNormWeight:t=Q.fieldNormWeight}={}){this.norm=ZS(t,3),this.getFn=e,this.isCreated=!1,this.docs=[],this.keys=[],this._keysMap={},this.setIndexRecords()}setSources(e=[]){this.docs=e}setIndexRecords(e=[]){this.records=e}setKeys(e=[]){this.keys=e,this._keysMap={},e.forEach((t,s)=>{this._keysMap[t.id]=s})}create(){if(this.isCreated||!this.docs.length)return;this.isCreated=!0;const e=this.docs.length;this.records=new Array(e);let t=0;if(Te(this.docs[0]))for(let s=0;s<e;s++){const r=this._createStringRecord(this.docs[s],s);r&&(this.records[t++]=r)}else for(let s=0;s<e;s++)this.records[t++]=this._createObjectRecord(this.docs[s],s);this.records.length=t,this.norm.clear()}add(e,t){if(!Number.isInteger(t)||t<0)throw new Error($r);if(Te(e)){const r=this._createStringRecord(e,t);return r&&this.records.push(r),r}const s=this._createObjectRecord(e,t);return this.records.push(s),s}removeAt(e){if(!Number.isInteger(e)||e<0)throw new Error($r);for(let t=0,s=this.records.length;t<s;t+=1)if(this.records[t].i===e){this.records.splice(t,1);break}for(let t=0,s=this.records.length;t<s;t+=1)this.records[t].i>e&&(this.records[t].i-=1)}removeAll(e){const t=new Set;for(const r of e)Number.isInteger(r)&&r>=0&&t.add(r);if(t.size===0)return;this.records=this.records.filter(r=>!t.has(r.i));const s=Array.from(t).sort((r,o)=>r-o);for(const r of this.records){let o=0,a=s.length;for(;o<a;){const i=o+a>>>1;s[i]<r.i?o=i+1:a=i}r.i-=o}}getValueForItemAtKeyId(e,t){return e[this._keysMap[t]]}size(){return this.records.length}_createStringRecord(e,t){return!Ke(e)||Zn(e)?null:{v:e,i:t,n:this.norm.get(e)}}_createObjectRecord(e,t){const s={i:t,$:{}};for(let r=0,o=this.keys.length;r<o;r++){const a=this.keys[r],i=a.getFn?a.getFn(e):this.getFn(e,a.path);if(Ke(i)){if(Tt(i)){const c=[];for(let d=0,l=i.length;d<l;d+=1){const m=i[d];if(Ke(m)){if(Te(m)){if(!Zn(m)){const h={v:m,i:d,n:this.norm.get(m)};c.push(h)}}else if(Ke(m.v)){const h=Te(m.v)?m.v:Fr(m.v);if(!Zn(h)){const p={v:h,i:m.i,n:this.norm.get(h)};c.push(p)}}}}s.$[r]=c}else if(Te(i)&&!Zn(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 ou(e,t,{getFn:s=Q.getFn,fieldNormWeight:r=Q.fieldNormWeight}={}){const o=new Ko({getFn:s,fieldNormWeight:r});return o.setKeys(e.map(ru)),o.setSources(t),o.create(),o}function e0(e,{getFn:t=Q.getFn,fieldNormWeight:s=Q.fieldNormWeight}={}){const{keys:r,records:o}=e,a=new Ko({getFn:t,fieldNormWeight:s});return a.setKeys(r),a.setIndexRecords(o),a}function t0(e=[],t=Q.minMatchCharLength){const s=[];let r=-1,o=-1,a=0;for(let i=e.length;a<i;a+=1){const c=e[a];c&&r===-1?r=a:!c&&r!==-1&&(o=a-1,o-r+1>=t&&s.push([r,o]),r=-1)}return e[a-1]&&a-r>=t&&s.push([r,a-1]),s}function n0(e,t,s,{location:r=Q.location,distance:o=Q.distance,threshold:a=Q.threshold,findAllMatches:i=Q.findAllMatches,minMatchCharLength:c=Q.minMatchCharLength,includeMatches:d=Q.includeMatches,ignoreLocation:l=Q.ignoreLocation}={}){if(t.length>32)throw new Error(US(32));const m=t.length,h=e.length,p=Math.max(0,Math.min(r,h));let f=a,g=p;const x=(O,_)=>{const D=O/m;if(l)return D;const k=Math.abs(p-_);return o?D+k/o:k?1:D},y=c>1||d,b=y?Array(h):[];let C;for(;(C=e.indexOf(t,g))>-1;){const O=x(0,C);if(f=Math.min(O,f),g=C+m,y){let _=0;for(;_<m;)b[C+_]=1,_+=1}}g=-1;let S=[],I=1,v=0,E=m+h;const R=1<<m-1;for(let O=0;O<m;O+=1){let _=0,D=E;for(;_<D;)x(O,p+D)<=f?_=D:E=D,D=Math.floor((E-_)/2+_);E=D;let k=Math.max(1,p-D+1);const j=i?h:Math.min(p+D,h)+m,N=Array(j+2);N[j+1]=(1<<O)-1;for(let w=j;w>=k;w-=1){const T=w-1,F=s[e[T]];if(N[w]=(N[w+1]<<1|1)&F,O&&(N[w]|=(S[w+1]|S[w])<<1|1|S[w+1]),N[w]&R&&(I=x(O,T),I<=f)){if(f=I,g=T,v=O,g<=p)break;k=Math.max(1,2*p-g)}}if(x(O+1,p)>f)break;S=N}if(y&&g>=0){const O=Math.min(h-1,g+m-1+v);for(let _=g;_<=O;_+=1)s[e[_]]&&(b[_]=1)}const M={isMatch:g>=0,score:Math.max(.001,I)};if(y){const O=t0(b,c);O.length?d&&(M.indices=O):M.isMatch=!1}return M}function s0(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 Ho(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 au={ł:"l",Ł:"L",đ:"d",Đ:"D",ø:"o",Ø:"O",ħ:"h",Ħ:"H",ŧ:"t",Ŧ:"T",ı:"i",ß:"ss"},r0=new RegExp("["+Object.keys(au).join("")+"]","g"),Fn=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(r0,t=>au[t]):e=>e;var Wo=class{constructor(e,{location:t=Q.location,threshold:s=Q.threshold,distance:r=Q.distance,includeMatches:o=Q.includeMatches,findAllMatches:a=Q.findAllMatches,minMatchCharLength:i=Q.minMatchCharLength,isCaseSensitive:c=Q.isCaseSensitive,ignoreDiacritics:d=Q.ignoreDiacritics,ignoreLocation:l=Q.ignoreLocation}={}){if(this.options={location:t,threshold:s,distance:r,includeMatches:o,findAllMatches:a,minMatchCharLength:i,isCaseSensitive:c,ignoreDiacritics:d,ignoreLocation:l},e=c?e:e.toLowerCase(),e=d?Fn(e):e,this.pattern=e,this.chunks=[],!this.pattern.length)return;const m=(p,f)=>{this.chunks.push({pattern:p,alphabet:s0(p),startIndex:f})},h=this.pattern.length;if(h>32){let p=0;const f=h%32,g=h-f;for(;p<g;)m(this.pattern.substr(p,32),p),p+=32;if(f){const x=h-32;m(this.pattern.substr(x),x)}}else m(this.pattern,0)}searchIn(e){const{isCaseSensitive:t,ignoreDiacritics:s,includeMatches:r}=this.options;if(e=t?e:e.toLowerCase(),e=s?Fn(e):e,this.pattern===e){if(e.length<this.options.minMatchCharLength)return{isMatch:!1,score:1};const g={isMatch:!0,score:0};return r&&(g.indices=[[0,e.length-1]]),g}const{location:o,distance:a,threshold:i,findAllMatches:c,minMatchCharLength:d,ignoreLocation:l}=this.options,m=[];let h=0,p=!1;this.chunks.forEach(({pattern:g,alphabet:x,startIndex:y})=>{const{isMatch:b,score:C,indices:S}=n0(e,g,x,{location:o+y,distance:a,threshold:i,findAllMatches:c,minMatchCharLength:d,includeMatches:r,ignoreLocation:l});b&&(p=!0),h+=C,b&&S&&m.push(...S)});const f={isMatch:p,score:p?h/this.chunks.length:1};return p&&r&&(f.indices=Ho(m)),f}};const o0=new Set(["fuzzy","include"]);function a0(e){return e.startsWith("inverse")}const Br=[{type:"exact",multiRegex:/^="(.*)"$/,singleRegex:/^=(.*)$/,create:e=>({type:"exact",search(t){const s=t===e;return{isMatch:s,score:s?0:1,indices:[0,e.length-1]}}})},{type:"include",multiRegex:/^'"(.*)"$/,singleRegex:/^'(.*)$/,create:e=>({type:"include",search(t){let s=0,r;const o=[],a=e.length;for(;(r=t.indexOf(e,s))>-1;)s=r+a,o.push([r,s-1]);const i=!!o.length;return{isMatch:i,score:i?0:1,indices:o}}})},{type:"prefix-exact",multiRegex:/^\^"(.*)"$/,singleRegex:/^\^(.*)$/,create:e=>({type:"prefix-exact",search(t){const s=t.startsWith(e);return{isMatch:s,score:s?0:1,indices:[0,e.length-1]}}})},{type:"inverse-prefix-exact",multiRegex:/^!\^"(.*)"$/,singleRegex:/^!\^(.*)$/,create:e=>({type:"inverse-prefix-exact",search(t){const s=!t.startsWith(e);return{isMatch:s,score:s?0:1,indices:[0,t.length-1]}}})},{type:"inverse-suffix-exact",multiRegex:/^!"(.*)"\$$/,singleRegex:/^!(.*)\$$/,create:e=>({type:"inverse-suffix-exact",search(t){const s=!t.endsWith(e);return{isMatch:s,score:s?0:1,indices:[0,t.length-1]}}})},{type:"suffix-exact",multiRegex:/^"(.*)"\$$/,singleRegex:/^(.*)\$$/,create:e=>({type:"suffix-exact",search(t){const s=t.endsWith(e);return{isMatch:s,score:s?0:1,indices:[t.length-e.length,t.length-1]}}})},{type:"inverse-exact",multiRegex:/^!"(.*)"$/,singleRegex:/^!(.*)$/,create:e=>({type:"inverse-exact",search(t){const s=t.indexOf(e)===-1;return{isMatch:s,score:s?0:1,indices:[0,t.length-1]}}})},{type:"fuzzy",multiRegex:/^"(.*)"$/,singleRegex:/^(.*)$/,create:(e,t={})=>{const s=new Wo(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)}}}}],ii=Br.length,i0="\0",c0="|";function l0(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 ci(e,t){const s=e.match(t);return s?s[1]:null}function d0(e,t={}){return e.replace(/\\\|/g,i0).split(c0).map(s=>{const r=l0(s.replace(/\u0000/g,"|").trim()).filter(a=>a&&!!a.trim()),o=[];for(let a=0,i=r.length;a<i;a+=1){const c=r[a];let d=!1,l=-1;for(;!d&&++l<ii;){const m=Br[l],h=ci(c,m.multiRegex);h&&(o.push(m.create(h,t)),d=!0)}if(!d)for(l=-1;++l<ii;){const m=Br[l],h=ci(c,m.singleRegex);if(h){o.push(m.create(h,t));break}}}return o})}var u0=class{constructor(e,{isCaseSensitive:t=Q.isCaseSensitive,ignoreDiacritics:s=Q.ignoreDiacritics,includeMatches:r=Q.includeMatches,minMatchCharLength:o=Q.minMatchCharLength,ignoreLocation:a=Q.ignoreLocation,findAllMatches:i=Q.findAllMatches,location:c=Q.location,threshold:d=Q.threshold,distance:l=Q.distance}={}){this.query=null,this.options={isCaseSensitive:t,ignoreDiacritics:s,includeMatches:r,minMatchCharLength:o,findAllMatches:i,ignoreLocation:a,location:c,threshold:d,distance:l},e=t?e:e.toLowerCase(),e=s?Fn(e):e,this.pattern=e,this.query=d0(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?Fn(e):e;let a=0;const i=[];let c=0,d=!1;for(let l=0,m=t.length;l<m;l+=1){const h=t[l];i.length=0,a=0,d=!1;for(let p=0,f=h.length;p<f;p+=1){const g=h[p],{isMatch:x,indices:y,score:b}=g.search(e);if(x)a+=1,c+=b,a0(g.type)&&(d=!0),s&&(o0.has(g.type)?i.push(...y):i.push(y));else{c=0,a=0,i.length=0,d=!1;break}}if(a){const p={isMatch:!0,score:c/a};return d&&(p.hasInverse=!0),s&&(p.indices=Ho(i)),p}}return{isMatch:!1,score:1}}};const zr=[];function Go(...e){zr.push(...e)}function ks(e,t){for(let s=0,r=zr.length;s<r;s+=1){const o=zr[s];if(o.condition(e,t))return new o(e,t)}return new Wo(e,t)}const Ss={AND:"$and",OR:"$or"},Ur={PATH:"$path",PATTERN:"$val"},Kr=e=>!!(e[Ss.AND]||e[Ss.OR]),m0=e=>!!e[Ur.PATH],h0=e=>!Tt(e)&&nu(e)&&!Kr(e),li=e=>({[Ss.AND]:Object.keys(e).map(t=>({[t]:e[t]}))});function iu(e,t,{auto:s=!0}={}){const r=o=>{if(Te(o)){const d={keyId:null,pattern:o};return s&&(d.searcher=ks(o,t)),d}const a=Object.keys(o),i=m0(o);if(!i&&a.length>1&&!Kr(o))return r(li(o));if(h0(o)){const d=i?o[Ur.PATH]:a[0],l=i?o[Ur.PATTERN]:o[d];if(!Te(l))throw new Error(zS(d));const m={keyId:ls(d),pattern:l};return s&&(m.searcher=ks(l,t)),m}const c={children:[],operator:a[0]};return a.forEach(d=>{const l=o[d];Tt(l)&&l.forEach(m=>{c.children.push(r(m))})}),c};return Kr(e)||(e=li(e)),r(e)}function Hr(e,{ignoreFieldNorm:t=Q.ignoreFieldNorm}){let s=1;return e.forEach(({key:r,norm:o,score:a})=>{const i=r?r.weight:null;s*=Math.pow(a===0&&i?Number.EPSILON:a,(i||1)*(t?1:o))}),s}function f0(e,{ignoreFieldNorm:t=Q.ignoreFieldNorm}){e.forEach(s=>{s.score=Hr(s.matches,{ignoreFieldNorm:t})})}var p0=class{constructor(e,t){this.limit=e,this.heap=[],this.comparator=t}get size(){return this.heap.length}insert(e){this.size<this.limit?(this.heap.push(e),this._bubbleUp(this.size-1)):this.comparator(e,this.heap[0])<0&&(this.heap[0]=e,this._sinkDown(0))}extractSorted(){return this.heap.sort(this.comparator)}_bubbleUp(e){const t=this.heap;for(;e>0;){const s=e-1>>1;if(this.comparator(t[e],t[s])<=0)break;const r=t[e];t[e]=t[s],t[s]=r,e=s}}_sinkDown(e){const t=this.heap,s=t.length;let r=e;do{e=r;const o=2*e+1,a=2*e+2;if(o<s&&this.comparator(t[o],t[r])>0&&(r=o),a<s&&this.comparator(t[a],t[r])>0&&(r=a),r!==e){const i=t[e];t[e]=t[r],t[r]=i}}while(r!==e)}};function g0(e){const t=[];return e.matches.forEach(s=>{if(!Ke(s.indices)||!s.indices.length)return;const r={indices:s.indices,value:s.value};s.key&&(r.key=s.key.id),s.idx>-1&&(r.refIndex=s.idx),t.push(r)}),t}function x0(e,t,{includeMatches:s=Q.includeMatches,includeScore:r=Q.includeScore}={}){return e.map(o=>{const{idx:a}=o,i={item:t[a],refIndex:a};return s&&(i.matches=g0(o)),r&&(i.score=o.score),i})}const b0=/[\p{L}\p{M}\p{N}_]+/gu,di=new WeakSet;function y0(e){di.has(e)||(di.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 v0(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||y0(e),t=>t.match(e)||[]):t=>t.match(b0)||[]}function Wr({isCaseSensitive:e=!1,ignoreDiacritics:t=!1,tokenize:s}={}){const r=v0(s);return{tokenize(o){return e||(o=o.toLowerCase()),t&&(o=Fn(o)),r(o)}}}var w0=class{static condition(e,t){return t.useTokenSearch}constructor(e,t){this.options=t,this.analyzer=Wr({isCaseSensitive:t.isCaseSensitive,ignoreDiacritics:t.ignoreDiacritics,tokenize:t.tokenize});const s=this.analyzer.tokenize(e),{df:r,fieldCount:o}=t._invertedIndex;this.termSearchers=[],this.idfWeights=[];for(const a of s){this.termSearchers.push(new Wo(a,{location:t.location,threshold:t.threshold,distance:t.distance,includeMatches:t.includeMatches,findAllMatches:t.findAllMatches,minMatchCharLength:t.minMatchCharLength,isCaseSensitive:t.isCaseSensitive,ignoreDiacritics:t.ignoreDiacritics,ignoreLocation:!0}));const i=r.get(a)||0,c=Math.log(1+(o-i+.5)/(i+.5));this.idfWeights.push(c)}this.combineAll=t.tokenMatch==="all",this.numTerms=this.termSearchers.length,this.useMask=this.numTerms<=31}searchIn(e){if(!this.termSearchers.length)return{isMatch:!1,score:1};const t=[];let s=0,r=0,o=0,a=0;const i=this.combineAll&&!this.useMask?new Set:null;for(let l=0;l<this.termSearchers.length;l++){const m=this.termSearchers[l].searchIn(e),h=this.idfWeights[l];r+=h,m.isMatch&&(o++,s+=h*(1-m.score),m.indices&&t.push(...m.indices),this.combineAll&&(this.useMask?a|=1<<l:i.add(l)))}if(o===0)return{isMatch:!1,score:1};const c=r>0?1-s/r:0,d={isMatch:!0,score:Math.max(.001,c)};return this.options.includeMatches&&t.length&&(d.indices=Ho(t)),this.combineAll&&(this.useMask?d.matchedMask=a:d.matchedTerms=i,d.termCount=this.numTerms),d}};function lr(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 cu(e,t,s,r){const{i:o,v:a,$:i}=t;if(a!==void 0){lr(e,a,o,r);return}if(i)for(let c=0;c<s;c++){const d=i[c];if(d)if(Array.isArray(d))for(const l of d)lr(e,l.v,o,r);else lr(e,d.v,o,r)}}function j0(e,t,s){const r={fieldCount:0,df:new Map,docFieldCount:new Map,docTermFieldHits:new Map};for(const o of e)cu(r,o,t,s);return r}function k0(e,t,s,r){cu(e,t,s,r)}function S0(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 ui(e,t){if(t.length===0)return;const s=Array.from(new Set(t)).sort((c,d)=>c-d);for(const c of s)S0(e,c);const r=c=>{let d=0,l=s.length;for(;d<l;){const m=d+l>>>1;s[m]<c?d=m+1:l=m}return c-d},o=s[0],a=new Map;for(const[c,d]of e.docFieldCount)a.set(c>o?r(c):c,d);e.docFieldCount=a;const i=new Map;for(const[c,d]of e.docTermFieldHits)i.set(c>o?r(c):c,d);e.docTermFieldHits=i}var Dt=class{constructor(e,t,s){this.options={...Q,...t},this.options.useExtendedSearch,this.options.useTokenSearch,this._keyStore=new GS(this.options.keys),this._docs=e,this._myIndex=null,this._invertedIndex=null,this.setCollection(e,s),this._lastQuery=null,this._lastSearcher=null}_getSearcher(e){if(this._lastQuery===e)return this._lastSearcher;const t=ks(e,this._invertedIndex?{...this.options,_invertedIndex:this._invertedIndex}:this.options);return this._lastQuery=e,this._lastSearcher=t,t}setCollection(e,t){if(this._docs=e,t&&!(t instanceof Ko))throw new Error(BS);if(this._myIndex=t||ou(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight}),this.options.useTokenSearch){const s=Wr({isCaseSensitive:this.options.isCaseSensitive,ignoreDiacritics:this.options.ignoreDiacritics,tokenize:this.options.tokenize});this._invertedIndex=j0(this._myIndex.records,this._myIndex.keys.length,s)}this._invalidateSearcherCache()}add(e){if(!Ke(e))return;this._docs.push(e);const t=this._myIndex.add(e,this._docs.length-1);if(this._invertedIndex&&t){const s=Wr({isCaseSensitive:this.options.isCaseSensitive,ignoreDiacritics:this.options.ignoreDiacritics,tokenize:this.options.tokenize});k0(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&&ui(this._invertedIndex,s);const r=new Set(s);this._docs=this._docs.filter((o,a)=>!r.has(a)),this._myIndex.removeAll(s),this._invalidateSearcherCache()}return t}removeAt(e){if(!Number.isInteger(e)||e<0||e>=this._docs.length)throw new Error($r);this._invertedIndex&&ui(this._invertedIndex,[e]);const t=this._docs.splice(e,1)[0];return this._myIndex.removeAt(e),this._invalidateSearcherCache(),t}_invalidateSearcherCache(){this._lastQuery=null,this._lastSearcher=null}getIndex(){return this._myIndex}_normalizedKeys(){return this._myIndex.keys.map(e=>this._keyStore.get(e.id)||e)}search(e,t){const{limit:s=-1}=t||{},{includeMatches:r,includeScore:o,shouldSort:a,sortFn:i,ignoreFieldNorm:c}=this.options;if(Te(e)&&!e.trim()){let p=this._docs.map((f,g)=>({item:f,refIndex:g}));return cs(s)&&s>-1&&(p=p.slice(0,s)),p}const d=a&&cs(s)&&s>0&&Te(e),l=i,m=(p,f)=>l(p,f)||p.idx-f.idx;let h;if(d){const p=new p0(s,m);Te(this._docs[0])?this._searchStringList(e,{heap:p,ignoreFieldNorm:c}):this._searchObjectList(e,{heap:p,ignoreFieldNorm:c}),h=p.extractSorted()}else h=Te(e)?Te(this._docs[0])?this._searchStringList(e):this._searchObjectList(e):this._searchLogical(e),f0(h,{ignoreFieldNorm:c}),a&&h.sort(Te(e)?m:l),cs(s)&&s>-1&&(h=h.slice(0,s));return x0(h,this._docs,{includeMatches:r,includeScore:o})}_searchStringList(e,{heap:t,ignoreFieldNorm:s}={}){const r=this._getSearcher(e),o=this.options.useTokenSearch&&this.options.tokenMatch==="all",{records:a}=this._myIndex,i=t?null:[];return a.forEach(({v:c,i:d,n:l})=>{if(!Ke(c))return;const m=r.searchIn(c);if(m.isMatch){const h={score:m.score,value:c,norm:l,indices:m.indices};o&&(h.matchedMask=m.matchedMask,h.matchedTerms=m.matchedTerms,h.termCount=m.termCount);const p=[h];if(!o||this._coversAllTokens(p)){const f={item:c,idx:d,matches:p};t?(f.score=Hr(f.matches,{ignoreFieldNorm:s}),t.insert(f)):i.push(f)}}}),i}_searchLogical(e){const t=iu(e,this.options),s=this._normalizedKeys(),r=(c,d,l)=>{if(!("children"in c)){const{keyId:f,searcher:g}=c;let x;return f===null?(x=[],s.forEach((y,b)=>{x.push(...this._findMatches({key:y,value:d[b],searcher:g}))})):x=this._findMatches({key:this._keyStore.get(f),value:this._myIndex.getValueForItemAtKeyId(d,f),searcher:g}),x&&x.length?[{idx:l,item:d,matches:x}]:[]}const{children:m,operator:h}=c,p=[];for(let f=0,g=m.length;f<g;f+=1){const x=m[f],y=r(x,d,l);if(y.length)p.push(...y);else if(h===Ss.AND)return[]}return p},o=this._myIndex.records,a=new Map,i=[];return o.forEach(({$:c,i:d})=>{if(Ke(c)){const l=r(t,c,d);l.length&&(a.has(d)||(a.set(d,{idx:d,item:c,matches:[]}),i.push(a.get(d))),l.forEach(({matches:m})=>{a.get(d).matches.push(...m)}))}}),i}_searchObjectList(e,{heap:t,ignoreFieldNorm:s}={}){const r=this._getSearcher(e),o=this.options.useTokenSearch&&this.options.tokenMatch==="all",{records:a}=this._myIndex,i=this._normalizedKeys(),c=t?null:[];return a.forEach(({$:d,i:l})=>{if(!Ke(d))return;const m=[];let h=!1,p=!1;if(i.forEach((f,g)=>{const x=this._findMatches({key:f,value:d[g],searcher:r});x.length?(m.push(...x),x[0].hasInverse&&(p=!0)):h=!0}),!(p&&h)&&m.length&&(!o||this._coversAllTokens(m))){const f={idx:l,item:d,matches:m};t?(f.score=Hr(f.matches,{ignoreFieldNorm:s}),t.insert(f)):c.push(f)}}),c}_findMatches({key:e,value:t,searcher:s}){if(!Ke(t))return[];const r=[];if(Tt(t))t.forEach(({v:o,i:a,n:i})=>{if(!Ke(o))return;const c=s.searchIn(o);if(c.isMatch){const d={score:c.score,key:e,value:o,idx:a,norm:i,indices:c.indices,hasInverse:c.hasInverse};c.termCount!==void 0&&(d.matchedMask=c.matchedMask,d.matchedTerms=c.matchedTerms,d.termCount=c.termCount),r.push(d)}});else{const{v:o,n:a}=t,i=s.searchIn(o);if(i.isMatch){const c={score:i.score,key:e,value:o,norm:a,indices:i.indices,hasInverse:i.hasInverse};i.termCount!==void 0&&(c.matchedMask=i.matchedMask,c.matchedTerms=i.matchedTerms,c.termCount=i.termCount),r.push(c)}}return r}_coversAllTokens(e){const t=e.length?e[0].termCount:void 0;if(t===void 0)return!0;if(t<=31){let r=0;for(let o=0;o<e.length;o++)r|=e[o].matchedMask||0;return r===2**t-1}const s=new Set;for(let r=0;r<e.length;r++){const o=e[r].matchedTerms;if(o)for(const a of o)s.add(a)}return s.size===t}};Dt.version="7.5.0";Dt.createIndex=ou;Dt.parseIndex=e0;Dt.config=Q;Dt.match=function(e,t,s){if(s&&s.useTokenSearch)throw new Error(WS);return ks(e,{...Q,...s}).searchIn(t)};Dt.parseQuery=iu;Go(u0);Go(w0);Dt.use=function(...e){e.forEach(t=>Go(t))};var C0=Dt;const N0=.02,lu=.5,du=.35,uu=.15,A0=1+lu+du+uu,E0=4320*60*1e3,I0=3,R0=1440*60*1e3,T0=.15,D0={lastUsedAt:null,useCount:0};function qo(e){return!Number.isFinite(e)||e<0?0:e>1?1:e}function mu(e,t){return!Number.isFinite(e)||e<=0?1:qo(Math.pow(2,-e/t))}function O0(e,t){const s=e.lastUsedAt===null?0:mu(t-e.lastUsedAt,E0),r=Math.max(0,e.useCount),o=r===0?0:r/(r+I0);return qo((s+o)/2)}function M0(e,t){const s=e.distance===null?1:qo(Math.pow(2,-Math.max(0,e.distance)/N0)),r=O0(e.usage,t),o=e.lastActivityAt===null?0:mu(t-e.lastActivityAt,R0),a=1+(e.waiting?lu:0)+du*r+uu*o;return{score:s*a/A0,signals:{relevance:s,frecency:r,recency:o}}}function _0(e,t){return e.map(s=>{const{score:r,signals:o}=M0(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 P0(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<T0?{best:null,rest:s}:{best:r,rest:s.slice(1)}:{best:null,rest:s}}function L0(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 F0={keys:["name","keywords"],includeMatches:!0,includeScore:!0,threshold:.3,distance:100,minMatchCharLength:1};function $0(e,t,s){const{usage:r,now:o,scope:a}=s,{prefix:i,term:c}=u.useMemo(()=>a===null?B0(t):{prefix:null,term:t},[t,a]),d=u.useMemo(()=>{if(a===null)return e;const x=eu(a);return e.filter(y=>y.scopes.includes(x))},[e,a]),l=u.useMemo(()=>i==="#"?d.filter(x=>x.type==="room"):i==="@"?d.filter(x=>x.type==="agent"||x.type==="dm"):i===">"?d.filter(x=>x.type==="command"):d,[d,i]),m=u.useMemo(()=>new C0(l,F0),[l]),h=u.useMemo(()=>{const x=(y,b,C)=>{const S=y.lastActivityAt===null?NaN:Date.parse(y.lastActivityAt);return{key:`${y.type}:${y.id}`,item:{item:y,matches:b},distance:C,usage:(y.usageKey===null?void 0:r[y.usageKey])??D0,lastActivityAt:Number.isNaN(S)?null:S,waiting:y.waiting,demoted:y.demoted}};return c?m.search(c).map(y=>x(y.item,y.matches,y.score??0)):l.map(y=>x(y,void 0,null))},[m,c,l,r]),p=u.useMemo(()=>_0(h,o),[h,o]),{best:f,rest:g}=u.useMemo(()=>P0(p,{queried:c.length>0}),[p,c]);return{bestMatch:f,rows:g,prefix:i,term:c}}function B0(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 z0(){const e=po(),t=Ph();return u.useMemo(()=>{const s={};for(const[r,o]of Object.entries(e)){const a=Date.parse(o);s[r]={lastUsedAt:Number.isNaN(a)?null:a,useCount:t[r]??0}}return s},[e,t])}const U0=/^\/([A-Za-z0-9][\w.-]*(?::[\w.-]+)*)(?=\s|$)\s*/;function K0(e,t){const s=t.trim().replace(U0,"").trim();return s?`${e} ${s}`:`${e} `}function H0(e){const[t,s]=$s(),{setTheme:r,theme:o}=Zi(),a=Me(),i=le(),c=ae(),d=Cn(N=>N.openFeedback),l=go(),{url:m}=Wc(),{copy:h}=Bn({toastOnSettle:!0}),{open:p}=at(),{open:f}=fo(),g=oo(),x=P(N=>N.setPickerOpen),y=P(N=>N.setCanvasOpen),b=P(N=>N.setRightPanelOpen),C=P(N=>N.setActiveRightPanelTab),S=u.useCallback(N=>{gs.getState().recordOpened("agent",N)},[]),I=Yc(),v=u.useCallback(N=>{if(Lh(i,Kh)){e(),I({agentPath:N.projectPath}).then(w=>{w&&S(N.projectPath)});return}s(N.projectPath,{onOpened:()=>{S(N.projectPath)}}),e()},[i,I,S,s,e]),E=Vc(),R=u.useCallback(N=>{gs.getState().recordOpened("room",N.id),e(),a({...ve.channels(),search:{id:N.id}})},[e,a]),M=u.useCallback((N,w)=>{w&&S(w),e(),a(Kt({session:N,dir:w??void 0}))},[e,a,S]),O=u.useCallback(N=>{e(),Fh({queryClient:i,transport:c},t).then(async w=>{if(w===null){ra(t);return}t&&S(t);const T=$h.getState(),F=T.getSession(w.sessionId).input;T.updateSession(w.sessionId,{input:K0(N,F)}),a(w.isNew?await Bh(c,{session:w.sessionId,dir:t??void 0}):Kt({session:w.sessionId}))}).catch(w=>{sc(c,w),ra(t)})},[e,a,i,c,t,S]),_=u.useCallback(N=>{e(),a({href:N})},[e,a]),D=u.useCallback(N=>{zh(N)||console.warn(`[command-palette] no handler registered for action "${N}"`)},[]),k=u.useCallback(N=>{switch(e(),N){case"openTasks":f();return;case"openRelay":g();return;case"openMesh":a({...ve.team()});return;case"openSettings":p();return;case"discoverAgents":sn.getState().open();return;case"browseFilesystem":x(!0);return;case"openAgentProfile":C(Uh),b(!0);return;default:{const w=qc(N);if(w){p(w);return}D(N);return}}},[e,a,f,g,p,x,C,b,D]),j=u.useCallback(N=>{switch(e(),N){case"navigateDashboard":a({...ve.home()});return;case"newSession":E();return;case"openDevPlayground":Tn("/dev");return;case"toggleDevtools":P.getState().toggleDevtools();return;case"toggleRouterDevtools":P.getState().toggleRouterDevtools();return;case"createAgent":Is.getState().open();return;case"switchShape":P.getState().setShapeSwitcherOpen(!0);return;case"openControlCenter":P.getState().setControlCenterOpen(!0);return;case"toggleCanvas":y(!P.getState().canvasOpen);return;case"toggleTheme":r(o==="dark"?"light":"dark");return;case"openFeedback":d();return;case"openYourReports":a({...ve.feedbackRequests()});return;case"openTasks":f();return;case"openRelay":g();return;case"openMesh":a({...ve.team()});return;case"discoverAgents":sn.getState().open();return;case"openSettings":p();return;case"browseFilesystem":x(!0);return;case ht.copyLink:m&&h(m);return;case ht.showQr:P.getState().setRemoteAccessBeaconOpen(!0);return;case ht.turnOn:l.start();return;case ht.turnOff:l.stop();return;default:D(N);return}},[e,a,D,r,o,y,x,f,g,p,d,h,l,m,E]);return{handleAgentSelect:v,startNewSession:E,handleFeatureAction:k,handleQuickAction:j,handleRoomSelect:R,handleSessionSelect:M,handleCommandSelect:O,handlePageSelect:_,recordAgentOpened:S,setDir:s,selectedCwd:t}}const mi='[cmdk-item=""]:not([aria-disabled="true"])',W0=new Set(["ArrowUp","ArrowDown","Home","End"]),G0=new Set(["n","p","j","k"]);function q0({rootRef:e,activePage:t,onPin:s,resetKey:r}){const o=u.useRef(!1);u.useLayoutEffect(()=>{o.current=!1},[r]),u.useLayoutEffect(()=>{var l;if(o.current)return;const c=(l=e.current)==null?void 0:l.querySelector(`[data-palette-page="${CSS.escape(t)}"] ${mi}`);if(!c||c.getAttribute("aria-selected")==="true")return;const d=c.getAttribute("data-value");d&&s(d)});const a=u.useCallback(c=>{c.nativeEvent.isComposing||c.keyCode===229||(W0.has(c.key)||c.ctrlKey&&G0.has(c.key))&&(o.current=!0)},[]),i=u.useCallback(c=>{c.target instanceof Element&&c.target.closest(mi)&&(o.current=!0)},[]);return{onKeyDown:a,onPointerMove:i}}function Y0({scope:e,className:t}){return n.jsx("span",{"data-testid":"palette-scope-chip",className:K("bg-accent text-accent-foreground inline-flex shrink-0 items-center gap-1.5 rounded-md px-1.5 py-0.5 text-xs font-medium",t),children:e.kind==="agent"?n.jsxs(n.Fragment,{children:[n.jsx(xo,{...bo(e.agent),size:"xs",badge:null}),Le(e.agent)]}):n.jsxs(n.Fragment,{children:[n.jsx(Qc,{room:e.room,participants:e.room.participants,size:"xs"}),n.jsx(Xc,{room:e.room})]})})}function V0(e){const t=e.trim();return t.length===0?null:t}function hu(e,t){const s=u.useDeferredValue(e),{sessions:r}=Hh(t),{data:o}=Ox(s||null),a=u.useMemo(()=>r.slice(0,3).map(i=>({id:i.id,title:Uc(i.title),lastActive:i.updatedAt})),[r]);return{sessionCount:r.length,recentSessions:a,health:o??null}}function Q0({agent:e}){const{sessionCount:t,recentSessions:s,health:r}=hu(e.id,e.projectPath),{color:o,emoji:a}=bo(e);return n.jsx(se.div,{initial:{opacity:0,width:0},animate:{opacity:1,width:240},exit:{opacity:0,width:0},transition:{duration:.2,ease:[0,0,.2,1]},className:"flex-shrink-0 overflow-hidden border-l will-change-[width]",children:n.jsxs("div",{className:"w-[240px] space-y-3 p-4",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(xo,{color:o,emoji:a,size:"sm",className:"shrink-0"}),n.jsx("span",{className:"truncate text-sm font-semibold",children:Le(e)})]}),n.jsx("p",{className:"text-muted-foreground truncate text-xs",children:io(e.projectPath)}),n.jsxs("div",{className:"flex items-center gap-3 text-xs",children:[r&&n.jsx(Dn,{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 X0({agent:e,onOpenHere:t,onOpenNewTab:s,onOpenNewWindow:r,onNewSession:o,onBrowseSessions:a,onEditSettings:i,recentSessions:c,onSelectSession:d}){const l=Wt?"⌘":"Ctrl+";return n.jsxs(n.Fragment,{children:[n.jsxs(nt,{heading:`${Le(e)} actions`,children:[n.jsxs(Ae,{value:"open-here",onSelect:t,children:[n.jsx(Rs,{className:"size-4"}),n.jsx("span",{children:"Open here"}),n.jsx(Aa,{children:"Enter"})]}),n.jsxs(Ae,{value:"open-new-tab",onSelect:s,children:[n.jsx(Xb,{className:"size-4"}),n.jsx("span",{children:"Open in a new tab"}),n.jsxs(Aa,{children:[l,"Enter"]})]}),r&&n.jsxs(Ae,{value:"open-new-window",onSelect:r,children:[n.jsx(py,{className:"size-4"}),n.jsx("span",{children:"Open in a new window"})]}),n.jsxs(Ae,{value:"new-session",onSelect:o,children:[n.jsx(Rt,{className:"size-4"}),n.jsx("span",{children:"New chat"})]}),a&&n.jsxs(Ae,{value:"browse-sessions",onSelect:a,children:[n.jsx(Zb,{className:"size-4"}),n.jsx("span",{children:"Browse chats…"})]}),n.jsxs(Ae,{value:"edit-settings",onSelect:i,children:[n.jsx(Bs,{className:"size-4"}),n.jsxs("span",{children:["Edit ",Le(e)," settings"]})]})]}),c.length>0&&n.jsx(nt,{heading:"Recent chats",children:c.map(m=>n.jsxs(Ae,{value:m.id,onSelect:()=>d(m.id),children:[n.jsx(Es,{className:"size-4"}),n.jsx("span",{className:"truncate",children:m.title}),n.jsx("span",{className:"text-muted-foreground ml-auto text-xs",children:J0(m.lastActive)})]},m.id))})]})}function J0(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 kt="bg-muted rounded px-1 py-0.5 font-mono text-3xs";function Z0({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:kt,children:"↑↓"}),"Navigate"]}),!e&&t&&n.jsxs("span",{className:"inline-flex items-center gap-1",children:[n.jsx("kbd",{className:kt,children:"Enter"}),"Open"]}),(!e&&t||e==="agent-actions")&&n.jsxs("span",{className:"inline-flex items-center gap-1",children:[n.jsxs("kbd",{className:kt,children:[o,"Enter"]}),"New tab"]}),e==="agent-actions"&&n.jsxs("span",{className:"inline-flex items-center gap-1",children:[n.jsx("kbd",{className:kt,children:"Enter"}),"Select"]}),e&&n.jsxs("span",{className:"inline-flex items-center gap-1",children:[n.jsx("kbd",{className:kt,children:"Backspace"}),"Back"]}),s&&n.jsxs("span",{className:"inline-flex items-center gap-1",children:[n.jsx("kbd",{className:kt,children:"Tab"}),"Search inside"]}),r&&n.jsxs("span",{className:"inline-flex items-center gap-1",children:[n.jsx("kbd",{className:kt,children:"Backspace"}),"Clear scope, at the start"]}),n.jsxs("span",{className:"ml-auto inline-flex items-center gap-1",children:[n.jsx("kbd",{className:kt,children:"esc"}),"Close"]})]})}const eC=[{key:"#",means:"channels"},{key:"@",means:"agents and DMs"},{key:">",means:"commands"}];function fu({className:e}){return n.jsx("div",{className:K("text-muted-foreground flex flex-wrap items-center gap-x-3 gap-y-1 px-3 py-2 text-xs",e),children:eC.map(({key:t,means:s})=>n.jsxs("span",{className:"inline-flex items-center gap-1",children:[n.jsx("kbd",{className:"bg-muted text-3xs rounded px-1 py-0.5 font-mono",children:t}),s]},t))})}function tC({text:e,indices:t,className:s}){if(!t||t.length===0)return n.jsx("span",{className:s,children:e});const r=[];let o=0;for(let a=0;a<t.length;a++){const[i,c]=t[a],d=c+1;o<i&&r.push(n.jsx("span",{children:e.slice(o,i)},`p-${a}`)),r.push(n.jsx("mark",{className:"text-foreground bg-transparent font-semibold",children:e.slice(i,d)},`m-${a}`)),o=d}return o<e.length&&r.push(n.jsx("span",{children:e.slice(o)},"tail")),n.jsx("span",{className:s,children:r})}function pu({agent:e,isActive:t,onSelect:s,nameIndices:r,isSelected:o}){return n.jsxs(Ae,{value:Le(e),keywords:[e.name,e.projectPath,e.id],onSelect:()=>s(),className:"relative py-2",forceMount:t?!0:void 0,children:[o&&n.jsx(se.div,{layoutId:"cmd-palette-selection",className:"bg-accent absolute inset-0 rounded-sm",transition:{duration:.15,ease:[0,0,.2,1]}}),n.jsx("div",{className:"relative z-10 w-full",children:n.jsx(ey,{agent:e,name:r?n.jsx(tC,{text:Le(e),indices:r,className:"truncate text-sm font-semibold"}):n.jsx("span",{className:"truncate text-sm font-semibold",children:Le(e)}),secondary:io(e.projectPath),selected:t})})]})}function gu(){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 nC(e){if(e.kind==="dm"){const r=e.unreadCount??0;if(r<=0)return null;const o=r>Nn?`More than ${Nn}`:String(r);return{count:r,cap:Nn,label:r===1?"1 new message":`${o} new messages`}}const t=e.mentionCount??0;if(t<=0||e.unreadCount===null)return null;const s=t>rs?`More than ${rs}`:String(t);return{count:t,cap:rs,label:t===1?"1 mention":`${s} mentions`}}function xu({room:e,onSelect:t}){const s=nC(e);return n.jsxs(Ae,{value:e.id,keywords:Lr(e),onSelect:t,className:"flex items-center gap-2 py-2",children:[n.jsx(Qc,{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(Xc,{room:e,className:"min-w-0 flex-1 text-sm"}),e.archived&&n.jsx(gu,{}),s&&n.jsx(zs,{solid:!0,count:s.count,cap:s.cap,label:s.label})]})}const sC=6e4;function rC({lastActivityAt:e}){const t=yo(sC),s=u.useMemo(()=>Number.isNaN(Date.parse(e))?null:Kn(e),[e,t]);return s===null?null:n.jsx("span",{className:"text-muted-foreground text-2xs font-normal",children:s})}function Gr({item:e,live:t,isSelected:s=!1,onSelect:r}){const o=Jc(e.agent,e.cwd??e.id),a=Wh(e.who,e.title),i=(t==null?void 0:t.verb)??null;return n.jsxs(Ae,{value:e.id,keywords:tu(e),onSelect:r,title:a,className:K("flex gap-2 py-1.5",i!==null?"items-start":"items-center"),children:[n.jsx(xo,{color:o.color,emoji:o.emoji,size:"xs",className:K("shrink-0",i!==null&&"mt-px")}),n.jsxs("span",{className:"flex min-w-0 flex-1 flex-col",children:[n.jsxs("span",{"data-slot":"palette-session-line",className:"flex w-full items-center gap-1.5 text-sm",children:[e.who?n.jsxs(n.Fragment,{children:[n.jsx("span",{"data-slot":"palette-session-who",className:Gh,children:e.who}),n.jsx("span",{"aria-hidden":!0,className:"text-muted-foreground/60 flex-none",children:qh})]}):null,n.jsx("span",{"data-slot":"palette-session-title",className:Yh,children:e.title}),n.jsxs("span",{className:K("flex items-center gap-1.5",Qh),children:[e.archived&&t===void 0&&n.jsx(gu,{}),n.jsx(Vh,{origin:e.origin,label:e.originLabel,className:"text-muted-foreground"}),n.jsx(rC,{lastActivityAt:e.lastActivityAt}),s&&n.jsx(oC,{canStartNewSession:e.cwd!==null})]})]}),i!==null&&n.jsxs("span",{className:"text-muted-foreground text-2xs flex items-center gap-1.5 font-normal",children:[t!==void 0&&n.jsx("span",{"aria-hidden":!0,className:K("size-1.5 shrink-0 rounded-full",Xh(t.signal))}),i]})]})]})}function oC({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 aC={session:"Conversations",agent:"Agents",room:"Channels",dm:"Direct messages",command:"Commands",feature:"Actions","quick-action":"Actions",page:"Add-ons"},iC="Best match",qr={Clock:fc,Radio:ty,Globe:fs,Settings:Bs,Plus:Rt,Search:hs,FolderOpen:Rs,Moon:hb,Shapes:Zh,MessageSquarePlus:Zc,Inbox:Jh},$t=[0,0,.2,1],cC=[.4,0,1,1],bu={hidden:{opacity:0,scale:.96,y:-8},visible:{opacity:1,scale:1,y:0,transition:{duration:.2,ease:$t}},exit:{opacity:0,scale:.96,y:-8,transition:{duration:.12,ease:cC}}},lC={hidden:{},visible:{transition:{staggerChildren:.035,delayChildren:.04}}},En={hidden:{opacity:0,y:-4},visible:{opacity:1,y:0,transition:{duration:.15,ease:$t}}},dr=8;function dC({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(nt,{heading:"Continue",children:e.map((l,m)=>n.jsx(se.div,{variants:m<dr?En:void 0,children:n.jsx(Gr,{item:l.session,live:{verb:l.verb,signal:l.signal},isSelected:o===l.session.id,onSelect:()=>a(l.session)})},l.session.id))}),t.length>0&&n.jsx(nt,{heading:"Recent",children:t.map((l,m)=>n.jsxs(se.div,{variants:m<dr?En:void 0,children:[l.kind==="session"&&n.jsx(Gr,{item:l.session,isSelected:o===l.session.id,onSelect:()=>a(l.session)}),l.kind==="room"&&n.jsx(xu,{room:l.room,onSelect:()=>i(l.room)}),l.kind==="agent"&&n.jsx(pu,{agent:l.agent,isActive:l.agent.projectPath===r,isSelected:o===Le(l.agent),onSelect:()=>c(l.agent)})]},l.key))}),s.length>0&&n.jsxs(n.Fragment,{children:[(e.length>0||t.length>0)&&n.jsx(sd,{}),n.jsx(nt,{heading:"New",children:s.map((l,m)=>{const h=qr[l.icon];return n.jsx(se.div,{variants:m<dr?En:void 0,children:n.jsx(Ae,{value:l.label,onSelect:()=>d(l.action),children:n.jsxs(se.div,{whileHover:{x:2},transition:{duration:.1,ease:$t},className:"flex w-full items-center gap-2",children:[h&&n.jsx(h,{className:"size-4"}),n.jsx("span",{children:l.label})]})})},l.id)})})]})]})}function hi({row:e,selectedCwd:t,selectedValue:s,onFeatureAction:r,onQuickAction:o,onGoToAgentActions:a,onRoomSelect:i,onSessionSelect:c,onCommandSelect:d,onPageSelect:l}){var p;const{item:m,matches:h}=e.item;switch(m.type){case"session":return n.jsx(Gr,{item:m.data,isSelected:s===m.data.id,onSelect:()=>c(m.data)});case"agent":return n.jsx(pu,{agent:m.data,isActive:m.data.projectPath===t,isSelected:s===Le(m.data),onSelect:()=>a(m.data),nameIndices:(p=h==null?void 0:h.find(f=>f.key==="name"))==null?void 0:p.indices});case"room":case"dm":return n.jsx(xu,{room:m.data,onSelect:()=>i(m.data)});case"command":return n.jsx(Ae,{value:m.data.name,onSelect:()=>d(m.data.name),children:n.jsxs(se.div,{whileHover:{x:2},transition:{duration:.1,ease:$t},className:"flex w-full items-center gap-2",children:[n.jsx("span",{className:"font-mono text-xs",children:m.data.name}),m.data.description&&n.jsx("span",{className:"text-muted-foreground ml-2 text-xs",children:m.data.description})]})});case"feature":{const f=qr[m.data.icon];return n.jsx(Ae,{value:m.data.label,onSelect:()=>r(m.data.action),children:n.jsxs(se.div,{whileHover:{x:2},transition:{duration:.1,ease:$t},className:"flex w-full items-center gap-2",children:[f&&n.jsx(f,{className:"size-4"}),n.jsx("span",{children:m.data.label}),m.data.shortcut&&n.jsx("span",{className:"text-muted-foreground ml-auto text-xs",children:m.data.shortcut})]})})}case"page":return n.jsx(Ae,{value:m.data.id,onSelect:()=>l(m.data.href),children:n.jsxs(se.div,{whileHover:{x:2},transition:{duration:.1,ease:$t},className:"flex w-full items-center gap-2",children:[n.jsx(Un,{icon:m.data.icon,className:"size-4"}),n.jsx("span",{children:m.data.label})]})});case"quick-action":{const f=qr[m.data.icon];return n.jsx(Ae,{value:m.data.label,onSelect:()=>o(m.data.action),children:n.jsxs(se.div,{whileHover:{x:2},transition:{duration:.1,ease:$t},className:"flex w-full items-center gap-2",children:[f&&n.jsx(f,{className:"size-4"}),n.jsx("span",{children:m.data.label})]})})}}}function uC({term:e,isScoped:t=!1,onSelect:s}){return n.jsxs(Ae,{value:"search-messages-handoff",onSelect:s,className:"flex items-center gap-2 py-2",children:[n.jsx(Es,{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 fi=8;function mC({staggerKey:e,isZeroQuery:t,isRoomMode:s,scope:r,hasQuery:o,selectedCwd:a,selectedValue:i,continueRows:c,recent:d,newActions:l,bestMatch:m,rows:h,rooms:p,searchHandoff:f,onFeatureAction:g,onQuickAction:x,onGoToAgentActions:y,onRoomSelect:b,onSessionSelect:C,onCommandSelect:S,onPageSelect:I}){const v=s?p.isError?"Couldn’t load your channels.":p.isLoading?"Loading channels…":p.channels.length===0?"No channels yet.":null:null,E=L0(h,_=>r?ti(r):aC[_.item.item.type]),R=r&&!o&&h.length===0&&!m?pS(r):null,M=new Set(h.slice(0,m?fi-1:fi).map(_=>_.key)),O={selectedCwd:a,selectedValue:i,onFeatureAction:g,onQuickAction:x,onGoToAgentActions:y,onRoomSelect:b,onSessionSelect:C,onCommandSelect:S,onPageSelect:I};return n.jsxs(se.div,{variants:lC,initial:"hidden",animate:"visible",children:[t&&n.jsx(dC,{continueRows:c,recent:d,newActions:l,selectedCwd:a,selectedValue:i,onSessionSelect:C,onRoomSelect:b,onGoToAgentActions:y,onQuickAction:x}),!t&&m&&n.jsx(nt,{heading:iC,children:n.jsx(se.div,{variants:En,children:n.jsx(hi,{row:m,...O})})}),!t&&E.map((_,D)=>n.jsx(nt,{heading:_.label,children:_.rows.map(k=>n.jsx(se.div,{variants:M.has(k.key)?En:void 0,children:n.jsx(hi,{row:k,...O})},k.key))},`${_.label}-${D}`)),R&&n.jsx(nt,{heading:r?ti(r):void 0,children:n.jsx(Ae,{disabled:!0,value:"scope-status",className:"text-muted-foreground text-sm",children:R})}),v&&n.jsx(nt,{heading:"Channels",children:n.jsx(Ae,{disabled:!0,value:"rooms-status",className:"text-muted-foreground text-sm",children:v})}),f&&n.jsx(nt,{children:n.jsx(uC,{term:f.term,isScoped:f.isScoped,onSelect:f.onSelect})}),t&&n.jsxs(n.Fragment,{children:[n.jsx(sd,{}),n.jsx(fu,{})]})]},e)}function hC(e,t){const s=fb(),{dismissedIds:r}=ql(),o=P(a=>a.promoEnabled);return u.useMemo(()=>o?pb(gb.filter(a=>a.placements.includes(e)),s,r,t):[],[e,t,s,r,o])}const fC={initial:{opacity:0,y:12},animate:{opacity:1,y:0},exit:{opacity:0,scale:.95,transition:{duration:.15}}};function pC({promo:e}){const{activate:t,dialog:s}=xb(e),{dismissPromo:r}=ql(),o=ut(),a=e.content.icon;return n.jsxs(se.div,{variants:o?void 0:fC,layout:!o,className:"group/promo relative",children:[n.jsxs("button",{"data-slot":"promo-card-compact",onClick:t,className:"bg-sidebar-accent/40 text-sidebar-foreground/70 hover:bg-sidebar-accent/70 hover:text-sidebar-foreground focus-visible:ring-sidebar-ring flex w-full items-center gap-2 rounded-md py-1.5 pr-7 pl-2 text-left outline-hidden transition-colors duration-150 focus-visible:ring-2",children:[n.jsx("span",{className:"flex size-[18px] shrink-0 items-center justify-center",children:n.jsx(a,{className:"size-4"})}),n.jsxs("span",{className:"min-w-0 flex-1",children:[n.jsx("span",{className:"text-sidebar-foreground/90 text-control block truncate font-medium",children:e.content.title}),n.jsx("span",{className:"text-2xs block truncate",children:e.content.shortDescription})]}),n.jsx(Lc,{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(Be,{className:"size-3.5"})}),s]})}const gC=1;function xC(e){const[t]=hC(e,gC);return u.useMemo(()=>t===void 0?{id:"promo",show:!1,render:()=>null}:{id:`promo:${t.id}`,show:!0,render:()=>n.jsx(pC,{promo:t})},[t])}const bC=new Set(["downloading","downloaded","install-failed"]);function pi(e,t){return(e==null?void 0:e.state)==="install-failed"?t.state==="downloaded"&&Io(t.version,e.version)?t:e:bC.has(t.state)||t.state==="error"?t:e&&(e.state==="downloading"||e.state==="downloaded")?e:t}function yC(){var o;const e=typeof window<"u"&&!!((o=window.electronAPI)!=null&&o.onUpdateStatus),[t,s]=u.useState(null);u.useEffect(()=>{var c;const a=window.electronAPI;if(!(a!=null&&a.onUpdateStatus))return;const i=a.onUpdateStatus(d=>{s(l=>pi(l,d))});return(c=a.getUpdateStatus)==null||c.call(a).then(d=>{d&&s(l=>pi(l,d))}),i},[]);const r=u.useCallback(()=>{var a,i;(i=(a=window.electronAPI)==null?void 0:a.restartToUpdate)==null||i.call(a)},[]);return{isDesktop:e,status:t,restart:r}}const vC={darwin:Nr("/download/mac"),win32:Nr("/download/windows")},wC=Zr.site;function jC(){var t;const e=typeof window>"u"||(t=window.electronAPI)==null?void 0:t.platform;Et((e&&vC[e])??wC)}function kC(){const{data:e}=_e(),{isDesktop:t,status:s,restart:r}=yC(),o=qn(),a=e==null?void 0:e.version,i=(e==null?void 0:e.latestVersion)??null,c=u.useMemo(()=>(e==null?void 0:e.dismissedUpgradeVersions)??[],[e==null?void 0:e.dismissedUpgradeVersions]),d=u.useCallback(m=>{o.mutate({ui:{dismissedUpgradeVersions:[...c,m]}})},[c,o]),l=(e==null?void 0:e.serverRole)==="hub";return u.useMemo(()=>l?{kind:"none"}:t?(s==null?void 0:s.state)==="install-failed"?{kind:"desktop-install-failed",downloadFresh:jC}:(s==null?void 0:s.state)!=="downloaded"?{kind:"none"}:{kind:"desktop-restart",restart:r}:i!==null&&a!==void 0&&Io(i,a)&&!c.includes(i)?{kind:"command",latestVersion:i,dismiss:()=>d(i)}:{kind:"none"},[l,t,s,r,i,a,c,d])}const SC="npm update -g dorkos",CC="The update couldn’t install itself. Download a fresh copy. Your settings and agents stay put.",ur="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 NC(e,t,s){return t?"Command copied":s?"Couldn’t copy":`Update ready: v${e}`}function AC({update:e}){const{copied:t,failed:s,copy:r}=Bn(),o=u.useCallback(()=>{r(SC)},[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:ur,children:[n.jsx(Nb,{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:CC}),n.jsxs("button",{type:"button",onClick:e.downloadFresh,"aria-label":"Download a fresh copy of DorkOS",className:K(ur,"self-start"),children:[n.jsx(ef,{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:ur,children:[t?n.jsx(Xt,{className:"size-3"}):n.jsx(so,{className:"size-3"}),NC(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(Be,{className:"size-3"})})]})}function yu(){const{shouldShowGettingStarted:e,dismiss:t}=Zt(),s=kC(),r=jw(),o=Aw(),a=Pd(),i=xC("dashboard-sidebar"),c=vo(),d=[{id:"getting-started",show:e,render:()=>n.jsx(Sw,{onDismiss:t})},{id:"update",show:s.kind!=="none",render:()=>n.jsx(AC,{update:s})},{id:"identity-prompt",show:r.visible,render:()=>n.jsx(Ew,{prompt:r})},{id:"profile-prompt",show:o.visible,render:()=>n.jsx(Cw,{prompt:o})},{id:"official-space-offer",show:a.due&&!e,render:()=>n.jsx(Ol,{className:"bg-secondary/60 rounded-lg"})},{...i,show:i.show&&!a.pending}];return n.jsx(cb,{candidates:d,ready:c.settled})}const gi="dorkos-pinned-agents";function vu(){const{data:e}=_e(),t=Us(),{update:s}=Ks(),r=t.pinned.length,o=u.useRef(!1);u.useEffect(()=>{if(o.current||e===void 0)return;const a=localStorage.getItem(gi);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(gi)},[e,r,s])}function wu(e){return u.useMemo(()=>tf(e),[e])}const EC=6e4,IC=[];function ju(e,t){const s=Tc(e),r=s.read();return r!==e&&!t(r,e)?(s.write(e),e):r}function RC(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 TC(e,t){return e.length===t.length&&t.every((s,r)=>e[r]===s)}function mr(e){return ju(e,RC)}function DC(e){return ju(e,TC)}function OC(e,t){const s=De({select:p=>p.location.pathname}),r=sf(t,s),o=(r==null?void 0:r.extensionId)??null,a=(r==null?void 0:r.path)??null,i=to({strict:!1}),c=s==="/session"?i.session??null:null,d=rf(c),l=s==="/session"?(d==null?void 0:d.cwd)??i.dir??null:null,m=s==="/channels"?i.id??null:null,h=m===null?null:e(m);return u.useMemo(()=>c!==null?{kind:"session",sessionId:c,agentPath:l??"",cwd:l}:s==="/threads"?{kind:"command",commandId:"open-threads"}:s==="/team"?{kind:"command",commandId:"open-directory"}:o!==null&&a!==null?{kind:"add-on",extensionId:o,path:a}:m===null||h===null?null:{kind:"room",roomId:m,roomKind:h},[c,l,s,o,a,m,h])}function ku(){const e=yo(EC),t=vo(),s=Kc(nf),r=u.useMemo(()=>{var w;return((w=s.data)==null?void 0:w.sessions)??[]},[s.data]),o=Nt(Hc(w=>{const T={};for(const[F,$]of Object.entries(w.statuses))T[F]=$.lifecycle;return T})),a=u.useMemo(()=>Object.entries(o).filter(([,w])=>w==="streaming").map(([w])=>w),[o]),i=u.useMemo(()=>Object.entries(o).filter(([,w])=>w==="blocked").map(([w])=>w),[o]),c=Nt(u.useCallback(w=>w.statusCwds,[])),d=Ls(),l=u.useMemo(()=>{const w=d.data??[];return t.fleetKnown?w:w.filter(T=>T.kind!=="dm")},[d.data,t.fleetKnown]),m=mr(u.useMemo(()=>{const w={};for(const T of d.data??[]){const F=T.mentionCount??0;F>0&&(w[T.id]=F)}return w},[d.data])),h=po(),p=mr(u.useMemo(()=>{const w={};for(const[T,F]of Object.entries(h)){if(!T.startsWith("agent:"))continue;const $=Date.parse(F);Number.isNaN($)||(w[T.slice(6)]=$)}return w},[h])),g=Fs().data,x=DC(u.useMemo(()=>((g==null?void 0:g.agents)??[]).map(w=>w.projectPath),[g])),b=wo(x).data,{brokenPaths:C}=wx(),S=mr(Mx(x,C,p)),I=u.useMemo(()=>{var w;return((w=s.data)==null?void 0:w.agentActivity)??{}},[s.data]),v=t.fleetKnown?x:IC,E=u.useMemo(()=>v.map(w=>{const T=(b==null?void 0:b[w])??null,F=I[w],$=F===void 0?NaN:Date.parse(F);return{path:w,runtime:(T==null?void 0:T.runtime)??"claude-code",namespace:(T==null?void 0:T.namespace)??null,isSystem:(T==null?void 0:T.isSystem)??!1,lastActivityAt:Number.isNaN($)?null:$,attention:S[w]??"inactive"}}),[v,b,I,S]),R=u.useMemo(()=>el(v,b??{}),[v,b]),M=Us(),O=u.useMemo(()=>Nv(M),[M]),_=u.useMemo(()=>{const w=new Map;for(const T of l)w.set(T.id,T.kind==="dm"?"dm":"channel");return w},[l]),D=u.useMemo(()=>w=>_.get(w)??"channel",[_]),k=lo(),j=u.useMemo(()=>k.map(({id:w,extensionId:T,path:F,title:$})=>({id:w,extensionId:T,path:F,title:$})),[k]),N=OC(D,j);return u.useMemo(()=>({now:e,sessions:r,workingSessionIds:a,blockedSessionIds:i,liveSessionCwds:c,rooms:l,agents:E,displayNames:R,prefs:O,mentions:m,addOns:j,activeTarget:N}),[e,r,a,i,c,l,E,R,O,m,j,N])}const MC="Threads and Directory are pages. Drop it in a section.",_C="Add-ons lists extension pages only.";function Su(e){return e==="addons"?_C:MC}const Cu={channels:"Channels",dms:"Direct messages"};function xi(e){if(typeof e!="object"||e===null)return!1;const t=e.kind;if(t==="ungrouped"){const s=e.section;return s===void 0||typeof s=="string"&&s in Cu}if(t==="computed"){const s=e.section;return s==="top"||s==="addons"}return t==="group"&&typeof e.groupId=="string"}function PC(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 In(e){if(typeof e!="object"||e===null)return null;const t=e.type;if(t==="item"){const s=e.ref,r=e.container;return PC(s)&&xi(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 xi(s)?{type:"container",container:s}:null}return null}function Nu(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 Au(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 Yr(e,t){return e.findIndex(s=>of(s,t))}function bi(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=Yr(o.items,r);i>=0&&(a=i)}return{kind:"move-to-group",ref:t,groupId:s,toIndex:a}}function Yo(e,t,s){if(s===null)return{kind:"none"};if(t.type==="group"){if(s.type!=="group-header")return{kind:"none"};const c=e.groups.findIndex(l=>l.id===t.groupId),d=e.groups.findIndex(l=>l.id===s.groupId);return c<0||d<0||c===d?{kind:"none"}:{kind:"reorder-group",groupId:t.groupId,from:c,to:d}}const{ref:r,from:o}=t,{container:a,overRef:i}=Eu(s);if(a.kind==="computed")return{kind:"reject-computed-section",ref:r,section:a.section};if(o.kind==="group"){if(a.kind==="ungrouped")return{kind:"remove-from-group",ref:r};if(a.groupId!==o.groupId)return bi(e,r,a.groupId,i);const c=e.groups.find(m=>m.id===o.groupId);if(!c||c.sortMode!=="manual"||i===void 0)return{kind:"none"};const d=Yr(c.items,r),l=Yr(c.items,i);return d<0||l<0||d===l?{kind:"none"}:{kind:"reorder-within-group",groupId:o.groupId,ref:r,from:d,to:l}}return a.kind==="group"?bi(e,r,a.groupId,i):{kind:"none"}}function LC(e,t,s){switch(t.kind){case"none":case"reject-smart-group":case"reject-computed-section":return e;case"reorder-group":return lf(e,t.from,t.to);case"remove-from-group":return cf(e,{kind:"item",ref:t.ref},s);case"reorder-within-group":return oa(e,t.groupId,t.from,t.to);case"move-to-group":{const r=af(e,t.ref,t.groupId);if(t.toIndex===null)return r;const o=r.groups.find(a=>a.id===t.groupId);return o?oa(r,t.groupId,o.items.length-1,t.toIndex):r}}}function FC(e,t,s,r){return LC(e,Yo(e,t,s),r)}function $C(e,t){return e.type==="group"?`Picked up section ${t.groupName(e.groupId)}.`:`Picked up ${t.itemName(e.ref)}.`}function BC(e,t){switch(e.kind){case"reorder-group":return`Moved section ${t.groupName(e.groupId)}.`;case"move-to-group":return`Moved ${t.itemName(e.ref)} to ${t.groupName(e.groupId)}.`;case"remove-from-group":return`Moved ${t.itemName(e.ref)} out of its section.`;case"reorder-within-group":return`Reordered ${t.itemName(e.ref)} in ${t.groupName(e.groupId)}.`;case"reject-smart-group":return`Can’t move ${t.itemName(e.ref)} into ${t.groupName(e.groupId)}. Membership is rule-based. Edit rules instead.`;case"reject-computed-section":return`Can’t move ${t.itemName(e.ref)} there. ${Su(e.section)}`;case"none":return""}}function zC(e,t){if(e===null)return"";const{container:s}=Eu(e);switch(s.kind){case"ungrouped":return`Over ${Cu[s.section??"dms"]}.`;case"computed":return s.section==="addons"?"Over Add-ons.":"Over Threads and Directory.";case"group":return`Over ${t.groupName(s.groupId)}.`}}function UC(e){const t=r=>Nu(In(r.active.data.current)),s=r=>{var o;return Au(In((o=r.over)==null?void 0:o.data.current))};return{onDragStart:r=>{const o=t(r);return o?$C(o,e()):void 0},onDragOver:r=>{if(t(r))return zC(s(r),e())||void 0},onDragEnd:r=>{const o=t(r);if(!o)return;const a=e(),i=Yo(a.prefs,o,s(r));return i.kind==="none"?"Movement cancelled. Item returned to its place.":BC(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 KC({label:e}){const t=ut();return n.jsx(se.div,{initial:{scale:1},animate:{scale:t===!0?1:uf},transition:{duration:t===!0?0:df},className:"bg-sidebar border-sidebar-border text-sidebar-foreground shadow-floating flex items-center rounded-md border px-2.5 py-1.5 text-xs font-medium",children:e})}function HC(e){const t=e.defaultView;if(t===null)return;const s=[],r=a=>{a.preventDefault(),a.stopImmediatePropagation(),s.push(a)};t.addEventListener("keydown",r,!0);const o=()=>{const a=s.shift();if(a===void 0)return;(a.target instanceof t.Node?a.target:e).dispatchEvent(new t.KeyboardEvent("keydown",{key:a.key,code:a.code,altKey:a.altKey,ctrlKey:a.ctrlKey,metaKey:a.metaKey,shiftKey:a.shiftKey,repeat:a.repeat,bubbles:!0,cancelable:!0,composed:!0})),s.length>0&&t.setTimeout(o)};t.setTimeout(()=>{t.setTimeout(()=>{t.removeEventListener("keydown",r,!0),o()})})}const WC=60;function GC(e){const t=document.querySelectorAll(`[${aa}]`);for(const s of t)if(s.getAttribute(aa)===e)return s.querySelector(`[${mf}]`);return null}function qC(e,t=WC){let s=t;const r=()=>{const o=GC(e);if(o!==null){o.focus();return}s-- >0&&requestAnimationFrame(r)};requestAnimationFrame(r)}const YC={start:["Space"],cancel:["Escape"],end:["Space","Enter","Tab"]};function VC(e){switch(e.kind){case"move-to-group":return ia(e.groupId,e.ref);case"remove-from-group":return ia("ungrouped",e.ref);default:return null}}function QC({data:e,itemName:t,groupName:s}){const r=e.type==="group"?s(e.groupId):e.type==="item"?t(e.ref):"";return n.jsx(KC,{label:r})}function XC({children:e,displayNames:t,rooms:s}){const r=Pe(),o=Us(),{update:a}=Ks(),[i,c]=u.useState(null),d=Lt(o),l=Lt(t),m=u.useMemo(()=>Object.fromEntries(s.map(I=>[I.id,I.slug??I.title])),[s]),h=Lt(m),p=u.useMemo(()=>hf(s),[s]),f=Lt(p),g=Dc(ps(_c,{activationConstraint:{distance:8}}),ps(Mc,{coordinateGetter:Cr,keyboardCodes:YC}));if(r)return n.jsx(n.Fragment,{children:e});const x=I=>{var v;return((v=d.read().groups.find(E=>E.id===I))==null?void 0:v.name)??"group"},y=I=>I.kind==="agent"?l.read()[I.path]??I.path.split("/").pop()??"Agent":h.read()[I.roomId]??"room",b=UC(()=>({prefs:d.read(),itemName:y,groupName:x})),C=I=>{if(I.activatorEvent instanceof KeyboardEvent&&I.activatorEvent.target instanceof Node){const v=I.activatorEvent.target.ownerDocument;v!==null&&HC(v)}c(In(I.active.data.current))},S=I=>{var O;c(null);const v=Nu(In(I.active.data.current));if(v===null)return;const E=Au(In((O=I.over)==null?void 0:O.data.current)),R=Yo(d.read(),v,E);if(R.kind==="reject-smart-group"){ce.info("Membership is rule-based. Edit rules instead.",{description:x(R.groupId)});return}if(R.kind==="reject-computed-section"){ce.info(Su(R.section),{description:y(R.ref)});return}if(R.kind==="none"||(a(_=>FC(_,v,E,f.read())),!(I.activatorEvent instanceof KeyboardEvent)))return;const M=VC(R);M!==null&&qC(M)};return n.jsx(ff,{value:!0,children:n.jsxs(Oc,{sensors:g,collisionDetection:Ic,accessibility:{announcements:b},onDragStart:C,onDragEnd:S,onDragCancel:()=>c(null),children:[e,n.jsx(pf,{children:i?n.jsx(QC,{data:i,itemName:y,groupName:x}):null})]})})}const JC='[aria-current="page"]';function ZC(e,t,s){const r=ut(),o=u.useRef(null);u.useLayoutEffect(()=>{var l,m;if(!s)return;const a=o.current===null,i=((l=o.current)==null?void 0:l.key)??null;if(o.current={key:t},!a&&(i===t||t===null)||t===null)return;const c=(m=e.current)==null?void 0:m.querySelector(JC);if(!(c instanceof HTMLElement))return;const d=!a&&r!==!0;c.scrollIntoView({block:"nearest",behavior:d?"smooth":"auto"})},[t,e,s])}function eN(e){const t=new Map;for(const s of e)s.rows.forEach((r,o)=>{t.set(r.key,{sectionId:s.id,index:o,row:r})});return t}function tN(e,t){const s=new Set(e.map(c=>c.id)),r=new Map,o=new Map;for(const c of e)for(const d of c.rows)r.set(d.key,d),o.set(d.key,c.id);const a=new Map;for(const[c,d]of t){if(d.row.target.kind==="command"||o.get(c)===d.sectionId||!s.has(d.sectionId))continue;const l=a.get(d.sectionId)??[];l.push({index:d.index,row:r.get(c)??d.row}),a.set(d.sectionId,l)}const i=new Set([...a.values()].flat().map(c=>c.row.key));return i.size===0?e:e.map(c=>{const d=a.get(c.id)??[],l=c.rows.filter(h=>!i.has(h.key));if(d.length===0&&l.length===c.rows.length)return c;const m=[...l];for(const h of[...d].sort((p,f)=>p.index-f.index))m.splice(Math.min(h.index,m.length),0,h.row);return{...c,rows:m}})}function nN(){const[e,t]=u.useState(!1),[s,r]=u.useState(!1),o=u.useCallback(()=>t(!0),[]),a=u.useCallback(()=>t(!1),[]),i=u.useCallback(()=>r(!0),[]),c=u.useCallback(d=>{const l=d.relatedTarget;(l===null||!d.currentTarget.contains(l))&&r(!1)},[]);return{inside:e||s,handlers:{onPointerEnter:o,onPointerLeave:a,onFocus:i,onBlur:c}}}function sN(e,t,s){const[r,o]=u.useState(null);!t&&r!==null&&o(null),t&&(r===null||r.key!==s)&&o({held:eN(e),key:s});const a=t?(r==null?void 0:r.held)??null:null;return u.useMemo(()=>a===null?e:tN(e,a),[e,a])}const rN=[2,3,3],yi=["w-14","w-10","w-16"];function oN(){return n.jsx("div",{className:"flex flex-col gap-1","data-testid":"sidebar-skeleton","aria-hidden":!0,children:rN.map((e,t)=>n.jsxs("div",{className:"flex flex-col",children:[n.jsx("div",{className:K("flex h-7 items-center",gf),children:n.jsx(dt,{className:K("h-2.5 rounded-sm",yi[t])})}),Array.from({length:e},(s,r)=>n.jsx(xf,{showIcon:!0},r))]},yi[t]))})}const aN=.16,iN=4,cN=.03,lN={hidden:{},shown:{transition:{staggerChildren:cN}}},dN={hidden:{opacity:0,y:iN},shown:{opacity:1,y:0}};function vi(e){return{duration:e===!0?0:aN}}function uN(){var r;const e=Hs(!0),t=zn();if(!t.community)return null;if(e.isPending)return n.jsx("p",{role:"status",className:"text-muted-foreground px-3 py-2 text-xs",children:"Loading space…"});if(e.isError)return n.jsxs("p",{role:"status",className:"text-muted-foreground px-3 py-2 text-xs",children:["Spaces could not be loaded."," ",n.jsx(L,{variant:"ghost",size:"sm",onClick:()=>void e.refetch(),children:"Retry"})]});const s=(r=e.data)==null?void 0:r.find(({ref:o})=>o===t.community);return s?s.status!=="connected"?n.jsx("p",{role:"status",className:"text-muted-foreground px-3 py-2 text-xs",children:"Reconnect this space to open its channels."}):n.jsx(mN,{connection:s}):n.jsx("p",{role:"status",className:"text-muted-foreground px-3 py-2 text-xs",children:"This space is no longer connected."})}function mN({connection:e}){var o,a,i;const t=tl(e.access),s=bf(e.ref,t.capabilities.read,t.fingerprint),r=zn();return n.jsxs("section",{"aria-label":e.label,className:"px-2 py-2",children:[n.jsx("h3",{className:"text-muted-foreground px-2 text-xs font-medium",children:e.label}),!t.cacheReadable&&n.jsx("p",{role:"status",className:"text-muted-foreground px-2 py-1 text-xs",children:e.status==="reconnect-required"?"Reconnect to view channels.":"Channels aren’t available."}),t.cacheReadable&&!t.verified&&n.jsx("p",{role:"status",className:"text-muted-foreground px-2 py-1 text-xs",children:"Saved channels"}),t.verified&&s.isPending&&n.jsx("p",{role:"status",className:"text-muted-foreground px-2 py-1 text-xs",children:"Loading channels…"}),t.verified&&s.isError&&n.jsxs("p",{role:"status",className:"text-muted-foreground px-2 py-1 text-xs",children:["Space unavailable."," ",n.jsx(L,{variant:"ghost",size:"sm",onClick:()=>void s.refetch(),children:"Retry"})]}),((o=s.data)==null?void 0:o.stale)&&n.jsx("p",{className:"text-muted-foreground px-2 text-xs",children:"Saved channels · offline"}),(a=s.data)==null?void 0:a.rooms.filter(c=>!c.archived).map(c=>n.jsx(nl,{...ve.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:K("truncate",c.unreadCount!==null&&c.unreadCount>0&&"font-semibold"),children:["#",c.slug??c.title,c.unreadCount!==null&&c.unreadCount>0&&n.jsx("span",{className:"sr-only",children:", unread messages"})]})},c.roomId)),((i=s.data)==null?void 0:i.rooms.length)===0&&n.jsx("p",{className:"text-muted-foreground px-2 py-1 text-xs",children:"No channels available."}),t.verified&&n.jsx(hN,{connection:e})]})}function hN({connection:e}){var o;const t=tl(e.access),s=yf(e.ref,t.capabilities.read,t.fingerprint),r=zn();return!((o=s.data)!=null&&o.available)||s.data.dms.length===0&&!s.data.incomplete?null:n.jsxs("section",{className:"mt-2","aria-label":"Direct messages",children:[n.jsx("h4",{className:"text-muted-foreground px-2 text-xs font-medium",children:"Direct messages"}),s.data.dms.map(a=>n.jsxs(nl,{...ve.channels(),search:{community:e.ref,id:a.roomId},"aria-current":r.community===e.ref&&r.id===a.roomId?"page":void 0,className:"hover:bg-accent aria-[current=page]:bg-accent flex min-h-9 items-center justify-between gap-2 rounded-md px-2 py-1 text-sm",children:[n.jsxs("span",{className:"truncate",children:[vf(a),a.readOnly&&n.jsx("span",{className:"text-muted-foreground",children:" · read-only"})]}),!a.readOnly&&n.jsx(zs,{count:a.unreadCount,label:`${a.unreadCount>Nn?`More than ${Nn}`:a.unreadCount} unread messages`})]},a.roomId)),s.data.incomplete&&n.jsx("p",{role:"status",className:"text-muted-foreground px-2 py-1 text-xs",children:"Some direct messages couldn’t load."})]})}const fN=1,wi=40;function pN({onCommit:e,onCancel:t}){const[s,r]=u.useState(""),o=u.useRef(null),a=u.useRef(!1),i=wf(o);u.useEffect(()=>{var l;(l=o.current)==null||l.focus()},[]);const c=()=>{if(a.current)return;a.current=!0;const l=s.trim();if(l.length<fN||l.length>wi){t();return}e(l)},d=l=>{l.key==="Enter"?(l.preventDefault(),c()):l.key==="Escape"&&(l.preventDefault(),a.current=!0,t())};return n.jsx(jf,{children:n.jsxs("div",{className:"flex w-full items-center gap-2 rounded-md px-2 py-1.5",children:[n.jsx(kf,{className:"text-muted-foreground size-3.5 shrink-0"}),n.jsx("input",{ref:o,value:s,maxLength:wi,placeholder:"Section name","aria-label":"New section name",onChange:l=>r(l.target.value),onKeyDown:d,onBlur:l=>{i.shouldHandleBlur(l)&&(a.current||t())},className:K("bg-background text-foreground placeholder:text-muted-foreground/50","focus-visible:ring-ring min-w-0 flex-1 rounded border px-1.5 py-0.5 text-xs outline-none focus-visible:ring-1")})]})})}function gN(e){return e.collapsible?e.id.startsWith("group:")||ol(e.id)!==null:!1}function Iu({model:e}){const{update:t}=Ks(),s=Us(),{inside:r,handlers:o}=nN(),a=sN(e.sections,r,s),i=Sf(),c=xs(i.destination),l=sl(c??void 0).visible?c:null,m=vo(),h=ut(),p=rl(),f=u.useRef(null),g=p.activeTarget===null?null:Cf(p.activeTarget);ZC(f,g,m.settled);const x=e.sections.filter(gN),y=u.useCallback(()=>{if(x.length===0)return;const v=x.some(E=>!E.collapsed);t(E=>{let R=E;for(const M of x){if(M.id.startsWith("group:")){R=Nf(R,M.id.slice(6),v);continue}const O=ol(M.id);O!==null&&(R=ca(R,O,v))}return R})},[x,t]),b=e.sections.find(v=>v.id==="addons"),C=(b==null?void 0:b.collapsed)??!1,S=u.useCallback(()=>t(v=>ca(v,"addons",!C)),[C,t]),I={variants:dN,transition:vi(h)};return l?n.jsxs("div",{className:"flex min-h-0 flex-col","data-community-context":l,children:[n.jsx(uN,{}),b!==void 0&&n.jsx(la,{section:b,onToggleAll:S})]}):n.jsx("div",{ref:f,className:"flex flex-col gap-1",...o,children:n.jsx(Ye,{mode:"wait",initial:!1,children:m.phase==="cold"?n.jsx(se.div,{exit:{opacity:0},transition:vi(h),children:n.jsx(oN,{})},"skeleton"):n.jsx(se.div,{className:"flex flex-col gap-1",variants:lN,initial:m.startedWarm?!1:"hidden",animate:"shown",children:n.jsx(al,{id:"sidebar-sections",children:a.map(v=>n.jsxs(se.div,{...I,children:[n.jsx(la,{section:v,onToggleAll:y}),v.id==="top"&&n.jsx(xN,{})]},v.id))})},"sections")})})}function xN(){const e=rl();return e.groupCreation===null?null:n.jsx(Af,{children:n.jsx(pN,{onCommit:e.commitNewGroup,onCancel:e.cancelNewGroup})})}const ji="flex min-h-0 flex-1 flex-col";function bN(){vu();const e=ku(),t=wu(e),s=Ef(),r=n.jsxs(n.Fragment,{children:[n.jsx(If,{className:"sidebar-scroll-edges px-2 py-3",children:n.jsx(il,{activeTarget:e.activeTarget,children:n.jsx(XC,{displayNames:e.displayNames,rooms:e.rooms,children:n.jsx(Iu,{model:t})})})}),n.jsx(yu,{})]});return s?n.jsx("div",{className:ji,children:r}):n.jsx(cl,{className:ji,children:r})}const yN=2;function vN(){return{label:"Active now",rules:{statuses:["needs-attention","active"]}}}function wN(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>=yN).map(([s,r])=>({runtime:s,count:r,label:ct(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 ki="agent:";function jN(){const[e]=$s(),t=po(),{data:s}=Fs(),r=u.useMemo(()=>((s==null?void 0:s.agents)??[]).map(i=>i.projectPath),[s]),{data:o}=wo(r),a=u.useMemo(()=>el(r,o??{}),[r,o]);return u.useMemo(()=>{const i=new Set(r);let c=null,d=-1/0;for(const[m,h]of Object.entries(t)){if(!m.startsWith(ki))continue;const p=m.slice(ki.length);if(!i.has(p))continue;const f=Date.parse(h);Number.isNaN(f)||f<=d||(d=f,c=p)}const l=e!==null&&i.has(e)?e:c;return l===null?null:{path:l,displayName:a[l]??l}},[a,t,r,e])}function kN(e){u.useEffect(()=>{if(!$e())return;const t=s=>{!(s.metaKey||s.ctrlKey)||s.shiftKey||s.altKey||s.key.toLowerCase()==="n"&&(s.preventDefault(),e())};return document.addEventListener("keydown",t),()=>document.removeEventListener("keydown",t)},[e])}function SN(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:vn,opensInput:!1,run:()=>e.onCreatePresetSmartGroup(r)})),{kind:"action",id:"new-group-custom",label:"Custom rules",icon:vn,opensInput:!0,run:e.onOpenSmartGroupDialog}],s=[t.length===0?{kind:"action",id:"new-group",label:"Section",icon:vn,opensInput:!0,run:e.onNewGroup}:{kind:"submenu",id:"new-group",label:"Section",icon:vn,items:[{kind:"action",id:"new-group-empty",label:"Empty section",icon:vn,opensInput:!0,run:e.onNewGroup},...t]}];return[{kind:"action",id:"new-session",label:"Chat",icon:Zc,opensInput:!1,...e.showSessionShortcut?{hint:Ht(an.NEW_SESSION)}:{},run:e.onNewSession},...e.lastUsedAgentName===null?[]:[{kind:"note",id:"new-session-note",icon:Db,text:`Starts with ${e.lastUsedAgentName} (last used)`}],{kind:"separator",id:"sep-rooms"},{kind:"action",id:"new-channel",label:"Channel",icon:dl,opensInput:!0,run:e.onNewChannel},{kind:"action",id:"new-message",label:"Group message",icon:Ql,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 CN(){const e=Pe(),t=Qn(T=>T.menuOpen),s=Qn(T=>T.preselect),r=Qn(T=>T.setMenuOpen),o=Qn(T=>T.requestNewGroup),a=Me(),i=Vc(),c=Ab(),d=Yc(),l=jN(),{update:m}=Ks(),[h,p]=u.useState(!1),[f,g]=u.useState(!1),[x,y]=u.useState(!1),{data:b}=Fs(),C=u.useMemo(()=>((b==null?void 0:b.agents)??[]).map(T=>T.projectPath),[b]),{data:S}=wo(C),I=u.useMemo(()=>C.map(T=>{var F,$;return{projectPath:T,runtime:((F=S==null?void 0:S[T])==null?void 0:F.runtime)??"claude-code",namespace:(($=S==null?void 0:S[T])==null?void 0:$.namespace)??null,attention:"inactive",lastActivityAt:null}}),[C,S]),v=Rf(I),E=u.useMemo(()=>v?[vN(),...wN(I)]:[],[I,v]),R=u.useMemo(()=>{const T=new Map;for(const F of I)T.has(F.runtime)||T.set(F.runtime,ct(F.runtime).label);return Array.from(T,([F,$])=>({value:F,label:$})).sort((F,$)=>F.label.localeCompare($.label))},[I]),M=u.useMemo(()=>{const T=new Set;for(const F of I)F.namespace&&T.add(F.namespace);return Array.from(T).sort()},[I]),O=u.useCallback((T,F)=>m($=>Tf($,T,F).next),[m]),_=u.useCallback(T=>{gs.getState().recordOpened("room",T.id),a({...ve.channels(),search:{id:T.id}})},[a]),D=u.useCallback(()=>i(l==null?void 0:l.path),[l,i]);kN(D);const k=u.useCallback(T=>{const[F]=T;if(F!==void 0&&Eb(T)){gs.getState().recordOpened("agent",F.agentPath),d({agentPath:F.agentPath});return}const $=Df(T.map(W=>W.displayName));c.mutate({agentPaths:T.map(W=>W.agentPath),title:$},{onSuccess:_})},[d,_,c]),j=SN({onNewSession:D,lastUsedAgentName:(l==null?void 0:l.displayName)??null,onNewChannel:()=>p(!0),onNewMessage:()=>g(!0),onNewAgent:()=>Is.getState().open(),onNewGroup:()=>o(),smartGroupPresets:E,onCreatePresetSmartGroup:T=>O(T.label,T.rules),onOpenSmartGroupDialog:()=>y(!0),showSessionShortcut:$e()}),N=ll(j),w=u.useRef(null);return u.useEffect(()=>{if(!t||s===null)return;const T=requestAnimationFrame(()=>{var F,$;($=(F=w.current)==null?void 0:F.querySelector(`[data-menu-item-id="${s}"]`))==null||$.focus()});return()=>cancelAnimationFrame(T)},[t,s]),n.jsxs(n.Fragment,{children:[n.jsxs(Ds,{open:t,onOpenChange:r,children:[n.jsx(Os,{asChild:!0,children:n.jsxs("button",{type:"button","data-testid":"sidebar-new-button",className:K("bg-sidebar-accent text-sidebar-accent-foreground hover:bg-sidebar-accent/70 focus-visible:ring-sidebar-ring flex shrink-0 items-center gap-1 rounded-md px-2 py-1 text-xs font-medium outline-hidden transition-colors duration-150 focus-visible:ring-2",e&&K(Ws,"px-3")),children:[n.jsx(Rt,{className:"size-3.5"}),"New"]})}),n.jsx(Ms,{ref:w,align:"end",className:"w-56",onCloseAutoFocus:N.onCloseAutoFocus,children:n.jsx(Ar,{variant:"dropdown",nodes:N.nodes})})]}),h&&n.jsx(Ib,{open:!0,onOpenChange:T=>!T&&p(!1),onCreated:_}),n.jsx(Rb,{open:f,onOpenChange:g,onStart:k,hideTrigger:!0}),n.jsx(Of,{open:x,onOpenChange:y,mode:"create",runtimeOptions:R,namespaceOptions:M,onSubmit:({name:T,rules:F})=>O(T,F)})]})}function NN(){const e=P(s=>s.setGlobalPaletteOpen),t=Pe();return n.jsxs("button",{type:"button","data-testid":"sidebar-search-pill",onClick:()=>e(!0),className:K("bg-sidebar-accent/40 text-sidebar-foreground/60 hover:bg-sidebar-accent/70 hover:text-sidebar-foreground focus-visible:ring-sidebar-ring text-control flex w-full items-center gap-1.5 rounded-md px-2 py-1.5 outline-hidden transition-colors duration-150 focus-visible:ring-2",t&&Ws),children:[n.jsx(hs,{className:"size-(--size-icon-sm) shrink-0"}),n.jsx("span",{className:"truncate",children:"Find a conversation…"}),n.jsx(ul,{className:"bg-sidebar-accent text-sidebar-foreground/70 ml-auto shrink-0 border-transparent",children:Ht(an.COMMAND_PALETTE)})]})}function AN(e){const t=[];return e.you!==null&&t.push({kind:"action",id:"you",label:e.you.name,description:"View profile",icon:ao,leading:e.you.face,guardsFocus:!0,run:e.you.onOpen}),t.push({kind:"action",id:"dorkos-account",label:"DorkOS account",description:e.accountStatus,icon:Bl,guardsFocus:!0,run:e.onOpenAccount},{kind:"action",id:"settings",label:"Settings",icon:Bs,guardsFocus:!0,run:e.onOpenSettings}),t}function EN(e){return e.isDevMode?[{kind:"separator",id:"sep-version"},{kind:"note",id:"version",icon:da,text:"Development build"}]:e.version===null?[]:[{kind:"separator",id:"sep-version"},{kind:"action",id:"version",label:`v${e.version} beta`,icon:da,opensInput:!1,hint:"Check for updates",run:e.onCheckForUpdates}]}function IN(e){const t=(e==null?void 0:e.trim())??"";return t.length===0||t===_f?"Your team":t.endsWith("s")?`${t}’ team`:`${t}’s team`}function RN(e,t){const s=Pf(e);return u.createElement(ms,{size:t,kind:s.kind,color:s.color,emoji:s.emoji,imageUrl:s.imageUrl,fallback:s.fallback,origin:s.origin})}function Ru(e="xs"){var i;const t=ro(),{open:s}=at(),{open:r}=jo(),o=hS(),a=((i=t.data)==null?void 0:i.members.find(c=>c.isSelf))??null;return{you:a===null?null:{name:a.displayName,face:RN(a,e),onOpen:()=>r(a.id)},accountStatus:mS(o),onOpenAccount:()=>s("account"),onOpenSettings:()=>s()}}function TN(e=[]){var l;const t=ro(),s=ae(),r=le(),o=Ru(),a=((l=t.data)==null?void 0:l.members.find(m=>m.isSelf))??null,{data:i,refetch:c}=Ee({queryKey:Fe.current(),queryFn:()=>s.getConfig(),staleTime:oc}),d=u.useCallback(async()=>{var f,g;await r.invalidateQueries({queryKey:Fe.all});const m=await c(),h=(f=m.data)==null?void 0:f.version,p=((g=m.data)==null?void 0:g.latestVersion)??null;if(h===void 0){ce.error("Couldn’t check for updates");return}if(p!==null&&Io(p,h)){ce.success(`Version ${p} is available`);return}ce.success("You’re up to date")},[r,c]);return{teamName:IN((a==null?void 0:a.displayName)??null),nameUnknown:t.isPending,identityNodes:AN(o),nodes:[...e,...EN({version:(i==null?void 0:i.version)??null,isDevMode:(i==null?void 0:i.isDevMode)??!1,onCheckForUpdates:()=>void d()})]}}const DN=ml("/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 MN(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 es(e){try{return new URL(e).host}catch{return e}}function _N(e){const t=[],s=e.selected;if(s){const{connection:i,availability:c}=s,d=[],l={host:es(i.pinnedOrigin)};c.canInvite&&d.push({kind:"action",id:"community-invite",label:"Invite people",icon:Ff,external:l,run:e.onInvite}),c.canOpenSettings&&d.push({kind:"action",id:"community-settings",label:"Space settings",icon:Bs,external:l,run:e.onOpenSettings}),s.canMoveUp&&d.push({kind:"action",id:"community-move-up",label:"Move up",icon:$f,run:()=>e.onMove("up")}),s.canMoveDown&&d.push({kind:"action",id:"community-move-down",label:"Move down",icon:Bf,run:()=>e.onMove("down")}),d.push({kind:"separator",id:"community-sep-end"}),d.push({kind:"action",id:"community-disconnect",label:"Disconnect",icon:Pb,opensInput:!0,destructive:!0,run:e.onDisconnect}),c.canLeave&&d.push({kind:"action",id:"community-leave",label:"Leave space",icon:zf,opensInput:!0,external:l,run:e.onLeave}),t.push({kind:"submenu",id:"community-actions",label:`Manage ${i.label}`,icon:Tr,items:d})}e.onJoinOfficial&&t.push({kind:"action",id:"join-official-space",label:"Join the DorkOS community",icon:Er,opensInput:!0,run:e.onJoinOfficial});const r=e.onJoin;if(!r)return t;const o=[...e.creationOrigins.map(i=>({kind:"action",id:e.creationOrigins.length===1?"add-community-create":`add-community-create-${es(i)}`,label:e.creationOrigins.length===1?"Create a space on your server":`Create a space on ${es(i)}`,icon:ly,opensInput:!0,external:{host:es(i)},run:()=>e.onCreate(i)})),{kind:"action",id:"add-community-deploy",label:"Run your own space server",icon:Lf,run:e.onDeploy}],a=[];return e.hosting&&a.push({kind:"action",id:"add-community-start",label:"Start a space",icon:ko,opensInput:!0,run:e.hosting.onStart}),a.push({kind:"action",id:"add-community-join",label:"Join a space",icon:Er,opensInput:!0,run:r}),e.hosting&&a.push({kind:"action",id:"add-community-yours",label:"Your spaces",icon:ay,guardsFocus:!0,run:e.hosting.onOpenYourSpaces}),a.push({kind:"separator",id:"add-community-sep-advanced"},{kind:"submenu",id:"add-community-advanced",label:"Advanced",icon:Xl,items:o}),t.push({kind:"submenu",id:"add-community",label:"Add a space",icon:Rt,items:a}),t}function Tu(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 PN(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=Tu(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 FN(e){return e.charAt(0).toLowerCase()+e.slice(1)}function $N(e,t){const s=Uf(),r=sl(e),o=Dl();return{spaces:s.enabled,anySpace:s.anySpace,selectedRef:r.visible?e:void 0,visible:(t??[]).filter(a=>Kf(a,s.enabled)),joinOfficial:o.link!==null&&!o.joined?o.join:null}}function BN(e){const t=ua(r=>r.url),s=ua(r=>r.take);u.useEffect(()=>{if(t===null)return;const r=s();r!==null&&e(r)},[t,s])}function zN({connection:e,onOpenChange:t,onDisconnected:s}){var p;const r=hl(),o=Ad(e),[a,i]=u.useState(e);e!==null&&e!==a&&i(e);const c=(a==null?void 0:a.label)??"this space",d=(a==null?void 0:a.status)==="pending"?[]:(p=o.data)==null?void 0:p.agents,l=d===void 0&&o.fetchStatus==="fetching",m=d?Id(c,d):l?null:Rd(c);function h(){e&&r.mutate(e,{onSuccess:f=>{t(!1);const g=Td(e.label,f);g.tone==="success"?ce.success(g.message):ce.warning(g.message,{duration:15e3}),s(e)}})}return n.jsx(Hf,{open:e!==null,onOpenChange:f=>{f||r.reset(),t(f)},children:n.jsxs(Wf,{children:[n.jsxs(Gf,{children:[n.jsxs(qf,{children:["Disconnect this DorkOS from ",c,"?"]}),n.jsx(Yf,{asChild:!0,children:n.jsxs("div",{className:"space-y-2",children:[n.jsxs("p",{children:["Its channels leave this app. You stay a member of ",c,"."]}),n.jsx("p",{children:"You can connect again later."}),m&&n.jsx("p",{className:"text-foreground",children:m}),l&&n.jsx("p",{children:"Checking for agents you added from here…"})]})})]}),o.isError&&d===void 0&&!l&&n.jsxs("div",{role:"alert",className:"flex flex-col items-start gap-2 text-sm sm:flex-row sm:items-center sm:justify-between sm:gap-3",children:[n.jsxs("p",{className:"text-destructive",children:["Couldn’t check which of your agents are on ",c,"."]}),n.jsx(L,{size:"sm",variant:"outline",onClick:()=>void o.refetch(),children:"Check again"})]}),r.isError&&n.jsx("p",{role:"alert",className:"text-destructive text-sm",children:"Couldn’t disconnect. Check DorkOS is running and try again."}),n.jsxs(Vf,{children:[n.jsx(Qf,{disabled:r.isPending,children:"Keep connected"}),n.jsx(L,{variant:"destructive",disabled:r.isPending||l,onClick:h,children:r.isPending?"Disconnecting…":"Disconnect"})]})]})})}function UN(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 ${HN(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 ${Xf((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 KN(e){const t=typeof e=="object"&&e!==null?e.code:"";return t!=="COMMUNITY_RATE_LIMITED"&&t!=="COMMUNITY_UPGRADE_REQUIRED"}function HN(e){try{return`${new URL(e??"").origin}/your-space`}catch{return"https://example.com/acme"}}const WN="That invitation link is incomplete or isn’t secure. Copy the whole link again.";function GN(e){let t;try{t=new URL(e.trim())}catch{return!1}return/^\/(?:c\/[^/]+\/)?join\/?$/u.test(t.pathname)&&!Ir(e)}function qN(e){const t=new URL(e.trim()),s=/^(\/c\/[^/]+)\/join\/?$/u.exec(t.pathname);return s?`${t.origin}${s[1]}`:t.origin}function YN({request:e,onOpenChange:t,installName:s,onConnected:r}){var F;const o=$n(!0),a=Hs(!0),i=Jf(o),c=e!==null,d=Xs($=>$.links),l=Xs($=>$.rememberLink),m=Xs($=>$.ending),h=(o==null?void 0:o.ownerKey)??null,[p,f]=u.useState(null),g=$=>f($===null?null:{owner:h,ref:$}),[x,y]=u.useState(null),[b,C]=u.useState(null),[S,I]=u.useState((m==null?void 0:m.id)??0),[v,E]=u.useState(null),[R,M]=u.useState(null);e!==R&&(M(e),e&&(g(e.ref),y(null))),p!==null&&h!==null&&p.owner!==h&&(p.owner===null?f({owner:h,ref:p.ref}):(f(null),y(null),E(null)));const O=p!==null&&p.owner===h?p.ref:null,_=O===null||(F=a.data)==null?void 0:F.find($=>$.ref===O),D=!_&&b!==null&&!b.settled&&b.address===i&&b.connection.ref===O?b.connection:null,k=_??D;if(k&&h!==null&&((v==null?void 0:v.owner)!==h||v.ref!==k.ref||v.label!==k.label)&&E({owner:h,ref:k.ref,label:k.label}),m&&m.id!==S)I(m.id),m.ref===O&&m.outcome!=="connected"&&(g(null),y({address:i,value:m.outcome==="expired"?`Approval for ${m.label} expired. Connect again to continue.`:`Approval for ${m.label} was cancelled.`}));else if(c&&O!==null&&!k&&a.isSuccess){const $=(v==null?void 0:v.owner)===h&&v.ref===O?v.label:"this space";g(null),y({address:i,value:`Approval for ${$} ended somewhere else. Connect again to continue.`})}Zf(c&&(k==null?void 0:k.status)==="pending"?k.ref:null);const j=ep((k==null?void 0:k.status)==="pending"?k:null),N=c&&(k==null?void 0:k.status)==="connected"?k.ref:null,w=u.useRef(r),T=u.useRef(t);return u.useEffect(()=>{w.current=r,T.current=t}),u.useEffect(()=>{N===null||!k||(ce.success(`${k.label} is connected.`,{id:`community-approval-${N}`}),T.current(!1),w.current(N))},[N]),n.jsx(bt,{open:c,onOpenChange:t,children:n.jsx(yt,{className:"!min-h-0 sm:max-w-md",children:n.jsx(VN,{authority:o,connection:k,check:j,approvalUrl:k&&(d==null?void 0:d.address)===i?d.urls[k.ref]:void 0,notice:(x==null?void 0:x.address)===i?x.value:"",installName:s,initialUrl:R==null?void 0:R.url,onStarted:$=>{l(i,$.connection.ref,$.approvalUrl),C({address:i,connection:$.connection,settled:!1}),g($.connection.ref),y({address:i,value:`Next, approve this DorkOS on ${$.connection.label}.`})},onStartSettled:$=>C(W=>(W==null?void 0:W.connection.ref)===$?{...W,settled:!0}:W),onEnded:$=>{g(null),y({address:i,value:$})},onCancelled:$=>{t(!1),ce.success(`Approval for ${$} was cancelled.`)},onClose:()=>t(!1)})})})}function VN({authority:e,connection:t,check:s,approvalUrl:r,notice:o,installName:a,initialUrl:i,onStarted:c,onStartSettled:d,onEnded:l,onCancelled:m,onClose:h}){const p=ae(),f=le(),g=$c(),x=u.useId(),[y,b]=u.useState(i??""),[C,S]=u.useState(null),[I,v]=u.useState(!1),[E,R]=u.useState(a),M=u.useRef(null),O=u.useRef(null),_=t===null?"form":t.status,D=u.useRef(_);u.useEffect(()=>{var Y,oe;const B=D.current;D.current=_,B!==_&&(_==="form"?(Y=M.current)==null||Y.focus():_==="pending"&&((oe=O.current)==null||oe.focus()))},[_]);const k=Vt({mutationFn:async B=>{if(!e||!Ft(e))throw new Error("Community owner is still loading.");const Y=await p.startCommunityConnection({url:B,installName:E.trim()});if(!Ft(e))throw new Error("Community owner changed.");return Y},onSuccess:async B=>{b(""),c(B),e&&await f.invalidateQueries({queryKey:Ct.connections(e)}),d(B.connection.ref)}}),j=hl(),N=Ad((t==null?void 0:t.status)==="reconnect-required"?t:null),w=k.error;u.useEffect(()=>{var B;(w||I)&&((B=M.current)==null||B.focus())},[w,I]);const T=Ir(y),F=I?WN:k.error?UN(k.error,k.variables):null;function $(B){if(B.preventDefault(),!(!y.trim()||k.isPending)){if(GN(y)){k.reset(),v(!0);return}if(Ir(y)){if(!Et(g.linkFor(y.trim())))return;b(qN(y)),S({host:new URL(y.trim()).host,withAccount:g.signsInWithAccount(y)}),k.reset();return}E.trim()&&k.mutate(y.trim())}}function W(B){j.mutate(B,{onSuccess:Y=>{if(B.status==="pending")m(B.label);else{const oe=Td(B.label,Y);l(oe.tone==="success"?`${B.label} is disconnected. Connect again to continue.`:oe.message)}},onSettled:()=>{e&&f.invalidateQueries({queryKey:Ct.connections(e)})}})}const X=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:$,children:[n.jsxs(ft,{children:[n.jsx(st,{children:"Join a space"}),n.jsx(pt,{children:"Bring a space’s channels here. You approve it on the space’s site."})]}),n.jsxs(At,{className:"space-y-4 py-4",children:[X,n.jsxs("div",{className:"space-y-1.5",children:[n.jsx(He,{htmlFor:`${x}-url`,children:"Space address or invitation link"}),n.jsx(xt,{ref:M,id:`${x}-url`,type:"url",inputMode:"url",placeholder:"https://example.com/acme","aria-describedby":F?`${x}-url-hint ${x}-url-error`:`${x}-url-hint`,"aria-invalid":I||k.error&&KN(k.error)?!0:void 0,required:!0,autoComplete:"off",value:y,onChange:B=>{b(B.target.value),S(null),v(!1)},disabled:k.isPending||!e}),n.jsx("p",{id:`${x}-url-hint`,"aria-live":"polite",className:"text-muted-foreground text-xs",children:C?C.withAccount?`Join on ${C.host} with your DorkOS account in the new tab, then connect.`:`Finish joining on ${C.host} in the new tab, then connect.`:"Its link, short address or an invitation link."})]}),n.jsxs("div",{className:"space-y-1.5",children:[n.jsx(He,{htmlFor:`${x}-name`,children:"Name for this installation"}),n.jsx(xt,{id:`${x}-name`,required:!0,maxLength:120,"aria-describedby":`${x}-name-hint`,value:E,onChange:B=>R(B.target.value),disabled:k.isPending||!e}),n.jsx("p",{id:`${x}-name-hint`,className:"text-muted-foreground text-xs",children:"What the space calls this DorkOS."})]}),F&&n.jsx("p",{id:`${x}-url-error`,role:"alert",className:"text-destructive text-sm",children:F})]}),n.jsxs(rn,{children:[n.jsx(L,{type:"button",variant:"outline",onClick:h,children:"Cancel"}),n.jsx(L,{type:"submit",disabled:k.isPending||!y.trim()||!T&&(!e||!E.trim()),children:k.isPending?"Connecting…":T?"Open invitation":"Connect"})]})]});const ie=n.jsx("p",{className:"text-muted-foreground text-xs break-all",children:t.pinnedOrigin});if(t.status==="reconnect-required"){const B=!N.data&&N.fetchStatus==="fetching",Y=N.data?Id(t.label,N.data.agents):B?null:Rd(t.label);return n.jsxs(n.Fragment,{children:[n.jsxs(ft,{children:[n.jsxs(st,{children:["Reconnect ",t.label]}),n.jsxs(pt,{children:["DorkOS can’t reach ",t.label,"’s channels. Disconnect, then connect again."]})]}),n.jsxs(At,{className:"space-y-3 py-4",children:[ie,Y&&n.jsx("p",{className:"text-sm",children:Y}),N.isError&&!N.data&&!B&&n.jsxs("div",{role:"alert",className:"flex flex-col items-start gap-2 text-sm sm:flex-row sm:items-center sm:justify-between sm:gap-3",children:[n.jsxs("p",{className:"text-destructive",children:["Couldn’t check which of your agents are on ",t.label,"."]}),n.jsx(L,{size:"sm",variant:"outline",onClick:()=>void N.refetch(),children:"Check again"})]}),j.isError&&n.jsx("p",{role:"alert",className:"text-destructive text-sm",children:"Couldn’t disconnect. Check DorkOS is running and try again."})]}),n.jsxs(rn,{children:[n.jsx(L,{type:"button",variant:"outline",onClick:h,children:"Close"}),n.jsx(L,{disabled:j.isPending||B,onClick:()=>W(t),children:j.isPending?"Disconnecting…":"Disconnect"})]})]})}return n.jsxs(n.Fragment,{children:[n.jsxs(ft,{children:[n.jsxs(st,{children:["Approve on ",t.label]}),n.jsx(pt,{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(At,{className:"space-y-3 py-4",children:[ie,X,n.jsxs("p",{className:"flex items-center gap-2 text-sm",children:[n.jsx(Oe,{})," Waiting for your approval"]}),r?n.jsx(L,{asChild:!0,children:n.jsxs("a",{ref:O,href:g.linkFor(r),target:"_blank",rel:"noopener noreferrer",children:["Open ",t.label," to approve",n.jsx(on,{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."}),(j.isError||!!s.error)&&n.jsxs("div",{role:"alert",className:"space-y-2 text-sm",children:[n.jsx("p",{children:j.isError?"Couldn’t confirm it was cancelled. Refresh to check.":"Couldn’t check approval. Try again."}),!j.isError&&n.jsx(L,{size:"sm",variant:"outline",onClick:s.retry,disabled:s.isFetching,children:"Check approval"})]})]}),n.jsxs(rn,{children:[n.jsx(L,{type:"button",variant:"outline",onClick:h,children:"Close"}),n.jsx(L,{variant:"outline",disabled:j.isPending,onClick:()=>W(t),children:j.isPending?"Cancelling…":"Cancel approval"})]})]})}function QN(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 Si({sheet:e,label:t="Actions",children:s}){return e?n.jsx("div",{role:"menu","aria-label":t,tabIndex:-1,onKeyDown:QN,children:s}):n.jsx(n.Fragment,{children:s})}function hr(){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 XN({trigger:e,selectedRef:t}){const s=ae(),r=Pe(),o=Me(),a=De({select:f=>f.location}),i=u.useRef(!1),c=u.useRef(!1),[d,l]=u.useState(null);function m(f,g){var y;if(!r||(f||(c.current=!1),g))return;if(f){const b=hr();np({cancelled:b.acted}).finally(b.stop);return}const x=document.activeElement;(x===null||x===document.body)&&((y=e.current)==null||y.focus())}async function h(f){if(f.ref===t||i.current||f.status!=="connected")return;const g=ma();if(g.ownerKey===null)return;const x={epoch:g.epoch,ownerKey:g.ownerKey},y={pathname:a.pathname,search:a.search};c.current=r;const b=hr();i.current=!0,l(f.ref);let C=!1,S=null;try{await o({...ve.channels(),search:{community:f.ref}}),C=!0,S=_n();const I=await s.resolveCommunityNavigation(f.ref),v=I?null:(await s.listRemoteCommunityRooms(f.ref)).rooms.find(R=>R.readable&&!R.archived)??null,E=(I==null?void 0:I.roomId)??(v==null?void 0:v.roomId);if(!Ft(x)||!S.isCurrent()){m(!1,b.acted());return}E&&await o({...ve.channels(),search:{community:f.ref,...E?{id:E}:{},...I!=null&&I.threadId?{thread:I.threadId}:{}}}),m(!0,b.acted())}catch{m(!1,b.acted()),C&&(S==null?void 0:S.isCurrent())===!0&&Ft(x)&&await o({to:y.pathname,search:y.search,replace:!0}).then(()=>!0,()=>!1)&&ce.error(`Couldn’t open ${f.label}.`,{description:"You’re still where you were. Try again in a moment."})}finally{b.stop(),i.current=!1,l(null)}}async function p(){if(t===void 0||i.current)return;const f=ma();if(f.ownerKey===null)return;const g={epoch:f.epoch,ownerKey:f.ownerKey},x=_n();c.current=r;const y=hr();i.current=!0;try{const b=await s.getCommunityNavigation();if(b.ownerKey!==g.ownerKey||!Ft(g)||!x.isCurrent()){m(!1,y.acted());return}const C=tp.safeParse(b.installationDestination);await o(C.success?{to:C.data.path,search:C.data.search}:{...ve.home()}),m(!0,y.acted())}catch{const b=Ft(g)&&x.isCurrent();b&&await o({...ve.home()}),m(b,y.acted())}finally{y.stop(),i.current=!1}}return{pendingRef:d,isSelecting:()=>i.current,holdCloseFocus:()=>{c.current=!0},takeCloseFocusHold:()=>{const f=c.current;return c.current=!1,f},selectCommunity:h,selectInstallation:p}}function JN(e){const t=u.useRef(e);u.useEffect(()=>{t.current=e},[e]),u.useEffect(()=>{const s=r=>{if(r.isComposing||!(r.metaKey||r.ctrlKey)||!r.shiftKey||r.altKey||r.key.toLowerCase()!=="k")return;r.preventDefault();const o=document.activeElement;t.current(o instanceof HTMLElement&&o!==document.body?o:null)};return window.addEventListener("keydown",s),()=>window.removeEventListener("keydown",s)},[])}function Du({triggerClassName:e,compact:t=!1}){var Ge;const s=Pe(),r=Me(),o=De({select:U=>U.location.search.community}),a=sp(),i=rp(),c=Hs(),{spaces:d,anySpace:l,selectedRef:m,visible:h,joinOfficial:p}=$N(o,c.data),f=u.useMemo(()=>{var U;return LN(h,((U=a.data)==null?void 0:U.order)??[])},[h,(Ge=a.data)==null?void 0:Ge.order]),g=f.find(U=>U.ref===m)??null,x=u.useRef(null),y=u.useRef(null),b=u.useRef(null),{pendingRef:C,isSelecting:S,holdCloseFocus:I,takeCloseFocusHold:v,selectCommunity:E,selectInstallation:R}=XN({trigger:b,selectedRef:m}),[M,O]=u.useState(""),[_,D]=u.useState(!1),[k,j]=u.useState(null),[N,w]=u.useState(null),T=zk(),[F,$]=u.useState(null),W=m?f.findIndex(U=>U.ref===m):-1;function X(U,de){Et(new URL(dp(U.remoteCommunityId,de),U.pinnedOrigin).toString())}const ie=_N({selected:g?{connection:g,availability:MN(g),canMoveUp:W>0,canMoveDown:W>=0&&W<f.length-1}:null,onMove:U=>{g&&i.mutate({ref:g.ref,direction:U})},onInvite:()=>g&&X(g,"community"),onOpenSettings:()=>g&&X(g),onLeave:()=>g&&X(g,"account"),onDisconnect:()=>w(g),onJoin:d?()=>j({ref:null}):null,onJoinOfficial:p,creationOrigins:d?ON(f):[],onCreate:U=>Et(new URL(lp,U).toString()),onDeploy:()=>Et(DN),hosting:d&&T?{onStart:()=>$({kind:"start"}),onOpenYourSpaces:()=>$({kind:"hosted"})}:null}),B=l?ie:[];BN(U=>j({ref:null,url:U}));const Y=TN(B),oe=ll([...Y.identityNodes,...Y.nodes]),pe=oe.nodes.slice(0,Y.identityNodes.length),V=oe.nodes.slice(Y.identityNodes.length),G=_e().data,te=(G==null?void 0:G.serverRole)==="hub",we=te?"Private":Y.teamName,ne=G===void 0||!te&&Y.nameUnknown,q=te?bs:hy,he=Y.nameUnknown?"My DorkOS":Y.teamName,ge=m!==void 0&&c.data===void 0,Ve=m===void 0?ne:ge,Qe=m===void 0?we:(g==null?void 0:g.label)??"Space",Re=s&&f.length>=8&&M.trim().length>0?f.filter(U=>U.label.toLocaleLowerCase().includes(M.trim().toLocaleLowerCase())):f;JN(U=>{y.current=U,D(!0)});function Xe(U){if(S())return;if(y.current=null,U==="installation"){R();return}const de=f.find(ke=>`community:${ke.ref}`===U);if(de){if(de.status==="connected"){E(de);return}I(),j({ref:de.ref})}}function ee(U){D(U),U||O("")}function ye(U){if(oe.onCloseAutoFocus(U),v()){U.preventDefault();return}const de=y.current;y.current=null,!(U.defaultPrevented||!(de!=null&&de.isConnected))&&(U.preventDefault(),de.focus())}u.useEffect(()=>{if(!_)return;const U=requestAnimationFrame(()=>{var de;return(de=x.current)==null?void 0:de.focus()});return()=>cancelAnimationFrame(U)},[_]);async function je(U){var Je;const ke=(Je=(await c.refetch()).data)==null?void 0:Je.find(Ze=>Ze.ref===U&&Ze.status==="connected");ke&&await E(ke)}function vt(U){xs(_n().destination)===U.ref&&r({...ve.home(),replace:!0})}return n.jsxs(n.Fragment,{children:[n.jsxs(op,{open:_,onOpenChange:ee,children:[n.jsx(ap,{asChild:!0,children:n.jsxs("button",{ref:b,type:"button","data-testid":"sidebar-header-block","aria-label":Ve?"Context menu":`${Qe} menu`,"aria-busy":C!==null||void 0,title:te&&m===void 0?"Just you and your agents":void 0,className:e,children:[t?m===void 0?n.jsx(q,{className:"size-4 shrink-0","aria-hidden":!0}):n.jsx(Tr,{className:"size-4 shrink-0","aria-hidden":!0}):Ve?n.jsx(dt,{className:"my-[3px] h-3.5 w-24 rounded-sm","data-testid":"sidebar-team-name-skeleton"}):n.jsxs(n.Fragment,{children:[te&&m===void 0&&n.jsx(bs,{className:"size-3.5 shrink-0","aria-hidden":!0}),n.jsx("span",{className:"truncate",children:Qe})]}),n.jsx(Jt,{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(ip,{align:"start",className:"max-h-(--radix-dropdown-menu-content-available-height) w-64 overflow-y-auto",onCloseAutoFocus:ye,children:[s&&n.jsx(ha,{children:l?"Switch context":"Menu"}),n.jsx(Si,{sheet:s,label:"You",children:n.jsx(Ar,{variant:s?"sheet":"dropdown",nodes:pe,onSheetClose:()=>ee(!1)})}),l&&n.jsx(fa,{}),l&&!s&&n.jsx(ha,{children:"Switch context"}),l&&s&&f.length>=8&&n.jsx("div",{className:"px-4 pb-2",children:n.jsx(xt,{type:"search",value:M,onChange:U=>O(U.target.value),placeholder:"Find a space","aria-label":"Find a space"})}),l&&n.jsxs(cp,{value:m?`community:${m}`:"installation",onValueChange:Xe,children:[n.jsx(pa,{value:"installation",icon:q,disabled:C!==null,itemRef:m===void 0?x:void 0,className:C!==null?"opacity-50":void 0,children:n.jsxs("span",{className:"min-w-0 flex-1 truncate",children:[we,te&&n.jsx("span",{className:"text-muted-foreground block truncate text-xs",children:"Just you and your agents"})]})}),Re.map(U=>{var Ie;const de=Tu(U),ke=de.mentionCount??0,Je=Math.max(0,(de.unreadCount??0)-ke),Ze=[ke>0?`${ke} ${ke===1?"mention":"mentions"}`:null,Je>0?`${Je} other unread`:null,((Ie=U.attention)==null?void 0:Ie.state)==="stale"?`last checked ${FN(Kn(U.attention.verifiedAt))}`:null].filter(Boolean).join(", ");return n.jsx(pa,{value:`community:${U.ref}`,icon:Tr,disabled:C!==null,itemRef:U.ref===m?x:void 0,description:[PN(U),Ze].filter(Boolean).join(" · ")||void 0,className:C!==null?"opacity-50":void 0,children:n.jsxs("span",{className:"flex min-w-0 items-center gap-1.5",children:[n.jsx("span",{className:"min-w-0 truncate",children:U.label}),_b(U)&&n.jsx("span",{role:"img",className:"bg-status-warning-dot size-2 shrink-0 rounded-full","aria-label":"Someone asked to take over this space",title:"Someone asked to take over this space"}),n.jsx(zs,{count:ke,cap:rs})]})},U.ref)})]}),V.length>0&&n.jsxs(n.Fragment,{children:[n.jsx(fa,{}),n.jsx(Si,{sheet:s,children:n.jsx(Ar,{variant:s?"sheet":"dropdown",nodes:V,onSheetClose:()=>ee(!1)})})]})]})]}),n.jsx(YN,{request:k,onOpenChange:U=>{U||j(null)},installName:he,onConnected:U=>void je(U)}),n.jsx(lS,{entry:T,dialog:F,onDialogChange:$,installName:he,onConnected:U=>void je(U)}),n.jsx(zN,{connection:N,onOpenChange:U=>{U||w(null)},onDisconnected:vt})]})}function ZN(){return n.jsx(Du,{compact:!0,triggerClassName:K("hover:bg-accent focus-visible:ring-ring text-foreground flex shrink-0 items-center rounded-md px-1 py-1.5 outline-hidden focus-visible:ring-2",Ws)})}function Ou(){const e=Pe();return n.jsxs(up,{className:"gap-2 px-2 py-3",children:[n.jsxs("div",{className:"flex items-center gap-1",children:[!e&&n.jsx(Du,{triggerClassName:"text-sidebar-foreground hover:bg-sidebar-accent/70 focus-visible:ring-sidebar-ring flex min-w-0 flex-1 items-center gap-1.5 rounded-md px-2 py-1 text-left text-control font-semibold outline-hidden transition-colors duration-150 focus-visible:ring-2"}),n.jsx(CN,{})]}),n.jsx(NN,{})]})}function eA(){const e=Ru("sm");return n.jsxs("div",{className:"space-y-1 pb-2",children:[e.you!==null&&n.jsx(Ci,{leading:e.you.face,label:e.you.name,description:"View profile",onClick:e.you.onOpen}),n.jsx(Ci,{leading:n.jsx(Bl,{className:"text-muted-foreground size-7 p-0.5","aria-hidden":!0}),label:"DorkOS account",description:e.accountStatus,onClick:e.onOpenAccount})]})}function Ci({leading:e,label:t,description:s,onClick:r}){return n.jsxs("button",{type:"button",onClick:r,className:K("hover:bg-accent focus-visible:ring-ring flex w-full items-center gap-3 rounded-md px-2 py-2 text-left outline-hidden focus-visible:ring-2",Ws),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(fn,{className:"text-muted-foreground size-4 shrink-0","aria-hidden":!0})]})}const tA=6e4;function nA(e){return e===null?!0:(e.selectionStart??0)===0&&(e.selectionEnd??0)===0}function sA(e,t,s){if(!e)return null;const r=t===null?s:[t,...s];for(const o of r){const{item:a}=o.item;if(a.type==="agent"&&Le(a.data)===e)return{kind:"agent",agent:a.data};if((a.type==="room"||a.type==="dm")&&a.id===e)return{kind:"room",room:a.data}}return null}function rA(){const{globalPaletteOpen:e,setGlobalPaletteOpen:t}=PS(),s=P(z=>z.openMessageSearch),[r,o]=u.useState(""),a=u.useRef(null),[i,c]=u.useState(""),d=u.useRef(null),[l,m]=u.useState([]),[h,p]=u.useState(null),[f,g]=u.useState(null),[x,y]=u.useState(null),b=l[l.length-1],[C,S]=u.useState(0),I=Pe(),v=P(z=>z.globalPaletteInitialSearch),E=P(z=>z.clearGlobalPaletteInitialSearch),R=u.useCallback(()=>{t(!1),E(),o(""),c(""),m([]),p(null),y(null)},[t,E]),{handleAgentSelect:M,startNewSession:O,handleFeatureAction:_,handleQuickAction:D,handleRoomSelect:k,handleSessionSelect:j,handleCommandSelect:N,handlePageSelect:w,recordAgentOpened:T,selectedCwd:F}=H0(R),$=le(),W=u.useCallback(z=>{const Se=mp($,z.projectPath);return hp(Se?{session:Se}:{agentId:z.id})},[$]),X=u.useCallback(z=>{if(!fp()){M(z);return}Tn(W(z),{target:"tab"}),T(z.projectPath),R()},[W,M,T,R]),ie=u.useCallback(z=>{Tn(W(z),{target:"window"}),T(z.projectPath),R()},[W,T,R]),B=pp(),Y=z0(),oe=yo(tA),{allAgents:pe,newActions:V,rooms:G,sessions:te,continueRows:we,recent:ne,searchableItems:q}=_S(F,oe);gp(pe);const{bestMatch:he,rows:ge,prefix:Ve,term:Qe}=$0(q,r,{usage:Y,now:oe,scope:x}),Re=Ve==="#",Xe=V0(Qe),ee=Xe?{term:Xe,isScoped:x!==null,onSelect:()=>{R(),s(Xe)}}:null,ye=u.useMemo(()=>i?pe.find(z=>z.name===i)??null:null,[i,pe]),je=sA(i,he,ge),vt=u.useCallback(z=>{y(z),o(""),c("")},[]),Ge=!I&&ye!==null,U=u.useMemo(()=>{var z;return i?te.find(Se=>Se.id===i)??((z=we.find(Se=>Se.session.id===i))==null?void 0:z.session)??null:null},[i,te,we]),de=hu((h==null?void 0:h.id)??"",(h==null?void 0:h.projectPath)??""),ke=u.useCallback(()=>{m(z=>z.slice(0,-1)),p(z=>l.length<=1?null:z),c("")},[l.length]),Je=u.useCallback(z=>{p(z),m(Se=>[...Se,"agent-actions"]),o(""),c(""),S(Se=>Se+1)},[]);u.useEffect(()=>{e&&v!=null&&(o(v),E(),requestAnimationFrame(()=>{const z=a.current;if(z){const Se=v.length;z.setSelectionRange(Se,Se)}}))},[e,v,E]);const Ze=u.useCallback(z=>{t(z),z?S(Se=>Se+1):(o(""),c(""),m([]),p(null),y(null))},[t]),Ie=q0({rootRef:d,activePage:b??"root",onPin:c,resetKey:JSON.stringify([e,b??null,r,x&&eu(x)])}),wt=!r&&x===null,Ot=u.useId(),Mt=n.jsx(bt,{open:e,onOpenChange:Ze,children:n.jsx(yt,{className:K("!min-h-0 overflow-hidden p-0 transition-[max-width] duration-200","[&>button:last-child]:top-2 [&>button:last-child]:right-2.5",Ge?"max-w-[640px]":"max-w-[480px]",I&&"h-[85vh]"),children:n.jsxs(se.div,{variants:bu,initial:"hidden",animate:"visible",exit:"exit",className:K("flex overflow-hidden",I&&"h-full flex-col"),children:[n.jsxs(rd,{ref:d,loop:!0,shouldFilter:!1,value:i,onValueChange:c,onPointerMove:Ie.onPointerMove,className:K("min-w-0 flex-1",I&&"flex flex-col [&_[cmdk-list]]:max-h-none [&_[cmdk-list]]:flex-1 [&_[cmdk-list]]:overflow-y-auto"),onKeyDown:z=>{if(Ie.onKeyDown(z),z.key==="Enter"&&(z.metaKey||z.ctrlKey)&&!b&&(U==null?void 0:U.cwd)!=null){z.preventDefault(),O(U.cwd),R();return}if(z.key==="Enter"&&(z.metaKey||z.ctrlKey)&&!b&&ye){z.preventDefault(),X(ye);return}if(z.key==="Enter"&&(z.metaKey||z.ctrlKey)&&b==="agent-actions"&&h){z.preventDefault(),X(h);return}if(z.key==="Tab"&&!z.shiftKey&&!b&&je){z.preventDefault(),z.stopPropagation(),vt(je);return}if(z.key==="Backspace"&&x&&!b&&nA(a.current)){z.preventDefault(),y(null);return}z.key==="Backspace"&&!r&&l.length>0&&(z.preventDefault(),ke()),z.key==="Escape"&&l.length>0&&(z.preventDefault(),z.stopPropagation(),ke())},children:[l.length>0&&n.jsxs("div",{className:"text-muted-foreground flex items-center gap-1 border-b px-3 py-1.5 text-xs",children:[n.jsx("button",{onClick:()=>{m([]),p(null),S(z=>z+1)},className:"hover:text-foreground transition-colors",children:"All"}),n.jsx("span",{children:"/"}),n.jsxs("span",{children:["Agent: ",h==null?void 0:h.name]})]}),n.jsx(od,{ref:a,"data-testid":"command-palette-input",leading:x&&!b?n.jsx(Y0,{scope:x}):void 0,placeholder:b==="agent-actions"?`${(h==null?void 0:h.name)??"Agent"} actions…`:x&&!b?"Search within…":"Search rooms, agents, commands…",value:r,onValueChange:o}),n.jsx(ad,{children:n.jsxs(An,{className:"h-full",children:[n.jsxs(Qb,{children:[n.jsx("p",{children:"No results found."}),n.jsx(fu,{className:"justify-center pb-0"})]}),n.jsx(Ye,{mode:"wait",initial:!1,children:n.jsxs(se.div,{"data-palette-page":b??"root",initial:{opacity:0,x:b?16:-16},animate:{opacity:1,x:0},exit:{opacity:0,x:b?-16:16},transition:{duration:.15,ease:"easeOut"},children:[!b&&n.jsx(mC,{staggerKey:C,isZeroQuery:wt,isRoomMode:Re,scope:x,hasQuery:Qe.length>0,selectedCwd:F,selectedValue:i,continueRows:we,recent:ne,newActions:V,bestMatch:he,rows:ge,rooms:G,searchHandoff:ee,onFeatureAction:_,onQuickAction:D,onGoToAgentActions:Je,onRoomSelect:k,onSessionSelect:z=>j(z.id,z.cwd),onCommandSelect:N,onPageSelect:w}),b==="agent-actions"&&h&&n.jsx(X0,{agent:h,onOpenHere:()=>M(h),onOpenNewTab:()=>X(h),onOpenNewWindow:B?()=>ie(h):void 0,onNewSession:()=>{O(h.projectPath),T(h.projectPath),R()},onEditSettings:()=>{xp.getState().openProfileDocked(h.projectPath),R()},onBrowseSessions:de.sessionCount>0?()=>{g(h),T(h.projectPath),R()}:void 0,recentSessions:de.recentSessions,onSelectSession:z=>j(z,h.projectPath)})]},b??"root")})]})}),n.jsx(Z0,{page:b,hasAgentSelected:Ge,canScope:!b&&je!==null,isScoped:x!==null})]}),n.jsx(Ye,{children:Ge&&ye&&n.jsx(Q0,{agent:ye},ye.id)})]})})});return n.jsxs(n.Fragment,{children:[n.jsx(al,{id:Ot,children:Mt}),f!==null&&n.jsx(bp,{agentPath:f.projectPath,agentName:f.displayName??f.name,agentVisual:bo(f),open:!0,onOpenChange:z=>{z||g(null)},onSelectSession:z=>j(z,f.projectPath),onNewSession:()=>O(f.projectPath)})]})}const oA="",aA="";function iA(e){const t=[];let s=e,r=!1;for(;s.length>0;){const o=r?aA:oA,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 cA({excerpt:e,className:t}){const s=iA(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 Mu="rooms",lA=["claude-code","opencode"];function dA(e){if(e.source===Mu)return{kind:"room",...ve.channels(),search:{id:e.container,entry:e.ordinal}};if(e.sessionId===void 0)return{kind:"unopenable"};const t=e.messageId!==void 0&&lA.includes(e.source);return{kind:"session",...Kt({session:e.sessionId,dir:e.containerPath??void 0,...t?{message:e.messageId}:{}})}}function uA(e,t){return e.source===Mu?t.get(e.container)??"Channel":e.containerPath===null?"Conversation":fl(e.containerPath)}function mA(e){return e==="user"?"You":"Agent"}function hA({hit:e,containerLabel:t,value:s,onSelect:r,openable:o}){const a=e.source==="rooms"?dl:fy;return n.jsxs(Ae,{value:s,onSelect:r,className:"flex flex-col items-start gap-1 py-2",children:[n.jsxs("div",{className:"text-muted-foreground flex w-full min-w-0 items-center gap-1.5 text-xs",children:[n.jsx(a,{className:"size-3.5 shrink-0","aria-hidden":"true"}),n.jsx("span",{className:"min-w-0 truncate",children:t}),n.jsx("span",{"aria-hidden":"true",children:"·"}),n.jsx("span",{className:"shrink-0",children:mA(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:Kn(e.createdAt)})]}),n.jsx(cA,{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 fA=["Your channels and direct messages, as soon as they’re posted.","DorkOS chats can lag five minutes.","Claude Code, Codex and OpenCode chats, even outside DorkOS. These can lag five minutes."],pA=["Tool output is never searched: no errors, stack traces, file contents or diffs.","Matches whole words: “ogs” won’t find “dogs”. Type “dog*” to match word starts."],gA="Searches channels, direct messages, and DorkOS, Claude Code, Codex and OpenCode chats. Not tool output.",xA=`Type at least ${pl} letters to search.`,bA="Search what was said…";function yA({detailOpen:e=!1,className:t}){const[s,r]=u.useState(null),o=s??e,a=pA;return n.jsxs(So,{open:o,onOpenChange:r,className:K("px-3 py-2",t),children:[n.jsxs(Co,{className:K("text-muted-foreground/80 hover:text-foreground focus-ring text-2xs","flex w-full items-start gap-2 rounded-sm py-1 text-left leading-relaxed transition-colors"),children:[n.jsx("span",{className:"min-w-0 flex-1",children:gA}),n.jsx(Jt,{className:K("mt-0.5 size-3 shrink-0 transition-transform",!o&&"-rotate-90"),"aria-hidden":"true"})]}),n.jsx(No,{children:n.jsxs("ul",{className:"mt-2 space-y-1.5",children:[fA.map(i=>n.jsxs("li",{className:"text-muted-foreground flex gap-2 text-xs leading-relaxed",children:[n.jsx(Xt,{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(kb,{className:"mt-0.5 size-3.5 shrink-0 opacity-60","aria-hidden":"true"}),n.jsx("span",{children:i})]},i))]})})]})}const vA=3e4,wA=e=>["message-search",e];function fr(e){return yp(e).some(t=>t.length>=pl)}function jA(e,t){const s=ae(),r=kA(e,vp),o=t&&fr(e)&&fr(r),{data:a,isFetching:i,error:c}=Ee({queryKey:wA(r),queryFn:()=>s.search({q:r}),enabled:o,staleTime:vA,placeholderData:l=>l,retry:!1});return{submitted:o?r:"",tooShort:t&&r.trim().length>0&&!fr(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 kA(e,t){const[s,r]=u.useState(e);return u.useEffect(()=>{const o=setTimeout(()=>r(e),t);return()=>clearTimeout(o)},[e,t]),s}function SA(){const e=P(t=>t.toggleMessageSearch);u.useEffect(()=>{const t=s=>{(s.metaKey||s.ctrlKey)&&s.shiftKey&&s.code==="KeyF"&&(s.preventDefault(),e())};return document.addEventListener("keydown",t),()=>document.removeEventListener("keydown",t)},[e])}const pr="bg-muted rounded px-1 py-0.5 font-mono text-3xs";function CA(){SA();const e=P(v=>v.messageSearchOpen),t=P(v=>v.messageSearchQuery),s=P(v=>v.setMessageSearchOpen),r=Pe(),o=Me(),a=ae(),[i,c]=u.useState("");u.useEffect(()=>{e&&c(t??"")},[e,t]);const{results:d,warnings:l,tooShort:m,isSearching:h,error:p,submitted:f}=jA(i,e),{data:g}=Ls({includeArchived:!0}),x=u.useMemo(()=>{const v=new Map;for(const E of g??[])v.set(E.id,E.kind==="channel"&&E.slug?`#${E.slug}`:E.title);return v},[g]),y=u.useCallback(()=>s(!1),[s]),b=u.useCallback((v,E)=>{if(E.kind!=="unopenable"&&(y(),o({to:E.to,search:E.search}),E.kind==="session"&&v.containerPath!==null)){const R=v.containerPath;a.browseDirectory(R).catch(M=>{if((M==null?void 0:M.status)===404){ce.info("That folder is gone",{description:`${R} is gone, so nothing new can run there. You can still read it.`});return}ce.info("Couldn’t open that folder",{description:`DorkOS couldn’t read ${R}. The chat may not open.`})})}},[y,o,a]),C=d.length>0,S=!C&&!m&&!h&&f.trim().length>0&&p===null,I=!C&&!m&&f.trim().length>0&&p===null;return n.jsx(bt,{open:e,onOpenChange:s,children:n.jsxs(yt,{"data-testid":"message-search-dialog",className:K("!min-h-0 max-w-[560px] overflow-hidden p-0","[&>button:last-child]:top-2 [&>button:last-child]:right-2.5",r&&"h-[85vh]"),children:[n.jsx(st,{className:"sr-only",children:"Search your messages"}),n.jsx(se.div,{variants:bu,initial:"hidden",animate:"visible",exit:"exit",className:K("flex overflow-hidden",r&&"h-full flex-col"),children:n.jsxs(rd,{loop:!0,shouldFilter:!1,className:K("min-w-0 flex-1",r&&"flex flex-col [&_[cmdk-list]]:max-h-none [&_[cmdk-list]]:flex-1 [&_[cmdk-list]]:overflow-y-auto"),children:[n.jsx(od,{"data-testid":"message-search-input",placeholder:bA,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(wp,{className:"mt-0.5 size-3.5 shrink-0","aria-hidden":"true"}),n.jsx("span",{children:p.message})]}),l.map(v=>n.jsxs("p",{role:"status",className:"text-muted-foreground text-2xs flex items-start gap-2 px-3 pt-2 leading-relaxed",children:[n.jsx(tc,{className:"mt-0.5 size-3 shrink-0","aria-hidden":"true"}),n.jsx("span",{children:v.message})]},v.source)),n.jsx(ad,{children:n.jsx(An,{className:"h-full",children:C&&n.jsx(nt,{className:K("transition-opacity duration-150",h&&"opacity-60"),children:d.map(v=>{const E=`${v.source}:${v.container}:${v.ordinal}`,R=dA(v);return n.jsx(hA,{value:E,hit:v,containerLabel:uA(v,x),openable:R.kind!=="unopenable",onSelect:()=>b(v,R)},E)})})})}),p===null&&n.jsxs("div",{className:"max-h-[45vh] min-h-0 shrink-0 overflow-y-auto",children:[m&&n.jsx("p",{className:"text-muted-foreground px-3 pt-3 text-xs",children:xA}),S&&n.jsxs("p",{className:"text-muted-foreground px-3 pt-3 text-xs",children:["No messages match “",f.trim(),"”."]}),n.jsx(yA,{detailOpen:I})]}),n.jsxs("div",{className:"text-muted-foreground flex flex-shrink-0 items-center gap-3 border-t px-3 py-1.5 text-xs",children:[n.jsxs("span",{className:"inline-flex items-center gap-1",children:[n.jsx("kbd",{className:pr,children:"↑↓"}),"Navigate"]}),n.jsxs("span",{className:"inline-flex items-center gap-1",children:[n.jsx("kbd",{className:pr,children:"Enter"}),"Open"]}),n.jsxs("span",{className:"ml-auto inline-flex items-center gap-1",children:[n.jsx("kbd",{className:pr,children:"esc"}),"Close"]})]})]})})]})})}function NA(e){return`set${e.charAt(0).toUpperCase()}${e.slice(1)}`}function AA(e){const t=at(),s=fo(),r=jo();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=P(m=>m[t]),r=P(m=>m[NA(t)]),o=AA(e.urlParam),a=o.isOpen,i=o.close,c=s||a,d=u.useCallback(m=>{r(m),!m&&a&&i()},[r,a,i]),l=e.component;return n.jsx(l,{open:c,onOpenChange:d})}function IA({contribution:e,openState:t}){const s=u.useSyncExternalStore(t.subscribe,t.getSnapshot),r=e.component;return s?n.jsx(jp,{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 RA({contribution:e}){return e.openState?n.jsx(IA,{contribution:e,openState:e.openState}):n.jsx(EA,{contribution:e,openStateKey:e.openStateKey})}function TA(){const e=_s("dialog");return n.jsx(n.Fragment,{children:e.map(t=>n.jsx(RA,{contribution:t},t.id))})}const DA=["session","id","thread","entry","itemId","agent","profile","continuedFrom","pkg","view","region","detail","panel"];function OA(e,t){if(e.length>=Js)return e.slice(0,Js);const s=new URLSearchParams(t);let r="";for(const o of DA)for(const a of s.getAll(o)){const i=new URLSearchParams([[o,a]]).toString(),c=r?`${r}&${i}`:i;e.length+1+c.length<=Js&&(r=c)}return r?`${e}?${r}`:e}const MA=6e4,_A={bug:"when it’s fixed",idea:"when it ships",feedback:"when the team acts on it"};function PA(e,t){var s;return JSON.stringify([e.kind,t,e.screenshotDataUrl??null,((s=e.element)==null?void 0:s.selector)??null])}function Ni(e,t,s,r){const o=wd("bug",e,t),a=[...Ap()];r&&a.push({at:new Date().toISOString(),kind:"console_error",message:Cp(r).slice(0,Np)});const i=a.slice(-Ep);return{clientReport:{version:o.version,platform:o.platform,runtimes:o.runtimes,flags:Object.fromEntries(Object.entries(o.flags).map(([c,d])=>[c,typeof d=="number"?String(d):d])),...uv(s)},...i.length>0?{breadcrumbs:i}:{}}}function LA(){const e=ae(),t=De({select:b=>b.location.pathname}),s=De({select:b=>b.location.searchStr}),r=kp(),o=OA(t,s),a=De({select:b=>{const C=b.location.search;return typeof(C==null?void 0:C.session)=="string"?C.session:void 0}}),i=De({select:b=>{if(b.location.pathname!=="/channels")return;const C=b.location.search;return typeof(C==null?void 0:C.id)=="string"?C.id:void 0}}),c=Sp(),d=t==="/"&&c.status==="ready"?c.room.id:void 0,l=a?void 0:i??d,{data:m}=Ee({queryKey:Fe.current(),queryFn:()=>e.getConfig(),staleTime:300*1e3}),[h,p]=u.useState(!1),f=Me(),g=u.useRef(null),x=u.useCallback(b=>m?Ni(m,t,r,b==null?void 0:b.crashStack):void 0,[m,t,r]),y=u.useCallback(async b=>{var _;const C=b.message.trim();if(!C)return!1;const S=(_=b.contact)==null?void 0:_.trim(),I=PA(b,C),v=g.current;if(v&&v.fingerprint===I&&Date.now()-v.at<MA)return ce.info("Already sent a moment ago."),!0;const E=b.includeDiagnostics?Ni(m,t,r,b.crashStack):void 0,R=b.includeDiagnostics&&b.kind==="bug",M=!!(b.includeConversation&&a),O=!!(b.includeConversation&&l);p(!0);try{const D=E&&R?await ev():void 0,{ok:k}=await e.sendFeedback({kind:b.kind,message:C,...S?{contact:S}:{},...o?{route:o}:{},...E?{diagnostics:{...E,...D?{shellLogExcerpt:D}:{}}}:{},...R?{includeServerLogs:!0}:{},...M?{sessionId:a,includeTranscript:!0}:{},...O?{roomId:l,includeTranscript:!0,...b.roomThroughSeq?{roomThroughSeq:b.roomThroughSeq}:{}}:{},...b.screenshotDataUrl?{screenshot:{dataUrl:b.screenshotDataUrl}}:{},...b.anonymous?{anonymous:!0}:{},...b.element?{element:b.element}:{}});return k?(g.current={fingerprint:I,at:Date.now()},ce.success("Sent. Thank you.",{...b.notifyEmail?{description:`DorkOS emails ${b.notifyEmail} ${_A[b.kind]}.`}:{},action:{label:"Your reports",onClick:()=>f(ve.feedbackRequests())}})):ce.error("Couldn’t send. Your words are still here. Try again or open a GitHub issue."),k}finally{p(!1)}},[e,t,o,a,l,m,r,f]);return{isSubmitting:h,sessionId:a,roomId:l,route:o,buildDiagnostics:x,send:y}}const Ai=500;function Ei(e){const t=e.trim();return t.length>Ai?`${t.slice(0,Ai)}… [trimmed]`:t}function FA(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: ${Ei(s.input)}`),s.result&&t.push(` result: ${Ei(s.result)}`);return t.join(`
74
+ `)}function $A(e){const t=e.slice(-20),s=Ip(Rp(t.map(FA).join(`
75
+
76
+ `))).trim();return s.length>ga?`${s.slice(0,ga-1)}…`:s}function BA(e,t){const s=ae(),[r]=$s(),{data:o,isLoading:a,isError:i}=Ee({queryKey:["feedback-transcript-preview",e,r],queryFn:async()=>{const{messages:c}=await s.getMessages(e,r??void 0);return $A(c)},enabled:t&&!!e,staleTime:30*1e3});return{text:o??"",isLoading:a,isError:i}}function _u(e,t){const s=ae(),{data:r,isLoading:o,isError:a}=Ee({queryKey:["feedback-room-transcript-preview",e],queryFn:()=>s.previewRoomTranscript(e),enabled:t&&!!e,staleTime:30*1e3});return{text:(r==null?void 0:r.text)??"",throughSeq:(r==null?void 0:r.throughSeq)??void 0,isLoading:o,isError:a}}const zA=24;function Ii(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??zA;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=Ii(i,{left:0,top:0,width:s.width,height:s.height});if(!c)return null;const d=Ii(c,r);if(!d)return null;const l=o.width/r.width,m=o.height/r.height,h=Math.round((d.left-r.left)*l),p=Math.round((d.top-r.top)*m),f=Math.round((d.left+d.width-r.left)*l),g=Math.round((d.top+d.height-r.top)*m),x=Math.min(Math.max(0,h),Math.max(0,o.width-1)),y=Math.min(Math.max(0,p),Math.max(0,o.height-1));return{sx:x,sy:y,sw:Math.max(1,f-x),sh:Math.max(1,g-y)}}function KA(e){return new Promise((t,s)=>{const r=new Image,o=i=>{clearTimeout(a),s(new ot("failed",i))},a=setTimeout(()=>o(`The capture did not decode within ${ws}ms.`),ws);r.onload=()=>{clearTimeout(a),t(r)},r.onerror=()=>o("The capture did not decode, so it cannot be cropped."),r.src=e})}function 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 ot("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 WA(e,t){const s=t.getBoundingClientRect();if(s.width===0&&s.height===0)throw new ot("failed","That element has no size to crop to.");if(!Sd().contains(t))throw new ot("failed","That element is not part of the app that was captured.");const r=await KA(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 ot("failed","That element is no longer inside the captured picture.");return Or(HA(r,o))}const Ri={"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."},GA={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 qA(e){return e instanceof ot?GA[e.reason]:e instanceof qt?Ri[e.reason]:Ri.unreadable}const gr="Only images can be attached.",YA="Files";function Sn(e){return e?Array.from(e.types).includes(YA):!1}function Ti(e){return e.find(t=>t.type.startsWith("image/"))}function VA(e={}){const{enabled:t=!1}=e,[s,r]=u.useState(null),[o,a]=u.useState(!1),[i,c]=u.useState(!1),d=u.useRef(0),l=u.useRef(0),m=u.useCallback(async v=>{const E=++l.current;a(!0);try{const R=await v();return E!==l.current?null:(r(R),R)}catch(R){return E!==l.current||ce.error(qA(R)),null}finally{E===l.current&&a(!1)}},[]),h=u.useCallback(async v=>{if(!v.type.startsWith("image/")){ce.error(gr);return}await m(()=>Or(v))},[m]),p=u.useCallback(async()=>{await m(async()=>Or(await cv()))},[m]),f=u.useCallback(v=>m(async()=>WA(await Cd(),v)),[m]),g=u.useCallback(()=>{l.current+=1,r(null),a(!1)},[]),x=u.useCallback(v=>{l.current+=1,d.current=0,v!==void 0&&!bv(v)?(console.warn("[feedback] Ignoring an initial screenshot that is not a bounded image data URL."),r(null)):r(v??null),a(!1),c(!1)},[]);u.useEffect(()=>{if(!t)return;const v=E=>{Sn(E.dataTransfer)&&E.preventDefault()};return window.addEventListener("dragover",v),window.addEventListener("drop",v),()=>{window.removeEventListener("dragover",v),window.removeEventListener("drop",v)}},[t]);const y=u.useCallback(v=>{var M;const E=Array.from(((M=v.clipboardData)==null?void 0:M.items)??[]).map(O=>O.getAsFile()).filter(O=>O!==null);if(E.length===0)return;const R=Ti(E);if(!R){ce.error(gr);return}v.preventDefault(),h(R)},[h]),b=u.useCallback(v=>{Sn(v.dataTransfer)&&(v.preventDefault(),d.current+=1,c(!0))},[]),C=u.useCallback(v=>{Sn(v.dataTransfer)&&(v.preventDefault(),v.dataTransfer.dropEffect="copy")},[]),S=u.useCallback(v=>{Sn(v.dataTransfer)&&(d.current=Math.max(0,d.current-1),d.current===0&&c(!1))},[]),I=u.useCallback(v=>{if(!Sn(v.dataTransfer))return;v.preventDefault(),d.current=0,c(!1);const E=Ti(Array.from(v.dataTransfer.files));if(!E){ce.error(gr);return}h(E)},[h]);return{dataUrl:s,isPreparing:o,isDraggingOver:i,attach:h,capture:p,captureElement:f,clear:g,reset:x,handlers:{onPaste:y,onDragEnter:b,onDragOver:C,onDragLeave:S,onDrop:I}}}const Di=Op,QA="root";function Pu(e){return typeof CSS<"u"&&typeof CSS.escape=="function"?CSS.escape(e):e.replace(/["'\\[\]]/g,t=>`\\${t}`)}function Oi(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?`#${Pu(e.id)}`:null}function Vr(e,t){const s=e.getAttribute(t);return s?`[${t}="${Pu(s)}"]`:null}function XA(e){const t=e.tagName;let s=1,r=e.previousElementSibling;for(;r;)r.tagName===t&&(s+=1),r=r.previousElementSibling;return s}function JA(e){const t=e.tagName.toLowerCase(),s=Lu(e);if(s)return s;const r=Vr(e,"data-testid")??Vr(e,"data-slot"),o=`:nth-of-type(${XA(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 ZA(e){for(const r of[Lu(e),Vr(e,"data-testid")])if(r&&r.length<=Di&&Oi(r,e))return r;const t=[];let s=e;for(;s&&s.id!==QA&&s.tagName!=="BODY";){t.unshift(JA(s));const r=t.join(" > ");if(r.length>Di){t.shift();break}if(Oi(r,e))return r;s=s.parentElement}return t.join(" > ")||e.tagName.toLowerCase()}function Mi(e,t){var r;const s=(r=e.closest(`[${t}]`))==null?void 0:r.getAttribute(t);if(!(!s||s.length>Tp))return s}const e1=8;function Fu(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*e1?s:null}function t1(e){const t=Mi(e,"data-slot"),s=Fu(e,e),r=s?Mi(s,"data-testid"):void 0,o=$u(e);return{selector:ZA(e),...t?{slot:t}:{},...r?{testId:r}:{},...o?{label:o}:{}}}const xr=40,n1=["button","a[href]","summary","input","select","textarea",'[role="button"]','[role="link"]','[role="menuitem"]','[role="tab"]','[role="option"]','[role="checkbox"]','[role="switch"]'].join(", "),s1=new Set(["INPUT","SELECT","TEXTAREA"]),r1=['[contenteditable]:not([contenteditable="false"])','[role="textbox"]','[role="searchbox"]','[role="combobox"]'].join(", "),o1=["h1","h2","h3","h4","h5","h6",'[role="heading"]',"label","legend","th","dt"].join(", ");function a1(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 Rn(e){const t=(e??"").replace(/\s+/g," ").trim();if(!t)return;const s=a1(t);if(s.length<=xr)return t;const r=s.slice(0,xr-1),o=r.lastIndexOf(" ");return`${(o>xr/2?r.slice(0,o):r).join("").trimEnd()}…`}function i1(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 Rn(s)}function ts(e){return Rn(e.getAttribute("aria-label"))??i1(e)}function $u(e){const t=c1(e);return t&&t.length<=Dp?t:void 0}function c1(e){var a,i;const t=e.closest(r1);if(t)return ts(t);const s=e.closest(n1);if(s){if(s1.has(s.tagName)){const c=s;return ts(s)??Rn((i=(a=c.labels)==null?void 0:a[0])==null?void 0:i.textContent)}return ts(s)??Rn(s.textContent)}const r=ts(e);if(r)return r;const o=e.closest(o1);return o?Rn(o.textContent):void 0}function _i(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 l1(e){var d;const t=$u(e);if(t)return{text:t,onScreen:!0};const s=e.getAttribute("data-testid")??e.getAttribute("data-slot"),r=s?_i(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&&Fu(e,o)===o?o.getAttribute("data-testid"):null)??(o==null?void 0:o.getAttribute("data-slot")),c=i?_i(i):null;return c?{text:c,onScreen:!1}:null}const d1="This part";function Bu(e){return(e==null?void 0:e.text)??d1}function u1(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 m1(e){return e!=null&&e.onScreen?`Remove “${e.text}”`:`Remove ${Bu(e).toLowerCase()}`}function h1(){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(bs,{className:"size-3 shrink-0","aria-hidden":!0}),"Private. Only the DorkOS team sees these. Never public."]})})}function tt({label:e,value:t}){return n.jsxs("div",{className:"flex items-baseline justify-between gap-4 py-1",children:[n.jsx("span",{className:"text-muted-foreground shrink-0 text-xs",children:e}),n.jsx("span",{className:"text-foreground text-right font-mono text-xs break-all",children:t})]})}function f1({diagnostics:e,kind:t,route:s}){if(!e)return n.jsx("p",{className:"text-muted-foreground text-xs",children:"Gathering diagnostics…"});const{clientReport:r,breadcrumbs:o}=e,{viewport:a,browser:i,shell:c,theme:d,locale:l,timezone:m}=r;return n.jsxs("div",{className:"flex flex-col gap-3",children:[n.jsxs("div",{className:"rounded-md border p-3",children:[n.jsx(tt,{label:"Page",value:s}),n.jsx(tt,{label:"Version",value:r.version}),n.jsx(tt,{label:"Platform",value:r.platform}),n.jsx(tt,{label:"Runtimes",value:r.runtimes.length?r.runtimes.join(", "):"none"}),a&&n.jsx(tt,{label:"Window",value:`${a.width}×${a.height}${a.devicePixelRatio&&a.devicePixelRatio!==1?` @${a.devicePixelRatio}x`:""}`}),c&&n.jsx(tt,{label:"Shell",value:c}),d&&n.jsx(tt,{label:"Theme",value:d}),l&&n.jsx(tt,{label:"Locale",value:l}),m&&n.jsx(tt,{label:"Timezone",value:m}),i&&n.jsx(tt,{label:"Browser",value:i}),Object.entries(r.flags).map(([h,p])=>n.jsx(tt,{label:h,value:String(p)},h))]}),n.jsxs("div",{className:"flex flex-col gap-1.5",children:[n.jsxs("span",{className:"text-muted-foreground text-xs font-medium",children:["Recent events (",(o==null?void 0:o.length)??0,")"]}),o&&o.length>0?n.jsx("ul",{className:"flex flex-col gap-1",children:o.map((h,p)=>n.jsxs("li",{className:"text-foreground font-mono text-xs break-all",children:[n.jsx("span",{className:"text-muted-foreground",children:h.kind})," ",h.message]},p))}):n.jsx("p",{className:"text-muted-foreground text-xs",children:"No recent errors or warnings."})]}),t==="bug"&&n.jsxs("div",{className:"text-muted-foreground space-y-1 text-xs",children:[n.jsx("p",{children:$e()?"Recent server and app log excerpts are added when you send.":"An excerpt of recent server logs is added when you send."}),n.jsx("p",{children:"Scrubbed first: home paths shown as ~, tokens removed, web addresses cut to the page."})]})]})}function p1({sessionId:e,active:t}){const{text:s,isLoading:r,isError:o}=BA(e,t);return r?n.jsxs("div",{className:"flex flex-col gap-2",children:[n.jsx(dt,{className:"h-4 w-3/4"}),n.jsx(dt,{className:"h-4 w-full"}),n.jsx(dt,{className:"h-4 w-2/3"})]}):o?n.jsx("p",{className:"text-muted-foreground text-xs",children:"Couldn’t load the chat preview."}):s?n.jsxs("div",{className:"flex flex-col gap-2",children:[n.jsxs("div",{className:"text-muted-foreground space-y-1 text-xs",children:[n.jsx("p",{children:"The last ~10 turns, gathered and scrubbed when you send."}),n.jsx("p",{children:"Home paths shown as ~, tokens removed, long tool output trimmed."})]}),n.jsx("pre",{className:"text-foreground bg-muted/40 rounded-md p-3 font-mono text-xs break-words whitespace-pre-wrap",children:s})]}):n.jsx("p",{className:"text-muted-foreground text-xs",children:"No recent chat to attach."})}function g1({roomId:e,active:t}){const{text:s,isLoading:r,isError:o}=_u(e,t);return r?n.jsxs("div",{className:"flex flex-col gap-2",children:[n.jsx(dt,{className:"h-4 w-3/4"}),n.jsx(dt,{className:"h-4 w-full"}),n.jsx(dt,{className:"h-4 w-2/3"})]}):o?n.jsx("p",{className:"text-muted-foreground text-xs",children:"Couldn’t load the room preview."}):s?n.jsxs("div",{className:"flex flex-col gap-2",children:[n.jsxs("div",{className:"text-muted-foreground space-y-1 text-xs",children:[n.jsxs("p",{children:["The last ",gl," messages in this room, without threads."]}),n.jsx("p",{children:"Home paths shown as ~, tokens removed, file names left out."})]}),n.jsx("pre",{className:"text-foreground bg-muted/40 rounded-md p-3 font-mono text-xs break-words whitespace-pre-wrap",children:s})]}):n.jsx("p",{className:"text-muted-foreground text-xs",children:"No recent messages to attach."})}function x1({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 b1({open:e,onOpenChange:t,initialTab:s,diagnostics:r,kind:o,route:a,showConversation:i,sessionId:c,roomId:d,screenshotDataUrl:l}){const m=!Pe(),h=["diagnostics",...i?["conversation"]:[],...l?["screenshot"]:[]],p=h.includes(s)?s:"diagnostics";return n.jsx(bt,{open:e,onOpenChange:t,children:n.jsxs(yt,{className:K("max-h-[85vh]",m&&"max-w-lg"),children:[n.jsxs(ft,{children:[n.jsx(st,{className:"text-sm font-medium",children:"What will be sent"}),n.jsx(pt,{className:"text-muted-foreground text-xs",children:"Each part is sent only if its toggle is on."})]}),n.jsxs(Kl,{defaultValue:p,className:"flex min-h-0 flex-col gap-3 px-4 pb-4 sm:px-0",children:[n.jsxs(Hl,{className:K("grid shrink-0",h.length===3&&"grid-cols-3",h.length===2&&"grid-cols-2",h.length===1&&"grid-cols-1"),children:[n.jsx(os,{value:"diagnostics",children:"Diagnostics"}),i&&n.jsx(os,{value:"conversation",children:d?"Room":"Chat"}),l&&n.jsx(os,{value:"screenshot",children:"Screenshot"})]}),n.jsx(tr,{value:"diagnostics",className:"min-h-0",children:n.jsx(An,{className:"max-h-[45vh]",children:n.jsx(f1,{diagnostics:r,kind:o,route:a})})}),i&&n.jsx(tr,{value:"conversation",className:"min-h-0",children:n.jsx(An,{className:"max-h-[45vh]",children:d?n.jsx(g1,{roomId:d,active:e}):n.jsx(p1,{sessionId:c,active:e})})}),l&&n.jsx(tr,{value:"screenshot",className:"min-h-0",children:n.jsx(An,{className:"max-h-[45vh]",children:n.jsx(x1,{dataUrl:l})})}),n.jsx(h1,{})]},p)]})})}const y1="0 0 0 9999px var(--scrim)";function v1(e){var r,o;const t=(r=e.closest("[data-slot]"))==null?void 0:r.getAttribute("data-slot");return((o=e.closest("[data-testid]"))==null?void 0:o.getAttribute("data-testid"))??t??e.tagName.toLowerCase()}function w1(e){let t=e;for(;t;){if(/^(auto|scroll|overlay)$/.test(getComputedStyle(t).overflowY)&&t.scrollHeight>t.clientHeight)return t;t=t.parentElement}return null}function j1({phase:e,onSelect:t,onCancel:s}){const r=u.useRef(null),o=u.useRef(null),[a,i]=u.useState(null),c=e==="picking",d=u.useCallback((x,y)=>{const b=r.current;if(!b)return null;const C=b.style.pointerEvents;b.style.pointerEvents="none";try{return document.elementFromPoint(x,y)}finally{b.style.pointerEvents=C}},[]),l=u.useCallback(x=>{var y;return x instanceof Node&&!!((y=o.current)!=null&&y.contains(x))},[]),m=u.useCallback(x=>{if(!c)return;if(l(x.target)){i(null);return}const y=d(x.clientX,x.clientY);if(!y){i(null);return}const b=y.getBoundingClientRect();i({element:y,box:{left:b.left,top:b.top,width:b.width,height:b.height},label:v1(y)})},[c,d,l]),h=u.useCallback(x=>{if(!c||l(x.target))return;const y=d(x.clientX,x.clientY)??(a==null?void 0:a.element);y&&t(y)},[c,d,l,t,a]),p=u.useCallback(x=>{if(!c)return;const y=w1(d(x.clientX,x.clientY));y==null||y.scrollBy({left:x.deltaX,top:x.deltaY})},[c,d]);u.useEffect(()=>{if(!c)return;const x=y=>{y.preventDefault(),y.stopImmediatePropagation(),y.key==="Escape"&&s()};return window.addEventListener("keydown",x,!0),()=>window.removeEventListener("keydown",x,!0)},[c,s]),u.useEffect(()=>{var y;const x=document.activeElement;return(y=r.current)==null||y.focus(),()=>{x instanceof HTMLElement&&x.focus()}},[]),u.useEffect(()=>{if(!c)return;const x=()=>{i(y=>{if(!y)return y;const b=y.element.getBoundingClientRect();return{...y,box:{left:b.left,top:b.top,width:b.width,height:b.height}}})};return window.addEventListener("scroll",x,!0),()=>window.removeEventListener("scroll",x,!0)},[c]);const f=c?a:null,g=f!==null&&f.box.top<28;return Ns.createPortal(n.jsxs("div",{ref:r,role:"dialog","aria-modal":"true","aria-label":"Point at the part of the app that looks wrong",tabIndex:-1,className:K("fixed inset-0 z-50 focus:outline-none",c?"cursor-crosshair":"cursor-wait"),onPointerMove:m,onPointerLeave:()=>i(null),onClick:h,onWheel:p,onContextMenu:x=>{x.preventDefault(),c&&s()},children:[c&&(f?n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"border-primary pointer-events-none absolute rounded-sm border-2",style:{left:f.box.left,top:f.box.top,width:f.box.width,height:f.box.height,boxShadow:y1}}),n.jsx("div",{className:"bg-primary text-primary-foreground text-2xs pointer-events-none absolute max-w-[60vw] truncate rounded-sm px-1.5 py-0.5 font-mono leading-tight",style:{left:Math.max(4,f.box.left),top:g?f.box.top+f.box.height+4:f.box.top-22},children:f.label})]}):n.jsx("div",{className:"bg-scrim absolute inset-0"})),c&&n.jsxs("div",{ref:o,className:"bg-popover text-popover-foreground absolute bottom-6 left-1/2 flex -translate-x-1/2 items-center gap-3 rounded-lg border px-3 py-2 shadow-lg",children:[n.jsxs("span",{className:"flex items-center gap-2 text-xs",children:[n.jsx(vs,{className:"size-3.5 shrink-0","aria-hidden":!0}),"Click the part that looks wrong. Esc to cancel."]}),n.jsx("button",{type:"button",onClick:s,className:"text-muted-foreground hover:text-foreground focus-visible:ring-ring rounded-sm text-xs underline underline-offset-2 transition-colors duration-150 focus-visible:ring-2 focus-visible:outline-none",children:"Cancel"})]})]}),document.body)}const Pi="text-muted-foreground hover:text-foreground h-8 px-2 text-xs aria-disabled:pointer-events-none aria-disabled:opacity-50";function br({tip:e,children:t}){return n.jsxs(pn,{children:[n.jsx(gn,{asChild:!0,children:t}),n.jsx(xn,{className:"max-w-60 text-center",children:e})]})}function k1({showPictureTools:e,isPreparing:t,hasPointed:s,hasWords:r,isMobile:o,onCapture:a,onPointAtElement:i,onPick:c}){const d=u.useId(),l=u.useId(),m=u.useId(),h=u.useId();function p(C){var I;const S=(I=C.target.files)==null?void 0:I[0];C.target.value="",S&&c(S)}const f=r&&!o;if(!e&&!f)return null;const g=o?"Add a photo":"Add an image",x=o?"Add a photo from your library.":"Add an image from your files, or paste or drop one here.",y="Take a picture of this app. Never the rest of your screen.",b="Click the part that looks wrong. DorkOS crops the picture to it.";return n.jsxs("div",{className:"flex flex-wrap items-center gap-1 border-t px-1.5 py-1.5",children:[e&&n.jsxs(n.Fragment,{children:[n.jsx("span",{id:l,className:"sr-only",children:y}),n.jsx(br,{tip:y,children:n.jsxs(L,{"aria-describedby":l,type:"button",variant:"ghost",size:"sm",onClick:()=>{t||a()},"aria-disabled":t||void 0,className:Pi,children:[n.jsx(iy,{className:"size-3.5","aria-hidden":!0}),"Capture app"]})}),!o&&n.jsx(br,{tip:b,children:n.jsxs(L,{"aria-describedby":m,type:"button",variant:"ghost",size:"sm",onClick:()=>{t||i()},"aria-disabled":t||void 0,className:Pi,children:[n.jsx(vs,{className:"size-3.5","aria-hidden":!0}),s?"Point again":"Point at it"]})}),!o&&n.jsx("span",{id:m,className:"sr-only",children:b}),n.jsx("span",{id:h,className:"sr-only",children:x}),n.jsx(br,{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(sb,{className:"size-3.5","aria-hidden":!0}),n.jsx("input",{id:d,type:"file",accept:"image/*","aria-label":g,"aria-describedby":h,disabled:t,className:"sr-only",onChange:p})]})})]}),f&&n.jsxs("span",{className:"text-muted-foreground ml-auto pr-1.5 text-xs","aria-hidden":!0,children:[Wt?"⌘↵":"Ctrl+↵"," to send"]})]})}function Li({imageUrl:e,alt:t,caption:s,pointed:r=!1,detail:o,onOpen:a,onRemove:i,removeLabel:c}){const d=n.jsxs(n.Fragment,{children:[e?n.jsx("img",{src:e,alt:t,className:"size-full object-cover"}):n.jsx("span",{className:"text-muted-foreground flex size-full items-center justify-center",children:n.jsx(vs,{className:"size-4","aria-hidden":!0})}),s&&n.jsxs("span",{className:"bg-background/85 text-2xs absolute inset-x-0 bottom-0 flex items-center gap-1 truncate px-1.5 py-0.5 text-left leading-tight",children:[r&&n.jsx(vs,{className:"size-3 shrink-0","aria-hidden":!0}),n.jsx("span",{className:"truncate",children:s})]})]}),l=a?n.jsx("button",{type:"button",onClick:a,"aria-label":`Open ${t.charAt(0).toLowerCase()}${t.slice(1)}`,className:"focus-visible:ring-ring relative block size-full overflow-hidden rounded-[inherit] focus-visible:ring-2 focus-visible:outline-none",children:d}):n.jsx("div",{role:"img","aria-label":t,className:"relative size-full overflow-hidden rounded-[inherit]",children:d});return n.jsxs("div",{className:"bg-muted/40 relative h-16 w-28 shrink-0 rounded-md border",children:[o&&a?n.jsxs(pn,{children:[n.jsx(gn,{asChild:!0,children:l}),n.jsx(xn,{className:"text-2xs max-w-72 font-mono break-all",children:o})]}):l,n.jsx("button",{type:"button",onClick:i,"aria-label":c,className:"bg-background/90 text-muted-foreground hover:text-foreground focus-visible:ring-ring absolute top-1 right-1 flex size-5 items-center justify-center rounded-full border transition-colors duration-150 focus-visible:ring-2 focus-visible:outline-none",children:n.jsx(Be,{className:"size-3","aria-hidden":!0})})]})}function Fi({label:e,summary:t,pressed:s,onPressedChange:r,onPreview:o}){return n.jsxs("span",{className:K("inline-flex items-center rounded-full border text-xs transition-colors duration-150",s?"bg-muted/60 text-foreground":"text-muted-foreground"),children:[n.jsxs(pn,{children:[n.jsx(gn,{asChild:!0,children:n.jsxs("button",{type:"button","aria-pressed":s,onClick:()=>r(!s),className:"hover:text-foreground focus-ring-inset flex items-center gap-1 rounded-full py-1 pr-1.5 pl-2.5",children:[s&&n.jsx(Xt,{className:"size-3","aria-hidden":!0}),e]})}),n.jsx(xn,{className:"max-w-60",children:t})]}),n.jsx("button",{type:"button",onClick:o,"aria-label":`Preview ${e.toLowerCase()}`,className:"text-muted-foreground hover:text-foreground focus-ring-inset flex items-center justify-center rounded-full py-1 pr-2.5 pl-1 max-sm:min-h-11 max-sm:min-w-11 max-sm:px-0",children:n.jsx(Mp,{className:"size-3.5","aria-hidden":!0})})]})}function S1({currentUser:e,anonymous:t,onToggleAnonymous:s,contact:r,onContactChange:o}){const a=u.useId(),i=u.useId();if(e)return n.jsxs("div",{className:"flex flex-col gap-1",children:[n.jsxs("div",{className:"text-muted-foreground flex items-center gap-1.5 text-xs",children:[t?n.jsx(gy,{className:"size-3.5 shrink-0","aria-hidden":!0}):n.jsx(_p,{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&&!xl(r);return n.jsxs("div",{className:"flex flex-col gap-1.5",children:[n.jsx(He,{htmlFor:a,className:"text-xs",children:"Your email"}),n.jsx(xt,{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 C1=[{value:"feedback",label:"Feedback",icon:Es},{value:"bug",label:"Bug",icon:Lp},{value:"idea",label:"Idea",icon:rb}];function N1({kind:e,onChange:t}){return n.jsx("div",{role:"radiogroup","aria-label":"What kind of feedback",className:"flex gap-1.5",children:C1.map(({value:s,label:r,icon:o})=>{const a=e===s;return n.jsxs("button",{type:"button",role:"radio","aria-checked":a,onClick:()=>t(s),className:K("focus-visible:ring-ring flex items-center gap-1.5 rounded-full border px-3 py-1 text-xs font-medium transition-colors duration-150 focus-visible:ring-2 focus-visible:outline-none",a?"border-foreground/60 text-foreground bg-muted/60":"text-muted-foreground hover:text-foreground"),children:[n.jsx(o,{className:"size-3.5","aria-hidden":!0}),r]},s)})})}function A1({needsWords:e,canSend:t,isSubmitting:s,onOpenGitHubIssue:r}){const o=u.useId();return n.jsxs(rn,{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(bs,{className:"size-3 shrink-0","aria-hidden":!0}),"Only the DorkOS team sees this"]}),n.jsx(L,{type:"submit",disabled:!t,"aria-keyshortcuts":"Meta+Enter Control+Enter","aria-describedby":e?o:void 0,className:"shrink-0",children:s?"Sending…":"Send"})]}),n.jsxs("p",{className:"text-muted-foreground text-center text-xs",children:["Prefer a public GitHub issue?"," ",n.jsx("button",{type:"button",onClick:r,className:"hover:text-foreground focus-visible:ring-ring rounded-sm underline underline-offset-2 transition-colors duration-150 focus-visible:ring-2 focus-visible:outline-none",children:"Open one instead"})]})]})}const E1={feedback:"What works, what does not, what you wish it did…",bug:"What happened, and what did you expect instead?",idea:"What would you like DorkOS to do?"};function $i(e,t,s){return{diagnostics:e==="bug"||s,conversation:e==="bug"&&t}}function I1({open:e,onOpenChange:t,initialKind:s,prefillMessage:r,crashStack:o,currentUser:a,initialScreenshotDataUrl:i}){const c=!Pe(),{isSubmitting:d,sessionId:l,roomId:m,route:h,buildDiagnostics:p,send:f}=LA(),g=Uy(),x=!!(l||m),y=l?`session:${l}`:m?`room:${m}`:void 0,{throughSeq:b}=_u(m,!1),C=!!a,S=u.useId(),[I,v]=u.useState(s??"feedback"),[E,R]=u.useState(r??""),[M,O]=u.useState(xa),[_,D]=u.useState(!1),[k,j]=u.useState(!1),[N,w]=u.useState(!1),[T,F]=u.useState(!1),[$,W]=u.useState("diagnostics"),[X,ie]=u.useState(null),[B,Y]=u.useState(null),[oe,pe]=u.useState(null),[V,G]=u.useState(null),[te,we]=u.useState(0),ne=u.useRef(te);u.useEffect(()=>{ne.current=te},[te]);const[q,he]=u.useState(!1),[ge,Ve]=u.useState(o),[Qe,Re]=u.useState(y),Xe=u.useRef(null),ee=VA({enabled:e}),ye=E.trim().length>0,je=ye||ee.dataUrl!==null||X!==null,[vt,Ge]=u.useState(e);if(e!==vt&&(Ge(e),e)){F(!1),G(null);const J=i;if(!!(r||o||J)||!je){const jt=s??"feedback",Vn=$i(jt,!!l,!!o);v(jt),R(r??""),O(xa()),D(!1),j(Vn.diagnostics),w(Vn.conversation),he(!1),ie(null),Y(null),Ve(o),Re(y),ee.reset(J),we(Vs=>Vs+1)}else y!==Qe&&(w(!1),Re(y))}function U(J){const Ne=$i(J,!!l,!!ge);j(Ne.diagnostics),w(Ne.conversation)}function de(J){v(J),U(J)}function ke(J){W(J),F(!0)}async function Je(J){const Ne=ne.current,jt=t1(J),Vn=l1(J);B&&ee.dataUrl===B&&ee.clear(),Y(null),G("capturing");const Vs=await ee.captureElement(J);Ne===ne.current&&(G(null),ie(jt),pe(Vn),Y(Vs),v("bug"),q||U("bug"))}function Ze(){B&&ee.dataUrl===B&&ee.clear(),ie(null),Y(null)}function Ie(){R(""),ie(null),Y(null),he(!1),Ve(void 0),ee.clear()}const wt=ye&&!d&&!ee.isPreparing,Ot=C?_||a==null?void 0:a.email:xl(M)?M.trim():void 0;async function Mt(){!wt||!await f({kind:I,message:E,...C?{}:{contact:M},includeDiagnostics:k,includeConversation:N,...m&&b?{roomThroughSeq:b}:{},anonymous:_,...ge?{crashStack:ge}:{},...ee.dataUrl?{screenshotDataUrl:ee.dataUrl}:{},...X?{element:X}:{},...Ot?{notifyEmail:Ot}:{}})||(C||Bp(M),Ie(),t(!1))}function z(J){J.preventDefault(),Mt()}function Se(J){const Ne=Xe.current;Ne&&(J.preventDefault(),Ne.focus(),Ne.setSelectionRange(Ne.value.length,Ne.value.length))}function A(J){J.key!=="Enter"||!(J.metaKey||J.ctrlKey)||J.nativeEvent.isComposing||T||(J.preventDefault(),Mt())}const H=ee.handlers,Z=V!==null,re=X?oe:null,xe=Bu(re),et=!!(X&&B&&ee.dataUrl===B),Ce=!!ee.dataUrl&&!et,ze=!ye&&(!!ee.dataUrl||X!==null);return n.jsxs(n.Fragment,{children:[Z&&n.jsx(j1,{phase:V,onSelect:J=>void Je(J),onCancel:()=>G(null)}),n.jsx(bt,{open:e&&!Z,onOpenChange:t,children:n.jsxs(yt,{...H,onKeyDown:A,desktopProps:{className:"max-w-md",onOpenAutoFocus:Se},className:K("max-h-[85vh] !min-h-0",ee.isDraggingOver&&"ring-primary ring-2"),children:[n.jsxs(ft,{children:[n.jsx(st,{className:"text-sm font-medium",children:"Send feedback"}),n.jsx(pt,{className:"text-muted-foreground text-xs",children:"Straight to the DorkOS team. Private."})]}),n.jsxs("form",{onSubmit:z,noValidate:!0,className:"flex min-h-0 flex-1 flex-col gap-4",children:[n.jsxs(At,{alignWithHeader:!0,className:"flex flex-col gap-4",children:[n.jsx(N1,{kind:I,onChange:de}),n.jsxs("div",{className:K("dark:bg-input/30 flex flex-col rounded-lg border transition-[border-color,box-shadow] duration-150","focus-within:border-ring focus-within:ring-ring focus-within:ring-[3px]",ee.isDraggingOver&&"border-primary"),children:[n.jsx(He,{htmlFor:S,className:"sr-only",children:"Your message"}),n.jsx(Fp,{ref:Xe,id:S,value:E,onChange:J=>R(J.target.value),placeholder:X?u1(re):E1[I],rows:4,maxLength:$p,className:"min-h-24 resize-none rounded-lg border-0 bg-transparent shadow-none focus-visible:ring-0 dark:bg-transparent"}),(X||Ce||ee.isPreparing||ee.isDraggingOver)&&n.jsxs("div",{className:"flex flex-wrap items-center gap-2 px-2.5 pb-2.5",children:[X&&n.jsx(Li,{imageUrl:et?B??void 0:void 0,alt:`The part you pointed at: ${xe}`,caption:xe,pointed:!0,detail:X.selector,...et?{onOpen:()=>ke("screenshot")}:{},onRemove:Ze,removeLabel:m1(re)}),Ce&&ee.dataUrl&&n.jsx(Li,{imageUrl:ee.dataUrl,alt:"The screenshot you attached",onOpen:()=>ke("screenshot"),onRemove:ee.clear,removeLabel:"Remove screenshot"}),(ee.isPreparing||ee.isDraggingOver)&&n.jsx("p",{role:"status","aria-live":"polite",className:"text-muted-foreground text-xs",children:ee.isDraggingOver?"Drop to attach":"Getting it ready…"})]}),n.jsx(k1,{showPictureTools:!0,isPreparing:ee.isPreparing,hasPointed:X!==null,hasWords:ye,isMobile:!c,onCapture:()=>void ee.capture(),onPointAtElement:()=>G("picking"),onPick:J=>void ee.attach(J)})]}),n.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[n.jsx("span",{className:"text-muted-foreground mr-0.5 text-xs",children:"Also send"}),n.jsx(Fi,{label:"Diagnostics",summary:"Version, window size, browser, and recent errors.",pressed:k,onPressedChange:J=>{he(!0),j(J)},onPreview:()=>ke("diagnostics")}),x&&n.jsx(Fi,{label:m?"This room":"This chat",summary:m?`The last ${gl} messages in this room.`:"Shows what led to the bug.",pressed:N,onPressedChange:J=>{he(!0),w(J)},onPreview:()=>ke("conversation")})]}),n.jsx(S1,{currentUser:a??null,anonymous:_,onToggleAnonymous:()=>D(J=>!J),contact:M,onContactChange:O})]}),n.jsx(A1,{needsWords:ze,canSend:wt,isSubmitting:d,onOpenGitHubIssue:()=>g(I==="idea"?"feature":"bug")})]}),n.jsx(b1,{open:T,onOpenChange:F,initialTab:$,diagnostics:p(ge?{crashStack:ge}:void 0),kind:I,route:h,showConversation:x,sessionId:l,roomId:m,...ee.dataUrl?{screenshotDataUrl:ee.dataUrl}:{}})]})})]})}function R1(){const e=Cn(a=>a.open),t=Cn(a=>a.prefill),s=Cn(a=>a.openFeedback),r=Cn(a=>a.setOpen),o=zp();return u.useEffect(()=>{const a=Up();a&&s(a)},[s]),n.jsx(I1,{open:e,onOpenChange:r,initialKind:t.kind,prefillMessage:t.message,crashStack:t.crashStack,currentUser:o?{email:o.email,name:o.name}:null})}function T1(){const e=Me();u.useEffect(()=>{var s,r,o;if(!((s=window.electronAPI)!=null&&s.onNavigate))return;const t=window.electronAPI.onNavigate(a=>{e({href:a})});return(o=(r=window.electronAPI).getPendingNavigate)==null||o.call(r).then(a=>{a&&e({href:a})}),t},[e])}function D1(){const{closeActive:e}=_o();u.useEffect(()=>{const t=window.electronAPI;if(t!=null&&t.onCloseTab)return t.onCloseTab(()=>e())},[e])}function O1(){const[e,t]=u.useState(!1);return u.useEffect(()=>{var a,i,c;if(!((a=window.electronAPI)!=null&&a.onFullscreenChange))return;let s=!0,r=!1;const o=window.electronAPI.onFullscreenChange(d=>{r=!0,t(d)});return(c=(i=window.electronAPI).getFullscreenState)==null||c.call(i).then(d=>{s&&!r&&t(d)}),()=>{s=!1,o()}},[]),e}const Bi="window-blurred";function M1(){u.useEffect(()=>{var a,i,c;if(!Kp||!((a=window.electronAPI)!=null&&a.onFocusChange))return;const e=document.documentElement,t=d=>{e.classList.toggle(Bi,!d)};let s=!0,r=!1;const o=window.electronAPI.onFocusChange(d=>{r=!0,t(d)});return(c=(i=window.electronAPI).getFocusState)==null||c.call(i).then(d=>{s&&!r&&t(d)}),()=>{s=!1,o(),e.classList.remove(Bi)}},[])}const _1="/channels";function P1(){pw();const e=Hp(),t=zn(),s=e===_1&&!t.community?t.id??null:null,{data:r}=yc(s),{data:o}=Ls(),a=u.useMemo(()=>(o??[]).filter(Mn).length,[o]);return{room:s&&r?r:null,unreadRoomCount:a}}function L1({unreadRoomCount:e}){pk();const t=P(c=>c.isStreaming),s=P(c=>c.isWaitingForUser),r=On(c=>c.schedulesWaitingCount),o=On(c=>c.needsYouCount),a=De({select:c=>c.location.href}),i=Ps(a);return Wy(c=>Wp(i,{...c,badgeCount:e+r,needsYou:s||o>0}),t),null}function F1(){const e=$n(),t=Hs(),s=le(),r=Me(),o=u.useRef(null);u.useEffect(()=>{var d;if(!e||!t.data)return;const a=JSON.stringify([e.ownerKey,e.epoch]),i=((d=o.current)==null?void 0:d.owner)===a?o.current.rows:null,c=new Map(t.data.map(l=>[l.ref,{status:l.status,label:l.label,generation:ba(l.ref)}]));if(o.current={owner:a,rows:c},!!i)for(const[l,m]of i){if(m.status!=="connected")continue;const h=c.get(l);if((h==null?void 0:h.status)==="connected")continue;const p=xs(_n().destination)===l,f=ba(l)>m.generation,g=h===void 0?"removed":"revoked";(f?Promise.resolve():Gp(s,e,l,g)).then(()=>{p&&xs(_n().destination)===l&&r({...ve.home(),replace:!0})}),g==="revoked"&&ce(`This DorkOS can no longer reach ${m.label}.`,{description:"Still a member? Pick it in the sidebar switcher to reconnect."})}},[e,t.data,r,s])}function $1(){F1(),Av(),qp()}function B1({isFullscreen:e}){return n.jsx("div",{className:K("desktop-darwin:block app-drag-region hidden shrink-0",!e&&"desktop-darwin:h-11"),"aria-hidden":"true"})}class z1 extends u.Component{constructor(){super(...arguments);yn(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 U1=5e3;function zu({testId:e,headline:t,detail:s}){const{isFetching:r,refetch:o}=_e({refetchInterval:U1});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(It,{size:120,className:"mb-8 opacity-80 dark:hidden"}),n.jsx(It,{variant:"white",size:120,className:"mb-8 hidden opacity-80 dark:block"}),n.jsx("h1",{className:"text-xl font-semibold tracking-tight",children:t}),n.jsx("p",{className:"text-muted-foreground mt-3 text-sm",children:s}),n.jsx(L,{variant:"outline",className:"mt-6",onClick:()=>void o(),disabled:r,children:r?"Trying…":"Try again"})]})})}function K1(){return n.jsx(zu,{testId:"server-unreachable",headline:"DorkOS can’t reach its server",detail:"It may still be starting up. DorkOS keeps checking."})}function H1(){const{open:e}=at(),t=P(r=>r.setControlCenterOpen),s=Ys(()=>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(jx,{surface:"control-center"}),n.jsxs(L,{variant:"ghost",size:"sm",className:"text-muted-foreground h-7 self-start px-2 text-xs",onClick:s(()=>e("permissions")),children:["Edit permissions",n.jsx(fn,{className:"size-3.5","aria-hidden":!0})]})]})}const en={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 W1(){var m,h;const e=Gs(),t=go(),s=P(p=>p.setRemoteAccessOpen),r=P(p=>p.setControlCenterOpen),a=Ys(()=>r(!1))(()=>s(!0)),i=e.isSetUp,c=e.state==="starting"||e.state==="stopping",d=e.hasServerReport;let l;return d?i?e.error!==null?l=n.jsxs("span",{className:"flex min-w-0 items-baseline gap-1.5",children:[n.jsx("span",{className:"text-destructive truncate",children:vl(e.error)}),n.jsx("button",{type:"button",onClick:a,className:"focus-ring text-foreground shrink-0 rounded-sm underline underline-offset-2",children:"Fix…"})]}):e.state==="blocked"?l=n.jsxs("span",{className:"flex min-w-0 items-baseline gap-1.5",children:[n.jsx("span",{className:"text-status-warning-fg truncate",children:((m=e.managed)==null?void 0:m.reason)??"Needs attention"}),n.jsx("button",{type:"button",onClick:a,className:"focus-ring text-foreground shrink-0 rounded-sm underline underline-offset-2",children:"Fix…"})]}):e.state==="connected"?l=`On · ${e.host??"connected"}`:e.state==="asleep"?l=e.host?`Closed for now · ${e.host}`:"Closed for now":e.state==="draining"?l=en.draining:e.state==="reconnecting"?l=e.host?`On · ${e.host} · reconnecting…`:"Reconnecting…":e.state==="starting"?l=en.starting:e.state==="stopping"?l=en.stopping:l=en.off:l=en.unconfigured:l=en.off,d&&((h=e.managed)!=null&&h.cloudStale)&&typeof l=="string"&&(l=`${l} · Can’t reach DorkOS Cloud`),n.jsx(bl,{label:"Remote access",description:n.jsx("span",{"data-testid":"remote-access-row-description",className:K("block min-w-0",c&&"motion-safe:animate-breath"),children:l}),children:n.jsx(yl,{checked:i&&e.isChecked,disabled:!d||i&&e.isTransitioning,"aria-label":"Remote access",onCheckedChange:p=>{if(!i){a();return}t.toggle(p)}})})}const G1=1,q1=10,Y1=4;function V1(){var l,m;const{data:e}=_e(),t=qn(),s=le(),{limits:r,setLimits:o}=Yp(),a=Ts(),i=()=>void s.invalidateQueries({queryKey:Fe.all}),c=((l=e==null?void 0:e.claudeCode)==null?void 0:l.persistentSession)??!0,d=((m=e==null?void 0:e.scheduler)==null?void 0:m.maxConcurrentRuns)??Y1;return n.jsx(Vp,{children:n.jsxs(Qp,{children:[!a&&n.jsx(W1,{}),n.jsx(_x,{}),n.jsx(ya,{label:"Limit automatic replies",description:(r==null?void 0:r.turnLimitsEnabled)===!1?"Agents reply to each other without limit until you press Stop.":n.jsxs(n.Fragment,{children:["Agents pause after a long back-and-forth."," ",n.jsxs(Sa,{label:"About reply limits",children:[n.jsx("p",{children:"Your next message starts the count over."}),n.jsx("p",{children:"Set the numbers in Settings → Advanced → Room limits."})]})]}),checked:(r==null?void 0:r.turnLimitsEnabled)??!0,disabled:r===null,onCheckedChange:h=>o({turnLimitsEnabled:h})}),!a&&n.jsx(ya,{label:"Warm agents",description:n.jsxs(n.Fragment,{children:["Replies start about 4× faster. Each warm agent uses up to about 1 GB."," ",n.jsxs(Sa,{label:"About warm agents",children:[n.jsx("p",{children:"Your agent stays running between messages."}),n.jsx("p",{children:"At most twelve agents stay warm at once."})]})]}),checked:c,disabled:t.isPending,onCheckedChange:h=>t.mutate({runtimes:{claudeCode:{persistentSession:h}}},{onSuccess:i})}),n.jsx(bl,{label:"Scheduled runs at once",description:"How many scheduled tasks run together.",children:n.jsx(kx,{value:d,min:G1,max:q1,"aria-label":"Scheduled runs at once",onCommit:h=>t.mutate({scheduler:{maxConcurrentRuns:h}},{onSuccess:i})})})]})})}const zi="claude-code";function Q1(){var R,M,O,_,D;const{data:e}=_e(),{data:t}=lc(),{sessions:s}=Gc(),r=Xp(),{data:o}=Fc(r),{data:a}=Hx(),i=Lx(),c=i.data,d=xw(),l=co(),{open:m}=at(),{open:h}=jo(),p=oo(),f=P(k=>k.setControlCenterOpen),g=Ys(()=>f(!1)),x=i.isError,y=t===void 0||e===void 0||c===void 0&&!x,b=e==null?void 0:e.executionDefaults,C=(b==null?void 0:b.runtime)??zi,S=(R=t==null?void 0:t.capabilities[C])==null?void 0:R.permissionModes,I=((M=S==null?void 0:S.values.find(k=>k.id===S.default))==null?void 0:M.stop)??"ask",v=(b==null?void 0:b.trustStop)??I,E=[];if(!y){for(const j of(b==null?void 0:b.perRuntime)??[])j.trustStop===null||j.trustStop===v||E.push({key:`runtime:${j.runtime}`,kind:"runtime",name:ct(j.runtime).label,detail:Zs(j.trustStop),onOpen:l?g(()=>m("runtimes")):null});for(const j of s){const N=(O=t==null?void 0:t.capabilities[j.runtime])==null?void 0:O.permissionModes,w=N==null?void 0:N.values.find(F=>F.id===j.permissionMode),T=w==null?void 0:w.stop;!T||T===v||E.push({key:`session:${j.id}`,kind:"session",name:j.title||"Untitled chat",detail:(w==null?void 0:w.label)??er(j.permissionMode),onOpen:l?g(()=>l(Kt({session:j.id,dir:j.cwd}))):null})}const k=((D=(_=t==null?void 0:t.capabilities[zi])==null?void 0:_.permissionModes)==null?void 0:D.values)??[];for(const j of o??[]){const N=k.find(T=>T.id===j.permissionMode),w=N==null?void 0:N.stop;!w||w===v||E.push({key:`task:${j.id}`,kind:"task",name:j.displayName??j.name,detail:(N==null?void 0:N.label)??er(j.permissionMode),onOpen:l?g(()=>l({...ve.tasks()})):null})}for(const j of a??[]){const N=k.find(T=>T.id===j.permissionMode),w=N==null?void 0:N.stop;!w||w===v||E.push({key:`binding:${j.id}`,kind:"binding",name:j.label||j.adapterId,detail:(N==null?void 0:N.label)??er(j.permissionMode),onOpen:l?g(()=>p({app:j.adapterId})):null})}}if(c){const k=new Map(c.areas.map(w=>[w.id,w.label])),j=new Map(c.areas.flatMap(w=>w.actions.map(T=>[T.id,T.title]))),N=w=>g(()=>h(w,"permissions"));for(const w of c.exceptions){const T=w.action?j.get(w.action)??w.action:k.get(w.area),F=Fx[w.state];E.push({key:`agent-permission:${w.agentId}:${w.action??w.area}`,kind:"agent-permission",name:w.agentName,detail:`${T??w.area} ${F}`,why:{question:`Why is ${T??w.area} set to ${F} for ${w.agentName}?`,sentence:$x({state:w.state,source:w.action?"agent-action":"agent-area",preset:c.preset,agentName:w.agentName}),...w.lastChange?{lastChange:w.lastChange}:{}},onOpen:N(w.agentId),onReset:()=>d.mutate({agentId:w.agentId,key:w.action?{kind:"action",action:w.action}:{kind:"area",area:w.area},surface:"control-center"}),resetting:d.isPending})}for(const w of c.filesAndCommands.exceptions)E.push({key:`agent-permission:${w.agentId}:files`,kind:"agent-permission",name:w.agentName,detail:`Files & commands ${Zs(w.stop)}`,why:{question:`Why is Files & commands set to ${Zs(w.stop)} for ${w.agentName}?`,sentence:Bx(w.stop,"agent",w.agentName),...w.lastChange?{lastChange:w.lastChange}:{}},onOpen:N(w.agentId),onReset:()=>d.mutate({agentId:w.agentId,key:{kind:"files"},surface:"control-center"}),resetting:d.isPending})}return{rows:E,isEmpty:!y&&!x&&E.length===0,isResolving:y,permissionsUnreadable:x}}const X1={runtime:Wx,session:Zp,task:Ao,binding:uc,"agent-permission":Jp};function J1(){const{rows:e,isEmpty:t,isResolving:s,permissionsUnreadable:r}=Q1();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=X1[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(fn,{className:"text-muted-foreground/60 size-3.5 shrink-0","aria-hidden":!0})]}),o.why?n.jsx(zx,{question:o.why.question,sentence:o.why.sentence,...o.why.lastChange?{lastChange:o.why.lastChange}:{},className:"shrink-0 px-1"}):null,o.onReset?n.jsxs(L,{variant:"ghost",size:"sm",className:"h-7 shrink-0 px-2 text-xs",disabled:o.resetting,"aria-label":`Reset ${o.name}: ${o.detail}`,onClick:o.onReset,children:[n.jsx(Rc,{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 Z1(){const e=Ll();return Fl(e)?n.jsxs("p",{"data-testid":"control-center-keep-awake",className:"text-muted-foreground flex items-start gap-1.5 px-1 text-xs",children:[n.jsx(md,{className:"mt-px size-3 shrink-0","aria-hidden":!0}),n.jsxs("span",{children:["Keeping this computer awake: ",$l(e.working),"."]})]}):null}function eE(){return n.jsxs("div",{className:"flex flex-col gap-4","data-testid":"control-center-body",children:[n.jsx(H1,{}),n.jsx(V1,{}),n.jsx(J1,{}),n.jsx(Z1,{})]})}function tE(){const e=P(r=>r.controlCenterOpen),t=P(r=>r.setControlCenterOpen),s=Pe();return n.jsxs(dn,{open:e,onOpenChange:t,modal:!0,autoFocus:!0,children:[n.jsx(un,{asChild:!0,children:n.jsx("button",{type:"button","data-testid":"control-center-trigger","aria-label":"Control Center",className:"focus-ring text-muted-foreground hover:text-foreground inline-flex size-11 shrink-0 items-center justify-center rounded-md transition-colors md:size-7",children:n.jsx(va,{className:"size-(--size-icon-sm)","aria-hidden":!0})})}),n.jsxs(mn,{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(va,{className:"text-status-success size-4 shrink-0","aria-hidden":!0}),n.jsx("h2",{className:"text-sm font-semibold",children:"Control Center"})]}),n.jsx(hn,{children:"Control Center"}),n.jsx(eE,{})]})]})}function nE(){const e=P(t=>t.toggleControlCenter);u.useEffect(()=>{const t=s=>{(s.metaKey||s.ctrlKey)&&s.shiftKey&&(s.key==="l"||s.key==="L")&&(s.preventDefault(),e())};return document.addEventListener("keydown",t),()=>document.removeEventListener("keydown",t)},[e])}function sE(){const{isDesktop:e}=wl(),t="In use from the web";return e?n.jsx("p",{className:"text-sm font-medium",children:t}):n.jsx(hn,{className:"text-sm font-medium",children:t})}function rE(){const{presence:e,canEnd:t,end:s,ending:r,error:o}=Sx(),[a,i]=u.useState(!1);return e!=null&&e.active?n.jsxs(dn,{open:a,onOpenChange:i,children:[n.jsx(un,{asChild:!0,children:n.jsx("button",{type:"button","data-testid":"remote-session-indicator","aria-label":"In use from the web. Show details",className:"focus-ring text-muted-foreground hover:text-foreground inline-flex size-7 shrink-0 items-center justify-center rounded-md transition-colors",children:n.jsx(eg,{className:"size-4","aria-hidden":!0})})}),n.jsxs(mn,{side:"bottom",align:"end","aria-label":"In use from the web",className:"w-72 max-w-[calc(100vw-1.5rem)] space-y-3 p-3",children:[n.jsxs("div",{className:"space-y-0.5",children:[n.jsx(sE,{}),e.since&&n.jsxs("p",{className:"text-muted-foreground text-xs",children:["Someone is chatting here from the web. Started ",Kn(e.since),"."]})]}),e.devices.length>0?n.jsx(Cx,{devices:e.devices}):n.jsx("p",{className:"text-muted-foreground text-xs",children:"No device named yet."}),t?n.jsxs("div",{className:"space-y-1",children:[n.jsx(L,{variant:"outline",size:"sm",disabled:r,onClick:s,children:"End now"}),n.jsx("p",{className:"text-muted-foreground text-xs",children:"This also pauses chat from the web."})]}):n.jsx("p",{className:"text-muted-foreground text-xs",children:"End it on the computer DorkOS runs on."}),o&&n.jsx("p",{className:"text-destructive text-xs",role:"alert",children:o})]})]}):null}function oE(e,t){const s=u.useRef(null),[r,o]=u.useState(0);return u.useEffect(()=>{if(!t)return;const a=s.current;s.current=e,a!==null&&a!=="connected"&&e==="connected"&&o(i=>i+1)},[e,t]),r}function aE({url:e}){const t=ut();return n.jsxs("div",{"data-testid":"remote-access-qr",children:[n.jsx(se.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(tg,{url:e,size:168})}),n.jsx("p",{className:"text-muted-foreground mt-2 text-center text-xs",children:"Scan with your phone"})]})}function iE({url:e}){const{copied:t,failed:s,copy:r}=Bn();let o,a;return t?(o=n.jsx(Xt,{className:"size-3.5"}),a="Copied"):s?(o=n.jsx(Be,{className:"text-destructive size-3.5"}),a="Couldn’t copy"):(o=n.jsx(so,{className:"size-3.5"}),a="Copy link"),n.jsxs("div",{className:"bg-muted/40 rounded-lg border p-2.5","data-testid":"remote-access-link",children:[n.jsx("p",{className:"text-foreground truncate font-mono text-xs",title:e,children:e}),n.jsxs(L,{variant:"outline",size:"sm",className:"mt-2 w-full gap-1.5",onClick:()=>void r(e),children:[o,a]})]})}function cE(){const e=Gs(),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 lE({onClose:e}){const t=Gs(),s=go(),r=Pe(),o=P(h=>h.setRemoteAccessOpen),a=Ys(e),i=t.url,c=t.mode==="managed",d=i?n.jsx(iE,{url:i},"link"):null,l=i?n.jsx(aE,{url:i},"qr"):null,m=r?[d,l]:[l,d];return n.jsxs("div",{className:"flex flex-col gap-3","data-testid":"remote-access-panel",children:[!r&&n.jsxs("header",{className:"flex items-center gap-2",children:[n.jsx("span",{className:K("inline-block size-2 shrink-0 rounded-full",jl(t.state)),"aria-hidden":!0}),n.jsx("h2",{className:"text-sm font-semibold",children:kl(t.state)})]}),t.error!==null&&n.jsx("p",{role:"alert","data-testid":"remote-access-panel-error",className:"text-destructive text-xs",children:vl(t.error)}),c&&n.jsx(cE,{}),i===null&&t.state!=="asleep"&&n.jsx("p",{className:"text-muted-foreground text-xs",children:"Your link appears here when it’s ready."}),m,n.jsxs("div",{className:"flex items-center justify-between gap-3 pt-1",children:[n.jsx("span",{className:"text-muted-foreground text-sm",children:"Remote access"}),n.jsx(yl,{checked:t.isChecked,disabled:t.isTransitioning,"aria-label":"Remote access",onCheckedChange:h=>void s.toggle(h)})]}),n.jsx(L,{variant:"ghost",size:"sm",className:"text-muted-foreground hover:text-foreground -mx-1 justify-start",onClick:a(()=>o(!0)),children:"Manage…"})]})}function Uu(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 dE(e,t){const s=e==="starting"||e==="asleep"&&!t?"Open remote access":"Show link and QR code";return`${Uu(e,t)}. ${s}`}function uE(){const e=Gs(),t=P(i=>i.remoteAccessBeaconOpen),s=P(i=>i.setRemoteAccessBeaconOpen),r=ut(),o=oE(e.state,e.hasServerReport);u.useEffect(()=>{!e.isLive&&t&&s(!1)},[e.isLive,t,s]);const a=e.isLive?Uu(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(dn,{open:t,onOpenChange:s,modal:!0,children:[n.jsx(un,{asChild:!0,children:n.jsxs("button",{type:"button","data-testid":"remote-access-beacon","data-state-name":e.state,"aria-label":dE(e.state,e.host),className:K("focus-ring text-muted-foreground hover:text-foreground relative inline-flex size-11 shrink-0 items-center justify-center rounded-md transition-colors md:size-7",e.state==="reconnecting"&&"opacity-70"),children:[n.jsx(fs,{className:K("size-(--size-icon-sm)",e.state==="starting"&&"motion-safe:animate-breath"),"aria-hidden":!0}),n.jsx("span",{"aria-hidden":!0,"data-testid":"remote-access-beacon-dot",className:K("border-background absolute right-0.5 bottom-0.5 size-1.5 rounded-full border",jl(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(mn,{side:"bottom",align:"end","aria-label":"Remote access",className:"w-72 max-w-[calc(100vw-1.5rem)] p-3",children:[n.jsx(hn,{children:kl(e.state)}),n.jsx(lE,{onClose:()=>s(!1)})]})]}),n.jsx(rE,{})]})}function mE({work:e}){const{isDesktop:t}=wl();return t?n.jsxs("p",{className:"text-sm font-medium",children:["Keeping awake: ",e]}):n.jsxs(hn,{className:"text-sm font-medium",children:["Keeping awake: ",e]})}function hE(){const e=Ll(),{open:t}=at(),[s,r]=u.useState(!1);if(!Fl(e))return null;const o=$l(e.working);return n.jsxs(dn,{open:s,onOpenChange:r,children:[n.jsx(un,{asChild:!0,children:n.jsx("button",{type:"button","data-testid":"keep-awake-beacon","aria-label":`Keeping this computer awake: ${o}. Show details`,className:"focus-ring text-muted-foreground hover:text-foreground inline-flex size-11 shrink-0 items-center justify-center rounded-md transition-colors md:size-7",children:n.jsx(md,{className:"size-(--size-icon-sm)","aria-hidden":!0})})}),n.jsxs(mn,{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(mE,{work:o}),n.jsx("p",{className:"text-muted-foreground text-xs",children:Nx}),n.jsx(L,{variant:"outline",size:"sm",onClick:()=>{r(!1),t(ka.tab,ka.section)},children:"Sleep settings"})]})]})}function fE(){return n.jsxs("div",{"data-slot":"global-header-actions",className:"ml-auto flex h-11 items-center justify-end gap-1 md:h-auto md:shrink-0 lg:gap-2",children:[n.jsx(tE,{}),n.jsx(uE,{}),n.jsx(hE,{}),n.jsx(ng,{})]})}const pE="onboarding";function gE({render:e}){const t=sg(),s=rg(),{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:pE}),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 xE={renderAccountLink:e=>n.jsx(gE,{render:e}),renderRuntimeConnect:Gx,renderOtherService:({onSave:e})=>n.jsx(qx,{onSave:e})},bE="HOST_NOT_ALLOWED",Ui=240;function yE({status:e,message:t,code:s}){const r=s===bE&&t?t:void 0,o=r===void 0?`Your settings didn’t load (HTTP ${e}). DorkOS keeps trying.`:r.length>Ui?`${r.slice(0,Ui).trimEnd()}…`:r;return n.jsx(zu,{testId:"server-error",headline:"The server answered with an error",detail:o})}function vE(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 yr={at:0};function wE(e,t){return e>yr.at&&(yr=t==null?{at:e}:{at:e,...vE(t)}),e>cn?yr:void 0}function jE(e){return e.state.dataUpdatedAt>cn?!0:"always"}function kE(e){return!e}function SE(e){var t;return((t=e.at(-1))==null?void 0:t.pathname)??""}function CE({descriptors:e}){const t=e.reduce((s,r)=>s===null||r.priority>s.priority?r:s,null);return n.jsx(Ye,{mode:"wait",initial:!1,children:t&&n.jsx(se.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 NE=["memory-provider-status"],AE=6e4;function EE(){const e=ae(),{data:t}=Ee({queryKey:[...NE],queryFn:()=>e.getMemoryProviderStatus(),staleTime:AE,refetchOnWindowFocus:!0});return t}function IE(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||RE(s,r))&&t.set(s.subject.id,s)}return[...t.entries()].filter(([,s])=>s.outcome!=="cleared").map(([s])=>s)}function RE(e,t){return e.createdAt!==t.createdAt?e.createdAt>t.createdAt:e.id>t.id}function TE({configuredId:e,benched:t}){return n.jsxs(zl,{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 DE="runtimes",OE=3;function ME({runtimes:e}){const{open:t}=at(),s=og(),{nameFor:r}=ag();if(e.length===0)return null;const o=e.map(ig),a=o.slice(0,OE).map(l=>l.accountRoot?r(l.accountRoot):Sl(l.runtime)),i=e.length-a.length,c=`${PE(a)}${i>0?` and ${i} more`:""}`,d=o.length===1&&o[0].runtime==="claude-code"?o[0].accountRoot:void 0;return n.jsxs(zl,{variant:"critical",icon:Er,actions:n.jsxs(n.Fragment,{children:[o.length===1&&s&&n.jsx(_E,{runtimes:o.map(l=>l.runtime),renderCreditsOffer:s}),d?n.jsx(Ax,{accountRoot:d,name:r(d),state:"signed-out",showAccountName:!0,hideStatus:!0}):n.jsx(L,{variant:"outline",size:"sm",onClick:()=>t(DE),children:"Review sign-ins"})]}),children:[n.jsx("span",{className:"font-medium",children:c})," ",o.length===1?"is":"are"," signed out. ",o.length===1?"Its":"Their"," agents and tasks wait until you sign in."]})}function _E({runtimes:e,renderCreditsOffer:t}){var d;const s=cc(),{data:r}=dc(),o=!Yx(),a=((d=Bc().data)==null?void 0:d.linked)===!0,i=cg(a,zc({enabled:a}).data),c=e.find(l=>lg(dg(s.data,l),r,l)==="lead");return c?n.jsxs(dn,{children:[n.jsx(un,{asChild:!0,children:n.jsx(L,{size:"sm","data-testid":"signin-banner-credits",disabled:i===null,children:i===null?"DorkOS credits":`${i} DorkOS credits`})}),n.jsxs(mn,{align:"end",className:"w-80 p-4",children:[n.jsxs(hn,{children:["Run ",Sl(c)," on DorkOS credits"]}),n.jsxs("div",{className:"space-y-3",children:[t({runtime:c,origin:`signin-banner:${c}`,fullWidth:!0}),n.jsx(Vx,{remote:o})]})]})]}):null}function PE(e){return e.length<=1?e[0]??"":`${e.slice(0,-1).join(", ")} and ${e[e.length-1]}`}const Ku={critical:40,warning:30};function LE(){const e=EE();return!e||e.configuredId===e.activeId?null:{id:"memory-provider-benched",variant:"warning",priority:Ku.warning,render:()=>n.jsx(TE,{configuredId:e.configuredId,benched:e.benched})}}const FE={kinds:["signin.required"]};function $E(){const{notifications:e}=ug(FE),t=u.useMemo(()=>IE(e),[e]);return t.length===0?null:{id:"runtime-signin",variant:"critical",priority:Ku.critical,render:()=>n.jsx(ME,{runtimes:t})}}function BE(e){const t=LE(),s=$E();return[t,s].filter(r=>r!==null)}function zE(){const e=qn(),[t,s]=u.useState(!1),r=()=>{e.mutate({telemetry:{install:!1,heartbeat:!1,usage:!1,userHasDecided:!0}})},o=()=>{e.mutate({telemetry:{install:!0,heartbeat:!0,usage:!0,userHasDecided:!0}})};return n.jsxs(n.Fragment,{children:[n.jsxs(Cl,{children:[n.jsx(Nl,{children:"Share anonymous usage data?"}),n.jsx(Al,{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(Ex,{open:t,onToggle:()=>s(a=>!a)}),n.jsx("a",{href:Nr("/telemetry"),target:"_blank",rel:"noopener noreferrer",className:"text-muted-foreground hover:text-foreground text-xs font-medium underline underline-offset-2",children:"Full contract"})]}),t&&n.jsx(Ix,{})]}),n.jsxs(El,{className:"items-center gap-2 sm:justify-between",children:[e.isError?n.jsx("p",{role:"alert",className:"text-destructive text-xs",children:"Couldn’t save your choice. Try again."}):n.jsx("span",{"aria-hidden":!0}),n.jsxs("div",{className:"flex justify-end gap-2",children:[n.jsx(L,{variant:"outline",size:"sm",onClick:r,disabled:e.isPending,children:"Don’t share"}),n.jsx(L,{size:"sm",onClick:o,disabled:e.isPending,children:"Share anonymously"})]})]})]})}function UE(e){return e.everyAgentLevel!==void 0?e.everyAgentLevel!==null:e.everyAgent!==null}function KE(e){const{data:t}=ob(),s=new Set(e),r=((t==null?void 0:t.connections)??[]).filter(a=>s.has(a.connectionId)&&UE(a)),o=new Map;for(const a of r)o.set(a.toolkit,(o.get(a.toolkit)??0)+1);return r.map(a=>{const i=mg(a.toolkit);return{connectionId:a.connectionId,name:(o.get(a.toolkit)??0)>1?`${i} (${a.label})`:i}})}function HE({apps:e,onChooseAgents:t,disabled:s}){return n.jsxs("div",{className:"space-y-1 text-sm","data-testid":"trust-notice-shared-apps",children:[n.jsx("p",{className:"text-muted-foreground",children:"Shared with every agent:"}),n.jsx("ul",{className:"space-y-0.5",children:e.map(r=>n.jsxs("li",{className:"flex items-center justify-between gap-2",children:[n.jsx("span",{children:r.name}),n.jsx(L,{variant:"link",size:"sm",className:"h-auto p-0 text-xs",disabled:s,"aria-label":`Choose agents for ${r.name}`,onClick:()=>t(r.connectionId),children:"Choose agents"})]},r.connectionId))})]})}const WE=ml("/guides/permissions#what-changed"),GE=["Everything they do is recorded in Activity. Anyone can pause an agent.","Messages and code from strangers still need your yes."],qE="Agents ask first again. Shared apps stay shared; change them in Connections.";function YE(e){return e instanceof Error&&e.message||"Couldn’t save that. Try again."}function VE({onClose:e,sharedConnectionIds:t=[]}){return t.length>0?n.jsx(QE,{onClose:e,connectionIds:t}):n.jsx(Hu,{onClose:e,sharedApps:[]})}function QE({onClose:e,connectionIds:t}){return n.jsx(Hu,{onClose:e,sharedApps:KE(t)})}function Hu({onClose:e,sharedApps:t}){const s=Me(),r=qn(),o=Ux({kind:"default"}),[a,i]=u.useState(!1),[c,d]=u.useState(null),l=a||r.isPending||o.isPending,m=async(f,g)=>{d(null),i(!0);try{f&&await o.mutateAsync({kind:"preset",preset:"careful",surface:"first-run"}),await r.mutateAsync({ui:{trustNoticeSeenAt:new Date().toISOString()}})}catch(x){d(YE(x)),i(!1);return}i(!1),f&&ce.success(t.length>0?qE:"Agents ask first again. Change it in Permissions."),e(),g==null||g()},h=f=>void s({...ve.connections(),search:{app:f,who:"picked"}}),p=f=>{if(t.length>1){e(),h(f);return}m(!1,()=>h(f))};return n.jsxs(n.Fragment,{children:[n.jsxs(Cl,{children:[n.jsx(Nl,{"data-testid":"trust-notice",children:"Agents now work without asking"}),n.jsx(Al,{children:"They edit files, run commands, schedule work and use your connected apps on their own."})]}),n.jsx("div",{className:"text-muted-foreground space-y-2 text-sm",children:GE.map(f=>n.jsx("p",{children:f},f))}),t.length>0&&n.jsx(HE,{apps:t,onChooseAgents:p,disabled:l}),c&&n.jsx("p",{role:"alert",className:"text-destructive text-xs",children:c}),n.jsxs(El,{className:"items-center gap-2 sm:justify-between",children:[n.jsx(hg,{href:WE,className:"text-muted-foreground hover:text-foreground text-xs font-medium underline underline-offset-2",children:"What changed"}),n.jsxs("div",{className:"flex flex-wrap justify-end gap-2",children:[n.jsx(L,{variant:"outline",size:"sm",onClick:()=>m(!0),disabled:l,children:"Keep asking me"}),n.jsx(L,{size:"sm",onClick:()=>m(!1),disabled:l,children:"Got it"})]})]})]})}function XE(e){var s,r,o,a;return!e||!(((s=e.onboarding)==null?void 0:s.completedAt)!=null||((r=e.onboarding)==null?void 0:r.dismissedAt)!=null)||((o=e.ui)==null?void 0:o.trustNoticeSeenAt)!=null||e.callerRoute==="wifi"?!1:Dx((a=e.permissions)==null?void 0:a.preset)==="trusted"}const Wu={high:30,low:10};function JE(){var t;const{data:e}=_e();return(t=e==null?void 0:e.telemetry)!=null&&t.userHasDecided?null:{id:"telemetry-consent",priority:Wu.low,render:()=>n.jsx(zE,{})}}function ZE(){const{data:e}=_e();return XE(e)?{id:"trust-notice",priority:Wu.high,render:({onClose:t})=>{var s;return n.jsx(VE,{onClose:t,sharedConnectionIds:((s=e==null?void 0:e.permissions)==null?void 0:s.sharedAtUpgrade)??[]})}}:null}function eI(){const e=ZE(),t=JE();return P(r=>r.onboardingHiddenForSession)?[]:[e,t].filter(r=>r!==null)}function tI(e){return e.reduce((t,s)=>t===null||s.priority>t.priority?s:t,null)}function nI({onboardingOverlayVisible:e=!1}){const t=eI(),{data:s,dataUpdatedAt:r}=_e(),o=P(b=>b.momentShownThisLaunch),a=P(b=>b.markMomentShown),[i,c]=u.useState(null),[d,l]=u.useState(null),m=u.useRef(null),h=(s==null?void 0:s.onboarding)!=null&&(s.onboarding.completedAt!=null||s.onboarding.dismissedAt!=null),p=r>cn,f=e||!p||!h,g=f?null:tI(t);i===null&&g!==null&&!o&&(c(g.id),l(g)),u.useEffect(()=>{i!==null&&a()},[i,a]);const x=!f&&i!==null&&t.some(b=>b.id===i),y=()=>c(null);return n.jsx(fg,{open:x,onOpenChange:b=>{b||y()},children:d!==null&&n.jsx(pg,{ref:m,onOpenAutoFocus:b=>{var C;b.preventDefault(),(C=m.current)==null||C.focus()},children:d.render({onClose:y})},d.id)})}function sI({slotKey:e,direction:t,children:s}){return n.jsx("div",{className:"relative flex min-h-0 flex-1 flex-col overflow-hidden",children:n.jsx(Ye,{mode:"wait",initial:!1,custom:t,children:n.jsx(se.div,{"data-testid":"sidebar-body-swap",custom:t,initial:"enter",animate:"center",exit:"exit",variants:{enter:r=>({x:`${r*100}%`,opacity:0}),center:{x:0,opacity:1},exit:r=>({x:`${r*-100}%`,opacity:0})},transition:{duration:.2,ease:[.4,0,.2,1]},className:"flex min-h-0 flex-1 flex-col overflow-hidden",children:s},e)})})}function rI(){const{approvals:e,isError:t,retry:s}=gg(),{interactions:r}=xg(),o=bg(),a=yg(e),{schedules:i}=vg(),c=wg(i),d=jg(r),l=Il(),m=Me(),h=u.useMemo(()=>{const g=new Set([...e.map(x=>kg(x.approvalId)),...r.map(x=>Sg(x.interaction.id))]);return l.filter(x=>x.kind!=="schedule-approval"&&!g.has(x.id))},[l,e,r]),p=e.length+r.length+i.length+h.length;return!t&&a.length===0&&r.length===0&&o.length===0&&c.length===0&&h.length===0?{slot:null,count:p}:{count:p,slot:n.jsxs("div",{"data-testid":"mobile-now-attention",className:"flex flex-col gap-2 px-2 pt-0.5 pb-1",children:[t&&n.jsx(Cg,{onRetry:s}),(r.length>0||o.length>0)&&n.jsx(Ng,{asks:r,agentNames:d,onOpenSession:g=>{m(Kt({session:g}))}}),a.length>0&&n.jsx(Ag,{approvals:a}),n.jsx(Ye,{initial:!1,children:c.map(g=>n.jsx(Eg,{task:g},g.id))}),h.length>0&&n.jsx("div",{"data-testid":"mobile-now-rows",className:"flex flex-col",children:h.map(g=>n.jsx(Yb,{signal:g},g.id))})]})}}const Gu=[{id:"home",label:"Home",icon:Ig,badged:!0,kind:"panel"},{id:"dorkbot",label:"DorkBot",icon:ko,badged:!1,kind:"action"},{id:"you",label:"You",icon:ao,badged:!1,kind:"panel"}],Qr="calc(3.5rem + env(safe-area-inset-bottom))",Cs=Rg(e=>({panelUp:!1,raise:()=>e({panelUp:!0}),lower:()=>e({panelUp:!1})}));function Ki(){Cs.getState().lower()}const oI=1e3;function aI(e){if(e!==0)return e===1?"1 agent needs you":`${e} agents need you`}function iI(e){const[t,s]=u.useState(""),r=u.useRef(t);return u.useEffect(()=>{const o=e??"";if(o===r.current)return;const a=setTimeout(()=>{r.current=o,s(o)},oI);return()=>clearTimeout(a)},[e]),t}function cI({current:e,needsYouCount:t,dorkBotReady:s,onSelect:r,label:o="Main"}){return n.jsx("nav",{"aria-label":o,"data-testid":"mobile-tab-bar",className:"bg-sidebar border-border/60 flex shrink-0 items-stretch border-t",style:{height:Qr,paddingBottom:"env(safe-area-inset-bottom)"},children:Gu.map(a=>{const i=a.icon,c=a.id===e,d=a.badged&&t>0?t:null,l=a.kind==="action"&&!s;return n.jsxs("button",{type:"button",onClick:()=>r(a.id),disabled:l,"aria-current":c?"page":void 0,"data-testid":`mobile-tab-${a.id}`,"data-mobile-tab":"",className:K("focus-ring text-2xs relative flex flex-1 flex-col items-center justify-center gap-0.5 transition-[color,background-color,scale] duration-150","active:bg-sidebar-accent motion-safe:active:scale-[0.96]",c?"text-sidebar-foreground font-semibold":"text-sidebar-foreground/70 hover:text-sidebar-foreground font-medium","disabled:pointer-events-none disabled:opacity-50"),children:[n.jsxs("span",{className:"relative",children:[n.jsx(i,{className:"size-5","aria-hidden":!0}),d!==null&&n.jsx(zs,{"data-testid":`mobile-tab-badge-${a.id}`,count:d,tone:"warning",placement:"corner",className:"-top-1.5 -right-2.5"})]}),a.label]},a.id)})})}function Hi({id:e,active:t,children:s}){return n.jsx("div",{id:`mobile-tab-panel-${e}`,"data-testid":`mobile-tab-panel-${e}`,"data-active":t?"":void 0,inert:!t,className:K("absolute inset-0",!t&&"invisible"),children:s})}function lI({takeover:e}){vu();const t=rI(),s=ku(),r=wu(s),{ask:o,ready:a}=Tg(),[i,c]=u.useState("home"),d=Cs(g=>g.panelUp),l=Cs(g=>g.raise),m=Qt();u.useEffect(()=>m.subscribe("onBeforeLoad",Ki),[m]),u.useEffect(()=>Ki,[]),u.useEffect(()=>(document.documentElement.style.setProperty("--mobile-tab-dock",Qr),()=>{document.documentElement.style.removeProperty("--mobile-tab-dock")}),[]);const h=u.useCallback(g=>{const x=Gu.find(y=>y.id===g);if(x!==void 0){if(x.kind==="action"){if(!a)return;c(g),o();return}c(g),l()}},[o,a,l]),p=t.count,f=iI(aI(p));return n.jsxs(il,{activeTarget:s.activeTarget,children:[n.jsxs("div",{"data-testid":"mobile-tab-panels",inert:!d,className:K("bg-background fixed inset-x-0 top-0 z-30",!d&&"pointer-events-none invisible"),style:{bottom:`calc(${Qr} + var(--pip-dock, 0px))`},children:[n.jsx(Hi,{id:"home",active:i==="home",children:n.jsxs(Na,{width:"full",className:"px-3 py-2",children:[n.jsx(Ou,{}),t.slot,e??n.jsx(Iu,{model:r}),n.jsx(yu,{})]})}),n.jsx(Hi,{id:"you",active:i==="you",children:n.jsxs(Na,{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(eA,{}),n.jsx(Rl,{})]})})]}),n.jsx("span",{"data-testid":"mobile-needs-you-live-region","aria-live":"polite","aria-atomic":"true",className:"sr-only",children:f}),n.jsx(cI,{current:d?i:null,needsYouCount:p,dorkBotReady:a,onSelect:h})]})}function dI(){const e=ae(),t=le();return Vt({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 uI(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 mI({step:e,templateName:t,seedDisplayName:s=null,faceSeed:r=null,runtimeSeed:o="claude-code"}){var pe;const a=ae(),{data:i}=Ee({queryKey:Fe.current(),queryFn:()=>a.getConfig(),staleTime:3e4}),c=((pe=i==null?void 0:i.agents)==null?void 0:pe.defaultDirectory)??"",[d,l]=u.useState(""),[m,h]=u.useState(!1),[p,f]=u.useState(""),[g,x]=u.useState(!1),[y,b]=u.useState(!1),[C,S]=u.useState(null),[I,v]=u.useState(""),[E,R]=u.useState(!1),[M,O]=u.useState(o),[_,D]=u.useState(s);s!==_&&(D(s),s&&(l(s),h(!1)));const[k,j]=u.useState(o);o!==k&&(j(o),O(o));const N=u.useMemo(()=>d?Dg(d):"",[d]),w=u.useMemo(()=>N?Og(N):{valid:!1,error:void 0},[N]),T=d.length>0&&N.length>0&&!w.valid,F=p||(c&&N?`${c}/${N}`:""),$=e!=="naming"||!F?"idle":C!==null&&C.directory===F?C.status:"checking",W=d.length>0&&w.valid&&$!=="error",X=u.useRef(null);u.useEffect(()=>{if(e!=="naming")return;const V=t?!d||m?t.replace(/^@[^/]+\//,""):null:m?"":null;if(V===null)return;const G=`${e}|${t??""}`;X.current!==G&&(X.current=G,l(V),h(!!t))},[e,t]);const ie=u.useRef(null);u.useEffect(()=>{if(e!=="naming"||E||!r)return;const V=`${e}|${r}`;ie.current!==V&&(ie.current=V,v(r))},[e,r]),u.useEffect(()=>{if(e!=="naming"||!F)return;const V=F,G=setTimeout(()=>{uI(a,V).then(te=>{S({directory:V,status:te})})},500);return()=>clearTimeout(G)},[e,F,a]);function B(V){l(V),m&&h(!1)}function Y(V){v(V),R(!0)}function oe(){X.current=null,ie.current=null,l(""),h(!1),f(""),x(!1),b(!1),S(null),v(""),R(!1),O(o)}return{displayName:d,slug:N,handleNameChange:B,nameAutoFilled:m,slugValidation:w,showSlugError:T,defaultDirectory:c,resolvedDirectory:F,directoryOverride:p,setDirectoryOverride:f,directoryOpen:g,setDirectoryOpen:x,directoryPickerOpen:y,setDirectoryPickerOpen:b,conflictStatus:$,canSubmit:W,icon:I,setIcon:Y,runtime:M,setRuntime:O,reset:oe}}function hI(e){var a;const t=(e==null?void 0:e.packageName)??null,{data:s,isError:r,error:o}=eb(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&&tb(o)&&{refusal:o},...s!=null&&s.disclosed&&s.contentHash?{approval:{approvedDisclosure:s.disclosed,approvedContentHash:s.contentHash},packageAgentName:s.manifest.name}:{}}}const fI={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."}},vr={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"]},pI=[["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 gI(e){if(!e)return vr.default;const t=[e.name,e.description,e.category,...e.tags??[]].filter(Boolean).join(" ").toLowerCase();for(const[s,r]of pI)if(r.some(o=>t.includes(o)))return vr[s];return vr.default}function xI(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 bI=64,yI=16,Wi=3;function vI(e){return e.map(t=>t.replace(/[\u0000-\u001f\u007f]/g," ").replace(/\s+/g," ").trim().slice(0,bI)).filter(t=>t.length>0).slice(0,yI)}function wI(e){const t=vI(e.capabilities??[]),s=t.length>0?`
77
+
78
+ Your declared abilities include: ${t.join(", ")}. Draw your first-action offer from these when it fits.`:"";return["You have just been created. This is your first moment awake — greet the person who made you.","",`Read your ${nn.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 ${nn.soul} so you can introduce yourself is fine; anything beyond that waits for their go-ahead.) Just make the offer and let them decide. Speak warmly and directly to the person.`+s].join(`
79
+ `)}function jI(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 ${nn.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 ${Wi} 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 ${Wi} 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 ${nn.soul} now, using your file-editing tools. It lives at \`.dork/${nn.soul}\` in your working directory and already contains a "Personality Traits" block fenced by \`${Mg}\` and \`${wa}\` — leave that fenced block exactly as it is. Replace only the prose BELOW the \`${wa}\` 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 ${nn.soul} is the only file you touch now. Do not act on their project or run their work until they say go. Speak warmly and directly to the person throughout.`].join(`
80
+ `)}const kI={template:wI,"design-your-own":jI};function SI(e,t){return kI[e](t)}function CI(e,t){return lb(SI(e,t))}const qu="🤖",NI=["🤖","🦾","🧭","🛰️","📡","🔭","🗺️","🧠","🦉","🦊","🐝","🐙","🚀","⚡","🌟","🔮","🛠️","🔧","📊","📋","✅","🗂️","🔔","🛡️"];function Gi({face:e,title:t,subtitle:s,chips:r,variant:o,tabIndex:a,onSelect:i,onKeyDown:c,ref:d,"data-testid":l}){return n.jsxs("button",{ref:d,type:"button",tabIndex:a,onClick:i,onKeyDown:c,"data-gallery-card":"","data-testid":l,className:K("card-interactive group flex h-full flex-col gap-2 rounded-xl border p-4 text-left","focus-visible:ring-ring focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none",o==="design"?"border-primary/40 bg-primary/5 hover:border-primary/60 border-dashed":"bg-card hover:border-border/80 hover:shadow-md"),children:[n.jsx("span",{className:"text-3xl leading-none","aria-hidden":!0,children:e}),n.jsxs("div",{className:"space-y-0.5",children:[n.jsx("p",{className:"text-sm font-semibold",children:t}),n.jsx("p",{className:"text-muted-foreground text-xs leading-relaxed",children:s})]}),r&&r.length>0&&n.jsx("div",{className:"mt-auto flex flex-wrap gap-1 pt-1",children:r.map(m=>n.jsx("span",{className:"bg-muted text-muted-foreground text-2xs rounded-full px-2 py-0.5",children:m},m))})]})}function AI(e){return{source:e.source,name:e.name,displayName:Tl(e),description:e.description,icon:e.icon,tags:e.tags,category:e.category,packageName:e.name,...e.marketplace?{marketplace:e.marketplace}:{}}}function EI(e){return e.tags&&e.tags.length>0?e.tags.slice(0,2):e.category?[e.category]:[]}function II(e){const t=e.replace(/\/+$/,"");return t.split("/").pop()??t}function RI({onDesignYourOwn:e,onSelectTemplate:t,onImport:s}){const{data:r,error:o,isLoading:a}=_g(),i=Yl(a),[c,d]=u.useState(""),[l,m]=u.useState(!1),h=u.useMemo(()=>(r??[]).filter(f=>f.type==="agent"),[r]),p=Yy(h.length+1);return n.jsxs("div",{className:"space-y-5",children:[n.jsxs("div",{role:"group","aria-label":"Choose what your agent will do",className:"grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4","data-testid":"agent-gallery",children:[n.jsx(Gi,{ref:p.setRef(0),variant:"design",face:n.jsx(ko,{className:"text-primary size-7"}),title:"Design your own",subtitle:"Describe the job in your own words.",tabIndex:p.tabIndexFor(0),onSelect:e,onKeyDown:f=>p.handleKeyDown(f,0),"data-testid":"gallery-design-your-own"}),h.map((f,g)=>{const x=g+1;return n.jsx(Gi,{ref:p.setRef(x),variant:"template",face:f.icon??qu,title:Tl(f),subtitle:f.description??"A ready-made agent.",chips:EI(f),tabIndex:p.tabIndexFor(x),onSelect:()=>t(AI(f)),onKeyDown:y=>p.handleKeyDown(y,x),"data-testid":`gallery-template-${f.name}`},f.name)}),i&&h.length===0&&Array.from({length:2}).map((f,g)=>n.jsx(dt,{className:"h-28 rounded-xl","data-testid":"gallery-skeleton"},g))]}),!i&&h.length===0&&n.jsx("p",{className:"text-muted-foreground text-center text-xs","data-testid":"gallery-templates-note",children:o?"Couldn’t load ready-made agents. Check marketplace sources in Settings.":"No ready-made agents yet. Add a marketplace source in Settings."}),n.jsxs(So,{open:l,onOpenChange:m,children:[n.jsx(Co,{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(Jt,{className:K("size-3.5 transition-transform",l&&"rotate-180")}),"Build from a template URL"]})}),n.jsx(No,{children:n.jsxs("div",{className:"flex items-center gap-2 pt-2",children:[n.jsx(xt,{value:c,onChange:f=>d(f.target.value),placeholder:"github.com/org/repo","data-testid":"custom-url-input",className:"flex-1"}),n.jsx(L,{size:"sm",disabled:!c,onClick:()=>{const f=II(c);t({source:c,name:f,displayName:Pg(f)}),d("")},"data-testid":"custom-url-go",children:"Continue"})]})})]}),s&&n.jsx("div",{className:"border-t pt-3",children:n.jsxs("button",{type:"button",onClick:s,className:"text-muted-foreground hover:text-foreground inline-flex items-center gap-1.5 text-sm transition-colors","data-testid":"gallery-import-link",children:[n.jsx(Lg,{className:"size-4"}),"Bring in an existing project folder",n.jsx("span",{"aria-hidden":!0,children:"→"})]})})]})}function TI({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:NI.map(s=>{const r=s===e;return n.jsx("button",{type:"button","aria-label":`Face ${s}`,"aria-pressed":r,onClick:()=>t(s),className:K("flex size-9 items-center justify-center rounded-md border text-lg transition-colors","focus-visible:ring-ring focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none",r?"border-primary bg-primary/10":"hover:border-border hover:bg-accent border-transparent"),"data-testid":`face-${s}`,children:n.jsx("span",{"aria-hidden":!0,children:s})},s)})})}function DI({value:e,onChange:t}){return n.jsx("div",{role:"radiogroup","aria-label":"Runs on",className:"flex gap-1.5","data-testid":"runtime-picker",children:Fg.map(s=>{const r=ct(s),o=r.icon,a=e===s;return n.jsxs("button",{type:"button",role:"radio","aria-checked":a,onClick:()=>t(s),className:K("flex flex-1 items-center justify-center gap-1.5 rounded-md border px-2 py-1.5 text-xs transition-colors","focus-visible:ring-ring focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none",a?"border-primary bg-primary/10 font-medium":"hover:border-border hover:bg-accent border-transparent"),"data-testid":`runtime-${s}`,children:[n.jsx(o,{size:14}),r.label]},s)})})}function OI({face:e,name:t,jobLine:s,capabilities:r,className:o}){const a=t.trim()||"Your agent",i=t.trim().length===0;return n.jsxs("div",{className:K("bg-card shadow-soft flex flex-col items-center gap-3 rounded-lg border p-5",o),"data-testid":"agent-preview",children:[n.jsx("span",{className:"bg-primary/10 flex size-16 items-center justify-center rounded-full text-3xl","aria-hidden":!0,children:e}),n.jsxs("div",{className:"space-y-1 text-center",children:[n.jsx("p",{className:K("text-lg font-semibold",i&&"text-muted-foreground"),"data-testid":"preview-name",children:a}),n.jsx("p",{className:"text-muted-foreground text-sm leading-relaxed",children:s})]}),r.length>0&&n.jsx("div",{className:"flex flex-wrap justify-center gap-1.5","data-testid":"preview-capabilities",children:r.map(c=>n.jsx("span",{className:"bg-muted text-muted-foreground rounded-full px-2 py-0.5 text-xs",children:c},c))})]})}function 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(Ao,{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}),": ",nb(r)]},`${r.name}-${o}`))})]}),t&&n.jsxs("div",{className:"flex items-start gap-2","data-testid":`${s}-offer-check-failed`,children:[n.jsx(ec,{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 qi=4;function MI({form:e,suggestionPool:t,jobLine:s,previewCapabilities:r,onBack:o,onImportInstead:a,onCreate:i,isCreating:c,packageSchedules:d=[],offerCheckFailed:l=!1,isCheckingOffer:m=!1,offerRefusal:h,packageDirectory:p,templateReview:f,inheritance:g,isCheckingInheritance:x=!1}){const y=u.useRef(null),[b,C]=u.useState(0),S=e.displayName.trim().toLowerCase(),I=t.filter(M=>M.toLowerCase()!==S),v=xI(I,b,qi);u.useEffect(()=>{const M=setTimeout(()=>{var O;return(O=y.current)==null?void 0:O.focus()},160);return()=>clearTimeout(M)},[]);const E=e.displayName.trim(),R=c?`Creating ${E||"your agent"}…`:`Create ${E||"agent"}`;return n.jsxs("div",{className:"grid gap-6 md:grid-cols-2",children:[n.jsxs("div",{className:"space-y-5",children:[n.jsxs("button",{type:"button",onClick:o,className:"text-muted-foreground hover:text-foreground -ml-1 inline-flex items-center gap-1 text-xs transition-colors","data-testid":"naming-back",children:[n.jsx(Pc,{className:"size-3.5"}),"Choose a different agent"]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(He,{htmlFor:"agent-name",className:"text-sm",children:"Name"}),n.jsx(xt,{ref:y,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"}),a&&n.jsx("button",{type:"button",className:"text-primary text-xs hover:underline",onClick:a,"data-testid":"import-instead-link",children:"Import it instead"})]})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx("span",{className:"text-muted-foreground text-xs",children:"Need a name?"}),n.jsx("button",{type:"button",onClick:()=>C(M=>M+qi),"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(He,{className:"text-sm",children:"Face"}),!e.icon&&n.jsx("span",{className:"text-muted-foreground text-xs",children:"Picked for you if skipped"})]}),n.jsx(TI,{value:e.icon,onChange:e.setIcon})]}),n.jsxs(So,{open:e.directoryOpen,onOpenChange:e.setDirectoryOpen,children:[n.jsx(Co,{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(Jt,{className:K("size-4 transition-transform",e.directoryOpen&&"rotate-180")}),"Details",e.directoryOverride&&n.jsx("span",{className:"bg-primary/10 text-primary ml-1 rounded px-1.5 py-0.5 text-xs",children:"Custom"})]})}),n.jsx(No,{children:n.jsxs("div",{className:"space-y-4 pt-3",children:[n.jsxs("div",{className:"space-y-1.5",children:[n.jsx(He,{className:"text-muted-foreground text-xs",children:"Runs on"}),n.jsx(DI,{value:e.runtime,onChange:e.setRuntime})]}),p?n.jsxs("div",{className:"space-y-1.5","data-testid":"package-directory",children:[n.jsx(He,{className:"text-muted-foreground text-xs",children:"Directory"}),n.jsx("p",{className:"font-mono text-xs [overflow-wrap:anywhere]",children:p}),n.jsx("p",{className:"text-muted-foreground text-xs",children:"Kept in its package’s folder so updates reach it."})]}):n.jsxs("div",{className:"space-y-1.5",children:[n.jsx(He,{htmlFor:"agent-directory",className:"text-muted-foreground text-xs",children:"Directory"}),n.jsx(ry,{id:"agent-directory",placeholder:e.resolvedDirectory||(e.defaultDirectory?`${e.defaultDirectory}/…`:""),value:e.directoryOverride,onChange:e.setDirectoryOverride,onBrowse:()=>e.setDirectoryPickerOpen(!0),browseTestId:"browse-directory-button","data-testid":"directory-preview"}),e.conflictStatus==="no-path"&&n.jsx("p",{className:"text-muted-foreground text-xs","data-testid":"conflict-status",children:"Creates a new folder"}),e.conflictStatus==="exists-no-dork"&&n.jsx("p",{className:"text-muted-foreground text-xs","data-testid":"conflict-status",children:"That folder is already there. The project goes inside it."}),e.conflictStatus==="error"&&n.jsx("p",{className:"text-destructive text-xs","data-testid":"conflict-status",children:"Can’t open this folder. Pick another."})]}),!p&&e.slug&&!e.showSlugError&&n.jsxs("p",{className:"text-muted-foreground text-xs",children:["Folder name:"," ",n.jsx("code",{className:"bg-muted rounded px-1 py-0.5 font-mono text-xs",children:e.slug})]})]})})]})]}),n.jsxs("div",{className:"flex flex-col gap-4 self-start",children:[n.jsx(OI,{face:e.icon||qu,name:e.displayName,jobLine:s,capabilities:r}),(d.length>0||l)&&n.jsx("dl",{className:"bg-muted/30 space-y-2.5 rounded-lg border p-3.5 text-sm",children:n.jsx(Yu,{schedules:d,checkFailed:l,testIdPrefix:"naming"})}),h!==void 0&&n.jsx(Wl,{error:h}),f,m&&n.jsx("p",{className:"text-muted-foreground text-center text-xs","data-testid":"naming-checking-offer",children:"Checking for scheduled work…"}),g,n.jsx(L,{size:"lg",onClick:i,disabled:!e.canSubmit||c||m||x||h!==void 0,"data-testid":"create-button",children:R})]})]})}function _I({seed:e,packageSchedules:t,isCheckingOffer:s,offerCheckFailed:r,offerRefusal:o,resolvedDirectory:a,canSubmit:i,isCreating:c,inheritance:d,isCheckingInheritance:l=!1,onCreate:m,onCustomize:h,onNotNow:p}){const{displayName:f,persona:g,runtime:x,capabilities:y,skills:b,schedule:C,icon:S}=e.template,I=ct(x??"claude-code").label,v=f.trim().charAt(0).toUpperCase()||"?",E=S&&Rr(S)?S:v,R=e.sourceLabel?`Offered by ${e.sourceLabel}.`:"A ready-made agent.";return n.jsxs("div",{className:"mx-auto max-w-md space-y-6","data-testid":"arrival-confirm",children:[n.jsxs("div",{className:"flex flex-col items-center gap-3 text-center",children:[n.jsx("span",{className:"bg-primary/10 text-primary flex size-20 items-center justify-center rounded-full text-4xl font-semibold","aria-hidden":"true",children:E}),n.jsxs("div",{className:"space-y-1",children:[n.jsxs(st,{className:"text-xl",children:["Meet ",f]}),n.jsx(pt,{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(PI,{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(Rs,{className:"text-muted-foreground mt-0.5 size-4 shrink-0"}),n.jsx("dt",{className:"text-muted-foreground shrink-0",children:"Lives in"}),n.jsx("dd",{className:"min-w-0",children:a?n.jsx("code",{className:"text-xs break-all",children:a}):n.jsx(dt,{className:"h-3.5 w-48 max-w-full rounded"})})]}),C&&n.jsxs("div",{className:"flex items-start gap-2","data-testid":"arrival-schedule",children:[n.jsx(Ao,{className:"text-muted-foreground mt-0.5 size-4 shrink-0"}),n.jsx("dt",{className:"text-muted-foreground shrink-0",children:"Runs on a schedule"}),n.jsx("dd",{children:C})]}),n.jsx(Yu,{schedules:t,checkFailed:r,testIdPrefix:"arrival"}),y&&y.length>0&&n.jsxs("div",{className:"flex items-start gap-2",children:[n.jsx(Rx,{className:"text-muted-foreground mt-0.5 size-4 shrink-0"}),n.jsx("dt",{className:"text-muted-foreground shrink-0",children:"Can"}),n.jsx("dd",{children:y.join(", ")})]}),b&&b.length>0&&n.jsxs("div",{className:"flex items-start gap-2",children:[n.jsx($g,{className:"text-muted-foreground mt-0.5 size-4 shrink-0"}),n.jsx("dt",{className:"text-muted-foreground shrink-0",children:"Uses skills"}),n.jsx("dd",{children:b.join(", ")})]})]}),o!==void 0&&n.jsx(Wl,{error:o}),n.jsxs("div",{className:"flex flex-col gap-2",children:[!i&&n.jsx("p",{className:"text-status-warning-fg text-center text-xs","data-testid":"arrival-needs-name",children:"Needs a name. Choose “Customize first” to add one."}),s&&n.jsx("p",{className:"text-muted-foreground text-center text-xs","data-testid":"arrival-checking-offer",children:"Checking for scheduled work…"}),d,n.jsx(L,{size:"lg",onClick:m,disabled:c||!i||s||l||o!==void 0,"data-testid":"arrival-create",children:c?"Creating…":`Create ${f}`}),n.jsxs("div",{className:"flex items-center justify-center gap-4",children:[n.jsx(L,{variant:"ghost",size:"sm",onClick:h,className:"text-muted-foreground","data-testid":"arrival-customize",children:"Customize first"}),n.jsx(L,{variant:"ghost",size:"sm",onClick:p,className:"text-muted-foreground","data-testid":"arrival-not-now",children:"Not now"})]})]})]})}function PI({runtime:e}){const t=ct(e??"claude-code").icon;return n.jsx(t,{size:16,className:"text-muted-foreground shrink-0"})}function LI(e){const t=e==null?void 0:e.body;return(t==null?void 0:t.code)==="template_needs_review"?t.template:void 0}function FI(e,t){const s=e.replace(/\/*$/,"/");return t.filter(r=>r.path===e||r.path.startsWith(s))}function $I(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 BI(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 zI(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:FI(s.path,e.settings??[])})),...t.hooks.map((s,r)=>({key:`hook:${r}`,label:mt(s.command),detail:`Runs on ${s.event}${s.source?`, while ${mt(s.source)} is in use`:""}.`})),...(t.skillCommands??[]).map((s,r)=>({key:`command:${s.source}:${r}`,label:mt(s.command),detail:`Runs when skill “${mt(s.skill)}” is used (${mt(s.source)})`+(s.usesArguments?". Reads the text typed after it.":".")})),...t.mcpServers.map(s=>({key:`mcp:${s.name}`,label:s.command?zg(s.command,s.args):mt(s.url??s.name),detail:`Starts the MCP server “${mt(s.name)}”.`})),...t.skillTools.map(s=>({key:`tools:${s.source}`,label:s.tools.map(mt).join(", "),detail:`Skill “${mt(s.skill)}” may use these without asking you.`}))]}function UI({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(Bg,{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:zI(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:$I(i)})]},i.path))]},o.key)})}),n.jsxs("div",{className:"flex flex-wrap justify-end gap-2",children:[n.jsx(L,{variant:"ghost",size:"sm",onClick:s,disabled:r,children:"Don’t create it"}),n.jsx(L,{size:"sm",onClick:t,disabled:r,className:"h-auto max-w-full py-1.5 text-left [overflow-wrap:anywhere] whitespace-normal",children:r?"Creating…":BI(e)})]})]})}function KI(){const{isOpen:e,seed:t,onCreated:s,close:r}=Is(),o=sn(B=>B.open),a=dI(),i=Me(),[c,d]=u.useState("gallery"),[l,m]=u.useState(null),[h,p]=u.useState(!1);e!==h&&(p(e),e&&(m(null),d(t?"arrival":"gallery")));const f=t!=null&&t.template.icon&&Rr(t.template.icon)?t.template.icon:void 0,g=l!=null&&l.icon&&Rr(l.icon)?l.icon:f??null,x=(t==null?void 0:t.template.runtime)??"claude-code",y=(t==null?void 0:t.packageName)!==void 0?t:(l==null?void 0:l.packageName)!==void 0?{packageName:l.packageName,marketplace:l.marketplace}:null,b=hI(y),{data:C}=_e(),S=Ts()?void 0:w,I=y&&b.packageAgentName&&(C!=null&&C.dorkHome)?`${C.dorkHome}/agents/${b.packageAgentName}`:void 0,[v,E]=u.useState(null),R=mI({step:c,templateName:(l==null?void 0:l.displayName)??null,seedDisplayName:(t==null?void 0:t.template.displayName)??null,faceSeed:g,runtimeSeed:x}),M=gI(l?{name:l.name,description:l.description,category:l.category,tags:l.tags}:t?{name:t.template.displayName,description:t.template.persona}:void 0),O=l?l.description??"A ready-made agent.":t!=null&&t.template.persona?t.template.persona:"You’ll define the job together in your first chat.",_=l?l.tags??[]:(t==null?void 0:t.template.capabilities)??[];function D(){R.reset(),E(null),m(null),d("gallery")}const k=u.useCallback(B=>{m(B),d("naming")},[]),j=u.useCallback(()=>{m(null),d("naming")},[]);function N(){d(t?"arrival":"gallery")}function w(){r(),D(),o()}function T(B){var pe;if(!R.canSubmit||a.isPending)return;const Y=(y==null?void 0:y.packageName)!==void 0&&b.approval?{package:{name:y.packageName,...y.marketplace?{marketplace:y.marketplace}:{},...b.approval}}:void 0,oe=Y?void 0:(l==null?void 0:l.source)??(t==null?void 0:t.template.source);a.mutate({name:R.slug,displayName:R.displayName.trim()||void 0,runtime:R.runtime,...!Y&&R.directoryOverride?{directory:R.directoryOverride}:{},...R.icon?{icon:R.icon}:{},...Y??{},...oe?{template:oe}:{},...B?{approvedTemplateHash:B}:{},...t!=null&&t.template.persona?{persona:t.template.persona}:{},...(pe=t==null?void 0:t.template.capabilities)!=null&&pe.length?{capabilities:t.template.capabilities}:{}},{onSuccess:V=>{const G=crypto.randomUUID(),te=V.displayName??V.name,we=l||t?"template":"design-your-own";Ug.getState().register(G,{name:V.name,displayName:te,agentId:V.id,icon:V.icon,color:V.color,bornAt:V.registeredAt,path:V._path,runtime:V.runtime,kickoffMessage:CI(we,{displayName:te,capabilities:V.capabilities})}),ny();const ne=s;if(r(),D(),ne){ne();return}i(Kt({agentId:V.id,draft:"1",session:G,runtime:V.runtime}))},onError:V=>{const G=LI(V);G&&E(G)}})}function F(B){B||(r(),D())}const $=Gl(e),W=n.jsx(ow,{agentName:R.displayName||(t==null?void 0:t.template.displayName)||""}),X=fI[c],ie=c==="gallery"?"max-w-6xl":c==="naming"?"max-w-5xl":"max-w-2xl";return n.jsx(bt,{open:e,onOpenChange:F,defaultFullscreen:!0,children:n.jsxs(yt,{className:"flex flex-col gap-0 p-0",children:["title"in X&&n.jsxs(ft,{className:"shrink-0 border-b px-5 py-4",children:[n.jsx(st,{children:X.title}),n.jsx(pt,{children:X.description})]}),n.jsx("span",{className:"sr-only","aria-live":"polite","aria-atomic":"true",children:X.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 ${ie}`,children:[n.jsx(Ye,{mode:"wait",children:n.jsxs(se.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.15},children:[c==="gallery"&&n.jsx(RI,{onDesignYourOwn:j,onSelectTemplate:k,onImport:S}),c==="arrival"&&t&&n.jsx(_I,{seed:t,packageSchedules:b.schedules,isCheckingOffer:b.isChecking,offerCheckFailed:b.failed,offerRefusal:b.refusal,resolvedDirectory:I??R.resolvedDirectory,canSubmit:R.canSubmit,isCreating:a.isPending,inheritance:W,isCheckingInheritance:$.isPending,onCreate:()=>T(),onCustomize:()=>d("naming"),onNotNow:()=>F(!1)}),c==="naming"&&n.jsx(MI,{form:R,suggestionPool:M,jobLine:O,previewCapabilities:_,onBack:N,onImportInstead:S,onCreate:()=>T(),isCreating:a.isPending,packageSchedules:b.schedules,offerCheckFailed:b.failed,offerRefusal:b.refusal,isCheckingOffer:b.isChecking,packageDirectory:I,inheritance:W,isCheckingInheritance:$.isPending,templateReview:v?n.jsx(UI,{template:v,isCreating:a.isPending,onCreateAnyway:()=>T(v.contentHash),onCancel:()=>E(null)}):void 0})]},c)}),c!=="gallery"&&n.jsx(Px,{className:"mt-6"})]})}),n.jsx(gc,{open:R.directoryPickerOpen,onOpenChange:R.setDirectoryPickerOpen,initialPath:R.directoryOverride||R.defaultDirectory,onSelect:B=>{R.setDirectoryOverride(B),R.directoryOpen||R.setDirectoryOpen(!0)}})]})})}function HI({sessionId:e}){u.useEffect(()=>{var a;const r=Nt.getState(),o=((a=r.sessions[e])==null?void 0:a.cwd)??r.statusCwds[e]??null;return us.pinSession(e,o),ja.getState().setPinnedSession(e),()=>{us.unpinSession(),ja.getState().setPinnedSession(null)}},[e]);const t=Kg(e),s=u.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(Mb,{code:s.code,isIncomplete:s.isIncomplete,sessionId:e,isLatestMessage:s.isLatest,isStreaming:s.isStreaming},s.sourceMessageKey)}function WI({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 wr=64,GI={type:"spring",stiffness:480,damping:44};function qI({content:e,onRestore:t,onClose:s}){u.useEffect(()=>(document.documentElement.style.setProperty("--pip-dock",`${wr}px`),()=>{document.documentElement.style.removeProperty("--pip-dock")}),[]);const r=$b();return Ns.createPortal(n.jsxs(se.div,{"data-slot":"pip-minibar",role:"complementary","aria-label":e.title,initial:{y:wr},animate:{y:0},exit:{y:wr},transition:GI,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(cy,{className:"text-muted-foreground size-4 shrink-0"})]}),n.jsx("button",{type:"button","aria-label":"Close",onClick:s,className:"text-muted-foreground hover:bg-muted hover:text-foreground focus-ring mr-3 flex size-11 shrink-0 items-center justify-center rounded-md transition-colors",children:n.jsx(Be,{className:"size-4"})})]}),document.body)}const ns={peek:.5,expanded:.94},YI=.4,VI=800,Yi=500,jr={type:"spring",stiffness:480,damping:44};function QI({content:e,onClose:t,onMinimize:s,children:r}){const o=Sy(),a=wy(),[i,c]=u.useState("peek"),d=jd(),l=d.height,m=Math.max(0,window.innerHeight-d.top-d.height),h=ns.expanded*l,p=(ns.expanded-ns.peek)*l,f=i==="expanded"?0:p;u.useEffect(()=>{a.start({y:f,transition:jr})},[a,f]);const g=(y,b)=>{const C=f+b.offset.y,S=b.velocity.y,I=C-p,v=ns.peek*l;if(I>YI*v||I>0&&S>VI){s();return}let E;S<-Yi?E="expanded":S>Yi?E="peek":E=C<p/2?"expanded":"peek",E===i?a.start({y:f,transition:jr}):c(E)},x=y=>{y.target.closest("button")||o.start(y)};return Ns.createPortal(n.jsxs(se.div,{"data-slot":"pip-sheet",role:"complementary","aria-label":e.title,initial:{y:h},animate:a,exit:{y:h},transition:jr,drag:"y",dragListener:!1,dragControls:o,dragConstraints:{top:0,bottom:h},dragElastic:.1,dragMomentum:!1,onDragEnd:g,style:{height:h,bottom:m},className:"bg-background border-border shadow-modal fixed inset-x-0 z-40 flex flex-col rounded-t-lg border-t",children:[n.jsxs("div",{onPointerDown:x,className:"cursor-grab touch-none select-none active:cursor-grabbing",children:[n.jsx("div",{className:"bg-muted mx-auto mt-4 h-2 w-[100px] rounded-full"}),n.jsxs("div",{className:"flex items-center justify-between gap-2 border-b pt-1 pr-[max(1rem,env(safe-area-inset-right))] pb-2 pl-[max(1rem,env(safe-area-inset-left))]",children:[n.jsx("span",{className:"min-w-0 flex-1 truncate text-sm font-medium",children:e.title}),n.jsx("button",{type:"button","aria-label":"Minimize",onClick:s,className:"text-muted-foreground hover:bg-muted hover:text-foreground focus-ring flex size-11 shrink-0 items-center justify-center rounded-md transition-colors",children:n.jsx(Jt,{className:"size-4"})}),n.jsx("button",{type:"button","aria-label":"Close",onClick:t,className:"text-muted-foreground hover:bg-muted hover:text-foreground focus-ring flex size-11 shrink-0 items-center justify-center rounded-md transition-colors",children:n.jsx(Be,{className:"size-4"})})]})]}),n.jsx("div",{"data-slot":"pip-sheet-content",style:{marginBottom:f},className:"min-h-0 flex-1 overflow-y-auto pt-3 pr-[max(0.75rem,env(safe-area-inset-right))] pb-[max(0.75rem,env(safe-area-inset-bottom))] pl-[max(0.75rem,env(safe-area-inset-left))]",children:r})]}),document.body)}const Vi=360,Qi=240,Xr=16,kr={demo:WI,mcp_app:XI,widget:JI};function XI({content:e}){return n.jsx(Jb,{sessionId:e.sessionId,serverName:e.serverName,uri:e.uri,title:e.title,className:"h-full"})}function JI({content:e}){return n.jsx(HI,{sessionId:e.sessionId})}function ZI(e){u.useEffect(()=>{},[e])}function Xi(){return{x:window.innerWidth-Vi-Xr,y:window.innerHeight-Qi-Xr,width:Vi,height:Qi}}function eR(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=kr.demo;return n.jsx(t,{content:e})}case"mcp_app":{const t=kr.mcp_app;return n.jsx(t,{content:e})}case"computer":return n.jsx(oy,{content:e});case"widget":{const t=kr.widget;return n.jsx(t,{content:e})}default:return e}}function tR({content:e,onClose:t}){const s=P(c=>c.pipGeometry),r=P(c=>c.setPipGeometry),[o,a]=u.useState(Xi);u.useEffect(()=>{if(s!==null)return;const c=()=>a(d=>{const l=Xi();return eR(d,l)?d:l});return c(),window.addEventListener("resize",c),()=>window.removeEventListener("resize",c)},[s]);const i=u.useMemo(()=>s||((e==null?void 0:e.kind)!=="computer"?o:{...o,width:480,height:360,x:Math.max(0,window.innerWidth-480-Xr),y:Math.max(0,window.innerHeight-360-80)}),[s,o,e==null?void 0:e.kind]);return n.jsx(Ye,{children:e!==null&&n.jsx(Jy,{title:e.title,geometry:i,onGeometryChange:r,onClose:t,minWidth:e.kind==="computer"?360:void 0,minHeight:e.kind==="computer"?300:void 0,children:Vu(e)},"pip-panel")})}function nR(){const e=P(d=>d.pipContent),t=P(d=>d.pipMinimized),s=P(d=>d.closePip),r=P(d=>d.minimizePip),o=P(d=>d.restorePip),a=P(d=>d.openPip),i=Pe();ZI(a);const c=u.useRef(i);return u.useEffect(()=>{i&&!c.current&&e!==null&&r(),c.current=i},[i,e,r]),i?n.jsx(Ye,{children:e!==null&&(t?n.jsx(qI,{content:e,onRestore:o,onClose:s},"pip-minibar"):n.jsx(QI,{content:e,onClose:s,onMinimize:r,children:Vu(e)},"pip-sheet"))}):n.jsx(tR,{content:e,onClose:s})}const sR=new Set(["permission-prompt","question","schedule-approval"]),rR={"permission-prompt":"Needs your approval to go on.",question:"Has a question for you.","schedule-approval":"Wants to run on a timer."};function Qu(e){const t=Il(),s=Hg(),r=Lt(e),o=u.useRef(null);u.useEffect(()=>{var l,m,h,p;if(s)return;const a=new Map;for(const f of t)!sR.has(f.kind)||f.quiet===!0||a.set(f.id,{id:f.id,who:f.primary,summary:rR[f.kind],deepLink:f.deepLink});const i=o.current;if(o.current=new Set(a.keys()),i===null)return;const c=[...a.values()].filter(f=>!i.has(f.id)),d=[...i].filter(f=>!a.has(f));c.length>0&&((m=(l=r.read()).onArrive)==null||m.call(l,c)),d.length>0&&((p=(h=r.read()).onDepart)==null||p.call(h,d,a.size))},[s,t,r])}function oR(){const{permission:e}=Sb(),{prefs:t}=Cb(),s=co(),r=$e(),o=u.useRef(new Map),a=Lt(s),i=u.useCallback(()=>r||e!=="granted"||typeof document>"u"||!document.hidden?!1:typeof window<"u"&&typeof window.Notification<"u",[r,e]),c=u.useCallback((h,p,f,g)=>{let x;try{x=new Notification(p,{body:f,tag:h,silent:!0})}catch{return}x.onclick=()=>{var y;window.focus(),x.close(),o.current.delete(h),g!==null&&((y=a.read())==null||y({href:g}))},x.onclose=()=>{o.current.delete(h)},o.current.set(h,{notification:x,href:g})},[a]),d=u.useCallback(h=>{if(i())for(const p of h)c(p.id,`${p.who} needs you`,p.summary,p.deepLink)},[i,c]),l=u.useCallback(h=>{for(const p of h){const f=o.current.get(p);f!==void 0&&(f.notification.close(),o.current.delete(p))}},[]);Qu({onArrive:d,onDepart:l});const m=t.notifyOnTurnCompleteWhileAway;fe("notification",h=>{const p=Wg.safeParse(h);if(!p.success)return;const f=p.data.notification;if(f.tier!=="notable"||!m||!i())return;const g=Gg(f),x=g===null?null:aR(g.to,g.search);c(f.id,f.title,f.body??"",x)}),u.useEffect(()=>{const h=o.current;return()=>{for(const{notification:p}of h.values())p.close();h.clear()}},[])}function aR(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 iR(){const{play:e}=db(),t=u.useCallback(()=>{e("knock"),ub()},[e]),s=u.useCallback((r,o)=>{o===0&&e("settle")},[e]);return Qu({onArrive:t,onDepart:s}),oR(),null}function cR(){const e=P(r=>r.shortcutsPanelOpen),t=P(r=>r.setShortcutsPanelOpen),s=qg();return n.jsx(bt,{open:e,onOpenChange:t,children:n.jsxs(yt,{className:"sm:max-w-md",children:[n.jsx(ft,{children:n.jsx(st,{children:"Keyboard shortcuts"})}),n.jsx(At,{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(ul,{className:"inline-flex",children:Ht(i)})]},i.id))})]},r))})]})})}function lR(){const e=P(t=>t.toggleShortcutsPanel);u.useEffect(()=>{const t=s=>{const r=s.target,o=r.tagName==="INPUT"||r.tagName==="TEXTAREA"||r.isContentEditable;s.key==="?"&&!o&&(s.preventDefault(),e())};return document.addEventListener("keydown",t),()=>document.removeEventListener("keydown",t)},[e])}const dR=15e3;function uR(){const e=De({select:r=>r.location.pathname}),s=_s("sidebar.body").find(r=>{var o;return(o=r.visibleWhen)==null?void 0:o.call(r,{pathname:e})});if(s){const r=s.component;return{key:`body:${s.id}`,body:n.jsx(z1,{contributionId:s.id,children:n.jsx(u.Suspense,{fallback:null,children:n.jsx(r,{})})}),direction:1,isTakeover:!0}}return{key:"dashboard",body:n.jsx(bN,{}),direction:-1,isTakeover:!1}}function mR(){const e=De({select:t=>t.matches});return Sj(e)}function hR(){const{sidebarOpen:e,setSidebarOpen:t}=P(),s=Pe(),r=Cs(ne=>ne.panelUp),[o]=bc(),a=De({select:ne=>ne.location.pathname}),i=De({select:ne=>ne.location.searchStr}),c=new URLSearchParams(i),d=a==="/channels"&&!!c.get("community")&&!!c.get("id"),l=kE(ut()??!1),m=De({select:ne=>SE(ne.matches)});Iv();const[h]=$s(),p=P(ne=>ne.isStreaming),{data:f}=Nc(h),g=Jc(f??null,h??""),{room:x,unreadRoomCount:y}=P1();$1(),Hy({cwd:h,isStreaming:p,color:f?g.color:void 0}),lR(),wj(),yb(),nE(),vb(),mb(),ck(),T1(),D1();const b=O1();M1(),_v(),fS(),Qw(),Xw(),Yg(),Tx(),bw(),Vg(),jv(),Xx(),Gy(),Qg(),gw(),Xg(),RS(),ab();const C=P(ne=>ne.onboardingHiddenForSession),S=P(ne=>ne.setOnboardingHiddenForSession),{shouldShowOnboarding:I,isLoading:v,isOnboardingComplete:E,isOnboardingDismissed:R}=Zt(),M=Pv({shouldShowOnboarding:I,onboardingHiddenForSession:C});Fv({done:E||R,overlayVisible:M}),Zw({blocked:M});const{dataUpdatedAt:O,errorUpdatedAt:_,error:D}=_e({refetchOnMount:jE}),k=O>cn,j=_>cn,N=wE(_,D),[w,T]=u.useState(!1);u.useEffect(()=>{if(k)return;const ne=setTimeout(()=>T(!0),dR);return()=>clearTimeout(ne)},[k]);const F=(N==null?void 0:N.status)===void 0,$=!k&&F&&(j||w),W=k||(N==null?void 0:N.status)===void 0?void 0:N,[X,ie]=u.useState(!1);u.useEffect(()=>{if(!v)return;const ne=setTimeout(()=>ie(!0),3e3);return()=>clearTimeout(ne)},[v]);const B=u.useCallback(()=>S(!0),[S]),Y=uR(),{origin:oe,originLabel:pe}=Jg(o),{data:V}=Zg(o,{enabled:!1,select:ne=>ne.title}),G=mR(),te=u.useMemo(()=>({sessionId:o??void 0,agentName:f?Le(f):void 0,agentVisual:f?g:void 0,origin:oe,originLabel:pe,sessionTitle:V,sessionDirectoryName:h?fl(h):void 0,room:x,teamViewMode:ex(new URLSearchParams(i).get("view")??void 0)}),[o,f,g,oe,pe,V,h,x,i]),we=BE();return $?n.jsx(K1,{}):(W==null?void 0:W.status)!==void 0?n.jsx(yE,{status:W.status,message:W.message,code:W.code}):v&&!X?n.jsx("div",{className:"bg-background h-dvh"}):n.jsxs(tx,{children:[n.jsx(L1,{unreadRoomCount:y}),n.jsxs(xy,{reducedMotion:"user",children:[n.jsx(Ye,{mode:"wait",children:M?n.jsx(se.div,{initial:{opacity:1},exit:{opacity:0},transition:{duration:.2},className:"fixed inset-0 z-50",children:n.jsx(iw,{onComplete:B,slots:xE})},"onboarding"):n.jsx(se.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(nx,{open:e,onOpenChange:t,className:K("flex-1 overflow-hidden",s&&"min-h-0"),style:{"--sidebar-width":"calc(272px + 1rem)"},children:[!s&&n.jsxs(sx,{variant:"inset",children:[n.jsxs(cl,{className:"flex min-h-0 flex-1 flex-col",children:[n.jsx(B1,{isFullscreen:b}),n.jsx(Ou,{}),n.jsx(sI,{slotKey:Y.key,direction:Y.direction,children:Y.body}),n.jsx(rx,{className:"px-2 py-3",children:n.jsx(Rl,{})})]}),n.jsx(ox,{})]}),n.jsxs(ax,{className:"overflow-hidden",inert:s&&r,children:[$e()&&n.jsx(Yj,{className:K("app-drag-region",!e&&!b&&"desktop-darwin:pl-20")}),n.jsxs("header",{className:"app-drag-region @container/bar relative flex h-auto min-h-11 shrink-0 flex-wrap items-center gap-x-1 border-b px-2 transition-[border-color] duration-300 md:h-9 md:min-h-0 md:flex-nowrap lg:gap-x-2",children:[!s&&n.jsxs(n.Fragment,{children:[n.jsx(ix,{className:"-ml-0.5"}),n.jsx(Xj,{}),n.jsx(cx,{orientation:"vertical",className:"mr-1 h-4"})]}),s&&n.jsx(ZN,{}),n.jsx(Ye,{mode:"wait",initial:!1,children:G&&n.jsx(se.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.1},className:"flex h-11 min-w-0 grow basis-32 items-center gap-1 has-[[data-slot=bar-tab-strip]]:basis-[calc(100%-2.5rem)] md:h-auto md:flex-1 md:self-stretch md:has-[[data-slot=bar-tab-strip]]:basis-0 lg:gap-2",children:n.jsx(lx,{value:te,children:n.jsx(G.Header,{})})},G.key)}),n.jsx(fE,{})]}),n.jsx(CE,{descriptors:we}),n.jsx("main",{id:$d,className:"flex-1 overflow-hidden pb-[var(--pip-dock,0px)]",children:n.jsxs(dx,{direction:"horizontal",id:_r,autoSaveId:_r,children:[n.jsx(Ac,{id:"main-content",order:1,minSize:30,defaultSize:100,children:n.jsx(se.div,{initial:l?{opacity:0}:!1,animate:{opacity:1},transition:l?{duration:.12,ease:"easeOut"}:{duration:0},"data-route-fade":l,className:"h-full",children:n.jsx(ux,{})},m)}),n.jsx(vj,{pathname:a,isRemoteCommunityRoom:d})]})})]})]}),s&&n.jsx(lI,{takeover:Y.isTakeover?Y.body:null})]})},"main-app")}),n.jsx(TA,{}),n.jsx(nI,{onboardingOverlayVisible:M}),n.jsx(R1,{}),n.jsx(rA,{}),n.jsx(CA,{}),n.jsx(KI,{}),n.jsx(Yw,{}),n.jsx(cR,{}),n.jsx(Zy,{}),n.jsx(Ub,{}),n.jsx(nR,{}),n.jsx(fx,{}),n.jsx(iR,{})]})]})}const UT=hR;export{UT as component};