dorkos 0.123.0 → 0.124.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 (316) hide show
  1. package/dist/bin/cli.js +775 -308
  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-BmtoPqP9.js → AboutPage-BH8Ndn3e.js} +1 -1
  5. package/dist/client/assets/{ActivityErrorState-CEzdFJiR.js → ActivityErrorState-K5Mew9EX.js} +1 -1
  6. package/dist/client/assets/{ActivityPage-mFYgTr3e.js → ActivityPage-BB20L5HU.js} +1 -1
  7. package/dist/client/assets/{ActivityRow-Bkc0kkim.js → ActivityRow-C5O7rnmS.js} +1 -1
  8. package/dist/client/assets/{AdapterIcon-DVgTrgnM.js → AdapterIcon-Bmybvrzb.js} +1 -1
  9. package/dist/client/assets/{AdapterSetupWizard-I03EluU5.js → AdapterSetupWizard-CkdV7Hhh.js} +2 -2
  10. package/dist/client/assets/{AgentOptionRow-DI1TzLaR.js → AgentOptionRow-BA2cDa7r.js} +1 -1
  11. package/dist/client/assets/{AgentPicker-CBYeBzjf.js → AgentPicker-CsIIPGZJ.js} +1 -1
  12. package/dist/client/assets/{AgentRequestCard-DQ6GYoeE.js → AgentRequestCard-0fOxvaoe.js} +3 -3
  13. package/dist/client/assets/{AppearancePage-62xIPNPn.js → AppearancePage-XOjkkoli.js} +1 -1
  14. package/dist/client/assets/{ApplyToOverridesDialog-CrqkeHQb.js → ApplyToOverridesDialog-CoO6V1G4.js} +1 -1
  15. package/dist/client/assets/{AttentionSignalRow-Coe5pYX6.js → AttentionSignalRow-CjjZobp7.js} +1 -1
  16. package/dist/client/assets/{BaseTanStackRouterDevtoolsPanel-B-iktbLX-D07cg75s.js → BaseTanStackRouterDevtoolsPanel-B-iktbLX-9TVHyRPJ.js} +1 -1
  17. package/dist/client/assets/{BindingDialog-DVyxVXZM.js → BindingDialog-DLoAQauL.js} +1 -1
  18. package/dist/client/assets/{BlintzCanvas-BmfkiUQJ.js → BlintzCanvas-CYHsXAcY.js} +3 -3
  19. package/dist/client/assets/{CanvasCsvContent-CRTr-AI7.js → CanvasCsvContent--Gr7Fe_U.js} +1 -1
  20. package/dist/client/assets/{CanvasFileContent-rOmY1s3T.js → CanvasFileContent-estXyAbr.js} +2 -2
  21. package/dist/client/assets/{CanvasModel3dContent-D7oRT6ey.js → CanvasModel3dContent-CkOo930M.js} +2 -2
  22. package/dist/client/assets/{ChatAppsOff-BmuOTq83.js → ChatAppsOff-D4L1zJVN.js} +1 -1
  23. package/dist/client/assets/{CodeMirrorDiff-DidSWwYJ.js → CodeMirrorDiff-DY_6ju-z.js} +1 -1
  24. package/dist/client/assets/{CodeMirrorEditor-BUAWGbRo.js → CodeMirrorEditor-BUoDBsBv.js} +1 -1
  25. package/dist/client/assets/{CommitmentList-uK4CKaz0.js → CommitmentList-wDkcVP9c.js} +1 -1
  26. package/dist/client/assets/{CommitmentsPage-BWITH1r2.js → CommitmentsPage-CzSM6b8R.js} +1 -1
  27. package/dist/client/assets/{ComputerResourceView-adgF_EZU.js → ComputerResourceView-cERD9H2L.js} +1 -1
  28. package/dist/client/assets/{ComputerViewer-D87LhxwL.js → ComputerViewer-rMcfbk2_.js} +1 -1
  29. package/dist/client/assets/{ConnectionAccessLists-BFEFqcSZ.js → ConnectionAccessLists-f7QeQbQo.js} +1 -1
  30. package/dist/client/assets/{ConnectionsPage-Cd_cLoSY.js → ConnectionsPage-BmjtA6pw.js} +2 -2
  31. package/dist/client/assets/{ConventionPage-BSztD-gU.js → ConventionPage-CH-ah6nI.js} +1 -1
  32. package/dist/client/assets/{ExtensionPageRoute-BSge6XRv.js → ExtensionPageRoute-CJIxa6ST.js} +2 -2
  33. package/dist/client/assets/{FloatingTanStackRouterDevtools-CqogiFob-TO2CUPG0.js → FloatingTanStackRouterDevtools-CqogiFob-BP7EJ2JL.js} +1 -1
  34. package/dist/client/assets/HandlePage-Cg8H3mQS.js +1 -0
  35. package/dist/client/assets/{HeartbeatPage-DIJzdOhj.js → HeartbeatPage-BUsf-qrU.js} +1 -1
  36. package/dist/client/assets/{KeyEntry-DJnzW3Mu.js → KeyEntry-C2kWdN8q.js} +1 -1
  37. package/dist/client/assets/{LexicalField-BxzNvIjJ.js → LexicalField-CR8ulsI_.js} +1 -1
  38. package/dist/client/assets/{ManagesPage-BQj8KbYA.js → ManagesPage-DTtsIOGi.js} +1 -1
  39. package/dist/client/assets/{Marketplace-CIG5_a_H.js → Marketplace-iaV5XAzv.js} +2 -2
  40. package/dist/client/assets/{MarketplaceSourcesView-16HKvFK-.js → MarketplaceSourcesView-6tgzUfFj.js} +1 -1
  41. package/dist/client/assets/{McpAppFrame-5xlga1jD.js → McpAppFrame-C7eYYdI9.js} +1 -1
  42. package/dist/client/assets/McpSigninBody-BDyGbJ7I.js +1 -0
  43. package/dist/client/assets/{Model3dViewer-CQ0sA_kr.js → Model3dViewer-BujDNuVS.js} +1 -1
  44. package/dist/client/assets/NamePage-Bx8T98OF.js +1 -0
  45. package/dist/client/assets/{NewDirectMessageMenu-D092y0K9.js → NewDirectMessageMenu-D4e-z2Jt.js} +1 -1
  46. package/dist/client/assets/{NotificationsPage-CskOPdhh.js → NotificationsPage-CkDeTaJp.js} +1 -1
  47. package/dist/client/assets/{OpenMeshSwitch-BHRm328L.js → OpenMeshSwitch-CtbOt3r5.js} +2 -2
  48. package/dist/client/assets/OperatorIdentityForm-Vr4qZnmM.js +1 -0
  49. package/dist/client/assets/PermissionHistory-DzU1rf2B.js +1 -0
  50. package/dist/client/assets/{PermissionsPage-XuPOSYll.js → PermissionsPage-f4QaX8oM.js} +1 -1
  51. package/dist/client/assets/{PersonalityPopover-BrZjxakx.js → PersonalityPopover-BkZruwF-.js} +1 -1
  52. package/dist/client/assets/PhotoPage-CmrOIRjf.js +1 -0
  53. package/dist/client/assets/{PreviewRefusedNotice-BANdpT9O.js → PreviewRefusedNotice-BXC2K0tx.js} +1 -1
  54. package/dist/client/assets/{ProfileFields-Dp68ebW9.js → ProfileFields-BebX5oiv.js} +1 -1
  55. package/dist/client/assets/{ProfilePanelContainer-BKwGdI90.js → ProfilePanelContainer-DZoL65zQ.js} +1 -1
  56. package/dist/client/assets/{ProfileRolePicker-ClOdfLda.js → ProfileRolePicker-D9H7wsuT.js} +1 -1
  57. package/dist/client/assets/{PromptSuggestionChips-zcW4UJ_O.js → PromptSuggestionChips-B5fDmc-g.js} +1 -1
  58. package/dist/client/assets/{ReportsToPopover-BwDVGqFg.js → ReportsToPopover-uVYhSqj7.js} +1 -1
  59. package/dist/client/assets/{RoomSurface-CSKIvyHH.js → RoomSurface-Bg5WV4Ep.js} +7 -7
  60. package/dist/client/assets/{RoomsPage-CAvrRbPk.js → RoomsPage-yflYFulU.js} +1 -1
  61. package/dist/client/assets/{RunsOnPopover-CQ4t9EZ-.js → RunsOnPopover-DtGrX1Vq.js} +1 -1
  62. package/dist/client/assets/{RuntimeConnectFlow--fVpIf0B.js → RuntimeConnectFlow-DjReuQ-T.js} +1 -1
  63. package/dist/client/assets/{RuntimeSetupDialog-COpyPrqL.js → RuntimeSetupDialog-Cr4GRi8c.js} +1 -1
  64. package/dist/client/assets/{SeenDevices-BPw3UgjX.js → SeenDevices-SPWkdzoK.js} +3 -3
  65. package/dist/client/assets/{SessionsPage-FDyYzuXs.js → SessionsPage-BWu-en78.js} +1 -1
  66. package/dist/client/assets/SettingsDialog-_dEXUhHe.js +12 -0
  67. package/dist/client/assets/{SkillsPage-PLXEY0LB.js → SkillsPage-BdUb9SZy.js} +1 -1
  68. package/dist/client/assets/TaskDialogWrapper-qYJPEoSR.js +1 -0
  69. package/dist/client/assets/{TasksEmptyState-8RZxhRh6.js → TasksEmptyState-Bgcg9vxF.js} +2 -2
  70. package/dist/client/assets/{TasksPage-C-EtQXKb.js → TasksPage-Ch5W2WQS.js} +1 -1
  71. package/dist/client/assets/{TeamComputerEntry-qx_19Htj.js → TeamComputerEntry-CPwSIMRw.js} +1 -1
  72. package/dist/client/assets/ToolsPage-Idimrn3o.js +2 -0
  73. package/dist/client/assets/{TopologyGraph-1wtG1BE9.js → TopologyGraph-I4_mkMHM.js} +14 -14
  74. package/dist/client/assets/{TourHost-C664E8OY.js → TourHost-BPaSwh9I.js} +1 -1
  75. package/dist/client/assets/{UnlinkDialog-Di1oBFA_.js → UnlinkDialog-BUWZUu5P.js} +1 -1
  76. package/dist/client/assets/{WidgetErrorCard-BfgGzyqg.js → WidgetErrorCard-cS8yMCxU.js} +3 -3
  77. package/dist/client/assets/_shell-ClVN2pUj.js +80 -0
  78. package/dist/client/assets/{_shell._home-Hz78BY6-.js → _shell._home-DCA5k-jb.js} +1 -1
  79. package/dist/client/assets/{_shell._home.activity-BxvI0gkw.js → _shell._home.activity-BX4nFLna.js} +1 -1
  80. package/dist/client/assets/{_shell._home.index-Cqq81f3P.js → _shell._home.index-C8t8cw72.js} +1 -1
  81. package/dist/client/assets/{_shell._home.tasks-Cth56CwC.js → _shell._home.tasks-BgUeEvhK.js} +1 -1
  82. package/dist/client/assets/{_shell._home.workspaces-DkoOJSWz.js → _shell._home.workspaces-BPBdnkRt.js} +1 -1
  83. package/dist/client/assets/_shell.channels-CX4kki7G.js +10 -0
  84. package/dist/client/assets/_shell.connections-0vP7g7E4.js +1 -0
  85. package/dist/client/assets/{_shell.feedback-requests-BTxHdsfb.js → _shell.feedback-requests-TsuaO4eR.js} +2 -2
  86. package/dist/client/assets/_shell.marketplace-CiL6YRbl.js +1 -0
  87. package/dist/client/assets/_shell.marketplace_.sources-C0sI8e21.js +1 -0
  88. package/dist/client/assets/_shell.session-_hhBvFc6.js +63 -0
  89. package/dist/client/assets/{_shell.team-ZxGwa39m.js → _shell.team-Bm6cOBhR.js} +4 -4
  90. package/dist/client/assets/_shell.x._extensionId-BWy5v1YE.js +1 -0
  91. package/dist/client/assets/_shell.x._extensionId_._-BWy5v1YE.js +1 -0
  92. package/dist/client/assets/{abnfDiagram-WEYOIA3C-CzqPVMdw.js → abnfDiagram-WEYOIA3C-CrvoN15x.js} +1 -1
  93. package/dist/client/assets/{access-copy-Dj09Xk4b.js → access-copy-B3yNZ7Gz.js} +1 -1
  94. package/dist/client/assets/{arc-Bgy7ExYl.js → arc-CuT6QA_y.js} +1 -1
  95. package/dist/client/assets/{architectureDiagram-ZHVYKT53-DYfb2p9r.js → architectureDiagram-ZHVYKT53-CPXCZ9H4.js} +1 -1
  96. package/dist/client/assets/{banner-dlsHTWSf.js → banner-DRumuw3F.js} +1 -1
  97. package/dist/client/assets/{blockDiagram-RJAE7QA3-BkOzLL8s.js → blockDiagram-RJAE7QA3-CM0rka9p.js} +1 -1
  98. package/dist/client/assets/{c4Diagram-XDPPPE54-CsZm4qpD.js → c4Diagram-XDPPPE54-D4j2cXRy.js} +1 -1
  99. package/dist/client/assets/{card-Dj6ZfRgu.js → card-B3CtfC3R.js} +1 -1
  100. package/dist/client/assets/channel-DjBlTcCV.js +1 -0
  101. package/dist/client/assets/{chunk-2E7WHVMD-GA96Jfps.js → chunk-2E7WHVMD-KGyqhVpO.js} +1 -1
  102. package/dist/client/assets/{chunk-2Q5K7J3B-CW2i0IkT.js → chunk-2Q5K7J3B-Dl0BHoqK.js} +1 -1
  103. package/dist/client/assets/{chunk-4EMNKR2T-BwFvnPZg.js → chunk-4EMNKR2T-Da7vH6Kv.js} +1 -1
  104. package/dist/client/assets/{chunk-55XCU76K-MOezzAAB.js → chunk-55XCU76K-DgBUEROO.js} +1 -1
  105. package/dist/client/assets/{chunk-5VM5RSS4-woru6zOC.js → chunk-5VM5RSS4-BQ4mn-_I.js} +1 -1
  106. package/dist/client/assets/{chunk-JWPE2WC7-CUrKlP2M.js → chunk-JWPE2WC7-8LPR3mXf.js} +1 -1
  107. package/dist/client/assets/{chunk-VQ5W62QI-CqZ2cdEu.js → chunk-VQ5W62QI-BkIVXi4W.js} +1 -1
  108. package/dist/client/assets/{chunk-XXDRQBXY-ByAcvWaE.js → chunk-XXDRQBXY-DQXJx06h.js} +1 -1
  109. package/dist/client/assets/{chunk-ZCHMQSOR-3nkba9kj.js → chunk-ZCHMQSOR-DzCE7qlD.js} +2 -2
  110. package/dist/client/assets/{classDiagram-v2-4MYWR3UA-B-zZKAmI.js → classDiagram-v2-4MYWR3UA-C_cZra7c.js} +1 -1
  111. package/dist/client/assets/{command-BAOEURY7.js → command-CDKbyppr.js} +1 -1
  112. package/dist/client/assets/{cose-bilkent-JH36ORCC-sCKxRv1H.js → cose-bilkent-JH36ORCC-DlXHdGwT.js} +1 -1
  113. package/dist/client/assets/{cpu-TtYQqONc.js → cpu-B7xLO7jn.js} +1 -1
  114. package/dist/client/assets/{cynefin-EF2NZ3EQ-CXzvL5Cg.js → cynefin-EF2NZ3EQ-HhP4ArLc.js} +1 -1
  115. package/dist/client/assets/{cynefinDiagram-WF24UDRP-C0wjhu9X.js → cynefinDiagram-WF24UDRP-D4GgWnZV.js} +1 -1
  116. package/dist/client/assets/{dagre-NK4GIZVX-Doi2IPkY.js → dagre-NK4GIZVX-SZ_OI2Zi.js} +1 -1
  117. package/dist/client/assets/{diagram-CBK3MWTC-11TVuPel.js → diagram-CBK3MWTC-BN-_Ja5m.js} +1 -1
  118. package/dist/client/assets/{diagram-I5XIIV2D-CJq7fHFM.js → diagram-I5XIIV2D-t7AK6xnL.js} +1 -1
  119. package/dist/client/assets/{diagram-ODIL2UCW-2Ae6unuU.js → diagram-ODIL2UCW-C1V7szSc.js} +1 -1
  120. package/dist/client/assets/{diagram-PFBEJUXE-BXza6_iz.js → diagram-PFBEJUXE-DPtraQ2g.js} +1 -1
  121. package/dist/client/assets/{diagram-RJA3I4VV-Z0i3uBW9.js → diagram-RJA3I4VV-D2XNRB2b.js} +1 -1
  122. package/dist/client/assets/{diagram-TYUNFSNR-Dq_-g1oP.js → diagram-TYUNFSNR-BieaRy38.js} +1 -1
  123. package/dist/client/assets/{ebnfDiagram-V4P3TTPT-vxzIvg-W.js → ebnfDiagram-V4P3TTPT-Bwki86UY.js} +1 -1
  124. package/dist/client/assets/{elk-QONTBCTQ-BBIXXtg_.js → elk-QONTBCTQ-WEXSAyHB.js} +1 -1
  125. package/dist/client/assets/{empty-state-kISAAp0z.js → empty-state-J-UJ0BUU.js} +1 -1
  126. package/dist/client/assets/{erDiagram-KYQIGQAA-Bk2MeLBx.js → erDiagram-KYQIGQAA-DIKASnoc.js} +1 -1
  127. package/dist/client/assets/{execution-config-DYFe-VNC.js → execution-config-ILQiJAmy.js} +1 -1
  128. package/dist/client/assets/{file-DEt4KgZG.js → file-D40js1Zx.js} +1 -1
  129. package/dist/client/assets/{file-exclamation-point-QqXJhXD9.js → file-exclamation-point-Dg3ZpiAe.js} +1 -1
  130. package/dist/client/assets/{file-text-CRw31ZWd.js → file-text-DgdvRfMk.js} +1 -1
  131. package/dist/client/assets/{find-latest-widget-fence-B3aaiBNI.js → find-latest-widget-fence-D4kBWC_1.js} +1 -1
  132. package/dist/client/assets/{flowDiagram-IUGLLWBU-B53m4r8u.js → flowDiagram-IUGLLWBU-CoavNw0M.js} +1 -1
  133. package/dist/client/assets/{form-Bjhk9zOn.js → form-DlPwEgQH.js} +1 -1
  134. package/dist/client/assets/{format-cron-9tmNIcgl.js → format-cron-BrK8RzgT.js} +1 -1
  135. package/dist/client/assets/{ganttDiagram-R7GPNTJY-CS6TN3R1.js → ganttDiagram-R7GPNTJY-DccKAz7f.js} +1 -1
  136. package/dist/client/assets/{git-branch-DWerghmw.js → git-branch-BpxhecMq.js} +1 -1
  137. package/dist/client/assets/{gitGraphDiagram-PDYL7XHY-D096ZtqE.js → gitGraphDiagram-PDYL7XHY-DEbo_dgQ.js} +1 -1
  138. package/dist/client/assets/{graph-DQpTuPmX.js → graph-DROgI3M3.js} +1 -1
  139. package/dist/client/assets/{heart-CRkjVW7-.js → heart-c7u4Ezxt.js} +1 -1
  140. package/dist/client/assets/{highlighted-body-KPVGNVTW-DoVCXOMU.js → highlighted-body-KPVGNVTW-CrATNdTR.js} +1 -1
  141. package/dist/client/assets/image-lightbox-DE_fHkw-.js +1 -0
  142. package/dist/client/assets/{image-off-VyMBVwgK.js → image-off-BExgZjfM.js} +2 -2
  143. package/dist/client/assets/{index-DgyhdQnI.js → index-2wezsLA_.js} +1 -1
  144. package/dist/client/assets/index-7jby-RRg.js +1 -0
  145. package/dist/client/assets/{index-Czm6C7FZ.js → index-AzyLwYS_.js} +3 -3
  146. package/dist/client/assets/{index-CiVeycsn.js → index-B3eeEDWj.js} +5 -5
  147. package/dist/client/assets/{index-setKr4xl.js → index-BEkYBuOq.js} +1 -1
  148. package/dist/client/assets/index-BGqvci3k.js +1 -0
  149. package/dist/client/assets/{index-DKWpwwxo.js → index-BVqSmajJ.js} +1 -1
  150. package/dist/client/assets/{index-BBcAekWE.js → index-Be0OJLWK.js} +1 -1
  151. package/dist/client/assets/{index-BiFJIg4n.js → index-BizvylBV.js} +1 -1
  152. package/dist/client/assets/{index-n3-zWcH-.js → index-BkoMsjtM.js} +2 -2
  153. package/dist/client/assets/{index-_emDKzsu.js → index-BlyoyIck.js} +1 -1
  154. package/dist/client/assets/{index-C24HfJir.js → index-BqIHtiaE.js} +1 -1
  155. package/dist/client/assets/{index-Cs3WB8yn.js → index-C5or4L_3.js} +1 -1
  156. package/dist/client/assets/{index-igLqtuoO.js → index-C7B3eSOP.js} +1 -1
  157. package/dist/client/assets/{index-COMRALJO.js → index-CD8aw6Jb.js} +1 -1
  158. package/dist/client/assets/{index-CDuYKaGY.js → index-CT_pFeX_.js} +1 -1
  159. package/dist/client/assets/{index-b9p_y2Ql.js → index-CYy1cjtq.js} +1 -1
  160. package/dist/client/assets/{index-Csr_C1sk.js → index-CZmqtJWZ.js} +1 -1
  161. package/dist/client/assets/{index-DBo2XfNv.js → index-CbHCZsbE.js} +1 -1
  162. package/dist/client/assets/{index-BcFMs7lK.js → index-Ccf1XBTs.js} +1 -1
  163. package/dist/client/assets/index-Cga0qx1T.js +1033 -0
  164. package/dist/client/assets/{index-Ctqe81qr.js → index-CqPRAM_6.js} +1 -1
  165. package/dist/client/assets/index-Ct4At33X.js +1 -0
  166. package/dist/client/assets/{index-DN2sTT2U.js → index-D0eJtRlK.js} +1 -1
  167. package/dist/client/assets/{index-C3sW6rkN.js → index-D150FXCC.js} +22 -20
  168. package/dist/client/assets/{index-C6udJCgz.js → index-D3YeRrne.js} +1 -1
  169. package/dist/client/assets/index-DCJQGDZk.js +1 -0
  170. package/dist/client/assets/{index-BpjEclkM.js → index-DDgOoXP1.js} +1 -1
  171. package/dist/client/assets/{index-DmFNztTX.js → index-DINk1YfD.js} +1 -1
  172. package/dist/client/assets/{index-Dgrk2udV.js → index-DITPwUa9.js} +3 -3
  173. package/dist/client/assets/{index-CvhR1oZB.js → index-DNGNMW3c.js} +1 -1
  174. package/dist/client/assets/{index-rCvQat0D.js → index-DT7pv2iW.js} +1 -1
  175. package/dist/client/assets/{index-TnoaFCrj.js → index-DaZ1I8s-.js} +1 -1
  176. package/dist/client/assets/{index-CEVwhauU.js → index-DeRDq7bD.js} +1 -1
  177. package/dist/client/assets/{index-2EaVZrJe.js → index-DhHobJd3.js} +1 -1
  178. package/dist/client/assets/{index-CyGRWyhV.js → index-DksjixUS.js} +1 -1
  179. package/dist/client/assets/{index-C6Fo2htT.js → index-DswGXheF.js} +1 -1
  180. package/dist/client/assets/{index-t3eRSGcT.js → index-DxiRRZRo.js} +1 -1
  181. package/dist/client/assets/index-F-vqXYqa.js +1 -0
  182. package/dist/client/assets/{index-DNzk9m1D.js → index-InEBtYxw.js} +6 -6
  183. package/dist/client/assets/{index-BLkXoquZ.js → index-J3Hh1MnL.js} +1 -1
  184. package/dist/client/assets/{index-gIQ7FrL9.js → index-dyAahqKe.js} +1 -1
  185. package/dist/client/assets/{index-B2rBVMNl.js → index-mwf7ZNk2.js} +1 -1
  186. package/dist/client/assets/{index.esm-bLeQzVWT.js → index.esm-BFJ9SG0n.js} +1 -1
  187. package/dist/client/assets/{infoDiagram-MVDRKAX5-nN_N76Fn.js → infoDiagram-MVDRKAX5-VL8q5pKx.js} +1 -1
  188. package/dist/client/assets/{inline-code-D9bLKHjY.js → inline-code-BE9ckzPs.js} +1 -1
  189. package/dist/client/assets/{ishikawaDiagram-HPEHV2GE-CiLFbWXd.js → ishikawaDiagram-HPEHV2GE-BLKkPYF-.js} +1 -1
  190. package/dist/client/assets/{journeyDiagram-BOSHW7O7-Dn3yOv96.js → journeyDiagram-BOSHW7O7-CSYpRobu.js} +1 -1
  191. package/dist/client/assets/{kanban-definition-FNSA4HC5-JxiBdBQC.js → kanban-definition-FNSA4HC5-HilAqtZo.js} +1 -1
  192. package/dist/client/assets/{layers-DTnLoRvE.js → layers-Cm7coqdo.js} +1 -1
  193. package/dist/client/assets/{lightbulb-CRKLr5q3.js → lightbulb-DqdWS75d.js} +1 -1
  194. package/dist/client/assets/{link-2-hgHg-lyw.js → link-2-CDJapTSa.js} +1 -1
  195. package/dist/client/assets/{list-runtime-types-Bb33QiMC.js → list-runtime-types-CP82p1u4.js} +1 -1
  196. package/dist/client/assets/{markdown-content-D0FpU2cz.js → markdown-content-m_qereFc.js} +1 -1
  197. package/dist/client/assets/{mention-pill-uuaUvwSW.js → mention-pill-DV5HIG5Q.js} +1 -1
  198. package/dist/client/assets/{mermaid.core-x3Hh6iut.js → mermaid.core-zxW6MBr-.js} +4 -4
  199. package/dist/client/assets/{message-square-off-B8N6YF9R.js → message-square-off-YVtpbaJ0.js} +1 -1
  200. package/dist/client/assets/{mindmap-definition-6OY57UG3-D0SEv5Re.js → mindmap-definition-6OY57UG3-IAYemvOg.js} +1 -1
  201. package/dist/client/assets/{more-details-CadxnGyH.js → more-details-ReA2ZFBn.js} +1 -1
  202. package/dist/client/assets/{owner-notice-CJHyha58.js → owner-notice-M4hn_1ep.js} +1 -1
  203. package/dist/client/assets/{package-B8G7jQm-.js → package-CUuTl39E.js} +1 -1
  204. package/dist/client/assets/{page-container-Bb-_N7lw.js → page-container-BnmNikNZ.js} +1 -1
  205. package/dist/client/assets/{paperclip-BDeYGKqh.js → paperclip-C6fYq5Zf.js} +1 -1
  206. package/dist/client/assets/{path-input-BIfexEKz.js → path-input-DHn9-XaE.js} +1 -1
  207. package/dist/client/assets/{pegDiagram-ECIUJNBX-7ivMd0-b.js → pegDiagram-ECIUJNBX-CojaUwe7.js} +1 -1
  208. package/dist/client/assets/{pieDiagram-GNMPY74T-DGDkbFvu.js → pieDiagram-GNMPY74T-CjP3pw6V.js} +1 -1
  209. package/dist/client/assets/{plug-wP1d6OUX.js → plug-DHQcxt7N.js} +1 -1
  210. package/dist/client/assets/primer-trigger-BmV5wjek.js +3 -0
  211. package/dist/client/assets/{profile-errors-C1qSJkiG.js → profile-errors-BSCuj3rT.js} +1 -1
  212. package/dist/client/assets/{progress-DmUieXLn.js → progress-4FQQfnS6.js} +1 -1
  213. package/dist/client/assets/{quadrantDiagram-D57K4MC3-AFQRVSsK.js → quadrantDiagram-D57K4MC3-OP0Z8zcR.js} +1 -1
  214. package/dist/client/assets/{query-error-state--8AnWSSn.js → query-error-state-BkUdxenP.js} +1 -1
  215. package/dist/client/assets/{radio-mkA-Sqe0.js → radio-ta5Bw763.js} +1 -1
  216. package/dist/client/assets/{railroadDiagram-Y72NRBL7-3QBa2d3j.js → railroadDiagram-Y72NRBL7-CT3NCb9b.js} +1 -1
  217. package/dist/client/assets/registry-Dc102rws.js +1 -0
  218. package/dist/client/assets/{relay-trace-schemas-fScydQ3A.js → relay-trace-schemas-DwUuyxao.js} +2 -2
  219. package/dist/client/assets/{requirementDiagram-EQYSW5RA-BVBqcASy.js → requirementDiagram-EQYSW5RA-tde4lYGp.js} +1 -1
  220. package/dist/client/assets/{room-files-source-BhkPUTiP.js → room-files-source-CZWhaaOy.js} +2 -2
  221. package/dist/client/assets/{rotate-ccw-clock-DiuTseKz.js → rotate-ccw-clock-RfbbgUa4.js} +1 -1
  222. package/dist/client/assets/{rotate-cw-DvoxWwSx.js → rotate-cw-B3rB_YSw.js} +1 -1
  223. package/dist/client/assets/{sankeyDiagram-SY24JHO5-DFjfOD38.js → sankeyDiagram-SY24JHO5-sdCzIA7-.js} +1 -1
  224. package/dist/client/assets/{scroll-area-DYyyRqW_.js → scroll-area-B4WB7Q40.js} +1 -1
  225. package/dist/client/assets/{search-x-CA-FzEqZ.js → search-x-DCUmWW2_.js} +1 -1
  226. package/dist/client/assets/{sequenceDiagram-BLEHNHQU-Cr9LzoSF.js → sequenceDiagram-BLEHNHQU-DvzTJcKu.js} +1 -1
  227. package/dist/client/assets/{shield-x-B0W_7qwR.js → shield-x-CANziVLc.js} +1 -1
  228. package/dist/client/assets/signed-in-DctJ2IWe.js +1 -0
  229. package/dist/client/assets/{sizeCapture-INFHLROL-Do_jfNyT.js → sizeCapture-INFHLROL-DuDA7TKE.js} +1 -1
  230. package/dist/client/assets/{soul-file-DgfhKQIK.js → soul-file-Co_8f1qw.js} +1 -1
  231. package/dist/client/assets/{stateDiagram-v2-A6IESKWZ-BCi9yk_0.js → stateDiagram-v2-A6IESKWZ-BJPX5JTC.js} +1 -1
  232. package/dist/client/assets/{swimlanes-B3ENRKFQ-3SSAw2av.js → swimlanes-B3ENRKFQ-CiLSffGv.js} +1 -1
  233. package/dist/client/assets/swimlanesDiagram-AYQRV4AK-Dv1-QS9J.js +8 -0
  234. package/dist/client/assets/{table-DvU_oS4E.js → table-BSAvOYPp.js} +1 -1
  235. package/dist/client/assets/{terminal-Dw2QZ7Dh.js → terminal-6CdY-T1V.js} +1 -1
  236. package/dist/client/assets/{timeline-definition-JXYKGLGB-DTLPXTMA.js → timeline-definition-JXYKGLGB-5oq8sl82.js} +1 -1
  237. package/dist/client/assets/{trust-posture-2MR0ap9o.js → trust-posture-D-Yjm6ot.js} +1 -1
  238. package/dist/client/assets/{unplug-CAVOLB2R.js → unplug-Bq_1WdV7.js} +1 -1
  239. package/dist/client/assets/{unverified-catalog-notice-u4ikVg8J.js → unverified-catalog-notice-CEzu54YH.js} +1 -1
  240. package/dist/client/assets/{use-adapter-catalog-BQKfRxXC.js → use-adapter-catalog-Tn3ZbPAj.js} +1 -1
  241. package/dist/client/assets/{use-bindings-BV6HA0MD.js → use-bindings-Bz9YRgO7.js} +1 -1
  242. package/dist/client/assets/{use-composer-prefs-DCSzOnEO.js → use-composer-prefs-D9oKJSQN.js} +1 -1
  243. package/dist/client/assets/{use-connector-management-fr1tx-GZ.js → use-connector-management-CLYFraXN.js} +1 -1
  244. package/dist/client/assets/{use-deep-link-scroll-v02TbidQ.js → use-deep-link-scroll-DkS713kG.js} +1 -1
  245. package/dist/client/assets/{use-delete-binding-CnziYpXo.js → use-delete-binding-CukKpHBK.js} +1 -1
  246. package/dist/client/assets/{use-dev-links-k4YWFO1v.js → use-dev-links-DQ32IcGe.js} +1 -1
  247. package/dist/client/assets/{use-external-adapter-catalog-DoGUfa2F.js → use-external-adapter-catalog-D-FO_XW6.js} +1 -1
  248. package/dist/client/assets/{use-full-activity-feed-CQNxgxnw.js → use-full-activity-feed-BNxcyb1j.js} +1 -1
  249. package/dist/client/assets/use-is-below-desktop-gTvJDvw4.js +1 -0
  250. package/dist/client/assets/use-is-hub-B1vPpkYU.js +1 -0
  251. package/dist/client/assets/{use-jump-back-in-BuO6A0P7.js → use-jump-back-in-Bibj5tVk.js} +3 -3
  252. package/dist/client/assets/{use-local-browser-BNzN5O1P.js → use-local-browser-xg7WXAVK.js} +1 -1
  253. package/dist/client/assets/{use-mesh-topology-CpIDE8lD.js → use-mesh-topology-BgCSFw8s.js} +1 -1
  254. package/dist/client/assets/{use-mounted-ref-BAO3qunF.js → use-mounted-ref-qRbdZfOU.js} +1 -1
  255. package/dist/client/assets/{use-notification-prefs-CtqeH5Pk.js → use-notification-prefs-B-4kZR7I.js} +1 -1
  256. package/dist/client/assets/{use-panel-tab-placements-DFobGBRm.js → use-panel-tab-placements-CCq-mZlY.js} +1 -1
  257. package/dist/client/assets/use-pending-read-C8L_v4Zw.js +1 -0
  258. package/dist/client/assets/{use-personality-commit-BvqCwzAC.js → use-personality-commit-DwSisUfF.js} +1 -1
  259. package/dist/client/assets/{use-promo-activation-Dz5cYm-X.js → use-promo-activation-Botoso6l.js} +3 -3
  260. package/dist/client/assets/{use-promo-dismissals-CuOsnqnZ.js → use-promo-dismissals-RJXp-r_J.js} +1 -1
  261. package/dist/client/assets/{use-pulse-freshness-qcTH6PM7.js → use-pulse-freshness-B3390hGg.js} +1 -1
  262. package/dist/client/assets/{use-relay-config-1mAMDNbc.js → use-relay-config-BV0xcLwS.js} +1 -1
  263. package/dist/client/assets/{use-room-follow-claim-CCGhsyH3.js → use-room-follow-claim-Du4hKHIJ.js} +1 -1
  264. package/dist/client/assets/{use-roving-tab-list-Bsg2dfUx.js → use-roving-tab-list-g2hO6Ruz.js} +1 -1
  265. package/dist/client/assets/{use-session-canvas-awPngMKg.js → use-session-canvas-i30oMO_Q.js} +3 -3
  266. package/dist/client/assets/{use-session-diagnostics-D5g8Mc52.js → use-session-diagnostics-a4b83F5J.js} +2 -2
  267. package/dist/client/assets/{use-unclaimed-chats-Db_wuzt0.js → use-unclaimed-chats-B92om889.js} +1 -1
  268. package/dist/client/assets/use-update-config-Tbn3SodN.js +1 -0
  269. package/dist/client/assets/{useMutationState-BvwBDXKc.js → useMutationState-DdOGdpjP.js} +1 -1
  270. package/dist/client/assets/{usecaseDiagram-WPOLBNNX-1zKygEKR.js → usecaseDiagram-WPOLBNNX-Di5pJvcw.js} +1 -1
  271. package/dist/client/assets/{vennDiagram-Q3Y3IDCW-BR2EbgGY.js → vennDiagram-Q3Y3IDCW-K7KAf26T.js} +1 -1
  272. package/dist/client/assets/{wardleyDiagram-IVAIDKWA-D0OwouJc.js → wardleyDiagram-IVAIDKWA-DVTaxQt9.js} +1 -1
  273. package/dist/client/assets/{xychartDiagram-4URNHDU4-BM-7_FQQ.js → xychartDiagram-4URNHDU4-x-lSJm_B.js} +1 -1
  274. package/dist/client/index.html +1 -1
  275. package/dist/drizzle/20261018210140_remote_command_agent_computer_kind.sql +21 -0
  276. package/dist/drizzle/20261019142317_turn_marks.sql +3 -0
  277. package/dist/drizzle/meta/20261018210140_snapshot.json +14027 -0
  278. package/dist/drizzle/meta/20261019142317_snapshot.json +14048 -0
  279. package/dist/drizzle/meta/_journal.json +14 -0
  280. package/dist/server/index.js +23779 -20674
  281. package/dist/server/index.js.map +2 -2
  282. package/package.json +4 -4
  283. package/dist/client/assets/HandlePage-BKiqymRF.js +0 -1
  284. package/dist/client/assets/McpSigninBody-COIHpHq_.js +0 -1
  285. package/dist/client/assets/NamePage-D7W6VMYd.js +0 -1
  286. package/dist/client/assets/OperatorIdentityForm-C3op6BIC.js +0 -1
  287. package/dist/client/assets/PermissionHistory-CKebTVkq.js +0 -1
  288. package/dist/client/assets/PhotoPage-Ch1at4A6.js +0 -1
  289. package/dist/client/assets/SettingsDialog-Bdws5dbS.js +0 -12
  290. package/dist/client/assets/TaskDialogWrapper-CTcW70s8.js +0 -1
  291. package/dist/client/assets/ToolsPage-D5-fx1EA.js +0 -2
  292. package/dist/client/assets/_shell-BLTSXXDw.js +0 -80
  293. package/dist/client/assets/_shell.channels-D_GQU4RB.js +0 -10
  294. package/dist/client/assets/_shell.connections-DZrlxs4G.js +0 -1
  295. package/dist/client/assets/_shell.marketplace-CZxkAmFz.js +0 -1
  296. package/dist/client/assets/_shell.marketplace_.sources-Q0BTQIuE.js +0 -1
  297. package/dist/client/assets/_shell.session-DvGL0DoX.js +0 -63
  298. package/dist/client/assets/_shell.x._extensionId-B6Tm5KuT.js +0 -1
  299. package/dist/client/assets/_shell.x._extensionId_._-B6Tm5KuT.js +0 -1
  300. package/dist/client/assets/channel-CGffcDRq.js +0 -1
  301. package/dist/client/assets/image-lightbox-BXzbN27o.js +0 -1
  302. package/dist/client/assets/index-1qv8ldHx.js +0 -1
  303. package/dist/client/assets/index-8-iQ6PnT.js +0 -1028
  304. package/dist/client/assets/index-BFitbVs4.js +0 -1
  305. package/dist/client/assets/index-CI84yP-g.js +0 -1
  306. package/dist/client/assets/index-D5zUdnZM.js +0 -1
  307. package/dist/client/assets/index-DX_2Mxwv.js +0 -1
  308. package/dist/client/assets/primer-trigger-CEli_z4n.js +0 -3
  309. package/dist/client/assets/registry-Bnd-HFt3.js +0 -1
  310. package/dist/client/assets/shield-check-CpUB_Ju1.js +0 -6
  311. package/dist/client/assets/signed-in-X2utDqQS.js +0 -1
  312. package/dist/client/assets/swimlanesDiagram-AYQRV4AK-jpZCGfva.js +0 -8
  313. package/dist/client/assets/use-is-below-desktop-DR8FEbRW.js +0 -1
  314. package/dist/client/assets/use-is-hub-BmpgFnFp.js +0 -1
  315. package/dist/client/assets/use-pending-read-Do0_vZ2I.js +0 -1
  316. package/dist/client/assets/use-update-config-DwtH_H9Z.js +0 -1
