@vellumai/web 0.12.6-staging.2 → 0.12.6

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 (211) hide show
  1. package/dist/assets/{a2a-invite-DLiMk0tx.js → a2a-invite-BfDyIsBX.js} +1 -1
  2. package/dist/assets/{about-page-CiMOdcNb.js → about-page-BigOjgfp.js} +1 -1
  3. package/dist/assets/{account-page-TK116SOZ.js → account-page-DbP0iNWg.js} +1 -1
  4. package/dist/assets/{account-shell-81SeJquZ.js → account-shell-CkJWoTHP.js} +1 -1
  5. package/dist/assets/{acp-run-detail-panel-CmPXAFIy.js → acp-run-detail-panel-DNMcOAkY.js} +1 -1
  6. package/dist/assets/{activation-list-route-CI0Q1kuF.js → activation-list-route-BbPqJODX.js} +1 -1
  7. package/dist/assets/{activity-redirect-page-C_U_6GGf.js → activity-redirect-page-CTGWJZqK.js} +1 -1
  8. package/dist/assets/{activity-steps-panel-C4gojUTz.js → activity-steps-panel-Dz34WmYH.js} +1 -1
  9. package/dist/assets/add-credits-modal-BtnHnN8V.js +1 -0
  10. package/dist/assets/{add-credits-modal-DckEY84t.js → add-credits-modal-DRBFth5G.js} +1 -1
  11. package/dist/assets/{ai-page-BmHi1DMy.js → ai-page-beQly0My.js} +1 -1
  12. package/dist/assets/{all-chats-page-route-Bar5pmkt.js → all-chats-page-route-DlZUO9J_.js} +1 -1
  13. package/dist/assets/{android-billing-handoff-CBj4G7HW.js → android-billing-handoff-CRfjXp7l.js} +1 -1
  14. package/dist/assets/{animated-stat-square-Dh0clEOc.js → animated-stat-square-B-JargN6.js} +1 -1
  15. package/dist/assets/{api-key-screen-CEZN1wmw.js → api-key-screen-jvDwbC50.js} +1 -1
  16. package/dist/assets/{app-6IVvZ0HU.css → app-CgzFhQCl.css} +1 -1
  17. package/dist/assets/{app-D0NlDYsG.js → app-DbJUeBix.js} +13 -13
  18. package/dist/assets/{app-info-D4RcR6ew.js → app-info-VAqkCXW3.js} +1 -1
  19. package/dist/assets/{archive-redirect-page-BzkHSKVl.js → archive-redirect-page-DZMdx89H.js} +1 -1
  20. package/dist/assets/{assistant-handle-modal-CH_OHdcF.js → assistant-handle-modal-C2RftL0v.js} +1 -1
  21. package/dist/assets/{assistant-inbox-page-route-B6wflkJF.js → assistant-inbox-page-route-DLSz1vYi.js} +1 -1
  22. package/dist/assets/{assistant-status-panel-DwkD7W_2.js → assistant-status-panel-BJpCnYoq.js} +1 -1
  23. package/dist/assets/auth-store-Cd-d1a4K.js +1 -0
  24. package/dist/assets/{auth-welcome-screen-DCozLA-c.js → auth-welcome-screen-Bng5AnvV.js} +1 -1
  25. package/dist/assets/avatar-bundled-components-DqGPWIMe.js +1 -0
  26. package/dist/assets/{avatar-random-DITwNAON.js → avatar-random-CVuabfEZ.js} +2 -2
  27. package/dist/assets/{await-org-header-settled-qqVu2-4K.js → await-org-header-settled-P4ncwaMI.js} +1 -1
  28. package/dist/assets/{background-task-detail-panel-DKAy68TE.js → background-task-detail-panel-BcllAg3N.js} +1 -1
  29. package/dist/assets/{billing-page-CKfb20qY.js → billing-page-D54LLGz1.js} +3 -3
  30. package/dist/assets/{billing-redirect-page-2osoPYFq.js → billing-redirect-page-DBSdrzJ7.js} +1 -1
  31. package/dist/assets/{bookmarks-page-BjXRVnIe.js → bookmarks-page-BQyOw7IR.js} +1 -1
  32. package/dist/assets/{bundle-confirm-page-CrdckyMV.js → bundle-confirm-page-BE0p_xZi.js} +1 -1
  33. package/dist/assets/{channel-transcript-panel-BuZfEA7U.js → channel-transcript-panel-BdL4iejZ.js} +1 -1
  34. package/dist/assets/{channels-page-route-Cg7kY8Ai.js → channels-page-route-BseMMdHV.js} +1 -1
  35. package/dist/assets/{chat-info-panel-DL7X3eOQ.js → chat-info-panel-C6px8Mlo.js} +1 -1
  36. package/dist/assets/{checkout-continuation-CY40TSs-.js → checkout-continuation-BniC3jRe.js} +1 -1
  37. package/dist/assets/{checkout-page-B0xOGseN.js → checkout-page-_P1Km-Pk.js} +1 -1
  38. package/dist/assets/checkout-return-target-B3XAFuN6.js +1 -0
  39. package/dist/assets/{command-palette-CQYESNwG.js → command-palette-BMTSC06x.js} +1 -1
  40. package/dist/assets/command-palette-BgqisOfz.js +1 -0
  41. package/dist/assets/{command-palette-window-page-BB81RrWx.js → command-palette-window-page-BlD7b2cA.js} +1 -1
  42. package/dist/assets/{community-page-BtRNJxo9.js → community-page-dezChmB7.js} +1 -1
  43. package/dist/assets/{companion-accent-DPZ9Nluh.js → companion-accent-C8bpme2H.js} +1 -1
  44. package/dist/assets/{companion-dock-zones-page-U9kZSVxS.js → companion-dock-zones-page-B4iVErZw.js} +1 -1
  45. package/dist/assets/{companion-layout-DjM8056C.js → companion-layout-DdDcoKuc.js} +1 -1
  46. package/dist/assets/{companion-popover-DwgXZsMW.js → companion-popover-BYFhyUGI.js} +1 -1
  47. package/dist/assets/{companion-popover-page-CcdLMpdW.js → companion-popover-page-CvizjjZk.js} +1 -1
  48. package/dist/assets/{companion-surface-Da1cTcgR.js → companion-surface-CjiszIMu.js} +1 -1
  49. package/dist/assets/{companion-surface-page--6xuXTFM.js → companion-surface-page-BIpW__dy.js} +1 -1
  50. package/dist/assets/{companion-tour-entry-GiftNvIY.js → companion-tour-entry-2hR1vArn.js} +1 -1
  51. package/dist/assets/{companion-watch-frame-page-BboeANE6.js → companion-watch-frame-page-LUmlRewI.js} +1 -1
  52. package/dist/assets/{connect-page-BqlDwAok.js → connect-page-uRvPpjMP.js} +1 -1
  53. package/dist/assets/{consent-controls-DtYOOcoG.js → consent-controls-DZEtlgAi.js} +1 -1
  54. package/dist/assets/{contacts-gateway-BUQHi3Rm.js → contacts-gateway-DI64mVLV.js} +1 -1
  55. package/dist/assets/{contacts-page-route-CapX1klb.js → contacts-page-route-C_UApZGi.js} +1 -1
  56. package/dist/assets/{copy-button-5QB6tIZi.js → copy-button-ZsDy0Kvk.js} +1 -1
  57. package/dist/assets/{credential-entry-page-C2yTTqSI.js → credential-entry-page-BeKm3_yM.js} +1 -1
  58. package/dist/assets/{credentials-page-DTZCc_jM.js → credentials-page-CLjmeZw3.js} +1 -1
  59. package/dist/assets/{csv-preview-Dg1E9gcw.js → csv-preview-C2fmutVQ.js} +1 -1
  60. package/dist/assets/{danger-zone-redirect-page-BxnmBzTy.js → danger-zone-redirect-page-D5Xk_8UY.js} +1 -1
  61. package/dist/assets/{debug-page-Cv3_hpaB.js → debug-page-tQ4hqmdO.js} +1 -1
  62. package/dist/assets/deploy-dialogs-BW3wFOZ-.js +1 -0
  63. package/dist/assets/{deploy-dialogs-Dy1YiAUx.js → deploy-dialogs-Hu5UmFuB.js} +1 -1
  64. package/dist/assets/{desktop-preview-content-_hBA655n.js → desktop-preview-content-CoZvaRAg.js} +2 -2
  65. package/dist/assets/{desktop-status-t3wLUynb.js → desktop-status-ZiDkY3z1.js} +1 -1
  66. package/dist/assets/{desktop-viewer-Zm7K7Goi.js → desktop-viewer-zD3tun-C.js} +1 -1
  67. package/dist/assets/{detail-card-BhbwKaee.js → detail-card-WMdjzPA_.js} +1 -1
  68. package/dist/assets/{detail-panel-stop-button-BR-k5Xmc.js → detail-panel-stop-button-CPVsXUuy.js} +1 -1
  69. package/dist/assets/{detail-primitives-Dgh4IUh2.js → detail-primitives-CAZf545a.js} +1 -1
  70. package/dist/assets/{developer-page-BeATC5qR.js → developer-page-DpSngWHa.js} +1 -1
  71. package/dist/assets/{devices-redirect-page-BjQ3ITZg.js → devices-redirect-page-BUydOv62.js} +1 -1
  72. package/dist/assets/{dictation-overlay-page-Dy5vIWxC.js → dictation-overlay-page-Cs5bufLA.js} +1 -1
  73. package/dist/assets/{document-load-Ca8B9f1j.js → document-load-CXdi-UrD.js} +1 -1
  74. package/dist/assets/document-load-Dyyzd-te.js +1 -0
  75. package/dist/assets/{document-viewer-page-BXGQ3JBX.js → document-viewer-page-R3nFa-RR.js} +1 -1
  76. package/dist/assets/{emails-page-DJBdc2in.js → emails-page-BUZyXttB.js} +1 -1
  77. package/dist/assets/{file-diff-view-C6IviiAg.js → file-diff-view-5WOLjbDI.js} +1 -1
  78. package/dist/assets/{file-view-mode-CusGxTrO.js → file-view-mode-D6Wxo-FH.js} +1 -1
  79. package/dist/assets/{general-page-BFn9KhSd.js → general-page-BgczK5kM.js} +1 -1
  80. package/dist/assets/{hatching-screen-BPBDkDXC.js → hatching-screen-DUME_h4W.js} +1 -1
  81. package/dist/assets/{hosting-screen-C_1tvRyn.js → hosting-screen-CQosTH53.js} +1 -1
  82. package/dist/assets/{identity-page-route-CBYR7Ik7.js → identity-page-route-CnUbEnOj.js} +1 -1
  83. package/dist/assets/{inspect-page-C1_GK1MG.js → inspect-page-B4pwuqL9.js} +3 -3
  84. package/dist/assets/{integrations-page-tVNddBNW.js → integrations-page-DfV4AIUY.js} +1 -1
  85. package/dist/assets/{intelligence-layout-B2AmY2BP.js → intelligence-layout-CAtJ8qJB.js} +1 -1
  86. package/dist/assets/{intelligence-layout-slots-store-D6qaMstC.js → intelligence-layout-slots-store-DSIw2NvD.js} +1 -1
  87. package/dist/assets/{keyboard-shortcuts-redirect-page-DCra2iW7.js → keyboard-shortcuts-redirect-page-eiKQBBin.js} +1 -1
  88. package/dist/assets/{latest-assistant-text-BvuWjv7_.js → latest-assistant-text-CU1nEv57.js} +1 -1
  89. package/dist/assets/{library-detail-page-DPas89E0.js → library-detail-page-D5TQdRPW.js} +1 -1
  90. package/dist/assets/{library-page-D9RL3HDn.js → library-page-CQHRf1us.js} +1 -1
  91. package/dist/assets/local-mode-glOMwWKw.js +1 -0
  92. package/dist/assets/{login-page-EuF3D2nA.js → login-page-nEJ8VtCM.js} +1 -1
  93. package/dist/assets/{logout-page-BNacG6Tt.js → logout-page-CRexidth.js} +1 -1
  94. package/dist/assets/{logs-layout-DnsMzvJ_.js → logs-layout-C1WQAyKd.js} +1 -1
  95. package/dist/assets/{markdown-preview-C2Z0FRTc.js → markdown-preview-FMAKqNG5.js} +1 -1
  96. package/dist/assets/{media-preview-BcSPsOfs.js → media-preview-DxyJX5PI.js} +1 -1
  97. package/dist/assets/{memory-page-route-CX33STIW.js → memory-page-route-Bt8cmhxi.js} +1 -1
  98. package/dist/assets/{memory-router-playground-page-DgzlohIX.js → memory-router-playground-page-B5SPYr3X.js} +1 -1
  99. package/dist/assets/{message-files-panel-Dc5JcFJT.js → message-files-panel-DM2OHYKS.js} +1 -1
  100. package/dist/assets/mutation-error-DsmwzTdH.js +1 -0
  101. package/dist/assets/native-attachment-pickers-Caaw_YOU.js +1 -0
  102. package/dist/assets/native-file-DICtaDdr.js +1 -0
  103. package/dist/assets/{notifications-page-BXm0OpJB.js → notifications-page-DRBXLm8k.js} +1 -1
  104. package/dist/assets/{oauth-complete-page-D0ymRcSM.js → oauth-complete-page-DgpDdc3q.js} +1 -1
  105. package/dist/assets/{oauth-popup-complete-page-8iZS6PLm.js → oauth-popup-complete-page-v6Kq8SKs.js} +1 -1
  106. package/dist/assets/paired-platform-identity-u4Q-YPGw.js +1 -0
  107. package/dist/assets/{pairing-page-ClXvlMJw.js → pairing-page-Oj52Prdb.js} +1 -1
  108. package/dist/assets/password-reset-page-D3ksp7Ej.js +1 -0
  109. package/dist/assets/{pdf-file-preview-Bl5mk1_3.js → pdf-file-preview-BhDsUdwQ.js} +1 -1
  110. package/dist/assets/{permission-guide-page-BbHEjtyD.js → permission-guide-page-C72w2Kmj.js} +1 -1
  111. package/dist/assets/{permission-setup-3fJQB-KB.js → permission-setup-CJJV_COn.js} +1 -1
  112. package/dist/assets/{personality-page-BTNI4eG5.js → personality-page-CvTaj6nv.js} +1 -1
  113. package/dist/assets/{personality-page-CFaJc26z.js → personality-page-smzeVdLh.js} +1 -1
  114. package/dist/assets/{personality-sliders-CJrh8-AP.js → personality-sliders-B9dseUZv.js} +1 -1
  115. package/dist/assets/{plans-page-DSDYvUo5.js → plans-page-CdJnxa9Q.js} +1 -1
  116. package/dist/assets/{platform-loopback-page-BDR7i_cY.js → platform-loopback-page-BmFqgelr.js} +1 -1
  117. package/dist/assets/{plugin-detail-page-BJfIO-HZ.js → plugin-detail-page-CFGniBM4.js} +1 -1
  118. package/dist/assets/{plugins-page-b9i4h7rI.js → plugins-page-BuHZ0XlZ.js} +1 -1
  119. package/dist/assets/plugins-surface-CYlZGgus.js +1 -0
  120. package/dist/assets/{preview-error-BKpqKOCK.js → preview-error-DycCFOOO.js} +1 -1
  121. package/dist/assets/{privacy-page-CWwydiKF.js → privacy-page-BTNM3CXN.js} +1 -1
  122. package/dist/assets/{privacy-screen-GBRjX2Y3.js → privacy-screen-BNyV1Jpv.js} +1 -1
  123. package/dist/assets/{profile-card-ClUTN6Rc.js → profile-card-CCv7LkYu.js} +1 -1
  124. package/dist/assets/{provider-callback-page-0z-aomMf.js → provider-callback-page-BiI5YuU7.js} +1 -1
  125. package/dist/assets/{provider-key-DTk8I67Q.js → provider-key-mKVB6Qhq.js} +1 -1
  126. package/dist/assets/{provider-signup-page-BKlREM_2.js → provider-signup-page-Dj_CGQAF.js} +1 -1
  127. package/dist/assets/{quick-input-page-Ddg_UlmO.js → quick-input-page-jYydiJfm.js} +1 -1
  128. package/dist/assets/referral-modal-CfWPpnvV.js +1 -0
  129. package/dist/assets/{referral-modal-DZObiadq.js → referral-modal-DgZAlouF.js} +1 -1
  130. package/dist/assets/{research-mock-page-CutRQF5f.js → research-mock-page-CDpXk7ca.js} +1 -1
  131. package/dist/assets/{research-onboarding-route-DBQZHDC7.js → research-onboarding-route-Se5ksePw.js} +1 -1
  132. package/dist/assets/{review-terms-screen-dBbWlnXP.js → review-terms-screen-Cy9FX3yC.js} +1 -1
  133. package/dist/assets/routes-Df2libs9.js +1 -0
  134. package/dist/assets/{schedules-page-BvbL-8N9.js → schedules-page-O2ueZz6n.js} +1 -1
  135. package/dist/assets/{schedules-0KQuWZ-V.js → schedules-rvMiqGp0.js} +1 -1
  136. package/dist/assets/{security-redirect-page-CH4u9S3v.js → security-redirect-page-B00kAvrV.js} +1 -1
  137. package/dist/assets/{select-assistant-screen-C5892FeX.js → select-assistant-screen-GuXyFlAh.js} +1 -1
  138. package/dist/assets/{self-hosted-servers-C__IKdzk.js → self-hosted-servers-B-57ZNA3.js} +1 -1
  139. package/dist/assets/{service-form-controls-CjcwqBZf.js → service-form-controls-DZJcQaNO.js} +1 -1
  140. package/dist/assets/{setting-row-oSonbOdy.js → setting-row-BuBlxds2.js} +1 -1
  141. package/dist/assets/{settings-layout-Cf0NuysH.js → settings-layout-B_sC3oOX.js} +1 -1
  142. package/dist/assets/{share-feedback-modal-C7IjV0PW.js → share-feedback-modal-Dg6x94HR.js} +1 -1
  143. package/dist/assets/share-feedback-modal-n7ZgtNxB.js +1 -0
  144. package/dist/assets/{sidebar-tree-BLqbyk5v.js → sidebar-tree-BLMAqL8a.js} +1 -1
  145. package/dist/assets/{signup-page-BTkcbn24.js → signup-page-CF6CvKYm.js} +1 -1
  146. package/dist/assets/{signup-shell-DrGfLGsz.js → signup-shell-BUn2lHTO.js} +1 -1
  147. package/dist/assets/{skill-detail-page-DZ_FXWFT.js → skill-detail-page-B7oLoGRE.js} +1 -1
  148. package/dist/assets/{skill-detail-panel-xL20TJgL.js → skill-detail-panel-BgTf3-Jj.js} +1 -1
  149. package/dist/assets/{skill-removal-dialog-C4WF7sn9.js → skill-removal-dialog-DwT8ZoB9.js} +1 -1
  150. package/dist/assets/{skills-page-C0ikFeI-.js → skills-page-hxGLH0Yi.js} +1 -1
  151. package/dist/assets/{sounds-page-BYZulvt8.js → sounds-page-C1u9YUVJ.js} +1 -1
  152. package/dist/assets/{start-screen-CjIOV9Ig.js → start-screen-DfzPyvUq.js} +1 -1
  153. package/dist/assets/{step-detail-header-BsK4vZvH.js → step-detail-header-CdUCWAlu.js} +1 -1
  154. package/dist/assets/{stt-language-picker-modal-ArB52Kbp.js → stt-language-picker-modal-0IKnLGpu.js} +1 -1
  155. package/dist/assets/{subagent-detail-panel-Cqr5RNAr.js → subagent-detail-panel-CtkJH9-r.js} +1 -1
  156. package/dist/assets/{superpowers-page-CM-_gkRq.js → superpowers-page-C0V-BVj9.js} +1 -1
  157. package/dist/assets/{system-events-page-q1CCjaae.js → system-events-page-B13dkMsH.js} +1 -1
  158. package/dist/assets/{system-events-redirect-page-D0nYClwA.js → system-events-redirect-page-ayoYsUNU.js} +1 -1
  159. package/dist/assets/{tabular-grid-ClRQmbrS.js → tabular-grid-DkyI1XY2.js} +1 -1
  160. package/dist/assets/{teleport-gateway-client-BCQlm0IG.js → teleport-gateway-client-C3wmILxC.js} +1 -1
  161. package/dist/assets/{text-preview-DisLM6Ix.js → text-preview-BGQO4VRv.js} +1 -1
  162. package/dist/assets/{theme-stage-page-B4lCVU0g.js → theme-stage-page-9l6G0GQD.js} +1 -1
  163. package/dist/assets/{tiptap-document-editor-NU9u7Q3B.js → tiptap-document-editor-6J6u0gMB.js} +1 -1
  164. package/dist/assets/tool-detail-panel-B267q93W.js +1 -0
  165. package/dist/assets/{tool-detail-panel-BgULoaCP.js → tool-detail-panel-D29OCtjo.js} +1 -1
  166. package/dist/assets/{trait-cycle-row-h6tNq4lj.js → trait-cycle-row-C76P92r3.js} +1 -1
  167. package/dist/assets/{upgrade-cancel-page-CSFfsg3T.js → upgrade-cancel-page-CsIYnmSq.js} +1 -1
  168. package/dist/assets/{upgrade-success-page-Bb9vkeFS.js → upgrade-success-page-Ba_xpT9b.js} +1 -1
  169. package/dist/assets/{usage-redirect-page-DxSTmtpM.js → usage-redirect-page-C7pPUdxP.js} +1 -1
  170. package/dist/assets/{use-app-delete-CyCUfXGp.js → use-app-delete-2je5dBpX.js} +1 -1
  171. package/dist/assets/{use-assistant-identity-details-ft05GaL-.js → use-assistant-identity-details-S74x7sbE.js} +1 -1
  172. package/dist/assets/{use-channel-trust-floors-DeIos7Sw.js → use-channel-trust-floors-fBDQnvgz.js} +1 -1
  173. package/dist/assets/{use-checkout-dismiss-refresh-CVLzCRhG.js → use-checkout-dismiss-refresh-DB31reZx.js} +1 -1
  174. package/dist/assets/{use-edge-swipe-back-kH1IWvhn.js → use-edge-swipe-back-DeHKMrh8.js} +1 -1
  175. package/dist/assets/{use-hotkey-recorder-B0ho6P1Q.js → use-hotkey-recorder-BKycBMhe.js} +1 -1
  176. package/dist/assets/{use-invite-link-dialog-BWTyTo38.js → use-invite-link-dialog-BdHG4b3u.js} +1 -1
  177. package/dist/assets/{use-plugins-list-Dg7cmWWy.js → use-plugins-list-B9d39t5k.js} +1 -1
  178. package/dist/assets/{use-return-to-short-circuit-DZLF2zb8.js → use-return-to-short-circuit-D82kSfEB.js} +1 -1
  179. package/dist/assets/{use-side-list-room-Bm4W05s8.js → use-side-list-room-CMVDwjej.js} +1 -1
  180. package/dist/assets/{use-skill-actions-BDB6OPDL.js → use-skill-actions-BkSsu_a-.js} +1 -1
  181. package/dist/assets/{use-skill-detail-files-DOJu82AO.js → use-skill-detail-files-DRDxliP2.js} +1 -1
  182. package/dist/assets/use-supports-credentials-settings-DXa8eid1.js +1 -0
  183. package/dist/assets/{use-transcript-message-by-id-ImJNR0ZS.js → use-transcript-message-by-id-DVnOyFfP.js} +1 -1
  184. package/dist/assets/{voice-page-D6iJnwpE.js → voice-page-DoYjxDlf.js} +1 -1
  185. package/dist/assets/{wake-detail-panel-BBCXrrwt.js → wake-detail-panel-PQ5V9JtN.js} +1 -1
  186. package/dist/assets/{weather-forecast-display-D38nUHK1.js → weather-forecast-display-BWS4MRRa.js} +1 -1
  187. package/dist/assets/{welcome-screen-CUh7JIoK.js → welcome-screen-BKY6SHne.js} +1 -1
  188. package/dist/assets/{workflow-detail-panel-Cle_xFav.js → workflow-detail-panel-N8CV0RrQ.js} +1 -1
  189. package/dist/assets/{workspace-page-BhdFaoFV.js → workspace-page-B7cCk3SZ.js} +1 -1
  190. package/dist/assets/{xlsx-preview-DVein85j.js → xlsx-preview-DaCmEr4c.js} +1 -1
  191. package/dist/index.html +2 -2
  192. package/package.json +1 -1
  193. package/dist/assets/add-credits-modal-Cx2D0qMT.js +0 -1
  194. package/dist/assets/auth-store-MTbC_MGl.js +0 -1
  195. package/dist/assets/avatar-bundled-components-BzBQbsbk.js +0 -1
  196. package/dist/assets/checkout-return-target-gl5H9x5u.js +0 -1
  197. package/dist/assets/command-palette-BLiF3fyX.js +0 -1
  198. package/dist/assets/deploy-dialogs-7jGhK4l2.js +0 -1
  199. package/dist/assets/document-load-B7bN8N4u.js +0 -1
  200. package/dist/assets/local-mode-BM0aWB6A.js +0 -1
  201. package/dist/assets/mutation-error-Bpj2rO9W.js +0 -1
  202. package/dist/assets/native-attachment-pickers-BEdhcWFZ.js +0 -1
  203. package/dist/assets/native-file-uymdgwvc.js +0 -1
  204. package/dist/assets/paired-platform-identity-BumKYxOS.js +0 -1
  205. package/dist/assets/password-reset-page-C4ulvC0x.js +0 -1
  206. package/dist/assets/plugins-surface-5VJsSvrd.js +0 -1
  207. package/dist/assets/referral-modal-Bx__UjCU.js +0 -1
  208. package/dist/assets/routes-DEGM-k2Y.js +0 -1
  209. package/dist/assets/share-feedback-modal-DjrtiKSJ.js +0 -1
  210. package/dist/assets/tool-detail-panel-BZPy9LTd.js +0 -1
  211. package/dist/assets/use-supports-credentials-settings-VPsbB7QL.js +0 -1
