dorkos 0.114.0 → 0.114.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (180) hide show
  1. package/dist/bin/cli.js +1516 -1029
  2. package/dist/browser/native/package-manifest.json +1 -1
  3. package/dist/browser/source-manifest.json +1 -1
  4. package/dist/client/assets/{AboutPage-mErbIY0l.js → AboutPage-BRHiWrvg.js} +1 -1
  5. package/dist/client/assets/{ActivityErrorState-AlI4F82u.js → ActivityErrorState-DGwKpdjB.js} +1 -1
  6. package/dist/client/assets/{ActivityPage-CHUqb-8c.js → ActivityPage-C-lpXfva.js} +1 -1
  7. package/dist/client/assets/{ActivityRow-Baqdr6cP.js → ActivityRow-TjAMUrcU.js} +1 -1
  8. package/dist/client/assets/AdapterIcon-B-NJfk_R.js +1 -0
  9. package/dist/client/assets/{AdapterSetupWizard-BL70qy2J.js → AdapterSetupWizard-CrdiWINL.js} +2 -2
  10. package/dist/client/assets/{AgentRequestCard-CcMh6JyE.js → AgentRequestCard-BRINjair.js} +1 -1
  11. package/dist/client/assets/{AppearancePage-t9SnSRs-.js → AppearancePage-COdpfn1g.js} +1 -1
  12. package/dist/client/assets/{AttentionSignalRow-jlgWaSSd.js → AttentionSignalRow-Dc8laCri.js} +1 -1
  13. package/dist/client/assets/{BaseTanStackRouterDevtoolsPanel-B-iktbLX-DHr_AhUv.js → BaseTanStackRouterDevtoolsPanel-B-iktbLX-C-BpNthi.js} +3 -3
  14. package/dist/client/assets/{BlintzCanvas-Bq4e7n__.js → BlintzCanvas-DCU4iOtF.js} +1 -1
  15. package/dist/client/assets/{CanvasCsvContent-OR226CLS.js → CanvasCsvContent-oayJjsGq.js} +1 -1
  16. package/dist/client/assets/{CanvasFileContent-BejM-9Wg.js → CanvasFileContent-C-aDKKws.js} +2 -2
  17. package/dist/client/assets/{CanvasModel3dContent-BD-eCVsX.js → CanvasModel3dContent-Dnx6oUx2.js} +2 -2
  18. package/dist/client/assets/{CodeMirrorDiff-D7BWMOim.js → CodeMirrorDiff-j0jAFw_i.js} +1 -1
  19. package/dist/client/assets/{CodeMirrorEditor-BodwsIG7.js → CodeMirrorEditor-DWgnGEHZ.js} +1 -1
  20. package/dist/client/assets/{CommitmentList-YVb3yTvO.js → CommitmentList-CCsDbGY2.js} +1 -1
  21. package/dist/client/assets/{CommitmentsPage-DL_jJQbw.js → CommitmentsPage-_vCusfuJ.js} +1 -1
  22. package/dist/client/assets/{ConnectionAccessLists-BPsgToSR.js → ConnectionAccessLists-umV6IbYS.js} +1 -1
  23. package/dist/client/assets/{ConnectionsPage-D7vlYnjf.js → ConnectionsPage-2iGwApEi.js} +2 -2
  24. package/dist/client/assets/{ConventionPage-BR7I3AdE.js → ConventionPage-Bucu3-TK.js} +3 -3
  25. package/dist/client/assets/{ExtensionPageRoute-CzXGvVRm.js → ExtensionPageRoute-XXcMwrQY.js} +2 -2
  26. package/dist/client/assets/{FloatingTanStackRouterDevtools-CqogiFob-BV3h0rFa.js → FloatingTanStackRouterDevtools-CqogiFob-C8yf1gK7.js} +1 -1
  27. package/dist/client/assets/HandlePage-BotSAp8X.js +1 -0
  28. package/dist/client/assets/{HeartbeatPage-CfjZuvtQ.js → HeartbeatPage-CVAZeDqg.js} +1 -1
  29. package/dist/client/assets/{LexicalField-Cc6wFZAZ.js → LexicalField-Dr5vnDVn.js} +1 -1
  30. package/dist/client/assets/{ManagesPage-BxHSb65X.js → ManagesPage-Dj_UOeFQ.js} +1 -1
  31. package/dist/client/assets/{Marketplace-EgG6JmBG.js → Marketplace-RwZrKU4O.js} +2 -2
  32. package/dist/client/assets/{MarketplaceSourcesView-D9kq9hl6.js → MarketplaceSourcesView-xSimTjA0.js} +1 -1
  33. package/dist/client/assets/{McpAppFrame-6zxszx9A.js → McpAppFrame-Er6EX82b.js} +2 -2
  34. package/dist/client/assets/{McpSigninBody-DBWSc6bm.js → McpSigninBody-DMK94EGx.js} +1 -1
  35. package/dist/client/assets/{Model3dViewer-CgeJ2v-F.js → Model3dViewer-D5xu-FCi.js} +1 -1
  36. package/dist/client/assets/NamePage-NZ40HlPR.js +1 -0
  37. package/dist/client/assets/{NewDirectMessageMenu-BnBO4aGI.js → NewDirectMessageMenu-DiI_GTiE.js} +1 -1
  38. package/dist/client/assets/{NotificationsPage-C5aRITCd.js → NotificationsPage-B_XMIlHt.js} +1 -1
  39. package/dist/client/assets/{OpenMeshSwitch-UKMQeS7-.js → OpenMeshSwitch-BjiejioP.js} +2 -2
  40. package/dist/client/assets/{OperatorIdentityForm-DH2au7QU.js → OperatorIdentityForm-H7l8r2VC.js} +1 -1
  41. package/dist/client/assets/{PermissionsPage-BgLLmdg2.js → PermissionsPage-DVV9vtoW.js} +1 -1
  42. package/dist/client/assets/{PersonalityPopover-vLDfndfo.js → PersonalityPopover-BT-aQ65s.js} +1 -1
  43. package/dist/client/assets/PhotoPage-DKgOQCBH.js +1 -0
  44. package/dist/client/assets/{PreviewRefusedNotice-Dh3SCC_A.js → PreviewRefusedNotice-DJyQxUFv.js} +1 -1
  45. package/dist/client/assets/{PromptSuggestionChips-EO_0zbzq.js → PromptSuggestionChips-Dw7RA2P1.js} +1 -1
  46. package/dist/client/assets/{ReportsToPopover-C9Ceg1AW.js → ReportsToPopover-fxu1r9iw.js} +1 -1
  47. package/dist/client/assets/{RoomSurface-B8ec3_at.js → RoomSurface-D4Etqadg.js} +5 -5
  48. package/dist/client/assets/{RoomsPage-pPw8vrsB.js → RoomsPage-D0795GTq.js} +1 -1
  49. package/dist/client/assets/{RunsOnPopover-CJoSj8w7.js → RunsOnPopover-Cp8EMGHD.js} +1 -1
  50. package/dist/client/assets/{RuntimeSetupDialog-Cqn_Grel.js → RuntimeSetupDialog-Cxtz9b_r.js} +1 -1
  51. package/dist/client/assets/{SessionsPage-BASybh9v.js → SessionsPage-DbIKrtbg.js} +1 -1
  52. package/dist/client/assets/{SkillsPage-DL0909et.js → SkillsPage-DYSIGciZ.js} +1 -1
  53. package/dist/client/assets/{TasksPage-BwUW6dia.js → TasksPage-DoEP7ZsZ.js} +1 -1
  54. package/dist/client/assets/{ToolsPage-C3xfGWdb.js → ToolsPage-gUYaNA1-.js} +2 -2
  55. package/dist/client/assets/{TopologyGraph-D7Ik1Xt6.js → TopologyGraph-KPxRfshp.js} +1 -1
  56. package/dist/client/assets/{TourHost-Db0fxAXo.js → TourHost-BIozl4IA.js} +1 -1
  57. package/dist/client/assets/{UnlinkDialog-TTK5Z_QD.js → UnlinkDialog-RuuQUyOF.js} +1 -1
  58. package/dist/client/assets/{WidgetErrorCard-D--KcgW1.js → WidgetErrorCard-BojvLOeP.js} +4 -4
  59. package/dist/client/assets/{_shell-CGWsN6Gs.js → _shell-BMQyJ7r4.js} +4 -4
  60. package/dist/client/assets/{_shell._home-CzpVyTzo.js → _shell._home-C-OJaDmg.js} +1 -1
  61. package/dist/client/assets/{_shell._home.activity-BbWquOK0.js → _shell._home.activity-Bvsxue6y.js} +1 -1
  62. package/dist/client/assets/{_shell._home.index-Cg0nRFMN.js → _shell._home.index-DXnd_q3h.js} +2 -2
  63. package/dist/client/assets/{_shell._home.tasks-BpoOVihw.js → _shell._home.tasks-Mz-iO--x.js} +1 -1
  64. package/dist/client/assets/_shell._home.workspaces-ChuVp2dK.js +1 -0
  65. package/dist/client/assets/{_shell.channels-CCGSs0Bn.js → _shell.channels-Cpde6Iix.js} +3 -3
  66. package/dist/client/assets/_shell.connections-CxgvSPjQ.js +1 -0
  67. package/dist/client/assets/{_shell.feedback-requests-C6alx2ox.js → _shell.feedback-requests-BBEuotuF.js} +2 -2
  68. package/dist/client/assets/_shell.marketplace-Hk6n4nNt.js +1 -0
  69. package/dist/client/assets/_shell.marketplace_.sources-B8f38K6K.js +1 -0
  70. package/dist/client/assets/_shell.session-DsF1tXPP.js +66 -0
  71. package/dist/client/assets/{_shell.team-BIwJNdkd.js → _shell.team-4bF5Nn4_.js} +5 -5
  72. package/dist/client/assets/_shell.x._extensionId-B6J6mDaT.js +1 -0
  73. package/dist/client/assets/_shell.x._extensionId_._-B6J6mDaT.js +1 -0
  74. package/dist/client/assets/{agent-browser-CO5haI5Y.js → agent-browser-BIsnzdje.js} +1 -1
  75. package/dist/client/assets/{banner-Dh5mO27l.js → banner-Dll8KWyW.js} +2 -2
  76. package/dist/client/assets/{card-CKZCX8ol.js → card-5POMzMJ6.js} +1 -1
  77. package/dist/client/assets/{file-CMPbZedq.js → file-CY9v6yos.js} +1 -1
  78. package/dist/client/assets/{file-exclamation-point-emLeXvmw.js → file-exclamation-point-DNS4eVZR.js} +1 -1
  79. package/dist/client/assets/{file-text-9a0DChCq.js → file-text-BQ5NBk6w.js} +1 -1
  80. package/dist/client/assets/{find-latest-widget-fence--3kWMT1F.js → find-latest-widget-fence-BC8zM39x.js} +3 -3
  81. package/dist/client/assets/{git-branch-hfu8isLA.js → git-branch-34CUrn_R.js} +1 -1
  82. package/dist/client/assets/{heart-SRafwnSd.js → heart-B5oPCBeT.js} +1 -1
  83. package/dist/client/assets/{highlighted-body-KPVGNVTW-Dxwd3mxT.js → highlighted-body-KPVGNVTW-DeDxlHr7.js} +1 -1
  84. package/dist/client/assets/{index-D67aFWxz.js → index-BCJdsNmC.js} +1 -1
  85. package/dist/client/assets/{index-BDfoFNcA.js → index-BM9_nnxH.js} +1 -1
  86. package/dist/client/assets/{index-DX-j3Ul0.js → index-BTkflOTk.js} +1 -1
  87. package/dist/client/assets/{index-CbFo-7kM.js → index-BWj2VXUd.js} +1 -1
  88. package/dist/client/assets/{index-C4nEz6I-.js → index-BZYcFunZ.js} +1 -1
  89. package/dist/client/assets/{index-D_Wc_qTa.js → index-B_LR9e6q.js} +3 -3
  90. package/dist/client/assets/{index-BNn3-chz.js → index-BeH3ljiU.js} +1 -1
  91. package/dist/client/assets/{index-DmTI5Hye.js → index-BfY2tknC.js} +1 -1
  92. package/dist/client/assets/{index-CAlXjm0N.js → index-BfoRyh9U.js} +1 -1
  93. package/dist/client/assets/index-BqtFX8p5.js +1 -0
  94. package/dist/client/assets/{index-Ch41JOI2.js → index-Bvr-_HFb.js} +1 -1
  95. package/dist/client/assets/{index-g_5oOlG6.js → index-C-DMBd4V.js} +1 -1
  96. package/dist/client/assets/{index-DLNwEM2Q.js → index-C4ZJEVQG.js} +1 -1
  97. package/dist/client/assets/{index-DLZi_nae.js → index-C6XffNP5.js} +1 -1
  98. package/dist/client/assets/{index-C3xuhmPa.js → index-C9NjdeaX.js} +3 -3
  99. package/dist/client/assets/{index-DX7V94qe.js → index-CFakjglG.js} +1 -1
  100. package/dist/client/assets/{index-CpYs0Lli.js → index-C_nYZwKl.js} +1 -1
  101. package/dist/client/assets/{index-DRqEM5Wb.js → index-CbUkmP4v.js} +1 -1
  102. package/dist/client/assets/index-Cdi4wcy2.js +23 -0
  103. package/dist/client/assets/{index-DdsKmfEH.js → index-CfPs0N2z.js} +1 -1
  104. package/dist/client/assets/{index-Cp7oifSs.js → index-CiOdQLWf.js} +1 -1
  105. package/dist/client/assets/{index-DIlV08Vw.js → index-CkfVcaGE.js} +1 -1
  106. package/dist/client/assets/{index-BTreBsWa.js → index-Cw1lCYXU.js} +2 -2
  107. package/dist/client/assets/index-D1AN47IZ.js +17 -0
  108. package/dist/client/assets/{index-lJc8v0Z3.js → index-D6QoZ_JK.js} +1 -1
  109. package/dist/client/assets/{index-C7BTAdSc.js → index-DipT3Tl7.js} +1 -1
  110. package/dist/client/assets/{index-BokDvdOG.js → index-DjQZM7xU.js} +1 -1
  111. package/dist/client/assets/{index-D0Nd2LA-.js → index-Dl3NBIFK.js} +1 -1
  112. package/dist/client/assets/{index-BRGOMmOM.js → index-DvSjlchr.js} +1 -1
  113. package/dist/client/assets/{index-BB18IeC2.js → index-HmNnK1_1.js} +1 -1
  114. package/dist/client/assets/{index-BTXBESRm.js → index-Svn7q7Oq.js} +1 -1
  115. package/dist/client/assets/{index-C63bLSO4.js → index-d-DK54t2.js} +259 -259
  116. package/dist/client/assets/{index-BYp9xcmS.js → index-hw9zI0x5.js} +1 -1
  117. package/dist/client/assets/{index-Cow815Qa.js → index-juObjGCH.js} +1 -1
  118. package/dist/client/assets/{index-3GDQSKet.js → index-obtMBZBo.js} +1 -1
  119. package/dist/client/assets/{index-YswfjpmW.js → index-sLuAyJv-.js} +1 -1
  120. package/dist/client/assets/{index-t7gsOfUI.js → index-tdK5EJaB.js} +1 -1
  121. package/dist/client/assets/{index-BBQMqcO_.js → index-wx8w6kby.js} +1 -1
  122. package/dist/client/assets/{index-iD0epmn3.js → index-yDaSJS2Z.js} +1 -1
  123. package/dist/client/assets/{kickoff-xkt4LpIP.js → kickoff-BwvlCy0n.js} +2 -2
  124. package/dist/client/assets/{layers-Cy8Tme6i.js → layers-5nJbTYJI.js} +1 -1
  125. package/dist/client/assets/{lightbulb-tNm7gLYi.js → lightbulb-CTbrj6Bh.js} +1 -1
  126. package/dist/client/assets/{markdown-content-CoK3F0c0.js → markdown-content-BWVUF3Ll.js} +1 -1
  127. package/dist/client/assets/{mention-pill-Bgs_yujj.js → mention-pill-DlZf_ikY.js} +1 -1
  128. package/dist/client/assets/{message-square-off-CF2Bzen3.js → message-square-off-DwAOErT_.js} +1 -1
  129. package/dist/client/assets/{owner-notice-cgCWG4hG.js → owner-notice-De98Vj3z.js} +1 -1
  130. package/dist/client/assets/{package-DE8sQpId.js → package-B1hSUoIL.js} +1 -1
  131. package/dist/client/assets/{page-container-BoXmmBSs.js → page-container-DTyW7UJt.js} +1 -1
  132. package/dist/client/assets/{paperclip-IgDeVFea.js → paperclip-CoxP50ae.js} +1 -1
  133. package/dist/client/assets/{radio-BzTkFBDD.js → radio-WZhvBdvS.js} +1 -1
  134. package/dist/client/assets/{room-files-source-CIIDTSTA.js → room-files-source-B2H-CIeN.js} +1 -1
  135. package/dist/client/assets/{rotate-ccw-clock-CGcSqHnk.js → rotate-ccw-clock-DFGhE-_C.js} +1 -1
  136. package/dist/client/assets/{rotate-cw-DaduzRfP.js → rotate-cw-DiWMKflx.js} +1 -1
  137. package/dist/client/assets/{scroll-area-DW0-Liri.js → scroll-area-BJrXoUrS.js} +1 -1
  138. package/dist/client/assets/{search-x-Sme5ElYi.js → search-x-CPf5yiSS.js} +2 -2
  139. package/dist/client/assets/{shield-x-Bh5xap8N.js → shield-x-D-yr2n7H.js} +1 -1
  140. package/dist/client/assets/{soul-file-NcuTUIiB.js → soul-file-D0y7QIBL.js} +1 -1
  141. package/dist/client/assets/{table-BEtvgYmW.js → table-B3kRSRyK.js} +1 -1
  142. package/dist/client/assets/{use-connector-management-Cohvs7jD.js → use-connector-management-2rrubqr1.js} +1 -1
  143. package/dist/client/assets/{use-delete-binding-C19umm_i.js → use-delete-binding-BKhK3a7C.js} +1 -1
  144. package/dist/client/assets/{use-dev-links-DRnLdl--.js → use-dev-links-BIxj0Pjl.js} +1 -1
  145. package/dist/client/assets/{use-external-adapter-catalog-BOn9aj72.js → use-external-adapter-catalog-XS0vyTlS.js} +1 -1
  146. package/dist/client/assets/{use-full-activity-feed-BpQANbns.js → use-full-activity-feed-CwqKSvpf.js} +1 -1
  147. package/dist/client/assets/use-is-below-desktop-Dzs5i_TM.js +1 -0
  148. package/dist/client/assets/{use-jump-back-in-CkFErfWY.js → use-jump-back-in-CD5wYoFA.js} +3 -3
  149. package/dist/client/assets/use-mesh-topology-3LbL6yfa.js +1 -0
  150. package/dist/client/assets/{use-panel-tab-placements-AFrWTQ0a.js → use-panel-tab-placements-CTNXdvC6.js} +1 -1
  151. package/dist/client/assets/use-pending-read-sDmA-i7r.js +1 -0
  152. package/dist/client/assets/{use-personality-commit-fUtuc2lC.js → use-personality-commit-B13DSXxo.js} +1 -1
  153. package/dist/client/assets/{use-promo-activation-Dxt-1yuT.js → use-promo-activation-DCy9ROgP.js} +2 -2
  154. package/dist/client/assets/{use-pulse-freshness-DRRM5Hza.js → use-pulse-freshness-CRHnQO_-.js} +1 -1
  155. package/dist/client/assets/{use-room-follow-claim-huRfaa4e.js → use-room-follow-claim-FWatOD5-.js} +1 -1
  156. package/dist/client/assets/{use-roving-tab-list-BZIBAGgJ.js → use-roving-tab-list-C56ygMxj.js} +1 -1
  157. package/dist/client/assets/{use-session-canvas-CZIsr9qL.js → use-session-canvas-Dsmt92or.js} +4 -4
  158. package/dist/client/assets/{use-session-diagnostics-C41hV7rK.js → use-session-diagnostics-ypmmhIlN.js} +2 -2
  159. package/dist/client/assets/{use-unclaimed-chats-BMlFQ2v1.js → use-unclaimed-chats-C_bsrJFb.js} +1 -1
  160. package/dist/client/index.html +1 -1
  161. package/dist/server/index.js +4371 -3444
  162. package/dist/server/index.js.map +2 -2
  163. package/package.json +6 -6
  164. package/dist/client/assets/AdapterIcon-C_fBZXHQ.js +0 -1
  165. package/dist/client/assets/HandlePage-B33P0oh0.js +0 -1
  166. package/dist/client/assets/NamePage-MfybpnwN.js +0 -1
  167. package/dist/client/assets/PhotoPage-BgyB3B2_.js +0 -1
  168. package/dist/client/assets/_shell._home.workspaces-DVF1rM3t.js +0 -1
  169. package/dist/client/assets/_shell.connections-0_34lXIQ.js +0 -1
  170. package/dist/client/assets/_shell.marketplace-Dp-p8E3V.js +0 -1
  171. package/dist/client/assets/_shell.marketplace_.sources-SN2Fb1eb.js +0 -1
  172. package/dist/client/assets/_shell.session-Bt3jdQdD.js +0 -66
  173. package/dist/client/assets/_shell.x._extensionId-Bjn-MKsP.js +0 -1
  174. package/dist/client/assets/_shell.x._extensionId_._-Bjn-MKsP.js +0 -1
  175. package/dist/client/assets/index-BUVKya1M.js +0 -23
  176. package/dist/client/assets/index-CTxEG5rD.js +0 -1
  177. package/dist/client/assets/index-CkknQ52Q.js +0 -17
  178. package/dist/client/assets/use-is-below-desktop-5LlietdR.js +0 -1
  179. package/dist/client/assets/use-mesh-topology-CIsDeAY0.js +0 -1
  180. package/dist/client/assets/use-pending-read-Dol8yvIx.js +0 -1