@@ -1,10 +0,0 @@
1
- import{W as Rt,r as m,j as t,gA as wt,a1 as ee,a3 as de,jo as ue,jp as V,jq as B,eM as St,jr as bt,js as kt,jt as At,c4 as Re,l as ge,a2 as Dt,a4 as Te,ju as Tt,jv as Et,jw as Mt,jx as je,jy as ke,B as k,jz as Ot,ct as $t,jA as Ge,d$ as ce,dU as It,dV as Kt,dW as Ut,dX as Lt,dY as _t,I as We,g9 as Ve,g$ as Ft,ga as Xe,gb as Ze,gc as et,gd as tt,ge as st,gf as nt,gg as zt,$ as Pt,jB as qt,jb as xe,cw as Ee,cx as Me,cz as Oe,cA as $e,cB as Ie,dw as Ke,dc as Ue,a7 as rt,jC as Ht,jD as Yt,hi as Bt,jE as Qt,jF as Le,jG as Jt,jH as Gt,jI as at,jJ as Wt,jK as it,jL as ot,jM as Vt,dI as lt,jN as Xt,jO as Zt,jP as es,iI as ts,a0 as ss,e2 as ns,fp as rs,jQ as as,cD as ct,jR as is,jS as os,ad as ls,n as He}from"./index-8-iQ6PnT.js";import{T as cs,R as ds,a as us}from"./RoomSurface-CSKIvyHH.js";import{M as pe,C as Ne}from"./index-DNzk9m1D.js";import{M as ms}from"./markdown-content-D0FpU2cz.js";import{o as fs,a as ps,c as hs}from"./owner-notice-CJHyha58.js";import"./use-jump-back-in-BuO6A0P7.js";import"./use-room-follow-claim-CCGhsyH3.js";import"./WidgetErrorCard-BfgGzyqg.js";import"./index-D5zUdnZM.js";import"./card-Dj6ZfRgu.js";import"./progress-DmUieXLn.js";import"./table-DvU_oS4E.js";import"./terminal-Dw2QZ7Dh.js";import"./package-B8G7jQm-.js";import"./heart-CRkjVW7-.js";import"./git-branch-DWerghmw.js";import"./file-text-CRw31ZWd.js";import"./file-DEt4KgZG.js";import"./find-latest-widget-fence-B3aaiBNI.js";import"./format-duration-BCr6uzby.js";import"./RuntimeSetupDialog-COpyPrqL.js";import"./inline-code-D9bLKHjY.js";import"./list-runtime-types-Bb33QiMC.js";import"./RuntimeConnectFlow--fVpIf0B.js";import"./useMutationState-BvwBDXKc.js";import"./runtime-connect-Dn0T5YWv.js";import"./mention-pill-uuaUvwSW.js";import"./rotate-ccw-clock-DiuTseKz.js";import"./unplug-CAVOLB2R.js";import"./message-square-off-B8N6YF9R.js";import"./registry-Bnd-HFt3.js";import"./use-connector-management-fr1tx-GZ.js";import"./AgentRequestCard-DQ6GYoeE.js";import"./access-copy-Dj09Xk4b.js";import"./query-error-state--8AnWSSn.js";import"./empty-state-kISAAp0z.js";import"./use-bindings-BV6HA0MD.js";import"./connection-copy--MA7AN04.js";import"./KeyEntry-DJnzW3Mu.js";import"./file-drag-GDx2qhdk.js";import"./paperclip-BDeYGKqh.js";import"./index-gIQ7FrL9.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 dt={name:"circle-off",size:24,node:[["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M8.35 2.69A10 10 0 0 1 21.3 15.65",key:"1pfsoa"}],["path",{d:"M19.08 19.08A10 10 0 1 1 4.92 4.92",key:"1ablyi"}]]};dt.node;const gs=Rt(dt),xs=5e3;function ys({connection:e}){var c;const s=e.official===!0&&e.status==="connected"&&((c=e.access)==null?void 0:c.state)==="unverified",n=m.useMemo(()=>s?{}:null,[s]),[r,o]=m.useState(null);return m.useEffect(()=>{if(!n)return;const f=setTimeout(()=>o(n),xs);return()=>clearTimeout(f)},[n]),n===null||r!==n?null:t.jsx(wt,{tone:"info",role:"status",className:"m-3","data-testid":"official-space-unreachable",children:"The DorkOS community isn’t reachable right now. Try again in a few minutes."})}const vs=500,ie=new Map;function ut(e,s){return e.id!==s.id||e.community!==s.community||e.roomId!==s.roomId||e.text===s.text&&e.authorDisplayName===s.authorDisplayName&&JSON.stringify(e.mentions)===JSON.stringify(s.mentions)&&JSON.stringify(e.attachments)===JSON.stringify(s.attachments)?e:{...e,text:s.text,mentions:s.mentions,attachments:s.attachments,authorDisplayName:s.authorDisplayName}}function De(e,s){if(s.size===0)return e;let n=!1;const r=e.map(o=>{const c=s.get(o.id),f=c?ut(o,c):o;return f!==o&&(n=!0),f});return n?r:e}function Ce(e,s,...n){const r=new Map;for(const o of n)for(const c of o){if(c.community!==e||c.roomId!==s)throw new Error("Community history contains a different room.");r.set(c.id,c)}return[...r.values()].sort((o,c)=>o.remoteSeq-c.remoteSeq)}function js(e,s,n=!0,r=0,o="legacy",c=!1,f){const l=ee(),a=m.useRef(f);m.useEffect(()=>{a.current=f},[f]);const i=de(),h=ue(!0,o,e),u=JSON.stringify([h==null?void 0:h.ownerKey,h==null?void 0:h.epoch,h==null?void 0:h.route.epoch,h==null?void 0:h.accessFingerprint,e,s]),[N,C]=m.useState(()=>({address:u,room:null,entries:[],revisions:ie,deliveries:[],status:"connecting"}));return m.useEffect(()=>{if(!h||!n)return;const v=h,w=new AbortController;let x,O=0,A,F,q=!1;C({address:u,room:null,entries:[],revisions:ie,deliveries:[],status:"connecting"});function M(){q=!0,A=void 0,F=void 0,i.removeQueries({queryKey:B.remote(v,e)}),C({address:u,room:null,entries:[],revisions:ie,deliveries:[],status:"removed"})}async function P(){try{await l.subscribeRemoteCommunityRoom(e,s,j=>{var I;if(!(w.signal.aborted||q||!V(v))){if(j.type==="closed"){(j.reason==="removed"||j.reason==="revoked")&&M();return}if(O=0,j.type==="snapshot")A=j.cursor??void 0,j.redactionCursor&&(F=j.redactionCursor),i.setQueryData(B.room(v,e,s),j.room),C(y=>({address:u,room:j.room,entries:De(Ce(e,s,y.address===u?y.entries:[],j.entries).slice(-500),y.address===u?y.revisions:ie),revisions:y.address===u?y.revisions:ie,deliveries:y.deliveries.filter(g=>!j.entries.some(K=>K.originIdempotencyKey===g.idempotencyKey)),status:j.stale?"offline":"live"}));else if(j.type==="revision"){const y=j.entry;j.redactionCursor&&(F=j.redactionCursor);const g=[...B.room(v,e,s),"entries"],b=i.getQueriesData({queryKey:g}).some(([,S])=>S==null?void 0:S.pages.some(L=>L.entries.some(H=>H.id===y.id)))||i.isFetching({queryKey:g})>0||((I=a.current)==null?void 0:I.call(a,y.id))===!0;i.setQueriesData({queryKey:g},S=>{if(!S)return S;let L=!1;const H=S.pages.map(X=>{const re=X.entries.map(Z=>ut(Z,y));return re.some((Z,me)=>Z!==X.entries[me])?(L=!0,{...X,entries:re}):X});return L?{...S,pages:H}:S}),C(S=>{if(!b&&!S.entries.some(H=>H.id===y.id))return S;const L=new Map(S.revisions);for(L.delete(y.id),L.set(y.id,y);L.size>vs;)L.delete(L.keys().next().value);return{...S,entries:De(S.entries,L),revisions:L}})}else j.type==="deliveries"?C(y=>({...y,deliveries:j.deliveries.filter(g=>!y.entries.some(K=>K.originIdempotencyKey===g.idempotencyKey))})):(A=j.entry.cursor,C(y=>({...y,entries:Ce(e,s,y.entries,[j.entry]).slice(-500),deliveries:y.deliveries.filter(g=>g.idempotencyKey!==j.entry.originIdempotencyKey),status:"live"})))}},{since:A,redactions:F,signal:w.signal})}catch(j){if(w.signal.aborted||!V(v))return;const I=j&&typeof j=="object"&&"status"in j?j.status:void 0,y=j&&typeof j=="object"&&"code"in j?j.code:void 0;y==="COMMUNITY_DELETED"||y==="COMMUNITY_TAKEN_DOWN"?(M(),i.invalidateQueries({queryKey:B.connections(v)})):I===401||I===403||I===404?M():I===410&&y==="COMMUNITY_CURSOR_STALE"&&(A=void 0)}if(w.signal.aborted||q||!V(v))return;const U=i.getQueryData(B.room(v,e,s));U&&i.setQueryData(B.room(v,e,s),{...U,stale:!0,writable:!1}),C(j=>({...j,room:j.room?{...j.room,stale:!0,writable:!1}:null,status:"offline"})),x=setTimeout(()=>{P()},Math.min(3e4,1e3*2**Math.min(O++,5)))}return P(),()=>{w.abort(),clearTimeout(x)}},[u,e,s,n,r,i,l,h,c]),N.address!==u||!h?{address:u,room:null,entries:[],revisions:ie,deliveries:[],status:"connecting"}:n?N:c?{...N,room:N.room?{...N.room,stale:!0,writable:!1}:null,deliveries:[],status:"offline"}:{address:u,room:null,entries:[],revisions:ie,deliveries:[],status:"removed"}}function Ns(e){var h;const s=St(),n=bt(),r=e===void 0||(h=s.data)==null?void 0:h.find(u=>u.id===e),o=r!==void 0&&kt(r)!==null,c=e===void 0||s.data!==void 0||s.isError,[f,l]=m.useState(void 0),a=e!==void 0&&f===e,i=m.useRef(void 0);return m.useEffect(()=>{!o||e===void 0||a||i.current===e||(i.current=e,n({roomId:e},{replace:!0,quiet:!0}).then(u=>{u||l(e)}))},[o,e,a,n]),c?o&&!a?"redirecting":"show":"pending"}function Cs(e,s,n){var l;const r=At(),o=Re(),c=e!==void 0&&((l=r.room)==null?void 0:l.id)===e,f=r.status!=="loading";return m.useEffect(()=>{c&&o({...ge.home(),search:{...s===void 0?{}:{thread:s},...n===void 0?{}:{entry:n}},replace:!0})},[c,s,n,o]),e===void 0?"show":c?"redirecting":f?"show":"pending"}function Rs(e){return e?{ownerAddress:JSON.stringify([e.ownerKey,e.epoch]),contextAddress:JSON.stringify([e.ownerKey,e.epoch,e.route.epoch,e.accessFingerprint])}:{ownerAddress:"",contextAddress:""}}const ws=new Set(["COMMUNITY_MUTED","COMMUNITY_SLOW_MODE","COMMUNITY_RULES_NOT_ACCEPTED"]);function Ss(e){const s=e==null?void 0:e.code;return typeof s=="string"&&ws.has(s)}function bs(e,s=new Date){return e.kind==="muted"?`You’re muted here until ${Tt(e.until,s)??"later"}.`:e.kind==="rules"?"Accept this space’s rules to post.":`Slow mode. Post again in ${e.secondsLeft}s.`}function ks(e,s){if(!e)return null;if(e.mutedUntil&&Date.parse(e.mutedUntil)>s)return{kind:"muted",until:e.mutedUntil};const{rules:n}=e;return n.text!==null&&n.version>0&&n.acceptedVersion<n.version?{kind:"rules"}:null}function As({community:e,roomId:s,enabled:n,accessFingerprint:r}){var q;const o=ee(),c=de(),f=ue(n,r,e),l=f?[...B.room(f,e,s),"standing"]:[...B.all,"owner","unresolved",e,"room",s,"standing"],a=Dt({queryKey:l,queryFn:()=>Et(f,()=>o.getRemoteCommunityStanding(e,s)),enabled:n&&f!==null,staleTime:3e4,retry:!1,refetchInterval:M=>{var P;return(P=M.state.data)!=null&&P.mutedUntil&&Date.parse(M.state.data.mutedUntil)>Date.now()?6e4:!1}}),[i,h]=m.useState(null),[u,N]=m.useState(()=>Date.now()),C=(q=a.data)!=null&&q.mutedUntil?Date.parse(a.data.mutedUntil):null;m.useEffect(()=>{if(i!==null&&i>u){const M=setTimeout(()=>N(Date.now()),1e3);return()=>clearTimeout(M)}if(C!==null&&C>u){const M=setTimeout(()=>N(Date.now()),Math.min(C-u+50,1073741824));return()=>clearTimeout(M)}},[C,u,i]);const v=a.refetch,w=m.useCallback(M=>{if((M==null?void 0:M.code)==="COMMUNITY_SLOW_MODE"){const U=M.retryAfterMs;if(typeof U=="number"&&U>0){const j=Date.now();N(j),h(j+U)}return}v()},[v]),x=Te({meta:{suppressErrorToast:!0},mutationFn:M=>o.acceptRemoteCommunityRules(e,M),onSuccess:M=>{c.setQueryData(l,P=>P&&{...P,rules:M})},onError:()=>void v()}),O=ks(a.data,u),A=i===null?0:Math.ceil((i-u)/1e3),F=O??(A>0?{kind:"slow",secondsLeft:A}:null);return{standing:a.data,hold:F,noteHold:w,accept:x}}const Ds=new Set(["COMMUNITY_DELETED","COMMUNITY_TAKEN_DOWN"]),Ts=30*6e4,he=new Map;function mt(e,s,n){return JSON.stringify([e,s,n])}function ft(e){return Date.now()-e<Ts}function Es(e){for(const[s,n]of he)ft(n.at)||he.delete(s);return he.get(e)}function Ms(){return Date.now()}function Os(e,s,n){he.set(e,{attachmentId:s,at:n})}function Ye(e){for(const s of e.files)he.delete(mt(e.ref,e.roomId,s.id))}function Be(e){return e.filter(s=>s.trim()).join(`
7
-
8
- `)}function $s(e){const s=e==null?void 0:e.code;return typeof s=="string"&&Ds.has(s)}function Ae(e){return e.map(({id:s,file:n})=>({id:s,file:n,status:"pending",progress:0}))}function Is({ref:e,roomId:s,canSend:n,entries:r,onReceipt:o,draft:c,ownerKey:f,contextKey:l=f,onHold:a}){const i=ee(),h=JSON.stringify([f,e,s,l]),u=Mt(c),N=u.text,C=m.useMemo(()=>Ae(u.files),[u.files]),v=m.useRef(c);m.useLayoutEffect(()=>{v.current=c},[c]);function w(d){const R=v.current;if(!R)return;const $=je.getState(),T=$.drafts[ke(R)],E=d({text:(T==null?void 0:T.text)??"",files:Ae((T==null?void 0:T.files)??[])});$.write(R,{text:E.text,files:E.files.map(({id:z,file:Q})=>({id:z,file:Q}))})}function x(d){w(R=>({...R,text:d}))}function O(d){w(R=>({...R,files:d(R.files)}))}const[A,F]=m.useState(null);function q(d){F(d===null?null:{address:h,context:l,message:d})}const[M,P]=m.useState([]),U=m.useRef(new Map),j=m.useRef(0),I=m.useRef(new Map),y=m.useRef(new Set),g=m.useRef(h),K=m.useRef(l),b=m.useRef(!0),S=m.useRef(n),L=m.useRef(o),H=m.useRef(a);m.useLayoutEffect(()=>{g.current=h,K.current=l,S.current=n,L.current=o,H.current=a},[h,n,l,o,a]),m.useEffect(()=>(b.current=!0,()=>{b.current=!1}),[]),m.useEffect(()=>{let d=!1;for(const R of r){if(!R.originIdempotencyKey)continue;const $=U.current.get(R.originIdempotencyKey);($==null?void 0:$.address)===g.current&&$.context===K.current&&U.current.delete(R.originIdempotencyKey)&&(Ye($),d=!0)}d&&P([...U.current.values()])},[r]);function X(){b.current&&P([...U.current.values()].filter(d=>d.address===g.current&&d.context===K.current).map(d=>({...d})))}async function re(d){var R,$;if(!(y.current.has(d.key)||!S.current||!b.current||d.address!==g.current)){y.current.add(d.key),d.status="sending",d.error=void 0,X();try{!d.posted&&d.uploadedAt.some(E=>!ft(E))&&(d.attachmentIds=[],d.uploadedAt=[],d.triedAt=[],d.uploadRound+=1);for(let E=d.attachmentIds.length;E<d.files.length;E++){if(!S.current||!b.current||d.address!==g.current)throw new Error("Reconnect to this channel, then try again.");const z=d.files[E],Q=mt(d.ref,d.roomId,z.id),J=Es(Q);if(J){d.attachmentIds.push(J.attachmentId),d.uploadedAt.push(J.at);continue}const te=(R=d.triedAt)[E]??(R[E]=Ms()),G=await i.uploadRemoteCommunityAttachment(d.ref,d.roomId,z.file,d.uploadRound?`${d.key}:file:${E}:${d.uploadRound}`:`${d.key}:file:${E}`);Os(Q,G.id,te),d.uploadedAt.push(te),d.attachmentIds.push(G.id)}if(!S.current||!b.current||d.address!==g.current)throw new Error("Reconnect to this channel, then try again.");d.posted=!0;const T=await i.postRemoteCommunityEntry(d.ref,d.roomId,{text:d.text,parentEntryId:d.parentEntryId,attachmentIds:d.attachmentIds,idempotencyKey:d.key});U.current.delete(d.key),Ye(d),b.current&&d.address===g.current&&d.context===K.current&&L.current(T)}catch(T){if($s(T)&&Z(d)){U.current.delete(d.key);return}if(Ss(T)&&Z(d)){U.current.delete(d.key),b.current&&d.address===g.current&&(($=H.current)==null||$.call(H,T));return}d.status="failed",d.error=T instanceof Error?T.message:"Not confirmed. Try this message again."}finally{y.current.delete(d.key),X()}}}function Z(d){const{draft:R}=d.origin,$=ke(R),T=je.getState(),E=T.drafts[$],z=(E==null?void 0:E.text)??"";let Q=I.current.get($)??[];const J=Be(Q.map(W=>W.origin.typed));let te=z;J&&z.startsWith(J)?te=z.slice(J.length).replace(/^\n+/,""):Q=[];const G=[...Q,d].sort((W,se)=>W.origin.seq-se.origin.seq),ye=new Set(G.flatMap(W=>W.files.map(se=>se.id))),ae=[...G.flatMap(W=>W.files.map(({id:se,file:fe})=>({id:se,file:fe}))),...((E==null?void 0:E.files)??[]).filter(W=>!ye.has(W.id))];return T.write(R,{text:Be([...G.map(W=>W.origin.typed),te]),files:ae}),$ in je.getState().drafts?(I.current.set($,G),!0):!1}function me(d){const R=v.current;if(!R||!S.current)return;const $=je.getState(),T=$.drafts[ke(R)];if(!T||!T.text.trim()&&T.files.length===0)return;if(U.current.size>=30){q("Too many messages waiting. Let them send, or retry them first.");return}const E=$.take(R),z=Ae(E.files),Q={address:h,context:l,ref:e,roomId:s,key:crypto.randomUUID(),text:E.text.trim()?E.text:z.map(J=>J.file.name).join(", "),parentEntryId:d,files:z,attachmentIds:[],uploadedAt:[],triedAt:[],posted:!1,uploadRound:0,status:"sending",origin:{draft:R,typed:E.text,seq:j.current+=1}};U.current.set(Q.key,Q),q(null),re(Q)}return{text:N,setText:x,attachments:{staged:C,add(d){if(d.some(R=>R.size>25*1024*1024)){q("Each file must be 25 MB or smaller.");return}O(R=>R.length+d.length>8?(q("Attach up to eight files to one message."),R):[...R,...d.map($=>({id:crypto.randomUUID(),file:$,status:"pending",progress:0}))])},remove(d){O(R=>R.filter($=>$.id!==d))},retry(){},cancel(){O(()=>[])},hasFailed:!1,isUploading:!1,holdsSendWhileUploading:!1},deliveries:M.filter(d=>d.address===h&&d.context===l),error:(A==null?void 0:A.address)===h&&A.context===l?A.message:null,send:me,retry(d){const R=U.current.get(d);R&&re(R)}}}function pt({entry:e,onThread:s,onReport:n}){const r=ee(),o=m.useId(),[c,f]=m.useState(null),[l,a]=m.useState(null),i={id:JSON.stringify([e.community,e.authorId]),kind:e.authorKind,displayName:e.authorDisplayName};async function h(u,N){if(l)return;a(u),f(null);let C;try{const v=await r.downloadRemoteCommunityAttachment(e.community,e.roomId,u);C=URL.createObjectURL(v);const w=document.createElement("a");w.href=C,w.download=Array.from(N,x=>x==="/"||x==="\\"||x.charCodeAt(0)<32?"_":x).join(""),document.body.append(w),w.click(),w.remove()}catch(v){f(v instanceof Error?v.message:"Couldn’t download the file. Try again.")}finally{C&&setTimeout(()=>URL.revokeObjectURL(C),1e3),a(null)}}return t.jsxs(pe.Root,{role:e.authorKind==="human"?"user":"assistant","aria-labelledby":o,children:[t.jsx(pe.Gutter,{author:i,at:e.createdAt}),t.jsxs(pe.Body,{children:[t.jsx(pe.Author,{id:o,author:i,at:e.createdAt}),t.jsxs(pe.Content,{children:[t.jsx(ms,{content:e.text}),e.attachments.map(u=>t.jsx(k,{variant:"outline",size:"sm",disabled:l!==null,onClick:()=>void h(u.id,u.name),className:"max-w-full",children:t.jsx("span",{className:"min-w-0 truncate",children:l===u.id?"Downloading…":u.name})},u.id)),c&&t.jsx("p",{role:"alert",className:"text-destructive text-sm",children:c}),s&&t.jsx(k,{variant:"ghost",size:"sm",onClick:()=>s(e.threadRootEntryId??e.id),children:e.depth===0?"Reply in thread":"Open thread"}),n&&t.jsx(k,{variant:"ghost",size:"sm",onClick:n,children:"Report"})]})]})]})}function Ks({community:e,roomId:s,online:n,canEnroll:r,accessFingerprint:o}){var y,g,K;const c=ee(),f=de(),l=ue(!0,o,e),a=Ot(e,r,o),i=$t(),h=Ge(e,r,o),[u,N]=m.useState(""),[C,v]=m.useState(""),[w,x]=m.useState(!1),[O,A]=m.useState(null),[F,q]=m.useState(null),M=m.useId(),P=((y=a.data)==null?void 0:y.filter(b=>b.active))??[],U=((g=i.data)==null?void 0:g.agents.filter(b=>!P.some(S=>S.localAgentId===b.id)))??[];async function j(){l&&V(l)&&await f.invalidateQueries({queryKey:B.remote(l,e)})}async function I(b){if(b.preventDefault(),!u||w||!n||!r||!l)return;const S=l;x(!0),A(null);try{if(await c.enrollRemoteCommunityAgent(e,u,C.trim()?{handle:C.trim()}:{}),!V(S))return;N(""),v(""),await j()}catch(L){V(S)&&A(L instanceof Error?L.message:"Couldn’t add the agent. Try again.")}finally{V(S)&&x(!1)}}return t.jsxs("section",{className:"mt-3 space-y-2 border-t pt-3","aria-label":"Your agents in this space",children:[t.jsx("h3",{className:"text-sm font-medium",children:"My agents"}),t.jsx("p",{className:"text-muted-foreground text-xs",children:"Add an agent from here, then choose whether it joins this channel."}),a.isError&&t.jsxs("p",{role:"alert",children:["Couldn’t load your agents in this space."," ",t.jsx(k,{variant:"ghost",size:"sm",onClick:()=>void a.refetch(),children:"Retry"})]}),(K=a.data)==null?void 0:K.map(b=>{var S;return t.jsx(Us,{agent:b,roomId:s,online:n,canEnroll:r,takesDms:((S=h.data)==null?void 0:S.available)===!0,onChanged:j,onNotice:q},b.localAgentId)}),i.isError&&t.jsx("p",{role:"alert",children:"Couldn’t load the agents on this computer."}),r&&U.length>0&&t.jsxs("form",{onSubmit:b=>void I(b),className:"flex flex-wrap items-end gap-2",children:[t.jsxs("div",{className:"min-w-40 flex-1 space-y-1",children:[t.jsx(ce,{htmlFor:`${M}-agent`,children:"Local agent"}),t.jsxs(It,{value:u,onValueChange:N,disabled:!n||w,children:[t.jsx(Kt,{id:`${M}-agent`,children:t.jsx(Ut,{placeholder:"Choose an agent"})}),t.jsx(Lt,{children:U.map(b=>t.jsx(_t,{value:b.id,children:b.name},b.id))})]})]}),t.jsxs("div",{className:"min-w-40 flex-1 space-y-1",children:[t.jsx(ce,{htmlFor:`${M}-handle`,children:"Space handle (optional)"}),t.jsx(We,{id:`${M}-handle`,value:C,onChange:b=>v(b.target.value),disabled:!n||w,placeholder:"Use the agent’s handle"})]}),t.jsx(k,{type:"submit",disabled:!u||!n||w,children:w?"Adding…":"Add to space"})]}),F&&t.jsx("p",{role:"status",className:"text-muted-foreground text-sm",children:F}),O&&t.jsx("p",{role:"alert",className:"text-destructive text-sm",children:O})]})}function Us({agent:e,roomId:s,online:n,canEnroll:r,takesDms:o,onChanged:c,onNotice:f}){const l=ee(),[a,i]=m.useState(null),[h,u]=m.useState(null),N=e.roomIds.includes(s),C=m.useId();async function v(x,O){if(!a){i(x),u(null);try{await O(),await c()}catch(A){u(A instanceof Error?A.message:"Couldn’t finish that. Try again.")}finally{i(null)}}}function w(x){f(x.remoteRevoked?"Stopped taking part.":"Stopped here, but the space wasn’t told. Try again when it’s reachable.")}return t.jsxs("div",{className:"space-y-1 rounded-md border p-2",children:[t.jsxs("p",{className:"text-sm font-medium",children:[e.displayName,!e.active&&" · stopped here"," ",t.jsxs("span",{className:"text-muted-foreground font-normal",children:["· owned by ",e.ownerDisplayName]})]}),t.jsxs("div",{className:"flex flex-wrap gap-1",children:[t.jsx(k,{variant:"outline",size:"sm",disabled:a!==null||!r||!e.active||!N&&!n,onClick:()=>void v("membership",async()=>{N?w(await l.leaveRemoteCommunityAgentRoom(e.community,s,e.localAgentId)):await l.joinRemoteCommunityAgentRoom(e.community,s,e.localAgentId)}),children:N?"Leave channel":"Join channel"}),t.jsx(k,{variant:"ghost",size:"sm",disabled:a!==null||!r,onClick:()=>void v("stop",()=>l.haltRemoteCommunityAgent(e.community,s,e.localAgentId)),children:"Stop agent"}),t.jsxs(Ve,{children:[t.jsx(Ft,{asChild:!0,children:t.jsx(k,{variant:"ghost",size:"sm",disabled:a!==null||!r,children:"Remove from space"})}),t.jsxs(Xe,{children:[t.jsxs(Ze,{children:[t.jsxs(et,{children:["Remove ",e.displayName,"?"]}),t.jsx(tt,{children:"It leaves every channel in this space. You can re-add it."})]}),t.jsxs(st,{children:[t.jsx(nt,{children:"Cancel"}),t.jsx(zt,{onClick:()=>void v("remove",async()=>w(await l.ejectRemoteCommunityAgent(e.community,e.localAgentId))),children:"Remove agent"})]})]})]})]}),o&&e.active&&t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(Pt,{id:C,checked:e.acceptsDms===!0,disabled:a!==null||!r||!n,onCheckedChange:x=>void v("dms",()=>l.setRemoteCommunityAgentDms(e.community,e.localAgentId,x))}),t.jsx(ce,{htmlFor:C,className:"text-xs font-normal",children:"Takes direct messages"})]}),h&&t.jsx("p",{role:"status",className:"text-muted-foreground text-xs",children:h})]})}function Ls({community:e,agent:s,disabled:n,accessFingerprint:r}){const o=ee(),c=Re(),f=de(),l=ue(!0,r,e),[a,i]=m.useState(!1),[h,u]=m.useState(null);async function N(){if(!a){i(!0),u(null);try{const C=await o.startRemoteCommunityDm(e,s.memberId);l&&await f.invalidateQueries({queryKey:B.dms(l,e)}),c({...ge.channels(),search:{community:e,id:C.roomId}})}catch(C){u(C.code===qt?`${s.displayName} isn’t taking direct messages.`:"Couldn’t open the direct message. Try again.")}finally{i(!1)}}}return t.jsxs("span",{className:"flex flex-wrap items-center justify-end gap-x-2",children:[h&&t.jsx("span",{role:"status",className:"text-muted-foreground order-last w-full text-right text-xs sm:order-none sm:w-auto",children:h}),t.jsx(k,{variant:"ghost",size:"sm",disabled:n||a,onClick:()=>void N(),"aria-label":`Message ${s.displayName}`,children:"Message"})]})}function _s(e,s){const n=new Date(e),r=n.toLocaleTimeString([],{hour:"numeric",minute:"2-digit"});return n.toDateString()===s.toDateString()?r:`${n.toLocaleDateString([],{month:"short",day:"numeric",...n.getFullYear()===s.getFullYear()?{}:{year:"numeric"}})}, ${r}`}function Fs(e,s=new Date){return e.kind!=="agent"?null:e.availability==="available"?{text:"Available"}:e.availability==="offline"&&e.lastSeenAt?{text:"Offline since",since:{dateTime:new Date(e.lastSeenAt).toISOString(),label:_s(e.lastSeenAt,s)}}:null}function zs({roster:e,failed:s,canMention:n,onMention:r,community:o,roomId:c,online:f,canEnroll:l,agentsKey:a,accessFingerprint:i}){var C,v,w;const u=((C=Ge(o,!0,i).data)==null?void 0:C.available)===!0,N=(w=(v=xe().data)==null?void 0:v.find(x=>x.ref===o))==null?void 0:w.connectedHumanMemberId;return t.jsxs("div",{className:"max-h-48 overflow-auto border-b p-3","aria-label":"Channel members",children:[s&&t.jsx("p",{role:"alert",children:"Couldn’t load members."}),(e==null?void 0:e.stale)&&t.jsx("p",{className:"text-muted-foreground text-sm",children:"Saved member list"}),e==null?void 0:e.members.map(x=>{var A;const O=Fs(x);return t.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-x-2 text-sm",children:[t.jsxs("span",{children:[x.displayName,x.kind==="agent"?" · Agent":"",x.ownerMemberId&&` · owned by ${((A=e.members.find(F=>F.memberId===x.ownerMemberId))==null?void 0:A.displayName)??"a space member"}`,O&&t.jsxs("span",{className:"text-muted-foreground",children:[` · ${O.text}`,O.since&&t.jsxs(t.Fragment,{children:[" ",t.jsx("time",{dateTime:O.since.dateTime,children:O.since.label})]})]})]}),t.jsxs("span",{className:"flex flex-wrap items-center justify-end",children:[u&&x.kind==="agent"&&x.ownerMemberId!==N&&t.jsx(Ls,{community:o,agent:x,disabled:!f,accessFingerprint:i}),x.handle&&t.jsxs(k,{variant:"ghost",size:"sm",disabled:!n,onClick:()=>r(x.handle),children:["Mention @",x.handle]})]})]},x.memberId)}),l&&t.jsx(Ks,{community:o,roomId:c,online:f,canEnroll:!0,accessFingerprint:i},a)]})}function ht(e,s){return e instanceof Error&&e.message?e.message:s}function Ps({conduct:e,staff:s,onReadRules:n}){const{hold:r,standing:o}=e;return(r==null?void 0:r.kind)==="rules"?t.jsx("div",{className:"px-1 pb-1",children:t.jsx(k,{size:"sm",variant:"outline",onClick:n,children:"Read the rules"})}):r||s||!(o!=null&&o.slowModeSeconds)?null:t.jsxs("p",{className:"text-muted-foreground px-1 pb-1 text-xs",children:["Slow mode: one message every ",o.slowModeSeconds,"s."]})}function qs({conduct:e,open:s,onOpenChange:n}){var c;const r=(c=e.standing)==null?void 0:c.rules,o=r?r.acceptedVersion>=r.version:!1;return t.jsx(Ee,{open:s,onOpenChange:n,children:t.jsxs(Me,{className:"sm:max-w-lg",children:[t.jsxs(Oe,{children:[t.jsx($e,{children:"Space rules"}),t.jsx(Ie,{children:o?"You accepted these rules.":"Accept these rules to post here."})]}),t.jsxs(Ke,{children:[t.jsx("div",{className:"max-h-[50vh] overflow-y-auto rounded-md border p-3 text-sm leading-relaxed whitespace-pre-wrap",children:(r==null?void 0:r.text)??"This space has no rules."}),e.accept.error&&t.jsx("p",{role:"alert",className:"text-destructive mt-2 text-sm",children:ht(e.accept.error,"Couldn’t accept the rules. Try again.")})]}),t.jsxs(Ue,{children:[t.jsx(k,{variant:"outline",onClick:()=>n(!1),children:"Close"}),(r==null?void 0:r.text)&&!o&&t.jsx(k,{disabled:e.accept.isPending,onClick:()=>e.accept.mutate(r.version,{onSuccess:()=>n(!1)}),children:e.accept.isPending?"Accepting…":"Accept rules"})]})]})})}function Hs({community:e,accessFingerprint:s,currentName:n,open:r,onOpenChange:o}){return t.jsx(Ee,{open:r,onOpenChange:o,children:t.jsx(Me,{className:"sm:max-w-md",children:r&&t.jsx(Ys,{community:e,accessFingerprint:s,currentName:n,onDone:()=>o(!1)})})})}function Ys({community:e,accessFingerprint:s,currentName:n,onDone:r}){const o=ee(),c=de(),f=ue(!0,s,e),[l,a]=m.useState(n),i=Te({meta:{suppressErrorToast:!0},mutationFn:u=>o.setRemoteCommunityDisplayName(e,u),onSuccess:async()=>{f&&await c.invalidateQueries({queryKey:B.content(f,e)}),r()}}),h=l.trim();return t.jsxs("form",{onSubmit:u=>{u.preventDefault(),h&&h!==n&&i.mutate(h)},children:[t.jsxs(Oe,{children:[t.jsx($e,{children:"Your name in this space"}),t.jsx(Ie,{children:"Other spaces keep the name they show."})]}),t.jsxs(Ke,{className:"space-y-2",children:[t.jsx(ce,{htmlFor:"remote-community-display-name",children:"Name"}),t.jsx(We,{id:"remote-community-display-name",value:l,maxLength:128,autoComplete:"nickname",onChange:u=>a(u.target.value)}),i.error&&t.jsx("p",{role:"alert",className:"text-destructive text-sm",children:ht(i.error,"Couldn’t change your name. Try again.")})]}),t.jsxs(Ue,{children:[t.jsx(k,{type:"button",variant:"outline",onClick:r,children:"Cancel"}),t.jsx(k,{type:"submit",disabled:!h||h===n||i.isPending,children:i.isPending?"Saving…":"Save name"})]})]})}const Bs=[{value:"spam",label:"Spam"},{value:"harassment",label:"Harassment"},{value:"off_topic",label:"Off topic"},{value:"illegal",label:"Against the law"},{value:"other",label:"Something else"}];function Qs({entry:e,onClose:s}){return t.jsx(Ee,{open:e!==null,onOpenChange:n=>!n&&s(),children:t.jsx(Me,{className:"sm:max-w-md",children:e&&t.jsx(Js,{entry:e,onClose:s},e.id)})})}function Js({entry:e,onClose:s}){const n=ee(),r=m.useId(),[o,c]=m.useState(null),[f,l]=m.useState(""),a=Te({meta:{suppressErrorToast:!0},mutationFn:i=>n.reportRemoteCommunityEntry(e.community,e.roomId,e.id,i),onSuccess:()=>{rt("Message reported"),s()}});return t.jsxs("form",{onSubmit:i=>{i.preventDefault(),o&&a.mutate({reason:o,...f.trim()?{note:f.trim()}:{}})},children:[t.jsxs(Oe,{children:[t.jsx($e,{children:"Report message"}),t.jsx(Ie,{children:"This space’s owners and admins review reports."})]}),t.jsxs(Ke,{className:"space-y-4",children:[t.jsxs("p",{className:"text-muted-foreground line-clamp-3 text-sm",children:[e.authorDisplayName,": ",e.text]}),t.jsx(Ht,{"aria-label":"Reason",value:o??"",onValueChange:i=>c(i),children:Bs.map(i=>t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(Yt,{value:i.value,id:`${r}-${i.value}`}),t.jsx(ce,{htmlFor:`${r}-${i.value}`,children:i.label})]},i.value))}),t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(ce,{htmlFor:`${r}-note`,children:"Note (optional)"}),t.jsx(Bt,{id:`${r}-note`,value:f,maxLength:Qt,onChange:i=>l(i.target.value),rows:3}),t.jsx("p",{className:"text-muted-foreground text-xs",children:"Only owners and admins see this."})]}),a.error&&t.jsx("p",{role:"alert",className:"text-destructive text-sm",children:a.error instanceof Error&&a.error.message?a.error.message:"Couldn’t send the report. Try again."})]}),t.jsxs(Ue,{children:[t.jsx(k,{type:"button",variant:"outline",onClick:s,children:"Cancel"}),t.jsx(k,{type:"submit",disabled:!o||a.isPending,children:a.isPending?"Sending…":"Send report"})]})]})}function Gs({agentDeliveries:e,drafts:s,entries:n,threadId:r,canSend:o,action:c,onRetryAgent:f,onRetryDraft:l}){return t.jsxs(t.Fragment,{children:[e.filter(a=>a.parentEntryId===(r??null)&&!n.some(i=>i.originIdempotencyKey===a.idempotencyKey)).map(a=>t.jsxs("div",{className:"border-t px-4 py-2 text-sm",role:"status",children:[t.jsxs("p",{className:"font-medium",children:[a.author.displayName," · Agent"]}),t.jsx("p",{className:"whitespace-pre-wrap",children:a.text}),a.attachments.map((i,h)=>t.jsx("span",{className:"mr-2",children:i.name},h)),t.jsx("p",{className:"text-muted-foreground",children:a.state==="pending"?"Waiting for the space to confirm…":a.failure==="expired"?"Not confirmed. Too late to try again.":"Not confirmed. Check the space and the agent’s channel access."}),a.state==="pending"&&a.retryable&&t.jsx(k,{variant:"outline",size:"sm",disabled:!o||c!==null,onClick:()=>f(a.idempotencyKey),children:c===`retry:${a.idempotencyKey}`?"Retrying…":"Retry now"})]},a.idempotencyKey)),s.filter(a=>a.parentEntryId===r&&!n.some(i=>i.originIdempotencyKey===a.key)).map(a=>t.jsxs("div",{className:"border-t px-4 py-2 text-sm",role:"status",children:[t.jsx("p",{className:"whitespace-pre-wrap",children:a.text}),a.files.map(i=>t.jsx("span",{className:"mr-2",children:i.file.name},i.id)),t.jsx("p",{className:"text-muted-foreground",children:a.status==="sending"?"Sending…":"Delivery not confirmed."}),a.error&&t.jsx("p",{children:a.error}),a.status==="failed"&&t.jsx(k,{variant:"outline",size:"sm",disabled:!o,onClick:()=>l(a.key),children:"Retry message"})]},a.key))]})}function Ws(e,s){var c;const n=new Map;for(const f of e)f.thread&&n.set(f.id,{count:f.thread.replyCount,lastAt:f.thread.lastReplyAt,through:f.threadLastReplySeq});const r=new Map;for(const f of s){const l=f.threadRootEntryId;if(f.depth===0||l===null)continue;const a=(c=n.get(l))==null?void 0:c.through;if(a!==void 0&&f.remoteSeq<=a)continue;const i=r.get(l);r.set(l,{count:((i==null?void 0:i.count)??0)+1,newest:i&&i.newest.remoteSeq>f.remoteSeq?i.newest:f})}const o=new Map;for(const f of new Set([...n.keys(),...r.keys()])){const l=n.get(f),a=r.get(f),i=l===void 0?a.count:l.through===void 0?Math.max(l.count,(a==null?void 0:a.count)??0):l.count+((a==null?void 0:a.count)??0);o.set(f,{count:i,lastAt:(a==null?void 0:a.newest.createdAt)??l.lastAt,unread:0})}return o}const Vs={reactions:!1,threads:!0,runWith:!1,attachments:!0,mentions:!0,streamHealth:!0,presence:!1,turnStatus:!1,asks:!1};function Xs({community:e,roomId:s,threadId:n,onThread:r,dmAgentName:o}){var Fe,ze,Pe,qe;const c=ee(),l=(Fe=xe().data)==null?void 0:Fe.find(p=>p.ref===e),a=Le(l==null?void 0:l.access),i=ue(!0,a.fingerprint,e),{ownerAddress:h,contextAddress:u}=Rs(i),N=de(),C=Jt(),v=Gt(),w=(ze=C.data)==null?void 0:ze.destinations.find(p=>p.ref===e&&p.roomId===s),x=m.useRef(null),O=m.useRef(void 0),A=(w==null?void 0:w.scrollAnchorEntryId)??null,F=m.useCallback(p=>{if(!i||n)return;x.current&&clearTimeout(x.current),x.current=null;const D=p??null,_=O.current===void 0?A:O.current;D===null&&_===null||(x.current=setTimeout(()=>{x.current=null,O.current=D,v.mutate({ref:e,roomId:s,threadId:n??null,scrollAnchorEntryId:D})},400))},[i,e,v,A,s,n]);m.useEffect(()=>()=>{x.current&&clearTimeout(x.current)},[]),m.useEffect(()=>{(l==null?void 0:l.status)==="reconnect-required"&&i&&N.removeQueries({queryKey:B.remote(i,e)})},[i,e,l==null?void 0:l.status,N]);const q=at(e,s,a.capabilities.read,a.fingerprint),[M,P]=m.useState(0),U=m.useRef([]),j=m.useCallback(p=>U.current.some(D=>D.id===p),[]),I=js(e,s,a.capabilities.stream,M,a.fingerprint,a.cacheReadable,j),y=I.status==="removed",g=y?null:I.room??q.data,K=Wt(e,s,n,!y&&a.capabilities.read&&(g==null?void 0:g.readable)===!0,a.fingerprint),b=it(e,s,!y&&a.capabilities.read&&(g==null?void 0:g.readable)===!0,a.fingerprint),[S,L]=m.useState(()=>({address:u,entries:[]})),H=m.useMemo(()=>S.address===u?S.entries:[],[u,S]);m.useEffect(()=>{U.current=H},[H]);const[X,re]=m.useState(0),[Z,me]=m.useState(!1),[we,d]=m.useState(null),[R,$]=m.useState(null),T=As({community:e,roomId:s,enabled:!y&&a.capabilities.read&&(g==null?void 0:g.readable)===!0,accessFingerprint:a.fingerprint}),E=(l==null?void 0:l.connectedHumanMemberId)??null,z=(Pe=b.data)==null?void 0:Pe.members.find(p=>p.memberId===E),Q=p=>{var D;return p===E||((D=b.data)==null?void 0:D.members.some(_=>_.memberId===p&&_.ownerMemberId===E))===!0},[J,te]=m.useState({address:"",name:null,error:null}),G=J.address===u?J.name:null,ye=J.address===u?J.error:null,ae=m.useRef(null),W=m.useRef(null),se=m.useRef(null),fe=!y&&a.capabilities.post&&I.status==="live"&&(g==null?void 0:g.writable)===!0,Se=fe&&T.hold===null,oe=m.useMemo(()=>{var p;return y?[]:De(Ce(e,s,...((p=K.data)==null?void 0:p.pages.map(D=>D.entries))??[],I.entries,H),I.revisions)},[e,s,K.data,I.entries,I.revisions,H,y]),xt=m.useCallback(p=>{L(D=>({address:u,entries:Ce(e,s,D.address===u?D.entries:[],[p]).slice(-500)})),re(D=>D+1)},[u,e,s]);m.useLayoutEffect(()=>{var p;X>0&&((p=se.current)==null||p.scrollToBottom())},[X]);const yt=m.useMemo(()=>{var p;return i?{ownerKey:i.ownerKey,epoch:i.epoch,ref:e,generation:((p=i.connection)==null?void 0:p.generation)??0,roomId:s,threadId:n}:null},[i,e,s,n]),Y=Is({ref:e,roomId:s,canSend:Se,entries:oe,onReceipt:xt,draft:yt,ownerKey:h||"unresolved",contextKey:u||"unresolved",onHold:T.noteHold}),vt=oe.filter(p=>n?p.id===n||p.threadRootEntryId===n:p.depth===0),jt=m.useMemo(()=>{var p;return n?new Map:Ws(((p=K.data)==null?void 0:p.pages.flatMap(D=>D.entries))??[],oe)},[n,K.data,oe]),_e=vt.flatMap(p=>{const D=jt.get(p.id);return D?[{kind:"message",entry:p},{kind:"replies",rootId:p.id,summary:D}]:[{kind:"message",entry:p}]}),Nt=_e.map(p=>p.kind==="replies"?{kind:"thread-reply",id:`${p.rootId}:replies`,rootId:p.rootId,replyCount:p.summary.count,lastAt:p.summary.lastAt}:{kind:"message",id:p.entry.id,payload:p.entry,grouping:{position:"only"},author:{id:JSON.stringify([e,p.entry.authorId]),kind:p.entry.authorKind,displayName:p.entry.authorDisplayName},at:p.entry.createdAt}),be={kind:"room",id:JSON.stringify([e,s,n]),placeholder:n?"Reply in thread…":`Message ${o??(g==null?void 0:g.title)??"this channel"}…`,canSend:Se,canSendReason:y?"You no longer have access to this channel.":T.hold?bs(T.hold):!a.capabilities.post&&a.cacheReadable?"This space is read-only.":g!=null&&g.archived?"This channel is archived.":g!=null&&g.joined?"Reconnecting. You can send once the space is back.":"Join this channel to send messages.",attachments:Y.attachments,async send(){Y.send(n)}};async function ve(p,D){if(G||!i)return;const _=i,le=u;te({address:le,name:p,error:null});try{if(await D(),!V(_))return;(p==="join"||p==="leave"||p.startsWith("retry:"))&&P(ne=>ne+1),await N.invalidateQueries({queryKey:B.remote(_,e)})}catch(ne){V(_)&&te({address:le,name:p,error:ne instanceof Error?ne.message:"Couldn’t finish that. Try again."})}finally{V(_)&&te(ne=>ne.address===le?{...ne,name:null}:ne)}}function Ct(){var _;const p=oe.at(-1);if(n||K.hasNextPage||!p||I.status!=="live"||((_=ae.current)==null?void 0:_.address)===u&&ae.current.cursor===p.cursor||!i)return;const D=i;ae.current={address:u,cursor:p.cursor},c.setRemoteCommunityReadCursor(e,s,p.cursor).then(()=>{V(D)&&N.invalidateQueries({queryKey:B.rooms(D,e)})}).catch(()=>{var le;((le=ae.current)==null?void 0:le.address)===u&&(ae.current=null)})}return t.jsxs(Ne.Root,{surface:"room",capabilities:Vs,target:be,children:[t.jsxs("section",{className:"flex h-full min-h-0 flex-col","aria-label":(g==null?void 0:g.title)??"Space channel",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2 border-b px-3 py-2",children:[n&&t.jsx(k,{variant:"ghost",size:"sm",onClick:()=>r(),children:"Back to channel"}),!y&&a.capabilities.post&&g&&!g.joined&&!g.stale&&t.jsx(k,{size:"sm",disabled:G!==null,onClick:()=>void ve("join",()=>c.joinRemoteCommunityRoom(e,s)),children:"Join channel"}),a.cacheReadable&&t.jsx(k,{variant:"ghost",size:"sm",disabled:y,onClick:()=>me(!Z),children:Z?"Hide members":"Members"}),((qe=T.standing)==null?void 0:qe.rules.text)&&t.jsx(k,{variant:"ghost",size:"sm",onClick:()=>d("rules"),children:"Rules"}),a.capabilities.post&&t.jsx(k,{variant:"ghost",size:"sm",onClick:()=>d("name"),children:"Your name"}),a.capabilities.enrollAgent&&t.jsx(k,{variant:"outline",size:"sm",disabled:G!==null,onClick:()=>void ve("stop",()=>c.haltRemoteCommunityRoom(e,s)),children:G==="stop"?"Stopping…":"Stop my agents"}),a.capabilities.post&&(g==null?void 0:g.joined)&&!o&&t.jsx(k,{variant:"ghost",size:"sm",disabled:G!==null||!fe,onClick:()=>void ve("leave",async()=>{await c.leaveRemoteCommunityRoom(e,s),i&&N.removeQueries({queryKey:B.room(i,e,s)})}),children:"Leave channel"})]}),ye&&t.jsx("p",{role:"alert",className:"text-destructive px-4 py-2 text-sm",children:ye}),y?t.jsx("p",{role:"status",className:"p-6 text-sm",children:"You no longer have access to this channel."}):t.jsxs(t.Fragment,{children:[I.status!=="live"&&t.jsx("p",{role:"status",className:"text-muted-foreground px-4 py-2 text-sm",children:I.status==="connecting"?"Connecting to the space…":"Space unavailable. Showing saved messages."}),q.isError&&t.jsx("p",{role:"alert",className:"px-4 py-2 text-sm",children:"Couldn’t load this channel."}),Z&&t.jsx(zs,{roster:b.data,failed:b.isError,canMention:fe,onMention:p=>{var D;Y.setText(`${Y.text}${Y.text&&!Y.text.endsWith(" ")?" ":""}@${p} `),(D=W.current)==null||D.focus()},community:e,roomId:s,online:I.status==="live",canEnroll:a.capabilities.enrollAgent,agentsKey:u,accessFingerprint:a.fingerprint}),K.isError&&t.jsxs("p",{role:"alert",className:"p-3 text-sm",children:["Some messages could not be loaded."," ",t.jsx(k,{variant:"ghost",size:"sm",onClick:()=>void K.refetch(),children:"Retry"})]}),K.hasNextPage&&t.jsx(k,{variant:"ghost",size:"sm",disabled:K.isFetchingNextPage,onClick:()=>void K.fetchNextPage(),children:"Load the next page of history"}),t.jsx(Ne.Timeline,{ref:se,conversationId:be.id,rows:Nt,label:n?"Space thread":"Space messages",busy:K.isFetching,resumeRow:()=>n?void 0:A??void 0,onTopRow:F,onReachedBottom:Ct,onOpenThread:r,empty:t.jsx("p",{className:"text-muted-foreground p-6 text-sm",children:K.isPending?"Loading messages…":"No messages here yet."}),renderRow:(p,D)=>{const _=_e[D.index];return _.kind==="message"?t.jsx(pt,{entry:_.entry,onThread:r,onReport:a.capabilities.post&&b.data&&!Q(_.entry.authorId)?()=>$(_.entry):void 0}):t.jsx(cs,{summary:_.summary,open:!1,onOpen:()=>r(_.rootId)})}}),t.jsx(Gs,{agentDeliveries:I.deliveries,drafts:Y.deliveries,entries:oe,threadId:n,canSend:Se,action:G,onRetryAgent:p=>void ve(`retry:${p}`,()=>c.retryRemoteCommunityDelivery(e,s,p)),onRetryDraft:Y.retry}),Y.error&&t.jsx("p",{role:"alert",className:"text-destructive px-4 py-2 text-sm",children:Y.error}),t.jsx(Ne.Composer,{inputRef:W,aboveInput:t.jsx(Ps,{conduct:T,staff:["owner","admin"].includes((z==null?void 0:z.role)??""),onReadRules:()=>d("rules")}),className:"m-3",value:Y.text,onChange:Y.setText,onSubmit:()=>Y.send(n),input:{isStreaming:!1,contextKey:be.id,canSubmit:Y.text.trim().length>0||Y.attachments.staged.length>0}})]})]}),t.jsx(qs,{conduct:T,open:we==="rules",onOpenChange:p=>d(p?"rules":null)}),t.jsx(Hs,{community:e,accessFingerprint:a.fingerprint,currentName:(z==null?void 0:z.displayName)??"",open:we==="name",onOpenChange:p=>d(p?"name":null)}),t.jsx(Qs,{entry:R,onClose:()=>$(null)})]})}function Zs({community:e,roomId:s}){var h,u;const n=xe(),r=(h=n.data)==null?void 0:h.find(N=>N.ref===e),o=Le(r==null?void 0:r.access),c=at(e,s??"",!!s&&o.capabilities.read,o.fingerprint),{dm:f}=ot(e,s??"",!!s&&o.capabilities.read,o.fingerprint),l=(r==null?void 0:r.label)??"Space",a=s?f?Vt(f):(u=c.data)==null?void 0:u.title:void 0,i=r===void 0&&n.fetchStatus==="fetching"||s!==void 0&&a===void 0&&c.fetchStatus==="fetching";return t.jsx(lt,{pending:i,children:a?`${l} · ${a}`:l})}function gt(e){var s,n,r,o;return!e||e.status==="reconnect-required"?null:((n=(s=e.access)==null?void 0:s.lastKnown)==null?void 0:n.lifecycle)==="deleted"?"deleted":((o=(r=e.access)==null?void 0:r.lastKnown)==null?void 0:o.lifecycle)==="taken_down"?"taken-down":e.seemsGoneSince?"seems-gone":null}function Qe(e,s,n){return`${e} ${e===1?s:n}`}function en(e,s){const n=[e>0?Qe(e,"message from your agents","messages from your agents"):null,s>0?Qe(s,"draft of yours","drafts of yours"):null].filter(o=>o!==null);if(n.length===0)return null;const r=n.length===1&&(e===1||s===1);return`${n.join(" and ")} ${r?"wasn’t":"weren’t"} sent.`}function tn({connection:e,onRemoved:s}){const n=gt(e),r=Xt(),[o,c]=m.useState(!1),{ownerKey:f}=Zt(),l=es(f,e.ref),{copied:a,failed:i,copy:h}=ts(),u=e.label,N=e.seemsGoneSince?new Date(e.seemsGoneSince).toLocaleDateString(void 0,{year:"numeric",month:"long",day:"numeric"}):null;function C(){r.mutate(e,{onSuccess:()=>{c(!1),rt.success(`${u} is removed from DorkOS.`),s()}})}const v=n==="deleted"||n==="taken-down",w=n==="taken-down"?"This space was taken down":n==="deleted"?"This space was deleted":"This space seems to be gone",x=n==="taken-down"?`DorkOS removed its copy here. If ${u} returns, you can connect again.`:n==="deleted"?"DorkOS removed its copy from this computer.":`Since ${N}, ${u} says it doesn’t exist. Its channels, messages and files are still here.`,O=en(v?e.undeliveredAgentMessages??0:0,l.length),A=l.length===0?null:l.length===1?"Your unsent draft is cleared too.":`Your ${l.length} unsent drafts are cleared too.`;return t.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-10 text-center text-sm","data-testid":"community-gone",children:[t.jsx(gs,{className:"text-muted-foreground/50 size-10","aria-hidden":!0}),t.jsx("p",{className:"text-foreground font-medium",children:w}),t.jsx("p",{className:"text-muted-foreground max-w-sm",children:x}),O&&t.jsx("p",{role:"status",className:"text-foreground max-w-sm","data-testid":"community-gone-unsent",children:O}),t.jsx("span",{className:"sr-only","aria-live":"polite","data-testid":"community-gone-copy-status",children:a?"Copied.":i?"Couldn’t copy to the clipboard.":""}),t.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-2",children:[l.length>0&&t.jsx(k,{variant:"outline",onClick:()=>void h(l.join(`
9
-
10
- `)),children:a?"Copied":i?"Couldn’t copy":l.length===1?"Copy your draft":"Copy your drafts"}),t.jsx(k,{variant:v?"outline":"destructive",onClick:()=>c(!0),children:v?"Remove from DorkOS":"Remove local copy"})]}),t.jsx(Ve,{open:o,onOpenChange:F=>{F||r.reset(),c(F)},children:t.jsxs(Xe,{children:[t.jsxs(Ze,{children:[t.jsx(et,{children:v?`Remove ${u} from DorkOS?`:`Remove your copy of ${u}?`}),t.jsx(tt,{asChild:!0,children:t.jsxs("div",{className:"space-y-2",children:[t.jsx("p",{children:v?`${u} leaves this app. Nothing else is stored here.`:"This deletes its channels, messages and files from this computer."}),!v&&t.jsx("p",{children:"Your agents stop answering there. If it’s still around, you can connect again."}),A&&t.jsx("p",{children:A})]})})]}),r.isError&&t.jsx("p",{role:"alert",className:"text-destructive text-sm",children:"Couldn’t remove it. Check that DorkOS is running, then try again."}),t.jsxs(st,{children:[t.jsx(nt,{disabled:r.isPending,children:"Cancel"}),t.jsx(k,{variant:"destructive",disabled:r.isPending,onClick:C,children:r.isPending?"Removing…":v?"Remove from DorkOS":"Remove local copy"})]})]})})]})}function sn({connection:e,dateFormat:s}){var c,f;const n=fs(e);if(!n)return null;const[r,...o]=ps(n,(f=(c=e.access)==null?void 0:c.lastKnown)==null?void 0:f.lifecycle,s);return t.jsxs("section",{"aria-label":"Request to take over this space",className:"border-status-warning-border bg-status-warning-bg text-status-warning-fg flex flex-wrap items-start gap-x-3 gap-y-2 border-b px-4 py-3 text-sm",children:[t.jsx(ss,{className:"mt-0.5 size-4 shrink-0","aria-hidden":!0}),t.jsxs("div",{className:"min-w-0 flex-1 basis-60 space-y-1",children:[t.jsx("p",{className:"text-foreground font-medium",children:r}),o.map(l=>t.jsx("p",{children:l},l))]}),t.jsxs(k,{variant:"outline",size:"sm",className:"shrink-0",onClick:()=>rs(hs(e)),children:["Open space",t.jsx(ns,{className:"size-3.5","aria-hidden":!0})]})]})}const nn={reactions:!1,threads:!1,runWith:!1,attachments:!1,mentions:!1,streamHealth:!1,presence:!1,turnStatus:!1,asks:!1};function rn({dm:e,localAgentId:s,access:n}){var a,i,h,u;const r=as(e.community,e.roomId,s,n),o=m.useRef(null),c=m.useRef(!0),f=(i=(a=r.data)==null?void 0:a.entries.at(-1))==null?void 0:i.id;m.useLayoutEffect(()=>{const N=o.current;N&&c.current&&(N.scrollTop=N.scrollHeight)},[f]);const l={kind:"room",id:JSON.stringify([e.community,e.roomId,"read-only"]),placeholder:"",canSend:!1,canSendReason:"This direct message is read-only.",attachments:null,send:()=>Promise.reject(new Error("This direct message is read-only."))};return t.jsx(Ne.Root,{surface:"room",capabilities:nn,target:l,children:t.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[t.jsxs("section",{className:"border-b px-4 py-2 text-sm","aria-label":"About this direct message",children:[t.jsxs("p",{children:[t.jsx("span",{className:"font-medium",children:`${e.member.displayName} with ${e.agent.displayName}`}),t.jsx("span",{className:"text-muted-foreground",children:" · Read-only"})]}),t.jsx("p",{className:"text-muted-foreground text-xs",children:`Only ${e.member.displayName} and ${e.agent.displayName} can post here.`})]}),t.jsxs("section",{ref:o,onScroll:N=>{const C=N.currentTarget;c.current=C.scrollHeight-C.scrollTop-C.clientHeight<40},className:"min-h-0 flex-1 overflow-auto py-2","aria-label":"Messages",children:[r.isError&&t.jsxs("p",{role:"alert",className:"px-4 text-sm",children:["Couldn’t load this direct message."," ",t.jsx(k,{variant:"ghost",size:"sm",onClick:()=>void r.refetch(),children:"Retry"})]}),((h=r.data)==null?void 0:h.entries.length)===0&&t.jsx("p",{className:"text-muted-foreground px-4 text-sm",children:"No messages yet."}),(u=r.data)==null?void 0:u.entries.map(N=>t.jsx(pt,{entry:N},N.id))]})]})})}function an({community:e,roomId:s,children:n}){var f;const r=(f=xe().data)==null?void 0:f.find(l=>l.ref===e),o=Le(r==null?void 0:r.access),{dm:c}=ot(e,s,o.verified&&o.capabilities.read,o.fingerprint);return c?c.readOnly&&c.localAgentId?t.jsx(rn,{dm:c,localAgentId:c.localAgentId,access:o.fingerprint}):t.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[t.jsx(on,{dm:c,accessFingerprint:o.fingerprint}),t.jsx("div",{className:"min-h-0 flex-1",children:n(c.agent.displayName)})]}):n()}function on({dm:e,accessFingerprint:s}){var c;const r=(c=it(e.community,e.roomId,!0,s).data)==null?void 0:c.members.find(f=>f.memberId===e.agent.memberId),o=e.agent.ownerDisplayName;return t.jsxs("section",{className:"border-b px-4 py-2 text-sm","aria-label":"About this direct message",children:[t.jsxs("p",{children:[t.jsx("span",{className:"font-medium",children:e.agent.displayName}),t.jsx("span",{className:"text-muted-foreground",children:` · ${o}’s agent · ${o} can read this`})]}),(r==null?void 0:r.availability)==="offline"&&t.jsx("p",{role:"status",className:"text-muted-foreground text-xs",children:`Offline. ${e.agent.displayName} won’t answer until its computer is back on.`})]})}function ln(){const{id:e,community:s}=ct({from:"/_shell/channels"}),n=is(s);return s&&!n.visible?n.isLoading?null:t.jsx(os,{...ge.channels(),search:{},replace:!0}):t.jsxs(t.Fragment,{children:[s?t.jsx(Zs,{community:s,roomId:e}):e===void 0&&t.jsx(lt,{children:"Channels"}),t.jsx(cn,{})]})}function cn(){const{id:e,thread:s,entry:n,community:r}=ct({from:"/_shell/channels"}),o=Re(),c=Cs(r?void 0:e,s,n),f=Ns(r?void 0:e),l=ls();return r&&e?t.jsx(Je,{community:r,children:t.jsx(an,{community:r,roomId:e,children:a=>t.jsx(Xs,{community:r,roomId:e,threadId:s,dmAgentName:a,onThread:i=>{o({...ge.channels(),search:{community:r,id:e,thread:i}})}})},JSON.stringify([r,e]))}):r?t.jsx(Je,{community:r,children:t.jsxs("div",{className:"text-muted-foreground flex h-full flex-col items-center justify-center gap-2 p-10 text-center text-sm",children:[t.jsx(He,{className:"text-muted-foreground/50 size-10","aria-hidden":!0}),t.jsx("p",{className:"text-foreground font-medium",children:"No channel selected"}),t.jsx("p",{className:"max-w-sm",children:"Choose a channel from this space."})]})}):c==="pending"||f==="pending"?t.jsx("div",{className:"flex h-full flex-col","aria-busy":!0,children:t.jsx(ds,{})}):c==="redirecting"||f==="redirecting"?null:e===void 0?t.jsxs("div",{className:"text-muted-foreground flex h-full flex-col items-center justify-center gap-2 p-10 text-center text-sm",children:[t.jsx(He,{className:"text-muted-foreground/50 size-10","aria-hidden":!0}),t.jsx("p",{className:"text-foreground font-medium",children:"Pick a channel or DM"}),t.jsx("p",{className:"max-w-sm",children:l?"Open one from All, at the bottom of the screen.":"Open one from the sidebar, or use + next to Channels."})]}):t.jsx(us,{roomId:e,threadId:s,entrySeq:n,threadRoute:"/channels"})}function Je({community:e,children:s}){var o;const n=Re(),r=(o=xe().data)==null?void 0:o.find(c=>c.ref===e);return r&&gt(r)?t.jsx(tn,{connection:r,onRemoved:()=>void n({...ge.channels(),search:{}})}):t.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[r&&t.jsx(sn,{connection:r}),r&&t.jsx(ys,{connection:r}),t.jsx("div",{className:"min-h-0 flex-1",children:s})]})}const Xn=ln;export{Xn as component};
@@ -1 +0,0 @@
1
- import{a1 as ht,a3 as mt,a4 as Xt,a2 as en,j as e,cw as J,cx as Z,cz as X,cA as ee,cB as te,dw as ne,dc as ge,B as b,a7 as D,d6 as gt,G as q,x as se,Z as pt,_ as K,bD as xt,C as ae,r as y,dH as tn,dj as nn,I as Pe,e as O,ct as ie,ak as Q,kK as $e,b6 as Le,z as sn,hI as an,gl as ft,h as jt,i as on,kM as rn,fr as cn,s as yt,es as ln,a0 as vt,O as le,Q as de,T as dn,U as ue,d$ as De,g9 as pe,ga as xe,gb as fe,gc as je,gd as ye,ge as ve,gf as be,gg as Ne,f6 as ze,e1 as Fe,e2 as Me,bO as un,aN as hn,kS as mn,hM as gn,dz as bt,bc as pn,dU as Nt,dV as kt,dW as Ct,dX as wt,dY as Te,c4 as Be,l as St,kI as xn,kT as fn,cM as we,cN as Se,aO as jn,cO as Ae,kU as yn,H as At,kV as vn,iq as bn,$ as Nn,g$ as kn,kW as Cn,eQ as wn,eR as Sn,eS as An,f as In,A as Rn,kX as $n,ad as Tn,ae as _n,af as En,hk as On,kY as Pn,ah as Ln,hn as Dn,kZ as zn,ho as Fn,aS as Mn,k_ as Bn,k$ as It,cD as qn,dI as Un,l0 as Wn}from"./index-8-iQ6PnT.js";import{e as Rt,j as he,k as $t,f as qe,l as Kn,m as Yn,n as Tt,c as Hn,g as _t,o as Gn,h as Vn,p as Qn,s as oe,q as Jn,i as Et}from"./access-copy-Dj09Xk4b.js";import{P as Zn}from"./page-container-Bb-_N7lw.js";import{Q as W}from"./query-error-state--8AnWSSn.js";import{s as Ue,u as Xn,a as es,b as Ot,c as ts,d as ns,e as Ze,f as ss,i as as,C as is,g as os,h as rs,j as cs,L as Pt,k as Lt,A as ls,l as ds,m as us,n as hs,o as ms,p as gs,w as ps,F as xs,q as fs,r as js,R as ys,t as vs,v as bs,x as Ns,y as ks}from"./AgentRequestCard-DQ6GYoeE.js";import{C as Cs}from"./ChatAppsOff-BmuOTq83.js";import{B as ws,u as ke}from"./use-bindings-BV6HA0MD.js";import{u as Dt,a as Ss,b as As,c as Is,d as Rs,e as $s,U as Ts}from"./use-unclaimed-chats-Db_wuzt0.js";import{a as zt}from"./use-relay-config-1mAMDNbc.js";import{u as Ft,d as _s}from"./use-adapter-catalog-BQKfRxXC.js";import{b as Es,f as Os,g as Xe,h as Ps,i as Ls,j as Ds,k as zs}from"./use-connector-management-fr1tx-GZ.js";import{b as Mt,C as Fs,O as Bt}from"./connection-copy--MA7AN04.js";import{E as Ms}from"./empty-state-kISAAp0z.js";import{S as Bs}from"./shield-check-CpUB_Ju1.js";import{C as qs}from"./card-Dj6ZfRgu.js";import{a as Us,B as Ws,t as Ks,c as Ys}from"./BindingDialog-DVyxVXZM.js";import{u as Hs}from"./use-delete-binding-CnziYpXo.js";import{u as We,A as qt}from"./AdapterSetupWizard-I03EluU5.js";import{s as Gs}from"./session-strategy-labels-C7Wduch3.js";import{M as Vs}from"./message-square-off-B8N6YF9R.js";import{M as Qs}from"./more-details-CadxnGyH.js";import{C as Js,a as Zs,b as Xs,c as ea,e as ta}from"./command-BAOEURY7.js";import"./relay-trace-schemas-fScydQ3A.js";import"./KeyEntry-DJnzW3Mu.js";import"./use-update-config-DwtH_H9Z.js";import"./inline-code-D9bLKHjY.js";import"./form-Bjhk9zOn.js";import"./trust-posture-2MR0ap9o.js";import"./markdown-content-D0FpU2cz.js";function na(){const t=ht(),n=mt();return Xt({mutationFn:({id:s,agentId:a})=>t.moveBinding(s,a),meta:{errorLabel:"Couldn’t move the chat"},onSuccess:()=>{n.invalidateQueries({queryKey:[...ws]})}})}function Ut(t){const n=ht();return en({queryKey:["relay","adapters",t,"events"],queryFn:()=>n.getAdapterEvents(t),enabled:!!t,refetchInterval:5e3})}function _e(t,n){var c;const s=t;if(!s||s.code!=="CHAT_ALREADY_BOUND")return null;const a=(c=s.body)==null?void 0:c.conflict,i=typeof(a==null?void 0:a.bindingId)=="string"?a.bindingId:null;if(!i)return null;const r=typeof(a==null?void 0:a.agentId)=="string"?a.agentId:"another agent";return{bindingId:i,currentAgentName:r,nextAgentId:n.id,nextAgentName:n.name}}function Wt({conflict:t,onClose:n,onMoved:s}){return e.jsx(J,{open:t!==null,onOpenChange:a=>!a&&n(),children:e.jsx(Z,{className:"sm:max-w-md",children:t&&e.jsx(sa,{conflict:t,onClose:n,onMoved:s})})})}function sa({conflict:t,onClose:n,onMoved:s}){const a=na();return e.jsxs(e.Fragment,{children:[e.jsxs(X,{children:[e.jsx(ee,{children:"This chat already reaches someone"}),e.jsx(te,{children:"A chat goes to one agent at a time."})]}),e.jsxs(ne,{className:"pb-2",children:[e.jsxs("p",{className:"text-sm leading-relaxed",children:["This chat reaches ",e.jsx("span",{className:"font-medium",children:t.currentAgentName}),". Move it to ",e.jsx("span",{className:"font-medium",children:t.nextAgentName}),"?"]}),e.jsxs("p",{className:"text-muted-foreground mt-2 text-xs leading-relaxed",children:["Past messages stay with ",t.currentAgentName,". ",t.nextAgentName," starts fresh."]})]}),e.jsxs(ge,{children:[e.jsx(b,{variant:"outline",onClick:n,disabled:a.isPending,children:"Leave it"}),e.jsx(b,{disabled:a.isPending,onClick:()=>a.mutate({id:t.bindingId,agentId:t.nextAgentId},{onSuccess:()=>{D.success(`${t.nextAgentName} answers this chat now.`),n(),s==null||s()}}),children:a.isPending?"Moving…":`Move it to ${t.nextAgentName}`})]})]})}function Ce(t,n){var s;return((s=n.get(t))==null?void 0:s.displayName)??gt(t)}function aa(t){return t===0?"No agents yet":t===1?"1 agent":`${t} agents`}function ia(t){return t.length<=1?t[0]??"":t.length===2?`${t[0]} and ${t[1]}`:`${t[0]} and ${t.length-1} more`}function oa(t){if(!(t.label.toLowerCase()!==t.toolkit.toLowerCase()))return{account:t.identityHint??t.label,identity:null};const s=t.identityHint&&t.identityHint!==t.label?t.identityHint:null;return{account:t.label,identity:s}}function Kt(t,n){const s=Ue(n.get(t));return s===void 0?{}:{logo:s}}const ra={ready:"ready",needs_you:"broken",unavailable:"broken",finishing:"busy",paused:"off",gone:"off"},ca={sign_in_again:"sign-in-again",resume:"resume",review_access:"review",fix_key:"fix-key",connect_new:"connect-again"};function la(t,n){var o;const{readiness:s}=t,a=oa(t),i=ra[s.state],r=(o=s.fix)==null?void 0:o.action,c=s.state==="gone"||!r?null:ca[r]??null;return{id:t.connectionId,kind:"account",name:Ce(t.toolkit,n),iconKey:t.toolkit,toolkit:t.toolkit,...Kt(t.toolkit,n),...a,waiting:0,tone:i,action:c,detail:s.state==="ready"?`${a.account} · ${t.everyAgent?"Every agent":aa(t.agentCount)}`:i==="broken"?s.copy.owner:`${a.account} · ${s.copy.owner}`}}function da(t,n){if(n.label)return n.label;const s=n.status.displayName;return s&&s!==t.manifest.displayName?s:null}function ua(t,n,s){const a=t.manifest,i=da(t,n),r={id:n.id,kind:"chat",name:a.displayName,iconKey:a.iconId??a.type,account:i,identity:null,waiting:s.waitingByChatApp[n.id]??0,deprecated:a.deprecated===!0},c=m=>i?`${i} · ${m}`:m;if(!n.enabled)return{...r,tone:"off",action:"resume",detail:"Paused · no messages in or out"};if(n.status.state==="error"||n.status.state==="disconnected")return{...r,tone:"broken",action:"fix",detail:"Stopped working. Messages aren’t getting through."};if(n.status.state!=="connected")return{...r,tone:"busy",action:null,detail:c("Connecting…")};const o=[...new Set(s.bindings.filter(m=>m.adapterId===n.id).map(m=>s.agentNames[m.agentId]??m.agentId))];if(o.length===0)return{...r,tone:"attention",action:null,detail:c("No agent answers yet")};const u=o.length===1?"answers":"answer";return{...r,tone:"ready",action:null,detail:c(`${ia(o)} ${u}`)}}const et={broken:1,attention:2,busy:3,ready:3,off:4};function ha(t){return t.manifest.category==="internal"}function ma(t){const n=t.connections.map(c=>la(c,t.services));for(const c of t.chatApps)if(!ha(c))for(const o of c.instances)n.push(ua(c,o,t));const s=n.map((c,o)=>({row:c,index:o})).sort((c,o)=>et[c.row.tone]-et[o.row.tone]||c.row.name.localeCompare(o.row.name)||c.index-o.index).map(({row:c})=>c),a=t.pendingSignIn;if(!a)return s;const i=t.services.get(a.toolkit),r=(i==null?void 0:i.displayName)??gt(a.toolkit);return[{id:a.flowId,kind:"connecting",name:r,iconKey:a.toolkit,...Kt(a.toolkit,t.services),account:null,identity:null,detail:`Finish signing in on ${(i==null?void 0:i.signInName)??r}…`,tone:"busy",action:"cancel",waiting:0},...s]}function Ke(t){const n=t.intents.find(s=>s.kind==="messages");return{account:t.intents.some(s=>s.kind==="account"),chatType:(n==null?void 0:n.kind)==="messages"?n.relayAdapterType:null}}function ga(t,n){return{accounts:new Set(t.filter(s=>s.lifecycle!=="disconnected").map(s=>s.toolkit)),chatApps:new Set(n.filter(s=>s.instances.length>0).map(s=>s.manifest.type))}}function Yt(t,n){const s=Ke(t);return{account:s.account&&!n.accounts.has(t.serviceSlug),chatType:s.chatType&&!n.chatApps.has(s.chatType)?s.chatType:null}}const Ht={popular:"Popular",email:"Email",calendar:"Calendar",chat:"Chat",docs:"Docs",files:"Files",code:"Code",tasks:"Tasks",sales:"Sales",all:"All"};function pa(t){const n=new Set(t.map(a=>a.category));return["popular",...Object.keys(Ht).filter(a=>a!=="popular"&&a!=="all"&&n.has(a)),"all"]}function xa(t,n){const s=t.filter(a=>a.category!=="developer");return n==="all"?s:n==="popular"?s.filter(a=>a.popular):s.filter(a=>a.category===n)}function fa(t,n){const s=n.trim().toLowerCase();return s===""?!0:`${t.name} ${t.detail}`.toLowerCase().includes(s)}const tt={"sign-in-again":"Sign in again",resume:"Resume",cancel:"Cancel",review:"Review",fix:"Fix","fix-key":"Fix the key","connect-again":"Connect again"};function ja(){return e.jsx(K,{size:"xs",variant:"secondary",className:"shrink-0",children:"Chat"})}function Gt({name:t,iconKey:n,logo:s,detail:a,chat:i,deprecated:r=!1,wrapDetail:c=!1,detailClassName:o}){return e.jsxs(e.Fragment,{children:[e.jsx(pt,{iconKey:n,displayName:t,logo:s}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"truncate text-sm font-medium",children:t}),i&&e.jsx(ja,{}),r&&e.jsx(K,{size:"xs",variant:"outline",tone:"warning",className:"shrink-0",children:"Deprecated"})]}),e.jsx("span",{className:q("text-muted-foreground block text-xs",c?"line-clamp-2":"truncate",o),children:a})]})]})}function ya({row:t,onOpen:n,onAction:s,actionPending:a=!1}){const i=t.tone==="off";return e.jsxs("li",{"data-testid":`app-row-${t.id}`,"data-tone":t.tone,className:q("group/row flex items-center rounded-lg transition-colors",t.tone==="broken"?"bg-status-warning-bg/70 hover:bg-status-warning-bg":"hover:bg-muted/50"),children:[e.jsxs("button",{type:"button",onClick:()=>n(t),className:"focus-ring flex min-h-14 min-w-0 flex-1 items-center gap-3 rounded-lg px-3 py-2 text-left",children:[e.jsx("span",{className:q("flex min-w-0 flex-1 items-center gap-3",i&&"opacity-55"),children:e.jsx(Gt,{name:t.name,iconKey:t.iconKey,logo:t.logo,detail:t.detail,chat:t.kind==="chat",deprecated:t.deprecated,wrapDetail:t.tone==="broken",detailClassName:t.tone==="broken"?"text-status-warning-fg":void 0})}),!t.action&&e.jsx(va,{row:t})]}),t.action&&e.jsx("div",{className:"flex shrink-0 items-center pr-3",children:e.jsxs(b,{size:"sm",variant:t.tone==="broken"?"default":"outline",disabled:a,onClick:()=>s(t),"aria-label":`${tt[t.action]}: ${t.name}`,children:[a&&e.jsx(se,{size:"xs"}),tt[t.action]]})})]})}function va({row:t}){return t.waiting>0?e.jsxs(K,{shape:"pill",tone:"warning",variant:"outline",className:"shrink-0",children:[t.waiting," waiting"]}):t.tone==="busy"?e.jsx(se,{size:"xs",className:"text-muted-foreground shrink-0"}):t.tone==="ready"?e.jsxs("span",{className:"flex shrink-0 items-center",children:[e.jsx("span",{className:q("size-2 rounded-full",xt.success),"aria-hidden":!0}),e.jsx("span",{className:"sr-only",children:"Connected"})]}):e.jsx(ae,{className:"text-muted-foreground size-4 shrink-0 opacity-0 transition-opacity group-focus-within/row:opacity-100 group-hover/row:opacity-100","aria-hidden":!0})}function ba({service:t,chat:n,actionLabel:s,onConnect:a,unavailableLabel:i}){const r=t.description??Na(t),c=e.jsx(Gt,{name:t.displayName,iconKey:t.iconKey,logo:Ue(t),detail:r,chat:n,wrapDetail:!0});return a?e.jsx("li",{"data-testid":`catalog-app-${t.serviceSlug}`,children:e.jsxs("button",{type:"button",onClick:()=>a(t),"aria-label":`${s} ${t.displayName}`,className:"group/row hover:bg-muted/50 focus-ring flex min-h-14 w-full items-center gap-3 rounded-lg px-3 py-2 text-left transition-colors",children:[c,e.jsx("span",{"aria-hidden":!0,className:"border-border bg-background group-hover/row:bg-muted shrink-0 rounded-md border px-3 py-1.5 text-xs font-medium shadow-xs transition-colors",children:s})]})}):e.jsxs("li",{"data-testid":`catalog-app-${t.serviceSlug}`,className:"flex min-h-14 items-center gap-3 px-3 py-2",children:[e.jsx("span",{className:"flex min-w-0 flex-1 items-center gap-3 opacity-55",children:c}),e.jsx("span",{className:"text-muted-foreground shrink-0 text-xs",children:i})]})}function Na(t){const n=t.intents.some(a=>a.kind==="messages"),s=t.intents.some(a=>a.kind==="account");return n&&s?`Talk to your agents in ${t.displayName}, or let them use it.`:n?`Talk to your agents in ${t.displayName}.`:`Let agents use your ${t.displayName} account.`}function ka({query:t,onQueryChange:n,data:s,onOpenRow:a,onRowAction:i,pendingRowId:r=null,onConnect:c}){var T,Y,S,$;const[o,u]=y.useState("popular"),m=t.trim()!=="",{catalog:d,relay:p}=s,l=p.enabled,h=s.available.filter(w=>w.category!=="developer"),f=s.available.filter(w=>w.category==="developer"),j=pa(h),k=j.includes(o)?o:"popular",N=m?h:xa(h,k),A=((T=d.data)==null?void 0:T.pages.flatMap(w=>w.warnings))??[],x=($=(S=(Y=d.data)==null?void 0:Y.pages[0])==null?void 0:S.appConnections)==null?void 0:$.newApps,g=m&&!d.isPending&&s.yours.length===0&&s.available.length===0,C=(w,E)=>{const z=Ke(w),I=z.chatType!==null&&!z.account&&!l;return e.jsx(ba,{service:w,chat:z.chatType!==null,actionLabel:E,onConnect:I?void 0:c,unavailableLabel:"Turned off"},w.serviceSlug)};return e.jsxs("div",{className:"space-y-8","data-testid":tn.relayIntegrations,children:[e.jsxs("div",{className:"relative",children:[e.jsx(nn,{className:"text-muted-foreground pointer-events-none absolute top-1/2 left-3 size-4 -translate-y-1/2","aria-hidden":!0}),e.jsx(Pe,{type:"search",value:t,onChange:w=>n(w.target.value),className:"pl-9","aria-label":"Search apps",placeholder:"Search apps","data-testid":"app-search"})]}),s.yoursLoading?e.jsxs("div",{className:"space-y-2","aria-label":"Loading your apps",children:[e.jsx(O,{className:"h-14 rounded-lg"}),e.jsx(O,{className:"h-14 rounded-lg"})]}):s.yoursError?e.jsx(W,{title:"Couldn’t load your apps",description:"Nothing changed. Try again.",onRetry:s.retryYours}):s.yours.length>0&&e.jsxs("section",{"aria-labelledby":"connections-yours",className:"space-y-2",children:[e.jsx("h2",{id:"connections-yours",className:"text-sm font-semibold",children:"Yours"}),e.jsx("ul",{className:"-mx-3 space-y-0.5","data-testid":"yours-list",children:s.yours.map(w=>e.jsx(ya,{row:w,onOpen:a,onAction:i,actionPending:r===w.id},w.id))})]}),g?e.jsxs("div",{className:"bg-muted/40 rounded-xl p-6 text-center",children:[e.jsxs("p",{className:"text-sm font-medium",children:["No app matches “",t.trim(),"”"]}),e.jsx("p",{className:"text-muted-foreground mt-1 text-xs",children:wa(x)})]}):e.jsxs("section",{"aria-labelledby":"connections-all-apps",className:"space-y-3",children:[e.jsx("h2",{id:"connections-all-apps",className:"text-sm font-semibold",children:m?"Apps":"All apps"}),!m&&j.length>2&&e.jsx("div",{role:"group","aria-label":"Show apps by kind",className:"-mx-4 flex scrollbar-none gap-1.5 overflow-x-auto px-4 sm:mx-0 sm:flex-wrap sm:px-0",children:j.map(w=>e.jsx("button",{type:"button","aria-pressed":w===k,onClick:()=>u(w),className:q("focus-ring shrink-0 rounded-full px-3 py-1 text-xs font-medium transition-colors",w===k?"bg-foreground text-background":"bg-muted/60 text-muted-foreground hover:bg-muted hover:text-foreground"),children:Ht[w]},w))}),d.isPending?e.jsxs("div",{className:"space-y-2","aria-label":"Loading apps",children:[e.jsx(O,{className:"h-14 rounded-lg"}),e.jsx(O,{className:"h-14 rounded-lg"}),e.jsx(O,{className:"h-14 rounded-lg"})]}):d.isError?e.jsx(W,{title:"Couldn’t load the app list",description:"Your apps are unchanged. Try again.",onRetry:()=>void d.refetch(),isRetrying:d.isFetching}):e.jsxs(e.Fragment,{children:[N.length>0&&e.jsx("ul",{className:"-mx-3 space-y-0.5","data-testid":"all-apps-list",children:N.map(w=>C(w,"Connect"))}),(m||k==="all")&&d.hasNextPage&&e.jsx(b,{variant:"ghost",size:"sm",onClick:()=>void d.fetchNextPage(),disabled:d.isFetchingNextPage,children:d.isFetchingNextPage?"Loading…":"Show more apps"})]}),e.jsx(Ca,{data:s}),A.map(w=>e.jsx("p",{className:"text-muted-foreground text-xs",children:w.message},`${w.code}-${w.message}`))]}),f.length>0&&!d.isPending&&e.jsxs("section",{"aria-labelledby":"connections-developers",className:"space-y-2",children:[e.jsx("h2",{id:"connections-developers",className:"text-muted-foreground text-xs font-semibold",children:"For developers"}),e.jsx("ul",{className:"-mx-3 space-y-0.5",children:f.map(w=>C(w,"Set up"))})]})]})}function Ca({data:t}){const{relay:n}=t;return t.chatAppsError?e.jsxs("p",{className:"text-muted-foreground flex flex-wrap items-center gap-x-2 text-xs",children:["Couldn’t load your chat apps.",e.jsx(b,{variant:"link",size:"xs",className:"h-auto p-0",onClick:t.retryChatApps,children:"Try again"})]}):n.isError?e.jsxs("p",{className:"text-muted-foreground flex flex-wrap items-center gap-x-2 text-xs",children:["Couldn’t check chat apps.",e.jsx(b,{variant:"link",size:"xs",className:"h-auto p-0",onClick:n.retry,disabled:n.isRetrying,children:n.isRetrying?"Checking…":"Try again"})]}):e.jsx(Cs,{relay:n,variant:"line"})}function wa(t){if((t==null?void 0:t.status)!=="setup_needed")return"Try another name.";switch(t.reason){case"nothing_set_up":return"Only popular apps show until you connect one. Then search finds every app.";case"own_key_unavailable":return"Only popular apps show while your saved key isn’t working.";case"dorkos_account_unavailable":return"Only popular apps show while your DorkOS account can’t connect apps.";case"dorkos_account_unlinked":return"Only popular apps show while your DorkOS account isn’t linked."}}function Sa(t,n){const s=t.trim()!=="",a=Rt(),i=he(""),r=he(t,s),c=zt(),o=Ft(c.enabled),{data:u}=ke(),{data:m}=Dt("pending",c.enabled),{data:d}=ie(),p=y.useMemo(()=>{var x;return new Map((((x=i.data)==null?void 0:x.pages.flatMap(g=>g.services))??[]).map(g=>[g.serviceSlug,g]))},[i.data]),l=y.useMemo(()=>Object.fromEntries(((d==null?void 0:d.agents)??[]).map(x=>[x.id,Q(x)])),[d]),h=y.useMemo(()=>c.enabled?o.data??[]:[],[c.enabled,o.data]),f=y.useMemo(()=>{var x;return((x=a.data)==null?void 0:x.connections)??[]},[a.data]),j=y.useMemo(()=>{const x={};for(const g of m??[])x[g.adapterId]=(x[g.adapterId]??0)+1;return ma({connections:f,chatApps:h,bindings:u??[],waitingByChatApp:x,agentNames:l,services:p,pendingSignIn:n})},[f,h,u,m,l,p,n]),k=s?r:i,N=y.useMemo(()=>ga(f,h),[f,h]),A=y.useMemo(()=>{var x;return(((x=k.data)==null?void 0:x.pages.flatMap(g=>g.services))??[]).filter(g=>{const C=Yt(g,N);return C.account||C.chatType!==null})},[k.data,N]);return{yours:j.filter(x=>fa(x,t)),allYours:j,chatApps:h,owned:N,available:A,services:p,agentNames:l,yoursLoading:a.isPending||c.isLoading||c.enabled&&o.isPending,yoursError:a.isError,yoursRefreshing:a.isFetching,retryYours:()=>void a.refetch(),catalog:k,relay:c,chatAppsError:c.enabled&&o.isError,retryChatApps:()=>void o.refetch()}}function Vt(t){switch(t&&typeof t=="object"&&"code"in t?t.code:void 0){case"connection_cleanup_pending":return"DorkOS is still removing this app’s earlier access. Try again in a few minutes.";case"connection_not_disconnected":return"Disconnect this app before removing it.";case"connection_not_found":return"This app is no longer connected. Pick it again from the list.";case"provider_not_found":case"authentication_unavailable":return"Sign-in isn’t available for this app. Check Settings › Connections, then try again.";case"idempotency_conflict":return"This sign-in was already used. Start again.";default:return"Couldn’t confirm that change. Check the app before trying again."}}const Aa={gmail:["Summarise today’s Gmail inbox","Which of my Gmail emails need a reply?"],outlook:["Summarise today’s Outlook inbox","Which of my Outlook emails need a reply?"],googlecalendar:["What’s on my Google Calendar today?","Find a free hour on my Google Calendar this week"],slack:["Summarise what I missed in Slack today","Which Slack messages mention me?"],notion:["What changed in my Notion this week?","Summarise my most recent Notion page"],googledocs:["Summarise my most recent Google Doc"],googlesheets:["What’s in my most recent Google Sheet?"],airtable:["List my Airtable bases and what each one tracks"],googledrive:["Which Google Drive files did I change this week?"],dropbox:["Which Dropbox files did I add this week?"],github:["Which GitHub pull requests need my review?","Summarise my open GitHub issues"],linear:["Which Linear issues are assigned to me?","What changed in my Linear issues today?"],jira:["Which Jira issues are assigned to me?"],asana:["Which Asana tasks are due this week?"],todoist:["What’s on my Todoist list today?"],hubspot:["Which HubSpot deals changed this week?"]};function Ia(t){return Aa[t]??[]}const Ra={gmail:"When a new email arrives…",outlook:"When a new email arrives…",googlecalendar:"When an event changes…",slack:"When a new message arrives…",github:"When something changes on GitHub…",linear:"When an issue changes…",jira:"When an issue changes…"};function $a(t,n){return Ra[t]??`When something new happens in ${n}…`}function Ta(t,n){if(t.agentId&&n[t.agentId])return n[t.agentId];switch(t.actorKind){case"operator":return"You";case"program":return"A program";case"event":return"A notification";default:return"An agent"}}function _a(t,n,s){const a=`${Ta(t,s)} · ${$e(t.operationSlug,n)}`;return t.outcome===void 0?t.completedAt?a:`${a} (in progress)`:t.outcome==="success"?a:t.outcome==="outcome_unknown"?`${a} (result unknown)`:`${a} (didn’t finish)`}function Ea(t,n=new Date){const s=new Date(t);if(s.getTime()<=n.getTime())return"Trying again now.";const a=s.toLocaleTimeString([],{hour:"numeric",minute:"2-digit"});return s.toDateString()===n.toDateString()?`Trying again at ${a}.`:`Trying again ${s.toLocaleDateString([],{weekday:"long"})} at ${a}.`}function Oa(t){const n=t.replaceAll(/([a-z0-9])([A-Z])/gu,"$1 $2").replaceAll(/[_-]+/gu," ").trim().toLowerCase();return n?`${n.charAt(0).toUpperCase()}${n.slice(1)}`:t}function Qt(t){return typeof t=="boolean"?t?"yes":"no":typeof t=="string"||typeof t=="number"?String(t):Array.isArray(t)&&t.every(n=>typeof n!="object"||n===null)?t.map(n=>Qt(n)).join(", "):"a custom value"}function Pa(t,n=null){const s=Object.entries(t).filter(([,a])=>a!==""&&a!==void 0&&a!==null).map(([a,i])=>{var c;return`${((c=n==null?void 0:n.find(o=>o.name===a))==null?void 0:c.label)??Oa(a)} is ${Qt(i)}`});return s.length>0?`Only when ${s.join(" and ")}`:null}function Jt(t,n,s){const a=u=>({text:u,tone:"plain",checkInChat:!1}),i=(u,m=!1)=>({text:u,tone:"problem",checkInChat:m});switch(t.state){case"pending":return a("Setting up. DorkOS keeps trying on its own.");case"unavailable":return i("Paused because this account can’t be used. Fix it above to restart.");case"revoked":return i("Stopped for good. Remove it and set it up again.")}const r=t.lastDelivery;if(!r)return a(s);const c=Le(r.receivedAt);switch(r.outcome){case"delivered":return a(`Last one delivered · ${c}`);case"sending":return a(`Newest one on its way · ${c}`);case"retrying":return a(`Newest one hasn’t reached ${n} yet. DorkOS is trying again.`)}const o=t.destination.kind==="agent";switch(r.problem){case"unknown_outcome":return i(o?`DorkOS can’t tell if ${n} got the newest one (${c}). Open the chat to check.`:`DorkOS can’t tell if the newest one reached ${n} (${c}). Check there.`,o);case"refused":return i(`${n} turned away the newest one (${c}). Check this agent can still post there.`);case"changed":return i(`Newest one (${c}) held back because this notification changed. Nothing to do.`);case"cancelled":return i(`Newest one (${c}) cancelled before ${n} read it. Nothing to do.`);case"expired":return i(`Newest one (${c}) expired and wasn’t sent. If it repeats, remove it and add it again.`);case"unreachable":case null:return i(`Newest one (${c}) didn’t reach ${n}. If it repeats, remove it and add it again.`)}}function La(t){const n=t.filter(s=>Jt(s,"","").tone==="problem").length;if(n!==0)return n===1?"1 notification needs a look":`${n} notifications need a look`}function Da(t,n){const s=t.find(i=>i.id===n);return s?t.some(i=>i.id!==s.id&&i.displayName===s.displayName)&&s.handle?`${s.displayName} (@${s.handle})`:s.displayName:"an agent that’s no longer here"}function za(t){const n=t==null?void 0:t.code,s=t==null?void 0:t.status;return n==="invalid_filter"?"Check the filter values, then try again.":n==="destination_unavailable"?"That place can’t take notifications now. Pick another.":s===409?"Something changed while you were choosing. Check your choices, then try again.":"Couldn’t finish setting this up. Try again."}function Fa({subscription:t,agents:n,definition:s,channelLabel:a,removing:i,onRemove:r}){var N,A,x;const c=jt(),o=on(t.agentId,{enabled:t.destination.kind==="room"}),u=Da(n,t.agentId),m=(N=o.data)==null?void 0:N.rooms.find(g=>g.id===t.destination.id);let d=u,p=`Goes to ${u}, all in one chat`;t.destination.kind==="room"?(d=m?m.slug?`#${m.slug}`:m.name:"a room this agent left",p=`Goes to ${d}, for ${u}`):t.destination.kind==="channel"&&(d=a??"a chat that’s no longer set up",p=`Goes to ${d}, for ${u}`);const l=Pa(t.filter,s?rn(s.filterSchema):null),h=Jt(t,d,rs(t)),f=(x=(A=n.find(g=>g.id===t.agentId))==null?void 0:A.agent)==null?void 0:x.projectPath,j=t.chatSessionId,k=l?`${p}. ${l}`:p;return e.jsxs("li",{className:"bg-muted/40 flex min-h-11 items-start justify-between gap-2 rounded-lg px-3 py-2","data-state":t.state,children:[e.jsxs("div",{className:"min-w-0 space-y-0.5",children:[e.jsx("p",{className:"text-sm font-medium break-words",children:t.displayName}),e.jsx("p",{className:"text-muted-foreground text-xs break-words",children:p}),l&&e.jsx("p",{className:"text-muted-foreground text-xs break-words",children:l}),e.jsx("p",{className:q("text-xs break-words",h.tone==="problem"?"text-destructive":"text-muted-foreground"),"data-testid":"notification-status",children:h.text})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[j&&c&&e.jsxs(b,{type:"button",size:"sm",variant:h.checkInChat?"secondary":"ghost",className:"gap-1.5","aria-label":`Open the chat for ${t.displayName}: ${k}`,onClick:()=>void c(yt({session:j,...f&&{dir:f}})),children:[e.jsx(cn,{className:"size-3.5","aria-hidden":!0}),e.jsx("span",{className:"max-sm:sr-only",children:"Open chat"})]}),e.jsx(b,{type:"button",size:"icon-sm",variant:"ghost","aria-label":`Remove ${t.displayName}: ${k}`,"aria-busy":i,disabled:i,onClick:r,children:i?e.jsx(se,{size:"sm"}):e.jsx(ln,{className:"size-4"})})]})]})}function Ma({connectionId:t}){return e.jsx(Ba,{connectionId:t},t)}function Ba({connectionId:t}){var w,E,z,U;const n=Xn(t),s=n.data!==void 0&&n.data.setupMode!=="unavailable",a=es(t,s),i=Ot(t),r=sn(),c=ke(),o=ts(),u=ns(),[m,d]=y.useState(()=>Ze()),[p,l]=y.useState(!1),[h,f]=y.useState(()=>new Set),j=I=>{f(L=>new Set(L).add(I)),u.mutate({connectionId:t,subscriptionId:I},{onSettled:()=>f(L=>{const P=new Set(L);return P.delete(I),P})})},k=y.useRef(null),N=((w=a.data)==null?void 0:w.pages.flatMap(I=>I.definitions))??[],A=((E=i.data)==null?void 0:E.pages.flatMap(I=>I.subscriptions))??[],x=(((z=r.data)==null?void 0:z.members)??[]).filter(I=>I.kind==="agent"),g=ss({connectionId:t,definitions:N,draft:m}),C=n.data?as(n.data):!1,T=!!(g&&C),Y=()=>{k.current=null,o.reset()},S=I=>{d(I),Y()},$=()=>{if(!g)return;const I={definitionId:g.definitionId,filter:g.filter,agentId:g.agentId,destination:g.destination,manageExistingTrigger:p},L=JSON.stringify({connectionId:t,decision:I}),P=k.current,F=(P==null?void 0:P.signature)===L?P.requestId:crypto.randomUUID();k.current={signature:L,requestId:F},o.mutate({connectionId:t,input:{...I,requestId:F}},{onSuccess:()=>{k.current=null,d(Ze()),l(!1)}})};return e.jsxs("section",{"aria-labelledby":"connection-notifications",className:"space-y-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("h3",{id:"connection-notifications",className:"flex items-center gap-2 text-sm font-semibold",children:[e.jsx(an,{className:"size-4","aria-hidden":"true"}),"Tell an agent"]}),e.jsx("p",{className:"text-muted-foreground text-xs",children:"Send new activity to an agent, a room or a chat app."})]}),n.isPending?e.jsx(O,{className:"h-20 rounded-lg","aria-label":"Loading delivery setup"}):n.isError?e.jsx(W,{title:"Couldn’t check notifications for this account",description:"Try again before adding one.",onRetry:()=>void n.refetch(),isRetrying:n.isFetching}):n.data?e.jsx(is,{connectionId:t,status:n.data}):null,i.isPending?e.jsx(O,{className:"h-20 rounded-lg","aria-label":"Loading notifications"}):i.isError?e.jsx(W,{title:"Couldn’t load notifications",description:"Try again. Nothing was changed.",onRetry:()=>void i.refetch(),isRetrying:i.isFetching}):A.length===0?s&&e.jsx("p",{className:"bg-muted/40 rounded-lg p-3 text-sm",children:"No notifications set up."}):e.jsxs("div",{className:"space-y-2","data-testid":"connection-notification-list",children:[e.jsx("ul",{className:"space-y-1.5",children:A.map(I=>{var P;const L=(P=c.data)==null?void 0:P.find(F=>F.id===I.destination.id);return e.jsx(Fa,{subscription:I,agents:x,definition:N.find(F=>F.id===I.definitionId),channelLabel:L?L.label||"a chat app":void 0,removing:h.has(I.id),onRemove:()=>j(I.id)},I.id)})}),i.hasNextPage&&e.jsx(b,{type:"button",size:"sm",variant:"ghost",disabled:i.isFetchingNextPage,onClick:()=>void i.fetchNextPage(),children:i.isFetchingNextPage?"Loading…":"Load more notifications"})]}),o.data&&!A.some(I=>I.id===o.data.id)&&e.jsx("p",{className:"bg-muted/40 rounded-lg p-3 text-sm",role:"status",children:o.data.state==="pending"?`${o.data.displayName} is being set up. DorkOS keeps trying.`:`${o.data.displayName} is on.`}),u.isError&&e.jsx("p",{role:"alert",className:"border-destructive/30 bg-destructive/10 text-foreground rounded-md border p-3 text-sm",children:"Couldn’t confirm the removal. Check the list."}),s&&e.jsxs("div",{className:"space-y-3 rounded-lg border p-3","data-testid":"notification-setup",children:[e.jsx("p",{className:"text-sm font-medium",children:"Add a notification"}),a.isPending?e.jsx(O,{className:"h-20 rounded-md","aria-label":"Loading available notifications"}):a.isError?e.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 text-sm",children:[e.jsx("p",{className:"text-muted-foreground",children:"Notifications aren’t available right now."}),e.jsx(b,{type:"button",variant:"link",size:"xs",className:"h-auto p-0",disabled:a.isFetching,onClick:()=>void a.refetch(),children:a.isFetching?"Checking…":"Check again"})]}):N.length===0?e.jsx("p",{className:"text-muted-foreground text-sm",children:"This app offers no notifications yet."}):r.isPending?e.jsx(O,{className:"h-20 rounded-md","aria-label":"Loading agents"}):r.isError?e.jsx(W,{title:"Couldn’t load agents",description:"Try again before choosing who gets this.",onRetry:()=>void r.refetch(),isRetrying:r.isFetching}):x.length===0?e.jsx("p",{className:"text-muted-foreground text-sm",children:"Notifications go to an agent. Add one first."}):e.jsxs(e.Fragment,{children:[e.jsx(os,{idPrefix:"notification",definitions:N,draft:m,onChange:S,agents:x,sourceStatus:n.data}),((U=n.data)==null?void 0:U.setupMode)==="byo_webhook"&&e.jsxs("div",{className:"flex min-h-11 items-center gap-2",children:[e.jsx(ft,{id:"notification-manage-existing",checked:p,onCheckedChange:I=>{l(I===!0),Y()}}),e.jsx("label",{htmlFor:"notification-manage-existing",className:"text-sm",children:"Take over a matching one already in Composio"})]}),o.isError&&e.jsx("p",{role:"alert",className:"text-destructive text-sm",children:za(o.error)}),e.jsx(b,{type:"button",size:"sm",disabled:!T||o.isPending,onClick:$,children:o.isPending?"Saving…":"Set up notification"})]}),a.hasNextPage&&e.jsx(b,{type:"button",size:"sm",variant:"ghost",disabled:a.isFetchingNextPage,onClick:()=>void a.fetchNextPage(),children:a.isFetchingNextPage?"Loading…":"Load more activity"})]})]})}function me({title:t,description:n,action:s,children:a,testId:i}){const r=`panel-section-${t.toLowerCase().replaceAll(/\s+/gu,"-")}`;return e.jsxs("section",{"aria-labelledby":r,className:"space-y-2.5","data-testid":i,children:[e.jsxs("div",{className:"flex items-baseline justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("h3",{id:r,className:"text-sm font-semibold",children:t}),n&&e.jsx("p",{className:"text-muted-foreground text-xs",children:n})]}),s]}),a]})}function Ee({message:t,detail:n,action:s,onAction:a,pending:i=!1,secondary:r,technicalDetail:c}){return e.jsxs("div",{role:"status","data-testid":"app-panel-fix",className:"bg-status-warning-bg flex flex-col gap-3 rounded-xl p-3.5",children:[e.jsxs("p",{className:"text-status-warning-fg flex items-start gap-2 text-sm",children:[e.jsx(vt,{className:"mt-0.5 size-4 shrink-0","aria-hidden":!0}),e.jsxs("span",{children:[t,n&&e.jsx("span",{className:"mt-1 block",children:n})]})]}),(s&&a||r)&&e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s&&a&&e.jsxs(b,{size:"sm",onClick:a,disabled:i,className:"h-auto min-h-8 max-w-full whitespace-normal",children:[i&&e.jsx(se,{size:"xs"}),s]}),r]}),c&&e.jsxs(le,{children:[e.jsxs(de,{className:"group/details text-status-warning-fg/80 hover:text-status-warning-fg focus-ring flex items-center gap-1 rounded text-xs",children:[e.jsx(dn,{className:"size-3 -rotate-90 transition-transform group-data-[state=open]/details:rotate-0","aria-hidden":!0}),"Details"]}),e.jsx(ue,{children:e.jsx("pre",{className:"bg-muted/50 mt-1 max-h-40 overflow-auto rounded p-2 text-xs whitespace-pre-wrap",children:c})})]})]})}function M({label:t,hint:n,destructive:s=!1,className:a,ref:i,...r}){return e.jsxs("button",{ref:i,type:"button",className:q("group/more-row hover:bg-muted/50 focus-ring flex min-h-10 w-full items-center gap-3 rounded-lg px-2 py-2 text-left transition-colors disabled:opacity-50",a),...r,children:[e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:q("block text-sm",s&&"text-destructive"),children:t}),n&&e.jsx("span",{className:"text-muted-foreground block text-xs",children:n})]}),e.jsx(ae,{className:"text-muted-foreground size-4 shrink-0 transition-transform group-data-[state=open]/more-row:rotate-90","aria-hidden":!0})]})}function qa({detail:t,appName:n,onEditExactActions:s,onSignInAgain:a,signingIn:i,onAddAnother:r,onClose:c}){var A;const{connection:o,provider:u}=t,m=Mt({payer:o.payer,custody:u.custody}),d=o.connectionId,p=$t(),l=qe(),h=Es(),f=Ot(d,o.lifecycle!=="disconnected"),[j,k]=y.useState(!1),N=o.lifecycle==="disconnected";return e.jsxs(le,{children:[e.jsxs(de,{className:"group/more text-muted-foreground hover:text-foreground focus-ring flex w-full items-center justify-between rounded-md py-1 text-sm font-semibold",children:["More",e.jsx(ae,{className:"size-4 transition-transform group-data-[state=open]/more:rotate-90","aria-hidden":!0})]}),e.jsxs(ue,{className:"-mx-2 space-y-1 pt-2","data-testid":"app-panel-more",children:[!N&&e.jsx(Ua,{detail:t}),!N&&e.jsxs(le,{children:[e.jsx(de,{asChild:!0,children:e.jsx(M,{label:$a(o.toolkit,n),hint:La(((A=f.data)==null?void 0:A.pages.flatMap(x=>x.subscriptions))??[])})}),e.jsx(ue,{className:"px-2 pt-2 pb-3",children:e.jsx(Ma,{connectionId:d})})]}),o.everyAgent&&e.jsx(M,{label:"Stop sharing with every agent",hint:"Agents picked by name keep access",disabled:h.isPending,onClick:()=>h.mutate({connectionId:d})}),h.isError&&e.jsx("p",{role:"alert",className:"text-destructive px-2 text-xs",children:"Couldn’t stop sharing. Try again."}),!N&&e.jsx(M,{label:"Exact actions per agent",onClick:()=>s(d)}),o.lifecycle==="connected"&&e.jsx(M,{label:"Pause",hint:"Agents stop until you resume",disabled:p.isPending,onClick:()=>p.mutate({connectionId:d,input:void 0})}),o.lifecycle==="paused"&&e.jsx(M,{label:"Resume",disabled:l.isPending,onClick:()=>l.mutate({connectionId:d,input:void 0})}),!N&&e.jsx(M,{label:"Sign in again",hint:"Who can use it stays the same",disabled:i,onClick:a}),e.jsx(M,{label:`Connect another ${n} account`,onClick:()=>r(o.toolkit)}),e.jsxs("div",{className:"px-2 py-2",children:[e.jsx("p",{className:"text-sm font-medium",children:"How it’s connected"}),e.jsxs("p",{className:"text-muted-foreground mt-0.5 text-xs leading-relaxed",children:[u.displayName,". ",u.disclosure]}),m&&e.jsx("p",{className:"text-muted-foreground mt-1 text-xs",children:m})]}),!N&&e.jsx(M,{label:"Disconnect…",destructive:!0,onClick:()=>k(!0)})]}),e.jsx(Wa,{detail:t,appName:n,open:j,onOpenChange:k,onDisconnected:c})]})}function Ua({detail:t}){const n=Kn(),[s,a]=y.useState(t.connection.label),i=`connection-name-${t.connection.connectionId}`,r=s.trim()===""||s.trim()===t.connection.label;return e.jsxs("form",{className:"flex items-end gap-2 px-2 py-2",onSubmit:c=>{c.preventDefault(),!r&&n.mutate({connectionId:t.connection.connectionId,input:{label:s.trim()}})},children:[e.jsxs("div",{className:"min-w-0 flex-1 space-y-1",children:[e.jsx(De,{htmlFor:i,children:"Name"}),e.jsx(Pe,{id:i,value:s,onChange:c=>a(c.target.value)})]}),e.jsx(b,{type:"submit",variant:"secondary",disabled:r||n.isPending,children:n.isPending?"Saving…":"Save"})]})}function Wa({detail:t,appName:n,open:s,onOpenChange:a,onDisconnected:i}){const r=t.connection.connectionId,c=Yn(r,s),o=Tt(),u=t.agents.map(m=>m.displayName);return e.jsx(pe,{open:s,onOpenChange:a,children:e.jsxs(xe,{children:[e.jsxs(fe,{children:[e.jsxs(je,{children:["Disconnect ",n,"?"]}),e.jsx(ye,{children:c.isPending?"Checking who will lose access…":c.data?Ka(u,c.data):"Who loses access isn’t known yet."})]}),c.isError&&e.jsx("p",{role:"alert",className:"text-destructive text-sm",children:"Couldn’t check who loses access. Try again."}),e.jsxs(ve,{children:[e.jsx(be,{children:"Keep connected"}),e.jsx(Ne,{disabled:!c.data||o.isPending,className:"bg-destructive hover:bg-destructive/90 dark:bg-destructive/60 text-white",onClick:m=>{m.preventDefault(),o.mutate({connectionId:r,input:void 0},{onSuccess:()=>{a(!1),i()}})},children:o.isPending?"Disconnecting…":"Disconnect"})]})]})})}function Ka(t,n){const s=[];return n.everyAgent?s.push("Every agent will lose access."):t.length>0?s.push(`${cs(t)} will lose access.`):n.affectedAgentCount>0?s.push(`${n.affectedAgentCount} ${n.affectedAgentCount===1?"agent":"agents"} will lose access.`):s.push("No agent uses it right now."),n.affectedSessionCount>0&&s.push(`${n.affectedSessionCount} open ${n.affectedSessionCount===1?"chat":"chats"} will stop using it.`),n.affectedSubscriptionCount>0&&s.push(`${n.affectedSubscriptionCount} ${n.affectedSubscriptionCount===1?"notification stops":"notifications stop"}.`),n.pendingDeliveryCount>0&&s.push(`${n.pendingDeliveryCount} waiting ${n.pendingDeliveryCount===1?"delivery":"deliveries"} won’t be sent.`),s.join(" ")}const nt=3;function Ya(t){const n=Hn(t.connectionId);return n.isPending?e.jsxs("div",{className:"space-y-3","aria-label":"Loading app details",children:[e.jsx(O,{className:"h-28 rounded-lg"}),e.jsx(O,{className:"h-20 rounded-lg"})]}):n.isError?e.jsx(Pt,{error:n.error,title:"Couldn’t load this app",description:"Nothing changed. Try again.",onRetry:()=>void n.refetch(),isRetrying:n.isFetching}):e.jsx(Ha,{...t,detail:n.data})}function Ha({connectionId:t,startWho:n,detail:s,onSignInStarted:a,onEditExactActions:i,onAddAnother:r,onClose:c}){var x;const{connection:o}=s,u=he(""),m=new Map((((x=u.data)==null?void 0:x.pages.flatMap(g=>g.services))??[]).map(g=>[g.serviceSlug,g])),d=Ce(o.toolkit,m),p=_t(),l=$t(),h=qe(),f=Tt(),j=Gn(),k=p.error??l.error??h.error??f.error??j.error,N=()=>p.mutate({connectionId:t},{onSuccess:g=>a(g.flowId)}),A=o.readiness.state==="gone";return e.jsxs("div",{className:"space-y-7",children:[e.jsx(Ga,{detail:s,appName:d,onSignInAgain:N,reconnecting:p.isPending,onResume:()=>h.mutate({connectionId:t,input:void 0}),resuming:h.isPending,onReview:()=>i(t),onConnectNew:()=>r(o.toolkit),onRemove:()=>j.mutate({connectionId:t,input:void 0},{onSuccess:()=>c()}),removing:j.isPending,onRetryDisconnect:()=>f.mutate({connectionId:t,input:void 0}),retryingDisconnect:f.isPending}),k&&e.jsx("p",{role:"alert",className:"text-destructive bg-destructive/5 rounded-lg p-3 text-sm",children:Vt(k)}),!A&&e.jsx(Lt,{mode:"page",variant:"embedded",connectionId:t,serviceName:d,startWho:n,onEditExactActions:i,appActions:{toolkit:o.toolkit,providerInstanceId:o.providerInstanceId}}),e.jsx(Va,{detail:s}),o.readiness.state==="ready"&&e.jsx(Qa,{detail:s}),e.jsx(qa,{detail:s,onSignInAgain:N,signingIn:p.isPending,appName:d,onEditExactActions:i,onAddAnother:r,onClose:c})]})}function Ga({detail:t,appName:n,onSignInAgain:s,reconnecting:a,onResume:i,resuming:r,onReview:c,onConnectNew:o,onRemove:u,removing:m,onRetryDisconnect:d,retryingDisconnect:p}){const l=ze(),h=Vn(),[f,j]=y.useState(!1),{readiness:k}=t.connection;if(k.state==="ready")return null;const N=k.fix,A=N!=null&&N.retryAt?Ea(N.retryAt):void 0,x=k.copy.owner,g=k.state==="gone",C=(()=>{switch(N==null?void 0:N.action){case"sign_in_again":return{action:"Sign in again",onAction:s,pending:a};case"connect_again":return{action:"Connect again",onAction:s,pending:a};case"connect_new":return{action:`Connect ${n} again`,onAction:o};case"resume":return{action:"Resume",onAction:i,pending:r};case"review_access":return{action:"Check who can use it",onAction:c};case"fix_key":return{action:"Fix the key",onAction:()=>l.open("connections","ways")};case"retry":return g?{action:"Try again now",onAction:d,pending:p}:{action:"Check again",onAction:()=>h.mutate(),pending:h.isPending};case"remove":return{action:"Remove from your apps",onAction:()=>j(!0),pending:m};case"wait":case"turn_on_for_this_chat":case void 0:return null}})(),T=k.serviceAccessPage;return e.jsxs(e.Fragment,{children:[e.jsx(Ee,{message:x,detail:A,...C??{},secondary:g&&e.jsxs(e.Fragment,{children:[T&&e.jsx(b,{asChild:!0,size:"sm",variant:"ghost",className:"h-auto min-h-8 max-w-full whitespace-normal","data-testid":"service-access-page",children:e.jsxs(Fe,{href:T.url,children:["Open ",T.service," settings",e.jsx(Me,{className:"size-3.5","aria-hidden":!0})]})}),(N==null?void 0:N.action)!=="remove"&&e.jsx(b,{size:"sm",variant:"ghost",className:"h-auto min-h-8 max-w-full whitespace-normal",onClick:()=>j(!0),disabled:m,"data-testid":"remove-account",children:"Remove from your apps"})]})}),g&&e.jsx(pe,{open:f,onOpenChange:j,children:e.jsxs(xe,{children:[e.jsxs(fe,{children:[e.jsxs(je,{children:["Remove ",n," from your apps?"]}),e.jsx(ye,{asChild:!0,children:e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{children:"It leaves this list. Its activity history is kept."}),e.jsx("p",{children:"Connect it again later and you choose who can use it."}),k.reason==="disconnect_finishing"&&e.jsx("p",{children:"DorkOS still finishes removing its access at the service."})]})})]}),e.jsxs(ve,{children:[e.jsx(be,{children:"Keep it"}),e.jsx(Ne,{disabled:m,onClick:u,children:"Remove app"})]})]})})]})}function Va({detail:t}){var d,p;const{connection:n}=t,s=Qn(n.connectionId),{data:a}=ie(),[i,r]=y.useState(!1),c=Object.fromEntries(t.agents.map(l=>[l.agentId,l.displayName]));for(const l of(a==null?void 0:a.agents)??[])c[d=l.id]??(c[d]=Q(l));const o=((p=s.data)==null?void 0:p.items)??[],u=i?o:o.slice(0,nt);let m;return n.usage.status==="unavailable"?m=e.jsx("p",{className:"text-muted-foreground text-sm",children:"Activity isn’t available right now."}):s.isPending?m=e.jsx(O,{className:"h-16 rounded-lg"}):s.isError?m=e.jsxs("p",{className:"text-muted-foreground flex items-center gap-2 text-sm",children:["Couldn’t load what agents did.",e.jsx(b,{variant:"link",size:"xs",className:"h-auto p-0",onClick:()=>void s.refetch(),children:"Try again"})]}):o.length===0?m=e.jsx("p",{className:"text-muted-foreground text-sm",children:"Nothing yet."}):m=e.jsx("ul",{className:"space-y-1.5",children:u.map(l=>e.jsxs("li",{className:"flex items-baseline justify-between gap-3 text-sm",children:[e.jsx("span",{className:"min-w-0 truncate",children:_a(l,n.toolkit,c)}),e.jsx("span",{className:"text-muted-foreground shrink-0 text-xs",children:Le(l.startedAt)})]},`${l.logicalOperationId}-${l.attemptIndex}`))}),e.jsx(me,{title:"Recently",action:o.length>nt&&e.jsx(b,{variant:"link",size:"xs",className:"h-auto p-0",onClick:()=>r(l=>!l),children:i?"Show less":"See all"}),children:m})}function Qa({detail:t}){const n=Ia(t.connection.toolkit),{data:s}=ie(),{data:a}=un(),i=jt();if(n.length===0)return null;const r=(a==null?void 0:a.agents)??[],c=d=>r.find(p=>p.id===d)??null,o=((s==null?void 0:s.agents)??[]).find(d=>d.isSystem),u=t.agents.map(d=>c(d.agentId)).find(d=>d!==null)??c(o==null?void 0:o.id),m=u?u.displayName??u.name:null;return e.jsx(me,{title:"Try it",description:m?`Opens a chat with ${m}, ready to send.`:void 0,children:e.jsx("div",{className:"flex flex-wrap gap-2",children:n.map(d=>e.jsxs(b,{variant:"outline",size:"sm",className:"h-auto min-h-8 justify-start py-1.5 text-left whitespace-normal",disabled:!u||!i,onClick:()=>u&&i&&void i(yt({session:crypto.randomUUID(),agentId:u.id,draft:"1",prompt:d})),children:[e.jsx(hn,{className:"text-muted-foreground size-3.5","aria-hidden":!0}),d]},d))})})}function Ja(t){return t.requesterKind==="program"?"A program":"Something using your sign-in"}function G(t,n,s){const a=Ce(t,s);return n?`${a} (${n})`:a}function st(t){return t===1?"1 action":`${t} actions`}function Za(t,n){const s=Ja(t),a=t.context;switch(a.kind){case"unavailable":return{title:`${s} asks to change a connection`,detail:"Open it to see the request."};case"connect":return{title:`${s} asks to connect ${G(a.toolkit,a.label,n)}`,detail:"You sign in first. No agent gets it until you choose."};case"edit":return{title:`${s} asks to rename ${G(a.connection.toolkit,a.connection.label,n)}`,detail:"Only its name changes."};case"pause":return{title:`${s} asks to pause ${G(a.connection.toolkit,a.connection.label,n)}`,detail:"Agents can’t use it until you resume it."};case"resume":return{title:`${s} asks to resume ${G(a.connection.toolkit,a.connection.label,n)}`,detail:"Agents it’s shared with get it back."};case"disconnect":return{title:`${s} asks to disconnect ${G(a.connection.toolkit,a.connection.label,n)}`,detail:a.everyAgent?"Every agent loses access.":a.affectedAgentCount===0?"No agent uses it right now.":`${a.affectedAgentCount===1?"1 agent loses":`${a.affectedAgentCount} agents lose`} access.`};case"set_agent_access":return{title:`${s} asks to let ${a.agent.displayName} use ${G(a.connection.toolkit,a.connection.label,n)}`,detail:`${st(a.requestedOperations.length)} to review.`};case"remove_agent_access":return{title:`${s} asks to stop ${a.agent.displayName} using ${G(a.connection.toolkit,a.connection.label,n)}`,detail:a.keptThroughEveryAgent.length>0?`Still shared with every agent, so it keeps ${st(a.keptThroughEveryAgent.length)}.`:"It loses access to this app."}}}function Xa(t,n){if(t.state!=="approved")return null;const s=t.context,a=s.kind==="connect"?G(s.toolkit,s.label,n):s.kind==="unavailable"?"the connection":G(s.connection.toolkit,s.connection.label,n);return t.resolution.kind==="connect_authentication_required"?{title:`Approved: finish signing in to ${a}`,detail:"Open it to finish signing in."}:t.resolution.kind==="outcome_unknown"?{title:`Check ${a} before another change`,detail:"Couldn’t confirm the approved change took effect."}:null}const ei=10080*60*1e3,ti=mn,ni=60*1e3;function si({services:t,onOpenRequest:n,onOpenReview:s}){var d,p;const a=Os("pending"),i=Xe("pending"),r=Xe("resolved"),c=ai(),o=(r.data??[]).filter(l=>l.state==="approved"&&(l.resolution.kind==="connect_authentication_required"&&c-Date.parse(l.resolvedAt)<ti||l.resolution.kind==="outcome_unknown"&&c-Date.parse(l.resolvedAt)<ei)),u=[a,i,r].filter(l=>l.isError);return!((((d=a.data)==null?void 0:d.length)??0)+(((p=i.data)==null?void 0:p.length)??0)+o.length>0)&&u.length===0?null:e.jsxs("section",{"aria-labelledby":"connections-needs-you","data-testid":"needs-you",className:"bg-status-warning-bg/60 rounded-xl p-1.5",children:[e.jsx("h2",{id:"connections-needs-you",className:"text-status-warning-fg px-2.5 pt-1.5 pb-1 text-xs font-semibold",children:"Needs you"}),e.jsxs("ul",{children:[(a.data??[]).map(l=>e.jsx(Ie,{testId:`needs-you-request-${l.requestId}`,line:{title:`${l.agent.displayName} wants to use ${Ce(l.serviceSlug,t)}`,detail:l.reason},onOpen:()=>n(l.requestId)},`request-${l.requestId}`)),(i.data??[]).map(l=>e.jsx(Ie,{testId:`needs-you-review-${l.reviewRequestId}`,line:Za(l,t),onOpen:()=>s(l.reviewRequestId)},`review-${l.reviewRequestId}`)),o.map(l=>{const h=Xa(l,t);return h?e.jsx(Ie,{testId:`needs-you-review-${l.reviewRequestId}`,line:h,onOpen:()=>s(l.reviewRequestId)},`review-${l.reviewRequestId}`):null})]}),u.length>0&&e.jsxs("p",{className:"text-muted-foreground flex flex-wrap items-center gap-x-2 px-2.5 pb-1.5 text-xs",children:["Couldn’t check for waiting requests.",e.jsx(b,{variant:"link",size:"xs",className:"h-auto p-0",onClick:()=>u.forEach(l=>void l.refetch()),children:"Try again"})]})]})}function ai(){const[t,n]=y.useState(()=>Date.now());return y.useEffect(()=>{const s=setInterval(()=>n(Date.now()),ni);return()=>clearInterval(s)},[]),t}function Ie({testId:t,line:n,onOpen:s}){return e.jsx("li",{children:e.jsxs("button",{type:"button","data-testid":t,onClick:s,className:"hover:bg-background/60 focus-ring flex min-h-12 w-full items-center gap-3 rounded-lg px-2.5 py-2 text-left transition-colors",children:[e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"line-clamp-2 block text-sm font-medium sm:line-clamp-1",children:n.title}),e.jsx("span",{className:"text-muted-foreground line-clamp-2 block text-xs sm:line-clamp-1",children:n.detail})]}),e.jsxs("span",{className:"text-muted-foreground flex shrink-0 items-center gap-0.5 text-xs font-medium",children:["Review",e.jsx(ae,{className:"size-3.5","aria-hidden":!0})]})]})})}function ii({requestId:t,open:n,onOpenChange:s,onEditExactActions:a,onCloseAutoFocus:i}){const r=Ps(t),c=r.data?`${r.data.agent.displayName} asked to use ${oe(r.data.serviceSlug)}`:"An agent’s request";return e.jsx(J,{open:n,onOpenChange:s,children:e.jsxs(Z,{"data-testid":"agent-request-dialog",onCloseAutoFocus:i,className:"max-h-[90vh] sm:max-w-xl",children:[e.jsxs(X,{className:"sr-only",children:[e.jsx(ee,{children:c}),e.jsx(te,{children:"Answer it here, as in the chat."})]}),e.jsx(ne,{className:"pb-4",children:r.isPending?e.jsx(O,{className:"h-40 rounded-xl","aria-label":"Loading the request"}):r.isError?e.jsx(W,{title:"Couldn’t load this request",description:"Nothing changed. Try again.",onRetry:()=>void r.refetch(),isRetrying:r.isFetching}):r.data?e.jsx(ls,{request:r.data,className:"max-w-none",...a?{onEditExactActions:a}:{}},r.data.requestId):null})]})})}function oi(t){const n=t.context;if(n.kind==="unavailable")return{title:"Older connection request",approveLabel:"Approve"};switch(n.kind){case"connect":return{title:`Connect ${oe(n.toolkit)}${n.label?` (${n.label})`:""}`,approveLabel:"Approve and continue"};case"edit":return{title:`Rename ${n.connection.label}`,approveLabel:"Approve rename"};case"pause":return{title:`Pause ${n.connection.label}`,approveLabel:"Approve pause"};case"resume":return{title:`Resume ${n.connection.label}`,approveLabel:"Approve resume"};case"disconnect":return{title:`Disconnect ${n.connection.label}`,approveLabel:"Approve disconnect"};case"set_agent_access":return{title:`Change access for ${n.agent.displayName}`,approveLabel:"Approve access"};case"remove_agent_access":return{title:`Remove access for ${n.agent.displayName}`,approveLabel:"Approve removal"}}}function ri(t){return(t.split(".").at(-1)??t).replaceAll("_"," ").replace(/\b\w/g,s=>s.toUpperCase())}function Zt(t){const n=new Map;for(const s of t){const a=n.get(s.operationSlug);(!a||s.toolkitVersion.localeCompare(a.toolkitVersion,void 0,{numeric:!0})>0)&&n.set(s.operationSlug,s)}return new Set(t.filter(s=>s.toolkitVersion.localeCompare(n.get(s.operationSlug).toolkitVersion,void 0,{numeric:!0})<0).map(s=>s.operationRevisionId))}function ci({reviewRequestId:t,open:n,onOpenChange:s,onCloseAutoFocus:a}){var N;const i=Ls(t),r=Ds(),[c,o]=y.useState(!1),[u,m]=y.useState(!1),d=i.data,p=(d==null?void 0:d.state)==="approved"&&d.resolution.kind==="connect_authentication_required"?d.resolution.authentication:null,l=c||!!(p&&!p.authorizeUrl),h=zs((p==null?void 0:p.flowId)??null,l),f=h.isError?"check_failed":((N=h.data)==null?void 0:N.state)??(l?"checking":"required"),j=y.useMemo(()=>d?oi(d):null,[d]),k=A=>{!t||u||r.mutate({reviewRequestId:t,decision:A},{onError:()=>{m(!0)}})};return e.jsx(J,{open:n,onOpenChange:s,children:e.jsxs(Z,{"data-testid":"connector-review-dialog",onCloseAutoFocus:a,className:"max-h-[90vh] sm:max-w-xl [&>[data-slot=dialog-content-close]]:absolute [&>[data-slot=dialog-content-close]]:top-4 [&>[data-slot=dialog-content-close]]:right-4 [&>[data-slot=dialog-content-close]]:m-0 [&>[data-slot=dialog-content-close]]:opacity-100",children:[e.jsxs(X,{children:[e.jsx(ee,{children:(j==null?void 0:j.title)??"Review connection request"}),e.jsx(te,{className:"text-foreground",children:"Check the account, agent and actions first."})]}),e.jsx(ne,{className:"space-y-4 pb-4",children:i.isLoading?e.jsx(O,{className:"h-48 rounded-lg"}):i.isError?e.jsx(W,{title:"Couldn’t load this request",description:"It may have expired or belong to another owner.",onRetry:()=>void i.refetch(),isRetrying:i.isFetching}):d&&j?e.jsxs(e.Fragment,{children:[e.jsx(li,{context:d.context}),d.targetStatus==="unavailable"&&d.state==="pending"&&e.jsxs("div",{className:"border-status-warning/30 bg-status-warning/5 flex gap-3 rounded-lg border p-3",children:[e.jsx(gn,{className:"text-status-warning-dot mt-0.5 size-4 shrink-0","aria-hidden":!0}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:"This request can’t be approved"}),e.jsx("p",{className:"text-muted-foreground mt-1 text-sm",children:"The account, agent or app setup changed since. You can still deny it."})]})]}),d.state!=="pending"&&e.jsx(ui,{review:d}),u&&e.jsxs("div",{role:"alert",className:"border-destructive/30 bg-destructive/5 rounded-lg border p-3",children:[e.jsx("p",{className:"text-sm font-medium",children:"Couldn’t confirm your decision"}),e.jsx("p",{className:"text-muted-foreground mt-1 text-sm",children:"Reload the request to see what was recorded."})]}),p&&e.jsxs("div",{"aria-live":"polite",className:"space-y-3 rounded-lg border p-4",children:[e.jsx("p",{className:"text-sm font-medium",children:f==="connected"?"Account connected":f==="failed"||f==="expired"||f==="start_unknown"?"Sign-in didn’t finish":f==="pending"||f==="starting"?"Waiting for sign-in":f==="checking"?"Checking sign-in":f==="check_failed"?"Couldn’t check sign-in":"Sign-in still required"}),e.jsx("p",{className:"text-muted-foreground text-sm",children:f==="connected"?"Sign-in finished and the account is ready.":f==="expired"?"The sign-in timed out. Connect it yourself on the Connections page.":f==="start_unknown"?"DorkOS can’t tell if the sign-in started. Connect it on the Connections page.":f==="failed"?"Sign-in didn’t finish. Connect it yourself on the Connections page.":f==="pending"||f==="starting"||f==="checking"?"Finish signing in. This page updates when the account is ready.":f==="check_failed"?"The account may be connected. Check again before another request.":"No account connected yet. Continue to the service to sign in."}),f==="check_failed"?e.jsx(b,{onClick:()=>void h.refetch(),disabled:h.isFetching,children:h.isFetching?"Checking…":"Check again"}):f!=="connected"&&f!=="failed"&&f!=="expired"&&f!=="start_unknown"&&p.authorizeUrl?e.jsx(b,{asChild:!0,children:e.jsxs(Fe,{href:p.authorizeUrl,onOpened:()=>o(!0),children:["Continue to sign in",e.jsx(Me,{className:"size-4","aria-hidden":!0})]})}):f==="required"?e.jsx(b,{onClick:()=>o(!0),children:"Check connection"}):null]})]}):null}),e.jsx(ge,{children:(d==null?void 0:d.state)==="pending"&&u?e.jsx(b,{onClick:()=>{i.refetch().then(A=>{A.isError||(m(!1),r.reset())})},disabled:i.isFetching,children:i.isFetching?"Reloading request…":"Reload request"}):(d==null?void 0:d.state)==="pending"?e.jsxs(e.Fragment,{children:[e.jsx(b,{variant:"outline",onClick:()=>k("denied"),disabled:r.isPending,children:"Deny"}),d.targetStatus==="available"&&d.context.kind!=="unavailable"&&e.jsx(b,{onClick:()=>k("approved"),disabled:r.isPending,children:r.isPending?"Saving decision…":j==null?void 0:j.approveLabel})]}):e.jsx(b,{variant:"secondary",onClick:()=>s(!1),children:"Done"})})]})})}function li({context:t}){if(t.kind==="unavailable")return e.jsx("p",{className:"text-muted-foreground rounded-lg border p-4 text-sm",children:"This older request lacks the detail to approve safely."});if(t.kind==="connect")return e.jsxs("dl",{className:"grid grid-cols-[auto_1fr] gap-x-4 gap-y-2 rounded-lg border p-4 text-sm",children:[e.jsx("dt",{children:"App"}),e.jsx("dd",{className:"font-medium",children:oe(t.toolkit)}),e.jsx("dt",{children:"Connected through"}),e.jsx("dd",{children:t.providerDisplayName}),t.label&&e.jsxs(e.Fragment,{children:[e.jsx("dt",{children:"Label"}),e.jsx("dd",{children:t.label})]})]});const n=t.kind==="set_agent_access"?t.requestedOperations:t.kind==="remove_agent_access"||t.kind==="disconnect"?t.affectedOperations:[],s=Zt(n),a=t.kind==="set_agent_access"||t.kind==="remove_agent_access"?t.agent:null;return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("dl",{className:"grid grid-cols-[auto_1fr] gap-x-4 gap-y-2 rounded-lg border p-4 text-sm",children:[e.jsx("dt",{children:"Account"}),e.jsx("dd",{className:"font-medium",children:t.connection.label}),e.jsx("dt",{children:"App"}),e.jsx("dd",{children:oe(t.connection.toolkit)}),e.jsx("dt",{children:"Status"}),e.jsx("dd",{children:Fs[t.connection.status]}),e.jsx("dt",{children:"Sign-in"}),e.jsx("dd",{"data-testid":"connector-review-custody",children:di(t.connection)}),a&&e.jsxs(e.Fragment,{children:[e.jsx("dt",{children:"Agent"}),e.jsx("dd",{children:a.displayName})]})]}),t.kind==="disconnect"&&e.jsx("p",{"data-testid":"connector-review-impact",className:"text-sm font-medium",children:t.everyAgent?"Every agent loses this account. It’s shared with every agent now.":`Removes this account from ${t.affectedAgentCount} ${t.affectedAgentCount===1?"agent":"agents"}.`}),t.kind==="remove_agent_access"&&t.keptThroughEveryAgent.length>0&&e.jsxs("div",{role:"note","data-testid":"connector-review-every-agent-kept",className:"bg-muted/40 space-y-1 rounded-lg p-3 text-sm",children:[e.jsxs("p",{children:[t.agent.displayName," keeps ",t.keptThroughEveryAgent.length," ",t.keptThroughEveryAgent.length===1?"action":"actions"," on"," ",t.connection.label," through “Every agent”."]}),e.jsxs("p",{children:["Approving removes only what ",t.agent.displayName," has by name."]}),e.jsxs("p",{children:["To remove it all, stop sharing ",t.connection.label," with every agent in Connections."]})]}),n.length>0&&e.jsxs("div",{children:[e.jsx("p",{className:"mb-2 text-sm font-medium",children:"Exact actions"}),e.jsx("ul",{className:"space-y-2",children:n.map(i=>e.jsxs("li",{className:"flex flex-wrap items-center justify-between gap-2 rounded-md border px-3 py-2",children:[e.jsxs("span",{className:"text-sm",children:[ri(i.operationSlug),s.has(i.operationRevisionId)&&e.jsx("span",{className:"text-muted-foreground ml-2 text-xs",children:"Older version"})]}),e.jsx(K,{size:"xs",variant:i.capabilityClassification==="destructive"?"destructive":"secondary",children:Bt[i.capabilityClassification]})]},i.operationRevisionId))})]})]})}function di(t){switch(t.custody){case"managed":return"Kept in Composio’s vault";case"self-host":return"Kept on your own Nango server";case"external":return"Handled by the app’s own server"}}function ui({review:t}){if(t.state==="pending")return null;if(t.state==="resolving")return e.jsxs("div",{"data-testid":"connector-review-outcome","data-outcome":"resolving",className:"bg-muted/40 rounded-lg border p-4",children:[e.jsx("p",{className:"text-sm font-medium",children:"Applying change"}),e.jsx("p",{className:"text-muted-foreground mt-1 text-sm",children:"Still applying. Check again before another change."})]});const n=t.state==="denied"?"Denied":t.state==="expired"?"Expired":t.resolution.kind==="applied"?"Approved and applied":t.resolution.kind==="outcome_unknown"?"Outcome unknown":"Approved",s=t.state==="expired"?"This request can no longer change access.":t.state==="denied"?"No requested change was made.":t.resolution.kind==="applied"?"The requested change was applied.":t.resolution.kind==="outcome_unknown"?"It may have been applied. Check the connection before another change.":"Finish signing in to connect the account.";return e.jsxs("div",{"data-testid":"connector-review-outcome","data-outcome":t.state==="approved"?t.resolution.kind:t.state,className:"bg-muted/40 rounded-lg border p-4",children:[e.jsx("p",{className:"text-sm font-medium",children:n}),e.jsx("p",{className:"text-muted-foreground mt-1 text-sm",children:s})]})}function hi(t,n){switch(t){case"service_not_ready":return{title:`${n} can’t be connected yet`,description:"This isn’t something you can fix here.",canRetry:!1};case"setup_needs_fix":return{title:`${n} can’t be connected right now`,description:"Its sign-in setup in DorkOS has a problem. Use Send feedback to report it.",canRetry:!1};case"account_link_required":return{title:"This computer isn’t linked to DorkOS",description:"Link your DorkOS account again, then connect.",canRetry:!1,action:"relink"};case"service_unavailable":return{title:`${n} isn’t available right now`,description:"Nothing was connected. Try again in a few minutes.",canRetry:!0}}}const mi=new Set(["provider_not_found","authentication_unavailable"]);function gi(t,n){const s=typeof t=="object"&&t!==null&&"code"in t?t.code:void 0;return typeof s=="string"&&mi.has(s)?{title:"Couldn’t start the connection",description:`The way DorkOS reaches ${n} isn’t working. Check Settings › Connections.`,canRetry:!1}:{title:"Couldn’t start the connection",description:"Nothing was connected. Try again in a moment.",canRetry:!0}}function pi(t,n){const s=t.authenticationSetup;return s?s.source==="configured"?`${n} uses its own sign-in page.`:s.kind==="oauth"?`A ${n} sign-in page opens next.`:s.kind==="fields"&&t.mode==="managed"?`Enter your ${n} details on dorkos.ai. DorkOS doesn’t save them.`:s.kind==="none"&&t.mode==="managed"?`Confirm this ${n} connection on dorkos.ai. No account details needed.`:null:null}function at(t,n){var s,a,i;return(t==null?void 0:t.mode)==="managed"&&((s=t.authenticationSetup)==null?void 0:s.kind)==="fields"?"Enter account details":(t==null?void 0:t.mode)==="managed"&&((a=t.authenticationSetup)==null?void 0:a.kind)==="none"?"Review and confirm":((i=t==null?void 0:t.authenticationSetup)==null?void 0:i.source)==="configured"?"Continue":n==="authorize"?"Open sign-in":(t==null?void 0:t.authKind)==="none"?"Check connection":"Continue"}function it({copy:t,onRetry:n,isRetrying:s=!1,onClose:a}){return t.canRetry&&n?e.jsx(W,{title:t.title,description:t.description,onRetry:n,isRetrying:s}):e.jsxs("div",{"data-testid":"connect-refusal",className:"space-y-2",children:[e.jsx(Ms,{icon:vt,tone:"destructive",headline:t.title,description:t.description}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[t.action==="relink"&&e.jsx(ys,{variant:"outline",size:"sm"}),a&&e.jsx(b,{variant:"secondary",size:"sm",onClick:a,children:"Close"})]})]})}function xi({service:t,flowId:n,onFlowIdChange:s,onClose:a,onChooseAccess:i,onConnected:r}){var re,ce,_;const[c,o]=y.useState(!!(t||n)),[u,m]=y.useState(""),[d,p]=y.useState(null),[l,h]=y.useState(!1),f=Jn(),j=Et(n),k=((re=j.data)==null?void 0:re.toolkit)??(t==null?void 0:t.serviceSlug)??"",N=he(k),A=(ce=N.data)==null?void 0:ce.pages.flatMap(R=>R.services).find(R=>R.serviceSlug===k),x=(_=N.data)==null?void 0:_.pages[0],g=x==null?void 0:x.appConnections,C=A??t??null,T=ds(C),Y=T.filter(R=>R.capabilities.authentication.status==="available").length,S=T.find(R=>R.providerInstanceId===d)??(j.data?T.find(R=>R.providerInstanceId===j.data.providerInstanceId):null)??us(T,g==null?void 0:g.newApps),$=j.data??f.data,w=!$&&hs(C),E=(C==null?void 0:C.displayName)??oe(($==null?void 0:$.toolkit)??"service"),z=S?pi(S,E):null,U=S?Mt(S):null,I=ms(S,C),L=()=>{o(!1),a()},P=()=>{s(null),L()},F=()=>{if(!C||!S)return;const R={providerInstanceId:S.providerInstanceId,...u.trim()&&{label:u.trim()}};f.mutate({...R,toolkit:C.serviceSlug,idempotencyKey:crypto.randomUUID()},{onSuccess:H=>s(H.flowId)})};return e.jsx(e.Fragment,{children:e.jsx(J,{open:c,onOpenChange:R=>{R?o(!0):L()},children:e.jsxs(Z,{"data-testid":"connect-auth-dialog",className:q("max-h-[90vh] sm:max-w-lg [&>[data-slot=dialog-content-close]]:absolute [&>[data-slot=dialog-content-close]]:top-4 [&>[data-slot=dialog-content-close]]:right-4 [&>[data-slot=dialog-content-close]]:m-0 [&>[data-slot=dialog-content-close]]:opacity-100",w&&"min-h-0"),children:[e.jsxs(X,{children:[e.jsxs(ee,{children:["Connect ",E]}),e.jsx(te,{children:$?"Finish, then choose which agents can use it.":w?"First, pick how DorkOS reaches your apps. You only do this once.":"Name the account and check who handles sign-in."})]}),e.jsx(ne,{className:"space-y-4 pb-4",children:w&&T.length===0&&gs(x)&&(g==null?void 0:g.newApps.status)==="ready"?e.jsx(W,{title:`Couldn’t reach ${E} just now`,description:`${ps(g.newApps.way)} didn’t answer. Try again in a moment.`,onRetry:()=>void N.refetch(),isRetrying:N.isFetching}):w?e.jsx(xs,{reason:fs(g,C),onLeave:L}):$?$.state==="starting"||$.state==="pending"?e.jsxs("div",{className:"space-y-4",children:[S&&e.jsxs("div",{"data-testid":"connect-disclosure",className:"bg-muted/40 space-y-1.5 rounded-lg p-3",children:[e.jsx("p",{className:"text-sm font-medium",children:S.displayName}),e.jsx("p",{className:"text-muted-foreground text-xs leading-relaxed",children:S.disclosure}),z&&e.jsx("p",{className:"text-muted-foreground text-xs leading-relaxed",children:z}),U&&e.jsx("p",{className:"text-muted-foreground text-xs",children:U})]}),$.state==="pending"&&$.authorizeUrl?e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-sm",children:I??`Continue to sign in to ${E}.`}),e.jsx(b,{asChild:!0,className:"w-full",children:e.jsxs(Fe,{href:$.authorizeUrl,keepOpener:(S==null?void 0:S.mode)==="managed",children:[at(S,"authorize"),e.jsx(Me,{className:"size-4","aria-hidden":!0})]})})]}):e.jsxs("p",{className:"flex items-center gap-2 text-sm",children:[e.jsx(bt,{className:"size-4 animate-spin","aria-hidden":!0}),$.state==="starting"?"Starting the connection…":"Waiting for sign-in…"]}),e.jsx("p",{className:"text-muted-foreground text-xs",children:"You can reload or leave without starting over."}),j.isError&&e.jsx(W,{title:"Couldn’t check the connection",description:"Sign-in may still finish. Check again.",onRetry:()=>void j.refetch(),isRetrying:j.isFetching})]}):$.state==="connected"?e.jsxs("div",{className:"space-y-4",children:[e.jsxs("p",{className:"flex items-center gap-2 text-sm font-medium",children:[e.jsx(pn,{className:"text-status-success size-4","aria-hidden":!0}),e.jsxs("span",{children:[E," is connected"]})]}),e.jsx(Lt,{mode:"page",connectionId:$.connectionId,serviceName:E,logo:Ue(C),onSkip:()=>{P(),r==null||r($.connectionId)},onFinished:()=>{P(),r==null||r($.connectionId)},onEditExactActions:R=>{i(R),P()}})]}):$.state==="failed"&&$.failureCode?(()=>{const R=hi($.failureCode,E);return e.jsx(it,{copy:R,onRetry:R.canRetry?()=>{s(null),f.reset()}:void 0,onClose:P})})():e.jsxs("div",{className:"space-y-3",children:[e.jsx("p",{role:"alert",className:"text-destructive text-sm font-medium",children:$.state==="expired"?"This connection request expired.":"The connection didn’t finish."}),"reason"in $&&e.jsx("p",{className:"text-muted-foreground text-xs",children:$.reason}),e.jsx(b,{variant:"secondary",onClick:()=>{s(null),f.reset()},children:"Start again"})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(De,{htmlFor:"connection-label",children:"Account label"}),e.jsx(Pe,{id:"connection-label",value:u,onChange:R=>m(R.target.value),placeholder:"Work, personal, support…",autoComplete:"off"}),e.jsxs("p",{className:"text-muted-foreground text-xs",children:["Tells several ",E," accounts apart."]})]}),I&&e.jsx("p",{"data-testid":"connect-sign-in-line",className:"text-sm",children:I}),S?e.jsxs("div",{"data-testid":"connect-disclosure",className:"bg-muted/40 space-y-2 rounded-lg p-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Bs,{className:"text-muted-foreground size-4","aria-hidden":!0}),e.jsx("p",{className:"text-sm font-medium",children:S.displayName})]}),Y>1&&e.jsx(b,{variant:"ghost",size:"sm",onClick:()=>h(R=>!R),children:"Connect another way"})]}),e.jsx("p",{className:"text-muted-foreground text-xs leading-relaxed",children:S.disclosure}),z&&e.jsx("p",{className:"text-muted-foreground text-xs leading-relaxed",children:z}),U&&e.jsx("p",{className:"text-muted-foreground text-xs",children:U})]}):null,e.jsx(js,{toolkit:k,appName:E,providerInstanceId:(S==null?void 0:S.providerInstanceId)??null}),l&&e.jsxs("fieldset",{className:"space-y-2",children:[e.jsx("legend",{className:"text-xs font-medium",children:"Ways to connect"}),T.map(R=>{const H=R.capabilities.authentication.status==="available";return e.jsxs("button",{type:"button",disabled:!H,onClick:()=>{p(R.providerInstanceId),h(!1)},className:"bg-muted/40 focus-visible:ring-ring flex min-h-11 w-full items-center justify-between rounded-lg px-3 py-2 text-left focus-visible:ring-2 focus-visible:outline-none disabled:opacity-50",children:[e.jsx("span",{children:e.jsx("span",{className:"block text-sm font-medium",children:R.displayName})}),!H&&e.jsx("span",{className:"text-muted-foreground text-xs",children:"Unavailable"})]},R.providerInstanceId)})]}),f.isError&&e.jsx(it,{copy:gi(f.error,E),onRetry:F,isRetrying:f.isPending})]})}),!$&&e.jsxs(ge,{children:[e.jsx(b,{variant:"ghost",onClick:L,children:"Cancel"}),!w&&e.jsx(b,{onClick:F,disabled:!S||f.isPending,children:f.isPending?"Starting…":at(S,"start")})]})]})})})}function fi(t){var s,a;const n=((s=t.senderName)==null?void 0:s.trim())||"Someone";if(t.chatKind==="group"){const i=(a=t.chatTitle)==null?void 0:a.trim();return i?`${n} added your bot to “${i}”`:`${n} added your bot to a group`}return`${n} messaged your bot`}function ot(t){return t.chatKind==="group"?"Which agent should join?":"Which agent should answer?"}function ji(t){return t.chatKind==="group"&&t.platformChatType==="channel"}function yi({chat:t,agentOptions:n,onClaim:s,onIgnore:a,onBlock:i,onLeave:r,isDeciding:c=!1}){var p;const[o,u]=y.useState(n.length===1?((p=n[0])==null?void 0:p.id)??"":""),m=t.chatKind==="group",d=ji(t);return e.jsxs(qs,{"data-testid":`claim-card-${t.id}`,gap:"sm",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-sm font-medium",children:fi(t)}),e.jsxs("p",{className:"text-muted-foreground text-xs",children:[t.messageCount===1?"One message so far.":`${t.messageCount} messages so far.`," ","Not read or answered yet."]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[!d&&e.jsxs(Nt,{value:o,onValueChange:u,disabled:c,children:[e.jsx(kt,{className:"w-full sm:w-56","aria-label":ot(t),"data-testid":`claim-agent-${t.id}`,children:e.jsx(Ct,{placeholder:ot(t)})}),e.jsx(wt,{children:n.map(l=>e.jsx(Te,{value:l.id,children:Q(l)},l.id))})]}),d?null:m?e.jsx(b,{size:"sm",disabled:!o||c,onClick:()=>s(o,!0),children:"Join"}):e.jsxs(e.Fragment,{children:[e.jsx(b,{size:"sm",disabled:!o||c,onClick:()=>s(o,!0),children:"Answer in a channel"}),e.jsx(b,{size:"sm",variant:"outline",disabled:!o||c,onClick:()=>s(o,!1),children:"Answer privately"})]}),e.jsx(b,{size:"sm",variant:"ghost",disabled:c,onClick:a,children:"Ignore"}),m?e.jsx(b,{size:"sm",variant:"ghost",disabled:c,onClick:r,children:"Leave"}):e.jsx(b,{size:"sm",variant:"ghost",disabled:c,onClick:i,children:"Block"})]}),d?e.jsx("p",{className:"text-muted-foreground text-xs",children:"Broadcast channel: no one to answer. Ignore hides it. Leave removes the bot."}):m?e.jsx("p",{className:"text-muted-foreground text-xs",children:"Ignore hides this quietly. Leave removes the bot, so nothing more arrives."}):e.jsxs("div",{className:"text-muted-foreground space-y-0.5 text-xs",children:[e.jsx("p",{children:"A channel gives you a room to see and reply from."}),e.jsx("p",{children:"Answering privately keeps this chat as it is."}),e.jsx("p",{children:"Ignore hides this quietly. Block stops recording this chat."})]})]})}function vi({enabled:t,adapterId:n}){Ss();const{data:s,isLoading:a}=Dt("pending",t),{data:i}=ie(),r=As(),c=Is(),o=Rs(),u=$s(),m=Be(),[d,p]=y.useState(null),l=(i==null?void 0:i.agents)??[],h=(s??[]).filter(j=>!n||j.adapterId===n),f=r.isPending||c.isPending||o.isPending||u.isPending;return t?a?e.jsx(O,{className:"h-28 w-full rounded-lg"}):h.length===0?null:e.jsxs("section",{"aria-labelledby":"connections-waiting",className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx("h3",{id:"connections-waiting",className:"text-sm font-semibold",children:"Waiting on you"}),e.jsx("p",{className:"text-muted-foreground mt-1 text-sm",children:h.length===1?"Someone messaged a bot with no agent to answer.":`${h.length} chats reached a bot with no agent to answer.`})]}),h.map(j=>e.jsx(yi,{chat:j,agentOptions:l,isDeciding:f,onClaim:(k,N)=>{var x;const A=((x=l.find(g=>g.id===k))==null?void 0:x.name)??k;r.mutate({id:j.id,input:{agentId:k,bridge:N}},{onSuccess:({binding:g,bridgeError:C})=>{if(C){D.warning(`${A} will answer this chat privately: ${C}`);return}if(N&&g.roomId){D.success(`${A} will answer in a new channel.`),m({...St.channels(),search:{id:g.roomId}});return}D.success(`${A} will answer this chat.`)},onError:g=>{const C=_e(g,{id:k,name:A});if(C){p(C);return}D.error(g instanceof Error?g.message:"Couldn’t set an agent to answer")}})},onIgnore:()=>c.mutate(j.id,{onSuccess:()=>D.success("Ignored. This chat won’t show again.")}),onBlock:()=>o.mutate(j.id,{onSuccess:()=>D.success("Blocked. This chat is no longer recorded.")}),onLeave:()=>u.mutate(j.id,{onSuccess:()=>D.success("Left the group. It’s no longer recorded.")})},j.id)),e.jsx(Wt,{conflict:d,onClose:()=>p(null)})]}):null}function bi({connectionId:t,open:n,onOpenChange:s}){var A,x;const[a,i]=y.useState({}),[r,c]=y.useState(null),o=vs({connectionId:t,active:n,onPreview:g=>i(bs(g))}),{preview:u,saveOutcome:m,saved:d,needsReconciliation:p,needsRefresh:l}=o,h=(x=(A=Rt().data)==null?void 0:A.connections.find(g=>g.connectionId===t))==null?void 0:x.readiness,f=(h==null?void 0:h.reason)==="needs_review"||(h==null?void 0:h.reason)==="access_update_failed",j=y.useMemo(()=>u?Ns(u,a):[],[u,a]),k=l||m!==null,N=f&&j.length===0;return e.jsx(J,{open:n,onOpenChange:s,children:e.jsxs(Z,{"data-testid":"connector-access-dialog",className:"max-h-[90vh] sm:max-w-3xl [&>[data-slot=dialog-content-close]]:absolute [&>[data-slot=dialog-content-close]]:top-4 [&>[data-slot=dialog-content-close]]:right-4 [&>[data-slot=dialog-content-close]]:m-0 [&>[data-slot=dialog-content-close]]:opacity-100",children:[e.jsxs(X,{children:[e.jsx(ee,{children:"Choose agent access"}),e.jsx(te,{children:"Pick the actions each agent may take. Current access stays selected."})]}),e.jsx(ne,{className:"space-y-4 pb-4",children:o.isLoading?e.jsxs("div",{className:"space-y-3","aria-label":"Loading account actions",children:[e.jsx(O,{className:"h-20 rounded-lg"}),e.jsx(O,{className:"h-36 rounded-lg"})]}):o.loadFailed?e.jsx(Pt,{error:o.loadError,title:"Couldn’t load account actions",description:"Nothing changed. Try again.",onRetry:o.refresh,isRetrying:o.isLoading}):k?e.jsx(ks,{access:o}):u?e.jsxs(e.Fragment,{children:[f&&h&&e.jsxs("p",{"data-testid":"access-dialog-cause",className:"bg-status-warning-bg text-status-warning-fg rounded-lg p-3 text-sm",children:[h.copy.owner," If this looks right, confirm it."]}),e.jsx(Ni,{preview:u,selections:a,setSelections:i,advancedAgentId:r,setAdvancedAgentId:c})]}):null}),e.jsxs(ge,{children:[e.jsx(b,{variant:"ghost",onClick:()=>s(!1),children:d?"Done":m?"Close":"Cancel"}),p?e.jsx(b,{variant:"secondary",onClick:o.refresh,children:"Reload current access"}):m&&!d?e.jsxs(b,{variant:"secondary",onClick:o.checkSync,disabled:o.isCheckingSync,children:[e.jsx(bt,{className:"size-4","aria-hidden":!0}),o.isCheckingSync?"Checking…":"Check if it’s done"]}):!l&&u&&!d?e.jsx(b,{onClick:()=>o.apply(j,void 0,{confirm:N}),disabled:j.length===0&&!f||o.isSaving,children:o.isSaving?"Saving…":N?"Confirm access":"Save access"}):null]})]})})}function Ni({preview:t,selections:n,setSelections:s,advancedAgentId:a,setAdvancedAgentId:i}){return e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:t.connection.label}),e.jsx("p",{className:"text-muted-foreground text-xs",children:"Pick a level for each agent. Use Advanced for single actions."})]}),t.everyAgent.operationRevisionIds.length>0&&e.jsxs("div",{"data-testid":"exact-editor-every-agent",className:"bg-muted/40 space-y-1 rounded-lg p-3 text-sm",children:[e.jsxs("p",{children:["Every agent, even future ones, also has ",t.everyAgent.operationRevisionIds.length," ",t.everyAgent.operationRevisionIds.length===1?"action":"actions"," here."]}),e.jsx("p",{className:"text-muted-foreground",children:"The levels below don’t include them. To remove them, stop sharing with every agent."})]}),t.agents.length===0?e.jsx("p",{className:"bg-muted/40 rounded-lg p-4 text-sm",children:"No agents yet. Add one first."}):e.jsx("div",{className:"space-y-2",children:t.agents.map(r=>{const c=Zt(t.candidates),o=n[r.agentId],u=new Set((o==null?void 0:o.operationRevisionIds)??[]),m=(o==null?void 0:o.level)==="read"?"Read":(o==null?void 0:o.level)==="read-write"?"Read + write":u.size===0?"No access":"Custom access",d=a===r.agentId,p=l=>s({...n,[r.agentId]:{operationRevisionIds:xn(t.candidates,l),...l!=="none"&&{level:l}}});return e.jsxs("fieldset",{className:"bg-muted/40 rounded-lg p-3",children:[e.jsxs("legend",{className:"sr-only",children:["Access for ",r.displayName]}),e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-semibold",children:r.displayName}),e.jsx("p",{className:"text-muted-foreground text-xs",children:m})]}),e.jsx(b,{size:"sm",variant:"ghost","aria-expanded":d,onClick:()=>i(d?null:r.agentId),children:"Advanced"})]}),e.jsx("div",{className:"mt-2 grid grid-cols-3 gap-1.5","aria-label":`Quick access for ${r.displayName}`,children:[["none","No access"],["read","Read"],["read-write","Read + write"]].map(([l,h])=>e.jsx(b,{size:"sm",variant:m===h?"secondary":"outline","aria-pressed":m===h,onClick:()=>p(l),className:"px-2 text-xs",children:h},l))}),d&&e.jsx("ul",{className:"mt-3 space-y-1.5","data-testid":`advanced-access-${r.agentId}`,children:t.candidates.map(l=>{const h=u.has(l.operationRevisionId),f=!l.supported&&!h;return e.jsxs("li",{className:"bg-background flex gap-3 rounded-md p-2.5",children:[e.jsx(ft,{"aria-label":`${$e(l.operationSlug,t.connection.toolkit)} for ${r.displayName}`,checked:h,disabled:f,onCheckedChange:j=>{const k=new Set(u);j===!0?k.add(l.operationRevisionId):k.delete(l.operationRevisionId),s({...n,[r.agentId]:{operationRevisionIds:[...k].sort()}})}}),e.jsx("div",{className:"min-w-0 flex-1",children:e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[e.jsx("span",{className:"text-sm font-medium",children:$e(l.operationSlug,t.connection.toolkit)}),e.jsx(K,{size:"xs",variant:l.capabilityClassification==="destructive"?"destructive":"secondary",children:Bt[l.capabilityClassification]}),!l.supported&&e.jsx(K,{size:"xs",variant:"outline",children:"No longer available"}),c.has(l.operationRevisionId)&&e.jsx("span",{className:"text-muted-foreground text-xs",children:"Older version"})]})})]},l.operationRevisionId)})})]},r.agentId)})})]})}function ki({agentName:t,sessionStrategy:n,chatId:s,channelType:a,canInitiate:i=!1,canReply:r=!0,canReceive:c=!0}){return e.jsxs("div",{className:"text-muted-foreground flex items-center gap-2 text-sm",children:[e.jsx("span",{className:"truncate",children:t}),n!=="per-chat"&&e.jsx(K,{variant:"secondary",className:"shrink-0",children:Gs(n)}),s&&e.jsx(K,{variant:"outline",className:"shrink-0 truncate",children:a?`#${s}`:s}),e.jsxs(fn,{children:[i&&e.jsxs(we,{children:[e.jsx(Se,{asChild:!0,children:e.jsx(jn,{className:"size-3 shrink-0 text-amber-500","aria-label":"Can message first"})}),e.jsx(Ae,{children:"Can message first"})]}),!r&&e.jsxs(we,{children:[e.jsx(Se,{asChild:!0,children:e.jsx(Vs,{className:"text-muted-foreground/70 size-3 shrink-0","aria-label":"Can’t reply"})}),e.jsx(Ae,{children:"Can’t reply"})]}),!c&&e.jsxs(we,{children:[e.jsx(Se,{asChild:!0,children:e.jsx(yn,{className:"text-muted-foreground/70 size-3 shrink-0","aria-label":"Doesn’t receive messages"})}),e.jsx(Ae,{children:"Doesn’t receive messages"})]})]})]})}const Ci=["People you may not know can put text in front of your agent.","Permissions are the real limit. A bridged chat asks before acting by default.","Raise that only if you trust everyone in the chat.","The channel keeps the whole record: every message that reached your agent, for good."];function wi({binding:t,onDone:n}){const s=We({errorLabel:"Couldn’t bridge that chat"}),a=Be();if(t.bridge==="room")return e.jsx(Si,{binding:t,onDone:n});if(!t.chatId)return e.jsx(Re,{reason:"This reaches every chat here. Point it at one chat first."});if(t.platformChatType==="channel")return e.jsx(Re,{reason:"This is a broadcast channel, not a two-way chat. Your agent can’t reply."});const i=t.channelType==null||t.channelType==="dm";if(!(t.platformChatType==="private"||t.platformChatType==="group"||t.platformChatType==="supergroup"||t.platformChatType==null&&i))return e.jsx(Re,{reason:"DorkOS doesn’t know what kind of chat this is. Reconnect it from a new message."});async function c(){try{const o=await s.mutateAsync({id:t.id,updates:{bridge:"room"}});o.roomId&&a({...St.channels(),search:{id:o.roomId}}),n==null||n()}catch{}}return e.jsxs("section",{className:"border-border/60 space-y-3 rounded-lg border p-3","aria-labelledby":"bridge-heading",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(At,{className:"text-muted-foreground size-4"}),e.jsx("h4",{id:"bridge-heading",className:"text-sm font-medium",children:"Bridge to a channel"})]}),e.jsx("p",{className:"text-muted-foreground text-xs",children:"Messages land in a channel your agent reads. You can reply from there too."}),e.jsx("ul",{className:"text-muted-foreground space-y-1.5 text-xs",children:Ci.map(o=>e.jsxs("li",{className:"flex gap-1.5",children:[e.jsx("span",{"aria-hidden":!0,className:"text-muted-foreground/60",children:"•"}),e.jsx("span",{children:o})]},o))}),e.jsxs(b,{size:"sm",onClick:c,disabled:s.isPending,children:[s.isPending&&e.jsx(se,{size:"xs",className:"mr-1.5"}),"Bridge to a channel"]})]})}function Si({binding:t,onDone:n}){const s=We({errorLabel:"Couldn’t un-bridge that chat"}),a=vn(),{data:i}=bn(t.roomId??null),r=i!==void 0,c=(i==null?void 0:i.deliverNotices)??!1;async function o(){try{await s.mutateAsync({id:t.id,updates:{bridge:"off"}}),D.success("This chat is private again"),n==null||n()}catch{}}return e.jsxs("section",{className:"border-border/60 space-y-3 rounded-lg border p-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(At,{className:"text-muted-foreground size-4"}),e.jsx("p",{className:"text-sm font-medium",children:"This chat is a channel"})]}),t.roomId&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx(De,{htmlFor:"bridge-deliver-notices",className:"cursor-pointer text-xs font-normal",children:"Tell this chat when your agent stops early"}),e.jsx(Nn,{id:"bridge-deliver-notices",checked:c,disabled:!r||a.isPending,onCheckedChange:u=>a.mutate({roomId:t.roomId,deliverNotices:u}),"aria-label":"Tell this chat when your agent stops early"})]}),e.jsx("p",{className:"text-muted-foreground text-xs",children:"People in this chat see a short note."})]}),e.jsxs(pe,{children:[e.jsx(kn,{asChild:!0,children:e.jsx(b,{variant:"ghost",size:"sm",className:"text-muted-foreground",children:"Un-bridge this chat"})}),e.jsxs(xe,{children:[e.jsxs(fe,{children:[e.jsx(je,{children:"Un-bridge this chat?"}),e.jsx(ye,{children:"Its channel is archived. The chat goes back to a private, one-to-one line."})]}),e.jsxs(Qs,{children:[e.jsx("p",{children:"The channel and everything in it are kept."}),e.jsx("p",{children:"Bridging this chat again brings its history back."}),e.jsx("p",{children:"For a clean start with no old messages, archive the channel, then bridge again."})]}),e.jsxs(ve,{children:[e.jsx(be,{children:"Keep it bridged"}),e.jsx(Ne,{onClick:o,children:"Un-bridge"})]})]})]})]})}function Re({reason:t}){return e.jsxs("section",{className:"border-border/60 bg-muted/30 flex gap-2 rounded-lg border p-3",children:[e.jsx(Cn,{className:"text-muted-foreground mt-0.5 size-4 shrink-0"}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-sm font-medium",children:"Can’t bridge this chat"}),e.jsx("p",{className:"text-muted-foreground text-xs",children:t})]})]})}function Ai({adapterId:t,onQuickBind:n,onAdvanced:s,isPending:a,children:i}){const[r,c]=y.useState(!1),{data:o}=ie(),{data:u=[]}=ke(),m=y.useMemo(()=>new Set(u.filter(h=>h.adapterId===t).map(h=>h.agentId)),[u,t]),d=y.useMemo(()=>((o==null?void 0:o.agents)??[]).filter(h=>!m.has(h.id)),[o,m]);async function p(h){await n(h),c(!1)}function l(){c(!1),s()}return e.jsxs(wn,{open:r,onOpenChange:c,children:[e.jsx(Sn,{asChild:!0,children:i}),e.jsxs(An,{className:"w-56 p-0",align:"start",children:[e.jsxs(Js,{children:[e.jsx(Zs,{placeholder:"Search agents…"}),e.jsxs(Xs,{children:[e.jsx(ea,{children:"No agents to add"}),d.map(h=>e.jsxs(ta,{value:h.id,keywords:[Q(h)],onSelect:()=>p(h.id),disabled:a,children:[a?e.jsx(se,{size:"xs",className:"mr-2"}):null,Q(h)]},h.id))]})]}),e.jsx("div",{className:"border-t px-2 py-1.5",children:e.jsx(b,{variant:"ghost",size:"sm",className:"text-muted-foreground w-full text-xs",onClick:l,children:"Advanced…"})})]})]})}function Ii({instance:t,appName:n,emphasizePick:s=!0}){const{data:a=[]}=ke(),{data:i}=ie(),r=Us({suppressErrorToast:!0}),c=We({suppressErrorToast:!0}),o=Hs(),[u,m]=y.useState(null),[d,p]=y.useState(null),l=(i==null?void 0:i.agents)??[],h=g=>{const C=l.find(T=>T.id===g);return C?Q(C):g},f=a.filter(g=>g.adapterId===t.id);async function j(g){try{await r.mutateAsync({adapterId:t.id,agentId:g,sessionStrategy:"per-chat",label:""}),D.success(`${h(g)} answers ${n} now`)}catch(C){const T=_e(C,{id:g,name:h(g)});if(T){p(T);return}D.error(C instanceof Error?C.message:"Couldn’t set who answers")}}async function k(g){if(u)try{u.mode==="edit"?(await c.mutateAsync({id:u.binding.id,updates:Ks(g)}),D.success("Saved")):(await r.mutateAsync(Ys(g)),D.success(`${h(g.agentId)} answers ${n} now`)),m(null)}catch(C){const T=_e(C,{id:g.agentId,name:h(g.agentId)});if(T){p(T);return}D.error(C instanceof Error?C.message:"Couldn’t save that")}}async function N(g){try{await o.mutateAsync(g),D.success("Removed"),m(null)}catch{}}const A=(g,C)=>e.jsx(Ai,{adapterId:t.id,onQuickBind:j,onAdvanced:()=>m({mode:"create"}),isPending:r.isPending,children:e.jsxs(b,{variant:C,size:"sm",children:[e.jsx(In,{className:"size-3.5","aria-hidden":!0}),g]})}),x=(u==null?void 0:u.mode)==="edit"?u.binding:null;return e.jsxs("div",{className:"space-y-2","data-testid":"chat-app-answerers",children:[f.length===0?e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-muted-foreground text-sm",children:"No agent answers yet. Messages wait until you pick one."}),A("Pick who answers",s?"default":"outline")]}):e.jsxs(e.Fragment,{children:[e.jsx("ul",{className:"-mx-2 space-y-0.5",children:f.map(g=>e.jsx("li",{children:e.jsxs("button",{type:"button",onClick:()=>m({mode:"edit",binding:g}),className:"group/row hover:bg-muted/50 focus-ring flex min-h-10 w-full items-center gap-2 rounded-lg px-2 py-1.5 text-left transition-colors",children:[e.jsx(ki,{agentName:h(g.agentId),sessionStrategy:g.sessionStrategy,chatId:g.chatId,channelType:g.channelType,canInitiate:g.canInitiate,canReply:g.canReply,canReceive:g.canReceive}),e.jsx(ae,{className:"text-muted-foreground ml-auto size-4 shrink-0","aria-hidden":!0})]})},g.id))}),A("Add an agent","ghost")]}),u&&e.jsx(Ws,{open:!0,onOpenChange:g=>{g||m(null)},mode:u.mode,initialValues:x?{adapterId:x.adapterId,agentId:x.agentId,sessionStrategy:x.sessionStrategy,label:x.label??"",permissionMode:x.permissionMode,chatId:x.chatId,channelType:x.channelType,canInitiate:x.canInitiate,canReply:x.canReply,canReceive:x.canReceive}:{adapterId:t.id},adapterName:n,agentName:x?h(x.agentId):void 0,onConfirm:k,onDelete:x?N:void 0,bindingId:x==null?void 0:x.id,isPending:r.isPending||c.isPending||o.isPending,bridged:(x==null?void 0:x.bridge)==="room",bridgeSlot:x?e.jsx(wi,{binding:x,onDone:()=>m(null)}):void 0}),e.jsx(Wt,{conflict:d,onClose:()=>p(null),onMoved:()=>m(null)})]})}const Ri={"adapter.connected":"bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-200","adapter.message_sent":"bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-200","adapter.disconnected":"bg-red-100 text-red-800 dark:bg-red-900 dark:text-red-200","adapter.error":"bg-red-100 text-red-800 dark:bg-red-900 dark:text-red-200","adapter.message_received":"bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-200","adapter.status_change":"bg-amber-100 text-amber-800 dark:bg-amber-900 dark:text-amber-200"},Oe={"adapter.connected":"Connected","adapter.disconnected":"Disconnected","adapter.message_received":"Received","adapter.message_sent":"Sent","adapter.error":"Error","adapter.status_change":"Status"},$i=Object.keys(Oe);function Ti({adapterId:t}){const{data:n,isLoading:s}=Ut(t),[a,i]=y.useState("all"),r=y.useRef(null),[c,o]=y.useState(!0),u=y.useCallback(()=>{const l=r.current;if(!l)return;o(l.scrollHeight-l.scrollTop-l.clientHeight<20)},[]);y.useEffect(()=>{c&&r.current&&(r.current.scrollTop=r.current.scrollHeight)},[n,c]);const m=()=>{r.current&&(r.current.scrollTop=r.current.scrollHeight,o(!0))};if(s)return e.jsx("div",{className:"space-y-2 p-3",children:[1,2,3,4].map(l=>e.jsx(O,{className:"h-6 w-full"},l))});const d=(n==null?void 0:n.events)??[],p=a==="all"?d:d.filter(l=>l.subject===a);return d.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 p-6 text-center",children:[e.jsx(Rn,{className:"text-muted-foreground size-6"}),e.jsx("p",{className:"text-muted-foreground text-sm",children:"No events yet"})]}):e.jsxs("div",{className:"flex h-full flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between border-b px-3 py-2",children:[e.jsx("h4",{className:"text-muted-foreground text-xs font-semibold tracking-wide uppercase",children:"Events"}),e.jsxs(Nt,{value:a,onValueChange:i,children:[e.jsx(kt,{responsive:!1,className:"h-7 w-[130px] text-xs",children:e.jsx(Ct,{})}),e.jsxs(wt,{children:[e.jsx(Te,{value:"all",children:"All types"}),$i.map(l=>e.jsx(Te,{value:l,children:Oe[l]},l))]})]})]}),e.jsx("div",{ref:r,onScroll:u,className:"flex-1 overflow-y-auto p-2",children:p.map(l=>{const h=l.metadata?JSON.parse(l.metadata):null,f=new Date(l.sentAt).toLocaleTimeString("en-US",{hour12:!1,hour:"2-digit",minute:"2-digit",second:"2-digit"});return e.jsxs("div",{className:"flex items-start gap-2 py-1",children:[e.jsx("span",{className:"text-muted-foreground shrink-0 font-mono text-xs tabular-nums",children:f}),e.jsx(K,{size:"xs",variant:"secondary",className:q("shrink-0",Ri[l.subject]??""),children:Oe[l.subject]??l.subject}),e.jsx("span",{className:"text-xs break-words",children:(h==null?void 0:h.message)??l.subject})]},l.id)})}),!c&&e.jsx("div",{className:"flex justify-center border-t py-1",children:e.jsxs(b,{variant:"ghost",size:"sm",onClick:m,className:"h-6 text-xs",children:[e.jsx($n,{className:"mr-1 size-3"}),"Jump to bottom"]})})]})}const _i=3,Ei={"adapter.message_received":"A message came in","adapter.message_sent":"A reply went out","adapter.connected":"Connected","adapter.disconnected":"Disconnected","adapter.status_change":"Its status changed"};function Oi(t){if(!t)return null;try{return JSON.parse(t)}catch{return null}}function Pi(t,n){if(t==="adapter.error"){const s=Oi(n);return s!=null&&s.message?`Something went wrong: ${s.message}`:"Something went wrong"}return Ei[t]??t}function Li({adapterId:t}){const{data:n,isPending:s,isError:a,refetch:i}=Ut(t),[r,c]=y.useState(!1),o=(n==null?void 0:n.events)??[],[u,m]=y.useState(null);return s?e.jsx(O,{className:"h-16 rounded-lg"}):a?e.jsxs("p",{className:"text-muted-foreground flex items-center gap-2 text-sm",children:["Couldn’t load what happened here.",e.jsx(b,{variant:"link",size:"xs",className:"h-auto p-0",onClick:()=>void i(),children:"Try again"})]}):o.length===0?e.jsx("p",{className:"text-muted-foreground text-sm",children:"Nothing yet."}):r?e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"bg-muted/30 h-72 overflow-hidden rounded-lg",children:e.jsx(Ti,{adapterId:t})}),e.jsx(b,{variant:"link",size:"xs",className:"h-auto p-0",onClick:()=>c(!1),children:"Show less"})]}):e.jsxs("div",{className:"space-y-2",children:[e.jsx("ul",{className:"space-y-1.5",children:o.slice(0,_i).map(d=>{const p=Pi(d.subject,d.metadata),l=u===d.id,h=e.jsx("span",{className:"text-muted-foreground shrink-0 text-xs",children:Le(d.sentAt)});return d.subject==="adapter.error"?e.jsx("li",{children:e.jsxs("button",{type:"button","aria-expanded":l,onClick:()=>m(l?null:d.id),className:"focus-ring hover:bg-muted/50 -mx-1 flex w-full items-baseline justify-between gap-3 rounded px-1 text-left text-sm",children:[e.jsx("span",{className:q("min-w-0",l?"break-words":"truncate"),children:p}),h]})},d.id):e.jsxs("li",{className:"flex items-baseline justify-between gap-3 text-sm",children:[e.jsx("span",{className:"min-w-0 truncate",children:p}),h]},d.id)})}),e.jsx(b,{variant:"link",size:"xs",className:"h-auto p-0",onClick:()=>c(!0),children:"See all"})]})}function Di({row:t,open:n,onOpenChange:s,onCloseAutoFocus:a,children:i}){const r=Tn(),[c,o]=y.useState({open:n,mobile:r});let u=c.mobile;(c.open!==n||!n&&c.mobile!==r)&&(o({open:n,mobile:r}),u=r);const m=t&&e.jsxs("div",{className:"flex items-center gap-3 pr-8",children:[e.jsx(pt,{iconKey:t.iconKey,displayName:t.name,logo:t.logo,className:"size-10 rounded-lg"}),e.jsxs("div",{className:"min-w-0 flex-1 text-left",children:[e.jsxs(ct,{mobile:u,className:"flex items-center gap-2 text-base font-semibold",children:[e.jsx("span",{className:"truncate",children:t.name}),t.kind==="chat"&&e.jsx(K,{size:"xs",variant:"secondary",children:"Chat"})]}),e.jsxs(lt,{mobile:u,className:"text-muted-foreground flex min-w-0 items-center gap-1.5 text-xs",children:[t.account&&e.jsx("span",{className:"truncate",children:t.identity?`${t.account} · ${t.identity}`:t.account}),t.tone==="ready"&&e.jsxs("span",{className:"flex shrink-0 items-center gap-1.5",children:[t.account&&e.jsx("span",{"aria-hidden":!0,children:"·"}),e.jsx("span",{className:q("size-2 rounded-full",xt.success),"aria-hidden":!0}),"Connected"]})]})]})]}),d=e.jsxs(e.Fragment,{children:[e.jsx(ct,{mobile:u,className:"sr-only",children:"App details"}),e.jsx(lt,{mobile:u,className:"sr-only",children:"Loading this app."})]});return u?e.jsx(_n,{open:n,onOpenChange:s,children:e.jsxs(En,{className:"max-h-[88vh] outline-none","data-testid":"app-panel",onOpenAutoFocus:rt,onCloseAutoFocus:a,children:[e.jsx("div",{className:"px-4 pt-3 pb-3",children:m??d}),e.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto px-4 pb-6",children:i})]})}):e.jsx(On,{open:n,onOpenChange:s,children:e.jsxs(Pn,{className:"w-full gap-0 outline-none","data-testid":"app-panel",onOpenAutoFocus:rt,onCloseAutoFocus:a,children:[e.jsx("div",{className:"px-6 pt-5 pb-4",children:m??d}),e.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto px-6 pb-8",children:i})]})})}function rt(t){var n;t.preventDefault(),(n=t.currentTarget)==null||n.focus()}function ct({mobile:t,className:n,children:s}){return t?e.jsx(Ln,{className:n,children:s}):e.jsx(Dn,{className:n,children:s})}function lt({mobile:t,className:n,children:s}){return t?e.jsx(zn,{className:n,children:s}):e.jsx(Fn,{className:n,children:s})}function zi({service:t,onClose:n,onChooseChat:s,onChooseAccount:a}){const i=(t==null?void 0:t.displayName)??"";return e.jsx(J,{open:t!==null,onOpenChange:r=>!r&&n(),children:e.jsxs(Z,{className:"min-h-0 sm:max-w-md","data-testid":"app-use-choice",children:[e.jsxs(X,{children:[e.jsxs(ee,{children:["Connect ",i]}),e.jsx(te,{children:"What do you want to do?"})]}),e.jsxs(ne,{className:"space-y-2 pb-5",children:[e.jsx(dt,{icon:e.jsx(Mn,{className:"size-4","aria-hidden":!0}),title:`Talk to my agents in ${i}`,detail:`Your agents get a ${i} bot. You message it, they answer.`,onClick:()=>t&&s(t)}),e.jsx(dt,{icon:e.jsx(Bn,{className:"size-4","aria-hidden":!0}),title:`Let agents use my ${i}`,detail:"Agents can read and post as you.",onClick:()=>t&&a(t)})]})]})})}function dt({icon:t,title:n,detail:s,onClick:a}){return e.jsxs("button",{type:"button",onClick:a,className:"bg-muted/40 hover:bg-muted/70 focus-ring flex w-full items-start gap-3 rounded-xl p-3.5 text-left transition-colors",children:[e.jsx("span",{className:"bg-background text-muted-foreground flex size-8 shrink-0 items-center justify-center rounded-lg",children:t}),e.jsxs("span",{className:"min-w-0",children:[e.jsx("span",{className:"block text-sm font-medium",children:n}),e.jsx("span",{className:"text-muted-foreground block text-xs",children:s})]})]})}function Fi({entry:t,instance:n,onClose:s}){const{manifest:a}=t,i=It(),r=_s(),c=mt(),[o,u]=y.useState(null),[m,d]=y.useState(!1),p=n.status.state==="error"||n.status.state==="disconnected",l=h=>i.mutate({id:n.id,enabled:h});return e.jsxs("div",{className:"space-y-7",children:[n.enabled?p?e.jsx(Ee,{message:"Stopped working. Messages aren’t getting through.",technicalDetail:n.status.lastError,action:"Check its settings",onAction:()=>u("edit")}):null:e.jsx(Ee,{message:"Paused. No messages go in or out.",action:"Resume",pending:i.isPending,onAction:()=>l(!0)}),e.jsx(me,{title:"Who answers",children:e.jsx(Ii,{instance:n,appName:a.displayName,emphasizePick:n.enabled&&!p})}),e.jsx(vi,{enabled:!0,adapterId:n.id}),e.jsx(me,{title:"Recently",children:e.jsx(Li,{adapterId:n.id})}),e.jsxs(le,{children:[e.jsxs(de,{className:"group/more text-muted-foreground hover:text-foreground focus-ring flex w-full items-center justify-between rounded-md py-1 text-sm font-semibold",children:["More",e.jsx(ae,{className:"size-4 transition-transform group-data-[state=open]/more:rotate-90","aria-hidden":!0})]}),e.jsxs(ue,{className:"-mx-2 space-y-1 pt-2","data-testid":"app-panel-more",children:[e.jsx(M,{label:"Settings",hint:"Who can message it, group chats, and its token",onClick:()=>u("edit")}),n.enabled?e.jsx(M,{label:"Pause",hint:"No messages in or out until you resume",disabled:i.isPending,onClick:()=>l(!1)}):e.jsx(M,{label:"Resume",disabled:i.isPending,onClick:()=>l(!0)}),a.multiInstance&&e.jsx(M,{label:`Set up another ${a.displayName}`,onClick:()=>u("add")}),e.jsx(M,{label:"Remove…",destructive:!0,onClick:()=>d(!0)})]})]}),o&&e.jsx(qt,{open:!0,onOpenChange:h=>{h||u(null)},manifest:a,existingInstance:o==="edit"?n:void 0,existingAdapterIds:t.instances.map(h=>h.id)}),e.jsx(pe,{open:m,onOpenChange:d,children:e.jsxs(xe,{children:[e.jsxs(fe,{children:[e.jsxs(je,{children:["Remove ",a.displayName,"?"]}),e.jsx(ye,{asChild:!0,children:e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{children:"It stops working and its settings are deleted."}),e.jsx("p",{children:"So are its recent deliveries."}),e.jsx("p",{children:"Its list of people who messaged it is deleted, names included."}),e.jsx("p",{children:"That includes anyone ignored or blocked."}),e.jsx("p",{children:"Messages sent to it after that reach nobody."}),e.jsx("p",{children:"If you set it up again, block anyone you blocked again."})]})})]}),e.jsxs(ve,{children:[e.jsx(be,{children:"Keep it"}),e.jsxs(Ne,{className:"bg-destructive hover:bg-destructive/90 dark:bg-destructive/60 text-white",onClick:()=>{r.mutate(n.id,{onSuccess:()=>{c.invalidateQueries({queryKey:[...Ts]}),s()}})},children:["Remove ",a.displayName]})]})]})})]})}function Mi(){var c;const t=zt(),n=Ft(t.enabled),[s,a]=y.useState(null),i=y.useCallback(o=>{var m;const u=t.enabled?(m=n.data)==null?void 0:m.find(d=>d.manifest.type===o):void 0;if(u&&(u.instances.length===0||u.manifest.multiInstance)){a(u.manifest);return}D.error("Chat apps aren’t ready. Try again in a moment.")},[n.data,t.enabled]),r=s?e.jsx(qt,{open:!0,onOpenChange:o=>{o||a(null)},manifest:s,existingAdapterIds:(c=n.data)==null?void 0:c.flatMap(o=>o.instances.map(u=>u.id))}):null;return{open:i,dialog:r}}function Bi(){var Ye,He,Ge,Ve,Qe;const t=qn({from:"/_shell/connections"}),n=Be({from:"/connections"}),s=y.useCallback(v=>void n({search:B=>{const V={...B,...v};for(const Je of Object.keys(v))V[Je]===void 0&&delete V[Je];return V}}),[n]),[a,i]=y.useState(""),r=y.useDeferredValue(a),[c,o]=y.useState(null),[u,m]=y.useState(!!t.flow),[d,p]=y.useState(null),[l,h]=y.useState(null),f=Mi(),j=y.useRef(null),k=v=>ut(v,j),N=y.useRef(null),A=v=>ut(v,N),x=t.request?null:t.flow??null,g=Et(x),C=(Ye=g.data)==null?void 0:Ye.state,T=(He=g.data)==null?void 0:He.toolkit,Y=y.useMemo(()=>!u&&x&&T&&(C==="starting"||C==="pending")?{flowId:x,toolkit:T}:null,[u,x,C,T]),S=Sa(r,Y),{relay:$}=S,w=_t(),E=qe(),z=It(),U=ze(),I=w.error??E.error,L=w.isPending&&((Ge=w.variables)==null?void 0:Ge.connectionId)||E.isPending&&((Ve=E.variables)==null?void 0:Ve.connectionId)||z.isPending&&((Qe=z.variables)==null?void 0:Qe.id)||null,P=v=>{o(null),s({flow:v,app:void 0}),m(!0)},F=v=>{o(v),m(!0)},re=v=>{const B=Yt(v,S.owned),V=$.enabled?B.chatType:null;if(B.account&&V){h(v);return}if(V){f.open(V);return}F(v)},ce=v=>{switch(v.action){case"sign-in-again":w.mutate({connectionId:v.id},{onSuccess:B=>P(B.flowId)});return;case"resume":v.kind==="chat"?z.mutate({id:v.id,enabled:!0}):E.mutate({connectionId:v.id,input:void 0});return;case"cancel":s({flow:void 0});return;case"review":p(v.id);return;case"fix":s({app:v.id});return;case"fix-key":U.open("connections","ways");return;case"connect-again":{const B=v.toolkit?S.services.get(v.toolkit):void 0;B?F(B):s({app:v.id});return}case null:return}},_=t.app?S.allYours.find(v=>v.id===t.app&&v.kind!=="connecting")??null:null,R=(_==null?void 0:_.kind)==="chat"?qi(S.chatApps,_.id):null;y.useEffect(()=>{t.app&&!S.yoursLoading&&!S.yoursRefreshing&&!S.yoursError&&!_&&s({app:void 0})},[t.app,S.yoursLoading,S.yoursRefreshing,S.yoursError,_,s]);const H=()=>s({app:void 0,who:void 0});return e.jsxs(Zn,{width:"reading",children:[e.jsxs("header",{className:"mb-6",children:[e.jsx(Un,{children:"Connections"}),e.jsx("p",{className:"text-muted-foreground text-sm",children:"Apps your agents use, and where you reach them."})]}),e.jsxs("div",{className:"space-y-8",children:[e.jsx(si,{services:S.services,onOpenRequest:v=>{j.current=document.activeElement,s({request:v})},onOpenReview:v=>{j.current=document.activeElement,s({review:v})}}),I&&e.jsx("p",{role:"alert","data-testid":"row-action-error",className:"text-destructive bg-destructive/5 rounded-lg p-3 text-sm",children:Vt(I)}),e.jsx(ka,{query:a,onQueryChange:i,data:S,onOpenRow:v=>{if(v.kind==="connecting"){m(!0);return}N.current=document.activeElement,s({app:v.id,who:void 0})},onRowAction:ce,pendingRowId:L,onConnect:re}),e.jsx(Wi,{})]}),e.jsxs(Di,{row:_,open:_!==null,onOpenChange:v=>{v||H()},onCloseAutoFocus:A,children:[(_==null?void 0:_.kind)==="account"&&e.jsx(Ya,{connectionId:_.id,startWho:t.who,onSignInStarted:P,onEditExactActions:p,onAddAnother:v=>{H(),F(S.services.get(v)??Ui(v,_.name))},onClose:H},_.id),(_==null?void 0:_.kind)==="chat"&&R&&e.jsx(Fi,{entry:R.entry,instance:R.instance,onClose:H},_.id)]}),u&&e.jsx(xi,{service:c,flowId:t.flow??null,onFlowIdChange:v=>s({flow:v??void 0}),onClose:()=>{m(!1),o(null)},onChooseAccess:p,onConnected:v=>s({app:v})},t.flow??(c==null?void 0:c.serviceSlug)??"idle"),e.jsx(ii,{requestId:t.request??null,open:!!t.request&&!u,onOpenChange:v=>{v||s({request:void 0})},onEditExactActions:v=>{s({request:void 0}),p(v)},onCloseAutoFocus:k}),e.jsx(ci,{reviewRequestId:t.review??null,open:!!t.review,onOpenChange:v=>{v||s({review:void 0})},onCloseAutoFocus:k},t.review??"closed"),e.jsx(bi,{connectionId:d,open:d!==null,onOpenChange:v=>{v||p(null)}},d??"closed"),e.jsx(zi,{service:l,onClose:()=>h(null),onChooseChat:v=>{h(null);const B=Ke(v).chatType;B&&f.open(B)},onChooseAccount:v=>{h(null),F(v)}}),f.dialog]})}function ut(t,n){t.preventDefault();const s=n.current;n.current=null,s!=null&&s.isConnected?s.focus():Wn()}function qi(t,n){for(const s of t){const a=s.instances.find(i=>i.id===n);if(a)return{entry:s,instance:a}}return null}function Ui(t,n){return{serviceSlug:t,displayName:n,iconKey:t,intents:[{kind:"account",displayName:`Use a ${n} account`,routes:[]}]}}function Wi(){const t=ze();return e.jsxs("p",{className:"text-muted-foreground text-xs",children:["Prefer your own Composio or Nango account?"," ",e.jsx(b,{variant:"link",className:"h-auto p-0 text-xs",onClick:()=>t.open("connections","ways"),children:"Set it up in Settings › Connections"})]})}const bo=Bi;export{bo as component};
@@ -1 +0,0 @@
1
- import{j as t}from"./index-8-iQ6PnT.js";import{M as o}from"./Marketplace-CIG5_a_H.js";import{P as r}from"./page-container-Bb-_N7lw.js";import"./PreviewRefusedNotice-BANdpT9O.js";import"./shield-x-B0W_7qwR.js";import"./card-Dj6ZfRgu.js";import"./empty-state-kISAAp0z.js";import"./markdown-content-D0FpU2cz.js";import"./use-unclaimed-chats-Db_wuzt0.js";import"./use-bindings-BV6HA0MD.js";import"./UnlinkDialog-Di1oBFA_.js";import"./use-dev-links-k4YWFO1v.js";import"./more-details-CadxnGyH.js";import"./terminal-Dw2QZ7Dh.js";import"./file-DEt4KgZG.js";import"./AgentPicker-CBYeBzjf.js";import"./command-BAOEURY7.js";import"./AgentOptionRow-DI1TzLaR.js";import"./useMutationState-BvwBDXKc.js";import"./file-exclamation-point-QqXJhXD9.js";import"./rotate-ccw-clock-DiuTseKz.js";import"./path-input-BIfexEKz.js";function i(){return t.jsx(r,{width:"wide",children:t.jsx(o,{})})}const S=i;export{S as component};
@@ -1 +0,0 @@
1
- import{j as o}from"./index-8-iQ6PnT.js";import{P as r}from"./page-container-Bb-_N7lw.js";import{M as e}from"./MarketplaceSourcesView-16HKvFK-.js";import"./use-pending-read-Do0_vZ2I.js";function t(){return o.jsx(r,{width:"reading",children:o.jsx(e,{})})}const s=t;export{s as component};