@@ -1 +1 @@
1
- import{o as e}from"./rolldown-runtime-BM3Ffeng.js";import{$m as t,BC as n,Ci as r,DS as i,Ei as a,GC as o,Gr as s,Hr as c,Hy as l,IS as u,I_ as d,Jc as f,Jy as p,KC as m,Li as h,MC as g,OS as _,PC as v,Qd as y,Qm as b,Qy as x,SC as S,Sh as C,Si as w,Th as T,US as E,Ur as D,VC as O,Wr as k,Wy as A,XC as j,Xy as M,YC as N,Yc as P,Zm as ee,aw as F,bC as I,cm as L,dm as R,ed as te,eh as ne,el as re,fm as ie,iu as ae,lm as oe,lw as se,nd as ce,np as le,nt as ue,oC as de,ow as z,rh as B,sm as fe,sw as pe,td as V,uC as H,um as U,uw as me,xC as W,xi as he}from"./app-D0NlDYsG.js";import{$n as G,E as K,Xn as ge,er as _e,nr as q}from"./vendor-CtXGFqsu.js";import{_ as ve,d as ye,f as be,t as xe,x as Se}from"./react-B9IgSVeK.js";import{$r as Ce,A as we,At as Te,D as J,Ji as Y,Lt as Ee,Pt as De,Ya as Oe,Yn as ke,Zr as Ae,a as je,dr as Me,ft as Ne,gt as Pe,i as Fe,li as Ie,qi as Le,vt as Re,za as ze}from"./icons-C0wyat6T.js";import{a as Be,n as Ve,r as He,u as Ue}from"./use-plugins-list-Dg7cmWWy.js";var We=Oe(`cable`,[[`path`,{d:`M17 19a1 1 0 0 1-1-1v-2a2 2 0 0 1 2-2h2a2 2 0 0 1 2 2v2a1 1 0 0 1-1 1z`,key:`trhst0`}],[`path`,{d:`M17 21v-2`,key:`ds4u3f`}],[`path`,{d:`M19 14V6.5a1 1 0 0 0-7 0v11a1 1 0 0 1-7 0V10`,key:`1mo9zo`}],[`path`,{d:`M21 21v-2`,key:`eo0ou`}],[`path`,{d:`M3 5V3`,key:`1k5hjh`}],[`path`,{d:`M4 10a2 2 0 0 1-2-2V6a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v2a2 2 0 0 1-2 2z`,key:`1dd30t`}],[`path`,{d:`M7 5V3`,key:`1t1388`}]]),Ge=[`productivity`,`communication`,`meetings`,`sales`,`marketing`,`finance`,`commerce`,`engineering`,`knowledge`,`recruiting`],Ke=new Set(Ge);function qe(e){return typeof e==`string`&&Ke.has(e)}var X=e(Se(),1),Z=xe(),Je={"mcp-oauth":We,"mcp-manual":We,"managed-oauth":Ne,"own-oauth":Me};function Ye(e){let{t}=K(`settings`);return(0,X.useCallback)(n=>{switch(n.kind){case`mcp-oauth`:return t(`connectMethod.mcp`,{name:e});case`mcp-manual`:return t(`connectMethod.mcpManual`);case`managed-oauth`:return t(`connectMethod.managed`);case`own-oauth`:return t(`connectMethod.own`)}},[t,e])}function Xe(e,t,n){return e.map(e=>(0,Z.jsx)(j.Item,{icon:Je[e.kind],label:t(e),onSelect:()=>n(e)},e.id))}var Ze={slack:`slack_channel`,discord:`discord_channel`,telegram:`telegram`};function Qe(e){return Object.entries(Ze).some(([t,n])=>t===e&&n!==e)}function $e(e){return`plugin:${e}`}function et(e){let t=e.filter(e=>e.transport.type!==`stdio`&&e.status!==`connected`);return t.length===1?t[0].id:null}function tt(e){return async()=>(await e.install(),et(await e.loadPluginServers()))}function nt(e,t){return e.filter(e=>e.source===`plugin`&&e.pluginName===t)}function rt(e){return qe(e)?e:null}function it(e){let{connectedCount:t,needsAttention:n}=ot(e,[]);return{connectedCount:t,needsAttention:n}}function at(e,t){return e.filter(e=>e.provider===t)}function ot(e,t,n=!0){let r=t.flatMap(e=>e.servers),i=t.filter(e=>ct(e,n));return{connectedCount:e.filter(e=>e.connected).length+r.filter(e=>e.status===`connected`).length,needsAttention:e.some(e=>!e.connected)||i.some(e=>e.servers.some(e=>e.status!==`connected`)),configured:e.length>0||i.length>0}}function st(e){return e.status===`connected`||e.hasOAuth||e.hasStaticAuth}function ct(e,t=!0){return t?e.servers.some(st)?!0:!!e.definition.installed&&et(e.servers)===null:!!e.definition.installed||e.servers.length>0}function lt(e){if(e.transport.url)try{return new URL(e.transport.url).hostname}catch{return}}function ut(e,t,n,r=[],i=!0){let a=r.map(e=>({definition:e,servers:nt(n,e.pluginName)})),o=new Set,s=new Set(a.flatMap(e=>e.servers));return[...e.filter(e=>e.supports_managed_mode).flatMap(e=>{let n=at(t,e.provider_key);if(Qe(e.provider_key)&&n.length===0)return[];let r=a.filter(t=>t.definition.oauthProvider===e.provider_key);return r.forEach(e=>o.add(e)),[{kind:`oauth`,id:`oauth:${e.provider_key}`,name:e.display_name??e.provider_key,description:[e.description,...r.map(e=>e.definition.description)].filter(Boolean).join(` `),configured:ot(n,r,i).configured,category:rt(e.category),provider:e,connections:n,methods:r}]}),...a.filter(e=>!o.has(e)).map(e=>({kind:`plugin`,id:`plugin:${e.definition.pluginName}`,name:e.definition.displayName,description:e.definition.description,configured:ct(e,i),category:e.definition.category??null,method:e})),...n.filter(e=>!s.has(e)).map(e=>({kind:`mcp`,id:`mcp:${e.id}`,name:e.id,description:[e.pluginName,lt(e)].filter(Boolean).join(` `),configured:!0,category:null,server:e}))]}function dt(e,t,n=null){let r=t.trim().toLocaleLowerCase();return e.filter(e=>!n||e.category===n).filter(e=>!r||e.name.toLocaleLowerCase().includes(r)||e.description.toLocaleLowerCase().includes(r)).sort((e,t)=>Number(t.configured)-Number(e.configured)||e.name.localeCompare(t.name)||e.id.localeCompare(t.id))}function ft(e){return e.logo?a(`/images/integrations/${e.logo}`):null}function Q(e){return e===`mcp-oauth`||e===`mcp-manual`}function pt(e){switch(e.status){case`connected`:return`connected`;case`connecting`:case`starting`:return`connecting`;case`declared`:return`pending`;default:return`needs-attention`}}function mt(e,t,n){let r=e.servers.length>1;return e.servers.map(e=>{let i=pt(e);return{id:`mcp:${e.id}`,methodId:t,methodKind:n,label:r?e.id:null,detail:lt(e),status:i,pluginName:e.pluginName,serverId:e.id,canReconnect:i!==`connected`&&i!==`connecting`&&e.transport.type!==`stdio`&&!e.hasStaticAuth}})}function ht(e,t,n){return{id:`plugin:${e.pluginName}`,methodId:t,methodKind:n,label:null,status:`pending`,pluginName:e.pluginName,canReconnect:!1}}function gt(e,t){return e.map(e=>({id:`oauth:${e.id}`,methodId:t,methodKind:`managed-oauth`,label:e.account_label,accountId:e.id,status:e.connected?`connected`:`needs-attention`,canReconnect:!e.connected}))}function _t(e,t){let{definition:n}=e,r=n.setup.mode===`manual`?`mcp-manual`:`mcp-oauth`,i=`mcp:${n.pluginName}`,a=t&&e.servers.length===0&&n.installed;return{id:i,kind:r,availability:`available`,instructions:n.setup.instructions,setupGuideUrl:n.documentationUrl,connections:a?[ht(n,i,r)]:mt(e,i,r),plugin:n}}function vt(e,t){let n=[],r,i=null,a;if(e.kind===`oauth`){r=e.provider.provider_key,i=e.provider.logo_url,a=e.provider.description;for(let r of e.methods)n.push(_t(r,t.mcpServersLoaded));if(t.platformGate!==`gated`){let r=`managed:${e.provider.provider_key}`;n.push({id:r,kind:`managed-oauth`,availability:t.platformGate===`full`?`available`:`login-required`,connections:gt(e.connections,r)})}t.ownOAuthAvailable&&n.push({id:`own:${e.provider.provider_key}`,kind:`own-oauth`,availability:`available`,setupGuideUrl:e.provider.dashboard_url??void 0,connections:[]})}else{let{definition:o}=e.method;r=o.pluginName,i=ft(o),a=o.description,n.push(_t(e.method,t.mcpServersLoaded))}let[o,...s]=n;return o?{name:e.name,description:a,iconKey:r,logoUrl:i,primary:o,alternatives:s}:null}function yt(e){return[e.primary,...e.alternatives]}function bt(e){return yt(e).flatMap(e=>e.connections)}function xt(e){return yt(e).filter(e=>!Q(e.kind)||e.connections.length===0)}var $=`pointer-coarse:size-11`,St=[`flex flex-wrap items-start gap-2 [&>*]:shrink-0`,`[&_button]:max-w-full [&_button]:whitespace-normal`,`[&_button]:pointer-coarse:min-h-11`].join(` `);function Ct({icon:e,title:t,subtitle:n,status:r,primaryAction:i,actionMenu:a,layout:o=`row`}){return o===`tile`?(0,Z.jsxs)(m.Root,{bordered:!0,className:`flex h-full flex-col gap-3 transition-colors hover:border-[var(--border-hover)]`,children:[(0,Z.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[e,(0,Z.jsxs)(`div`,{className:`${St} justify-end`,children:[i,a]})]}),(0,Z.jsxs)(`div`,{className:`min-w-0 space-y-1`,children:[(0,Z.jsx)(`p`,{className:`text-title-small text-[var(--content-default)] [overflow-wrap:anywhere]`,children:t}),(0,Z.jsx)(`p`,{className:`line-clamp-2 min-h-9 text-body-small-lighter text-[var(--content-tertiary)] [overflow-wrap:anywhere]`,children:n})]})]}):(0,Z.jsx)(m.Root,{children:(0,Z.jsxs)(m.Body,{padding:`md`,className:`grid grid-cols-[2rem_minmax(6rem,1fr)_minmax(0,auto)] items-start gap-x-3`,children:[e,(0,Z.jsxs)(`div`,{className:`min-w-0 space-y-1`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(`p`,{className:`text-title-small text-[var(--content-default)] [overflow-wrap:anywhere]`,children:t}),r]}),n?(0,Z.jsx)(`p`,{className:`line-clamp-2 text-body-medium-lighter text-[var(--content-tertiary)] [overflow-wrap:anywhere]`,children:n}):null]}),(0,Z.jsxs)(`div`,{className:`${St} col-start-3 row-start-1 justify-end`,children:[i,a]})]})})}function wt({plan:e,title:t,description:n}){return(0,Z.jsx)(S.Header,{children:(0,Z.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Z.jsx)(s,{providerKey:e.iconKey,displayName:e.name,logoUrl:e.logoUrl,size:40}),(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-col`,children:[(0,Z.jsx)(S.Title,{className:`[&>span]:whitespace-normal`,children:t}),(0,Z.jsx)(S.Description,{children:n})]})]})})}function Tt({plan:e,attempt:t,focusMethodId:n,callbackUrl:r,callbackCopied:i=!1,toolsByConnectionId:a,ownOAuthContent:o,tenantHost:s,onConnect:c,onLogin:l,onCancelAttempt:u,onRetryAttempt:d,onReconnect:f,onDisconnect:p,onOpenTools:m,onCopyCallbackUrl:h,onOpenSetupGuide:g,onClose:_}){let{t:v}=K(`settings`),y=Ye(e.name),b=yt(e),x=bt(e),[C,w]=(0,X.useState)(()=>n?{kind:`connect`,methodId:n}:x.length>0?{kind:`connections`}:{kind:`connect`,methodId:e.primary.id}),[T,E]=(0,X.useState)(!1),[D,O]=(0,X.useState)(null);function k(t){return t.kind===`connect`?t:x.length===0?{kind:`connect`,methodId:e.primary.id}:t.kind===`tools`&&!x.some(e=>e.id===t.connectionId)?{kind:`connections`}:t}let A=k(C);function j(e){switch(e.kind){case`mcp-oauth`:case`mcp-manual`:return v(`integrationConnect.tagMcp`);case`managed-oauth`:return v(`integrationConnect.tagVellum`);case`own-oauth`:return v(`integrationConnect.tagOwnApp`)}}function M(t){return t.label?t.label:Q(t.methodKind)?v(`integrationConnect.connectionMcpLabel`,{name:e.name}):v(`integrationConnect.connectionAccountLabel`,{name:e.name})}function N(e,t){return Xe(e,y,t)}function P(e){E(!1),w({kind:`connect`,methodId:e.id})}function ee(){if(x.length>0){w({kind:`connections`});return}w({kind:`connect`,methodId:e.primary.id})}let L=A.kind===`tools`?x.find(e=>e.id===A.connectionId):void 0,R=A.kind===`connect`?b.find(e=>e.id===A.methodId)??e.primary:e.primary;function te(e){let t=e.setupGuideUrl;return t?(0,Z.jsx)(F,{variant:`ghost`,className:`mr-auto min-h-11`,leftIcon:(0,Z.jsx)(Ae,{}),onClick:()=>g(t),children:v(`integrationConnect.setupGuide`)}):null}return(0,Z.jsxs)(S.Root,{open:!0,onOpenChange:e=>{e||_()},children:[(0,Z.jsx)(S.Content,{size:`md`,children:A.kind===`connect`?(0,Z.jsx)(Et,{plan:e,method:R,setupGuide:te(R),methods:b,attempt:t,callbackUrl:r,callbackCopied:i,ownOAuthContent:o,tenantHost:s,acknowledged:T,hasConnections:x.length>0,methodItems:N,onAcknowledge:E,onPickMethod:P,onBack:ee,onConnect:c,onLogin:l,onCancelAttempt:u,onRetryAttempt:d,onCopyCallbackUrl:h,onClose:_}):A.kind===`tools`?(0,Z.jsx)(Mt,{plan:e,connection:L,title:L?M(L):e.name,tools:a?.[A.connectionId],onBack:()=>w({kind:`connections`}),onClose:_}):(0,Z.jsx)(At,{plan:e,methods:b,connections:x,connectionTitle:M,methodTag:j,methodItems:N,onPickMethod:P,onOpenTools:e=>{m?.(e),w({kind:`tools`,connectionId:e.id})},onReconnect:e=>{f(e),w({kind:`connect`,methodId:e.methodId})},onRequestDisconnect:O,onClose:_})}),(0,Z.jsx)(I,{open:D!==null,destructive:!0,title:v(`integrationConnect.removeTitle`,{label:D?M(D):``}),message:v(`integrationConnect.removeMessage`),confirmLabel:v(`integrationConnect.remove`),cancelLabel:v(`integrationConnect.cancel`),onConfirm:()=>{D&&p(D),O(null)},onCancel:()=>O(null)})]})}function Et({plan:e,method:t,methods:n,attempt:r,callbackUrl:i,callbackCopied:a,ownOAuthContent:s,tenantHost:c,acknowledged:l,hasConnections:u,setupGuide:d,methodItems:f,onAcknowledge:p,onPickMethod:m,onBack:h,onConnect:g,onLogin:_,onCancelAttempt:y,onRetryAttempt:b,onCopyCallbackUrl:x,onClose:C}){let{t:w}=K(`settings`),T=t.kind===`managed-oauth`?c:null,E=k(T),D=r?.methodId===t.id?r:null,O=D!==null&&D.phase!==`error`,A=t.availability===`login-required`,j=t.kind===`mcp-manual`&&i!==void 0&&(!l||i.status!==`ready`),M=t.id!==e.primary.id||u,P=n.filter(e=>e.id!==t.id);return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(wt,{plan:e,title:w(`integrationConnect.connectTitle`,{name:e.name}),description:e.description??w(`integrationConnect.connectDescription`,{name:e.name})}),(0,Z.jsxs)(S.Body,{className:`space-y-4`,children:[M?(0,Z.jsx)(F,{variant:`ghost`,leftIcon:(0,Z.jsx)(ze,{}),onClick:h,children:w(`integrationConnect.back`)}):null,A?(0,Z.jsx)(o,{tone:`info`,children:w(`integrationConnect.loginRequired`,{name:e.name})}):null,D?(0,Z.jsx)(Dt,{name:e.name,attempt:D,onCancel:y,onRetry:b}):null,T?(0,Z.jsx)(v,{label:T.label,type:`text`,value:E.value,onChange:e=>E.setValue(e.target.value),placeholder:T.placeholder,"aria-invalid":E.showsInvalid||void 0,helperText:E.showsInvalid?w(`integrationConnect.tenantHostInvalid`,{label:T.label,placeholder:T.placeholder}):void 0,disabled:O,autoComplete:`off`,autoCapitalize:`none`,spellCheck:!1,fullWidth:!0}):null,t.kind===`mcp-manual`?(0,Z.jsx)(Ot,{instructions:t.instructions,name:e.name,callbackUrl:i,callbackCopied:a,acknowledged:l,onAcknowledge:p,onCopyCallbackUrl:x}):t.kind===`own-oauth`?s:(0,Z.jsx)(`p`,{className:`text-body-medium-default text-[var(--content-secondary)]`,children:t.instructions??w(`integrationConnect.browserHint`,{name:e.name})})]}),(0,Z.jsxs)(S.Footer,{children:[d,(0,Z.jsx)(F,{variant:`ghost`,className:`min-h-11`,onClick:C,children:w(`integrationConnect.cancel`)}),t.kind===`own-oauth`?null:(0,Z.jsx)(N,{className:`min-h-11`,disabled:O||j||!E.valid,menuDisabled:O,leftIcon:O?(0,Z.jsx)(ke,{className:`animate-spin`}):null,menuTitle:w(`integrationConnect.otherWays`),menuTriggerLabel:w(`connectMethod.otherWaysLabel`,{name:e.name}),menuItems:f(P,m),onClick:()=>A?_():g(t,{acknowledged:l,tenantHost:E.normalized}),children:w(A?`integrationConnect.loginToConnect`:`integrationConnect.connect`)})]})]})}function Dt({name:e,attempt:t,onCancel:n,onRetry:r}){let{t:i}=K(`settings`);if(t.phase===`error`)return(0,Z.jsx)(o,{tone:`error`,actions:(0,Z.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Z.jsx)(F,{variant:`outlined`,onClick:r,children:i(`integrationConnect.retry`)}),(0,Z.jsx)(F,{variant:`ghost`,onClick:n,children:t.canCancel?i(`integrationConnect.stopWaiting`):i(`integrationConnect.cancel`)})]}),children:(0,Z.jsx)(`p`,{children:t.error??i(`integrationConnect.attemptFailed`,{name:e})})});let a=t.phase===`starting`?i(`integrationConnect.attemptStarting`,{name:e}):t.phase===`connecting`?i(`integrationConnect.attemptConnecting`,{name:e}):i(`integrationConnect.attemptWaiting`,{name:e});return(0,Z.jsx)(o,{tone:`info`,icon:(0,Z.jsx)(ke,{className:`h-4 w-4 animate-spin`,"aria-hidden":`true`}),actions:t.canCancel?(0,Z.jsx)(F,{variant:`ghost`,onClick:n,children:i(`integrationConnect.stopWaiting`)}):void 0,children:a})}function Ot({instructions:e,name:t,callbackUrl:n,callbackCopied:r,acknowledged:i,onAcknowledge:a,onCopyCallbackUrl:o}){let{t:s}=K(`settings`),c=n?.status===`ready`?n.url:void 0,l=e?(0,Z.jsx)(`p`,{className:`text-body-medium-default text-[var(--content-secondary)]`,children:e}):null;return n?(0,Z.jsxs)(Z.Fragment,{children:[l,(0,Z.jsxs)(`ol`,{className:`space-y-4`,children:[(0,Z.jsxs)(kt,{index:1,children:[(0,Z.jsx)(`p`,{className:`text-body-medium-default`,children:s(`integrationConnect.manualStep1`)}),c?(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 rounded-md border border-[var(--border-base)] bg-[var(--surface-base)] px-3 py-2`,children:[(0,Z.jsx)(`code`,{className:`min-w-0 flex-1 font-mono text-body-small-default [overflow-wrap:anywhere]`,children:c}),o?(0,Z.jsx)(F,{variant:`outlined`,size:`compact`,leftIcon:r?(0,Z.jsx)(Y,{}):(0,Z.jsx)(Ie,{}),onClick:()=>o(c),children:s(r?`integrationConnect.copied`:`integrationConnect.copy`)}):null]}):(0,Z.jsx)(`p`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:n?.status===`error`?s(`integrationConnect.callbackError`):s(`integrationConnect.callbackLoading`)})]}),(0,Z.jsx)(kt,{index:2,children:(0,Z.jsx)(`p`,{className:`text-body-medium-default`,children:s(`integrationConnect.manualStep2`,{name:t})})}),(0,Z.jsx)(kt,{index:3,children:(0,Z.jsx)(g,{checked:i,onCheckedChange:e=>a(e===!0),label:s(`integrationConnect.manualStep3`)})})]})]}):l}function kt({index:e,children:t}){return(0,Z.jsxs)(`li`,{className:`flex gap-3`,children:[(0,Z.jsx)(`span`,{className:`w-3 shrink-0 text-body-medium-default text-[var(--content-tertiary)]`,children:e}),(0,Z.jsx)(`div`,{className:`min-w-0 flex-1 space-y-2`,children:t})]})}function At({plan:e,methods:t,connections:n,connectionTitle:r,methodTag:i,methodItems:a,onPickMethod:o,onOpenTools:s,onReconnect:c,onRequestDisconnect:l,onClose:u}){let{t:d}=K(`settings`),f=xt(e);function p(e){let n=t.find(t=>t.id===e.methodId);if(t.length<2||!n)return e.detail;let r=i(n);return e.detail?d(`integrationConnect.connectionSubtitle`,{method:r,detail:e.detail}):r}return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(wt,{plan:e,title:e.name,description:d(`integrationConnect.connectionsDescription`,{name:e.name})}),(0,Z.jsx)(S.Body,{children:(0,Z.jsx)(`div`,{className:`rounded-lg border border-[var(--border-base)]`,children:n.map(e=>(0,Z.jsx)(de,{title:r(e),subtitle:p(e),trailingInteractive:!0,trailing:(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2 touch-mobile:max-w-24`,children:[(0,Z.jsx)(jt,{status:e.status}),e.canReconnect?(0,Z.jsx)(F,{variant:`outlined`,size:`compact`,leftIcon:(0,Z.jsx)(Te,{}),onClick:()=>c(e),children:e.status===`pending`?d(`integrationConnect.finishConnecting`):d(`integrationConnect.reconnect`)}):null,Q(e.methodKind)?(0,Z.jsx)(F,{variant:`outlined`,className:$,iconOnly:(0,Z.jsx)(je,{}),"aria-label":d(`integrationConnect.toolsAndDetailsLabel`,{label:r(e)}),onClick:()=>s(e)}):null,(0,Z.jsx)(F,{variant:`dangerOutline`,className:$,iconOnly:(0,Z.jsx)(we,{}),"aria-label":d(`integrationConnect.removeLabel`,{label:r(e)}),onClick:()=>l(e)})]})},e.id))})}),(0,Z.jsxs)(S.Footer,{children:[f.length>0?(0,Z.jsxs)(j.Root,{children:[(0,Z.jsx)(j.Trigger,{asChild:!0,children:(0,Z.jsx)(F,{variant:`outlined`,className:`min-h-11`,rightIcon:(0,Z.jsx)(Le,{}),children:d(`integrationConnect.connectAnother`)})}),(0,Z.jsx)(j.Content,{title:d(`integrationConnect.connectAnother`),children:a(f,o)})]}):null,(0,Z.jsx)(F,{className:`min-h-11`,onClick:u,children:d(`integrationConnect.done`)})]})]})}function jt({status:e}){let{t}=K(`settings`);switch(e){case`needs-attention`:return(0,Z.jsx)(n,{tone:`negative`,children:t(`integrationConnect.statusNeedsAttention`)});case`connecting`:return(0,Z.jsx)(n,{children:t(`integrationConnect.statusConnecting`)});case`pending`:return(0,Z.jsx)(n,{children:t(`integrationConnect.statusPending`)});case`connected`:return null}}function Mt({plan:e,connection:t,title:n,tools:r,onBack:i,onClose:a}){let{t:o}=K(`settings`),s=r?.summary;return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(wt,{plan:e,title:n,description:o(`integrationConnect.toolsAndDetails`)}),(0,Z.jsxs)(S.Body,{className:`space-y-4`,children:[(0,Z.jsx)(F,{variant:`ghost`,leftIcon:(0,Z.jsx)(ze,{}),onClick:i,children:o(`integrationConnect.back`)}),(0,Z.jsxs)(`dl`,{className:`space-y-1`,children:[(0,Z.jsx)(`dt`,{className:`text-body-small-default text-[var(--content-secondary)]`,children:o(`integrationConnect.endpoint`)}),(0,Z.jsx)(`dd`,{className:`font-mono text-body-small-default text-[var(--content-tertiary)] [overflow-wrap:anywhere]`,children:r?.endpointUrl??t?.detail??o(`integrationConnect.endpointUnknown`)})]}),r?.loading?(0,Z.jsx)(`p`,{role:`status`,className:`text-body-small-default text-[var(--content-tertiary)]`,children:o(`integrationConnect.toolsLoading`)}):r?.error?(0,Z.jsx)(`p`,{role:`alert`,className:`text-body-small-default text-[var(--content-tertiary)]`,children:o(`integrationConnect.toolsError`)}):s&&s.tools.length>0?(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[(0,Z.jsx)(`p`,{className:`text-body-small-default text-[var(--content-secondary)]`,children:o(`integrationConnect.toolsSummary`,{count:s.toolCount,tokens:s.estimatedTokens})}),(0,Z.jsx)(H.Root,{type:`multiple`,className:`rounded-lg border border-[var(--border-base)]`,children:s.tools.map(e=>(0,Z.jsxs)(H.Item,{value:e.name,className:`border-b border-[var(--border-base)] last:border-b-0`,children:[(0,Z.jsxs)(H.Trigger,{className:`justify-between gap-2 px-3 py-2.5 text-left [&[data-state=open]>svg]:rotate-180`,children:[(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-body-small-default`,children:e.name}),(0,Z.jsx)(Le,{"aria-hidden":`true`,className:`h-4 w-4 shrink-0 text-[var(--content-tertiary)] transition-transform duration-150`})]}),(0,Z.jsx)(H.Content,{children:(0,Z.jsxs)(`div`,{className:`space-y-1 px-3 pb-3`,children:[e.description?(0,Z.jsx)(`p`,{className:`whitespace-pre-wrap text-body-small-default text-[var(--content-secondary)] [overflow-wrap:anywhere]`,children:e.description}):null,(0,Z.jsx)(`p`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:o(`integrationConnect.toolTokens`,{tokens:e.estimatedTokens})})]})})]},e.name))})]}):(0,Z.jsx)(`p`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:o(`integrationConnect.toolsEmpty`)})]}),(0,Z.jsx)(S.Footer,{children:(0,Z.jsx)(F,{className:`min-h-11`,onClick:a,children:o(`integrationConnect.done`)})})]})}function Nt({providerKey:e,displayName:t,description:r,logoUrl:i,connections:a,mcpMethods:o=[],disabled:c,onConfigure:l}){let{t:u}=K(`settings`),{connectedCount:d}=it(a),{needsAttention:f,configured:p}=ot(a,o);return(0,Z.jsx)(Ct,{icon:(0,Z.jsx)(s,{providerKey:e,displayName:t,logoUrl:i,size:32}),title:t,subtitle:d>0?u(`integrationRow.connectedAccounts`,{count:d}):r,status:f?(0,Z.jsx)(n,{tone:`negative`,children:u(`integrationRow.needsAttention`)}):void 0,primaryAction:p?(0,Z.jsx)(F,{variant:`outlined`,className:$,iconOnly:(0,Z.jsx)(Pe,{}),"aria-label":u(`integrationRow.configureLabel`,{name:t}),onClick:l,disabled:c}):(0,Z.jsx)(F,{variant:`primary`,onClick:l,disabled:c,children:u(`integrationRow.connect`)})})}function Pt({plan:e,state:t,layout:n=`tile`,showAlternatives:r=!1,disabled:i=!1,onConnect:a,onLogin:o,onCancel:c,onRetry:l,onOpenSetupGuide:u}){let{t:d}=K(`settings`),f=Ye(e.name),p=se(),m=t.phase===`waiting`||t.phase===`connecting`,h=m&&!p;function g(e){if(e.availability===`login-required`){o();return}a(e)}function _(e){return Xe(e,f,g)}let v=r&&e.alternatives.length>0?(0,Z.jsx)(N,{variant:`outlined`,className:$,iconOnly:(0,Z.jsx)(Ee,{}),"aria-label":d(`integrationTile.connect`,{name:e.name}),menuTitle:d(`integrationTile.connect`,{name:e.name}),menuTriggerLabel:d(`connectMethod.otherWaysLabel`,{name:e.name}),menuItems:_(yt(e)),disabled:i,onClick:()=>g(e.primary)}):(0,Z.jsx)(F,{variant:`outlined`,className:$,iconOnly:(0,Z.jsx)(Ee,{}),"aria-label":d(`integrationTile.connect`,{name:e.name}),disabled:i,onClick:()=>g(e.primary)});return m?v=(0,Z.jsx)(zt,{name:e.name,state:t,announce:!h,onCancel:c}):t.phase===`failed`&&(v=(0,Z.jsx)(Rt,{plan:e,state:t,disabled:i,methodItems:_,onRetry:l,onOpenSetupGuide:u})),(0,Z.jsx)(Ct,{layout:n,icon:(0,Z.jsx)(s,{providerKey:e.iconKey,displayName:e.name,logoUrl:e.logoUrl,size:32}),title:e.name,subtitle:t.phase===`failed`?(0,Z.jsx)(Lt,{name:e.name,state:t}):h&&m?(0,Z.jsx)(`span`,{role:`status`,children:It(d,e.name,t)}):e.description??void 0,primaryAction:v})}var Ft=4e3;function It(e,t,n){return n.phase===`waiting`?e(`integrationTile.waiting`,{name:t}):e(`integrationTile.connecting`,{name:t})}function Lt({name:e,state:t}){let{t:n}=K(`settings`),r=t.error||n(`integrationTile.failedGeneric`,{name:e});return(0,Z.jsxs)(`span`,{role:`alert`,title:t.error||void 0,className:`font-medium text-[var(--system-negative-strong)]`,children:[(0,Z.jsx)(J,{"aria-hidden":`true`,className:`mr-1 inline size-3.5 shrink-0 align-[-0.15em]`}),r]})}function Rt({plan:e,state:t,disabled:n,methodItems:r,onRetry:i,onOpenSetupGuide:a}){let{t:o}=K(`settings`),s=Q(t.methodKind)?t.setupGuideUrl:void 0,c=xt(e).filter(e=>e.id!==t.methodId),l=[...s?[(0,Z.jsx)(j.Item,{icon:Ae,label:o(`integrationTile.setupGuide`),onSelect:()=>a(s)},`setup-guide`)]:[],...r(c)],u=o(`integrationTile.retryLabel`,{name:e.name});return l.length===0?(0,Z.jsx)(F,{variant:`dangerOutline`,className:$,iconOnly:(0,Z.jsx)(Te,{}),"aria-label":u,disabled:n,onClick:i}):(0,Z.jsx)(N,{variant:`dangerOutline`,className:$,iconOnly:(0,Z.jsx)(Te,{}),"aria-label":u,menuTitle:o(`connectMethod.otherWaysLabel`,{name:e.name}),menuTriggerLabel:o(`connectMethod.otherWaysLabel`,{name:e.name}),menuItems:l,disabled:n,onClick:i})}function zt({name:e,state:t,announce:n,onCancel:r}){let{t:i}=K(`settings`),a=se(),[o,s]=(0,X.useState)(!1),c=(0,X.useRef)(null),l=t.phase===`waiting`&&t.canCancel,u=It(i,e,t);function d(){c.current&&=(clearTimeout(c.current),null)}function f(e){d(),s(!0),e&&(c.current=setTimeout(()=>s(!1),Ft))}function p(){d(),s(!1)}(0,X.useEffect)(()=>d,[]);function m(e){return a&&e!==`touch`}let h=n?(0,Z.jsx)(`span`,{role:`status`,className:`sr-only`,children:u}):null;return l?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(F,{variant:`outlined`,className:$,iconOnly:o?(0,Z.jsx)(Fe,{}):(0,Z.jsx)(ke,{className:`animate-spin`}),"aria-label":i(`integrationTile.cancelLabel`,{name:e}),tooltip:i(`integrationTile.waitingCancel`,{name:e}),onPointerEnter:e=>{m(e.pointerType)&&f(!1)},onPointerLeave:e=>{m(e.pointerType)&&p()},onBlur:p,onClick:e=>{if(o||e.detail===0){p(),r();return}f(!0)}}),h]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(pe,{content:u,children:(0,Z.jsx)(`span`,{className:me(z({variant:`outlined`,iconOnly:!0}),$,`cursor-default hover:bg-transparent`),children:(0,Z.jsx)(ke,{"aria-hidden":`true`,className:`size-3.5 animate-spin text-[var(--content-tertiary)]`})})}),h]})}function Bt({assistantId:e,providerKey:t,providerLabel:n,tenantHost:r,restartToken:i,onReport:a}){let{connect:o,dismiss:s,status:c,errorMessage:l}=he({assistantId:e,providerKey:t,providerLabel:n}),u=(0,X.useRef)(o),d=(0,X.useRef)(r);return(0,X.useLayoutEffect)(()=>{u.current=o,d.current=r}),(0,X.useLayoutEffect)(()=>{u.current(void 0,d.current)},[i]),(0,X.useEffect)(()=>s,[s]),(0,X.useEffect)(()=>{a({status:c,errorMessage:l})},[l,a,c]),null}function Vt(e){return e.length>16?`${e.slice(0,12)}…${e.slice(-4)}`:e.length>8?`${e.slice(0,8)}…`:e}function Ht(e){try{return new Date(e).toLocaleDateString(void 0,{year:`numeric`,month:`short`,day:`numeric`})}catch{return``}}function Ut({assistantId:e,providerKey:n,displayName:r,logoUrl:i}){let{t:a}=K(`settings`),o=q(),c=G({...oe({path:{assistant_id:e},query:{provider_key:n}}),select:e=>e.apps}),l=G({...R({path:{assistant_id:e,providerKey:n}}),select:e=>e.oauth_callback_url}),u=c.data??[],d=l.data??null,f=_e({queries:u.map(t=>({...fe({path:{assistant_id:e,appId:t.id}}),select:e=>e.connections}))}),p={};u.forEach((e,t)=>{p[e.id]=f[t]?.data??[]});let h=U({path:{assistant_id:e},query:{provider_key:n}}),g=t({onSuccess:()=>{o.invalidateQueries({queryKey:h}),T(``),D(``),C(!1),W.success(a(`yourOwnOauthTab.appAddedToast`,{name:r}))},onError:e=>{W.error(e.message||a(`yourOwnOauthTab.createFailedToast`))}}),_=b({onSuccess:()=>{o.invalidateQueries({queryKey:h}),W.success(a(`yourOwnOauthTab.appDeletedToast`))},onError:e=>{W.error(e.message||a(`yourOwnOauthTab.deleteFailedToast`))}}),y=ee({onSuccess:e=>{`auth_url`in e&&(window.location.href=e.auth_url)},onError:e=>{W.error(e.message||a(`yourOwnOauthTab.connectFailedToast`))}}),x=ne(),[S,C]=(0,X.useState)(!1),[w,T]=(0,X.useState)(``),[E,D]=(0,X.useState)(``),[O,k]=(0,X.useState)(!1),[j,M]=(0,X.useState)(null),[N,P]=(0,X.useState)(null),te=g.isPending,re=_.isPending?_.variables?.path?.id??null:null,ie=y.isPending?y.variables?.path?.appId??null:null,ae=x.isPending?x.variables?.path?.id??null:null,se=()=>{let t=w.trim(),r=E.trim();!t||!r||g.mutate({path:{assistant_id:e},body:{provider_key:n,client_id:t,client_secret:r}})},ce=()=>{let t=j;M(null),t&&_.mutate({path:{assistant_id:e,id:t.id}})},le=t=>{y.mutate({path:{assistant_id:e,appId:t.id},body:{callback_transport:`gateway`,scopes:[]}})};return c.isLoading?(0,Z.jsx)(`div`,{className:`flex items-center justify-center py-10`,children:(0,Z.jsx)(ke,{className:`h-5 w-5 animate-spin text-[var(--content-disabled)]`})}):(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[u.length===0||S?(0,Z.jsx)(m.Root,{children:(0,Z.jsxs)(m.Body,{className:`flex flex-col gap-3`,children:[(0,Z.jsxs)(`div`,{className:`space-y-1`,children:[(0,Z.jsx)(`p`,{className:`text-body-medium-default text-[var(--content-default)]`,children:u.length===0?a(`yourOwnOauthTab.addOwnApp`,{name:r}):a(`yourOwnOauthTab.addAnotherApp`,{name:r})}),(0,Z.jsx)(`p`,{className:`text-body-small-lighter leading-relaxed text-[var(--content-tertiary)]`,children:a(`yourOwnOauthTab.credentialsNote`)})]}),d?(0,Z.jsxs)(`div`,{className:`space-y-1`,children:[(0,Z.jsx)(`p`,{className:`text-body-small-default text-[var(--content-secondary)]`,children:a(`yourOwnOauthTab.redirectUrl`)}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(v,{type:`text`,value:d,readOnly:!0,fullWidth:!0}),(0,Z.jsx)(F,{type:`button`,variant:`outlined`,size:`compact`,onClick:()=>{A(d,{successMessage:a(`yourOwnOauthTab.copiedToast`),errorMessage:a(`yourOwnOauthTab.copyFailedToast`),onCopied:()=>{k(!0),setTimeout(()=>k(!1),2e3)}})},"aria-label":a(O?`yourOwnOauthTab.copiedAria`:`yourOwnOauthTab.copyRedirectAria`),iconOnly:O?(0,Z.jsx)(Y,{"aria-hidden":!0}):(0,Z.jsx)(Ie,{"aria-hidden":!0})})]}),(0,Z.jsx)(`p`,{className:`text-body-small-lighter text-[var(--content-tertiary)]`,children:a(`yourOwnOauthTab.redirectHint`)})]}):null,(0,Z.jsx)(v,{label:a(`yourOwnOauthTab.clientId`),type:`text`,value:w,onChange:e=>T(e.target.value),placeholder:a(`yourOwnOauthTab.clientIdPlaceholder`),fullWidth:!0}),(0,Z.jsx)(v,{label:a(`yourOwnOauthTab.clientSecret`),type:`password`,value:E,onChange:e=>D(e.target.value),placeholder:a(`yourOwnOauthTab.clientSecretPlaceholder`),fullWidth:!0}),(0,Z.jsxs)(`div`,{className:`flex items-center justify-end gap-2 pt-1`,children:[u.length>0?(0,Z.jsx)(F,{type:`button`,variant:`outlined`,size:`compact`,onClick:()=>{C(!1),T(``),D(``)},disabled:te,children:a(`yourOwnOauthTab.cancel`)}):null,(0,Z.jsx)(F,{type:`button`,size:`compact`,onClick:se,disabled:te||!w.trim()||!E.trim(),loading:te,leftIcon:(0,Z.jsx)(Ee,{"aria-hidden":!0}),children:a(`yourOwnOauthTab.addApp`)})]})]})}):null,u.map(e=>{let t=p[e.id]??[],o=re===e.id,c=ie===e.id;return(0,Z.jsx)(m.Root,{children:(0,Z.jsxs)(m.Body,{className:`flex flex-col gap-3`,children:[(0,Z.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0 space-y-0.5`,children:[(0,Z.jsx)(`p`,{className:`truncate text-body-medium-default text-[var(--content-default)]`,children:Vt(e.client_id)}),(0,Z.jsx)(`p`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:a(`yourOwnOauthTab.addedOn`,{date:Ht(e.created_at)})})]}),(0,Z.jsx)(F,{type:`button`,variant:`dangerOutline`,size:`compact`,onClick:()=>M(e),disabled:o,"aria-label":a(`yourOwnOauthTab.deleteAppAria`,{id:Vt(e.client_id)}),loading:o,iconOnly:(0,Z.jsx)(we,{"aria-hidden":!0})})]}),t.length>0?(0,Z.jsx)(`ul`,{className:`divide-y divide-[var(--border-base)] overflow-hidden rounded-md border border-[var(--border-base)] dark:divide-[var(--border-base)] dark:border-[var(--border-base)]`,children:t.map(t=>{let o=ae===t.id,c=t.account_info??a(`yourOwnOauthTab.accountFallback`,{name:r});return(0,Z.jsxs)(`li`,{className:`flex items-center gap-3 px-3 py-2`,children:[(0,Z.jsx)(s,{providerKey:n,displayName:r,logoUrl:i,size:18}),(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-body-medium-lighter text-[var(--content-default)]`,children:c}),(0,Z.jsx)(F,{type:`button`,variant:`dangerOutline`,size:`compact`,onClick:()=>P({appId:e.id,connection:t}),disabled:o,"aria-label":a(`yourOwnOauthTab.disconnectAria`,{account:c}),loading:o,iconOnly:(0,Z.jsx)(we,{"aria-hidden":!0})})]},t.id)})}):null,(0,Z.jsx)(F,{type:`button`,size:`compact`,onClick:()=>le(e),disabled:c,className:`w-full`,loading:c,leftIcon:(0,Z.jsx)(Ae,{"aria-hidden":!0}),children:a(c?`yourOwnOauthTab.waitingAuthorization`:`yourOwnOauthTab.connectAccount`)})]})},e.id)}),u.length>0&&!S?(0,Z.jsx)(F,{type:`button`,variant:`outlined`,size:`compact`,onClick:()=>C(!0),className:`w-full border-dashed`,leftIcon:(0,Z.jsx)(Ee,{"aria-hidden":!0}),children:a(`yourOwnOauthTab.addAnotherAppButton`)}):null,(0,Z.jsx)(I,{open:j!==null,title:a(`yourOwnOauthTab.deleteAppTitle`),message:j?a(`yourOwnOauthTab.deleteAppMessage`,{id:Vt(j.client_id)}):``,confirmLabel:a(`yourOwnOauthTab.delete`),destructive:!0,onConfirm:ce,onCancel:()=>M(null)}),(0,Z.jsx)(I,{open:N!==null,title:a(`yourOwnOauthTab.disconnectTitle`,{name:r}),message:N?a(`yourOwnOauthTab.disconnectMessage`,{account:N.connection.account_info??a(`yourOwnOauthTab.accountFallback`,{name:r})}):``,confirmLabel:a(`yourOwnOauthTab.disconnect`),destructive:!0,onConfirm:()=>{let t=N;P(null),t&&x.mutate({path:{assistant_id:e,id:t.connection.id}},{onSuccess:()=>{let n=L({path:{assistant_id:e,appId:t.appId}});o.invalidateQueries({queryKey:n}),o.invalidateQueries({queryKey:h}),W.success(a(`yourOwnOauthTab.disconnectedToast`,{name:r}))},onError:e=>{W.error(e.message||a(`yourOwnOauthTab.disconnectFailedToast`))}})},onCancel:()=>P(null)})]})}var Wt={phase:`idle`};function Gt({assistantId:e,mcp:t}){let{t:n}=K(`settings`),r=q(),{mutateAsync:i}=B(),[a,o]=(0,X.useState)(null),[s,l]=(0,X.useState)(null),[d,f]=(0,X.useState)(null),[p,m]=(0,X.useState)(null),[h,g]=(0,X.useState)(null),_=(0,X.useRef)(null),v=(0,X.useRef)(null),y=t.auth.attempt,b=t.auth.connect,x=t.auth.retry,S=t.auth.stopWaiting,C=t.auth.isBusy,w=t.list.refetch;(0,X.useEffect)(()=>{let e=_.current;if(e&&(_.current=null,y&&y.operationId!==e.priorOperationId)){o({itemId:e.itemId,methodId:e.methodId,methodKind:e.methodKind,setupGuideUrl:e.setupGuideUrl,operationId:y.operationId});return}a&&y?.operationId!==a.operationId&&(o(null),v.current=null)},[y,a]),(0,X.useEffect)(()=>{y?.phase===`connecting`&&(v.current=null)},[y?.phase]),(0,X.useEffect)(()=>{!s||d?.status!==`connected`||(W.success(n(`useOauthConnect.accountConnected`,{name:s.providerLabel,ns:`common`})),l(null),f(null))},[s,d,n]);let T=(0,X.useCallback)(async e=>{let t=await w();return t.isError?[]:nt(t.data?.servers??[],e)},[w]),{remove:E}=Be(e,{onRemoved:()=>{w(),g(null)},onRemoveError:(e,t)=>{u(t,{context:`integrations.connectRollback`,tags:{plugin:e}}),g(null)},announceWarnings:!1}),D=(0,X.useCallback)((t,n)=>{let a=(async()=>{await i({path:{assistant_id:e},body:{name:t}}),P(r,e,t)})();return v.current={itemId:n,pluginName:t,landed:a.then(()=>!0,()=>!1)},a},[e,i,r]),O=(0,X.useCallback)(()=>{let e=v.current;v.current=null,e&&(g(e.itemId),e.landed.then(t=>{if(!t){g(null);return}E(e.pluginName)}))},[E]),k=(0,X.useCallback)(()=>{a&&S(),l(null),f(null),O()},[S,a,O]),A=(0,X.useCallback)((e,t,n,r)=>{h!==e.itemId&&(k(),_.current={...e,priorOperationId:y?.operationId??null},b(t,r,n))},[y,b,k,h]),j=(0,X.useCallback)((e,t,n)=>{let r=n.plugin;if(!r||C)return;let i=!!r.installed;A({itemId:e.id,methodId:n.id,methodKind:n.kind,setupGuideUrl:n.setupGuideUrl},$e(r.pluginName),t.name,tt({install:i?()=>Promise.resolve():()=>D(r.pluginName,e.id),loadPluginServers:()=>T(r.pluginName)}))},[C,A,D,T]),M=(0,X.useCallback)((e,t,n,r)=>{if(e.kind!==`oauth`||C)return;let{provider:i}=e;if(!r?.tenantHost&&c(i.provider_key,i.tenant_host)){m({itemId:e.id,methodId:n.id});return}k(),l({itemId:e.id,methodId:n.id,providerKey:i.provider_key,providerLabel:t.name,tenantHost:r?.tenantHost,restartToken:0})},[C,k]),N=(0,X.useCallback)((e,t,n,r)=>{if(Q(n.kind)){j(e,t,n);return}n.kind===`managed-oauth`&&M(e,t,n,r)},[M,j]),ee=(0,X.useCallback)((e,t,n)=>{let r=yt(t).find(e=>e.id===n.methodId);if(!Q(n.methodKind)){r&&M(e,t,r);return}!n.serverId||C||A({itemId:e.id,methodId:n.methodId,methodKind:n.methodKind,setupGuideUrl:r?.setupGuideUrl},n.serverId,t.name)},[C,A,M]),F=(0,X.useCallback)((e,t,n)=>{if(n.kind===`mcp-manual`||n.kind===`own-oauth`){m({itemId:e.id,methodId:n.id});return}N(e,t,n)},[N]),I=(0,X.useCallback)(()=>{if(a){if(y?.phase!==`error`)return;_.current={itemId:a.itemId,methodId:a.methodId,methodKind:a.methodKind,setupGuideUrl:a.setupGuideUrl,priorOperationId:a.operationId},x();return}f(null),l(e=>e&&{...e,restartToken:e.restartToken+1})},[y,x,a]),L=(0,X.useCallback)((e,t)=>a?.itemId===e&&y?y.phase===`error`?{phase:`failed`,error:y.error??n(`integrationTile.failedGeneric`,{name:t}),methodId:a.methodId,methodKind:a.methodKind,setupGuideUrl:a.setupGuideUrl}:y.phase===`connecting`?{phase:`connecting`}:{phase:`waiting`,canCancel:!0}:s?.itemId===e?d?.errorMessage?{phase:`failed`,error:d.errorMessage,methodId:s.methodId,methodKind:`managed-oauth`}:{phase:`waiting`,canCancel:!0}:Wt,[y,s,d,a,n]),R=(0,X.useCallback)(e=>a?.itemId===e&&y?{methodId:a.methodId,phase:y.phase,error:y.error,canCancel:!0}:s?.itemId===e?{methodId:s.methodId,phase:d?.errorMessage?`error`:`waiting`,error:d?.errorMessage??void 0,canCancel:!0}:null,[y,s,d,a]),te=(0,X.useCallback)(e=>C&&a?.itemId!==e||s!==null&&s.itemId!==e||h===e,[C,s,a,h]),ne=(0,X.useCallback)((e,t)=>m({itemId:e,methodId:t}),[]),re=(0,X.useCallback)(()=>m(null),[]);return{start:F,run:N,reconnect:ee,cancel:k,retry:I,stateFor:L,attemptFor:R,isBusyElsewhere:te,ownsMcpAttempt:a!==null,attemptItemId:a?.itemId??s?.itemId??null,managed:s,onManagedReport:f,modal:p,openModal:ne,closeModal:re}}function Kt({assistantId:e,platformAssistantId:t,onStopAuth:n,onRemoveServer:r,onPluginRemoved:i}){let{t:a}=K(`settings`),o=q(),s=(0,X.useRef)(``),c=Be(e,{onRemoved:()=>{i(),W.success(a(`integrationConnect.removedToast`,{name:s.current}))},onRemoveError:()=>W.error(a(`integrationConnect.removeFailedToast`,{name:s.current}))}),l={path:{assistant_id:t??``}},u=y({onSuccess(e,t){W.success(a(`integrationConnect.disconnectedToast`,{name:s.current}));let n=t.path.connection_id;ce(o,l,e=>e?.filter(e=>e.id!==n)),o.invalidateQueries({queryKey:V(l)})},onError(e){W.error(E(e,void 0,a(`integrationConnect.disconnectFailedToast`,{name:s.current})))}}),d=u.mutate,f=c.remove,p=c.isRemoving||u.isPending;return(0,X.useCallback)((e,i)=>{if(!p){if(s.current=i,Q(e.methodKind)){if(n(e),e.pluginName){f(e.pluginName);return}e.serverId&&r(e.serverId);return}!e.accountId||!t||d({path:{assistant_id:t,connection_id:e.accountId}})}},[p,d,r,n,t,f])}var qt=[{value:`none`,labelKey:`mcpAddServerModal.authNone`},{value:`oauth`,labelKey:`mcpAddServerModal.authOAuth`},{value:`bearer`,labelKey:`mcpAddServerModal.authBearer`},{value:`api-key`,labelKey:`mcpAddServerModal.authApiKey`}],Jt=[{value:`sse`,labelKey:`mcpAddServerModal.transportSse`},{value:`streamable-http`,labelKey:`mcpAddServerModal.transportStreamableHttp`},{value:`stdio`,labelKey:`mcpAddServerModal.transportStdio`}];function Yt(e){return qt.map(({value:t,labelKey:n})=>({value:t,label:e(n)}))}function Xt(e){return Jt.map(({value:t,labelKey:n})=>({value:t,label:e(n)}))}function Zt({open:e,onClose:t,onAdd:n,isPending:r}){let{t:i}=K(`settings`),a=(0,X.useMemo)(()=>Yt(i),[i]),o=(0,X.useMemo)(()=>Xt(i),[i]),[s,c]=(0,X.useState)(``),[l,u]=(0,X.useState)(`sse`),[d,f]=(0,X.useState)(``),[p,m]=(0,X.useState)(``),[h,g]=(0,X.useState)(``),[_,y]=(0,X.useState)(`none`),[b,x]=(0,X.useState)(``),[C,w]=(0,X.useState)(`X-API-Key`),[T,E]=(0,X.useState)(``),D=(0,X.useCallback)(()=>{c(``),u(`sse`),f(``),m(``),g(``),y(`none`),x(``),w(`X-API-Key`),E(``)},[]),O=(0,X.useCallback)(()=>{r||(D(),t())},[r,D,t]),k=(0,X.useCallback)(()=>{let e=s.trim();if(!e)return;let t={name:e,transportType:l};if(l===`stdio`){let e=p.trim();if(!e)return;t.command=e;let n=h.trim();n&&(t.args=n.split(/\s+/))}else{let e=d.trim();if(!e)return;t.url=e,_===`bearer`&&b.trim()?t.headers={Authorization:`Bearer ${b.trim()}`}:_===`api-key`&&C.trim()&&T.trim()?t.headers={[C.trim()]:T.trim()}:_===`oauth`&&(t.autoAuth=!0)}n(t)},[s,l,d,p,h,_,b,C,T,n]),A=l===`stdio`,j=s.trim()&&(A?p.trim():d.trim());return(0,Z.jsx)(S.Root,{open:e,onOpenChange:e=>{e||O()},children:(0,Z.jsxs)(S.Content,{size:`md`,children:[(0,Z.jsxs)(S.Header,{icon:We,children:[(0,Z.jsx)(S.Title,{children:i(`mcpAddServerModal.title`)}),(0,Z.jsx)(S.Description,{children:i(`mcpAddServerModal.description`)})]}),(0,Z.jsx)(S.Body,{children:(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[(0,Z.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Z.jsx)(`label`,{className:`text-body-small-default text-[var(--content-secondary)]`,htmlFor:`mcp-name`,children:i(`mcpAddServerModal.serverNameLabel`)}),(0,Z.jsx)(v,{id:`mcp-name`,type:`text`,value:s,onChange:e=>c(e.target.value),placeholder:i(`mcpAddServerModal.namePlaceholder`),fullWidth:!0,autoFocus:!0})]}),(0,Z.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Z.jsx)(`label`,{className:`text-body-small-default text-[var(--content-secondary)]`,htmlFor:`mcp-transport`,children:i(`mcpAddServerModal.transportLabel`)}),(0,Z.jsx)(`select`,{id:`mcp-transport`,value:l,onChange:e=>u(e.target.value),className:`w-full rounded-md border border-[var(--border-element)] bg-[var(--surface-lift)] px-3 py-1.5 text-body-medium-default text-[var(--content-default)] outline-none focus:ring-2 focus:ring-[var(--ring)]`,children:o.map(e=>(0,Z.jsx)(`option`,{value:e.value,children:e.label},e.value))})]}),A?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Z.jsx)(`label`,{className:`text-body-small-default text-[var(--content-secondary)]`,htmlFor:`mcp-command`,children:i(`mcpAddServerModal.commandLabel`)}),(0,Z.jsx)(v,{id:`mcp-command`,type:`text`,value:p,onChange:e=>m(e.target.value),placeholder:i(`mcpAddServerModal.commandPlaceholder`),fullWidth:!0})]}),(0,Z.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Z.jsx)(`label`,{className:`text-body-small-default text-[var(--content-secondary)]`,htmlFor:`mcp-args`,children:i(`mcpAddServerModal.argsLabel`)}),(0,Z.jsx)(v,{id:`mcp-args`,type:`text`,value:h,onChange:e=>g(e.target.value),placeholder:i(`mcpAddServerModal.argsPlaceholder`),fullWidth:!0})]})]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Z.jsx)(`label`,{className:`text-body-small-default text-[var(--content-secondary)]`,htmlFor:`mcp-url`,children:i(`mcpAddServerModal.serverUrlLabel`)}),(0,Z.jsx)(v,{id:`mcp-url`,type:`url`,value:d,onChange:e=>f(e.target.value),placeholder:i(`mcpAddServerModal.urlPlaceholder`),fullWidth:!0})]}),(0,Z.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Z.jsx)(`label`,{className:`text-body-small-default text-[var(--content-secondary)]`,htmlFor:`mcp-auth`,children:i(`mcpAddServerModal.authenticationLabel`)}),(0,Z.jsx)(`select`,{id:`mcp-auth`,value:_,onChange:e=>y(e.target.value),className:`w-full rounded-md border border-[var(--border-element)] bg-[var(--surface-lift)] px-3 py-1.5 text-body-medium-default text-[var(--content-default)] outline-none focus:ring-2 focus:ring-[var(--ring)]`,children:a.map(e=>(0,Z.jsx)(`option`,{value:e.value,children:e.label},e.value))})]}),_===`oauth`?(0,Z.jsx)(`p`,{className:`rounded-md border border-[var(--border-element)] bg-[var(--surface-base)] px-3 py-2 text-body-small-lighter text-[var(--content-tertiary)]`,children:i(`mcpAddServerModal.oauthHint`)}):null,_===`bearer`?(0,Z.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Z.jsx)(`label`,{className:`text-body-small-default text-[var(--content-secondary)]`,htmlFor:`mcp-bearer`,children:i(`mcpAddServerModal.bearerTokenLabel`)}),(0,Z.jsx)(v,{id:`mcp-bearer`,type:`password`,value:b,onChange:e=>x(e.target.value),placeholder:i(`mcpAddServerModal.bearerPlaceholder`),fullWidth:!0})]}):null,_===`api-key`?(0,Z.jsxs)(`div`,{className:`flex gap-3`,children:[(0,Z.jsxs)(`div`,{className:`flex-1 space-y-1.5`,children:[(0,Z.jsx)(`label`,{className:`text-body-small-default text-[var(--content-secondary)]`,htmlFor:`mcp-apikey-header`,children:i(`mcpAddServerModal.headerNameLabel`)}),(0,Z.jsx)(v,{id:`mcp-apikey-header`,type:`text`,value:C,onChange:e=>w(e.target.value),placeholder:i(`mcpAddServerModal.apiKeyHeaderPlaceholder`),fullWidth:!0})]}),(0,Z.jsxs)(`div`,{className:`flex-1 space-y-1.5`,children:[(0,Z.jsx)(`label`,{className:`text-body-small-default text-[var(--content-secondary)]`,htmlFor:`mcp-apikey-value`,children:i(`mcpAddServerModal.apiKeyLabel`)}),(0,Z.jsx)(v,{id:`mcp-apikey-value`,type:`password`,value:T,onChange:e=>E(e.target.value),placeholder:i(`mcpAddServerModal.apiKeyPlaceholder`),fullWidth:!0})]})]}):null]})]})}),(0,Z.jsxs)(S.Footer,{children:[(0,Z.jsx)(F,{variant:`ghost`,onClick:O,disabled:r,children:i(`mcpAddServerModal.cancel`)}),(0,Z.jsx)(F,{variant:`primary`,onClick:k,disabled:!j||r,children:i(r?`mcpAddServerModal.adding`:`mcpAddServerModal.addServer`)})]})]})})}var Qt=[`none`,`bearer`,`api-key`];function $t(e,t){switch(e){case`none`:return t(`mcpServerDetailModal.authNone`);case`bearer`:return t(`mcpServerDetailModal.authBearerToken`);case`api-key`:return t(`mcpServerDetailModal.authApiKey`)}}function en({server:e,toolsSummary:t,toolsLoading:n=!1,toolsError:r=!1,readOnly:i=!1,onClose:a,onSave:o,isPending:s}){let{t:c}=K(`settings`),[l,u]=(0,X.useState)(`none`),[d,f]=(0,X.useState)(``),[p,m]=(0,X.useState)(`X-API-Key`),[h,g]=(0,X.useState)(``);(0,X.useEffect)(()=>{e&&(u(e.authType),f(``),m(e.authHeaderName??`X-API-Key`),g(``))},[e]);let _=(0,X.useCallback)(()=>{if(!e||i)return;let t=l!==e.authType,n=l===`bearer`&&d.trim()!==``,r=l===`api-key`&&p.trim()!==``&&h.trim()!==``,a=t||n||r,s;s=a?l===`none`?null:l===`bearer`&&d.trim()?{Authorization:`Bearer ${d.trim()}`}:l===`api-key`&&p.trim()&&h.trim()?{[p.trim()]:h.trim()}:void 0:void 0,o(e.id,{name:e.id,...s===void 0?{}:{headers:s}})},[e,l,d,p,h,o,i]),y=(0,X.useCallback)(()=>{s||a()},[s,a]);return e?(0,Z.jsx)(S.Root,{open:!!e,onOpenChange:e=>{e||y()},children:(0,Z.jsxs)(S.Content,{size:`lg`,children:[(0,Z.jsxs)(S.Header,{icon:We,children:[(0,Z.jsx)(S.Title,{children:e.id}),(0,Z.jsx)(S.Description,{children:c(`mcpServerDetailModal.description`,{transport:e.transport.type,status:e.status})})]}),(0,Z.jsx)(S.Body,{children:(0,Z.jsxs)(`div`,{className:`space-y-5`,children:[!i&&e.transport.type!==`stdio`?(0,Z.jsxs)(Z.Fragment,{children:[e.hasOAuth?(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 rounded-md border border-[var(--border-element)] bg-[var(--surface-base)] px-3 py-2`,children:[(0,Z.jsx)(`span`,{className:`text-body-small-default text-[var(--content-secondary)]`,children:c(`mcpServerDetailModal.authentication`)}),(0,Z.jsx)(`span`,{className:`rounded-full bg-[var(--surface-lift)] px-2 py-0.5 text-label-small-default text-[var(--content-default)]`,children:c(`mcpServerDetailModal.oauthBadge`)}),(0,Z.jsx)(`span`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:c(`mcpServerDetailModal.oauthManagedHint`)})]}):null,e.hasOAuth?null:(0,Z.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Z.jsx)(`label`,{className:`text-body-small-default text-[var(--content-secondary)]`,htmlFor:`mcp-detail-auth`,children:c(`mcpServerDetailModal.authentication`)}),(0,Z.jsx)(`select`,{id:`mcp-detail-auth`,value:l,onChange:e=>u(e.target.value),className:`w-full rounded-md border border-[var(--border-element)] bg-[var(--surface-lift)] px-3 py-1.5 text-body-medium-default text-[var(--content-default)] outline-none focus:ring-2 focus:ring-[var(--ring)]`,children:Qt.map(e=>(0,Z.jsx)(`option`,{value:e,children:$t(e,c)},e))})]}),l===`bearer`&&!e.hasOAuth?(0,Z.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Z.jsx)(`label`,{className:`text-body-small-default text-[var(--content-secondary)]`,htmlFor:`mcp-detail-bearer`,children:c(`mcpServerDetailModal.bearerToken`)}),(0,Z.jsx)(v,{id:`mcp-detail-bearer`,type:`password`,value:d,onChange:e=>f(e.target.value),placeholder:e.hasStaticAuth&&e.authType===`bearer`?c(`mcpServerDetailModal.savedBearerPlaceholder`):c(`mcpServerDetailModal.bearerTokenPlaceholder`),fullWidth:!0})]}):null,l===`api-key`&&!e.hasOAuth?(0,Z.jsxs)(`div`,{className:`flex gap-3`,children:[(0,Z.jsxs)(`div`,{className:`flex-1 space-y-1.5`,children:[(0,Z.jsx)(`label`,{className:`text-body-small-default text-[var(--content-secondary)]`,htmlFor:`mcp-detail-apikey-header`,children:c(`mcpServerDetailModal.headerName`)}),(0,Z.jsx)(v,{id:`mcp-detail-apikey-header`,type:`text`,value:p,onChange:e=>m(e.target.value),placeholder:c(`mcpServerDetailModal.headerNamePlaceholder`),fullWidth:!0})]}),(0,Z.jsxs)(`div`,{className:`flex-1 space-y-1.5`,children:[(0,Z.jsx)(`label`,{className:`text-body-small-default text-[var(--content-secondary)]`,htmlFor:`mcp-detail-apikey-value`,children:c(`mcpServerDetailModal.apiKey`)}),(0,Z.jsx)(v,{id:`mcp-detail-apikey-value`,type:`password`,value:h,onChange:e=>g(e.target.value),placeholder:e.hasStaticAuth&&e.authType===`api-key`?c(`mcpServerDetailModal.savedApiCredentialPlaceholder`):c(`mcpServerDetailModal.apiKeyPlaceholder`),fullWidth:!0})]})]}):null]}):null,e.transport.url||e.transport.command?(0,Z.jsxs)(`dl`,{className:`space-y-1 text-body-small-default`,children:[(0,Z.jsx)(`dt`,{className:`text-[var(--content-secondary)]`,children:e.transport.type===`stdio`?c(`mcpServerDetailModal.command`):c(`mcpServerDetailModal.endpoint`)}),(0,Z.jsx)(`dd`,{className:`text-[var(--content-tertiary)] [overflow-wrap:anywhere]`,children:e.transport.url??e.transport.command})]}):null,(0,Z.jsxs)(`section`,{className:`space-y-2`,children:[(0,Z.jsx)(`h3`,{className:`text-body-medium-default text-[var(--content-default)]`,children:c(`mcpServerDetailModal.toolsHeading`)}),n?(0,Z.jsx)(`p`,{role:`status`,className:`text-body-small-default text-[var(--content-tertiary)]`,children:c(`mcpServerDetailModal.toolsLoading`)}):r?(0,Z.jsx)(`p`,{role:`alert`,className:`text-body-small-default text-[var(--content-tertiary)]`,children:c(`mcpServerDetailModal.toolsError`)}):t&&t.tools.length>0?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`p`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:c(`mcpServerDetailModal.tokenOverhead`,{count:t.estimatedTokens.toLocaleString()})}),(0,Z.jsx)(`ul`,{className:`divide-y divide-[var(--border-base)] rounded-lg border border-[var(--border-base)]`,children:t.tools.map(e=>(0,Z.jsxs)(`li`,{className:`space-y-1 px-3 py-3`,children:[(0,Z.jsx)(`p`,{className:`text-body-small-default text-[var(--content-default)] [overflow-wrap:anywhere]`,children:e.name}),e.description?(0,Z.jsx)(`p`,{className:`whitespace-pre-wrap text-body-small-default text-[var(--content-secondary)] [overflow-wrap:anywhere]`,children:e.description}):null,(0,Z.jsx)(`p`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:c(`mcpServerDetailModal.toolEstimatedTokens`,{count:e.estimatedTokens.toLocaleString()})})]},e.name))})]}):(0,Z.jsx)(`p`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:c(`mcpServerDetailModal.toolsEmpty`)})]})]})}),(0,Z.jsxs)(S.Footer,{children:[(0,Z.jsx)(F,{variant:i?`primary`:`ghost`,onClick:y,disabled:s,children:c(i?`mcpServerDetailModal.close`:`mcpServerDetailModal.cancel`)}),i?null:(0,Z.jsx)(F,{variant:`primary`,onClick:_,disabled:s,children:c(s?`mcpServerDetailModal.saving`:`mcpServerDetailModal.save`)})]})]})}):null}function tn({connections:e,allowAdd:t,attemptReportedElsewhere:n=!1}){let{t:r}=K(`settings`),{auth:i,add:a,save:s,remove:c,details:l,configureServer:u}=e;return(0,Z.jsxs)(Z.Fragment,{children:[i.attempt&&!n?(0,Z.jsx)(o,{tone:i.attempt.error?`warning`:`info`,children:(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[(0,Z.jsx)(`p`,{className:`[overflow-wrap:anywhere]`,children:i.attempt.error??(i.attempt.phase===`connecting`?r(`mcpConnect.waitingForRuntime`,{name:i.attempt.displayName}):r(`mcpConnect.waitingForAuthorization`,{name:i.attempt.displayName}))}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[i.attempt.phase===`error`?(0,Z.jsx)(F,{variant:`outlined`,onClick:i.retry,children:r(`mcpConnect.retry`)}):null,(0,Z.jsx)(F,{variant:`ghost`,onClick:i.stopWaiting,children:r(`mcpConnect.stopWaiting`)})]})]})}):null,t?(0,Z.jsx)(Zt,{open:e.addOpen,onClose:()=>e.setAddOpen(!1),onAdd:e.addCustom,isPending:a.isPending}):null,(0,Z.jsx)(en,{server:u,readOnly:u?.source===`plugin`,toolsSummary:l.data?.servers.find(e=>e.serverId===u?.id),toolsLoading:l.isFetching,toolsError:l.isError,onClose:()=>e.setConfigureServerId(null),onSave:(e,t)=>s.mutate(t),isPending:s.isPending}),(0,Z.jsx)(I,{open:e.removeServerId!==null,title:r(`mcpPage.removeDialogTitle`),message:e.removeServerId?r(`mcpPage.removeDialogMessage`,{serverId:e.removeServerId}):``,confirmLabel:r(`mcpPage.removeDialogConfirm`),destructive:!0,isPending:c.isPending,onConfirm:()=>{e.removeServerId&&c.mutate(e.removeServerId)},onCancel:()=>e.setRemoveServerId(null)})]})}function nn(e,t){let n=new Map(t.map(e=>[e.name,e]));return e.flatMap(e=>{let t=e.integration;if(t?.kind!==`mcp`)return[];let r=n.get(e.name);return[{pluginName:e.name,displayName:t.displayName,description:e.description??t.displayName,documentationUrl:t.documentationUrl,logo:t.logo,oauthProvider:t.oauthProvider,category:rt(t.category)??void 0,setup:t.setup,installed:r?{icon:r.icon,hasIcon:r.hasIcon,iconVersion:r.iconVersion}:void 0}]})}function rn(){return(0,Z.jsx)(`span`,{"aria-hidden":`true`,className:`flex size-8 shrink-0 items-center justify-center rounded-md bg-[var(--surface-base)] text-[var(--content-secondary)]`,children:(0,Z.jsx)(De,{size:20})})}function an({server:e,onRemove:t,onConfigure:r,onAuthenticate:i,onManagePlugin:a,isAuthenticating:o,connectDisabled:s=!1}){let{t:c}=K(`settings`),l=e.source===`plugin`,u=!l&&e.status===`needs-auth`&&e.transport.type!==`stdio`,d=!l&&!o&&!u,f=l?c(`mcpServerCard.managePlugin`):o?c(`mcpServerCard.connecting`):e.hasOAuth?c(`mcpServerCard.reconnect`):c(`mcpServerCard.finishConnecting`);return(0,Z.jsx)(Ct,{icon:(0,Z.jsx)(rn,{}),title:e.id,subtitle:l?e.pluginName:lt(e),status:e.status===`connected`?void 0:(0,Z.jsx)(n,{tone:`negative`,children:c(`mcpServerCard.statusNeedsAttention`)}),primaryAction:d?(0,Z.jsx)(F,{variant:`outlined`,className:$,iconOnly:(0,Z.jsx)(Pe,{}),"aria-label":c(`mcpServerCard.configureLabel`,{serverId:e.id}),onClick:()=>r(e.id)}):(0,Z.jsx)(F,{variant:u?`primary`:`outlined`,loading:o,onClick:()=>{l?a(e.pluginName):u&&i(e.id)},disabled:o||u&&s,children:f}),actionMenu:(0,Z.jsxs)(j.Root,{children:[(0,Z.jsx)(j.Trigger,{asChild:!0,children:(0,Z.jsx)(F,{variant:`ghost`,iconOnly:(0,Z.jsx)(Ce,{}),className:$,"aria-label":c(`mcpServerCard.moreActions`,{serverId:e.id})})}),(0,Z.jsxs)(j.Content,{title:e.id,showTitle:!0,closeLabel:c(`mcpServerCard.actionsSheetClose`),align:`end`,children:[u||l?(0,Z.jsx)(j.Item,{icon:Pe,label:c(l?`mcpServerCard.viewDetails`:`mcpServerCard.configure`),onSelect:()=>r(e.id)}):null,l?null:(0,Z.jsx)(j.Item,{icon:we,label:c(`mcpServerCard.removeServer`),tone:`destructive`,onSelect:()=>t(e.id)})]})]})})}function on({assistantId:e,definition:t}){let n=He(e,t.pluginName,t.installed?.hasIcon,t.installed?.iconVersion);return(0,Z.jsx)(Ue,{external:!0,icon:t.installed?.icon,iconSrc:n,iconUrl:ft(t)??void 0,size:`md`})}function sn({assistantId:e,method:t,disabled:r,onOpen:i}){let{t:a}=K(`settings`),o=ot([],[t]);return(0,Z.jsx)(Ct,{icon:(0,Z.jsx)(on,{assistantId:e,definition:t.definition}),title:t.definition.displayName,subtitle:t.definition.description,status:o.needsAttention?(0,Z.jsx)(n,{tone:`negative`,children:a(`integrationRow.needsAttention`)}):void 0,primaryAction:(0,Z.jsx)(F,{variant:`outlined`,className:$,iconOnly:(0,Z.jsx)(Pe,{}),"aria-label":a(`integrationRow.configureLabel`,{name:t.definition.displayName}),disabled:r,onClick:i})})}async function cn(e){let{data:t,response:n}=await l.get({url:`/v1/assistants/{assistant_id}/internal/mcp/list`,path:{assistant_id:e}});if(!n?.ok)throw Error(`Failed to fetch MCP servers: ${n?.status}`);return t}async function ln(e){let{data:t,response:n}=await l.get({url:`/v1/assistants/{assistant_id}/internal/mcp/tools-summary`,path:{assistant_id:e}});if(!n?.ok)throw Error(`Failed to fetch MCP tools summary: ${n?.status}`);return t}async function un(e,t){let{response:n}=await l.post({url:`/v1/assistants/{assistant_id}/internal/mcp/update`,path:{assistant_id:e},body:t});if(!n?.ok)throw Error(`Failed to update MCP server: ${n?.status}`)}async function dn(e,t){let{response:n}=await l.post({url:`/v1/assistants/{assistant_id}/internal/mcp/add`,path:{assistant_id:e},body:t});if(!n?.ok)throw Error(`Failed to add MCP server: ${n?.status}`)}async function fn(e,t){let{response:n}=await l.post({url:`/v1/assistants/{assistant_id}/internal/mcp/remove`,path:{assistant_id:e},body:{name:t}});if(!n?.ok)throw Error(`Failed to remove MCP server: ${n?.status}`)}async function pn(e,t){let{data:n,response:r}=await l.post({url:`/v1/assistants/{assistant_id}/internal/mcp/auth/start`,path:{assistant_id:e},body:{serverId:t}});if(!r?.ok)throw Error(`Failed to start MCP auth: ${r?.status}`);return n}async function mn(e,t){let{data:n,response:r}=await l.get({url:`/v1/assistants/{assistant_id}/internal/mcp/auth/status/${encodeURIComponent(t)}`,path:{assistant_id:e}});if(!r?.ok)throw Error(`Failed to poll MCP auth status: ${r?.status}`);return n}function hn(e,t){return e.some(e=>e.id===t&&e.status===`connected`)}function gn(e,t){return t?null:e}function _n(e){let{t}=K(`settings`),n=q(),[i,a]=(0,X.useState)(null),o=(0,X.useRef)(null),s=(0,X.useRef)(null),c=(0,X.useRef)(null),l=(0,X.useCallback)(()=>{o.current=null,c.current=null,s.current?.close(),s.current=null,a(null)},[]);(0,X.useEffect)(()=>(l(),()=>{o.current=null,c.current=null,s.current?.close(),s.current=null}),[e,l]);let d=i?.phase===`authorizing`||i?.phase===`waiting`,m=G({queryKey:f.auth(e,i?.operationId??``),queryFn:()=>mn(e,i.serverId),enabled:d,refetchInterval:d?w:!1,staleTime:0,gcTime:0,retry:1}),h=G({queryKey:f.list(e),queryFn:()=>cn(e),enabled:i?.phase===`connecting`,refetchInterval:i?.phase===`connecting`?w:!1,staleTime:0,retry:1});(0,X.useEffect)(()=>{!i||!d||o.current!==i.operationId||!m.data||(m.data.status===`complete`?(s.current?.close(),s.current=null,a({...i,phase:`connecting`}),n.invalidateQueries({queryKey:f.list(e)})):m.data.status===`error`&&a({...i,phase:`error`,error:m.data.error?.replaceAll(i.serverId,i.displayName)??t(`mcpConnect.authorizationFailed`)}))},[e,i,m.data,d,n,t]),(0,X.useEffect)(()=>{i?.phase!==`connecting`||o.current!==i.operationId||!h.data||h.isFetching||hn(h.data.servers,i.serverId)&&(l(),n.invalidateQueries({queryKey:f.details(e)}))},[e,i,n,h.data,h.isFetching,l]),(0,X.useEffect)(()=>{if(!i||i.phase===`error`)return;let e=d?gn(m.error,m.isFetching):i.phase===`connecting`?gn(h.error,h.isFetching):null;e&&(u(e,{context:`mcp.connect.poll`}),a({...i,phase:`error`,error:t(`mcpConnect.pollFailed`)}))},[i,m.error,m.isFetching,d,h.error,h.isFetching,t]),(0,X.useEffect)(()=>{if(!i||i.phase===`error`)return;let e=setTimeout(()=>{o.current===i.operationId&&(s.current?.close(),s.current=null,a(e=>e?.operationId===i.operationId?{...e,phase:`error`,error:t(`mcpConnect.timedOut`)}:e))},Math.max(0,i.startedAt+r-Date.now()));return()=>clearTimeout(e)},[i,t]);let g=(0,X.useCallback)(t=>{o.current===t&&(a(e=>e?.operationId===t&&e.phase===`authorizing`?{...e,phase:`waiting`}:e),n.invalidateQueries({queryKey:f.auth(e,t)}),n.invalidateQueries({queryKey:f.list(e)}))},[e,n]);(0,X.useEffect)(()=>{let e=s.current;if(i?.phase!==`authorizing`||!e)return;let t=setInterval(()=>{e.closed&&g(i.operationId)},500);return()=>clearInterval(t)},[i?.operationId,i?.phase,g]),(0,X.useEffect)(()=>{let e=i?.operationId,t=i?.phase;if(!(!e||t===`connecting`||t===`error`))return M(()=>g(e))},[i?.operationId,i?.phase,g]);let v=(0,X.useCallback)((n,r,l=n)=>{if(o.current&&i?.phase!==`error`)return;let d=crypto.randomUUID();o.current=d,s.current?.close(),s.current=null,c.current=r?{operationId:d,run:r}:null;let f={operationId:d,serverId:n,displayName:l,startedAt:Date.now(),phase:`starting`};a(f);let m=x()||_(),h=m?null:window.open(``,`_blank`,`width=500,height=600`);if(!m&&!h){a({...f,phase:`error`,error:t(`mcpConnect.popupBlocked`)});return}h&&(h.opener=null,s.current=h);let g=()=>o.current===d&&Date.now()<f.startedAt+3e5;(async()=>{try{let t=await r?.();if(c.current?.operationId===d&&(c.current=null),!g())return;if(t===null){h?.close(),s.current=null,o.current=null,a(null);return}let n=t?{...f,serverId:t}:f;t&&a(n);let i=await pn(e,n.serverId);if(!g())return;if(i.already_authenticated){h?.close(),s.current=null,a({...n,phase:`connecting`});return}let l=new URL(i.auth_url);if(l.protocol!==`https:`&&l.protocol!==`http:`)throw Error(`Unsupported MCP authorization URL protocol`);a({...n,phase:`authorizing`}),h?h.closed||h.location.replace(l.href):await p(l.href)}catch(e){h?.close(),g()&&(s.current=null,u(e,{context:`mcp.connect.start`}),a(e=>e?.operationId===d?{...e,phase:`error`,error:t(`mcpConnect.startFailed`)}:e))}})()},[e,i?.phase,t]);return{attempt:i,isBusy:!!(i&&i.phase!==`error`),connect:v,retry:()=>{i&&v(i.serverId,c.current?.run,i.displayName)},stopWaiting:l}}function vn(e){let{t}=K(`settings`),n=q(),r=_n(e),[i,a]=(0,X.useState)(!1),[o,s]=(0,X.useState)(null),[c,l]=(0,X.useState)(null),[d,p]=(0,X.useState)(null),m=G({queryKey:f.list(e),queryFn:()=>cn(e)}),h=m.data?.servers.find(e=>e.id===o)??null,g=G({queryKey:f.details(e),queryFn:()=>ln(e),enabled:h!==null||d!==null}),_=()=>{n.invalidateQueries({queryKey:f.list(e)}),n.invalidateQueries({queryKey:f.details(e)})},v=ge({mutationFn:t=>dn(e,t),onSuccess:()=>{_(),a(!1)},onError:e=>{u(e,{context:`mcp.add`}),W.error(t(`mcpConnect.addFailed`))}});return{list:m,details:g,auth:r,add:v,save:ge({mutationFn:t=>un(e,t),onSuccess:()=>{_(),s(null)},onError:e=>{u(e,{context:`mcp.update`}),W.error(t(`mcpConnect.saveFailed`))}}),remove:ge({mutationFn:t=>fn(e,t),onSuccess:(e,n)=>{r.attempt?.serverId===n&&r.stopWaiting(),_(),l(null),s(null),W.success(t(`mcpPage.toastRemoved`,{serverId:n}))},onError:(e,n)=>{u(e,{context:`mcp.remove`}),W.error(t(`mcpPage.toastRemoveFailed`,{serverId:n}))}}),addCustom:e=>{e.autoAuth?r.connect(e.name,async()=>{await v.mutateAsync(e)},e.name):v.mutate(e)},addOpen:i,setAddOpen:a,configureServer:h,configureServerId:o,setConfigureServerId:s,removeServerId:c,setRemoveServerId:l,toolsServerId:d,setToolsServerId:p}}var yn={productivity:`integrationsPage.categories.productivity`,communication:`integrationsPage.categories.communication`,meetings:`integrationsPage.categories.meetings`,sales:`integrationsPage.categories.sales`,marketing:`integrationsPage.categories.marketing`,finance:`integrationsPage.categories.finance`,commerce:`integrationsPage.categories.commerce`,engineering:`integrationsPage.categories.engineering`,knowledge:`integrationsPage.categories.knowledge`,recruiting:`integrationsPage.categories.recruiting`},bn=`grid gap-3 [grid-template-columns:repeat(auto-fill,minmax(min(100%,22rem),1fr))]`,xn=`grid gap-3 [grid-template-columns:repeat(auto-fill,minmax(min(100%,15rem),1fr))]`;function Sn({title:e,count:t,gridClassName:n,children:r}){return(0,Z.jsxs)(`section`,{className:`space-y-3`,children:[(0,Z.jsxs)(`h2`,{className:`flex items-center gap-2 text-title-small text-[var(--content-default)]`,children:[e,(0,Z.jsx)(`span`,{className:`text-body-medium-lighter text-[var(--content-tertiary)]`,children:t})]}),(0,Z.jsx)(`div`,{className:n,children:r})]})}function Cn(e,t){return{denied:e(`integrationsPage.oauthErrorDenied`),state_invalid:e(`integrationsPage.oauthErrorStateInvalid`),state_expired:e(`integrationsPage.oauthErrorStateExpired`),exchange_failed:e(`integrationsPage.oauthErrorExchangeFailed`),identity_failed:e(`integrationsPage.oauthErrorIdentityFailed`)}[t]}function wn({mcpAssistantId:e}){let{t}=K(`settings`),[n,r]=ve(),a=be(),s=ye(),c=T(),l=C(),f=le.use.mcpAddServer(),m=le.use.hasHydrated(),[g,_]=(0,X.useState)(null),[y,b]=(0,X.useState)(!0),[x,S]=(0,X.useState)(``),[w,E]=(0,X.useState)(null),k=n.get(`provider`),A=(0,X.useRef)(null),j=vn(e),M=Ve(e),N=Gt({assistantId:e,mcp:j});(0,X.useEffect)(()=>{let t=!0;return(async()=>{try{let n=await d(e);t&&n.ok&&_(n.data)}catch(e){u(e,{context:`integrations.getAssistant`})}finally{t&&b(!1)}})(),()=>{t=!1}},[e]);let{login:P}=re(`${s.pathname}${s.search}${s.hash}`),ee=(0,X.useCallback)(()=>void P(),[P]),I=N.closeModal,L=N.cancel,R=N.attemptItemId,ne=N.modal?.itemId??null,oe=j.setToolsServerId,se=(0,X.useCallback)(()=>{if(ne!==null&&R===ne&&L(),I(),oe(null),!n.has(`provider`))return;let e=new URLSearchParams(n);e.delete(`provider`),r(e,{replace:!0})},[L,R,I,ne,n,r,oe]),{platformAssistantId:ce,isLoading:ue,error:de}=h(g?.id,c===`full`),z=G({...ie({path:{assistant_id:g?.id??``}}),select:e=>e.providers,enabled:!!g}),B=G({...te({path:{assistant_id:ce??``}}),enabled:!!ce&&c===`full`});(0,X.useEffect)(()=>{let e=n.get(`oauth_status`);if(!e)return;let r=n.get(`oauth_provider`),o=r?r.charAt(0).toUpperCase()+r.slice(1):null;e===`connected`?W.success(o?t(`integrationsPage.accountConnectedToast`,{providerLabel:o}):t(`integrationsPage.accountConnectedToastGeneric`)):e===`error`&&W.error(Cn(t,n.get(`oauth_code`)??`unknown`)??(o?t(`integrationsPage.connectFailedToast`,{providerLabel:o}):t(`integrationsPage.connectFailedToastGeneric`))),a(i.settings.integrations,{replace:!0})},[n,a,t]);let fe=z.isError||B.isError||!!de||!y&&!g,pe=!fe&&!!z.data&&(c!==`full`||!!B.data),V=(0,X.useMemo)(()=>ut(pe?z.data??[]:[],pe?B.data??[]:[],j.list.data?.servers??[],M.installedLoaded?nn(M.catalogMatches,M.installedPlugins):[],j.list.isSuccess),[pe,z.data,B.data,j.list.data,j.list.isSuccess,M.installedLoaded,M.catalogMatches,M.installedPlugins]),H=(0,X.useMemo)(()=>{let e=new Map;for(let t of V)t.category&&e.set(t.category,(e.get(t.category)??0)+1);return Ge.flatMap(t=>{let n=e.get(t);return n?[{category:t,count:n}]:[]})},[V]),U=H.some(e=>e.category===w)?w:null,me=(0,X.useMemo)(()=>dt(V,x,U),[V,x,U]),he=(0,X.useMemo)(()=>{let e=new Map;for(let t of V){if(t.kind===`mcp`)continue;let n=vt(t,{platformGate:c,ownOAuthAvailable:!l,mcpServersLoaded:j.list.isSuccess});n&&e.set(t.id,n)}return e},[V,l,j.list.isSuccess,c]),ge=e=>he.has(e.id)&&(!e.configured||e.id===R&&N.modal?.itemId!==e.id),_e=e=>!e.configured||ge(e),q=me.filter(e=>!_e(e)),xe=me.filter(_e).sort((e,t)=>e.name.localeCompare(t.name)||e.id.localeCompare(t.id)),Se=y||z.isLoading||B.isLoading||ue||j.list.isLoading||(M.isLoading||M.catalogLoading)&&V.length===0,Ce=j.auth.isBusy||N.managed!==null,we=y||!g||c===`full`&&!ce,Te=N.ownsMcpAttempt&&R!==null&&(N.modal?.itemId===R||me.some(e=>e.id===R&&ge(e))),J=N.modal?V.find(e=>e.id===N.modal?.itemId):void 0,Y=J?he.get(J.id):void 0,De=J?.kind===`oauth`?J.provider:void 0,Oe=D(De?.provider_key??``,De?.tenant_host),Ae=N.openModal;(0,X.useEffect)(()=>{if(!k){A.current=null;return}if(k===A.current)return;let e=V.find(e=>e.kind===`oauth`&&e.provider.provider_key===k);e&&(A.current=k,Ae(e.id))},[V,Ae,k]);let je=j.toolsServerId,Me=j.list.data?.servers.find(e=>e.id===je),Ne=Y&&je?bt(Y).find(e=>e.serverId===je):void 0,Pe=Ne?{[Ne.id]:{loading:j.details.isFetching,error:j.details.isError,summary:j.details.data?.servers.find(e=>e.serverId===je),endpointUrl:Me?.transport.url}}:void 0,Fe=Kt({assistantId:e,platformAssistantId:ce,onStopAuth:e=>{let t=j.auth.attempt?.serverId;if(!t)return;let n=e.pluginName!==void 0&&(t===$e(e.pluginName)||j.list.data?.servers.find(e=>e.id===t)?.pluginName===e.pluginName);(t===e.serverId||n)&&j.auth.stopWaiting()},onRemoveServer:j.setRemoveServerId,onPluginRemoved:()=>void j.list.refetch()}),Ie=()=>{f?j.setAddOpen(!0):ae(a,{prompt:t(`mcpPage.setupPrompt`)})},Le=t=>{let n=t.kind===`mcp`?void 0:he.get(t.id);return t.kind!==`mcp`&&n&&ge(t)?(0,Z.jsx)(Pt,{plan:n,state:N.stateFor(t.id,n.name),showAlternatives:!l,disabled:N.isBusyElsewhere(t.id)||n.primary.kind===`managed-oauth`&&we,onConnect:e=>N.start(t,n,e),onLogin:ee,onCancel:N.cancel,onRetry:N.retry,onOpenSetupGuide:e=>void p(e)},t.id):t.kind===`oauth`?(0,Z.jsx)(Nt,{providerKey:t.provider.provider_key,displayName:t.name,description:t.provider.description,logoUrl:t.provider.logo_url,connections:t.connections,mcpMethods:t.methods,disabled:we||!n||N.isBusyElsewhere(t.id),onConfigure:()=>N.openModal(t.id)},t.id):t.kind===`plugin`?(0,Z.jsx)(sn,{assistantId:e,method:t.method,disabled:!n||N.isBusyElsewhere(t.id),onOpen:()=>N.openModal(t.id)},t.id):(0,Z.jsx)(an,{server:t.server,onRemove:j.setRemoveServerId,onConfigure:j.setConfigureServerId,onAuthenticate:e=>j.auth.connect(e),onManagePlugin:e=>a(e?`${i.plugins}/${encodeURIComponent(e)}`:i.plugins),isAuthenticating:j.auth.attempt?.serverId===t.server.id&&Ce,connectDisabled:Ce},t.id)};return(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[(0,Z.jsxs)(`div`,{className:`space-y-3`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(v,{value:x,onChange:e=>S(e.target.value),placeholder:t(`integrationsPage.searchPlaceholder`),"aria-label":t(`integrationsPage.searchAriaLabel`),leftIcon:(0,Z.jsx)(Re,{"aria-hidden":!0,className:`size-4`}),className:`min-h-11`,wrapperClassName:`min-w-0 basis-64 flex-1`,fullWidth:!0}),(0,Z.jsx)(F,{variant:`outlined`,className:`min-h-11 max-w-full whitespace-normal`,leftIcon:(0,Z.jsx)(Ee,{}),onClick:Ie,disabled:!m||Ce,children:t(`integrationsPage.addCustom`)})]}),H.length>0?(0,Z.jsx)(`div`,{role:`group`,"aria-label":t(`integrationsPage.categoriesLabel`),className:`flex gap-2 overflow-x-auto pb-1 [scrollbar-width:none]`,children:H.map(e=>(0,Z.jsx)(O,{selected:U===e.category,count:e.count,onClick:()=>E(U===e.category?null:e.category),children:t(yn[e.category])},e.category))}):null]}),fe?(0,Z.jsx)(o,{tone:`warning`,children:t(`integrationsPage.oauthUnavailable`)}):null,j.list.isError?(0,Z.jsx)(o,{tone:`warning`,actions:(0,Z.jsx)(F,{variant:`ghost`,onClick:()=>void j.list.refetch(),children:t(`mcpConnect.retry`)}),children:t(`integrationsPage.mcpUnavailable`)}):null,M.catalogError||M.isError?(0,Z.jsx)(o,{tone:`warning`,children:t(`integrationsPage.pluginCatalogUnavailable`)}):null,(0,Z.jsx)(tn,{connections:j,allowAdd:f,attemptReportedElsewhere:Te}),N.managed&&g?(0,Z.jsx)(Bt,{assistantId:g.id,providerKey:N.managed.providerKey,providerLabel:N.managed.providerLabel,tenantHost:N.managed.tenantHost,restartToken:N.managed.restartToken,onReport:N.onManagedReport},N.managed.providerKey):null,Se?(0,Z.jsxs)(`div`,{role:`status`,className:`flex items-center gap-2 text-body-medium-lighter text-[var(--content-tertiary)]`,children:[(0,Z.jsx)(ke,{className:`size-4 animate-spin`}),t(`integrationsPage.loading`)]}):null,q.length>0?(0,Z.jsx)(Sn,{title:t(`integrationsPage.sectionConfigured`),count:q.length,gridClassName:bn,children:q.map(Le)}):null,xe.length>0?(0,Z.jsx)(Sn,{title:t(`integrationsPage.sectionAvailable`),count:xe.length,gridClassName:xn,children:xe.map(Le)}):null,!Se&&me.length===0?(0,Z.jsx)(`p`,{className:`py-8 text-center text-body-medium-default text-[var(--content-tertiary)]`,children:x.trim()?t(`integrationsPage.emptySearchSubtitle`,{query:x.trim()}):U?t(`integrationsPage.emptyCategory`,{category:t(yn[U])}):t(`integrationsPage.empty`)}):null,N.modal&&Y&&J&&J.kind!==`mcp`?(0,Z.jsx)(Tt,{plan:Y,focusMethodId:N.modal.methodId,attempt:N.attemptFor(J.id),tenantHost:Oe,toolsByConnectionId:Pe,ownOAuthContent:g&&J.kind===`oauth`?(0,Z.jsx)(Ut,{assistantId:g.id,providerKey:J.provider.provider_key,displayName:J.name,logoUrl:J.provider.logo_url}):null,onConnect:(e,t)=>N.run(J,Y,e,t),onLogin:ee,onCancelAttempt:N.cancel,onRetryAttempt:N.retry,onReconnect:e=>N.reconnect(J,Y,e),onOpenTools:e=>j.setToolsServerId(e.serverId??null),onDisconnect:e=>Fe(e,Y.name),onOpenSetupGuide:e=>void p(e),onClose:se},J.id):null]})}function Tn(){let e=ue();return(0,Z.jsx)(X.Suspense,{children:(0,Z.jsx)(wn,{mcpAssistantId:e},e)})}export{Tn as IntegrationsPage};
1
+ import{o as e}from"./rolldown-runtime-BM3Ffeng.js";import{$m as t,BC as n,Ci as r,DS as i,Ei as a,GC as o,Gr as s,Hr as c,Hy as l,IS as u,I_ as d,Jc as f,Jy as p,KC as m,Li as h,MC as g,OS as _,PC as v,Qd as y,Qm as b,Qy as x,SC as S,Sh as C,Si as w,Th as T,US as E,Ur as D,VC as O,Wr as k,Wy as A,XC as j,Xy as M,YC as N,Yc as P,Zm as ee,aw as F,bC as I,cm as L,dm as R,ed as te,eh as ne,el as re,fm as ie,iu as ae,lm as oe,lw as se,nd as ce,np as le,nt as ue,oC as de,ow as z,rh as B,sm as fe,sw as pe,td as V,uC as H,um as U,uw as me,xC as W,xi as he}from"./app-DbJUeBix.js";import{$n as G,E as K,Xn as ge,er as _e,nr as q}from"./vendor-CtXGFqsu.js";import{_ as ve,d as ye,f as be,t as xe,x as Se}from"./react-B9IgSVeK.js";import{$r as Ce,A as we,At as Te,D as J,Ji as Y,Lt as Ee,Pt as De,Ya as Oe,Yn as ke,Zr as Ae,a as je,dr as Me,ft as Ne,gt as Pe,i as Fe,li as Ie,qi as Le,vt as Re,za as ze}from"./icons-C0wyat6T.js";import{a as Be,n as Ve,r as He,u as Ue}from"./use-plugins-list-B9d39t5k.js";var We=Oe(`cable`,[[`path`,{d:`M17 19a1 1 0 0 1-1-1v-2a2 2 0 0 1 2-2h2a2 2 0 0 1 2 2v2a1 1 0 0 1-1 1z`,key:`trhst0`}],[`path`,{d:`M17 21v-2`,key:`ds4u3f`}],[`path`,{d:`M19 14V6.5a1 1 0 0 0-7 0v11a1 1 0 0 1-7 0V10`,key:`1mo9zo`}],[`path`,{d:`M21 21v-2`,key:`eo0ou`}],[`path`,{d:`M3 5V3`,key:`1k5hjh`}],[`path`,{d:`M4 10a2 2 0 0 1-2-2V6a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v2a2 2 0 0 1-2 2z`,key:`1dd30t`}],[`path`,{d:`M7 5V3`,key:`1t1388`}]]),Ge=[`productivity`,`communication`,`meetings`,`sales`,`marketing`,`finance`,`commerce`,`engineering`,`knowledge`,`recruiting`],Ke=new Set(Ge);function qe(e){return typeof e==`string`&&Ke.has(e)}var X=e(Se(),1),Z=xe(),Je={"mcp-oauth":We,"mcp-manual":We,"managed-oauth":Ne,"own-oauth":Me};function Ye(e){let{t}=K(`settings`);return(0,X.useCallback)(n=>{switch(n.kind){case`mcp-oauth`:return t(`connectMethod.mcp`,{name:e});case`mcp-manual`:return t(`connectMethod.mcpManual`);case`managed-oauth`:return t(`connectMethod.managed`);case`own-oauth`:return t(`connectMethod.own`)}},[t,e])}function Xe(e,t,n){return e.map(e=>(0,Z.jsx)(j.Item,{icon:Je[e.kind],label:t(e),onSelect:()=>n(e)},e.id))}var Ze={slack:`slack_channel`,discord:`discord_channel`,telegram:`telegram`};function Qe(e){return Object.entries(Ze).some(([t,n])=>t===e&&n!==e)}function $e(e){return`plugin:${e}`}function et(e){let t=e.filter(e=>e.transport.type!==`stdio`&&e.status!==`connected`);return t.length===1?t[0].id:null}function tt(e){return async()=>(await e.install(),et(await e.loadPluginServers()))}function nt(e,t){return e.filter(e=>e.source===`plugin`&&e.pluginName===t)}function rt(e){return qe(e)?e:null}function it(e){let{connectedCount:t,needsAttention:n}=ot(e,[]);return{connectedCount:t,needsAttention:n}}function at(e,t){return e.filter(e=>e.provider===t)}function ot(e,t,n=!0){let r=t.flatMap(e=>e.servers),i=t.filter(e=>ct(e,n));return{connectedCount:e.filter(e=>e.connected).length+r.filter(e=>e.status===`connected`).length,needsAttention:e.some(e=>!e.connected)||i.some(e=>e.servers.some(e=>e.status!==`connected`)),configured:e.length>0||i.length>0}}function st(e){return e.status===`connected`||e.hasOAuth||e.hasStaticAuth}function ct(e,t=!0){return t?e.servers.some(st)?!0:!!e.definition.installed&&et(e.servers)===null:!!e.definition.installed||e.servers.length>0}function lt(e){if(e.transport.url)try{return new URL(e.transport.url).hostname}catch{return}}function ut(e,t,n,r=[],i=!0){let a=r.map(e=>({definition:e,servers:nt(n,e.pluginName)})),o=new Set,s=new Set(a.flatMap(e=>e.servers));return[...e.filter(e=>e.supports_managed_mode).flatMap(e=>{let n=at(t,e.provider_key);if(Qe(e.provider_key)&&n.length===0)return[];let r=a.filter(t=>t.definition.oauthProvider===e.provider_key);return r.forEach(e=>o.add(e)),[{kind:`oauth`,id:`oauth:${e.provider_key}`,name:e.display_name??e.provider_key,description:[e.description,...r.map(e=>e.definition.description)].filter(Boolean).join(` `),configured:ot(n,r,i).configured,category:rt(e.category),provider:e,connections:n,methods:r}]}),...a.filter(e=>!o.has(e)).map(e=>({kind:`plugin`,id:`plugin:${e.definition.pluginName}`,name:e.definition.displayName,description:e.definition.description,configured:ct(e,i),category:e.definition.category??null,method:e})),...n.filter(e=>!s.has(e)).map(e=>({kind:`mcp`,id:`mcp:${e.id}`,name:e.id,description:[e.pluginName,lt(e)].filter(Boolean).join(` `),configured:!0,category:null,server:e}))]}function dt(e,t,n=null){let r=t.trim().toLocaleLowerCase();return e.filter(e=>!n||e.category===n).filter(e=>!r||e.name.toLocaleLowerCase().includes(r)||e.description.toLocaleLowerCase().includes(r)).sort((e,t)=>Number(t.configured)-Number(e.configured)||e.name.localeCompare(t.name)||e.id.localeCompare(t.id))}function ft(e){return e.logo?a(`/images/integrations/${e.logo}`):null}function Q(e){return e===`mcp-oauth`||e===`mcp-manual`}function pt(e){switch(e.status){case`connected`:return`connected`;case`connecting`:case`starting`:return`connecting`;case`declared`:return`pending`;default:return`needs-attention`}}function mt(e,t,n){let r=e.servers.length>1;return e.servers.map(e=>{let i=pt(e);return{id:`mcp:${e.id}`,methodId:t,methodKind:n,label:r?e.id:null,detail:lt(e),status:i,pluginName:e.pluginName,serverId:e.id,canReconnect:i!==`connected`&&i!==`connecting`&&e.transport.type!==`stdio`&&!e.hasStaticAuth}})}function ht(e,t,n){return{id:`plugin:${e.pluginName}`,methodId:t,methodKind:n,label:null,status:`pending`,pluginName:e.pluginName,canReconnect:!1}}function gt(e,t){return e.map(e=>({id:`oauth:${e.id}`,methodId:t,methodKind:`managed-oauth`,label:e.account_label,accountId:e.id,status:e.connected?`connected`:`needs-attention`,canReconnect:!e.connected}))}function _t(e,t){let{definition:n}=e,r=n.setup.mode===`manual`?`mcp-manual`:`mcp-oauth`,i=`mcp:${n.pluginName}`,a=t&&e.servers.length===0&&n.installed;return{id:i,kind:r,availability:`available`,instructions:n.setup.instructions,setupGuideUrl:n.documentationUrl,connections:a?[ht(n,i,r)]:mt(e,i,r),plugin:n}}function vt(e,t){let n=[],r,i=null,a;if(e.kind===`oauth`){r=e.provider.provider_key,i=e.provider.logo_url,a=e.provider.description;for(let r of e.methods)n.push(_t(r,t.mcpServersLoaded));if(t.platformGate!==`gated`){let r=`managed:${e.provider.provider_key}`;n.push({id:r,kind:`managed-oauth`,availability:t.platformGate===`full`?`available`:`login-required`,connections:gt(e.connections,r)})}t.ownOAuthAvailable&&n.push({id:`own:${e.provider.provider_key}`,kind:`own-oauth`,availability:`available`,setupGuideUrl:e.provider.dashboard_url??void 0,connections:[]})}else{let{definition:o}=e.method;r=o.pluginName,i=ft(o),a=o.description,n.push(_t(e.method,t.mcpServersLoaded))}let[o,...s]=n;return o?{name:e.name,description:a,iconKey:r,logoUrl:i,primary:o,alternatives:s}:null}function yt(e){return[e.primary,...e.alternatives]}function bt(e){return yt(e).flatMap(e=>e.connections)}function xt(e){return yt(e).filter(e=>!Q(e.kind)||e.connections.length===0)}var $=`pointer-coarse:size-11`,St=[`flex flex-wrap items-start gap-2 [&>*]:shrink-0`,`[&_button]:max-w-full [&_button]:whitespace-normal`,`[&_button]:pointer-coarse:min-h-11`].join(` `);function Ct({icon:e,title:t,subtitle:n,status:r,primaryAction:i,actionMenu:a,layout:o=`row`}){return o===`tile`?(0,Z.jsxs)(m.Root,{bordered:!0,className:`flex h-full flex-col gap-3 transition-colors hover:border-[var(--border-hover)]`,children:[(0,Z.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[e,(0,Z.jsxs)(`div`,{className:`${St} justify-end`,children:[i,a]})]}),(0,Z.jsxs)(`div`,{className:`min-w-0 space-y-1`,children:[(0,Z.jsx)(`p`,{className:`text-title-small text-[var(--content-default)] [overflow-wrap:anywhere]`,children:t}),(0,Z.jsx)(`p`,{className:`line-clamp-2 min-h-9 text-body-small-lighter text-[var(--content-tertiary)] [overflow-wrap:anywhere]`,children:n})]})]}):(0,Z.jsx)(m.Root,{children:(0,Z.jsxs)(m.Body,{padding:`md`,className:`grid grid-cols-[2rem_minmax(6rem,1fr)_minmax(0,auto)] items-start gap-x-3`,children:[e,(0,Z.jsxs)(`div`,{className:`min-w-0 space-y-1`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(`p`,{className:`text-title-small text-[var(--content-default)] [overflow-wrap:anywhere]`,children:t}),r]}),n?(0,Z.jsx)(`p`,{className:`line-clamp-2 text-body-medium-lighter text-[var(--content-tertiary)] [overflow-wrap:anywhere]`,children:n}):null]}),(0,Z.jsxs)(`div`,{className:`${St} col-start-3 row-start-1 justify-end`,children:[i,a]})]})})}function wt({plan:e,title:t,description:n}){return(0,Z.jsx)(S.Header,{children:(0,Z.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Z.jsx)(s,{providerKey:e.iconKey,displayName:e.name,logoUrl:e.logoUrl,size:40}),(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-col`,children:[(0,Z.jsx)(S.Title,{className:`[&>span]:whitespace-normal`,children:t}),(0,Z.jsx)(S.Description,{children:n})]})]})})}function Tt({plan:e,attempt:t,focusMethodId:n,callbackUrl:r,callbackCopied:i=!1,toolsByConnectionId:a,ownOAuthContent:o,tenantHost:s,onConnect:c,onLogin:l,onCancelAttempt:u,onRetryAttempt:d,onReconnect:f,onDisconnect:p,onOpenTools:m,onCopyCallbackUrl:h,onOpenSetupGuide:g,onClose:_}){let{t:v}=K(`settings`),y=Ye(e.name),b=yt(e),x=bt(e),[C,w]=(0,X.useState)(()=>n?{kind:`connect`,methodId:n}:x.length>0?{kind:`connections`}:{kind:`connect`,methodId:e.primary.id}),[T,E]=(0,X.useState)(!1),[D,O]=(0,X.useState)(null);function k(t){return t.kind===`connect`?t:x.length===0?{kind:`connect`,methodId:e.primary.id}:t.kind===`tools`&&!x.some(e=>e.id===t.connectionId)?{kind:`connections`}:t}let A=k(C);function j(e){switch(e.kind){case`mcp-oauth`:case`mcp-manual`:return v(`integrationConnect.tagMcp`);case`managed-oauth`:return v(`integrationConnect.tagVellum`);case`own-oauth`:return v(`integrationConnect.tagOwnApp`)}}function M(t){return t.label?t.label:Q(t.methodKind)?v(`integrationConnect.connectionMcpLabel`,{name:e.name}):v(`integrationConnect.connectionAccountLabel`,{name:e.name})}function N(e,t){return Xe(e,y,t)}function P(e){E(!1),w({kind:`connect`,methodId:e.id})}function ee(){if(x.length>0){w({kind:`connections`});return}w({kind:`connect`,methodId:e.primary.id})}let L=A.kind===`tools`?x.find(e=>e.id===A.connectionId):void 0,R=A.kind===`connect`?b.find(e=>e.id===A.methodId)??e.primary:e.primary;function te(e){let t=e.setupGuideUrl;return t?(0,Z.jsx)(F,{variant:`ghost`,className:`mr-auto min-h-11`,leftIcon:(0,Z.jsx)(Ae,{}),onClick:()=>g(t),children:v(`integrationConnect.setupGuide`)}):null}return(0,Z.jsxs)(S.Root,{open:!0,onOpenChange:e=>{e||_()},children:[(0,Z.jsx)(S.Content,{size:`md`,children:A.kind===`connect`?(0,Z.jsx)(Et,{plan:e,method:R,setupGuide:te(R),methods:b,attempt:t,callbackUrl:r,callbackCopied:i,ownOAuthContent:o,tenantHost:s,acknowledged:T,hasConnections:x.length>0,methodItems:N,onAcknowledge:E,onPickMethod:P,onBack:ee,onConnect:c,onLogin:l,onCancelAttempt:u,onRetryAttempt:d,onCopyCallbackUrl:h,onClose:_}):A.kind===`tools`?(0,Z.jsx)(Mt,{plan:e,connection:L,title:L?M(L):e.name,tools:a?.[A.connectionId],onBack:()=>w({kind:`connections`}),onClose:_}):(0,Z.jsx)(At,{plan:e,methods:b,connections:x,connectionTitle:M,methodTag:j,methodItems:N,onPickMethod:P,onOpenTools:e=>{m?.(e),w({kind:`tools`,connectionId:e.id})},onReconnect:e=>{f(e),w({kind:`connect`,methodId:e.methodId})},onRequestDisconnect:O,onClose:_})}),(0,Z.jsx)(I,{open:D!==null,destructive:!0,title:v(`integrationConnect.removeTitle`,{label:D?M(D):``}),message:v(`integrationConnect.removeMessage`),confirmLabel:v(`integrationConnect.remove`),cancelLabel:v(`integrationConnect.cancel`),onConfirm:()=>{D&&p(D),O(null)},onCancel:()=>O(null)})]})}function Et({plan:e,method:t,methods:n,attempt:r,callbackUrl:i,callbackCopied:a,ownOAuthContent:s,tenantHost:c,acknowledged:l,hasConnections:u,setupGuide:d,methodItems:f,onAcknowledge:p,onPickMethod:m,onBack:h,onConnect:g,onLogin:_,onCancelAttempt:y,onRetryAttempt:b,onCopyCallbackUrl:x,onClose:C}){let{t:w}=K(`settings`),T=t.kind===`managed-oauth`?c:null,E=k(T),D=r?.methodId===t.id?r:null,O=D!==null&&D.phase!==`error`,A=t.availability===`login-required`,j=t.kind===`mcp-manual`&&i!==void 0&&(!l||i.status!==`ready`),M=t.id!==e.primary.id||u,P=n.filter(e=>e.id!==t.id);return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(wt,{plan:e,title:w(`integrationConnect.connectTitle`,{name:e.name}),description:e.description??w(`integrationConnect.connectDescription`,{name:e.name})}),(0,Z.jsxs)(S.Body,{className:`space-y-4`,children:[M?(0,Z.jsx)(F,{variant:`ghost`,leftIcon:(0,Z.jsx)(ze,{}),onClick:h,children:w(`integrationConnect.back`)}):null,A?(0,Z.jsx)(o,{tone:`info`,children:w(`integrationConnect.loginRequired`,{name:e.name})}):null,D?(0,Z.jsx)(Dt,{name:e.name,attempt:D,onCancel:y,onRetry:b}):null,T?(0,Z.jsx)(v,{label:T.label,type:`text`,value:E.value,onChange:e=>E.setValue(e.target.value),placeholder:T.placeholder,"aria-invalid":E.showsInvalid||void 0,helperText:E.showsInvalid?w(`integrationConnect.tenantHostInvalid`,{label:T.label,placeholder:T.placeholder}):void 0,disabled:O,autoComplete:`off`,autoCapitalize:`none`,spellCheck:!1,fullWidth:!0}):null,t.kind===`mcp-manual`?(0,Z.jsx)(Ot,{instructions:t.instructions,name:e.name,callbackUrl:i,callbackCopied:a,acknowledged:l,onAcknowledge:p,onCopyCallbackUrl:x}):t.kind===`own-oauth`?s:(0,Z.jsx)(`p`,{className:`text-body-medium-default text-[var(--content-secondary)]`,children:t.instructions??w(`integrationConnect.browserHint`,{name:e.name})})]}),(0,Z.jsxs)(S.Footer,{children:[d,(0,Z.jsx)(F,{variant:`ghost`,className:`min-h-11`,onClick:C,children:w(`integrationConnect.cancel`)}),t.kind===`own-oauth`?null:(0,Z.jsx)(N,{className:`min-h-11`,disabled:O||j||!E.valid,menuDisabled:O,leftIcon:O?(0,Z.jsx)(ke,{className:`animate-spin`}):null,menuTitle:w(`integrationConnect.otherWays`),menuTriggerLabel:w(`connectMethod.otherWaysLabel`,{name:e.name}),menuItems:f(P,m),onClick:()=>A?_():g(t,{acknowledged:l,tenantHost:E.normalized}),children:w(A?`integrationConnect.loginToConnect`:`integrationConnect.connect`)})]})]})}function Dt({name:e,attempt:t,onCancel:n,onRetry:r}){let{t:i}=K(`settings`);if(t.phase===`error`)return(0,Z.jsx)(o,{tone:`error`,actions:(0,Z.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Z.jsx)(F,{variant:`outlined`,onClick:r,children:i(`integrationConnect.retry`)}),(0,Z.jsx)(F,{variant:`ghost`,onClick:n,children:t.canCancel?i(`integrationConnect.stopWaiting`):i(`integrationConnect.cancel`)})]}),children:(0,Z.jsx)(`p`,{children:t.error??i(`integrationConnect.attemptFailed`,{name:e})})});let a=t.phase===`starting`?i(`integrationConnect.attemptStarting`,{name:e}):t.phase===`connecting`?i(`integrationConnect.attemptConnecting`,{name:e}):i(`integrationConnect.attemptWaiting`,{name:e});return(0,Z.jsx)(o,{tone:`info`,icon:(0,Z.jsx)(ke,{className:`h-4 w-4 animate-spin`,"aria-hidden":`true`}),actions:t.canCancel?(0,Z.jsx)(F,{variant:`ghost`,onClick:n,children:i(`integrationConnect.stopWaiting`)}):void 0,children:a})}function Ot({instructions:e,name:t,callbackUrl:n,callbackCopied:r,acknowledged:i,onAcknowledge:a,onCopyCallbackUrl:o}){let{t:s}=K(`settings`),c=n?.status===`ready`?n.url:void 0,l=e?(0,Z.jsx)(`p`,{className:`text-body-medium-default text-[var(--content-secondary)]`,children:e}):null;return n?(0,Z.jsxs)(Z.Fragment,{children:[l,(0,Z.jsxs)(`ol`,{className:`space-y-4`,children:[(0,Z.jsxs)(kt,{index:1,children:[(0,Z.jsx)(`p`,{className:`text-body-medium-default`,children:s(`integrationConnect.manualStep1`)}),c?(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 rounded-md border border-[var(--border-base)] bg-[var(--surface-base)] px-3 py-2`,children:[(0,Z.jsx)(`code`,{className:`min-w-0 flex-1 font-mono text-body-small-default [overflow-wrap:anywhere]`,children:c}),o?(0,Z.jsx)(F,{variant:`outlined`,size:`compact`,leftIcon:r?(0,Z.jsx)(Y,{}):(0,Z.jsx)(Ie,{}),onClick:()=>o(c),children:s(r?`integrationConnect.copied`:`integrationConnect.copy`)}):null]}):(0,Z.jsx)(`p`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:n?.status===`error`?s(`integrationConnect.callbackError`):s(`integrationConnect.callbackLoading`)})]}),(0,Z.jsx)(kt,{index:2,children:(0,Z.jsx)(`p`,{className:`text-body-medium-default`,children:s(`integrationConnect.manualStep2`,{name:t})})}),(0,Z.jsx)(kt,{index:3,children:(0,Z.jsx)(g,{checked:i,onCheckedChange:e=>a(e===!0),label:s(`integrationConnect.manualStep3`)})})]})]}):l}function kt({index:e,children:t}){return(0,Z.jsxs)(`li`,{className:`flex gap-3`,children:[(0,Z.jsx)(`span`,{className:`w-3 shrink-0 text-body-medium-default text-[var(--content-tertiary)]`,children:e}),(0,Z.jsx)(`div`,{className:`min-w-0 flex-1 space-y-2`,children:t})]})}function At({plan:e,methods:t,connections:n,connectionTitle:r,methodTag:i,methodItems:a,onPickMethod:o,onOpenTools:s,onReconnect:c,onRequestDisconnect:l,onClose:u}){let{t:d}=K(`settings`),f=xt(e);function p(e){let n=t.find(t=>t.id===e.methodId);if(t.length<2||!n)return e.detail;let r=i(n);return e.detail?d(`integrationConnect.connectionSubtitle`,{method:r,detail:e.detail}):r}return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(wt,{plan:e,title:e.name,description:d(`integrationConnect.connectionsDescription`,{name:e.name})}),(0,Z.jsx)(S.Body,{children:(0,Z.jsx)(`div`,{className:`rounded-lg border border-[var(--border-base)]`,children:n.map(e=>(0,Z.jsx)(de,{title:r(e),subtitle:p(e),trailingInteractive:!0,trailing:(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2 touch-mobile:max-w-24`,children:[(0,Z.jsx)(jt,{status:e.status}),e.canReconnect?(0,Z.jsx)(F,{variant:`outlined`,size:`compact`,leftIcon:(0,Z.jsx)(Te,{}),onClick:()=>c(e),children:e.status===`pending`?d(`integrationConnect.finishConnecting`):d(`integrationConnect.reconnect`)}):null,Q(e.methodKind)?(0,Z.jsx)(F,{variant:`outlined`,className:$,iconOnly:(0,Z.jsx)(je,{}),"aria-label":d(`integrationConnect.toolsAndDetailsLabel`,{label:r(e)}),onClick:()=>s(e)}):null,(0,Z.jsx)(F,{variant:`dangerOutline`,className:$,iconOnly:(0,Z.jsx)(we,{}),"aria-label":d(`integrationConnect.removeLabel`,{label:r(e)}),onClick:()=>l(e)})]})},e.id))})}),(0,Z.jsxs)(S.Footer,{children:[f.length>0?(0,Z.jsxs)(j.Root,{children:[(0,Z.jsx)(j.Trigger,{asChild:!0,children:(0,Z.jsx)(F,{variant:`outlined`,className:`min-h-11`,rightIcon:(0,Z.jsx)(Le,{}),children:d(`integrationConnect.connectAnother`)})}),(0,Z.jsx)(j.Content,{title:d(`integrationConnect.connectAnother`),children:a(f,o)})]}):null,(0,Z.jsx)(F,{className:`min-h-11`,onClick:u,children:d(`integrationConnect.done`)})]})]})}function jt({status:e}){let{t}=K(`settings`);switch(e){case`needs-attention`:return(0,Z.jsx)(n,{tone:`negative`,children:t(`integrationConnect.statusNeedsAttention`)});case`connecting`:return(0,Z.jsx)(n,{children:t(`integrationConnect.statusConnecting`)});case`pending`:return(0,Z.jsx)(n,{children:t(`integrationConnect.statusPending`)});case`connected`:return null}}function Mt({plan:e,connection:t,title:n,tools:r,onBack:i,onClose:a}){let{t:o}=K(`settings`),s=r?.summary;return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(wt,{plan:e,title:n,description:o(`integrationConnect.toolsAndDetails`)}),(0,Z.jsxs)(S.Body,{className:`space-y-4`,children:[(0,Z.jsx)(F,{variant:`ghost`,leftIcon:(0,Z.jsx)(ze,{}),onClick:i,children:o(`integrationConnect.back`)}),(0,Z.jsxs)(`dl`,{className:`space-y-1`,children:[(0,Z.jsx)(`dt`,{className:`text-body-small-default text-[var(--content-secondary)]`,children:o(`integrationConnect.endpoint`)}),(0,Z.jsx)(`dd`,{className:`font-mono text-body-small-default text-[var(--content-tertiary)] [overflow-wrap:anywhere]`,children:r?.endpointUrl??t?.detail??o(`integrationConnect.endpointUnknown`)})]}),r?.loading?(0,Z.jsx)(`p`,{role:`status`,className:`text-body-small-default text-[var(--content-tertiary)]`,children:o(`integrationConnect.toolsLoading`)}):r?.error?(0,Z.jsx)(`p`,{role:`alert`,className:`text-body-small-default text-[var(--content-tertiary)]`,children:o(`integrationConnect.toolsError`)}):s&&s.tools.length>0?(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[(0,Z.jsx)(`p`,{className:`text-body-small-default text-[var(--content-secondary)]`,children:o(`integrationConnect.toolsSummary`,{count:s.toolCount,tokens:s.estimatedTokens})}),(0,Z.jsx)(H.Root,{type:`multiple`,className:`rounded-lg border border-[var(--border-base)]`,children:s.tools.map(e=>(0,Z.jsxs)(H.Item,{value:e.name,className:`border-b border-[var(--border-base)] last:border-b-0`,children:[(0,Z.jsxs)(H.Trigger,{className:`justify-between gap-2 px-3 py-2.5 text-left [&[data-state=open]>svg]:rotate-180`,children:[(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-body-small-default`,children:e.name}),(0,Z.jsx)(Le,{"aria-hidden":`true`,className:`h-4 w-4 shrink-0 text-[var(--content-tertiary)] transition-transform duration-150`})]}),(0,Z.jsx)(H.Content,{children:(0,Z.jsxs)(`div`,{className:`space-y-1 px-3 pb-3`,children:[e.description?(0,Z.jsx)(`p`,{className:`whitespace-pre-wrap text-body-small-default text-[var(--content-secondary)] [overflow-wrap:anywhere]`,children:e.description}):null,(0,Z.jsx)(`p`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:o(`integrationConnect.toolTokens`,{tokens:e.estimatedTokens})})]})})]},e.name))})]}):(0,Z.jsx)(`p`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:o(`integrationConnect.toolsEmpty`)})]}),(0,Z.jsx)(S.Footer,{children:(0,Z.jsx)(F,{className:`min-h-11`,onClick:a,children:o(`integrationConnect.done`)})})]})}function Nt({providerKey:e,displayName:t,description:r,logoUrl:i,connections:a,mcpMethods:o=[],disabled:c,onConfigure:l}){let{t:u}=K(`settings`),{connectedCount:d}=it(a),{needsAttention:f,configured:p}=ot(a,o);return(0,Z.jsx)(Ct,{icon:(0,Z.jsx)(s,{providerKey:e,displayName:t,logoUrl:i,size:32}),title:t,subtitle:d>0?u(`integrationRow.connectedAccounts`,{count:d}):r,status:f?(0,Z.jsx)(n,{tone:`negative`,children:u(`integrationRow.needsAttention`)}):void 0,primaryAction:p?(0,Z.jsx)(F,{variant:`outlined`,className:$,iconOnly:(0,Z.jsx)(Pe,{}),"aria-label":u(`integrationRow.configureLabel`,{name:t}),onClick:l,disabled:c}):(0,Z.jsx)(F,{variant:`primary`,onClick:l,disabled:c,children:u(`integrationRow.connect`)})})}function Pt({plan:e,state:t,layout:n=`tile`,showAlternatives:r=!1,disabled:i=!1,onConnect:a,onLogin:o,onCancel:c,onRetry:l,onOpenSetupGuide:u}){let{t:d}=K(`settings`),f=Ye(e.name),p=se(),m=t.phase===`waiting`||t.phase===`connecting`,h=m&&!p;function g(e){if(e.availability===`login-required`){o();return}a(e)}function _(e){return Xe(e,f,g)}let v=r&&e.alternatives.length>0?(0,Z.jsx)(N,{variant:`outlined`,className:$,iconOnly:(0,Z.jsx)(Ee,{}),"aria-label":d(`integrationTile.connect`,{name:e.name}),menuTitle:d(`integrationTile.connect`,{name:e.name}),menuTriggerLabel:d(`connectMethod.otherWaysLabel`,{name:e.name}),menuItems:_(yt(e)),disabled:i,onClick:()=>g(e.primary)}):(0,Z.jsx)(F,{variant:`outlined`,className:$,iconOnly:(0,Z.jsx)(Ee,{}),"aria-label":d(`integrationTile.connect`,{name:e.name}),disabled:i,onClick:()=>g(e.primary)});return m?v=(0,Z.jsx)(zt,{name:e.name,state:t,announce:!h,onCancel:c}):t.phase===`failed`&&(v=(0,Z.jsx)(Rt,{plan:e,state:t,disabled:i,methodItems:_,onRetry:l,onOpenSetupGuide:u})),(0,Z.jsx)(Ct,{layout:n,icon:(0,Z.jsx)(s,{providerKey:e.iconKey,displayName:e.name,logoUrl:e.logoUrl,size:32}),title:e.name,subtitle:t.phase===`failed`?(0,Z.jsx)(Lt,{name:e.name,state:t}):h&&m?(0,Z.jsx)(`span`,{role:`status`,children:It(d,e.name,t)}):e.description??void 0,primaryAction:v})}var Ft=4e3;function It(e,t,n){return n.phase===`waiting`?e(`integrationTile.waiting`,{name:t}):e(`integrationTile.connecting`,{name:t})}function Lt({name:e,state:t}){let{t:n}=K(`settings`),r=t.error||n(`integrationTile.failedGeneric`,{name:e});return(0,Z.jsxs)(`span`,{role:`alert`,title:t.error||void 0,className:`font-medium text-[var(--system-negative-strong)]`,children:[(0,Z.jsx)(J,{"aria-hidden":`true`,className:`mr-1 inline size-3.5 shrink-0 align-[-0.15em]`}),r]})}function Rt({plan:e,state:t,disabled:n,methodItems:r,onRetry:i,onOpenSetupGuide:a}){let{t:o}=K(`settings`),s=Q(t.methodKind)?t.setupGuideUrl:void 0,c=xt(e).filter(e=>e.id!==t.methodId),l=[...s?[(0,Z.jsx)(j.Item,{icon:Ae,label:o(`integrationTile.setupGuide`),onSelect:()=>a(s)},`setup-guide`)]:[],...r(c)],u=o(`integrationTile.retryLabel`,{name:e.name});return l.length===0?(0,Z.jsx)(F,{variant:`dangerOutline`,className:$,iconOnly:(0,Z.jsx)(Te,{}),"aria-label":u,disabled:n,onClick:i}):(0,Z.jsx)(N,{variant:`dangerOutline`,className:$,iconOnly:(0,Z.jsx)(Te,{}),"aria-label":u,menuTitle:o(`connectMethod.otherWaysLabel`,{name:e.name}),menuTriggerLabel:o(`connectMethod.otherWaysLabel`,{name:e.name}),menuItems:l,disabled:n,onClick:i})}function zt({name:e,state:t,announce:n,onCancel:r}){let{t:i}=K(`settings`),a=se(),[o,s]=(0,X.useState)(!1),c=(0,X.useRef)(null),l=t.phase===`waiting`&&t.canCancel,u=It(i,e,t);function d(){c.current&&=(clearTimeout(c.current),null)}function f(e){d(),s(!0),e&&(c.current=setTimeout(()=>s(!1),Ft))}function p(){d(),s(!1)}(0,X.useEffect)(()=>d,[]);function m(e){return a&&e!==`touch`}let h=n?(0,Z.jsx)(`span`,{role:`status`,className:`sr-only`,children:u}):null;return l?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(F,{variant:`outlined`,className:$,iconOnly:o?(0,Z.jsx)(Fe,{}):(0,Z.jsx)(ke,{className:`animate-spin`}),"aria-label":i(`integrationTile.cancelLabel`,{name:e}),tooltip:i(`integrationTile.waitingCancel`,{name:e}),onPointerEnter:e=>{m(e.pointerType)&&f(!1)},onPointerLeave:e=>{m(e.pointerType)&&p()},onBlur:p,onClick:e=>{if(o||e.detail===0){p(),r();return}f(!0)}}),h]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(pe,{content:u,children:(0,Z.jsx)(`span`,{className:me(z({variant:`outlined`,iconOnly:!0}),$,`cursor-default hover:bg-transparent`),children:(0,Z.jsx)(ke,{"aria-hidden":`true`,className:`size-3.5 animate-spin text-[var(--content-tertiary)]`})})}),h]})}function Bt({assistantId:e,providerKey:t,providerLabel:n,tenantHost:r,restartToken:i,onReport:a}){let{connect:o,dismiss:s,status:c,errorMessage:l}=he({assistantId:e,providerKey:t,providerLabel:n}),u=(0,X.useRef)(o),d=(0,X.useRef)(r);return(0,X.useLayoutEffect)(()=>{u.current=o,d.current=r}),(0,X.useLayoutEffect)(()=>{u.current(void 0,d.current)},[i]),(0,X.useEffect)(()=>s,[s]),(0,X.useEffect)(()=>{a({status:c,errorMessage:l})},[l,a,c]),null}function Vt(e){return e.length>16?`${e.slice(0,12)}…${e.slice(-4)}`:e.length>8?`${e.slice(0,8)}…`:e}function Ht(e){try{return new Date(e).toLocaleDateString(void 0,{year:`numeric`,month:`short`,day:`numeric`})}catch{return``}}function Ut({assistantId:e,providerKey:n,displayName:r,logoUrl:i}){let{t:a}=K(`settings`),o=q(),c=G({...oe({path:{assistant_id:e},query:{provider_key:n}}),select:e=>e.apps}),l=G({...R({path:{assistant_id:e,providerKey:n}}),select:e=>e.oauth_callback_url}),u=c.data??[],d=l.data??null,f=_e({queries:u.map(t=>({...fe({path:{assistant_id:e,appId:t.id}}),select:e=>e.connections}))}),p={};u.forEach((e,t)=>{p[e.id]=f[t]?.data??[]});let h=U({path:{assistant_id:e},query:{provider_key:n}}),g=t({onSuccess:()=>{o.invalidateQueries({queryKey:h}),T(``),D(``),C(!1),W.success(a(`yourOwnOauthTab.appAddedToast`,{name:r}))},onError:e=>{W.error(e.message||a(`yourOwnOauthTab.createFailedToast`))}}),_=b({onSuccess:()=>{o.invalidateQueries({queryKey:h}),W.success(a(`yourOwnOauthTab.appDeletedToast`))},onError:e=>{W.error(e.message||a(`yourOwnOauthTab.deleteFailedToast`))}}),y=ee({onSuccess:e=>{`auth_url`in e&&(window.location.href=e.auth_url)},onError:e=>{W.error(e.message||a(`yourOwnOauthTab.connectFailedToast`))}}),x=ne(),[S,C]=(0,X.useState)(!1),[w,T]=(0,X.useState)(``),[E,D]=(0,X.useState)(``),[O,k]=(0,X.useState)(!1),[j,M]=(0,X.useState)(null),[N,P]=(0,X.useState)(null),te=g.isPending,re=_.isPending?_.variables?.path?.id??null:null,ie=y.isPending?y.variables?.path?.appId??null:null,ae=x.isPending?x.variables?.path?.id??null:null,se=()=>{let t=w.trim(),r=E.trim();!t||!r||g.mutate({path:{assistant_id:e},body:{provider_key:n,client_id:t,client_secret:r}})},ce=()=>{let t=j;M(null),t&&_.mutate({path:{assistant_id:e,id:t.id}})},le=t=>{y.mutate({path:{assistant_id:e,appId:t.id},body:{callback_transport:`gateway`,scopes:[]}})};return c.isLoading?(0,Z.jsx)(`div`,{className:`flex items-center justify-center py-10`,children:(0,Z.jsx)(ke,{className:`h-5 w-5 animate-spin text-[var(--content-disabled)]`})}):(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[u.length===0||S?(0,Z.jsx)(m.Root,{children:(0,Z.jsxs)(m.Body,{className:`flex flex-col gap-3`,children:[(0,Z.jsxs)(`div`,{className:`space-y-1`,children:[(0,Z.jsx)(`p`,{className:`text-body-medium-default text-[var(--content-default)]`,children:u.length===0?a(`yourOwnOauthTab.addOwnApp`,{name:r}):a(`yourOwnOauthTab.addAnotherApp`,{name:r})}),(0,Z.jsx)(`p`,{className:`text-body-small-lighter leading-relaxed text-[var(--content-tertiary)]`,children:a(`yourOwnOauthTab.credentialsNote`)})]}),d?(0,Z.jsxs)(`div`,{className:`space-y-1`,children:[(0,Z.jsx)(`p`,{className:`text-body-small-default text-[var(--content-secondary)]`,children:a(`yourOwnOauthTab.redirectUrl`)}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(v,{type:`text`,value:d,readOnly:!0,fullWidth:!0}),(0,Z.jsx)(F,{type:`button`,variant:`outlined`,size:`compact`,onClick:()=>{A(d,{successMessage:a(`yourOwnOauthTab.copiedToast`),errorMessage:a(`yourOwnOauthTab.copyFailedToast`),onCopied:()=>{k(!0),setTimeout(()=>k(!1),2e3)}})},"aria-label":a(O?`yourOwnOauthTab.copiedAria`:`yourOwnOauthTab.copyRedirectAria`),iconOnly:O?(0,Z.jsx)(Y,{"aria-hidden":!0}):(0,Z.jsx)(Ie,{"aria-hidden":!0})})]}),(0,Z.jsx)(`p`,{className:`text-body-small-lighter text-[var(--content-tertiary)]`,children:a(`yourOwnOauthTab.redirectHint`)})]}):null,(0,Z.jsx)(v,{label:a(`yourOwnOauthTab.clientId`),type:`text`,value:w,onChange:e=>T(e.target.value),placeholder:a(`yourOwnOauthTab.clientIdPlaceholder`),fullWidth:!0}),(0,Z.jsx)(v,{label:a(`yourOwnOauthTab.clientSecret`),type:`password`,value:E,onChange:e=>D(e.target.value),placeholder:a(`yourOwnOauthTab.clientSecretPlaceholder`),fullWidth:!0}),(0,Z.jsxs)(`div`,{className:`flex items-center justify-end gap-2 pt-1`,children:[u.length>0?(0,Z.jsx)(F,{type:`button`,variant:`outlined`,size:`compact`,onClick:()=>{C(!1),T(``),D(``)},disabled:te,children:a(`yourOwnOauthTab.cancel`)}):null,(0,Z.jsx)(F,{type:`button`,size:`compact`,onClick:se,disabled:te||!w.trim()||!E.trim(),loading:te,leftIcon:(0,Z.jsx)(Ee,{"aria-hidden":!0}),children:a(`yourOwnOauthTab.addApp`)})]})]})}):null,u.map(e=>{let t=p[e.id]??[],o=re===e.id,c=ie===e.id;return(0,Z.jsx)(m.Root,{children:(0,Z.jsxs)(m.Body,{className:`flex flex-col gap-3`,children:[(0,Z.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0 space-y-0.5`,children:[(0,Z.jsx)(`p`,{className:`truncate text-body-medium-default text-[var(--content-default)]`,children:Vt(e.client_id)}),(0,Z.jsx)(`p`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:a(`yourOwnOauthTab.addedOn`,{date:Ht(e.created_at)})})]}),(0,Z.jsx)(F,{type:`button`,variant:`dangerOutline`,size:`compact`,onClick:()=>M(e),disabled:o,"aria-label":a(`yourOwnOauthTab.deleteAppAria`,{id:Vt(e.client_id)}),loading:o,iconOnly:(0,Z.jsx)(we,{"aria-hidden":!0})})]}),t.length>0?(0,Z.jsx)(`ul`,{className:`divide-y divide-[var(--border-base)] overflow-hidden rounded-md border border-[var(--border-base)] dark:divide-[var(--border-base)] dark:border-[var(--border-base)]`,children:t.map(t=>{let o=ae===t.id,c=t.account_info??a(`yourOwnOauthTab.accountFallback`,{name:r});return(0,Z.jsxs)(`li`,{className:`flex items-center gap-3 px-3 py-2`,children:[(0,Z.jsx)(s,{providerKey:n,displayName:r,logoUrl:i,size:18}),(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-body-medium-lighter text-[var(--content-default)]`,children:c}),(0,Z.jsx)(F,{type:`button`,variant:`dangerOutline`,size:`compact`,onClick:()=>P({appId:e.id,connection:t}),disabled:o,"aria-label":a(`yourOwnOauthTab.disconnectAria`,{account:c}),loading:o,iconOnly:(0,Z.jsx)(we,{"aria-hidden":!0})})]},t.id)})}):null,(0,Z.jsx)(F,{type:`button`,size:`compact`,onClick:()=>le(e),disabled:c,className:`w-full`,loading:c,leftIcon:(0,Z.jsx)(Ae,{"aria-hidden":!0}),children:a(c?`yourOwnOauthTab.waitingAuthorization`:`yourOwnOauthTab.connectAccount`)})]})},e.id)}),u.length>0&&!S?(0,Z.jsx)(F,{type:`button`,variant:`outlined`,size:`compact`,onClick:()=>C(!0),className:`w-full border-dashed`,leftIcon:(0,Z.jsx)(Ee,{"aria-hidden":!0}),children:a(`yourOwnOauthTab.addAnotherAppButton`)}):null,(0,Z.jsx)(I,{open:j!==null,title:a(`yourOwnOauthTab.deleteAppTitle`),message:j?a(`yourOwnOauthTab.deleteAppMessage`,{id:Vt(j.client_id)}):``,confirmLabel:a(`yourOwnOauthTab.delete`),destructive:!0,onConfirm:ce,onCancel:()=>M(null)}),(0,Z.jsx)(I,{open:N!==null,title:a(`yourOwnOauthTab.disconnectTitle`,{name:r}),message:N?a(`yourOwnOauthTab.disconnectMessage`,{account:N.connection.account_info??a(`yourOwnOauthTab.accountFallback`,{name:r})}):``,confirmLabel:a(`yourOwnOauthTab.disconnect`),destructive:!0,onConfirm:()=>{let t=N;P(null),t&&x.mutate({path:{assistant_id:e,id:t.connection.id}},{onSuccess:()=>{let n=L({path:{assistant_id:e,appId:t.appId}});o.invalidateQueries({queryKey:n}),o.invalidateQueries({queryKey:h}),W.success(a(`yourOwnOauthTab.disconnectedToast`,{name:r}))},onError:e=>{W.error(e.message||a(`yourOwnOauthTab.disconnectFailedToast`))}})},onCancel:()=>P(null)})]})}var Wt={phase:`idle`};function Gt({assistantId:e,mcp:t}){let{t:n}=K(`settings`),r=q(),{mutateAsync:i}=B(),[a,o]=(0,X.useState)(null),[s,l]=(0,X.useState)(null),[d,f]=(0,X.useState)(null),[p,m]=(0,X.useState)(null),[h,g]=(0,X.useState)(null),_=(0,X.useRef)(null),v=(0,X.useRef)(null),y=t.auth.attempt,b=t.auth.connect,x=t.auth.retry,S=t.auth.stopWaiting,C=t.auth.isBusy,w=t.list.refetch;(0,X.useEffect)(()=>{let e=_.current;if(e&&(_.current=null,y&&y.operationId!==e.priorOperationId)){o({itemId:e.itemId,methodId:e.methodId,methodKind:e.methodKind,setupGuideUrl:e.setupGuideUrl,operationId:y.operationId});return}a&&y?.operationId!==a.operationId&&(o(null),v.current=null)},[y,a]),(0,X.useEffect)(()=>{y?.phase===`connecting`&&(v.current=null)},[y?.phase]),(0,X.useEffect)(()=>{!s||d?.status!==`connected`||(W.success(n(`useOauthConnect.accountConnected`,{name:s.providerLabel,ns:`common`})),l(null),f(null))},[s,d,n]);let T=(0,X.useCallback)(async e=>{let t=await w();return t.isError?[]:nt(t.data?.servers??[],e)},[w]),{remove:E}=Be(e,{onRemoved:()=>{w(),g(null)},onRemoveError:(e,t)=>{u(t,{context:`integrations.connectRollback`,tags:{plugin:e}}),g(null)},announceWarnings:!1}),D=(0,X.useCallback)((t,n)=>{let a=(async()=>{await i({path:{assistant_id:e},body:{name:t}}),P(r,e,t)})();return v.current={itemId:n,pluginName:t,landed:a.then(()=>!0,()=>!1)},a},[e,i,r]),O=(0,X.useCallback)(()=>{let e=v.current;v.current=null,e&&(g(e.itemId),e.landed.then(t=>{if(!t){g(null);return}E(e.pluginName)}))},[E]),k=(0,X.useCallback)(()=>{a&&S(),l(null),f(null),O()},[S,a,O]),A=(0,X.useCallback)((e,t,n,r)=>{h!==e.itemId&&(k(),_.current={...e,priorOperationId:y?.operationId??null},b(t,r,n))},[y,b,k,h]),j=(0,X.useCallback)((e,t,n)=>{let r=n.plugin;if(!r||C)return;let i=!!r.installed;A({itemId:e.id,methodId:n.id,methodKind:n.kind,setupGuideUrl:n.setupGuideUrl},$e(r.pluginName),t.name,tt({install:i?()=>Promise.resolve():()=>D(r.pluginName,e.id),loadPluginServers:()=>T(r.pluginName)}))},[C,A,D,T]),M=(0,X.useCallback)((e,t,n,r)=>{if(e.kind!==`oauth`||C)return;let{provider:i}=e;if(!r?.tenantHost&&c(i.provider_key,i.tenant_host)){m({itemId:e.id,methodId:n.id});return}k(),l({itemId:e.id,methodId:n.id,providerKey:i.provider_key,providerLabel:t.name,tenantHost:r?.tenantHost,restartToken:0})},[C,k]),N=(0,X.useCallback)((e,t,n,r)=>{if(Q(n.kind)){j(e,t,n);return}n.kind===`managed-oauth`&&M(e,t,n,r)},[M,j]),ee=(0,X.useCallback)((e,t,n)=>{let r=yt(t).find(e=>e.id===n.methodId);if(!Q(n.methodKind)){r&&M(e,t,r);return}!n.serverId||C||A({itemId:e.id,methodId:n.methodId,methodKind:n.methodKind,setupGuideUrl:r?.setupGuideUrl},n.serverId,t.name)},[C,A,M]),F=(0,X.useCallback)((e,t,n)=>{if(n.kind===`mcp-manual`||n.kind===`own-oauth`){m({itemId:e.id,methodId:n.id});return}N(e,t,n)},[N]),I=(0,X.useCallback)(()=>{if(a){if(y?.phase!==`error`)return;_.current={itemId:a.itemId,methodId:a.methodId,methodKind:a.methodKind,setupGuideUrl:a.setupGuideUrl,priorOperationId:a.operationId},x();return}f(null),l(e=>e&&{...e,restartToken:e.restartToken+1})},[y,x,a]),L=(0,X.useCallback)((e,t)=>a?.itemId===e&&y?y.phase===`error`?{phase:`failed`,error:y.error??n(`integrationTile.failedGeneric`,{name:t}),methodId:a.methodId,methodKind:a.methodKind,setupGuideUrl:a.setupGuideUrl}:y.phase===`connecting`?{phase:`connecting`}:{phase:`waiting`,canCancel:!0}:s?.itemId===e?d?.errorMessage?{phase:`failed`,error:d.errorMessage,methodId:s.methodId,methodKind:`managed-oauth`}:{phase:`waiting`,canCancel:!0}:Wt,[y,s,d,a,n]),R=(0,X.useCallback)(e=>a?.itemId===e&&y?{methodId:a.methodId,phase:y.phase,error:y.error,canCancel:!0}:s?.itemId===e?{methodId:s.methodId,phase:d?.errorMessage?`error`:`waiting`,error:d?.errorMessage??void 0,canCancel:!0}:null,[y,s,d,a]),te=(0,X.useCallback)(e=>C&&a?.itemId!==e||s!==null&&s.itemId!==e||h===e,[C,s,a,h]),ne=(0,X.useCallback)((e,t)=>m({itemId:e,methodId:t}),[]),re=(0,X.useCallback)(()=>m(null),[]);return{start:F,run:N,reconnect:ee,cancel:k,retry:I,stateFor:L,attemptFor:R,isBusyElsewhere:te,ownsMcpAttempt:a!==null,attemptItemId:a?.itemId??s?.itemId??null,managed:s,onManagedReport:f,modal:p,openModal:ne,closeModal:re}}function Kt({assistantId:e,platformAssistantId:t,onStopAuth:n,onRemoveServer:r,onPluginRemoved:i}){let{t:a}=K(`settings`),o=q(),s=(0,X.useRef)(``),c=Be(e,{onRemoved:()=>{i(),W.success(a(`integrationConnect.removedToast`,{name:s.current}))},onRemoveError:()=>W.error(a(`integrationConnect.removeFailedToast`,{name:s.current}))}),l={path:{assistant_id:t??``}},u=y({onSuccess(e,t){W.success(a(`integrationConnect.disconnectedToast`,{name:s.current}));let n=t.path.connection_id;ce(o,l,e=>e?.filter(e=>e.id!==n)),o.invalidateQueries({queryKey:V(l)})},onError(e){W.error(E(e,void 0,a(`integrationConnect.disconnectFailedToast`,{name:s.current})))}}),d=u.mutate,f=c.remove,p=c.isRemoving||u.isPending;return(0,X.useCallback)((e,i)=>{if(!p){if(s.current=i,Q(e.methodKind)){if(n(e),e.pluginName){f(e.pluginName);return}e.serverId&&r(e.serverId);return}!e.accountId||!t||d({path:{assistant_id:t,connection_id:e.accountId}})}},[p,d,r,n,t,f])}var qt=[{value:`none`,labelKey:`mcpAddServerModal.authNone`},{value:`oauth`,labelKey:`mcpAddServerModal.authOAuth`},{value:`bearer`,labelKey:`mcpAddServerModal.authBearer`},{value:`api-key`,labelKey:`mcpAddServerModal.authApiKey`}],Jt=[{value:`sse`,labelKey:`mcpAddServerModal.transportSse`},{value:`streamable-http`,labelKey:`mcpAddServerModal.transportStreamableHttp`},{value:`stdio`,labelKey:`mcpAddServerModal.transportStdio`}];function Yt(e){return qt.map(({value:t,labelKey:n})=>({value:t,label:e(n)}))}function Xt(e){return Jt.map(({value:t,labelKey:n})=>({value:t,label:e(n)}))}function Zt({open:e,onClose:t,onAdd:n,isPending:r}){let{t:i}=K(`settings`),a=(0,X.useMemo)(()=>Yt(i),[i]),o=(0,X.useMemo)(()=>Xt(i),[i]),[s,c]=(0,X.useState)(``),[l,u]=(0,X.useState)(`sse`),[d,f]=(0,X.useState)(``),[p,m]=(0,X.useState)(``),[h,g]=(0,X.useState)(``),[_,y]=(0,X.useState)(`none`),[b,x]=(0,X.useState)(``),[C,w]=(0,X.useState)(`X-API-Key`),[T,E]=(0,X.useState)(``),D=(0,X.useCallback)(()=>{c(``),u(`sse`),f(``),m(``),g(``),y(`none`),x(``),w(`X-API-Key`),E(``)},[]),O=(0,X.useCallback)(()=>{r||(D(),t())},[r,D,t]),k=(0,X.useCallback)(()=>{let e=s.trim();if(!e)return;let t={name:e,transportType:l};if(l===`stdio`){let e=p.trim();if(!e)return;t.command=e;let n=h.trim();n&&(t.args=n.split(/\s+/))}else{let e=d.trim();if(!e)return;t.url=e,_===`bearer`&&b.trim()?t.headers={Authorization:`Bearer ${b.trim()}`}:_===`api-key`&&C.trim()&&T.trim()?t.headers={[C.trim()]:T.trim()}:_===`oauth`&&(t.autoAuth=!0)}n(t)},[s,l,d,p,h,_,b,C,T,n]),A=l===`stdio`,j=s.trim()&&(A?p.trim():d.trim());return(0,Z.jsx)(S.Root,{open:e,onOpenChange:e=>{e||O()},children:(0,Z.jsxs)(S.Content,{size:`md`,children:[(0,Z.jsxs)(S.Header,{icon:We,children:[(0,Z.jsx)(S.Title,{children:i(`mcpAddServerModal.title`)}),(0,Z.jsx)(S.Description,{children:i(`mcpAddServerModal.description`)})]}),(0,Z.jsx)(S.Body,{children:(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[(0,Z.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Z.jsx)(`label`,{className:`text-body-small-default text-[var(--content-secondary)]`,htmlFor:`mcp-name`,children:i(`mcpAddServerModal.serverNameLabel`)}),(0,Z.jsx)(v,{id:`mcp-name`,type:`text`,value:s,onChange:e=>c(e.target.value),placeholder:i(`mcpAddServerModal.namePlaceholder`),fullWidth:!0,autoFocus:!0})]}),(0,Z.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Z.jsx)(`label`,{className:`text-body-small-default text-[var(--content-secondary)]`,htmlFor:`mcp-transport`,children:i(`mcpAddServerModal.transportLabel`)}),(0,Z.jsx)(`select`,{id:`mcp-transport`,value:l,onChange:e=>u(e.target.value),className:`w-full rounded-md border border-[var(--border-element)] bg-[var(--surface-lift)] px-3 py-1.5 text-body-medium-default text-[var(--content-default)] outline-none focus:ring-2 focus:ring-[var(--ring)]`,children:o.map(e=>(0,Z.jsx)(`option`,{value:e.value,children:e.label},e.value))})]}),A?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Z.jsx)(`label`,{className:`text-body-small-default text-[var(--content-secondary)]`,htmlFor:`mcp-command`,children:i(`mcpAddServerModal.commandLabel`)}),(0,Z.jsx)(v,{id:`mcp-command`,type:`text`,value:p,onChange:e=>m(e.target.value),placeholder:i(`mcpAddServerModal.commandPlaceholder`),fullWidth:!0})]}),(0,Z.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Z.jsx)(`label`,{className:`text-body-small-default text-[var(--content-secondary)]`,htmlFor:`mcp-args`,children:i(`mcpAddServerModal.argsLabel`)}),(0,Z.jsx)(v,{id:`mcp-args`,type:`text`,value:h,onChange:e=>g(e.target.value),placeholder:i(`mcpAddServerModal.argsPlaceholder`),fullWidth:!0})]})]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Z.jsx)(`label`,{className:`text-body-small-default text-[var(--content-secondary)]`,htmlFor:`mcp-url`,children:i(`mcpAddServerModal.serverUrlLabel`)}),(0,Z.jsx)(v,{id:`mcp-url`,type:`url`,value:d,onChange:e=>f(e.target.value),placeholder:i(`mcpAddServerModal.urlPlaceholder`),fullWidth:!0})]}),(0,Z.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Z.jsx)(`label`,{className:`text-body-small-default text-[var(--content-secondary)]`,htmlFor:`mcp-auth`,children:i(`mcpAddServerModal.authenticationLabel`)}),(0,Z.jsx)(`select`,{id:`mcp-auth`,value:_,onChange:e=>y(e.target.value),className:`w-full rounded-md border border-[var(--border-element)] bg-[var(--surface-lift)] px-3 py-1.5 text-body-medium-default text-[var(--content-default)] outline-none focus:ring-2 focus:ring-[var(--ring)]`,children:a.map(e=>(0,Z.jsx)(`option`,{value:e.value,children:e.label},e.value))})]}),_===`oauth`?(0,Z.jsx)(`p`,{className:`rounded-md border border-[var(--border-element)] bg-[var(--surface-base)] px-3 py-2 text-body-small-lighter text-[var(--content-tertiary)]`,children:i(`mcpAddServerModal.oauthHint`)}):null,_===`bearer`?(0,Z.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Z.jsx)(`label`,{className:`text-body-small-default text-[var(--content-secondary)]`,htmlFor:`mcp-bearer`,children:i(`mcpAddServerModal.bearerTokenLabel`)}),(0,Z.jsx)(v,{id:`mcp-bearer`,type:`password`,value:b,onChange:e=>x(e.target.value),placeholder:i(`mcpAddServerModal.bearerPlaceholder`),fullWidth:!0})]}):null,_===`api-key`?(0,Z.jsxs)(`div`,{className:`flex gap-3`,children:[(0,Z.jsxs)(`div`,{className:`flex-1 space-y-1.5`,children:[(0,Z.jsx)(`label`,{className:`text-body-small-default text-[var(--content-secondary)]`,htmlFor:`mcp-apikey-header`,children:i(`mcpAddServerModal.headerNameLabel`)}),(0,Z.jsx)(v,{id:`mcp-apikey-header`,type:`text`,value:C,onChange:e=>w(e.target.value),placeholder:i(`mcpAddServerModal.apiKeyHeaderPlaceholder`),fullWidth:!0})]}),(0,Z.jsxs)(`div`,{className:`flex-1 space-y-1.5`,children:[(0,Z.jsx)(`label`,{className:`text-body-small-default text-[var(--content-secondary)]`,htmlFor:`mcp-apikey-value`,children:i(`mcpAddServerModal.apiKeyLabel`)}),(0,Z.jsx)(v,{id:`mcp-apikey-value`,type:`password`,value:T,onChange:e=>E(e.target.value),placeholder:i(`mcpAddServerModal.apiKeyPlaceholder`),fullWidth:!0})]})]}):null]})]})}),(0,Z.jsxs)(S.Footer,{children:[(0,Z.jsx)(F,{variant:`ghost`,onClick:O,disabled:r,children:i(`mcpAddServerModal.cancel`)}),(0,Z.jsx)(F,{variant:`primary`,onClick:k,disabled:!j||r,children:i(r?`mcpAddServerModal.adding`:`mcpAddServerModal.addServer`)})]})]})})}var Qt=[`none`,`bearer`,`api-key`];function $t(e,t){switch(e){case`none`:return t(`mcpServerDetailModal.authNone`);case`bearer`:return t(`mcpServerDetailModal.authBearerToken`);case`api-key`:return t(`mcpServerDetailModal.authApiKey`)}}function en({server:e,toolsSummary:t,toolsLoading:n=!1,toolsError:r=!1,readOnly:i=!1,onClose:a,onSave:o,isPending:s}){let{t:c}=K(`settings`),[l,u]=(0,X.useState)(`none`),[d,f]=(0,X.useState)(``),[p,m]=(0,X.useState)(`X-API-Key`),[h,g]=(0,X.useState)(``);(0,X.useEffect)(()=>{e&&(u(e.authType),f(``),m(e.authHeaderName??`X-API-Key`),g(``))},[e]);let _=(0,X.useCallback)(()=>{if(!e||i)return;let t=l!==e.authType,n=l===`bearer`&&d.trim()!==``,r=l===`api-key`&&p.trim()!==``&&h.trim()!==``,a=t||n||r,s;s=a?l===`none`?null:l===`bearer`&&d.trim()?{Authorization:`Bearer ${d.trim()}`}:l===`api-key`&&p.trim()&&h.trim()?{[p.trim()]:h.trim()}:void 0:void 0,o(e.id,{name:e.id,...s===void 0?{}:{headers:s}})},[e,l,d,p,h,o,i]),y=(0,X.useCallback)(()=>{s||a()},[s,a]);return e?(0,Z.jsx)(S.Root,{open:!!e,onOpenChange:e=>{e||y()},children:(0,Z.jsxs)(S.Content,{size:`lg`,children:[(0,Z.jsxs)(S.Header,{icon:We,children:[(0,Z.jsx)(S.Title,{children:e.id}),(0,Z.jsx)(S.Description,{children:c(`mcpServerDetailModal.description`,{transport:e.transport.type,status:e.status})})]}),(0,Z.jsx)(S.Body,{children:(0,Z.jsxs)(`div`,{className:`space-y-5`,children:[!i&&e.transport.type!==`stdio`?(0,Z.jsxs)(Z.Fragment,{children:[e.hasOAuth?(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 rounded-md border border-[var(--border-element)] bg-[var(--surface-base)] px-3 py-2`,children:[(0,Z.jsx)(`span`,{className:`text-body-small-default text-[var(--content-secondary)]`,children:c(`mcpServerDetailModal.authentication`)}),(0,Z.jsx)(`span`,{className:`rounded-full bg-[var(--surface-lift)] px-2 py-0.5 text-label-small-default text-[var(--content-default)]`,children:c(`mcpServerDetailModal.oauthBadge`)}),(0,Z.jsx)(`span`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:c(`mcpServerDetailModal.oauthManagedHint`)})]}):null,e.hasOAuth?null:(0,Z.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Z.jsx)(`label`,{className:`text-body-small-default text-[var(--content-secondary)]`,htmlFor:`mcp-detail-auth`,children:c(`mcpServerDetailModal.authentication`)}),(0,Z.jsx)(`select`,{id:`mcp-detail-auth`,value:l,onChange:e=>u(e.target.value),className:`w-full rounded-md border border-[var(--border-element)] bg-[var(--surface-lift)] px-3 py-1.5 text-body-medium-default text-[var(--content-default)] outline-none focus:ring-2 focus:ring-[var(--ring)]`,children:Qt.map(e=>(0,Z.jsx)(`option`,{value:e,children:$t(e,c)},e))})]}),l===`bearer`&&!e.hasOAuth?(0,Z.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Z.jsx)(`label`,{className:`text-body-small-default text-[var(--content-secondary)]`,htmlFor:`mcp-detail-bearer`,children:c(`mcpServerDetailModal.bearerToken`)}),(0,Z.jsx)(v,{id:`mcp-detail-bearer`,type:`password`,value:d,onChange:e=>f(e.target.value),placeholder:e.hasStaticAuth&&e.authType===`bearer`?c(`mcpServerDetailModal.savedBearerPlaceholder`):c(`mcpServerDetailModal.bearerTokenPlaceholder`),fullWidth:!0})]}):null,l===`api-key`&&!e.hasOAuth?(0,Z.jsxs)(`div`,{className:`flex gap-3`,children:[(0,Z.jsxs)(`div`,{className:`flex-1 space-y-1.5`,children:[(0,Z.jsx)(`label`,{className:`text-body-small-default text-[var(--content-secondary)]`,htmlFor:`mcp-detail-apikey-header`,children:c(`mcpServerDetailModal.headerName`)}),(0,Z.jsx)(v,{id:`mcp-detail-apikey-header`,type:`text`,value:p,onChange:e=>m(e.target.value),placeholder:c(`mcpServerDetailModal.headerNamePlaceholder`),fullWidth:!0})]}),(0,Z.jsxs)(`div`,{className:`flex-1 space-y-1.5`,children:[(0,Z.jsx)(`label`,{className:`text-body-small-default text-[var(--content-secondary)]`,htmlFor:`mcp-detail-apikey-value`,children:c(`mcpServerDetailModal.apiKey`)}),(0,Z.jsx)(v,{id:`mcp-detail-apikey-value`,type:`password`,value:h,onChange:e=>g(e.target.value),placeholder:e.hasStaticAuth&&e.authType===`api-key`?c(`mcpServerDetailModal.savedApiCredentialPlaceholder`):c(`mcpServerDetailModal.apiKeyPlaceholder`),fullWidth:!0})]})]}):null]}):null,e.transport.url||e.transport.command?(0,Z.jsxs)(`dl`,{className:`space-y-1 text-body-small-default`,children:[(0,Z.jsx)(`dt`,{className:`text-[var(--content-secondary)]`,children:e.transport.type===`stdio`?c(`mcpServerDetailModal.command`):c(`mcpServerDetailModal.endpoint`)}),(0,Z.jsx)(`dd`,{className:`text-[var(--content-tertiary)] [overflow-wrap:anywhere]`,children:e.transport.url??e.transport.command})]}):null,(0,Z.jsxs)(`section`,{className:`space-y-2`,children:[(0,Z.jsx)(`h3`,{className:`text-body-medium-default text-[var(--content-default)]`,children:c(`mcpServerDetailModal.toolsHeading`)}),n?(0,Z.jsx)(`p`,{role:`status`,className:`text-body-small-default text-[var(--content-tertiary)]`,children:c(`mcpServerDetailModal.toolsLoading`)}):r?(0,Z.jsx)(`p`,{role:`alert`,className:`text-body-small-default text-[var(--content-tertiary)]`,children:c(`mcpServerDetailModal.toolsError`)}):t&&t.tools.length>0?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`p`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:c(`mcpServerDetailModal.tokenOverhead`,{count:t.estimatedTokens.toLocaleString()})}),(0,Z.jsx)(`ul`,{className:`divide-y divide-[var(--border-base)] rounded-lg border border-[var(--border-base)]`,children:t.tools.map(e=>(0,Z.jsxs)(`li`,{className:`space-y-1 px-3 py-3`,children:[(0,Z.jsx)(`p`,{className:`text-body-small-default text-[var(--content-default)] [overflow-wrap:anywhere]`,children:e.name}),e.description?(0,Z.jsx)(`p`,{className:`whitespace-pre-wrap text-body-small-default text-[var(--content-secondary)] [overflow-wrap:anywhere]`,children:e.description}):null,(0,Z.jsx)(`p`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:c(`mcpServerDetailModal.toolEstimatedTokens`,{count:e.estimatedTokens.toLocaleString()})})]},e.name))})]}):(0,Z.jsx)(`p`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:c(`mcpServerDetailModal.toolsEmpty`)})]})]})}),(0,Z.jsxs)(S.Footer,{children:[(0,Z.jsx)(F,{variant:i?`primary`:`ghost`,onClick:y,disabled:s,children:c(i?`mcpServerDetailModal.close`:`mcpServerDetailModal.cancel`)}),i?null:(0,Z.jsx)(F,{variant:`primary`,onClick:_,disabled:s,children:c(s?`mcpServerDetailModal.saving`:`mcpServerDetailModal.save`)})]})]})}):null}function tn({connections:e,allowAdd:t,attemptReportedElsewhere:n=!1}){let{t:r}=K(`settings`),{auth:i,add:a,save:s,remove:c,details:l,configureServer:u}=e;return(0,Z.jsxs)(Z.Fragment,{children:[i.attempt&&!n?(0,Z.jsx)(o,{tone:i.attempt.error?`warning`:`info`,children:(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[(0,Z.jsx)(`p`,{className:`[overflow-wrap:anywhere]`,children:i.attempt.error??(i.attempt.phase===`connecting`?r(`mcpConnect.waitingForRuntime`,{name:i.attempt.displayName}):r(`mcpConnect.waitingForAuthorization`,{name:i.attempt.displayName}))}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[i.attempt.phase===`error`?(0,Z.jsx)(F,{variant:`outlined`,onClick:i.retry,children:r(`mcpConnect.retry`)}):null,(0,Z.jsx)(F,{variant:`ghost`,onClick:i.stopWaiting,children:r(`mcpConnect.stopWaiting`)})]})]})}):null,t?(0,Z.jsx)(Zt,{open:e.addOpen,onClose:()=>e.setAddOpen(!1),onAdd:e.addCustom,isPending:a.isPending}):null,(0,Z.jsx)(en,{server:u,readOnly:u?.source===`plugin`,toolsSummary:l.data?.servers.find(e=>e.serverId===u?.id),toolsLoading:l.isFetching,toolsError:l.isError,onClose:()=>e.setConfigureServerId(null),onSave:(e,t)=>s.mutate(t),isPending:s.isPending}),(0,Z.jsx)(I,{open:e.removeServerId!==null,title:r(`mcpPage.removeDialogTitle`),message:e.removeServerId?r(`mcpPage.removeDialogMessage`,{serverId:e.removeServerId}):``,confirmLabel:r(`mcpPage.removeDialogConfirm`),destructive:!0,isPending:c.isPending,onConfirm:()=>{e.removeServerId&&c.mutate(e.removeServerId)},onCancel:()=>e.setRemoveServerId(null)})]})}function nn(e,t){let n=new Map(t.map(e=>[e.name,e]));return e.flatMap(e=>{let t=e.integration;if(t?.kind!==`mcp`)return[];let r=n.get(e.name);return[{pluginName:e.name,displayName:t.displayName,description:e.description??t.displayName,documentationUrl:t.documentationUrl,logo:t.logo,oauthProvider:t.oauthProvider,category:rt(t.category)??void 0,setup:t.setup,installed:r?{icon:r.icon,hasIcon:r.hasIcon,iconVersion:r.iconVersion}:void 0}]})}function rn(){return(0,Z.jsx)(`span`,{"aria-hidden":`true`,className:`flex size-8 shrink-0 items-center justify-center rounded-md bg-[var(--surface-base)] text-[var(--content-secondary)]`,children:(0,Z.jsx)(De,{size:20})})}function an({server:e,onRemove:t,onConfigure:r,onAuthenticate:i,onManagePlugin:a,isAuthenticating:o,connectDisabled:s=!1}){let{t:c}=K(`settings`),l=e.source===`plugin`,u=!l&&e.status===`needs-auth`&&e.transport.type!==`stdio`,d=!l&&!o&&!u,f=l?c(`mcpServerCard.managePlugin`):o?c(`mcpServerCard.connecting`):e.hasOAuth?c(`mcpServerCard.reconnect`):c(`mcpServerCard.finishConnecting`);return(0,Z.jsx)(Ct,{icon:(0,Z.jsx)(rn,{}),title:e.id,subtitle:l?e.pluginName:lt(e),status:e.status===`connected`?void 0:(0,Z.jsx)(n,{tone:`negative`,children:c(`mcpServerCard.statusNeedsAttention`)}),primaryAction:d?(0,Z.jsx)(F,{variant:`outlined`,className:$,iconOnly:(0,Z.jsx)(Pe,{}),"aria-label":c(`mcpServerCard.configureLabel`,{serverId:e.id}),onClick:()=>r(e.id)}):(0,Z.jsx)(F,{variant:u?`primary`:`outlined`,loading:o,onClick:()=>{l?a(e.pluginName):u&&i(e.id)},disabled:o||u&&s,children:f}),actionMenu:(0,Z.jsxs)(j.Root,{children:[(0,Z.jsx)(j.Trigger,{asChild:!0,children:(0,Z.jsx)(F,{variant:`ghost`,iconOnly:(0,Z.jsx)(Ce,{}),className:$,"aria-label":c(`mcpServerCard.moreActions`,{serverId:e.id})})}),(0,Z.jsxs)(j.Content,{title:e.id,showTitle:!0,closeLabel:c(`mcpServerCard.actionsSheetClose`),align:`end`,children:[u||l?(0,Z.jsx)(j.Item,{icon:Pe,label:c(l?`mcpServerCard.viewDetails`:`mcpServerCard.configure`),onSelect:()=>r(e.id)}):null,l?null:(0,Z.jsx)(j.Item,{icon:we,label:c(`mcpServerCard.removeServer`),tone:`destructive`,onSelect:()=>t(e.id)})]})]})})}function on({assistantId:e,definition:t}){let n=He(e,t.pluginName,t.installed?.hasIcon,t.installed?.iconVersion);return(0,Z.jsx)(Ue,{external:!0,icon:t.installed?.icon,iconSrc:n,iconUrl:ft(t)??void 0,size:`md`})}function sn({assistantId:e,method:t,disabled:r,onOpen:i}){let{t:a}=K(`settings`),o=ot([],[t]);return(0,Z.jsx)(Ct,{icon:(0,Z.jsx)(on,{assistantId:e,definition:t.definition}),title:t.definition.displayName,subtitle:t.definition.description,status:o.needsAttention?(0,Z.jsx)(n,{tone:`negative`,children:a(`integrationRow.needsAttention`)}):void 0,primaryAction:(0,Z.jsx)(F,{variant:`outlined`,className:$,iconOnly:(0,Z.jsx)(Pe,{}),"aria-label":a(`integrationRow.configureLabel`,{name:t.definition.displayName}),disabled:r,onClick:i})})}async function cn(e){let{data:t,response:n}=await l.get({url:`/v1/assistants/{assistant_id}/internal/mcp/list`,path:{assistant_id:e}});if(!n?.ok)throw Error(`Failed to fetch MCP servers: ${n?.status}`);return t}async function ln(e){let{data:t,response:n}=await l.get({url:`/v1/assistants/{assistant_id}/internal/mcp/tools-summary`,path:{assistant_id:e}});if(!n?.ok)throw Error(`Failed to fetch MCP tools summary: ${n?.status}`);return t}async function un(e,t){let{response:n}=await l.post({url:`/v1/assistants/{assistant_id}/internal/mcp/update`,path:{assistant_id:e},body:t});if(!n?.ok)throw Error(`Failed to update MCP server: ${n?.status}`)}async function dn(e,t){let{response:n}=await l.post({url:`/v1/assistants/{assistant_id}/internal/mcp/add`,path:{assistant_id:e},body:t});if(!n?.ok)throw Error(`Failed to add MCP server: ${n?.status}`)}async function fn(e,t){let{response:n}=await l.post({url:`/v1/assistants/{assistant_id}/internal/mcp/remove`,path:{assistant_id:e},body:{name:t}});if(!n?.ok)throw Error(`Failed to remove MCP server: ${n?.status}`)}async function pn(e,t){let{data:n,response:r}=await l.post({url:`/v1/assistants/{assistant_id}/internal/mcp/auth/start`,path:{assistant_id:e},body:{serverId:t}});if(!r?.ok)throw Error(`Failed to start MCP auth: ${r?.status}`);return n}async function mn(e,t){let{data:n,response:r}=await l.get({url:`/v1/assistants/{assistant_id}/internal/mcp/auth/status/${encodeURIComponent(t)}`,path:{assistant_id:e}});if(!r?.ok)throw Error(`Failed to poll MCP auth status: ${r?.status}`);return n}function hn(e,t){return e.some(e=>e.id===t&&e.status===`connected`)}function gn(e,t){return t?null:e}function _n(e){let{t}=K(`settings`),n=q(),[i,a]=(0,X.useState)(null),o=(0,X.useRef)(null),s=(0,X.useRef)(null),c=(0,X.useRef)(null),l=(0,X.useCallback)(()=>{o.current=null,c.current=null,s.current?.close(),s.current=null,a(null)},[]);(0,X.useEffect)(()=>(l(),()=>{o.current=null,c.current=null,s.current?.close(),s.current=null}),[e,l]);let d=i?.phase===`authorizing`||i?.phase===`waiting`,m=G({queryKey:f.auth(e,i?.operationId??``),queryFn:()=>mn(e,i.serverId),enabled:d,refetchInterval:d?w:!1,staleTime:0,gcTime:0,retry:1}),h=G({queryKey:f.list(e),queryFn:()=>cn(e),enabled:i?.phase===`connecting`,refetchInterval:i?.phase===`connecting`?w:!1,staleTime:0,retry:1});(0,X.useEffect)(()=>{!i||!d||o.current!==i.operationId||!m.data||(m.data.status===`complete`?(s.current?.close(),s.current=null,a({...i,phase:`connecting`}),n.invalidateQueries({queryKey:f.list(e)})):m.data.status===`error`&&a({...i,phase:`error`,error:m.data.error?.replaceAll(i.serverId,i.displayName)??t(`mcpConnect.authorizationFailed`)}))},[e,i,m.data,d,n,t]),(0,X.useEffect)(()=>{i?.phase!==`connecting`||o.current!==i.operationId||!h.data||h.isFetching||hn(h.data.servers,i.serverId)&&(l(),n.invalidateQueries({queryKey:f.details(e)}))},[e,i,n,h.data,h.isFetching,l]),(0,X.useEffect)(()=>{if(!i||i.phase===`error`)return;let e=d?gn(m.error,m.isFetching):i.phase===`connecting`?gn(h.error,h.isFetching):null;e&&(u(e,{context:`mcp.connect.poll`}),a({...i,phase:`error`,error:t(`mcpConnect.pollFailed`)}))},[i,m.error,m.isFetching,d,h.error,h.isFetching,t]),(0,X.useEffect)(()=>{if(!i||i.phase===`error`)return;let e=setTimeout(()=>{o.current===i.operationId&&(s.current?.close(),s.current=null,a(e=>e?.operationId===i.operationId?{...e,phase:`error`,error:t(`mcpConnect.timedOut`)}:e))},Math.max(0,i.startedAt+r-Date.now()));return()=>clearTimeout(e)},[i,t]);let g=(0,X.useCallback)(t=>{o.current===t&&(a(e=>e?.operationId===t&&e.phase===`authorizing`?{...e,phase:`waiting`}:e),n.invalidateQueries({queryKey:f.auth(e,t)}),n.invalidateQueries({queryKey:f.list(e)}))},[e,n]);(0,X.useEffect)(()=>{let e=s.current;if(i?.phase!==`authorizing`||!e)return;let t=setInterval(()=>{e.closed&&g(i.operationId)},500);return()=>clearInterval(t)},[i?.operationId,i?.phase,g]),(0,X.useEffect)(()=>{let e=i?.operationId,t=i?.phase;if(!(!e||t===`connecting`||t===`error`))return M(()=>g(e))},[i?.operationId,i?.phase,g]);let v=(0,X.useCallback)((n,r,l=n)=>{if(o.current&&i?.phase!==`error`)return;let d=crypto.randomUUID();o.current=d,s.current?.close(),s.current=null,c.current=r?{operationId:d,run:r}:null;let f={operationId:d,serverId:n,displayName:l,startedAt:Date.now(),phase:`starting`};a(f);let m=x()||_(),h=m?null:window.open(``,`_blank`,`width=500,height=600`);if(!m&&!h){a({...f,phase:`error`,error:t(`mcpConnect.popupBlocked`)});return}h&&(h.opener=null,s.current=h);let g=()=>o.current===d&&Date.now()<f.startedAt+3e5;(async()=>{try{let t=await r?.();if(c.current?.operationId===d&&(c.current=null),!g())return;if(t===null){h?.close(),s.current=null,o.current=null,a(null);return}let n=t?{...f,serverId:t}:f;t&&a(n);let i=await pn(e,n.serverId);if(!g())return;if(i.already_authenticated){h?.close(),s.current=null,a({...n,phase:`connecting`});return}let l=new URL(i.auth_url);if(l.protocol!==`https:`&&l.protocol!==`http:`)throw Error(`Unsupported MCP authorization URL protocol`);a({...n,phase:`authorizing`}),h?h.closed||h.location.replace(l.href):await p(l.href)}catch(e){h?.close(),g()&&(s.current=null,u(e,{context:`mcp.connect.start`}),a(e=>e?.operationId===d?{...e,phase:`error`,error:t(`mcpConnect.startFailed`)}:e))}})()},[e,i?.phase,t]);return{attempt:i,isBusy:!!(i&&i.phase!==`error`),connect:v,retry:()=>{i&&v(i.serverId,c.current?.run,i.displayName)},stopWaiting:l}}function vn(e){let{t}=K(`settings`),n=q(),r=_n(e),[i,a]=(0,X.useState)(!1),[o,s]=(0,X.useState)(null),[c,l]=(0,X.useState)(null),[d,p]=(0,X.useState)(null),m=G({queryKey:f.list(e),queryFn:()=>cn(e)}),h=m.data?.servers.find(e=>e.id===o)??null,g=G({queryKey:f.details(e),queryFn:()=>ln(e),enabled:h!==null||d!==null}),_=()=>{n.invalidateQueries({queryKey:f.list(e)}),n.invalidateQueries({queryKey:f.details(e)})},v=ge({mutationFn:t=>dn(e,t),onSuccess:()=>{_(),a(!1)},onError:e=>{u(e,{context:`mcp.add`}),W.error(t(`mcpConnect.addFailed`))}});return{list:m,details:g,auth:r,add:v,save:ge({mutationFn:t=>un(e,t),onSuccess:()=>{_(),s(null)},onError:e=>{u(e,{context:`mcp.update`}),W.error(t(`mcpConnect.saveFailed`))}}),remove:ge({mutationFn:t=>fn(e,t),onSuccess:(e,n)=>{r.attempt?.serverId===n&&r.stopWaiting(),_(),l(null),s(null),W.success(t(`mcpPage.toastRemoved`,{serverId:n}))},onError:(e,n)=>{u(e,{context:`mcp.remove`}),W.error(t(`mcpPage.toastRemoveFailed`,{serverId:n}))}}),addCustom:e=>{e.autoAuth?r.connect(e.name,async()=>{await v.mutateAsync(e)},e.name):v.mutate(e)},addOpen:i,setAddOpen:a,configureServer:h,configureServerId:o,setConfigureServerId:s,removeServerId:c,setRemoveServerId:l,toolsServerId:d,setToolsServerId:p}}var yn={productivity:`integrationsPage.categories.productivity`,communication:`integrationsPage.categories.communication`,meetings:`integrationsPage.categories.meetings`,sales:`integrationsPage.categories.sales`,marketing:`integrationsPage.categories.marketing`,finance:`integrationsPage.categories.finance`,commerce:`integrationsPage.categories.commerce`,engineering:`integrationsPage.categories.engineering`,knowledge:`integrationsPage.categories.knowledge`,recruiting:`integrationsPage.categories.recruiting`},bn=`grid gap-3 [grid-template-columns:repeat(auto-fill,minmax(min(100%,22rem),1fr))]`,xn=`grid gap-3 [grid-template-columns:repeat(auto-fill,minmax(min(100%,15rem),1fr))]`;function Sn({title:e,count:t,gridClassName:n,children:r}){return(0,Z.jsxs)(`section`,{className:`space-y-3`,children:[(0,Z.jsxs)(`h2`,{className:`flex items-center gap-2 text-title-small text-[var(--content-default)]`,children:[e,(0,Z.jsx)(`span`,{className:`text-body-medium-lighter text-[var(--content-tertiary)]`,children:t})]}),(0,Z.jsx)(`div`,{className:n,children:r})]})}function Cn(e,t){return{denied:e(`integrationsPage.oauthErrorDenied`),state_invalid:e(`integrationsPage.oauthErrorStateInvalid`),state_expired:e(`integrationsPage.oauthErrorStateExpired`),exchange_failed:e(`integrationsPage.oauthErrorExchangeFailed`),identity_failed:e(`integrationsPage.oauthErrorIdentityFailed`)}[t]}function wn({mcpAssistantId:e}){let{t}=K(`settings`),[n,r]=ve(),a=be(),s=ye(),c=T(),l=C(),f=le.use.mcpAddServer(),m=le.use.hasHydrated(),[g,_]=(0,X.useState)(null),[y,b]=(0,X.useState)(!0),[x,S]=(0,X.useState)(``),[w,E]=(0,X.useState)(null),k=n.get(`provider`),A=(0,X.useRef)(null),j=vn(e),M=Ve(e),N=Gt({assistantId:e,mcp:j});(0,X.useEffect)(()=>{let t=!0;return(async()=>{try{let n=await d(e);t&&n.ok&&_(n.data)}catch(e){u(e,{context:`integrations.getAssistant`})}finally{t&&b(!1)}})(),()=>{t=!1}},[e]);let{login:P}=re(`${s.pathname}${s.search}${s.hash}`),ee=(0,X.useCallback)(()=>void P(),[P]),I=N.closeModal,L=N.cancel,R=N.attemptItemId,ne=N.modal?.itemId??null,oe=j.setToolsServerId,se=(0,X.useCallback)(()=>{if(ne!==null&&R===ne&&L(),I(),oe(null),!n.has(`provider`))return;let e=new URLSearchParams(n);e.delete(`provider`),r(e,{replace:!0})},[L,R,I,ne,n,r,oe]),{platformAssistantId:ce,isLoading:ue,error:de}=h(g?.id,c===`full`),z=G({...ie({path:{assistant_id:g?.id??``}}),select:e=>e.providers,enabled:!!g}),B=G({...te({path:{assistant_id:ce??``}}),enabled:!!ce&&c===`full`});(0,X.useEffect)(()=>{let e=n.get(`oauth_status`);if(!e)return;let r=n.get(`oauth_provider`),o=r?r.charAt(0).toUpperCase()+r.slice(1):null;e===`connected`?W.success(o?t(`integrationsPage.accountConnectedToast`,{providerLabel:o}):t(`integrationsPage.accountConnectedToastGeneric`)):e===`error`&&W.error(Cn(t,n.get(`oauth_code`)??`unknown`)??(o?t(`integrationsPage.connectFailedToast`,{providerLabel:o}):t(`integrationsPage.connectFailedToastGeneric`))),a(i.settings.integrations,{replace:!0})},[n,a,t]);let fe=z.isError||B.isError||!!de||!y&&!g,pe=!fe&&!!z.data&&(c!==`full`||!!B.data),V=(0,X.useMemo)(()=>ut(pe?z.data??[]:[],pe?B.data??[]:[],j.list.data?.servers??[],M.installedLoaded?nn(M.catalogMatches,M.installedPlugins):[],j.list.isSuccess),[pe,z.data,B.data,j.list.data,j.list.isSuccess,M.installedLoaded,M.catalogMatches,M.installedPlugins]),H=(0,X.useMemo)(()=>{let e=new Map;for(let t of V)t.category&&e.set(t.category,(e.get(t.category)??0)+1);return Ge.flatMap(t=>{let n=e.get(t);return n?[{category:t,count:n}]:[]})},[V]),U=H.some(e=>e.category===w)?w:null,me=(0,X.useMemo)(()=>dt(V,x,U),[V,x,U]),he=(0,X.useMemo)(()=>{let e=new Map;for(let t of V){if(t.kind===`mcp`)continue;let n=vt(t,{platformGate:c,ownOAuthAvailable:!l,mcpServersLoaded:j.list.isSuccess});n&&e.set(t.id,n)}return e},[V,l,j.list.isSuccess,c]),ge=e=>he.has(e.id)&&(!e.configured||e.id===R&&N.modal?.itemId!==e.id),_e=e=>!e.configured||ge(e),q=me.filter(e=>!_e(e)),xe=me.filter(_e).sort((e,t)=>e.name.localeCompare(t.name)||e.id.localeCompare(t.id)),Se=y||z.isLoading||B.isLoading||ue||j.list.isLoading||(M.isLoading||M.catalogLoading)&&V.length===0,Ce=j.auth.isBusy||N.managed!==null,we=y||!g||c===`full`&&!ce,Te=N.ownsMcpAttempt&&R!==null&&(N.modal?.itemId===R||me.some(e=>e.id===R&&ge(e))),J=N.modal?V.find(e=>e.id===N.modal?.itemId):void 0,Y=J?he.get(J.id):void 0,De=J?.kind===`oauth`?J.provider:void 0,Oe=D(De?.provider_key??``,De?.tenant_host),Ae=N.openModal;(0,X.useEffect)(()=>{if(!k){A.current=null;return}if(k===A.current)return;let e=V.find(e=>e.kind===`oauth`&&e.provider.provider_key===k);e&&(A.current=k,Ae(e.id))},[V,Ae,k]);let je=j.toolsServerId,Me=j.list.data?.servers.find(e=>e.id===je),Ne=Y&&je?bt(Y).find(e=>e.serverId===je):void 0,Pe=Ne?{[Ne.id]:{loading:j.details.isFetching,error:j.details.isError,summary:j.details.data?.servers.find(e=>e.serverId===je),endpointUrl:Me?.transport.url}}:void 0,Fe=Kt({assistantId:e,platformAssistantId:ce,onStopAuth:e=>{let t=j.auth.attempt?.serverId;if(!t)return;let n=e.pluginName!==void 0&&(t===$e(e.pluginName)||j.list.data?.servers.find(e=>e.id===t)?.pluginName===e.pluginName);(t===e.serverId||n)&&j.auth.stopWaiting()},onRemoveServer:j.setRemoveServerId,onPluginRemoved:()=>void j.list.refetch()}),Ie=()=>{f?j.setAddOpen(!0):ae(a,{prompt:t(`mcpPage.setupPrompt`)})},Le=t=>{let n=t.kind===`mcp`?void 0:he.get(t.id);return t.kind!==`mcp`&&n&&ge(t)?(0,Z.jsx)(Pt,{plan:n,state:N.stateFor(t.id,n.name),showAlternatives:!l,disabled:N.isBusyElsewhere(t.id)||n.primary.kind===`managed-oauth`&&we,onConnect:e=>N.start(t,n,e),onLogin:ee,onCancel:N.cancel,onRetry:N.retry,onOpenSetupGuide:e=>void p(e)},t.id):t.kind===`oauth`?(0,Z.jsx)(Nt,{providerKey:t.provider.provider_key,displayName:t.name,description:t.provider.description,logoUrl:t.provider.logo_url,connections:t.connections,mcpMethods:t.methods,disabled:we||!n||N.isBusyElsewhere(t.id),onConfigure:()=>N.openModal(t.id)},t.id):t.kind===`plugin`?(0,Z.jsx)(sn,{assistantId:e,method:t.method,disabled:!n||N.isBusyElsewhere(t.id),onOpen:()=>N.openModal(t.id)},t.id):(0,Z.jsx)(an,{server:t.server,onRemove:j.setRemoveServerId,onConfigure:j.setConfigureServerId,onAuthenticate:e=>j.auth.connect(e),onManagePlugin:e=>a(e?`${i.plugins}/${encodeURIComponent(e)}`:i.plugins),isAuthenticating:j.auth.attempt?.serverId===t.server.id&&Ce,connectDisabled:Ce},t.id)};return(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[(0,Z.jsxs)(`div`,{className:`space-y-3`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(v,{value:x,onChange:e=>S(e.target.value),placeholder:t(`integrationsPage.searchPlaceholder`),"aria-label":t(`integrationsPage.searchAriaLabel`),leftIcon:(0,Z.jsx)(Re,{"aria-hidden":!0,className:`size-4`}),className:`min-h-11`,wrapperClassName:`min-w-0 basis-64 flex-1`,fullWidth:!0}),(0,Z.jsx)(F,{variant:`outlined`,className:`min-h-11 max-w-full whitespace-normal`,leftIcon:(0,Z.jsx)(Ee,{}),onClick:Ie,disabled:!m||Ce,children:t(`integrationsPage.addCustom`)})]}),H.length>0?(0,Z.jsx)(`div`,{role:`group`,"aria-label":t(`integrationsPage.categoriesLabel`),className:`flex gap-2 overflow-x-auto pb-1 [scrollbar-width:none]`,children:H.map(e=>(0,Z.jsx)(O,{selected:U===e.category,count:e.count,onClick:()=>E(U===e.category?null:e.category),children:t(yn[e.category])},e.category))}):null]}),fe?(0,Z.jsx)(o,{tone:`warning`,children:t(`integrationsPage.oauthUnavailable`)}):null,j.list.isError?(0,Z.jsx)(o,{tone:`warning`,actions:(0,Z.jsx)(F,{variant:`ghost`,onClick:()=>void j.list.refetch(),children:t(`mcpConnect.retry`)}),children:t(`integrationsPage.mcpUnavailable`)}):null,M.catalogError||M.isError?(0,Z.jsx)(o,{tone:`warning`,children:t(`integrationsPage.pluginCatalogUnavailable`)}):null,(0,Z.jsx)(tn,{connections:j,allowAdd:f,attemptReportedElsewhere:Te}),N.managed&&g?(0,Z.jsx)(Bt,{assistantId:g.id,providerKey:N.managed.providerKey,providerLabel:N.managed.providerLabel,tenantHost:N.managed.tenantHost,restartToken:N.managed.restartToken,onReport:N.onManagedReport},N.managed.providerKey):null,Se?(0,Z.jsxs)(`div`,{role:`status`,className:`flex items-center gap-2 text-body-medium-lighter text-[var(--content-tertiary)]`,children:[(0,Z.jsx)(ke,{className:`size-4 animate-spin`}),t(`integrationsPage.loading`)]}):null,q.length>0?(0,Z.jsx)(Sn,{title:t(`integrationsPage.sectionConfigured`),count:q.length,gridClassName:bn,children:q.map(Le)}):null,xe.length>0?(0,Z.jsx)(Sn,{title:t(`integrationsPage.sectionAvailable`),count:xe.length,gridClassName:xn,children:xe.map(Le)}):null,!Se&&me.length===0?(0,Z.jsx)(`p`,{className:`py-8 text-center text-body-medium-default text-[var(--content-tertiary)]`,children:x.trim()?t(`integrationsPage.emptySearchSubtitle`,{query:x.trim()}):U?t(`integrationsPage.emptyCategory`,{category:t(yn[U])}):t(`integrationsPage.empty`)}):null,N.modal&&Y&&J&&J.kind!==`mcp`?(0,Z.jsx)(Tt,{plan:Y,focusMethodId:N.modal.methodId,attempt:N.attemptFor(J.id),tenantHost:Oe,toolsByConnectionId:Pe,ownOAuthContent:g&&J.kind===`oauth`?(0,Z.jsx)(Ut,{assistantId:g.id,providerKey:J.provider.provider_key,displayName:J.name,logoUrl:J.provider.logo_url}):null,onConnect:(e,t)=>N.run(J,Y,e,t),onLogin:ee,onCancelAttempt:N.cancel,onRetryAttempt:N.retry,onReconnect:e=>N.reconnect(J,Y,e),onOpenTools:e=>j.setToolsServerId(e.serverId??null),onDisconnect:e=>Fe(e,Y.name),onOpenSetupGuide:e=>void p(e),onClose:se},J.id):null]})}function Tn(){let e=ue();return(0,Z.jsx)(X.Suspense,{children:(0,Z.jsx)(wn,{mcpAssistantId:e},e)})}export{Tn as IntegrationsPage};
@@ -1 +1 @@
1
- import{o as e}from"./rolldown-runtime-BM3Ffeng.js";import{Ao as t,CS as n,DS as r,JC as i,TS as a,au as o,aw as s,o as c,uS as l,uw as u}from"./app-D0NlDYsG.js";import{E as d}from"./vendor-CtXGFqsu.js";import{d as f,f as p,i as m,n as h,t as g,x as _}from"./react-B9IgSVeK.js";import{Ki as v,za as y}from"./icons-C0wyat6T.js";import{t as b}from"./intelligence-layout-slots-store-D6qaMstC.js";import{n as x}from"./list-detail-navigation-BwyoNgJy.js";var S=e(_(),1),C=g();function w({children:e,className:t}){return(0,C.jsx)(i,{variant:`body-medium-default`,className:u(`max-w-[50vw] truncate text-[var(--content-secondary)]`,t),children:e})}function T({ariaLabel:e,tooltip:t,to:n,onClick:r}){return(0,C.jsx)(s,{"data-mobile-top-bar-back":``,shape:`pill`,variant:`ghost`,iconOnly:(0,C.jsx)(y,{"aria-hidden":!0}),className:`max-md:bg-[var(--surface-active)]`,"aria-label":e,tooltip:t,...n==null?{onClick:r}:{asChild:!0,children:(0,C.jsx)(h,{to:n})}})}var E={schedules:`sections.schedules`,superpowers:`sections.superpowers`,plugins:`sections.superpowers`,skills:`sections.superpowers`,memory:`sections.memory`,library:`sections.library`,workspace:`sections.workspace`,contacts:`sections.contacts`,channels:`sections.channels`};function D(){let{t:e}=d(`intelligence`),i=l.use.name(),{pathname:s,state:u}=f(),g=p(),_=o(),y=t.use.setTopBarCenter(),D=t.use.setMobileTopBar(),O=b.use.headerTrailing(),k=b.use.detailIsScreen(),A=n(s),j=A?.key===`workspace`,M=A?e(E[A.key]):null,N=M??(a(s,r.personality)?e(`identitySections.personality.label`):null),P=_&&N!=null,F=P&&k&&A!=null&&!a(s,A.to)?A.to:null,I=i||e(`identityOverview.defaultAssistantName`),L=e(`intelligenceLayout.backToAriaLabel`,{name:I}),R=e(`intelligenceLayout.backToTitle`,{name:I});return(0,S.useEffect)(()=>{if(P&&N){let t=F==null?{ariaLabel:L,tooltip:R,to:r.identity}:{ariaLabel:e(`intelligenceLayout.backToAriaLabel`,{name:N}),tooltip:e(`intelligenceLayout.backToTitle`,{name:N}),onClick:()=>x(g,u,F)};y(null),D({leading:(0,C.jsx)(T,{...t}),center:j?(0,C.jsx)(`span`,{"data-slot":`workspace-page-title`,className:`flex min-w-0`,children:(0,C.jsx)(w,{className:`text-[var(--content-default)] [--text-body-medium-default-size:17px] [--text-body-medium-default-weight:600]`,children:N})}):(0,C.jsx)(w,{children:N}),trailing:O})}else D(null),y(null);return()=>{D(null),y(null)}},[L,R,F,O,j,N,g,P,D,y,u,e]),A?(0,C.jsxs)(c,{className:j?`max-md:rounded-none max-md:border-0 max-md:px-3.5 max-md:pt-0 max-md:pb-3.5`:void 0,style:j?{backgroundColor:`var(--surface-base)`}:void 0,children:[P?null:(0,C.jsxs)(`div`,{className:`mb-4 flex shrink-0 items-center gap-1.5`,children:[(0,C.jsx)(h,{to:r.identity,className:`-ml-2 flex h-8 w-8 shrink-0 cursor-pointer items-center justify-center rounded-md text-[var(--content-secondary)] transition-colors outline-none hover:bg-[var(--surface-hover)] hover:text-[var(--content-default)] focus-visible:ring-2 focus-visible:ring-[var(--ring)]`,"aria-label":L,title:R,children:(0,C.jsx)(v,{className:`h-5 w-5`,"aria-hidden":!0})}),(0,C.jsx)(`h1`,{className:`text-title-large text-[var(--content-default)]`,children:M}),O?(0,C.jsx)(`div`,{className:`ml-auto flex shrink-0 items-center`,children:O}):null]}),(0,C.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-y-auto`,children:(0,C.jsx)(m,{})})]}):(0,C.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:(0,C.jsx)(m,{})})}export{D as IntelligenceLayout};
1
+ import{o as e}from"./rolldown-runtime-BM3Ffeng.js";import{Ao as t,CS as n,DS as r,JC as i,TS as a,au as o,aw as s,o as c,uS as l,uw as u}from"./app-DbJUeBix.js";import{E as d}from"./vendor-CtXGFqsu.js";import{d as f,f as p,i as m,n as h,t as g,x as _}from"./react-B9IgSVeK.js";import{Ki as v,za as y}from"./icons-C0wyat6T.js";import{t as b}from"./intelligence-layout-slots-store-DSIw2NvD.js";import{n as x}from"./list-detail-navigation-BwyoNgJy.js";var S=e(_(),1),C=g();function w({children:e,className:t}){return(0,C.jsx)(i,{variant:`body-medium-default`,className:u(`max-w-[50vw] truncate text-[var(--content-secondary)]`,t),children:e})}function T({ariaLabel:e,tooltip:t,to:n,onClick:r}){return(0,C.jsx)(s,{"data-mobile-top-bar-back":``,shape:`pill`,variant:`ghost`,iconOnly:(0,C.jsx)(y,{"aria-hidden":!0}),className:`max-md:bg-[var(--surface-active)]`,"aria-label":e,tooltip:t,...n==null?{onClick:r}:{asChild:!0,children:(0,C.jsx)(h,{to:n})}})}var E={schedules:`sections.schedules`,superpowers:`sections.superpowers`,plugins:`sections.superpowers`,skills:`sections.superpowers`,memory:`sections.memory`,library:`sections.library`,workspace:`sections.workspace`,contacts:`sections.contacts`,channels:`sections.channels`};function D(){let{t:e}=d(`intelligence`),i=l.use.name(),{pathname:s,state:u}=f(),g=p(),_=o(),y=t.use.setTopBarCenter(),D=t.use.setMobileTopBar(),O=b.use.headerTrailing(),k=b.use.detailIsScreen(),A=n(s),j=A?.key===`workspace`,M=A?e(E[A.key]):null,N=M??(a(s,r.personality)?e(`identitySections.personality.label`):null),P=_&&N!=null,F=P&&k&&A!=null&&!a(s,A.to)?A.to:null,I=i||e(`identityOverview.defaultAssistantName`),L=e(`intelligenceLayout.backToAriaLabel`,{name:I}),R=e(`intelligenceLayout.backToTitle`,{name:I});return(0,S.useEffect)(()=>{if(P&&N){let t=F==null?{ariaLabel:L,tooltip:R,to:r.identity}:{ariaLabel:e(`intelligenceLayout.backToAriaLabel`,{name:N}),tooltip:e(`intelligenceLayout.backToTitle`,{name:N}),onClick:()=>x(g,u,F)};y(null),D({leading:(0,C.jsx)(T,{...t}),center:j?(0,C.jsx)(`span`,{"data-slot":`workspace-page-title`,className:`flex min-w-0`,children:(0,C.jsx)(w,{className:`text-[var(--content-default)] [--text-body-medium-default-size:17px] [--text-body-medium-default-weight:600]`,children:N})}):(0,C.jsx)(w,{children:N}),trailing:O})}else D(null),y(null);return()=>{D(null),y(null)}},[L,R,F,O,j,N,g,P,D,y,u,e]),A?(0,C.jsxs)(c,{className:j?`max-md:rounded-none max-md:border-0 max-md:px-3.5 max-md:pt-0 max-md:pb-3.5`:void 0,style:j?{backgroundColor:`var(--surface-base)`}:void 0,children:[P?null:(0,C.jsxs)(`div`,{className:`mb-4 flex shrink-0 items-center gap-1.5`,children:[(0,C.jsx)(h,{to:r.identity,className:`-ml-2 flex h-8 w-8 shrink-0 cursor-pointer items-center justify-center rounded-md text-[var(--content-secondary)] transition-colors outline-none hover:bg-[var(--surface-hover)] hover:text-[var(--content-default)] focus-visible:ring-2 focus-visible:ring-[var(--ring)]`,"aria-label":L,title:R,children:(0,C.jsx)(v,{className:`h-5 w-5`,"aria-hidden":!0})}),(0,C.jsx)(`h1`,{className:`text-title-large text-[var(--content-default)]`,children:M}),O?(0,C.jsx)(`div`,{className:`ml-auto flex shrink-0 items-center`,children:O}):null]}),(0,C.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-y-auto`,children:(0,C.jsx)(m,{})})]}):(0,C.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:(0,C.jsx)(m,{})})}export{D as IntelligenceLayout};
@@ -1 +1 @@
1
- import{iC as e}from"./app-D0NlDYsG.js";import{J as t}from"./vendor-CtXGFqsu.js";var n=e(t(e=>({headerTrailing:null,detailIsScreen:!1,setHeaderTrailing:t=>e({headerTrailing:t}),setDetailIsScreen:t=>e({detailIsScreen:t})})));export{n as t};
1
+ import{iC as e}from"./app-DbJUeBix.js";import{J as t}from"./vendor-CtXGFqsu.js";var n=e(t(e=>({headerTrailing:null,detailIsScreen:!1,setHeaderTrailing:t=>e({headerTrailing:t}),setDetailIsScreen:t=>e({detailIsScreen:t})})));export{n as t};
@@ -1 +1 @@
1
- import{o as e}from"./rolldown-runtime-BM3Ffeng.js";import{DS as t}from"./app-D0NlDYsG.js";import{f as n,x as r}from"./react-B9IgSVeK.js";var i=e(r(),1);function a(){let e=n();return(0,i.useEffect)(()=>{e(t.settings.keyboardShortcuts,{replace:!0})},[e]),null}export{a as KeyboardShortcutsRedirectPage};
1
+ import{o as e}from"./rolldown-runtime-BM3Ffeng.js";import{DS as t}from"./app-DbJUeBix.js";import{f as n,x as r}from"./react-B9IgSVeK.js";var i=e(r(),1);function a(){let e=n();return(0,i.useEffect)(()=>{e(t.settings.keyboardShortcuts,{replace:!0})},[e]),null}export{a as KeyboardShortcutsRedirectPage};
@@ -1,4 +1,4 @@
1
- import{Dg as e,yv as t}from"./app-D0NlDYsG.js";var n=2;function r({processing:e,sawProcessing:t,hasReply:r,stableReads:i}){return e===void 0?r&&i>=n:!e&&(r||t)}var i=e=>Math.max(0,Math.min(100,Math.round(e)));function a(e,n,r){let a=t=>i(e[t]??50),o=a(t.companionCoworker),s=a(t.executeCollaborate),c=a(t.playfulSerious),l=a(t.politeUnfiltered),u=n?.trim()||`The user`,d=r?.trim(),f=d?`Your name is ${d}. Write exactly \`- **Name:** ${d}\` in IDENTITY.md — do not rename yourself or invent a different name, even if the file currently shows a placeholder or a different name. This changes your personality, not who you are.`:"Keep your existing name exactly as it is — this changes your personality, not who you are. Do not rename yourself, and if your name is already set, carry it through verbatim (don't treat it as a placeholder to fill). Whatever the name ends up being, keep it on IDENTITY.md's `- **Name:** …` line.";return`<system-message>
1
+ import{Dg as e,yv as t}from"./app-DbJUeBix.js";var n=2;function r({processing:e,sawProcessing:t,hasReply:r,stableReads:i}){return e===void 0?r&&i>=n:!e&&(r||t)}var i=e=>Math.max(0,Math.min(100,Math.round(e)));function a(e,n,r){let a=t=>i(e[t]??50),o=a(t.companionCoworker),s=a(t.executeCollaborate),c=a(t.playfulSerious),l=a(t.politeUnfiltered),u=n?.trim()||`The user`,d=r?.trim(),f=d?`Your name is ${d}. Write exactly \`- **Name:** ${d}\` in IDENTITY.md — do not rename yourself or invent a different name, even if the file currently shows a placeholder or a different name. This changes your personality, not who you are.`:"Keep your existing name exactly as it is — this changes your personality, not who you are. Do not rename yourself, and if your name is already set, carry it through verbatim (don't treat it as a placeholder to fill). Whatever the name ends up being, keep it on IDENTITY.md's `- **Name:** …` line.";return`<system-message>
2
2
  ${u} wants to customize your personality.
3
3
  This is what they want you to be:
4
4
  Companion (0-100): ${100-o}
@@ -1 +1 @@
1
- import{o as e}from"./rolldown-runtime-BM3Ffeng.js";import{DS as t,Ir as n,Lr as r,Mv as i,au as a,iu as o,nt as s,tg as c,v as l,yr as u}from"./app-D0NlDYsG.js";import{E as d}from"./vendor-CtXGFqsu.js";import{d as f,f as p,h as m,t as h,x as g}from"./react-B9IgSVeK.js";import{Yn as _}from"./icons-C0wyat6T.js";import{t as v}from"./deploy-dialogs-Dy1YiAUx.js";import{t as y}from"./use-edge-swipe-back-kH1IWvhn.js";import{t as b}from"./app-types-BwhjauA5.js";var x=e(g(),1),S=h();function C({enabled:e}){return e?(0,S.jsx)(`div`,{"aria-hidden":!0,className:`absolute inset-y-0 left-0 z-10`,style:{width:20}}):null}function w(){let{t:e}=d(`library`),{appId:h}=m(),g=s(),w=p(),{pathname:T}=f(),E=a(),D=n.use.isDeploying(),O=(0,x.useRef)(null),[k,A]=(0,x.useState)(null),[j,M]=(0,x.useState)(null),[N,P]=(0,x.useState)(!1),F=(0,x.useRef)(null);(0,x.useEffect)(()=>{if(h)return F.current=h,A(null),M(null),i({path:{assistant_id:g,id:h},throwOnError:!0}).then(({data:e})=>{F.current===h&&(c(g,e.appId,e.html),A({assistantId:g,appId:e.appId,dirName:e.dirName,name:e.name,html:e.html,origin:e.origin}))}).catch(e=>{F.current===h&&M(e instanceof Error?e.message:`Failed to open app`)}),()=>{F.current=null}},[g,h]);let I=(0,x.useCallback)(()=>{w(t.library.root)},[w]),L=(0,x.useCallback)(e=>{w(e)},[w]);y({containerRef:O,onBack:I,enabled:E,navKey:T,prefetchHref:t.library.root});let R=l(),z=(0,x.useCallback)(()=>{k&&R(k)},[k,R]),B=(0,x.useCallback)(async()=>{if(!(!k||N)){P(!0);try{await r(g,{id:k.appId,name:k.name},{exported:e(`libraryAppCard.exported`),failed:e(`libraryAppCard.shareFailed`)})}finally{P(!1)}}},[g,k,N,e]),V=(0,x.useCallback)(()=>{k&&n.getState().deployApp(g,k.appId,k.name,k.html)},[g,k]),H=(0,x.useCallback)(e=>{o(w,{prompt:e})},[w]);return h?j?(0,S.jsxs)(`div`,{className:`flex flex-1 flex-col items-center justify-center gap-4`,children:[(0,S.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--content-tertiary)]`,children:j}),(0,S.jsx)(`button`,{type:`button`,onClick:I,className:`text-body-medium-default text-[var(--primary-base)] underline`,children:e(`libraryDetailPage.backToLibrary`)})]}):k?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsxs)(`div`,{ref:O,className:`relative flex min-h-0 flex-1 flex-col`,children:[(0,S.jsx)(C,{enabled:E}),(0,S.jsx)(u,{appId:k.appId,appName:k.name,html:k.html,assistantId:g,onClose:I,onNavigateAppRoute:L,...b(k.origin)?{}:{onEdit:z,onShare:B,isSharing:N,onDeploy:V,isDeploying:D},enableFullscreen:!0})]}),(0,S.jsx)(v,{assistantId:g,onStartConversation:H})]}):(0,S.jsx)(`div`,{className:`flex flex-1 items-center justify-center`,children:(0,S.jsx)(_,{className:`h-6 w-6 animate-spin text-[var(--content-tertiary)]`})}):null}export{w as LibraryDetailPage};
1
+ import{o as e}from"./rolldown-runtime-BM3Ffeng.js";import{DS as t,Ir as n,Lr as r,Mv as i,au as a,iu as o,nt as s,tg as c,v as l,yr as u}from"./app-DbJUeBix.js";import{E as d}from"./vendor-CtXGFqsu.js";import{d as f,f as p,h as m,t as h,x as g}from"./react-B9IgSVeK.js";import{Yn as _}from"./icons-C0wyat6T.js";import{t as v}from"./deploy-dialogs-Hu5UmFuB.js";import{t as y}from"./use-edge-swipe-back-DeHKMrh8.js";import{t as b}from"./app-types-BwhjauA5.js";var x=e(g(),1),S=h();function C({enabled:e}){return e?(0,S.jsx)(`div`,{"aria-hidden":!0,className:`absolute inset-y-0 left-0 z-10`,style:{width:20}}):null}function w(){let{t:e}=d(`library`),{appId:h}=m(),g=s(),w=p(),{pathname:T}=f(),E=a(),D=n.use.isDeploying(),O=(0,x.useRef)(null),[k,A]=(0,x.useState)(null),[j,M]=(0,x.useState)(null),[N,P]=(0,x.useState)(!1),F=(0,x.useRef)(null);(0,x.useEffect)(()=>{if(h)return F.current=h,A(null),M(null),i({path:{assistant_id:g,id:h},throwOnError:!0}).then(({data:e})=>{F.current===h&&(c(g,e.appId,e.html),A({assistantId:g,appId:e.appId,dirName:e.dirName,name:e.name,html:e.html,origin:e.origin}))}).catch(e=>{F.current===h&&M(e instanceof Error?e.message:`Failed to open app`)}),()=>{F.current=null}},[g,h]);let I=(0,x.useCallback)(()=>{w(t.library.root)},[w]),L=(0,x.useCallback)(e=>{w(e)},[w]);y({containerRef:O,onBack:I,enabled:E,navKey:T,prefetchHref:t.library.root});let R=l(),z=(0,x.useCallback)(()=>{k&&R(k)},[k,R]),B=(0,x.useCallback)(async()=>{if(!(!k||N)){P(!0);try{await r(g,{id:k.appId,name:k.name},{exported:e(`libraryAppCard.exported`),failed:e(`libraryAppCard.shareFailed`)})}finally{P(!1)}}},[g,k,N,e]),V=(0,x.useCallback)(()=>{k&&n.getState().deployApp(g,k.appId,k.name,k.html)},[g,k]),H=(0,x.useCallback)(e=>{o(w,{prompt:e})},[w]);return h?j?(0,S.jsxs)(`div`,{className:`flex flex-1 flex-col items-center justify-center gap-4`,children:[(0,S.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--content-tertiary)]`,children:j}),(0,S.jsx)(`button`,{type:`button`,onClick:I,className:`text-body-medium-default text-[var(--primary-base)] underline`,children:e(`libraryDetailPage.backToLibrary`)})]}):k?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsxs)(`div`,{ref:O,className:`relative flex min-h-0 flex-1 flex-col`,children:[(0,S.jsx)(C,{enabled:E}),(0,S.jsx)(u,{appId:k.appId,appName:k.name,html:k.html,assistantId:g,onClose:I,onNavigateAppRoute:L,...b(k.origin)?{}:{onEdit:z,onShare:B,isSharing:N,onDeploy:V,isDeploying:D},enableFullscreen:!0})]}),(0,S.jsx)(v,{assistantId:g,onStartConversation:H})]}):(0,S.jsx)(`div`,{className:`flex flex-1 items-center justify-center`,children:(0,S.jsx)(_,{className:`h-6 w-6 animate-spin text-[var(--content-tertiary)]`})}):null}export{w as LibraryDetailPage};
@@ -1 +1 @@
1
- import{o as e}from"./rolldown-runtime-BM3Ffeng.js";import{Bp as t,DS as n,IS as r,Ir as i,Nv as a,PC as o,Qi as s,Qo as c,Rp as l,Vt as u,Wg as d,XC as f,_p as p,au as m,aw as h,br as g,eg as _,go as v,gp as y,ho as b,iu as x,ka as S,l as C,ln as w,nt as T,ss as E,u as D,xC as O,xc as k,xr as A,zp as j}from"./app-D0NlDYsG.js";import{$n as M,E as N,Xn as P,nr as F}from"./vendor-CtXGFqsu.js";import{d as I,f as L,t as R,x as z}from"./react-B9IgSVeK.js";import{$r as B,A as V,At as H,Br as U,Cr as W,Ht as G,Ia as K,Ur as ee,Vt as q,ir as J,ri as te,tr as ne,vt as Y}from"./icons-C0wyat6T.js";import{t as re}from"./deploy-dialogs-Dy1YiAUx.js";import{t as ie}from"./intelligence-layout-slots-store-D6qaMstC.js";import{n as ae,r as oe,t as se}from"./use-app-delete-CyCUfXGp.js";import{t as ce}from"./app-types-BwhjauA5.js";var X=e(z(),1),Z=R();function le(e){return e===1?`1 word`:`${e} words`}function ue({document:e,onOpen:t}){return(0,Z.jsxs)(`div`,{className:`group relative flex flex-col gap-2`,children:[(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>t(e.surfaceId),className:c(`relative flex w-full cursor-pointer flex-col items-center justify-center gap-2 overflow-hidden rounded-xl border border-[var(--border-base)] bg-[var(--surface-base)]`,`aspect-[16/10]`,`outline-none focus-visible:ring-2 focus-visible:ring-[var(--ring)]`),children:[(0,Z.jsx)(U,{size:34,className:`text-[var(--content-tertiary)]`}),(0,Z.jsx)(`span`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:le(e.wordCount)})]}),(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>t(e.surfaceId),className:`flex cursor-pointer flex-col gap-0.5 rounded-sm px-0.5 text-left outline-none keyboard-focus:ring-2 keyboard-focus:ring-inset keyboard-focus:ring-[var(--ring)]`,children:[(0,Z.jsx)(`span`,{className:`truncate text-body-large-default text-[color:var(--content-emphasised)]`,children:e.title}),(0,Z.jsx)(`span`,{className:`text-body-small-default text-[color:var(--content-tertiary)]`,children:u(new Date(e.updatedAt))})]})]})}function de({onNewConversation:e}){let{t}=N(`library`);return(0,Z.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-4 px-4 py-24`,children:[(0,Z.jsx)(`div`,{className:`flex h-16 w-16 items-center justify-center rounded-xl bg-[var(--surface-base)]`,children:(0,Z.jsx)(J,{size:32,className:`text-[var(--content-tertiary)]`})}),(0,Z.jsx)(`h2`,{className:`text-title-medium text-[var(--content-default)]`,children:t(`libraryEmptyState.heading`)}),(0,Z.jsx)(`p`,{className:`max-w-md text-center text-body-medium-lighter text-[color:var(--content-tertiary)]`,children:t(`libraryEmptyState.body`)}),e?(0,Z.jsx)(h,{variant:`primary`,size:`regular`,onClick:e,children:t(`libraryEmptyState.newConversation`)}):null]})}function fe({app:e,assistantId:t,isPinned:n,onOpen:r,onPin:i,onDelete:a,onDeploy:o,justImported:s,onAnimationEnd:l}){let{t:d}=N(`library`),f=ce(e.origin),p=f?void 0:a,m=f?void 0:o,h=(0,X.useCallback)(()=>_(t,e.id,e.updatedAt),[t,e.id,e.updatedAt]),v=ae(t,e,{exported:d(`libraryAppCard.exported`),failed:d(`libraryAppCard.shareFailed`)}),[y,b]=(0,X.useState)(!1),[x,C]=(0,X.useState)(!1),T=(0,X.useCallback)(()=>C(!0),[]),{deployedUrl:E}=A(t,e.id,{enabled:x&&m!=null}),D=(0,X.useCallback)(()=>{E!=null&&g(E)},[E]);return(0,Z.jsx)(S,{trailingActions:[{id:`pin`,label:d(n?`libraryAppCard.unpin`:`libraryAppCard.pin`),icon:n?G:q,onSelect:()=>i(e)},...p?[{id:`delete`,label:d(`libraryAppCard.delete`),icon:V,variant:`destructive`,onSelect:()=>p(e)}]:[]],className:`rounded-xl`,children:(0,Z.jsxs)(`div`,{"data-reveal-row":``,className:c(`relative flex flex-col gap-2`,s&&`animate-[card-entrance_400ms_ease-out]`),onAnimationEnd:s?l:void 0,onPointerEnter:T,children:[(0,Z.jsx)(`button`,{type:`button`,onClick:()=>r(e.id),className:c(`relative w-full cursor-pointer overflow-hidden rounded-xl`,`outline-none focus-visible:ring-2 focus-visible:ring-[var(--ring)]`),children:(0,Z.jsx)(w,{name:e.name,icon:e.icon,loadHtml:h})}),(0,Z.jsx)(`div`,{"data-reveal":``,className:`absolute right-2 top-2 z-20`,children:(0,Z.jsx)(pe,{appName:e.name,isPinned:n,open:y,onOpenChange:e=>{e&&T(),b(e)},onPin:()=>i(e),onDelete:p?()=>p(e):void 0,onShare:f?void 0:v,onDeploy:m,deployedUrl:E,onCopyDeployedLink:D})}),(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>r(e.id),className:`flex cursor-pointer flex-col gap-0.5 rounded-sm px-0.5 text-left outline-none keyboard-focus:ring-2 keyboard-focus:ring-inset keyboard-focus:ring-[var(--ring)]`,children:[(0,Z.jsx)(`span`,{className:`truncate text-body-large-default text-[color:var(--content-emphasised)] max-md:text-body-medium-lighter max-md:text-[color:var(--content-secondary)]`,children:e.name}),(0,Z.jsx)(`span`,{className:`text-body-small-default text-[color:var(--content-tertiary)] max-md:hidden`,children:u(new Date(e.createdAt))})]})]})})}function pe({appName:e,isPinned:t,open:n,onOpenChange:r,onPin:i,onDelete:a,onShare:o,onDeploy:s,deployedUrl:c,onCopyDeployedLink:l}){let{t:u}=N(`library`),d=c!=null&&c!==``&&l!=null,p=u(`libraryAppCard.actionsTitle`,{appName:e});return(0,Z.jsxs)(f.Root,{open:n,onOpenChange:r,children:[(0,Z.jsx)(f.Trigger,{asChild:!0,children:(0,Z.jsx)(h,{variant:`primary`,size:`compact`,iconOnly:(0,Z.jsx)(B,{}),"aria-label":p,onClick:e=>e.stopPropagation()})}),(0,Z.jsxs)(f.Content,{title:p,children:[(0,Z.jsx)(f.Item,{icon:t?G:q,label:u(t?`libraryAppCard.unpin`:`libraryAppCard.pin`),onSelect:i}),o?(0,Z.jsx)(f.Item,{icon:K,label:u(`libraryAppCard.share`),description:u(`libraryAppCard.shareSub`),onSelect:o}):null,s&&d?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(f.Item,{icon:ne,label:u(`libraryAppCard.deployed`),description:(0,Z.jsx)(`span`,{className:`break-all`,children:c}),trailing:u(`libraryAppCard.copyLink`),onSelect:()=>l?.()}),(0,Z.jsx)(f.Item,{icon:H,label:u(`libraryAppCard.redeploy`),description:u(`libraryAppCard.redeploySub`),onSelect:s})]}):s?(0,Z.jsx)(f.Item,{icon:W,label:u(`libraryAppCard.deploy`),description:u(`libraryAppCard.deploySub`),onSelect:s}):null,a?(0,Z.jsx)(f.Item,{icon:V,label:u(`libraryAppCard.delete`),tone:`destructive`,onSelect:a}):null]})]})}function Q({title:e,apps:t,assistantId:n,pinnedAppIds:r,lastImportedAppId:i,onOpen:a,onPin:o,onDelete:s,onDeploy:c,onAnimationEnd:l}){return t.length===0?null:(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(`h2`,{className:`mb-4 text-body-small-emphasised text-[color:var(--content-secondary)] max-md:sr-only`,children:e}),(0,Z.jsx)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(max(220px,calc((100%-6rem)/5)),1fr))] gap-6 [--swipe-item-surface:var(--surface-base)] max-md:[--swipe-item-surface:var(--surface-overlay)]`,children:t.map(e=>(0,Z.jsx)(fe,{app:e,assistantId:n,isPinned:r.has(e.id),onOpen:a,onPin:o,onDelete:s,justImported:e.id===i,onAnimationEnd:l,onDeploy:c?()=>c(e.id):void 0},e.id))})]})}var $=(e,t)=>t.updatedAt-e.updatedAt||t.createdAt-e.createdAt;function me(e){let{pinnedAppIds:t}=s(e),{data:n=[],isLoading:r,error:i}=M({...y({path:{assistant_id:e}}),select:e=>e.apps}),{data:a=[],isLoading:o,error:c}=M({...j({path:{assistant_id:e}}),select:e=>e.documents}),l=r||o,u=i&&c?i instanceof Error?i.message:`Failed to load library`:null,[d,f]=(0,X.useState)(``),p=(0,X.useMemo)(()=>{if(!d.trim())return n;let e=d.toLowerCase();return n.filter(t=>t.name.toLowerCase().includes(e)||t.description?.toLowerCase().includes(e))},[n,d]);return{apps:n,documents:a,filteredApps:p,pinnedApps:(0,X.useMemo)(()=>p.filter(e=>t.has(e.id)).sort($),[p,t]),recentApps:(0,X.useMemo)(()=>p.filter(e=>!t.has(e.id)).sort($),[p,t]),filteredDocuments:(0,X.useMemo)(()=>{if(!d.trim())return a;let e=d.toLowerCase();return a.filter(t=>t.title.toLowerCase().includes(e))},[a,d]),searchText:d,setSearchText:f,loading:l,error:u}}async function he(e,t){let{data:n,error:r,response:i}=await a({path:{assistant_id:e},body:t,bodySerializer:e=>e,headers:{"Content-Type":`application/octet-stream`},throwOnError:!1});if(!i||!i.ok){let e=(r&&typeof r==`object`&&`message`in r?r.message:null)??`Failed to import app.`;throw Error(e)}return n}function ge({assistantId:e,assistantName:t,onNewConversation:n,onOpenDocument:r,onNewDocument:a,isCreatingDocument:c=!1,onOpenApp:l}){let{t:u}=N(`library`),d=m(),f=F(),{togglePin:g,pinnedAppIds:v}=s(e),y=i.use.isDeploying(),{apps:b,documents:x,filteredApps:S,pinnedApps:C,recentApps:w,filteredDocuments:T,searchText:D,setSearchText:k,loading:A,error:j}=me(e),{pendingDelete:M,isDeleting:P,requestDelete:I,confirmDelete:L,cancelDelete:R}=se(e),[z]=(0,X.useState)(()=>E()?void 0:`.vellum`),B=(0,X.useRef)(null),[V,H]=(0,X.useState)(!1),U=(0,X.useCallback)(async t=>{let n=t.target.files?.[0];if(!(!n||V)){H(!0);try{let t=await he(e,n);await f.invalidateQueries({queryKey:p({path:{assistant_id:e}})}),O.success(u(`libraryView.imported`,{name:t.name})),l(t.appId)}catch(e){O.error(e instanceof Error?e.message:u(`libraryView.importFailed`))}finally{H(!1),B.current&&(B.current.value=``)}}},[e,V,f,l,u]),W=(0,X.useCallback)(async t=>{if(y)return;let n=b.find(e=>e.id===t)?.name??`this app`;try{let r=await _(e,t);i.getState().deployApp(e,t,n,r)}catch{i.getState().deployApp(e,t,n,``)}},[e,y,b]),G=(0,X.useCallback)(e=>g(e.id),[g]),K=ie.use.setHeaderTrailing(),q=!A&&!j;if((0,X.useEffect)(()=>{if(!q){K(null);return}let e=(0,Z.jsx)(`div`,{className:`h-4 w-4 animate-spin rounded-full border-2 border-current border-t-transparent`}),t=V?e:(0,Z.jsx)(te,{"aria-hidden":!0}),n=c?e:(0,Z.jsx)(ee,{"aria-hidden":!0});return K(d?(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(h,{shape:`pill`,variant:`ghost`,iconOnly:t,"aria-label":u(`libraryView.import`),tooltip:u(`libraryView.import`),className:`max-md:bg-[var(--surface-active)]`,onClick:()=>B.current?.click(),disabled:V}),a?(0,Z.jsx)(h,{shape:`pill`,variant:`ghost`,iconOnly:n,"aria-label":u(`libraryView.newDocument`),tooltip:u(`libraryView.newDocument`),className:`max-md:bg-[var(--surface-active)]`,onClick:a,disabled:c}):null]}):(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsxs)(h,{variant:`outlined`,size:`regular`,onClick:()=>B.current?.click(),disabled:V,children:[t,(0,Z.jsx)(`span`,{className:`ml-1.5`,children:u(`libraryView.import`)})]}),a?(0,Z.jsxs)(h,{size:`regular`,onClick:a,disabled:c,children:[n,(0,Z.jsx)(`span`,{className:`ml-1.5`,children:u(`libraryView.newDocument`)})]}):null]})),()=>{K(null)}},[d,q,V,a,c,K,u]),A)return(0,Z.jsx)(`div`,{className:`flex h-full items-center justify-center`,children:(0,Z.jsx)(`div`,{className:`h-6 w-6 animate-spin rounded-full border-2 border-[var(--border-base)] border-t-[var(--primary-base)]`,role:`status`,"aria-label":u(`libraryView.loadingAria`)})});if(j)return(0,Z.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-4 px-4`,children:[(0,Z.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--content-tertiary)]`,children:j}),(0,Z.jsx)(`button`,{type:`button`,className:`rounded-lg bg-[var(--primary-base)] px-4 py-2 text-body-medium-default text-[var(--content-inset)] transition-colors hover:bg-[var(--primary-hover)]`,onClick:()=>window.location.reload(),children:u(`libraryView.retry`)})]});let J=b.length===0&&x.length===0;return(0,Z.jsxs)(`div`,{className:`flex h-full flex-col overflow-hidden`,children:[(0,Z.jsx)(`input`,{ref:B,type:`file`,accept:z,className:`hidden`,onChange:U}),J?(0,Z.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,Z.jsx)(de,{onNewConversation:n?()=>n():void 0})}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{className:`mb-6 shrink-0`,children:(0,Z.jsx)(o,{fullWidth:!0,type:`text`,placeholder:u(`libraryView.searchPlaceholder`),value:D,onChange:e=>k(e.target.value),leftIcon:(0,Z.jsx)(Y,{size:16})})}),(0,Z.jsx)(`div`,{className:`flex-1 overflow-y-auto`,children:S.length===0&&T.length===0?(0,Z.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-16`,children:[(0,Z.jsx)(Y,{size:32,className:`mb-4 text-[var(--content-tertiary)]`}),(0,Z.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--content-tertiary)]`,children:u(`libraryView.noMatches`,{query:D})})]}):(0,Z.jsxs)(`div`,{className:`flex flex-col gap-8`,children:[(0,Z.jsx)(Q,{title:u(`libraryView.pinned`),apps:C,assistantId:e,pinnedAppIds:v,onOpen:l,onPin:G,onDelete:I,onDeploy:W}),(0,Z.jsx)(Q,{title:u(`libraryView.recents`),apps:w,assistantId:e,pinnedAppIds:v,onOpen:l,onPin:G,onDelete:I,onDeploy:W}),T.length>0?(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(`h2`,{className:`mb-4 text-body-small-emphasised text-[color:var(--content-secondary)]`,children:u(`libraryView.documents`)}),(0,Z.jsx)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(max(220px,calc((100%-6rem)/5)),1fr))] gap-6`,children:T.map(e=>(0,Z.jsx)(ue,{document:e,onOpen:e=>{r&&r(e)}},e.surfaceId))})]}):null]})}),(0,Z.jsx)(re,{assistantId:e,assistantName:t,onStartConversation:n}),(0,Z.jsx)(oe,{app:M,isDeleting:P,onConfirm:L,onCancel:R})]})]})}function _e(){let e=F(),n=P({...l(),onSuccess:(n,r)=>{e.invalidateQueries({queryKey:t({path:r.path})})}});return{createDocument:({assistantId:e,conversationId:t})=>n.mutateAsync({path:{assistant_id:e},body:{conversationId:t}}),isPending:n.isPending}}function ve(e,t){let{t:n}=N(`library`),i=F(),{createDocument:a}=_e(),[o,s]=(0,X.useState)(!1),c=(0,X.useRef)(!1);return{newDocument:(0,X.useCallback)(async()=>{if(!c.current){c.current=!0,s(!0);try{let o=await C({assistantId:e,fallback:n(`libraryView.newDocumentFailed`)});if(!o.ok){O.error(o.error);return}let s;try{({surfaceId:s}=await a({assistantId:e,conversationId:o.conversationId}))}catch(t){r(t,{context:`new_library_document`}),D(e,o.conversationId),O.error(n(`libraryView.newDocumentFailed`));return}k(i,e),t(s)}finally{c.current=!1,s(!1)}}},[e,a,t,i,n]),isCreating:o}}var ye=`0.12.2-dev.202609211450.3151b18`;function be(e){return d(ye,e)}function xe(){let e=T(),t=L(),r=I(),i=(0,X.useCallback)(e=>{x(t,{prompt:e})},[t]),a=(0,X.useCallback)(e=>{t(v(e,r.pathname),{state:b(r,e)})},[t,r]),{newDocument:o,isCreating:s}=ve(e,a),c=be(e),l=(0,X.useCallback)(()=>{o()},[o]),u=(0,X.useCallback)(e=>{t(n.library.app(e))},[t]);return(0,Z.jsx)(ge,{assistantId:e,onNewConversation:i,onOpenDocument:a,onNewDocument:c?l:void 0,isCreatingDocument:s,onOpenApp:u})}export{xe as LibraryPage};
1
+ import{o as e}from"./rolldown-runtime-BM3Ffeng.js";import{Bp as t,DS as n,IS as r,Ir as i,Nv as a,PC as o,Qi as s,Qo as c,Rp as l,Vt as u,Wg as d,XC as f,_p as p,au as m,aw as h,br as g,eg as _,go as v,gp as y,ho as b,iu as x,ka as S,l as C,ln as w,nt as T,ss as E,u as D,xC as O,xc as k,xr as A,zp as j}from"./app-DbJUeBix.js";import{$n as M,E as N,Xn as P,nr as F}from"./vendor-CtXGFqsu.js";import{d as I,f as L,t as R,x as z}from"./react-B9IgSVeK.js";import{$r as B,A as V,At as H,Br as U,Cr as W,Ht as G,Ia as K,Ur as ee,Vt as q,ir as J,ri as te,tr as ne,vt as Y}from"./icons-C0wyat6T.js";import{t as re}from"./deploy-dialogs-Hu5UmFuB.js";import{t as ie}from"./intelligence-layout-slots-store-DSIw2NvD.js";import{n as ae,r as oe,t as se}from"./use-app-delete-2je5dBpX.js";import{t as ce}from"./app-types-BwhjauA5.js";var X=e(z(),1),Z=R();function le(e){return e===1?`1 word`:`${e} words`}function ue({document:e,onOpen:t}){return(0,Z.jsxs)(`div`,{className:`group relative flex flex-col gap-2`,children:[(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>t(e.surfaceId),className:c(`relative flex w-full cursor-pointer flex-col items-center justify-center gap-2 overflow-hidden rounded-xl border border-[var(--border-base)] bg-[var(--surface-base)]`,`aspect-[16/10]`,`outline-none focus-visible:ring-2 focus-visible:ring-[var(--ring)]`),children:[(0,Z.jsx)(U,{size:34,className:`text-[var(--content-tertiary)]`}),(0,Z.jsx)(`span`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:le(e.wordCount)})]}),(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>t(e.surfaceId),className:`flex cursor-pointer flex-col gap-0.5 rounded-sm px-0.5 text-left outline-none keyboard-focus:ring-2 keyboard-focus:ring-inset keyboard-focus:ring-[var(--ring)]`,children:[(0,Z.jsx)(`span`,{className:`truncate text-body-large-default text-[color:var(--content-emphasised)]`,children:e.title}),(0,Z.jsx)(`span`,{className:`text-body-small-default text-[color:var(--content-tertiary)]`,children:u(new Date(e.updatedAt))})]})]})}function de({onNewConversation:e}){let{t}=N(`library`);return(0,Z.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-4 px-4 py-24`,children:[(0,Z.jsx)(`div`,{className:`flex h-16 w-16 items-center justify-center rounded-xl bg-[var(--surface-base)]`,children:(0,Z.jsx)(J,{size:32,className:`text-[var(--content-tertiary)]`})}),(0,Z.jsx)(`h2`,{className:`text-title-medium text-[var(--content-default)]`,children:t(`libraryEmptyState.heading`)}),(0,Z.jsx)(`p`,{className:`max-w-md text-center text-body-medium-lighter text-[color:var(--content-tertiary)]`,children:t(`libraryEmptyState.body`)}),e?(0,Z.jsx)(h,{variant:`primary`,size:`regular`,onClick:e,children:t(`libraryEmptyState.newConversation`)}):null]})}function fe({app:e,assistantId:t,isPinned:n,onOpen:r,onPin:i,onDelete:a,onDeploy:o,justImported:s,onAnimationEnd:l}){let{t:d}=N(`library`),f=ce(e.origin),p=f?void 0:a,m=f?void 0:o,h=(0,X.useCallback)(()=>_(t,e.id,e.updatedAt),[t,e.id,e.updatedAt]),v=ae(t,e,{exported:d(`libraryAppCard.exported`),failed:d(`libraryAppCard.shareFailed`)}),[y,b]=(0,X.useState)(!1),[x,C]=(0,X.useState)(!1),T=(0,X.useCallback)(()=>C(!0),[]),{deployedUrl:E}=A(t,e.id,{enabled:x&&m!=null}),D=(0,X.useCallback)(()=>{E!=null&&g(E)},[E]);return(0,Z.jsx)(S,{trailingActions:[{id:`pin`,label:d(n?`libraryAppCard.unpin`:`libraryAppCard.pin`),icon:n?G:q,onSelect:()=>i(e)},...p?[{id:`delete`,label:d(`libraryAppCard.delete`),icon:V,variant:`destructive`,onSelect:()=>p(e)}]:[]],className:`rounded-xl`,children:(0,Z.jsxs)(`div`,{"data-reveal-row":``,className:c(`relative flex flex-col gap-2`,s&&`animate-[card-entrance_400ms_ease-out]`),onAnimationEnd:s?l:void 0,onPointerEnter:T,children:[(0,Z.jsx)(`button`,{type:`button`,onClick:()=>r(e.id),className:c(`relative w-full cursor-pointer overflow-hidden rounded-xl`,`outline-none focus-visible:ring-2 focus-visible:ring-[var(--ring)]`),children:(0,Z.jsx)(w,{name:e.name,icon:e.icon,loadHtml:h})}),(0,Z.jsx)(`div`,{"data-reveal":``,className:`absolute right-2 top-2 z-20`,children:(0,Z.jsx)(pe,{appName:e.name,isPinned:n,open:y,onOpenChange:e=>{e&&T(),b(e)},onPin:()=>i(e),onDelete:p?()=>p(e):void 0,onShare:f?void 0:v,onDeploy:m,deployedUrl:E,onCopyDeployedLink:D})}),(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>r(e.id),className:`flex cursor-pointer flex-col gap-0.5 rounded-sm px-0.5 text-left outline-none keyboard-focus:ring-2 keyboard-focus:ring-inset keyboard-focus:ring-[var(--ring)]`,children:[(0,Z.jsx)(`span`,{className:`truncate text-body-large-default text-[color:var(--content-emphasised)] max-md:text-body-medium-lighter max-md:text-[color:var(--content-secondary)]`,children:e.name}),(0,Z.jsx)(`span`,{className:`text-body-small-default text-[color:var(--content-tertiary)] max-md:hidden`,children:u(new Date(e.createdAt))})]})]})})}function pe({appName:e,isPinned:t,open:n,onOpenChange:r,onPin:i,onDelete:a,onShare:o,onDeploy:s,deployedUrl:c,onCopyDeployedLink:l}){let{t:u}=N(`library`),d=c!=null&&c!==``&&l!=null,p=u(`libraryAppCard.actionsTitle`,{appName:e});return(0,Z.jsxs)(f.Root,{open:n,onOpenChange:r,children:[(0,Z.jsx)(f.Trigger,{asChild:!0,children:(0,Z.jsx)(h,{variant:`primary`,size:`compact`,iconOnly:(0,Z.jsx)(B,{}),"aria-label":p,onClick:e=>e.stopPropagation()})}),(0,Z.jsxs)(f.Content,{title:p,children:[(0,Z.jsx)(f.Item,{icon:t?G:q,label:u(t?`libraryAppCard.unpin`:`libraryAppCard.pin`),onSelect:i}),o?(0,Z.jsx)(f.Item,{icon:K,label:u(`libraryAppCard.share`),description:u(`libraryAppCard.shareSub`),onSelect:o}):null,s&&d?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(f.Item,{icon:ne,label:u(`libraryAppCard.deployed`),description:(0,Z.jsx)(`span`,{className:`break-all`,children:c}),trailing:u(`libraryAppCard.copyLink`),onSelect:()=>l?.()}),(0,Z.jsx)(f.Item,{icon:H,label:u(`libraryAppCard.redeploy`),description:u(`libraryAppCard.redeploySub`),onSelect:s})]}):s?(0,Z.jsx)(f.Item,{icon:W,label:u(`libraryAppCard.deploy`),description:u(`libraryAppCard.deploySub`),onSelect:s}):null,a?(0,Z.jsx)(f.Item,{icon:V,label:u(`libraryAppCard.delete`),tone:`destructive`,onSelect:a}):null]})]})}function Q({title:e,apps:t,assistantId:n,pinnedAppIds:r,lastImportedAppId:i,onOpen:a,onPin:o,onDelete:s,onDeploy:c,onAnimationEnd:l}){return t.length===0?null:(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(`h2`,{className:`mb-4 text-body-small-emphasised text-[color:var(--content-secondary)] max-md:sr-only`,children:e}),(0,Z.jsx)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(max(220px,calc((100%-6rem)/5)),1fr))] gap-6 [--swipe-item-surface:var(--surface-base)] max-md:[--swipe-item-surface:var(--surface-overlay)]`,children:t.map(e=>(0,Z.jsx)(fe,{app:e,assistantId:n,isPinned:r.has(e.id),onOpen:a,onPin:o,onDelete:s,justImported:e.id===i,onAnimationEnd:l,onDeploy:c?()=>c(e.id):void 0},e.id))})]})}var $=(e,t)=>t.updatedAt-e.updatedAt||t.createdAt-e.createdAt;function me(e){let{pinnedAppIds:t}=s(e),{data:n=[],isLoading:r,error:i}=M({...y({path:{assistant_id:e}}),select:e=>e.apps}),{data:a=[],isLoading:o,error:c}=M({...j({path:{assistant_id:e}}),select:e=>e.documents}),l=r||o,u=i&&c?i instanceof Error?i.message:`Failed to load library`:null,[d,f]=(0,X.useState)(``),p=(0,X.useMemo)(()=>{if(!d.trim())return n;let e=d.toLowerCase();return n.filter(t=>t.name.toLowerCase().includes(e)||t.description?.toLowerCase().includes(e))},[n,d]);return{apps:n,documents:a,filteredApps:p,pinnedApps:(0,X.useMemo)(()=>p.filter(e=>t.has(e.id)).sort($),[p,t]),recentApps:(0,X.useMemo)(()=>p.filter(e=>!t.has(e.id)).sort($),[p,t]),filteredDocuments:(0,X.useMemo)(()=>{if(!d.trim())return a;let e=d.toLowerCase();return a.filter(t=>t.title.toLowerCase().includes(e))},[a,d]),searchText:d,setSearchText:f,loading:l,error:u}}async function he(e,t){let{data:n,error:r,response:i}=await a({path:{assistant_id:e},body:t,bodySerializer:e=>e,headers:{"Content-Type":`application/octet-stream`},throwOnError:!1});if(!i||!i.ok){let e=(r&&typeof r==`object`&&`message`in r?r.message:null)??`Failed to import app.`;throw Error(e)}return n}function ge({assistantId:e,assistantName:t,onNewConversation:n,onOpenDocument:r,onNewDocument:a,isCreatingDocument:c=!1,onOpenApp:l}){let{t:u}=N(`library`),d=m(),f=F(),{togglePin:g,pinnedAppIds:v}=s(e),y=i.use.isDeploying(),{apps:b,documents:x,filteredApps:S,pinnedApps:C,recentApps:w,filteredDocuments:T,searchText:D,setSearchText:k,loading:A,error:j}=me(e),{pendingDelete:M,isDeleting:P,requestDelete:I,confirmDelete:L,cancelDelete:R}=se(e),[z]=(0,X.useState)(()=>E()?void 0:`.vellum`),B=(0,X.useRef)(null),[V,H]=(0,X.useState)(!1),U=(0,X.useCallback)(async t=>{let n=t.target.files?.[0];if(!(!n||V)){H(!0);try{let t=await he(e,n);await f.invalidateQueries({queryKey:p({path:{assistant_id:e}})}),O.success(u(`libraryView.imported`,{name:t.name})),l(t.appId)}catch(e){O.error(e instanceof Error?e.message:u(`libraryView.importFailed`))}finally{H(!1),B.current&&(B.current.value=``)}}},[e,V,f,l,u]),W=(0,X.useCallback)(async t=>{if(y)return;let n=b.find(e=>e.id===t)?.name??`this app`;try{let r=await _(e,t);i.getState().deployApp(e,t,n,r)}catch{i.getState().deployApp(e,t,n,``)}},[e,y,b]),G=(0,X.useCallback)(e=>g(e.id),[g]),K=ie.use.setHeaderTrailing(),q=!A&&!j;if((0,X.useEffect)(()=>{if(!q){K(null);return}let e=(0,Z.jsx)(`div`,{className:`h-4 w-4 animate-spin rounded-full border-2 border-current border-t-transparent`}),t=V?e:(0,Z.jsx)(te,{"aria-hidden":!0}),n=c?e:(0,Z.jsx)(ee,{"aria-hidden":!0});return K(d?(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(h,{shape:`pill`,variant:`ghost`,iconOnly:t,"aria-label":u(`libraryView.import`),tooltip:u(`libraryView.import`),className:`max-md:bg-[var(--surface-active)]`,onClick:()=>B.current?.click(),disabled:V}),a?(0,Z.jsx)(h,{shape:`pill`,variant:`ghost`,iconOnly:n,"aria-label":u(`libraryView.newDocument`),tooltip:u(`libraryView.newDocument`),className:`max-md:bg-[var(--surface-active)]`,onClick:a,disabled:c}):null]}):(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsxs)(h,{variant:`outlined`,size:`regular`,onClick:()=>B.current?.click(),disabled:V,children:[t,(0,Z.jsx)(`span`,{className:`ml-1.5`,children:u(`libraryView.import`)})]}),a?(0,Z.jsxs)(h,{size:`regular`,onClick:a,disabled:c,children:[n,(0,Z.jsx)(`span`,{className:`ml-1.5`,children:u(`libraryView.newDocument`)})]}):null]})),()=>{K(null)}},[d,q,V,a,c,K,u]),A)return(0,Z.jsx)(`div`,{className:`flex h-full items-center justify-center`,children:(0,Z.jsx)(`div`,{className:`h-6 w-6 animate-spin rounded-full border-2 border-[var(--border-base)] border-t-[var(--primary-base)]`,role:`status`,"aria-label":u(`libraryView.loadingAria`)})});if(j)return(0,Z.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-4 px-4`,children:[(0,Z.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--content-tertiary)]`,children:j}),(0,Z.jsx)(`button`,{type:`button`,className:`rounded-lg bg-[var(--primary-base)] px-4 py-2 text-body-medium-default text-[var(--content-inset)] transition-colors hover:bg-[var(--primary-hover)]`,onClick:()=>window.location.reload(),children:u(`libraryView.retry`)})]});let J=b.length===0&&x.length===0;return(0,Z.jsxs)(`div`,{className:`flex h-full flex-col overflow-hidden`,children:[(0,Z.jsx)(`input`,{ref:B,type:`file`,accept:z,className:`hidden`,onChange:U}),J?(0,Z.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,Z.jsx)(de,{onNewConversation:n?()=>n():void 0})}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{className:`mb-6 shrink-0`,children:(0,Z.jsx)(o,{fullWidth:!0,type:`text`,placeholder:u(`libraryView.searchPlaceholder`),value:D,onChange:e=>k(e.target.value),leftIcon:(0,Z.jsx)(Y,{size:16})})}),(0,Z.jsx)(`div`,{className:`flex-1 overflow-y-auto`,children:S.length===0&&T.length===0?(0,Z.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-16`,children:[(0,Z.jsx)(Y,{size:32,className:`mb-4 text-[var(--content-tertiary)]`}),(0,Z.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--content-tertiary)]`,children:u(`libraryView.noMatches`,{query:D})})]}):(0,Z.jsxs)(`div`,{className:`flex flex-col gap-8`,children:[(0,Z.jsx)(Q,{title:u(`libraryView.pinned`),apps:C,assistantId:e,pinnedAppIds:v,onOpen:l,onPin:G,onDelete:I,onDeploy:W}),(0,Z.jsx)(Q,{title:u(`libraryView.recents`),apps:w,assistantId:e,pinnedAppIds:v,onOpen:l,onPin:G,onDelete:I,onDeploy:W}),T.length>0?(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(`h2`,{className:`mb-4 text-body-small-emphasised text-[color:var(--content-secondary)]`,children:u(`libraryView.documents`)}),(0,Z.jsx)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(max(220px,calc((100%-6rem)/5)),1fr))] gap-6`,children:T.map(e=>(0,Z.jsx)(ue,{document:e,onOpen:e=>{r&&r(e)}},e.surfaceId))})]}):null]})}),(0,Z.jsx)(re,{assistantId:e,assistantName:t,onStartConversation:n}),(0,Z.jsx)(oe,{app:M,isDeleting:P,onConfirm:L,onCancel:R})]})]})}function _e(){let e=F(),n=P({...l(),onSuccess:(n,r)=>{e.invalidateQueries({queryKey:t({path:r.path})})}});return{createDocument:({assistantId:e,conversationId:t})=>n.mutateAsync({path:{assistant_id:e},body:{conversationId:t}}),isPending:n.isPending}}function ve(e,t){let{t:n}=N(`library`),i=F(),{createDocument:a}=_e(),[o,s]=(0,X.useState)(!1),c=(0,X.useRef)(!1);return{newDocument:(0,X.useCallback)(async()=>{if(!c.current){c.current=!0,s(!0);try{let o=await C({assistantId:e,fallback:n(`libraryView.newDocumentFailed`)});if(!o.ok){O.error(o.error);return}let s;try{({surfaceId:s}=await a({assistantId:e,conversationId:o.conversationId}))}catch(t){r(t,{context:`new_library_document`}),D(e,o.conversationId),O.error(n(`libraryView.newDocumentFailed`));return}k(i,e),t(s)}finally{c.current=!1,s(!1)}}},[e,a,t,i,n]),isCreating:o}}var ye=`0.12.2-dev.202609211450.3151b18`;function be(e){return d(ye,e)}function xe(){let e=T(),t=L(),r=I(),i=(0,X.useCallback)(e=>{x(t,{prompt:e})},[t]),a=(0,X.useCallback)(e=>{t(v(e,r.pathname),{state:b(r,e)})},[t,r]),{newDocument:o,isCreating:s}=ve(e,a),c=be(e),l=(0,X.useCallback)(()=>{o()},[o]),u=(0,X.useCallback)(e=>{t(n.library.app(e))},[t]);return(0,Z.jsx)(ge,{assistantId:e,onNewConversation:i,onOpenDocument:a,onNewDocument:c?l:void 0,isCreatingDocument:s,onOpenApp:u})}export{xe as LibraryPage};
@@ -0,0 +1 @@
1
+ import{Lx as e}from"./app-DbJUeBix.js";export{e as markLockfileAssistantOnboarded};
@@ -1 +1 @@
1
- import{o as e}from"./rolldown-runtime-BM3Ffeng.js";import{DS as t,IS as n,aw as r,eb as i,il as a,jb as o,nl as s,rl as c,tb as l,tl as u}from"./app-D0NlDYsG.js";import{E as d}from"./vendor-CtXGFqsu.js";import{d as f,t as p,x as m}from"./react-B9IgSVeK.js";import{n as h,r as g,t as _}from"./auth-welcome-screen-DCozLA-c.js";import{n as v,t as y}from"./use-return-to-short-circuit-DZLF2zb8.js";var b=e(m(),1),x=p();function S({returnTo:e}){let{t}=d(`account`),[o,l]=(0,b.useState)(null),[f,p]=(0,b.useState)(!1),m=async()=>{l(null),p(!0);try{await i({returnTo:e??null})}catch(e){if(s(e)){p(!1);return}n(e,{context:`native_login`,tags:{authError:c(e)??`unclassified`}}),l(t(a(e),{community:u})),p(!1)}};return(0,x.jsx)(g,{animateAvatarWaveIn:!0,fillsViewport:!0,children:(0,x.jsx)(h,{error:o,children:(0,x.jsx)(r,{type:`button`,variant:`primary`,size:`large`,fullWidth:!0,onClick:()=>{m()},disabled:f,children:t(`loginPage.signIn`)})})})}function C({returnTo:e}){let{t:n}=d(`account`),{search:r}=f(),i=o(e?`${t.account.signup}?returnTo=${encodeURIComponent(e)}`:t.account.signup,r);return(0,x.jsx)(_,{returnTo:e,errorContext:`web_login`,fillsViewport:!0,secondary:{label:n(`loginPage.signUp`),href:i}})}function w(){let e=l(),t=y();return t.kind===`wait`?(0,x.jsx)(g,{animateAvatarWaveIn:!0,fillsViewport:!0,children:(0,x.jsx)(v,{})}):t.kind===`redirect`?t.node:e?(0,x.jsx)(S,{returnTo:t.returnTo}):(0,x.jsx)(C,{returnTo:t.returnTo})}export{w as LoginPage};
1
+ import{o as e}from"./rolldown-runtime-BM3Ffeng.js";import{DS as t,IS as n,aw as r,eb as i,il as a,jb as o,nl as s,rl as c,tb as l,tl as u}from"./app-DbJUeBix.js";import{E as d}from"./vendor-CtXGFqsu.js";import{d as f,t as p,x as m}from"./react-B9IgSVeK.js";import{n as h,r as g,t as _}from"./auth-welcome-screen-Bng5AnvV.js";import{n as v,t as y}from"./use-return-to-short-circuit-D82kSfEB.js";var b=e(m(),1),x=p();function S({returnTo:e}){let{t}=d(`account`),[o,l]=(0,b.useState)(null),[f,p]=(0,b.useState)(!1),m=async()=>{l(null),p(!0);try{await i({returnTo:e??null})}catch(e){if(s(e)){p(!1);return}n(e,{context:`native_login`,tags:{authError:c(e)??`unclassified`}}),l(t(a(e),{community:u})),p(!1)}};return(0,x.jsx)(g,{animateAvatarWaveIn:!0,fillsViewport:!0,children:(0,x.jsx)(h,{error:o,children:(0,x.jsx)(r,{type:`button`,variant:`primary`,size:`large`,fullWidth:!0,onClick:()=>{m()},disabled:f,children:t(`loginPage.signIn`)})})})}function C({returnTo:e}){let{t:n}=d(`account`),{search:r}=f(),i=o(e?`${t.account.signup}?returnTo=${encodeURIComponent(e)}`:t.account.signup,r);return(0,x.jsx)(_,{returnTo:e,errorContext:`web_login`,fillsViewport:!0,secondary:{label:n(`loginPage.signUp`),href:i}})}function w(){let e=l(),t=y();return t.kind===`wait`?(0,x.jsx)(g,{animateAvatarWaveIn:!0,fillsViewport:!0,children:(0,x.jsx)(v,{})}):t.kind===`redirect`?t.node:e?(0,x.jsx)(S,{returnTo:t.returnTo}):(0,x.jsx)(C,{returnTo:t.returnTo})}export{w as LoginPage};
@@ -1 +1 @@
1
- import{o as e}from"./rolldown-runtime-BM3Ffeng.js";import{DS as t,Oh as n,hl as r,kb as i}from"./app-D0NlDYsG.js";import{E as a}from"./vendor-CtXGFqsu.js";import{_ as o,t as s,x as c}from"./react-B9IgSVeK.js";import{r as l,t as u}from"./account-shell-81SeJquZ.js";var d=e(c(),1),f=s();function p(){let{t:e}=a(`account`),[s]=o(),c=n.use.logout(),p=(0,d.useRef)(!1);return(0,d.useEffect)(()=>{if(p.current)return;p.current=!0;let e=i(s.get(`returnTo`),t.account.login),n=e.startsWith(`http`)||e===t.account.login?e:`${t.account.login}?returnTo=${encodeURIComponent(e)}`,a=!1;return c().then(()=>{a||r(n)},()=>{a||r(n)}),()=>{a=!0}},[c,s]),(0,f.jsx)(u,{children:(0,f.jsx)(l,{title:e(`logoutPage.title`)})})}export{p as LogoutPage};
1
+ import{o as e}from"./rolldown-runtime-BM3Ffeng.js";import{DS as t,Oh as n,hl as r,kb as i}from"./app-DbJUeBix.js";import{E as a}from"./vendor-CtXGFqsu.js";import{_ as o,t as s,x as c}from"./react-B9IgSVeK.js";import{r as l,t as u}from"./account-shell-CkJWoTHP.js";var d=e(c(),1),f=s();function p(){let{t:e}=a(`account`),[s]=o(),c=n.use.logout(),p=(0,d.useRef)(!1);return(0,d.useEffect)(()=>{if(p.current)return;p.current=!0;let e=i(s.get(`returnTo`),t.account.login),n=e.startsWith(`http`)||e===t.account.login?e:`${t.account.login}?returnTo=${encodeURIComponent(e)}`,a=!1;return c().then(()=>{a||r(n)},()=>{a||r(n)}),()=>{a=!0}},[c,s]),(0,f.jsx)(u,{children:(0,f.jsx)(l,{title:e(`logoutPage.title`)})})}export{p as LogoutPage};
@@ -1 +1 @@
1
- import{o as e}from"./rolldown-runtime-BM3Ffeng.js";import{DS as t,Th as n}from"./app-D0NlDYsG.js";import{d as r,i,t as a,x as o}from"./react-B9IgSVeK.js";import{Vn as s,Ya as c}from"./icons-C0wyat6T.js";import{n as l,t as u}from"./sidebar-tree-BLqbyk5v.js";var d=c(`monitor-cog`,[[`path`,{d:`M12 17v4`,key:`1riwvh`}],[`path`,{d:`m14.305 7.53.923-.382`,key:`1mlnsw`}],[`path`,{d:`m15.228 4.852-.923-.383`,key:`82mpwg`}],[`path`,{d:`m16.852 3.228-.383-.924`,key:`ln4sir`}],[`path`,{d:`m16.852 8.772-.383.923`,key:`1dejw0`}],[`path`,{d:`m19.148 3.228.383-.924`,key:`192kgf`}],[`path`,{d:`m19.53 9.696-.382-.924`,key:`fiavlr`}],[`path`,{d:`m20.772 4.852.924-.383`,key:`1j8mgp`}],[`path`,{d:`m20.772 7.148.924.383`,key:`zix9be`}],[`path`,{d:`M22 13v2a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h7`,key:`1tnzv8`}],[`path`,{d:`M8 21h8`,key:`1ev6f3`}],[`circle`,{cx:`18`,cy:`6`,r:`3`,key:`1h7g24`}]]),f=e(o(),1),p=[{id:`emails`,label:`Emails`,href:t.logs.emails,icon:s},{id:`system-events`,label:`System Events`,href:t.logs.systemEvents,icon:d}],m=a();function h(){let e=n({platformHostedOnly:!0}),a=n(),{pathname:o}=r(),s=(0,f.useMemo)(()=>p.filter(t=>!(t.id===`system-events`&&e===`gated`||t.id===`emails`&&a===`gated`)),[e,a]),c=(0,f.useMemo)(()=>{let e=p.find(e=>o===e.href||o.startsWith(e.href+`/`));return e?e.label:o===t.logs.root?p[0]?.label??`Logs & Usage`:`Logs & Usage`},[o]);return(0,m.jsx)(l,{backHref:t.assistant,sidebar:(0,m.jsx)(u,{items:s,indexPath:t.logs.root}),title:c,menuRoute:t.logs.root,children:(0,m.jsx)(i,{})})}export{h as LogsLayout};
1
+ import{o as e}from"./rolldown-runtime-BM3Ffeng.js";import{DS as t,Th as n}from"./app-DbJUeBix.js";import{d as r,i,t as a,x as o}from"./react-B9IgSVeK.js";import{Vn as s,Ya as c}from"./icons-C0wyat6T.js";import{n as l,t as u}from"./sidebar-tree-BLMAqL8a.js";var d=c(`monitor-cog`,[[`path`,{d:`M12 17v4`,key:`1riwvh`}],[`path`,{d:`m14.305 7.53.923-.382`,key:`1mlnsw`}],[`path`,{d:`m15.228 4.852-.923-.383`,key:`82mpwg`}],[`path`,{d:`m16.852 3.228-.383-.924`,key:`ln4sir`}],[`path`,{d:`m16.852 8.772-.383.923`,key:`1dejw0`}],[`path`,{d:`m19.148 3.228.383-.924`,key:`192kgf`}],[`path`,{d:`m19.53 9.696-.382-.924`,key:`fiavlr`}],[`path`,{d:`m20.772 4.852.924-.383`,key:`1j8mgp`}],[`path`,{d:`m20.772 7.148.924.383`,key:`zix9be`}],[`path`,{d:`M22 13v2a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h7`,key:`1tnzv8`}],[`path`,{d:`M8 21h8`,key:`1ev6f3`}],[`circle`,{cx:`18`,cy:`6`,r:`3`,key:`1h7g24`}]]),f=e(o(),1),p=[{id:`emails`,label:`Emails`,href:t.logs.emails,icon:s},{id:`system-events`,label:`System Events`,href:t.logs.systemEvents,icon:d}],m=a();function h(){let e=n({platformHostedOnly:!0}),a=n(),{pathname:o}=r(),s=(0,f.useMemo)(()=>p.filter(t=>!(t.id===`system-events`&&e===`gated`||t.id===`emails`&&a===`gated`)),[e,a]),c=(0,f.useMemo)(()=>{let e=p.find(e=>o===e.href||o.startsWith(e.href+`/`));return e?e.label:o===t.logs.root?p[0]?.label??`Logs & Usage`:`Logs & Usage`},[o]);return(0,m.jsx)(l,{backHref:t.assistant,sidebar:(0,m.jsx)(u,{items:s,indexPath:t.logs.root}),title:c,menuRoute:t.logs.root,children:(0,m.jsx)(i,{})})}export{h as LogsLayout};
@@ -1 +1 @@
1
- import{Hn as e,mr as t,zn as n}from"./app-D0NlDYsG.js";import{E as r}from"./vendor-CtXGFqsu.js";import{t as i}from"./react-B9IgSVeK.js";import{t as a}from"./preview-error-BKpqKOCK.js";import{t as o}from"./use-truncated-blob-text-_V8QhH9C.js";var s=i(),c=512*1024;function l({blob:i,filename:l}){let{t:u}=r(`chat`),{text:d,truncated:f,decodeFailed:p}=o(i,c);return p?(0,s.jsx)(a,{filename:l}):d===null?(0,s.jsx)(t,{}):(0,s.jsxs)(`div`,{className:`flex min-h-0 flex-col gap-2`,children:[(0,s.jsx)(n,{content:d}),f&&(0,s.jsx)(e,{children:u(`previewTruncationNotice.markdown`)})]})}export{l as MarkdownPreview};
1
+ import{Hn as e,mr as t,zn as n}from"./app-DbJUeBix.js";import{E as r}from"./vendor-CtXGFqsu.js";import{t as i}from"./react-B9IgSVeK.js";import{t as a}from"./preview-error-DycCFOOO.js";import{t as o}from"./use-truncated-blob-text-_V8QhH9C.js";var s=i(),c=512*1024;function l({blob:i,filename:l}){let{t:u}=r(`chat`),{text:d,truncated:f,decodeFailed:p}=o(i,c);return p?(0,s.jsx)(a,{filename:l}):d===null?(0,s.jsx)(t,{}):(0,s.jsxs)(`div`,{className:`flex min-h-0 flex-col gap-2`,children:[(0,s.jsx)(n,{content:d}),f&&(0,s.jsx)(e,{children:u(`previewTruncationNotice.markdown`)})]})}export{l as MarkdownPreview};
@@ -1 +1 @@
1
- import{o as e}from"./rolldown-runtime-BM3Ffeng.js";import{Uh as t,mr as n,pr as r}from"./app-D0NlDYsG.js";import{t as i,x as a}from"./react-B9IgSVeK.js";var o=e(a(),1),s=i(),c=`nodownload noplaybackrate`;function l({blob:e,filename:i,kind:a}){let l=r(e,(0,o.useMemo)(()=>t({sniffedMime:null,serverMime:e.type.length>0?e.type:null,filename:i}).mime,[e,i]));return l===null?(0,s.jsx)(n,{}):a===`image`?(0,s.jsx)(`div`,{className:`flex justify-center`,children:(0,s.jsx)(`img`,{src:l,alt:i,className:`h-auto max-w-full rounded-lg border border-[var(--border-element)]`})}):a===`audio`?(0,s.jsx)(`audio`,{src:l,controls:!0,controlsList:c,preload:`metadata`,"aria-label":i,className:`w-full`}):(0,s.jsx)(`video`,{src:l,controls:!0,controlsList:c,playsInline:!0,preload:`metadata`,"aria-label":i,className:`max-w-full rounded-lg border border-[var(--border-element)]`})}export{l as MediaPreview};
1
+ import{o as e}from"./rolldown-runtime-BM3Ffeng.js";import{Uh as t,mr as n,pr as r}from"./app-DbJUeBix.js";import{t as i,x as a}from"./react-B9IgSVeK.js";var o=e(a(),1),s=i(),c=`nodownload noplaybackrate`;function l({blob:e,filename:i,kind:a}){let l=r(e,(0,o.useMemo)(()=>t({sniffedMime:null,serverMime:e.type.length>0?e.type:null,filename:i}).mime,[e,i]));return l===null?(0,s.jsx)(n,{}):a===`image`?(0,s.jsx)(`div`,{className:`flex justify-center`,children:(0,s.jsx)(`img`,{src:l,alt:i,className:`h-auto max-w-full rounded-lg border border-[var(--border-element)]`})}):a===`audio`?(0,s.jsx)(`audio`,{src:l,controls:!0,controlsList:c,preload:`metadata`,"aria-label":i,className:`w-full`}):(0,s.jsx)(`video`,{src:l,controls:!0,controlsList:c,playsInline:!0,preload:`metadata`,"aria-label":i,className:`max-w-full rounded-lg border border-[var(--border-element)]`})}export{l as MediaPreview};