@@ -1,4 +1,4 @@
1
1
  [diffend] Oversized file quarantined before diffing.
2
2
  name: package/dist/server/index.js.map
3
- size: 59255478 bytes
4
- sha256: f599a322a8194b9b76eb4db199a75c03a3637482cd1858d7f0c439a3ec41526f
3
+ size: 59354892 bytes
4
+ sha256: bfff3e5a432c0823d7ade5566fd8c7806b8952b114b29e5b6c2b697b12cffdf1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dorkos",
3
- "version": "0.114.0",
3
+ "version": "0.114.1",
4
4
  "description": "You, multiplied. Build and run your business with an agent team. Your agents join your team chat, take on real work, and build the tools your company runs on.",
5
5
  "license": "MIT",
6
6
  "author": "Dorian Collier",
@@ -82,14 +82,14 @@
82
82
  "typescript": "^5.9.3",
83
83
  "vitest": "^4.1.11",
84
84
  "@dorkos/browser": "0.0.0",
85
- "@dorkos/harness": "0.0.0",
85
+ "@dorkos/client": "0.0.0",
86
+ "@dorkos/marketplace": "0.0.0",
86
87
  "@dorkos/eslint-config": "0.0.0",
87
- "@dorkos/shared": "0.0.0",
88
- "@dorkos/typescript-config": "0.0.0",
88
+ "@dorkos/harness": "0.0.0",
89
89
  "@dorkos/db": "0.0.0",
90
90
  "@dorkos/server": "0.0.0",
91
- "@dorkos/marketplace": "0.0.0",
92
- "@dorkos/client": "0.0.0"
91
+ "@dorkos/shared": "0.0.0",
92
+ "@dorkos/typescript-config": "0.0.0"
93
93
  },
94
94
  "scripts": {
95
95
  "build": "tsx scripts/build.ts",
@@ -1 +0,0 @@
1
- import{bp as n,bq as r,j as c,br as s,aM as A}from"./index-C63bLSO4.js";const g={connected:n.success,disconnected:n.neutral,error:n.error,starting:`${n.warning} ${r}`,stopping:`${n.warning} ${r}`,reconnecting:`${n.warning} ${r}`},p={connected:"Connected",disconnected:"Ready",error:"Error",starting:"Connecting…",stopping:"Stopping…",reconnecting:"Reconnecting…"};function _({iconId:i,adapterType:a,size:t=16,className:o}){const e=s[i??""]??s[a??""];return e?c.jsx(e,{size:t,className:o}):c.jsx(A,{className:o,style:{width:t,height:t}})}export{_ as A,g as a,p as b};
@@ -1 +0,0 @@
1
- import{j as r,q as n}from"./index-C63bLSO4.js";function t({member:e}){return r.jsx(n,{member:e})}export{t as HandlePage};
@@ -1 +0,0 @@
1
- import{j as o,o as r}from"./index-C63bLSO4.js";function a({member:e}){return o.jsx(r,{member:e})}export{a as NamePage};
@@ -1 +0,0 @@
1
- import{j as t,s as r}from"./index-C63bLSO4.js";function s({member:o}){return t.jsx(r,{member:o})}export{s as PhotoPage};
@@ -1 +0,0 @@
1
- import{ae as j,aj as g,r as f,j as e,dy as N,dE as i,aw as b,dF as y,dj as w,aa as u,b4 as C}from"./index-C63bLSO4.js";import{T,d as v,b as p,e as d,a as S,c}from"./table-BEtvgYmW.js";import{P as k}from"./page-container-BoXmmBSs.js";import{G as L}from"./git-branch-hfu8isLA.js";const F=["workspaces","scan"],E=6e4;function P(){var a,n,l;const s=j(),t=g({queryKey:F,queryFn:()=>s.scanWorktrees(),staleTime:E});return{root:((a=t.data)==null?void 0:a.root)??null,worktrees:((n=t.data)==null?void 0:n.worktrees)??[],warnings:((l=t.data)==null?void 0:l.warnings)??[],isLoading:t.isLoading,isError:t.isError}}const m="—";function A(s){return s.changedFiles===null?m:s.changedFiles===0?"Clean":`${s.changedFiles} changed`}function B(s){const{ahead:t,behind:a,upstreamGone:n}=s;return n?"Branch merged or deleted":t===null||a===null?m:t===0&&a===0?"In sync":[t>0&&`${t} ahead`,a>0&&`${a} behind`].filter(Boolean).join(" · ")}function W({worktree:s}){const t=(s.changedFiles??0)>0;return e.jsxs(p,{children:[e.jsxs(c,{className:"max-w-0",children:[e.jsx("div",{className:"truncate font-medium",children:s.name}),e.jsx("div",{className:"text-muted-foreground truncate text-xs",title:s.path,children:i(s.path)})]}),e.jsx(c,{className:"max-w-0",children:s.readable?s.branch?e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(L,{className:"text-muted-foreground size-3.5 shrink-0"}),e.jsx("span",{className:"truncate text-xs",children:s.branch})]}):e.jsx("span",{className:"text-muted-foreground text-xs",children:"No branch"}):e.jsx(u,{variant:"outline",title:"DorkOS couldn’t read this folder with git.",children:"Can’t read"})}),e.jsx(c,{className:t?"text-status-warning-fg":"text-muted-foreground",children:e.jsx("span",{className:"text-xs whitespace-nowrap",children:A(s)})}),e.jsx(c,{className:"text-muted-foreground hidden md:table-cell",children:e.jsx("span",{className:"text-xs whitespace-nowrap",children:B(s)})}),e.jsx(c,{className:"text-muted-foreground hidden sm:table-cell",children:e.jsx("span",{className:"text-xs whitespace-nowrap",children:s.lastCommitAt?C(s.lastCommitAt):m})})]})}function G({project:s,worktrees:t}){return e.jsxs("section",{children:[e.jsxs("h2",{className:"mb-3 flex items-center gap-2 text-sm font-semibold",children:[s,e.jsx(u,{variant:"secondary",children:t.length})]}),e.jsx("div",{className:"bg-card rounded-lg border",children:e.jsxs(T,{children:[e.jsx(v,{children:e.jsxs(p,{children:[e.jsx(d,{children:"Folder"}),e.jsx(d,{children:"Branch"}),e.jsx(d,{children:"Changes"}),e.jsx(d,{className:"hidden md:table-cell",children:"Compared to remote"}),e.jsx(d,{className:"hidden sm:table-cell",children:"Last commit"})]})}),e.jsx(S,{children:t.map(a=>e.jsx(W,{worktree:a},a.path))})]})})]})}function H(){const{root:s,worktrees:t,warnings:a,isLoading:n,isError:l}=P(),x=f.useMemo(()=>{const r=new Map;for(const o of t){const h=r.get(o.project)??[];h.push(o),r.set(o.project,h)}return[...r.entries()]},[t]);return e.jsxs(k,{width:"wide",children:[e.jsx(N,{children:"Workspaces"}),e.jsx("p",{className:"text-muted-foreground mb-6 text-sm",children:"Copies of your code, per agent."}),a.length>0&&e.jsxs("div",{className:"mb-6 rounded-lg border border-amber-600/40 bg-amber-500/10 p-4",children:[e.jsx("p",{className:"text-sm font-medium",children:"Some folders couldn’t be read"}),e.jsx("p",{className:"text-muted-foreground mt-1 text-sm",children:"This list may be missing what’s inside them."}),e.jsx("ul",{className:"text-muted-foreground mt-2 space-y-0.5 text-xs",children:a.map(r=>e.jsxs("li",{className:"truncate",title:r.path,children:[i(r.path)," (",r.reason,")"]},r.path))})]}),n?e.jsx("p",{className:"text-muted-foreground text-sm",children:"Looking for your worktrees…"}):l?e.jsxs("div",{className:"bg-card rounded-xl border p-10 text-center",children:[e.jsx(b,{className:"text-muted-foreground/60 mx-auto size-8"}),e.jsx("p",{className:"mt-3 font-medium",children:"Couldn’t check your worktrees"}),e.jsx("p",{className:"text-muted-foreground mt-1 text-sm",children:"The scan didn’t finish. DorkOS tries again on its own."})]}):x.length===0?e.jsxs("div",{className:"bg-card rounded-xl border p-10 text-center",children:[e.jsx(y,{className:"text-muted-foreground/60 mx-auto size-8"}),e.jsx("p",{className:"mt-3 font-medium",children:"No worktrees yet"}),e.jsx("p",{className:"text-muted-foreground mt-1 text-sm",children:"A worktree is a copy of your project, so agents’ edits never collide."}),s&&e.jsxs("p",{className:"text-muted-foreground mt-3 truncate text-xs",title:s,"data-slot":"workspaces-root-path",children:["Looking in ",e.jsx(w,{children:i(s)})]})]}):e.jsx("div",{className:"flex flex-col gap-8",children:x.map(([r,o])=>e.jsx(G,{project:r,worktrees:o},r))})]})}const M=H;export{M as component};
@@ -1 +0,0 @@
1
- import{ae as pn,af as Oe,ag as nt,ah as tt,k5 as st,an as Xe,aj as at,j as e,cY as J,cZ as Z,c_ as X,c$ as ee,d0 as ne,dd as te,d1 as ge,B as b,cT as D,k6 as xn,Z as B,F as se,a8 as fn,aa as K,bp as jn,C as ae,r as j,dw as it,jF as ot,I as Le,e as P,a6 as W,k7 as rt,jS as yn,k4 as le,k8 as vn,ai as bn,gl as pe,dz as ie,eU as Q,jP as Te,b4 as De,V as ct,hf as lt,iK as Nn,h as kn,i as dt,jT as ut,fN as ht,x as Cn,ey as mt,aw as wn,cD as de,cE as ue,di as gt,cF as he,k9 as Sn,ka as An,jW as ze,kb as pt,e5 as Fe,kc as xt,kd as In,gb as xe,gc as fe,gd as je,ge as ye,gf as ve,gg as be,gh as Ne,gi as ke,jN as ft,jX as Rn,ke as jt,fk as Me,jY as yt,e8 as qe,e9 as Be,kf as vt,bC as bt,aO as Nt,kg as kt,a9 as oe,hm as Ct,kh as wt,ki as Tn,kj as St,jZ as $n,e7 as At,dg as _n,ba as It,A as Rt,d_ as En,d$ as Pn,e0 as On,e1 as Ln,e2 as $e,bY as Ue,l as Dn,jM as Tt,kk as $t,cu as we,cv as Se,hg as _t,cw as Ae,kl as Et,H as zn,km as Pt,hF as Ot,ad as Lt,i2 as Dt,cS as zt,kn as Ft,eY as Mt,eZ as qt,e_ as Bt,e$ as Ut,f0 as Wt,f1 as Kt,f2 as Yt,f4 as Ht,gm as Gt,gp as Vt,f as Qt,go as Jt,ko as Zt,D as Xt,kp as es,dM as ns,jI as ts,jJ as ss,h1 as as,kq as is,kr as os,h4 as rs,ks as cs,h5 as ls,aM as ds,kt as us,ku as Fn,kv as hs,cl as ms,dy as gs,kw as ps}from"./index-C63bLSO4.js";import{P as xs}from"./page-container-BoXmmBSs.js";import{s as We,u as fs,a as js,b as Mn,c as ys,d as vs,e as en,f as bs,i as Ns,C as ks,g as Cs,h as ws,j as Ss,L as qn,k as Bn,A as As,l as Is,m as Rs,n as Ts,o as $s,p as _s,w as Es,F as Ps,q as Os,r as Ls,R as Ds,t as zs,v as Fs,x as Ms,y as qs}from"./AgentRequestCard-CcMh6JyE.js";import{u as Un,a as Bs,b as Us,c as Ws,d as Ks,e as Ys,U as Hs}from"./use-unclaimed-chats-BMlFQ2v1.js";import{b as Gs,f as Vs,g as nn,h as Qs,i as Js,j as Zs,k as Xs}from"./use-connector-management-Cohvs7jD.js";import{C as ea}from"./card-CKZCX8ol.js";import{u as na}from"./use-delete-binding-C19umm_i.js";import{u as Ke,A as Wn}from"./AdapterSetupWizard-BL70qy2J.js";import{s as ta}from"./session-strategy-labels-C7Wduch3.js";import{M as sa}from"./message-square-off-CF2Bzen3.js";import"./markdown-content-CoK3F0c0.js";function aa(){const n=pn(),t=Oe();return nt({mutationFn:({id:s,agentId:a})=>n.moveBinding(s,a),meta:{errorLabel:"Couldn’t move the chat"},onSuccess:()=>{t.invalidateQueries({queryKey:[...tt]})}})}function ia(n,t){const s=Oe(),{connectionState:a,failedAttempts:i}=st();return Xe("relay_message",()=>{n&&s.invalidateQueries({queryKey:["relay","conversations"]})}),Xe("relay_signal",()=>{n&&s.invalidateQueries({queryKey:["relay","conversations"]})}),{connectionState:a,failedAttempts:i}}function Kn(n){const t=pn();return at({queryKey:["relay","adapters",n,"events"],queryFn:()=>t.getAdapterEvents(n),enabled:!!n,refetchInterval:5e3})}function _e(n,t){var r;const s=n;if(!s||s.code!=="CHAT_ALREADY_BOUND")return null;const a=(r=s.body)==null?void 0:r.conflict,i=typeof(a==null?void 0:a.bindingId)=="string"?a.bindingId:null;if(!i)return null;const c=typeof(a==null?void 0:a.agentId)=="string"?a.agentId:"another agent";return{bindingId:i,currentAgentName:c,nextAgentId:t.id,nextAgentName:t.name}}function Yn({conflict:n,onClose:t,onMoved:s}){return e.jsx(J,{open:n!==null,onOpenChange:a=>!a&&t(),children:e.jsx(Z,{className:"sm:max-w-md",children:n&&e.jsx(oa,{conflict:n,onClose:t,onMoved:s})})})}function oa({conflict:n,onClose:t,onMoved:s}){const a=aa();return e.jsxs(e.Fragment,{children:[e.jsxs(X,{children:[e.jsx(ee,{children:"This chat already reaches someone"}),e.jsx(ne,{children:"A chat goes to one agent at a time."})]}),e.jsxs(te,{className:"pb-2",children:[e.jsxs("p",{className:"text-sm leading-relaxed",children:["This chat reaches ",e.jsx("span",{className:"font-medium",children:n.currentAgentName}),". Move it to ",e.jsx("span",{className:"font-medium",children:n.nextAgentName}),"?"]}),e.jsxs("p",{className:"text-muted-foreground mt-2 text-xs leading-relaxed",children:["Past messages stay with ",n.currentAgentName,". ",n.nextAgentName," starts fresh."]})]}),e.jsxs(ge,{children:[e.jsx(b,{variant:"outline",onClick:t,disabled:a.isPending,children:"Leave it"}),e.jsx(b,{disabled:a.isPending,onClick:()=>a.mutate({id:n.bindingId,agentId:n.nextAgentId},{onSuccess:()=>{D.success(`${n.nextAgentName} answers this chat now.`),t(),s==null||s()}}),children:a.isPending?"Moving…":`Move it to ${n.nextAgentName}`})]})]})}function Ce(n,t){var s;return((s=t.get(n))==null?void 0:s.displayName)??xn(n)}function ra(n){return n===0?"No agents yet":n===1?"1 agent":`${n} agents`}function ca(n){return n.length<=1?n[0]??"":n.length===2?`${n[0]} and ${n[1]}`:`${n[0]} and ${n.length-1} more`}function la(n){if(!(n.label.toLowerCase()!==n.toolkit.toLowerCase()))return{account:n.identityHint??n.label,identity:null};const s=n.identityHint&&n.identityHint!==n.label?n.identityHint:null;return{account:n.label,identity:s}}function Hn(n,t){const s=We(t.get(n));return s===void 0?{}:{logo:s}}const da={ready:"ready",needs_you:"broken",unavailable:"broken",finishing:"busy",paused:"off",gone:"off"},ua={sign_in_again:"sign-in-again",resume:"resume",review_access:"review",fix_key:"fix-key",connect_new:"connect-again"};function ha(n,t){var o;const{readiness:s}=n,a=la(n),i=da[s.state],c=(o=s.fix)==null?void 0:o.action,r=s.state==="gone"||!c?null:ua[c]??null;return{id:n.connectionId,kind:"account",name:Ce(n.toolkit,t),iconKey:n.toolkit,toolkit:n.toolkit,...Hn(n.toolkit,t),...a,waiting:0,tone:i,action:r,detail:s.state==="ready"?`${a.account} · ${n.everyAgent?"Every agent":ra(n.agentCount)}`:i==="broken"?s.copy.owner:`${a.account} · ${s.copy.owner}`}}function ma(n,t){if(t.label)return t.label;const s=t.status.displayName;return s&&s!==n.manifest.displayName?s:null}function ga(n,t,s){const a=n.manifest,i=ma(n,t),c={id:t.id,kind:"chat",name:a.displayName,iconKey:a.iconId??a.type,account:i,identity:null,waiting:s.waitingByChatApp[t.id]??0,deprecated:a.deprecated===!0},r=h=>i?`${i} · ${h}`:h;if(!t.enabled)return{...c,tone:"off",action:"resume",detail:"Paused · no messages in or out"};if(t.status.state==="error"||t.status.state==="disconnected")return{...c,tone:"broken",action:"fix",detail:"Stopped working. Messages aren’t getting through."};if(t.status.state!=="connected")return{...c,tone:"busy",action:null,detail:r("Connecting…")};const o=[...new Set(s.bindings.filter(h=>h.adapterId===t.id).map(h=>s.agentNames[h.agentId]??h.agentId))];if(o.length===0)return{...c,tone:"attention",action:null,detail:r("No agent answers yet")};const u=o.length===1?"answers":"answer";return{...c,tone:"ready",action:null,detail:r(`${ca(o)} ${u}`)}}const tn={broken:1,attention:2,busy:3,ready:3,off:4};function pa(n){return n.manifest.category==="internal"}function xa(n){const t=n.connections.map(r=>ha(r,n.services));for(const r of n.chatApps)if(!pa(r))for(const o of r.instances)t.push(ga(r,o,n));const s=t.map((r,o)=>({row:r,index:o})).sort((r,o)=>tn[r.row.tone]-tn[o.row.tone]||r.row.name.localeCompare(o.row.name)||r.index-o.index).map(({row:r})=>r),a=n.pendingSignIn;if(!a)return s;const i=n.services.get(a.toolkit),c=(i==null?void 0:i.displayName)??xn(a.toolkit);return[{id:a.flowId,kind:"connecting",name:c,iconKey:a.toolkit,...Hn(a.toolkit,n.services),account:null,identity:null,detail:`Finish signing in on ${(i==null?void 0:i.signInName)??c}…`,tone:"busy",action:"cancel",waiting:0},...s]}function Ye(n){const t=n.intents.find(s=>s.kind==="messages");return{account:n.intents.some(s=>s.kind==="account"),chatType:(t==null?void 0:t.kind)==="messages"?t.relayAdapterType:null}}function fa(n,t){return{accounts:new Set(n.filter(s=>s.lifecycle!=="disconnected").map(s=>s.toolkit)),chatApps:new Set(t.filter(s=>s.instances.length>0).map(s=>s.manifest.type))}}function Gn(n,t){const s=Ye(n);return{account:s.account&&!t.accounts.has(n.serviceSlug),chatType:s.chatType&&!t.chatApps.has(s.chatType)?s.chatType:null}}const Vn={popular:"Popular",email:"Email",calendar:"Calendar",chat:"Chat",docs:"Docs",files:"Files",code:"Code",tasks:"Tasks",sales:"Sales",all:"All"};function ja(n){const t=new Set(n.map(a=>a.category));return["popular",...Object.keys(Vn).filter(a=>a!=="popular"&&a!=="all"&&t.has(a)),"all"]}function ya(n,t){const s=n.filter(a=>a.category!=="developer");return t==="all"?s:t==="popular"?s.filter(a=>a.popular):s.filter(a=>a.category===t)}function va(n,t){const s=t.trim().toLowerCase();return s===""?!0:`${n.name} ${n.detail}`.toLowerCase().includes(s)}const sn={"sign-in-again":"Sign in again",resume:"Resume",cancel:"Cancel",review:"Review",fix:"Fix","fix-key":"Fix the key","connect-again":"Connect again"};function ba(){return e.jsx(K,{size:"xs",variant:"secondary",className:"shrink-0",children:"Chat"})}function Qn({name:n,iconKey:t,logo:s,detail:a,chat:i,deprecated:c=!1,wrapDetail:r=!1,detailClassName:o}){return e.jsxs(e.Fragment,{children:[e.jsx(fn,{iconKey:t,displayName:n,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:n}),i&&e.jsx(ba,{}),c&&e.jsx(K,{size:"xs",variant:"outline",tone:"warning",className:"shrink-0",children:"Deprecated"})]}),e.jsx("span",{className:B("text-muted-foreground block text-xs",r?"line-clamp-2":"truncate",o),children:a})]})]})}function Na({row:n,onOpen:t,onAction:s,actionPending:a=!1}){const i=n.tone==="off";return e.jsxs("li",{"data-testid":`app-row-${n.id}`,"data-tone":n.tone,className:B("group/row flex items-center rounded-lg transition-colors",n.tone==="broken"?"bg-status-warning-bg/70 hover:bg-status-warning-bg":"hover:bg-muted/50"),children:[e.jsxs("button",{type:"button",onClick:()=>t(n),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:B("flex min-w-0 flex-1 items-center gap-3",i&&"opacity-55"),children:e.jsx(Qn,{name:n.name,iconKey:n.iconKey,logo:n.logo,detail:n.detail,chat:n.kind==="chat",deprecated:n.deprecated,wrapDetail:n.tone==="broken",detailClassName:n.tone==="broken"?"text-status-warning-fg":void 0})}),!n.action&&e.jsx(ka,{row:n})]}),n.action&&e.jsx("div",{className:"flex shrink-0 items-center pr-3",children:e.jsxs(b,{size:"sm",variant:n.tone==="broken"?"default":"outline",disabled:a,onClick:()=>s(n),"aria-label":`${sn[n.action]}: ${n.name}`,children:[a&&e.jsx(se,{size:"xs"}),sn[n.action]]})})]})}function ka({row:n}){return n.waiting>0?e.jsxs(K,{shape:"pill",tone:"warning",variant:"outline",className:"shrink-0",children:[n.waiting," waiting"]}):n.tone==="busy"?e.jsx(se,{size:"xs",className:"text-muted-foreground shrink-0"}):n.tone==="ready"?e.jsxs("span",{className:"flex shrink-0 items-center",children:[e.jsx("span",{className:B("size-2 rounded-full",jn.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 Ca({service:n,chat:t,actionLabel:s,onConnect:a,unavailableLabel:i}){const c=n.description??wa(n),r=e.jsx(Qn,{name:n.displayName,iconKey:n.iconKey,logo:We(n),detail:c,chat:t,wrapDetail:!0});return a?e.jsx("li",{"data-testid":`catalog-app-${n.serviceSlug}`,children:e.jsxs("button",{type:"button",onClick:()=>a(n),"aria-label":`${s} ${n.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:[r,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-${n.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:r}),e.jsx("span",{className:"text-muted-foreground shrink-0 text-xs",children:i})]})}function wa(n){const t=n.intents.some(a=>a.kind==="messages"),s=n.intents.some(a=>a.kind==="account");return t&&s?`Talk to your agents in ${n.displayName}, or let them use it.`:t?`Talk to your agents in ${n.displayName}.`:`Let agents use your ${n.displayName} account.`}function Sa({query:n,onQueryChange:t,data:s,onOpenRow:a,onRowAction:i,pendingRowId:c=null,onConnect:r}){var $,Y,S,R;const[o,u]=j.useState("popular"),h=n.trim()!=="",{catalog:d,relay:f}=s,l=f.enabled,m=s.available.filter(w=>w.category!=="developer"),x=s.available.filter(w=>w.category==="developer"),y=ja(m),N=y.includes(o)?o:"popular",k=h?m:ya(m,N),A=(($=d.data)==null?void 0:$.pages.flatMap(w=>w.warnings))??[],p=(R=(S=(Y=d.data)==null?void 0:Y.pages[0])==null?void 0:S.appConnections)==null?void 0:R.newApps,g=h&&!d.isPending&&s.yours.length===0&&s.available.length===0,C=(w,E)=>{const z=Ye(w),I=z.chatType!==null&&!z.account&&!l;return e.jsx(Ca,{service:w,chat:z.chatType!==null,actionLabel:E,onConnect:I?void 0:r,unavailableLabel:"Turned off"},w.serviceSlug)};return e.jsxs("div",{className:"space-y-8","data-testid":it.relayIntegrations,children:[e.jsxs("div",{className:"relative",children:[e.jsx(ot,{className:"text-muted-foreground pointer-events-none absolute top-1/2 left-3 size-4 -translate-y-1/2","aria-hidden":!0}),e.jsx(Le,{type:"search",value:n,onChange:w=>t(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(P,{className:"h-14 rounded-lg"}),e.jsx(P,{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(Na,{row:w,onOpen:a,onAction:i,actionPending:c===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 “",n.trim(),"”"]}),e.jsx("p",{className:"text-muted-foreground mt-1 text-xs",children:Ia(p)})]}):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:h?"Apps":"All apps"}),!h&&y.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:y.map(w=>e.jsx("button",{type:"button","aria-pressed":w===N,onClick:()=>u(w),className:B("focus-ring shrink-0 rounded-full px-3 py-1 text-xs font-medium transition-colors",w===N?"bg-foreground text-background":"bg-muted/60 text-muted-foreground hover:bg-muted hover:text-foreground"),children:Vn[w]},w))}),d.isPending?e.jsxs("div",{className:"space-y-2","aria-label":"Loading apps",children:[e.jsx(P,{className:"h-14 rounded-lg"}),e.jsx(P,{className:"h-14 rounded-lg"}),e.jsx(P,{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:[k.length>0&&e.jsx("ul",{className:"-mx-3 space-y-0.5","data-testid":"all-apps-list",children:k.map(w=>C(w,"Connect"))}),(h||N==="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(Aa,{data:s}),A.map(w=>e.jsx("p",{className:"text-muted-foreground text-xs",children:w.message},`${w.code}-${w.message}`))]}),x.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:x.map(w=>C(w,"Set up"))})]})]})}function Aa({data:n}){const{relay:t}=n;return n.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:n.retryChatApps,children:"Try again"})]}):t.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:t.retry,disabled:t.isRetrying,children:t.isRetrying?"Checking…":"Try again"})]}):e.jsx(rt,{relay:t,variant:"line"})}function Ia(n){if((n==null?void 0:n.status)!=="setup_needed")return"Try another name.";switch(n.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 Ra(n,t){const s=n.trim()!=="",a=yn(),i=le(""),c=le(n,s),r=vn(),o=bn(r.enabled),{data:u}=pe(),{data:h}=Un("pending",r.enabled),{data:d}=ie(),f=j.useMemo(()=>{var p;return new Map((((p=i.data)==null?void 0:p.pages.flatMap(g=>g.services))??[]).map(g=>[g.serviceSlug,g]))},[i.data]),l=j.useMemo(()=>Object.fromEntries(((d==null?void 0:d.agents)??[]).map(p=>[p.id,Q(p)])),[d]),m=j.useMemo(()=>r.enabled?o.data??[]:[],[r.enabled,o.data]),x=j.useMemo(()=>{var p;return((p=a.data)==null?void 0:p.connections)??[]},[a.data]),y=j.useMemo(()=>{const p={};for(const g of h??[])p[g.adapterId]=(p[g.adapterId]??0)+1;return xa({connections:x,chatApps:m,bindings:u??[],waitingByChatApp:p,agentNames:l,services:f,pendingSignIn:t})},[x,m,u,h,l,f,t]),N=s?c:i,k=j.useMemo(()=>fa(x,m),[x,m]),A=j.useMemo(()=>{var p;return(((p=N.data)==null?void 0:p.pages.flatMap(g=>g.services))??[]).filter(g=>{const C=Gn(g,k);return C.account||C.chatType!==null})},[N.data,k]);return{yours:y.filter(p=>va(p,n)),allYours:y,chatApps:m,owned:k,available:A,services:f,agentNames:l,yoursLoading:a.isPending||r.isLoading||r.enabled&&o.isPending,yoursError:a.isError,yoursRefreshing:a.isFetching,retryYours:()=>void a.refetch(),catalog:N,relay:r,chatAppsError:r.enabled&&o.isError,retryChatApps:()=>void o.refetch()}}function Jn(n){switch(n&&typeof n=="object"&&"code"in n?n.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 Ta={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 $a(n){return Ta[n]??[]}const _a={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 Ea(n,t){return _a[n]??`When something new happens in ${t}…`}function Pa(n,t){if(n.agentId&&t[n.agentId])return t[n.agentId];switch(n.actorKind){case"operator":return"You";case"program":return"A program";case"event":return"A notification";default:return"An agent"}}function Oa(n,t,s){const a=`${Pa(n,s)} · ${Te(n.operationSlug,t)}`;return n.outcome===void 0?n.completedAt?a:`${a} (in progress)`:n.outcome==="success"?a:n.outcome==="outcome_unknown"?`${a} (result unknown)`:`${a} (didn’t finish)`}function La(n,t=new Date){const s=new Date(n);if(s.getTime()<=t.getTime())return"Trying again now.";const a=s.toLocaleTimeString([],{hour:"numeric",minute:"2-digit"});return s.toDateString()===t.toDateString()?`Trying again at ${a}.`:`Trying again ${s.toLocaleDateString([],{weekday:"long"})} at ${a}.`}function Da(n){const t=n.replaceAll(/([a-z0-9])([A-Z])/gu,"$1 $2").replaceAll(/[_-]+/gu," ").trim().toLowerCase();return t?`${t.charAt(0).toUpperCase()}${t.slice(1)}`:n}function Zn(n){return typeof n=="boolean"?n?"yes":"no":typeof n=="string"||typeof n=="number"?String(n):Array.isArray(n)&&n.every(t=>typeof t!="object"||t===null)?n.map(t=>Zn(t)).join(", "):"a custom value"}function za(n,t=null){const s=Object.entries(n).filter(([,a])=>a!==""&&a!==void 0&&a!==null).map(([a,i])=>{var r;return`${((r=t==null?void 0:t.find(o=>o.name===a))==null?void 0:r.label)??Da(a)} is ${Zn(i)}`});return s.length>0?`Only when ${s.join(" and ")}`:null}function Xn(n,t,s){const a=u=>({text:u,tone:"plain",checkInChat:!1}),i=(u,h=!1)=>({text:u,tone:"problem",checkInChat:h});switch(n.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 c=n.lastDelivery;if(!c)return a(s);const r=De(c.receivedAt);switch(c.outcome){case"delivered":return a(`Last one delivered · ${r}`);case"sending":return a(`Newest one on its way · ${r}`);case"retrying":return a(`Newest one hasn’t reached ${t} yet. DorkOS is trying again.`)}const o=n.destination.kind==="agent";switch(c.problem){case"unknown_outcome":return i(o?`DorkOS can’t tell if ${t} got the newest one (${r}). Open the chat to check.`:`DorkOS can’t tell if the newest one reached ${t} (${r}). Check there.`,o);case"refused":return i(`${t} turned away the newest one (${r}). Check this agent can still post there.`);case"changed":return i(`Newest one (${r}) held back because this notification changed. Nothing to do.`);case"cancelled":return i(`Newest one (${r}) cancelled before ${t} read it. Nothing to do.`);case"expired":return i(`Newest one (${r}) expired and wasn’t sent. If it repeats, remove it and add it again.`);case"unreachable":case null:return i(`Newest one (${r}) didn’t reach ${t}. If it repeats, remove it and add it again.`)}}function Fa(n){const t=n.filter(s=>Xn(s,"","").tone==="problem").length;if(t!==0)return t===1?"1 notification needs a look":`${t} notifications need a look`}function Ma(n,t){const s=n.find(i=>i.id===t);return s?n.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 qa(n){const t=n==null?void 0:n.code,s=n==null?void 0:n.status;return t==="invalid_filter"?"Check the filter values, then try again.":t==="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 Ba({subscription:n,agents:t,definition:s,channelLabel:a,removing:i,onRemove:c}){var k,A,p;const r=kn(),o=dt(n.agentId,{enabled:n.destination.kind==="room"}),u=Ma(t,n.agentId),h=(k=o.data)==null?void 0:k.rooms.find(g=>g.id===n.destination.id);let d=u,f=`Goes to ${u}, all in one chat`;n.destination.kind==="room"?(d=h?h.slug?`#${h.slug}`:h.name:"a room this agent left",f=`Goes to ${d}, for ${u}`):n.destination.kind==="channel"&&(d=a??"a chat that’s no longer set up",f=`Goes to ${d}, for ${u}`);const l=za(n.filter,s?ut(s.filterSchema):null),m=Xn(n,d,ws(n)),x=(p=(A=t.find(g=>g.id===n.agentId))==null?void 0:A.agent)==null?void 0:p.projectPath,y=n.chatSessionId,N=l?`${f}. ${l}`:f;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":n.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:n.displayName}),e.jsx("p",{className:"text-muted-foreground text-xs break-words",children:f}),l&&e.jsx("p",{className:"text-muted-foreground text-xs break-words",children:l}),e.jsx("p",{className:B("text-xs break-words",m.tone==="problem"?"text-destructive":"text-muted-foreground"),"data-testid":"notification-status",children:m.text})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[y&&r&&e.jsxs(b,{type:"button",size:"sm",variant:m.checkInChat?"secondary":"ghost",className:"gap-1.5","aria-label":`Open the chat for ${n.displayName}: ${N}`,onClick:()=>void r(Cn({session:y,...x&&{dir:x}})),children:[e.jsx(ht,{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 ${n.displayName}: ${N}`,"aria-busy":i,disabled:i,onClick:c,children:i?e.jsx(se,{size:"sm"}):e.jsx(mt,{className:"size-4"})})]})]})}function Ua({connectionId:n}){return e.jsx(Wa,{connectionId:n},n)}function Wa({connectionId:n}){var w,E,z,U;const t=fs(n),s=t.data!==void 0&&t.data.setupMode!=="unavailable",a=js(n,s),i=Mn(n),c=ct(),r=pe(),o=ys(),u=vs(),[h,d]=j.useState(()=>en()),[f,l]=j.useState(!1),[m,x]=j.useState(()=>new Set),y=I=>{x(L=>new Set(L).add(I)),u.mutate({connectionId:n,subscriptionId:I},{onSettled:()=>x(L=>{const O=new Set(L);return O.delete(I),O})})},N=j.useRef(null),k=((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))??[],p=(((z=c.data)==null?void 0:z.members)??[]).filter(I=>I.kind==="agent"),g=bs({connectionId:n,definitions:k,draft:h}),C=t.data?Ns(t.data):!1,$=!!(g&&C),Y=()=>{N.current=null,o.reset()},S=I=>{d(I),Y()},R=()=>{if(!g)return;const I={definitionId:g.definitionId,filter:g.filter,agentId:g.agentId,destination:g.destination,manageExistingTrigger:f},L=JSON.stringify({connectionId:n,decision:I}),O=N.current,F=(O==null?void 0:O.signature)===L?O.requestId:crypto.randomUUID();N.current={signature:L,requestId:F},o.mutate({connectionId:n,input:{...I,requestId:F}},{onSuccess:()=>{N.current=null,d(en()),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(lt,{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."})]}),t.isPending?e.jsx(P,{className:"h-20 rounded-lg","aria-label":"Loading delivery setup"}):t.isError?e.jsx(W,{title:"Couldn’t check notifications for this account",description:"Try again before adding one.",onRetry:()=>void t.refetch(),isRetrying:t.isFetching}):t.data?e.jsx(ks,{connectionId:n,status:t.data}):null,i.isPending?e.jsx(P,{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 O;const L=(O=r.data)==null?void 0:O.find(F=>F.id===I.destination.id);return e.jsx(Ba,{subscription:I,agents:p,definition:k.find(F=>F.id===I.definitionId),channelLabel:L?L.label||"a chat app":void 0,removing:m.has(I.id),onRemove:()=>y(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(P,{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"})]}):k.length===0?e.jsx("p",{className:"text-muted-foreground text-sm",children:"This app offers no notifications yet."}):c.isPending?e.jsx(P,{className:"h-20 rounded-md","aria-label":"Loading agents"}):c.isError?e.jsx(W,{title:"Couldn’t load agents",description:"Try again before choosing who gets this.",onRetry:()=>void c.refetch(),isRetrying:c.isFetching}):p.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(Cs,{idPrefix:"notification",definitions:k,draft:h,onChange:S,agents:p,sourceStatus:t.data}),((U=t.data)==null?void 0:U.setupMode)==="byo_webhook"&&e.jsxs("div",{className:"flex min-h-11 items-center gap-2",children:[e.jsx(Nn,{id:"notification-manage-existing",checked:f,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:qa(o.error)}),e.jsx(b,{type:"button",size:"sm",disabled:!$||o.isPending,onClick:R,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:n,description:t,action:s,children:a,testId:i}){const c=`panel-section-${n.toLowerCase().replaceAll(/\s+/gu,"-")}`;return e.jsxs("section",{"aria-labelledby":c,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:c,className:"text-sm font-semibold",children:n}),t&&e.jsx("p",{className:"text-muted-foreground text-xs",children:t})]}),s]}),a]})}function Ee({message:n,detail:t,action:s,onAction:a,pending:i=!1,secondary:c,technicalDetail:r}){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(wn,{className:"mt-0.5 size-4 shrink-0","aria-hidden":!0}),e.jsxs("span",{children:[n,t&&e.jsx("span",{className:"mt-1 block",children:t})]})]}),(s&&a||c)&&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]}),c]}),r&&e.jsxs(de,{children:[e.jsxs(ue,{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(gt,{className:"size-3 -rotate-90 transition-transform group-data-[state=open]/details:rotate-0","aria-hidden":!0}),"Details"]}),e.jsx(he,{children:e.jsx("pre",{className:"bg-muted/50 mt-1 max-h-40 overflow-auto rounded p-2 text-xs whitespace-pre-wrap",children:r})})]})]})}function M({label:n,hint:t,destructive:s=!1,className:a,ref:i,...c}){return e.jsxs("button",{ref:i,type:"button",className:B("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),...c,children:[e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:B("block text-sm",s&&"text-destructive"),children:n}),t&&e.jsx("span",{className:"text-muted-foreground block text-xs",children:t})]}),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 Ka({detail:n,appName:t,onEditExactActions:s,onSignInAgain:a,signingIn:i,onAddAnother:c,onClose:r}){var A;const{connection:o,provider:u}=n,h=Sn({payer:o.payer,custody:u.custody}),d=o.connectionId,f=An(),l=ze(),m=Gs(),x=Mn(d,o.lifecycle!=="disconnected"),[y,N]=j.useState(!1),k=o.lifecycle==="disconnected";return e.jsxs(de,{children:[e.jsxs(ue,{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(he,{className:"-mx-2 space-y-1 pt-2","data-testid":"app-panel-more",children:[!k&&e.jsx(Ya,{detail:n}),!k&&e.jsxs(de,{children:[e.jsx(ue,{asChild:!0,children:e.jsx(M,{label:Ea(o.toolkit,t),hint:Fa(((A=x.data)==null?void 0:A.pages.flatMap(p=>p.subscriptions))??[])})}),e.jsx(he,{className:"px-2 pt-2 pb-3",children:e.jsx(Ua,{connectionId:d})})]}),o.everyAgent&&e.jsx(M,{label:"Stop sharing with every agent",hint:"Agents picked by name keep access",disabled:m.isPending,onClick:()=>m.mutate({connectionId:d})}),m.isError&&e.jsx("p",{role:"alert",className:"text-destructive px-2 text-xs",children:"Couldn’t stop sharing. Try again."}),!k&&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:f.isPending,onClick:()=>f.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})}),!k&&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 ${t} account`,onClick:()=>c(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]}),h&&e.jsx("p",{className:"text-muted-foreground mt-1 text-xs",children:h})]}),!k&&e.jsx(M,{label:"Disconnect…",destructive:!0,onClick:()=>N(!0)})]}),e.jsx(Ha,{detail:n,appName:t,open:y,onOpenChange:N,onDisconnected:r})]})}function Ya({detail:n}){const t=pt(),[s,a]=j.useState(n.connection.label),i=`connection-name-${n.connection.connectionId}`,c=s.trim()===""||s.trim()===n.connection.label;return e.jsxs("form",{className:"flex items-end gap-2 px-2 py-2",onSubmit:r=>{r.preventDefault(),!c&&t.mutate({connectionId:n.connection.connectionId,input:{label:s.trim()}})},children:[e.jsxs("div",{className:"min-w-0 flex-1 space-y-1",children:[e.jsx(Fe,{htmlFor:i,children:"Name"}),e.jsx(Le,{id:i,value:s,onChange:r=>a(r.target.value)})]}),e.jsx(b,{type:"submit",variant:"secondary",disabled:c||t.isPending,children:t.isPending?"Saving…":"Save"})]})}function Ha({detail:n,appName:t,open:s,onOpenChange:a,onDisconnected:i}){const c=n.connection.connectionId,r=xt(c,s),o=In(),u=n.agents.map(h=>h.displayName);return e.jsx(xe,{open:s,onOpenChange:a,children:e.jsxs(fe,{children:[e.jsxs(je,{children:[e.jsxs(ye,{children:["Disconnect ",t,"?"]}),e.jsx(ve,{children:r.isPending?"Checking who will lose access…":r.data?Ga(u,r.data):"Who loses access isn’t known yet."})]}),r.isError&&e.jsx("p",{role:"alert",className:"text-destructive text-sm",children:"Couldn’t check who loses access. Try again."}),e.jsxs(be,{children:[e.jsx(Ne,{children:"Keep connected"}),e.jsx(ke,{disabled:!r.data||o.isPending,className:"bg-destructive hover:bg-destructive/90 dark:bg-destructive/60 text-white",onClick:h=>{h.preventDefault(),o.mutate({connectionId:c,input:void 0},{onSuccess:()=>{a(!1),i()}})},children:o.isPending?"Disconnecting…":"Disconnect"})]})]})})}function Ga(n,t){const s=[];return t.everyAgent?s.push("Every agent will lose access."):n.length>0?s.push(`${Ss(n)} will lose access.`):t.affectedAgentCount>0?s.push(`${t.affectedAgentCount} ${t.affectedAgentCount===1?"agent":"agents"} will lose access.`):s.push("No agent uses it right now."),t.affectedSessionCount>0&&s.push(`${t.affectedSessionCount} open ${t.affectedSessionCount===1?"chat":"chats"} will stop using it.`),t.affectedSubscriptionCount>0&&s.push(`${t.affectedSubscriptionCount} ${t.affectedSubscriptionCount===1?"notification stops":"notifications stop"}.`),t.pendingDeliveryCount>0&&s.push(`${t.pendingDeliveryCount} waiting ${t.pendingDeliveryCount===1?"delivery":"deliveries"} won’t be sent.`),s.join(" ")}const an=3;function Va(n){const t=ft(n.connectionId);return t.isPending?e.jsxs("div",{className:"space-y-3","aria-label":"Loading app details",children:[e.jsx(P,{className:"h-28 rounded-lg"}),e.jsx(P,{className:"h-20 rounded-lg"})]}):t.isError?e.jsx(qn,{error:t.error,title:"Couldn’t load this app",description:"Nothing changed. Try again.",onRetry:()=>void t.refetch(),isRetrying:t.isFetching}):e.jsx(Qa,{...n,detail:t.data})}function Qa({connectionId:n,detail:t,onSignInStarted:s,onEditExactActions:a,onAddAnother:i,onClose:c}){var A;const{connection:r}=t,o=le(""),u=new Map((((A=o.data)==null?void 0:A.pages.flatMap(p=>p.services))??[]).map(p=>[p.serviceSlug,p])),h=Ce(r.toolkit,u),d=Rn(),f=An(),l=ze(),m=In(),x=jt(),y=d.error??f.error??l.error??m.error??x.error,N=()=>d.mutate({connectionId:n},{onSuccess:p=>s(p.flowId)}),k=r.readiness.state==="gone";return e.jsxs("div",{className:"space-y-7",children:[e.jsx(Ja,{detail:t,appName:h,onSignInAgain:N,reconnecting:d.isPending,onResume:()=>l.mutate({connectionId:n,input:void 0}),resuming:l.isPending,onReview:()=>a(n),onConnectNew:()=>i(r.toolkit),onRemove:()=>x.mutate({connectionId:n,input:void 0},{onSuccess:()=>c()}),removing:x.isPending,onRetryDisconnect:()=>m.mutate({connectionId:n,input:void 0}),retryingDisconnect:m.isPending}),y&&e.jsx("p",{role:"alert",className:"text-destructive bg-destructive/5 rounded-lg p-3 text-sm",children:Jn(y)}),!k&&e.jsx(Bn,{mode:"page",variant:"embedded",connectionId:n,serviceName:h,onEditExactActions:a,appActions:{toolkit:r.toolkit,providerInstanceId:r.providerInstanceId}}),e.jsx(Za,{detail:t}),r.readiness.state==="ready"&&e.jsx(Xa,{detail:t}),e.jsx(Ka,{detail:t,onSignInAgain:N,signingIn:d.isPending,appName:h,onEditExactActions:a,onAddAnother:i,onClose:c})]})}function Ja({detail:n,appName:t,onSignInAgain:s,reconnecting:a,onResume:i,resuming:c,onReview:r,onConnectNew:o,onRemove:u,removing:h,onRetryDisconnect:d,retryingDisconnect:f}){const l=Me(),m=yt(),[x,y]=j.useState(!1),{readiness:N}=n.connection;if(N.state==="ready")return null;const k=N.fix,A=k!=null&&k.retryAt?La(k.retryAt):void 0,p=N.copy.owner,g=N.state==="gone",C=(()=>{switch(k==null?void 0:k.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 ${t} again`,onAction:o};case"resume":return{action:"Resume",onAction:i,pending:c};case"review_access":return{action:"Check who can use it",onAction:r};case"fix_key":return{action:"Fix the key",onAction:()=>l.open("connections","ways")};case"retry":return g?{action:"Try again now",onAction:d,pending:f}:{action:"Check again",onAction:()=>m.mutate(),pending:m.isPending};case"remove":return{action:"Remove from your apps",onAction:()=>y(!0),pending:h};case"wait":case"turn_on_for_this_chat":case void 0:return null}})(),$=N.serviceAccessPage;return e.jsxs(e.Fragment,{children:[e.jsx(Ee,{message:p,detail:A,...C??{},secondary:g&&e.jsxs(e.Fragment,{children:[$&&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(qe,{href:$.url,children:["Open ",$.service," settings",e.jsx(Be,{className:"size-3.5","aria-hidden":!0})]})}),(k==null?void 0:k.action)!=="remove"&&e.jsx(b,{size:"sm",variant:"ghost",className:"h-auto min-h-8 max-w-full whitespace-normal",onClick:()=>y(!0),disabled:h,"data-testid":"remove-account",children:"Remove from your apps"})]})}),g&&e.jsx(xe,{open:x,onOpenChange:y,children:e.jsxs(fe,{children:[e.jsxs(je,{children:[e.jsxs(ye,{children:["Remove ",t," from your apps?"]}),e.jsx(ve,{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."}),N.reason==="disconnect_finishing"&&e.jsx("p",{children:"DorkOS still finishes removing its access at the service."})]})})]}),e.jsxs(be,{children:[e.jsx(Ne,{children:"Keep it"}),e.jsx(ke,{disabled:h,onClick:u,children:"Remove app"})]})]})})]})}function Za({detail:n}){var d,f;const{connection:t}=n,s=vt(t.connectionId),{data:a}=ie(),[i,c]=j.useState(!1),r=Object.fromEntries(n.agents.map(l=>[l.agentId,l.displayName]));for(const l of(a==null?void 0:a.agents)??[])r[d=l.id]??(r[d]=Q(l));const o=((f=s.data)==null?void 0:f.items)??[],u=i?o:o.slice(0,an);let h;return t.usage.status==="unavailable"?h=e.jsx("p",{className:"text-muted-foreground text-sm",children:"Activity isn’t available right now."}):s.isPending?h=e.jsx(P,{className:"h-16 rounded-lg"}):s.isError?h=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?h=e.jsx("p",{className:"text-muted-foreground text-sm",children:"Nothing yet."}):h=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:Oa(l,t.toolkit,r)}),e.jsx("span",{className:"text-muted-foreground shrink-0 text-xs",children:De(l.startedAt)})]},`${l.logicalOperationId}-${l.attemptIndex}`))}),e.jsx(me,{title:"Recently",action:o.length>an&&e.jsx(b,{variant:"link",size:"xs",className:"h-auto p-0",onClick:()=>c(l=>!l),children:i?"Show less":"See all"}),children:h})}function Xa({detail:n}){const t=$a(n.connection.toolkit),{data:s}=ie(),{data:a}=bt(),i=kn();if(t.length===0)return null;const c=(a==null?void 0:a.agents)??[],r=d=>c.find(f=>f.id===d)??null,o=((s==null?void 0:s.agents)??[]).find(d=>d.isSystem),u=n.agents.map(d=>r(d.agentId)).find(d=>d!==null)??r(o==null?void 0:o.id),h=u?u.displayName??u.name:null;return e.jsx(me,{title:"Try it",description:h?`Opens a chat with ${h}, ready to send.`:void 0,children:e.jsx("div",{className:"flex flex-wrap gap-2",children:t.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(Cn({session:crypto.randomUUID(),agentId:u.id,draft:"1",prompt:d})),children:[e.jsx(Nt,{className:"text-muted-foreground size-3.5","aria-hidden":!0}),d]},d))})})}function ei(n){return n.requesterKind==="program"?"A program":"Something using your sign-in"}function G(n,t,s){const a=Ce(n,s);return t?`${a} (${t})`:a}function on(n){return n===1?"1 action":`${n} actions`}function ni(n,t){const s=ei(n),a=n.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,t)}`,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,t)}`,detail:"Only its name changes."};case"pause":return{title:`${s} asks to pause ${G(a.connection.toolkit,a.connection.label,t)}`,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,t)}`,detail:"Agents it’s shared with get it back."};case"disconnect":return{title:`${s} asks to disconnect ${G(a.connection.toolkit,a.connection.label,t)}`,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,t)}`,detail:`${on(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,t)}`,detail:a.keptThroughEveryAgent.length>0?`Still shared with every agent, so it keeps ${on(a.keptThroughEveryAgent.length)}.`:"It loses access to this app."}}}function ti(n,t){if(n.state!=="approved")return null;const s=n.context,a=s.kind==="connect"?G(s.toolkit,s.label,t):s.kind==="unavailable"?"the connection":G(s.connection.toolkit,s.connection.label,t);return n.resolution.kind==="connect_authentication_required"?{title:`Approved: finish signing in to ${a}`,detail:"Open it to finish signing in."}:n.resolution.kind==="outcome_unknown"?{title:`Check ${a} before another change`,detail:"Couldn’t confirm the approved change took effect."}:null}const si=10080*60*1e3,ai=kt,ii=60*1e3;function oi({services:n,onOpenRequest:t,onOpenReview:s}){var d,f;const a=Vs("pending"),i=nn("pending"),c=nn("resolved"),r=ri(),o=(c.data??[]).filter(l=>l.state==="approved"&&(l.resolution.kind==="connect_authentication_required"&&r-Date.parse(l.resolvedAt)<ai||l.resolution.kind==="outcome_unknown"&&r-Date.parse(l.resolvedAt)<si)),u=[a,i,c].filter(l=>l.isError);return!((((d=a.data)==null?void 0:d.length)??0)+(((f=i.data)==null?void 0:f.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,n)}`,detail:l.reason},onOpen:()=>t(l.requestId)},`request-${l.requestId}`)),(i.data??[]).map(l=>e.jsx(Ie,{testId:`needs-you-review-${l.reviewRequestId}`,line:ni(l,n),onOpen:()=>s(l.reviewRequestId)},`review-${l.reviewRequestId}`)),o.map(l=>{const m=ti(l,n);return m?e.jsx(Ie,{testId:`needs-you-review-${l.reviewRequestId}`,line:m,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 ri(){const[n,t]=j.useState(()=>Date.now());return j.useEffect(()=>{const s=setInterval(()=>t(Date.now()),ii);return()=>clearInterval(s)},[]),n}function Ie({testId:n,line:t,onOpen:s}){return e.jsx("li",{children:e.jsxs("button",{type:"button","data-testid":n,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:t.title}),e.jsx("span",{className:"text-muted-foreground line-clamp-2 block text-xs sm:line-clamp-1",children:t.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 ci({requestId:n,open:t,onOpenChange:s,onEditExactActions:a,onCloseAutoFocus:i}){const c=Qs(n),r=c.data?`${c.data.agent.displayName} asked to use ${oe(c.data.serviceSlug)}`:"An agent’s request";return e.jsx(J,{open:t,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:r}),e.jsx(ne,{children:"Answer it here, as in the chat."})]}),e.jsx(te,{className:"pb-4",children:c.isPending?e.jsx(P,{className:"h-40 rounded-xl","aria-label":"Loading the request"}):c.isError?e.jsx(W,{title:"Couldn’t load this request",description:"Nothing changed. Try again.",onRetry:()=>void c.refetch(),isRetrying:c.isFetching}):c.data?e.jsx(As,{request:c.data,className:"max-w-none",...a?{onEditExactActions:a}:{}},c.data.requestId):null})]})})}function li(n){const t=n.context;if(t.kind==="unavailable")return{title:"Older connection request",approveLabel:"Approve"};switch(t.kind){case"connect":return{title:`Connect ${oe(t.toolkit)}${t.label?` (${t.label})`:""}`,approveLabel:"Approve and continue"};case"edit":return{title:`Rename ${t.connection.label}`,approveLabel:"Approve rename"};case"pause":return{title:`Pause ${t.connection.label}`,approveLabel:"Approve pause"};case"resume":return{title:`Resume ${t.connection.label}`,approveLabel:"Approve resume"};case"disconnect":return{title:`Disconnect ${t.connection.label}`,approveLabel:"Approve disconnect"};case"set_agent_access":return{title:`Change access for ${t.agent.displayName}`,approveLabel:"Approve access"};case"remove_agent_access":return{title:`Remove access for ${t.agent.displayName}`,approveLabel:"Approve removal"}}}function di(n){return(n.split(".").at(-1)??n).replaceAll("_"," ").replace(/\b\w/g,s=>s.toUpperCase())}function et(n){const t=new Map;for(const s of n){const a=t.get(s.operationSlug);(!a||s.toolkitVersion.localeCompare(a.toolkitVersion,void 0,{numeric:!0})>0)&&t.set(s.operationSlug,s)}return new Set(n.filter(s=>s.toolkitVersion.localeCompare(t.get(s.operationSlug).toolkitVersion,void 0,{numeric:!0})<0).map(s=>s.operationRevisionId))}function ui({reviewRequestId:n,open:t,onOpenChange:s,onCloseAutoFocus:a}){var k;const i=Js(n),c=Zs(),[r,o]=j.useState(!1),[u,h]=j.useState(!1),d=i.data,f=(d==null?void 0:d.state)==="approved"&&d.resolution.kind==="connect_authentication_required"?d.resolution.authentication:null,l=r||!!(f&&!f.authorizeUrl),m=Xs((f==null?void 0:f.flowId)??null,l),x=m.isError?"check_failed":((k=m.data)==null?void 0:k.state)??(l?"checking":"required"),y=j.useMemo(()=>d?li(d):null,[d]),N=A=>{!n||u||c.mutate({reviewRequestId:n,decision:A},{onError:()=>{h(!0)}})};return e.jsx(J,{open:t,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:(y==null?void 0:y.title)??"Review connection request"}),e.jsx(ne,{className:"text-foreground",children:"Check the account, agent and actions first."})]}),e.jsx(te,{className:"space-y-4 pb-4",children:i.isLoading?e.jsx(P,{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&&y?e.jsxs(e.Fragment,{children:[e.jsx(hi,{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(Ct,{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(gi,{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."})]}),f&&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:x==="connected"?"Account connected":x==="failed"||x==="expired"||x==="start_unknown"?"Sign-in didn’t finish":x==="pending"||x==="starting"?"Waiting for sign-in":x==="checking"?"Checking sign-in":x==="check_failed"?"Couldn’t check sign-in":"Sign-in still required"}),e.jsx("p",{className:"text-muted-foreground text-sm",children:x==="connected"?"Sign-in finished and the account is ready.":x==="expired"?"The sign-in timed out. Connect it yourself on the Connections page.":x==="start_unknown"?"DorkOS can’t tell if the sign-in started. Connect it on the Connections page.":x==="failed"?"Sign-in didn’t finish. Connect it yourself on the Connections page.":x==="pending"||x==="starting"||x==="checking"?"Finish signing in. This page updates when the account is ready.":x==="check_failed"?"The account may be connected. Check again before another request.":"No account connected yet. Continue to the service to sign in."}),x==="check_failed"?e.jsx(b,{onClick:()=>void m.refetch(),disabled:m.isFetching,children:m.isFetching?"Checking…":"Check again"}):x!=="connected"&&x!=="failed"&&x!=="expired"&&x!=="start_unknown"&&f.authorizeUrl?e.jsx(b,{asChild:!0,children:e.jsxs(qe,{href:f.authorizeUrl,onOpened:()=>o(!0),children:["Continue to sign in",e.jsx(Be,{className:"size-4","aria-hidden":!0})]})}):x==="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||(h(!1),c.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:()=>N("denied"),disabled:c.isPending,children:"Deny"}),d.targetStatus==="available"&&d.context.kind!=="unavailable"&&e.jsx(b,{onClick:()=>N("approved"),disabled:c.isPending,children:c.isPending?"Saving decision…":y==null?void 0:y.approveLabel})]}):e.jsx(b,{variant:"secondary",onClick:()=>s(!1),children:"Done"})})]})})}function hi({context:n}){if(n.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(n.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(n.toolkit)}),e.jsx("dt",{children:"Connected through"}),e.jsx("dd",{children:n.providerDisplayName}),n.label&&e.jsxs(e.Fragment,{children:[e.jsx("dt",{children:"Label"}),e.jsx("dd",{children:n.label})]})]});const t=n.kind==="set_agent_access"?n.requestedOperations:n.kind==="remove_agent_access"||n.kind==="disconnect"?n.affectedOperations:[],s=et(t),a=n.kind==="set_agent_access"||n.kind==="remove_agent_access"?n.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:n.connection.label}),e.jsx("dt",{children:"App"}),e.jsx("dd",{children:oe(n.connection.toolkit)}),e.jsx("dt",{children:"Status"}),e.jsx("dd",{children:wt[n.connection.status]}),e.jsx("dt",{children:"Sign-in"}),e.jsx("dd",{"data-testid":"connector-review-custody",children:mi(n.connection)}),a&&e.jsxs(e.Fragment,{children:[e.jsx("dt",{children:"Agent"}),e.jsx("dd",{children:a.displayName})]})]}),n.kind==="disconnect"&&e.jsx("p",{"data-testid":"connector-review-impact",className:"text-sm font-medium",children:n.everyAgent?"Every agent loses this account. It’s shared with every agent now.":`Removes this account from ${n.affectedAgentCount} ${n.affectedAgentCount===1?"agent":"agents"}.`}),n.kind==="remove_agent_access"&&n.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:[n.agent.displayName," keeps ",n.keptThroughEveryAgent.length," ",n.keptThroughEveryAgent.length===1?"action":"actions"," on"," ",n.connection.label," through “Every agent”."]}),e.jsxs("p",{children:["Approving removes only what ",n.agent.displayName," has by name."]}),e.jsxs("p",{children:["To remove it all, stop sharing ",n.connection.label," with every agent in Connections."]})]}),t.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:t.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:[di(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:Tn[i.capabilityClassification]})]},i.operationRevisionId))})]})]})}function mi(n){switch(n.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 gi({review:n}){if(n.state==="pending")return null;if(n.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 t=n.state==="denied"?"Denied":n.state==="expired"?"Expired":n.resolution.kind==="applied"?"Approved and applied":n.resolution.kind==="outcome_unknown"?"Outcome unknown":"Approved",s=n.state==="expired"?"This request can no longer change access.":n.state==="denied"?"No requested change was made.":n.resolution.kind==="applied"?"The requested change was applied.":n.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":n.state==="approved"?n.resolution.kind:n.state,className:"bg-muted/40 rounded-lg border p-4",children:[e.jsx("p",{className:"text-sm font-medium",children:t}),e.jsx("p",{className:"text-muted-foreground mt-1 text-sm",children:s})]})}function pi(n,t){switch(n){case"service_not_ready":return{title:`${t} can’t be connected yet`,description:"This isn’t something you can fix here.",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:`${t} isn’t available right now`,description:"Nothing was connected. Try again in a few minutes.",canRetry:!0}}}const xi=new Set(["provider_not_found","authentication_unavailable"]);function fi(n,t){const s=typeof n=="object"&&n!==null&&"code"in n?n.code:void 0;return typeof s=="string"&&xi.has(s)?{title:"Couldn’t start the connection",description:`The way DorkOS reaches ${t} 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 ji(n,t){const s=n.authenticationSetup;return s?s.source==="configured"?`${t} uses its own sign-in page.`:s.kind==="oauth"?`A ${t} sign-in page opens next.`:s.kind==="fields"&&n.mode==="managed"?`Enter your ${t} details on dorkos.ai. DorkOS doesn’t save them.`:s.kind==="none"&&n.mode==="managed"?`Confirm this ${t} connection on dorkos.ai. No account details needed.`:null:null}function rn(n,t){var s,a,i;return(n==null?void 0:n.mode)==="managed"&&((s=n.authenticationSetup)==null?void 0:s.kind)==="fields"?"Enter account details":(n==null?void 0:n.mode)==="managed"&&((a=n.authenticationSetup)==null?void 0:a.kind)==="none"?"Review and confirm":((i=n==null?void 0:n.authenticationSetup)==null?void 0:i.source)==="configured"?"Continue":t==="authorize"?"Open sign-in":(n==null?void 0:n.authKind)==="none"?"Check connection":"Continue"}function cn({copy:n,onRetry:t,isRetrying:s=!1,onClose:a}){return n.canRetry&&t?e.jsx(W,{title:n.title,description:n.description,onRetry:t,isRetrying:s}):e.jsxs("div",{"data-testid":"connect-refusal",className:"space-y-2",children:[e.jsx(Rt,{icon:wn,tone:"destructive",headline:n.title,description:n.description}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[n.action==="relink"&&e.jsx(Ds,{variant:"outline",size:"sm"}),a&&e.jsx(b,{variant:"secondary",size:"sm",onClick:a,children:"Close"})]})]})}function yi({service:n,flowId:t,onFlowIdChange:s,onClose:a,onChooseAccess:i,onConnected:c}){var re,ce,_;const[r,o]=j.useState(!!(n||t)),[u,h]=j.useState(""),[d,f]=j.useState(null),[l,m]=j.useState(!1),x=St(),y=$n(t),N=((re=y.data)==null?void 0:re.toolkit)??(n==null?void 0:n.serviceSlug)??"",k=le(N),A=(ce=k.data)==null?void 0:ce.pages.flatMap(T=>T.services).find(T=>T.serviceSlug===N),p=(_=k.data)==null?void 0:_.pages[0],g=p==null?void 0:p.appConnections,C=A??n??null,$=Is(C),Y=$.filter(T=>T.capabilities.authentication.status==="available").length,S=$.find(T=>T.providerInstanceId===d)??(y.data?$.find(T=>T.providerInstanceId===y.data.providerInstanceId):null)??Rs($,g==null?void 0:g.newApps),R=y.data??x.data,w=!R&&Ts(C),E=(C==null?void 0:C.displayName)??oe((R==null?void 0:R.toolkit)??"service"),z=S?ji(S,E):null,U=S?Sn(S):null,I=$s(S,C),L=()=>{o(!1),a()},O=()=>{s(null),L()},F=()=>{if(!C||!S)return;const T={providerInstanceId:S.providerInstanceId,...u.trim()&&{label:u.trim()}};x.mutate({...T,toolkit:C.serviceSlug,idempotencyKey:crypto.randomUUID()},{onSuccess:H=>s(H.flowId)})};return e.jsx(e.Fragment,{children:e.jsx(J,{open:r,onOpenChange:T=>{T?o(!0):L()},children:e.jsxs(Z,{"data-testid":"connect-auth-dialog",className:B("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(ne,{children:R?"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(te,{className:"space-y-4 pb-4",children:w&&$.length===0&&_s(p)&&(g==null?void 0:g.newApps.status)==="ready"?e.jsx(W,{title:`Couldn’t reach ${E} just now`,description:`${Es(g.newApps.way)} didn’t answer. Try again in a moment.`,onRetry:()=>void k.refetch(),isRetrying:k.isFetching}):w?e.jsx(Ps,{reason:Os(g,C),onLeave:L}):R?R.state==="starting"||R.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})]}),R.state==="pending"&&R.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(qe,{href:R.authorizeUrl,keepOpener:(S==null?void 0:S.mode)==="managed",children:[rn(S,"authorize"),e.jsx(Be,{className:"size-4","aria-hidden":!0})]})})]}):e.jsxs("p",{className:"flex items-center gap-2 text-sm",children:[e.jsx(_n,{className:"size-4 animate-spin","aria-hidden":!0}),R.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."}),y.isError&&e.jsx(W,{title:"Couldn’t check the connection",description:"Sign-in may still finish. Check again.",onRetry:()=>void y.refetch(),isRetrying:y.isFetching})]}):R.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(It,{className:"text-status-success size-4","aria-hidden":!0}),e.jsxs("span",{children:[E," is connected"]})]}),e.jsx(Bn,{mode:"page",connectionId:R.connectionId,serviceName:E,logo:We(C),onSkip:()=>{O(),c==null||c(R.connectionId)},onFinished:()=>{O(),c==null||c(R.connectionId)},onEditExactActions:T=>{i(T),O()}})]}):R.state==="failed"&&R.failureCode?(()=>{const T=pi(R.failureCode,E);return e.jsx(cn,{copy:T,onRetry:T.canRetry?()=>{s(null),x.reset()}:void 0,onClose:O})})():e.jsxs("div",{className:"space-y-3",children:[e.jsx("p",{role:"alert",className:"text-destructive text-sm font-medium",children:R.state==="expired"?"This connection request expired.":"The connection didn’t finish."}),"reason"in R&&e.jsx("p",{className:"text-muted-foreground text-xs",children:R.reason}),e.jsx(b,{variant:"secondary",onClick:()=>{s(null),x.reset()},children:"Start again"})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(Fe,{htmlFor:"connection-label",children:"Account label"}),e.jsx(Le,{id:"connection-label",value:u,onChange:T=>h(T.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(At,{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:()=>m(T=>!T),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(Ls,{toolkit:N,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"}),$.map(T=>{const H=T.capabilities.authentication.status==="available";return e.jsxs("button",{type:"button",disabled:!H,onClick:()=>{f(T.providerInstanceId),m(!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:T.displayName})}),!H&&e.jsx("span",{className:"text-muted-foreground text-xs",children:"Unavailable"})]},T.providerInstanceId)})]}),x.isError&&e.jsx(cn,{copy:fi(x.error,E),onRetry:F,isRetrying:x.isPending})]})}),!R&&e.jsxs(ge,{children:[e.jsx(b,{variant:"ghost",onClick:L,children:"Cancel"}),!w&&e.jsx(b,{onClick:F,disabled:!S||x.isPending,children:x.isPending?"Starting…":rn(S,"start")})]})]})})})}function vi(n){var s,a;const t=((s=n.senderName)==null?void 0:s.trim())||"Someone";if(n.chatKind==="group"){const i=(a=n.chatTitle)==null?void 0:a.trim();return i?`${t} added your bot to “${i}”`:`${t} added your bot to a group`}return`${t} messaged your bot`}function ln(n){return n.chatKind==="group"?"Which agent should join?":"Which agent should answer?"}function bi(n){return n.chatKind==="group"&&n.platformChatType==="channel"}function Ni({chat:n,agentOptions:t,onClaim:s,onIgnore:a,onBlock:i,onLeave:c,isDeciding:r=!1}){var f;const[o,u]=j.useState(t.length===1?((f=t[0])==null?void 0:f.id)??"":""),h=n.chatKind==="group",d=bi(n);return e.jsxs(ea,{"data-testid":`claim-card-${n.id}`,gap:"sm",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-sm font-medium",children:vi(n)}),e.jsxs("p",{className:"text-muted-foreground text-xs",children:[n.messageCount===1?"One message so far.":`${n.messageCount} messages so far.`," ","Not read or answered yet."]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[!d&&e.jsxs(En,{value:o,onValueChange:u,disabled:r,children:[e.jsx(Pn,{className:"w-full sm:w-56","aria-label":ln(n),"data-testid":`claim-agent-${n.id}`,children:e.jsx(On,{placeholder:ln(n)})}),e.jsx(Ln,{children:t.map(l=>e.jsx($e,{value:l.id,children:Q(l)},l.id))})]}),d?null:h?e.jsx(b,{size:"sm",disabled:!o||r,onClick:()=>s(o,!0),children:"Join"}):e.jsxs(e.Fragment,{children:[e.jsx(b,{size:"sm",disabled:!o||r,onClick:()=>s(o,!0),children:"Answer in a channel"}),e.jsx(b,{size:"sm",variant:"outline",disabled:!o||r,onClick:()=>s(o,!1),children:"Answer privately"})]}),e.jsx(b,{size:"sm",variant:"ghost",disabled:r,onClick:a,children:"Ignore"}),h?e.jsx(b,{size:"sm",variant:"ghost",disabled:r,onClick:c,children:"Leave"}):e.jsx(b,{size:"sm",variant:"ghost",disabled:r,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."}):h?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 ki({enabled:n,adapterId:t}){Bs();const{data:s,isLoading:a}=Un("pending",n),{data:i}=ie(),c=Us(),r=Ws(),o=Ks(),u=Ys(),h=Ue(),[d,f]=j.useState(null),l=(i==null?void 0:i.agents)??[],m=(s??[]).filter(y=>!t||y.adapterId===t),x=c.isPending||r.isPending||o.isPending||u.isPending;return n?a?e.jsx(P,{className:"h-28 w-full rounded-lg"}):m.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:m.length===1?"Someone messaged a bot with no agent to answer.":`${m.length} chats reached a bot with no agent to answer.`})]}),m.map(y=>e.jsx(Ni,{chat:y,agentOptions:l,isDeciding:x,onClaim:(N,k)=>{var p;const A=((p=l.find(g=>g.id===N))==null?void 0:p.name)??N;c.mutate({id:y.id,input:{agentId:N,bridge:k}},{onSuccess:({binding:g,bridgeError:C})=>{if(C){D.warning(`${A} will answer this chat privately: ${C}`);return}if(k&&g.roomId){D.success(`${A} will answer in a new channel.`),h({...Dn.channels(),search:{id:g.roomId}});return}D.success(`${A} will answer this chat.`)},onError:g=>{const C=_e(g,{id:N,name:A});if(C){f(C);return}D.error(g instanceof Error?g.message:"Couldn’t set an agent to answer")}})},onIgnore:()=>r.mutate(y.id,{onSuccess:()=>D.success("Ignored. This chat won’t show again.")}),onBlock:()=>o.mutate(y.id,{onSuccess:()=>D.success("Blocked. This chat is no longer recorded.")}),onLeave:()=>u.mutate(y.id,{onSuccess:()=>D.success("Left the group. It’s no longer recorded.")})},y.id)),e.jsx(Yn,{conflict:d,onClose:()=>f(null)})]}):null}function Ci({connectionId:n,open:t,onOpenChange:s}){var A,p;const[a,i]=j.useState({}),[c,r]=j.useState(null),o=zs({connectionId:n,active:t,onPreview:g=>i(Fs(g))}),{preview:u,saveOutcome:h,saved:d,needsReconciliation:f,needsRefresh:l}=o,m=(p=(A=yn().data)==null?void 0:A.connections.find(g=>g.connectionId===n))==null?void 0:p.readiness,x=(m==null?void 0:m.reason)==="needs_review"||(m==null?void 0:m.reason)==="access_update_failed",y=j.useMemo(()=>u?Ms(u,a):[],[u,a]),N=l||h!==null,k=x&&y.length===0;return e.jsx(J,{open:t,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(ne,{children:"Pick the actions each agent may take. Current access stays selected."})]}),e.jsx(te,{className:"space-y-4 pb-4",children:o.isLoading?e.jsxs("div",{className:"space-y-3","aria-label":"Loading account actions",children:[e.jsx(P,{className:"h-20 rounded-lg"}),e.jsx(P,{className:"h-36 rounded-lg"})]}):o.loadFailed?e.jsx(qn,{error:o.loadError,title:"Couldn’t load account actions",description:"Nothing changed. Try again.",onRetry:o.refresh,isRetrying:o.isLoading}):N?e.jsx(qs,{access:o}):u?e.jsxs(e.Fragment,{children:[x&&m&&e.jsxs("p",{"data-testid":"access-dialog-cause",className:"bg-status-warning-bg text-status-warning-fg rounded-lg p-3 text-sm",children:[m.copy.owner," If this looks right, confirm it."]}),e.jsx(wi,{preview:u,selections:a,setSelections:i,advancedAgentId:c,setAdvancedAgentId:r})]}):null}),e.jsxs(ge,{children:[e.jsx(b,{variant:"ghost",onClick:()=>s(!1),children:d?"Done":h?"Close":"Cancel"}),f?e.jsx(b,{variant:"secondary",onClick:o.refresh,children:"Reload current access"}):h&&!d?e.jsxs(b,{variant:"secondary",onClick:o.checkSync,disabled:o.isCheckingSync,children:[e.jsx(_n,{className:"size-4","aria-hidden":!0}),o.isCheckingSync?"Checking…":"Check if it’s done"]}):!l&&u&&!d?e.jsx(b,{onClick:()=>o.apply(y,void 0,{confirm:k}),disabled:y.length===0&&!x||o.isSaving,children:o.isSaving?"Saving…":k?"Confirm access":"Save access"}):null]})]})})}function wi({preview:n,selections:t,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:n.connection.label}),e.jsx("p",{className:"text-muted-foreground text-xs",children:"Pick a level for each agent. Use Advanced for single actions."})]}),n.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 ",n.everyAgent.operationRevisionIds.length," ",n.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."})]}),n.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:n.agents.map(c=>{const r=et(n.candidates),o=t[c.agentId],u=new Set((o==null?void 0:o.operationRevisionIds)??[]),h=(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===c.agentId,f=l=>s({...t,[c.agentId]:{operationRevisionIds:Tt(n.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 ",c.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:c.displayName}),e.jsx("p",{className:"text-muted-foreground text-xs",children:h})]}),e.jsx(b,{size:"sm",variant:"ghost","aria-expanded":d,onClick:()=>i(d?null:c.agentId),children:"Advanced"})]}),e.jsx("div",{className:"mt-2 grid grid-cols-3 gap-1.5","aria-label":`Quick access for ${c.displayName}`,children:[["none","No access"],["read","Read"],["read-write","Read + write"]].map(([l,m])=>e.jsx(b,{size:"sm",variant:h===m?"secondary":"outline","aria-pressed":h===m,onClick:()=>f(l),className:"px-2 text-xs",children:m},l))}),d&&e.jsx("ul",{className:"mt-3 space-y-1.5","data-testid":`advanced-access-${c.agentId}`,children:n.candidates.map(l=>{const m=u.has(l.operationRevisionId),x=!l.supported&&!m;return e.jsxs("li",{className:"bg-background flex gap-3 rounded-md p-2.5",children:[e.jsx(Nn,{"aria-label":`${Te(l.operationSlug,n.connection.toolkit)} for ${c.displayName}`,checked:m,disabled:x,onCheckedChange:y=>{const N=new Set(u);y===!0?N.add(l.operationRevisionId):N.delete(l.operationRevisionId),s({...t,[c.agentId]:{operationRevisionIds:[...N].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:Te(l.operationSlug,n.connection.toolkit)}),e.jsx(K,{size:"xs",variant:l.capabilityClassification==="destructive"?"destructive":"secondary",children:Tn[l.capabilityClassification]}),!l.supported&&e.jsx(K,{size:"xs",variant:"outline",children:"No longer available"}),r.has(l.operationRevisionId)&&e.jsx("span",{className:"text-muted-foreground text-xs",children:"Older version"})]})})]},l.operationRevisionId)})})]},c.agentId)})})]})}function Si({agentName:n,sessionStrategy:t,chatId:s,channelType:a,canInitiate:i=!1,canReply:c=!0,canReceive:r=!0}){return e.jsxs("div",{className:"text-muted-foreground flex items-center gap-2 text-sm",children:[e.jsx("span",{className:"truncate",children:n}),t!=="per-chat"&&e.jsx(K,{variant:"secondary",className:"shrink-0",children:ta(t)}),s&&e.jsx(K,{variant:"outline",className:"shrink-0 truncate",children:a?`#${s}`:s}),e.jsxs($t,{children:[i&&e.jsxs(we,{children:[e.jsx(Se,{asChild:!0,children:e.jsx(_t,{className:"size-3 shrink-0 text-amber-500","aria-label":"Can message first"})}),e.jsx(Ae,{children:"Can message first"})]}),!c&&e.jsxs(we,{children:[e.jsx(Se,{asChild:!0,children:e.jsx(sa,{className:"text-muted-foreground/70 size-3 shrink-0","aria-label":"Can’t reply"})}),e.jsx(Ae,{children:"Can’t reply"})]}),!r&&e.jsxs(we,{children:[e.jsx(Se,{asChild:!0,children:e.jsx(Et,{className:"text-muted-foreground/70 size-3 shrink-0","aria-label":"Doesn’t receive messages"})}),e.jsx(Ae,{children:"Doesn’t receive messages"})]})]})]})}const Ai=["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 Ii({binding:n,onDone:t}){const s=Ke({errorLabel:"Couldn’t bridge that chat"}),a=Ue();if(n.bridge==="room")return e.jsx(Ri,{binding:n,onDone:t});if(!n.chatId)return e.jsx(Re,{reason:"This reaches every chat here. Point it at one chat first."});if(n.platformChatType==="channel")return e.jsx(Re,{reason:"This is a broadcast channel, not a two-way chat. Your agent can’t reply."});const i=n.channelType==null||n.channelType==="dm";if(!(n.platformChatType==="private"||n.platformChatType==="group"||n.platformChatType==="supergroup"||n.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 r(){try{const o=await s.mutateAsync({id:n.id,updates:{bridge:"room"}});o.roomId&&a({...Dn.channels(),search:{id:o.roomId}}),t==null||t()}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(zn,{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:Ai.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:r,disabled:s.isPending,children:[s.isPending&&e.jsx(se,{size:"xs",className:"mr-1.5"}),"Bridge to a channel"]})]})}function Ri({binding:n,onDone:t}){const s=Ke({errorLabel:"Couldn’t un-bridge that chat"}),a=Pt(),{data:i}=Ot(n.roomId??null),c=i!==void 0,r=(i==null?void 0:i.deliverNotices)??!1;async function o(){try{await s.mutateAsync({id:n.id,updates:{bridge:"off"}}),D.success("This chat is private again"),t==null||t()}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(zn,{className:"text-muted-foreground size-4"}),e.jsx("p",{className:"text-sm font-medium",children:"This chat is a channel"})]}),n.roomId&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx(Fe,{htmlFor:"bridge-deliver-notices",className:"cursor-pointer text-xs font-normal",children:"Tell this chat when your agent stops early"}),e.jsx(Lt,{id:"bridge-deliver-notices",checked:r,disabled:!c||a.isPending,onCheckedChange:u=>a.mutate({roomId:n.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(xe,{children:[e.jsx(Dt,{asChild:!0,children:e.jsx(b,{variant:"ghost",size:"sm",className:"text-muted-foreground",children:"Un-bridge this chat"})}),e.jsxs(fe,{children:[e.jsxs(je,{children:[e.jsx(ye,{children:"Un-bridge this chat?"}),e.jsx(ve,{children:"Its channel is archived. The chat goes back to a private, one-to-one line."})]}),e.jsxs(zt,{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(be,{children:[e.jsx(Ne,{children:"Keep it bridged"}),e.jsx(ke,{onClick:o,children:"Un-bridge"})]})]})]})]})}function Re({reason:n}){return e.jsxs("section",{className:"border-border/60 bg-muted/30 flex gap-2 rounded-lg border p-3",children:[e.jsx(Ft,{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:n})]})]})}function Ti({adapterId:n,onQuickBind:t,onAdvanced:s,isPending:a,children:i}){const[c,r]=j.useState(!1),{data:o}=ie(),{data:u=[]}=pe(),h=j.useMemo(()=>new Set(u.filter(m=>m.adapterId===n).map(m=>m.agentId)),[u,n]),d=j.useMemo(()=>((o==null?void 0:o.agents)??[]).filter(m=>!h.has(m.id)),[o,h]);async function f(m){await t(m),r(!1)}function l(){r(!1),s()}return e.jsxs(Mt,{open:c,onOpenChange:r,children:[e.jsx(qt,{asChild:!0,children:i}),e.jsxs(Bt,{className:"w-56 p-0",align:"start",children:[e.jsxs(Ut,{children:[e.jsx(Wt,{placeholder:"Search agents…"}),e.jsxs(Kt,{children:[e.jsx(Yt,{children:"No agents to add"}),d.map(m=>e.jsxs(Ht,{value:m.id,keywords:[Q(m)],onSelect:()=>f(m.id),disabled:a,children:[a?e.jsx(se,{size:"xs",className:"mr-2"}):null,Q(m)]},m.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 $i({instance:n,appName:t,emphasizePick:s=!0}){const{data:a=[]}=pe(),{data:i}=ie(),c=Gt({suppressErrorToast:!0}),r=Ke({suppressErrorToast:!0}),o=na(),[u,h]=j.useState(null),[d,f]=j.useState(null),l=(i==null?void 0:i.agents)??[],m=g=>{const C=l.find($=>$.id===g);return C?Q(C):g},x=a.filter(g=>g.adapterId===n.id);async function y(g){try{await c.mutateAsync({adapterId:n.id,agentId:g,sessionStrategy:"per-chat",label:""}),D.success(`${m(g)} answers ${t} now`)}catch(C){const $=_e(C,{id:g,name:m(g)});if($){f($);return}D.error(C instanceof Error?C.message:"Couldn’t set who answers")}}async function N(g){if(u)try{u.mode==="edit"?(await r.mutateAsync({id:u.binding.id,updates:Jt(g)}),D.success("Saved")):(await c.mutateAsync(Zt(g)),D.success(`${m(g.agentId)} answers ${t} now`)),h(null)}catch(C){const $=_e(C,{id:g.agentId,name:m(g.agentId)});if($){f($);return}D.error(C instanceof Error?C.message:"Couldn’t save that")}}async function k(g){try{await o.mutateAsync(g),D.success("Removed"),h(null)}catch{}}const A=(g,C)=>e.jsx(Ti,{adapterId:n.id,onQuickBind:y,onAdvanced:()=>h({mode:"create"}),isPending:c.isPending,children:e.jsxs(b,{variant:C,size:"sm",children:[e.jsx(Qt,{className:"size-3.5","aria-hidden":!0}),g]})}),p=(u==null?void 0:u.mode)==="edit"?u.binding:null;return e.jsxs("div",{className:"space-y-2","data-testid":"chat-app-answerers",children:[x.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:x.map(g=>e.jsx("li",{children:e.jsxs("button",{type:"button",onClick:()=>h({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(Si,{agentName:m(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(Vt,{open:!0,onOpenChange:g=>{g||h(null)},mode:u.mode,initialValues:p?{adapterId:p.adapterId,agentId:p.agentId,sessionStrategy:p.sessionStrategy,label:p.label??"",permissionMode:p.permissionMode,chatId:p.chatId,channelType:p.channelType,canInitiate:p.canInitiate,canReply:p.canReply,canReceive:p.canReceive}:{adapterId:n.id},adapterName:t,agentName:p?m(p.agentId):void 0,onConfirm:N,onDelete:p?k:void 0,bindingId:p==null?void 0:p.id,isPending:c.isPending||r.isPending||o.isPending,bridged:(p==null?void 0:p.bridge)==="room",bridgeSlot:p?e.jsx(Ii,{binding:p,onDone:()=>h(null)}):void 0}),e.jsx(Yn,{conflict:d,onClose:()=>f(null),onMoved:()=>h(null)})]})}const _i={"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"},Pe={"adapter.connected":"Connected","adapter.disconnected":"Disconnected","adapter.message_received":"Received","adapter.message_sent":"Sent","adapter.error":"Error","adapter.status_change":"Status"},Ei=Object.keys(Pe);function Pi({adapterId:n}){const{data:t,isLoading:s}=Kn(n),[a,i]=j.useState("all"),c=j.useRef(null),[r,o]=j.useState(!0),u=j.useCallback(()=>{const l=c.current;if(!l)return;o(l.scrollHeight-l.scrollTop-l.clientHeight<20)},[]);j.useEffect(()=>{r&&c.current&&(c.current.scrollTop=c.current.scrollHeight)},[t,r]);const h=()=>{c.current&&(c.current.scrollTop=c.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(P,{className:"h-6 w-full"},l))});const d=(t==null?void 0:t.events)??[],f=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(Xt,{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(En,{value:a,onValueChange:i,children:[e.jsx(Pn,{responsive:!1,className:"h-7 w-[130px] text-xs",children:e.jsx(On,{})}),e.jsxs(Ln,{children:[e.jsx($e,{value:"all",children:"All types"}),Ei.map(l=>e.jsx($e,{value:l,children:Pe[l]},l))]})]})]}),e.jsx("div",{ref:c,onScroll:u,className:"flex-1 overflow-y-auto p-2",children:f.map(l=>{const m=l.metadata?JSON.parse(l.metadata):null,x=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:x}),e.jsx(K,{size:"xs",variant:"secondary",className:B("shrink-0",_i[l.subject]??""),children:Pe[l.subject]??l.subject}),e.jsx("span",{className:"text-xs break-words",children:(m==null?void 0:m.message)??l.subject})]},l.id)})}),!r&&e.jsx("div",{className:"flex justify-center border-t py-1",children:e.jsxs(b,{variant:"ghost",size:"sm",onClick:h,className:"h-6 text-xs",children:[e.jsx(es,{className:"mr-1 size-3"}),"Jump to bottom"]})})]})}const Oi=3,Li={"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 Di(n){if(!n)return null;try{return JSON.parse(n)}catch{return null}}function zi(n,t){if(n==="adapter.error"){const s=Di(t);return s!=null&&s.message?`Something went wrong: ${s.message}`:"Something went wrong"}return Li[n]??n}function Fi({adapterId:n}){const{data:t,isPending:s,isError:a,refetch:i}=Kn(n),[c,r]=j.useState(!1),o=(t==null?void 0:t.events)??[],[u,h]=j.useState(null);return s?e.jsx(P,{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."}):c?e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"bg-muted/30 h-72 overflow-hidden rounded-lg",children:e.jsx(Pi,{adapterId:n})}),e.jsx(b,{variant:"link",size:"xs",className:"h-auto p-0",onClick:()=>r(!1),children:"Show less"})]}):e.jsxs("div",{className:"space-y-2",children:[e.jsx("ul",{className:"space-y-1.5",children:o.slice(0,Oi).map(d=>{const f=zi(d.subject,d.metadata),l=u===d.id,m=e.jsx("span",{className:"text-muted-foreground shrink-0 text-xs",children:De(d.sentAt)});return d.subject==="adapter.error"?e.jsx("li",{children:e.jsxs("button",{type:"button","aria-expanded":l,onClick:()=>h(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:B("min-w-0",l?"break-words":"truncate"),children:f}),m]})},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:f}),m]},d.id)})}),e.jsx(b,{variant:"link",size:"xs",className:"h-auto p-0",onClick:()=>r(!0),children:"See all"})]})}function Mi({row:n,open:t,onOpenChange:s,onCloseAutoFocus:a,children:i}){const c=ns(),[r,o]=j.useState({open:t,mobile:c});let u=r.mobile;(r.open!==t||!t&&r.mobile!==c)&&(o({open:t,mobile:c}),u=c);const h=n&&e.jsxs("div",{className:"flex items-center gap-3 pr-8",children:[e.jsx(fn,{iconKey:n.iconKey,displayName:n.name,logo:n.logo,className:"size-10 rounded-lg"}),e.jsxs("div",{className:"min-w-0 flex-1 text-left",children:[e.jsxs(un,{mobile:u,className:"flex items-center gap-2 text-base font-semibold",children:[e.jsx("span",{className:"truncate",children:n.name}),n.kind==="chat"&&e.jsx(K,{size:"xs",variant:"secondary",children:"Chat"})]}),e.jsxs(hn,{mobile:u,className:"text-muted-foreground flex min-w-0 items-center gap-1.5 text-xs",children:[n.account&&e.jsx("span",{className:"truncate",children:n.identity?`${n.account} · ${n.identity}`:n.account}),n.tone==="ready"&&e.jsxs("span",{className:"flex shrink-0 items-center gap-1.5",children:[n.account&&e.jsx("span",{"aria-hidden":!0,children:"·"}),e.jsx("span",{className:B("size-2 rounded-full",jn.success),"aria-hidden":!0}),"Connected"]})]})]})]}),d=e.jsxs(e.Fragment,{children:[e.jsx(un,{mobile:u,className:"sr-only",children:"App details"}),e.jsx(hn,{mobile:u,className:"sr-only",children:"Loading this app."})]});return u?e.jsx(ts,{open:t,onOpenChange:s,children:e.jsxs(ss,{className:"max-h-[88vh] outline-none","data-testid":"app-panel",onOpenAutoFocus:dn,onCloseAutoFocus:a,children:[e.jsx("div",{className:"px-4 pt-3 pb-3",children:h??d}),e.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto px-4 pb-6",children:i})]})}):e.jsx(as,{open:t,onOpenChange:s,children:e.jsxs(is,{className:"w-full gap-0 outline-none","data-testid":"app-panel",onOpenAutoFocus:dn,onCloseAutoFocus:a,children:[e.jsx("div",{className:"px-6 pt-5 pb-4",children:h??d}),e.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto px-6 pb-8",children:i})]})})}function dn(n){var t;n.preventDefault(),(t=n.currentTarget)==null||t.focus()}function un({mobile:n,className:t,children:s}){return n?e.jsx(os,{className:t,children:s}):e.jsx(rs,{className:t,children:s})}function hn({mobile:n,className:t,children:s}){return n?e.jsx(cs,{className:t,children:s}):e.jsx(ls,{className:t,children:s})}function qi({service:n,onClose:t,onChooseChat:s,onChooseAccount:a}){const i=(n==null?void 0:n.displayName)??"";return e.jsx(J,{open:n!==null,onOpenChange:c=>!c&&t(),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(ne,{children:"What do you want to do?"})]}),e.jsxs(te,{className:"space-y-2 pb-5",children:[e.jsx(mn,{icon:e.jsx(ds,{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:()=>n&&s(n)}),e.jsx(mn,{icon:e.jsx(us,{className:"size-4","aria-hidden":!0}),title:`Let agents use my ${i}`,detail:"Agents can read and post as you.",onClick:()=>n&&a(n)})]})]})})}function mn({icon:n,title:t,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:n}),e.jsxs("span",{className:"min-w-0",children:[e.jsx("span",{className:"block text-sm font-medium",children:t}),e.jsx("span",{className:"text-muted-foreground block text-xs",children:s})]})]})}function Bi({entry:n,instance:t,onClose:s}){const{manifest:a}=n,i=Fn(),c=hs(),r=Oe(),[o,u]=j.useState(null),[h,d]=j.useState(!1),f=t.status.state==="error"||t.status.state==="disconnected",l=m=>i.mutate({id:t.id,enabled:m});return e.jsxs("div",{className:"space-y-7",children:[t.enabled?f?e.jsx(Ee,{message:"Stopped working. Messages aren’t getting through.",technicalDetail:t.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($i,{instance:t,appName:a.displayName,emphasizePick:t.enabled&&!f})}),e.jsx(ki,{enabled:!0,adapterId:t.id}),e.jsx(me,{title:"Recently",children:e.jsx(Fi,{adapterId:t.id})}),e.jsxs(de,{children:[e.jsxs(ue,{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(he,{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")}),t.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(Wn,{open:!0,onOpenChange:m=>{m||u(null)},manifest:a,existingInstance:o==="edit"?t:void 0,existingAdapterIds:n.instances.map(m=>m.id)}),e.jsx(xe,{open:h,onOpenChange:d,children:e.jsxs(fe,{children:[e.jsxs(je,{children:[e.jsxs(ye,{children:["Remove ",a.displayName,"?"]}),e.jsx(ve,{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(be,{children:[e.jsx(Ne,{children:"Keep it"}),e.jsxs(ke,{className:"bg-destructive hover:bg-destructive/90 dark:bg-destructive/60 text-white",onClick:()=>{c.mutate(t.id,{onSuccess:()=>{r.invalidateQueries({queryKey:[...Hs]}),s()}})},children:["Remove ",a.displayName]})]})]})})]})}function Ui(){var r;const n=vn(),t=bn(n.enabled),[s,a]=j.useState(null),i=j.useCallback(o=>{var h;const u=n.enabled?(h=t.data)==null?void 0:h.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.")},[t.data,n.enabled]),c=s?e.jsx(Wn,{open:!0,onOpenChange:o=>{o||a(null)},manifest:s,existingAdapterIds:(r=t.data)==null?void 0:r.flatMap(o=>o.instances.map(u=>u.id))}):null;return{open:i,dialog:c}}function Wi(){var He,Ge,Ve,Qe,Je;const n=ms({from:"/_shell/connections"}),t=Ue({from:"/connections"}),s=j.useCallback(v=>void t({search:q=>{const V={...q,...v};for(const Ze of Object.keys(v))V[Ze]===void 0&&delete V[Ze];return V}}),[t]),[a,i]=j.useState(""),c=j.useDeferredValue(a),[r,o]=j.useState(null),[u,h]=j.useState(!!n.flow),[d,f]=j.useState(null),[l,m]=j.useState(null),x=Ui(),y=j.useRef(null),N=v=>gn(v,y),k=j.useRef(null),A=v=>gn(v,k),p=n.request?null:n.flow??null,g=$n(p),C=(He=g.data)==null?void 0:He.state,$=(Ge=g.data)==null?void 0:Ge.toolkit,Y=j.useMemo(()=>!u&&p&&$&&(C==="starting"||C==="pending")?{flowId:p,toolkit:$}:null,[u,p,C,$]),S=Ra(c,Y),{relay:R}=S;ia(R.enabled);const w=Rn(),E=ze(),z=Fn(),U=Me(),I=w.error??E.error,L=w.isPending&&((Ve=w.variables)==null?void 0:Ve.connectionId)||E.isPending&&((Qe=E.variables)==null?void 0:Qe.connectionId)||z.isPending&&((Je=z.variables)==null?void 0:Je.id)||null,O=v=>{o(null),s({flow:v,app:void 0}),h(!0)},F=v=>{o(v),h(!0)},re=v=>{const q=Gn(v,S.owned),V=R.enabled?q.chatType:null;if(q.account&&V){m(v);return}if(V){x.open(V);return}F(v)},ce=v=>{switch(v.action){case"sign-in-again":w.mutate({connectionId:v.id},{onSuccess:q=>O(q.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":f(v.id);return;case"fix":s({app:v.id});return;case"fix-key":U.open("connections","ways");return;case"connect-again":{const q=v.toolkit?S.services.get(v.toolkit):void 0;q?F(q):s({app:v.id});return}case null:return}},_=n.app?S.allYours.find(v=>v.id===n.app&&v.kind!=="connecting")??null:null,T=(_==null?void 0:_.kind)==="chat"?Ki(S.chatApps,_.id):null;j.useEffect(()=>{n.app&&!S.yoursLoading&&!S.yoursRefreshing&&!S.yoursError&&!_&&s({app:void 0})},[n.app,S.yoursLoading,S.yoursRefreshing,S.yoursError,_,s]);const H=()=>s({app:void 0});return e.jsxs(xs,{width:"reading",children:[e.jsxs("header",{className:"mb-6",children:[e.jsx(gs,{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(oi,{services:S.services,onOpenRequest:v=>{y.current=document.activeElement,s({request:v})},onOpenReview:v=>{y.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:Jn(I)}),e.jsx(Sa,{query:a,onQueryChange:i,data:S,onOpenRow:v=>{if(v.kind==="connecting"){h(!0);return}k.current=document.activeElement,s({app:v.id})},onRowAction:ce,pendingRowId:L,onConnect:re}),e.jsx(Hi,{})]}),e.jsxs(Mi,{row:_,open:_!==null,onOpenChange:v=>{v||H()},onCloseAutoFocus:A,children:[(_==null?void 0:_.kind)==="account"&&e.jsx(Va,{connectionId:_.id,onSignInStarted:O,onEditExactActions:f,onAddAnother:v=>{H(),F(S.services.get(v)??Yi(v,_.name))},onClose:H},_.id),(_==null?void 0:_.kind)==="chat"&&T&&e.jsx(Bi,{entry:T.entry,instance:T.instance,onClose:H},_.id)]}),u&&e.jsx(yi,{service:r,flowId:n.flow??null,onFlowIdChange:v=>s({flow:v??void 0}),onClose:()=>{h(!1),o(null)},onChooseAccess:f,onConnected:v=>s({app:v})},n.flow??(r==null?void 0:r.serviceSlug)??"idle"),e.jsx(ci,{requestId:n.request??null,open:!!n.request&&!u,onOpenChange:v=>{v||s({request:void 0})},onEditExactActions:v=>{s({request:void 0}),f(v)},onCloseAutoFocus:N}),e.jsx(ui,{reviewRequestId:n.review??null,open:!!n.review,onOpenChange:v=>{v||s({review:void 0})},onCloseAutoFocus:N},n.review??"closed"),e.jsx(Ci,{connectionId:d,open:d!==null,onOpenChange:v=>{v||f(null)}},d??"closed"),e.jsx(qi,{service:l,onClose:()=>m(null),onChooseChat:v=>{m(null);const q=Ye(v).chatType;q&&x.open(q)},onChooseAccount:v=>{m(null),F(v)}}),x.dialog]})}function gn(n,t){n.preventDefault();const s=t.current;t.current=null,s!=null&&s.isConnected?s.focus():ps()}function Ki(n,t){for(const s of n){const a=s.instances.find(i=>i.id===t);if(a)return{entry:s,instance:a}}return null}function Yi(n,t){return{serviceSlug:n,displayName:t,iconKey:n,intents:[{kind:"account",displayName:`Use a ${t} account`,routes:[]}]}}function Hi(){const n=Me();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:()=>n.open("connections","ways"),children:"Set it up in Settings › Connections"})]})}const io=Wi;export{io as component};
@@ -1 +0,0 @@
1
- import{j as t}from"./index-C63bLSO4.js";import{M as o}from"./Marketplace-EgG6JmBG.js";import{P as r}from"./page-container-BoXmmBSs.js";import"./PreviewRefusedNotice-Dh3SCC_A.js";import"./shield-x-Bh5xap8N.js";import"./card-CKZCX8ol.js";import"./markdown-content-CoK3F0c0.js";import"./use-unclaimed-chats-BMlFQ2v1.js";import"./UnlinkDialog-TTK5Z_QD.js";import"./use-dev-links-DRnLdl--.js";import"./file-CMPbZedq.js";import"./file-exclamation-point-emLeXvmw.js";import"./rotate-ccw-clock-CGcSqHnk.js";function i(){return t.jsx(r,{width:"wide",children:t.jsx(o,{})})}const M=i;export{M as component};
@@ -1 +0,0 @@
1
- import{j as o}from"./index-C63bLSO4.js";import{P as r}from"./page-container-BoXmmBSs.js";import{M as e}from"./MarketplaceSourcesView-D9kq9hl6.js";import"./use-pending-read-Dol8yvIx.js";function t(){return o.jsx(r,{width:"reading",children:o.jsx(e,{})})}const s=t;export{s as component};