decocms 4.204.20 → 4.204.21

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 (224) hide show
  1. package/dist/client/assets/{AlertCircle-yU8aQy-3.js → AlertCircle-BrFXH1Ft.js} +1 -1
  2. package/dist/client/assets/{AreaChart-DnsmNY0J.js → AreaChart-Cy58Kva_.js} +1 -1
  3. package/dist/client/assets/{ArrowLeft-Bx4aiJtk.js → ArrowLeft-DKVmkmvj.js} +1 -1
  4. package/dist/client/assets/{ArrowUp-Dp2uF0UJ.js → ArrowUp-D8z4cruk.js} +1 -1
  5. package/dist/client/assets/{ArrowUpRight-BfHHZJba.js → ArrowUpRight-C23Ec1g6.js} +1 -1
  6. package/dist/client/assets/{Check-CqTwbGPS.js → Check-DzadTydo.js} +1 -1
  7. package/dist/client/assets/{CheckCircle-BxiEu-D8.js → CheckCircle-Bxu6iVau.js} +1 -1
  8. package/dist/client/assets/{ChevronDown-BQ-Mj20Q.js → ChevronDown-vt1NHoOA.js} +1 -1
  9. package/dist/client/assets/{ChevronRight-CE8UVD3O.js → ChevronRight-C3SZts0d.js} +1 -1
  10. package/dist/client/assets/{ChevronUp-Dselft5e.js → ChevronUp-BcNGO3Vu.js} +1 -1
  11. package/dist/client/assets/{Copy01-BzIOqvji.js → Copy01-QrInJwzC.js} +1 -1
  12. package/dist/client/assets/{CpuChip01-BDzHX2JT.js → CpuChip01-cTqTQwto.js} +1 -1
  13. package/dist/client/assets/{CreditCard01-DrzQYyTF.js → CreditCard01-C3QibLrh.js} +1 -1
  14. package/dist/client/assets/{DotsVertical-Dz4LnlpO.js → DotsVertical-1yRdGK_v.js} +1 -1
  15. package/dist/client/assets/{Eye-DBvMA8g9.js → Eye-odHyWcll.js} +1 -1
  16. package/dist/client/assets/{FilterLines-wsSkt2VD.js → FilterLines-DavocdZN.js} +1 -1
  17. package/dist/client/assets/{Globe01-CaBRMTor.js → Globe01-Disdr2M_.js} +1 -1
  18. package/dist/client/assets/{Globe04-BZo2aEIg.js → Globe04-CkgKBLX4.js} +1 -1
  19. package/dist/client/assets/{HardDrive-C_NlDIRU.js → HardDrive-1eaSP0br.js} +1 -1
  20. package/dist/client/assets/{Key01-B3DU0GGv.js → Key01-IDw1ru2e.js} +1 -1
  21. package/dist/client/assets/{LayoutLeft-DqSVLxAq.js → LayoutLeft-B3YhHZ5u.js} +1 -1
  22. package/dist/client/assets/{LinkExternal01-BburGYWV.js → LinkExternal01-B4vZ2Ze0.js} +1 -1
  23. package/dist/client/assets/{LogOut01-DmOIavp4.js → LogOut01-B-W1a3gA.js} +1 -1
  24. package/dist/client/assets/{Monitor01-Df7fsh1A.js → Monitor01-B6Yn_Yup.js} +1 -1
  25. package/dist/client/assets/{Palette-Dt4cehDu.js → Palette-DJYLInqK.js} +1 -1
  26. package/dist/client/assets/{Play-BJiBNh4U.js → Play-SFHHbV5Z.js} +1 -1
  27. package/dist/client/assets/{Plus-CH7cgF_s.js → Plus-CMjdfynY.js} +1 -1
  28. package/dist/client/assets/{SearchLg-DEjBwoo_.js → SearchLg-BOx0rZF7.js} +1 -1
  29. package/dist/client/assets/{SearchMd-DMM0mPEy.js → SearchMd-B7U_-uKd.js} +1 -1
  30. package/dist/client/assets/{Settings02-Bf6xzFuE.js → Settings02-Cbbeju-O.js} +1 -1
  31. package/dist/client/assets/{Share07-CNsIlUv7.js → Share07-DSHtvFdS.js} +1 -1
  32. package/dist/client/assets/{Shield01-BUMWazdX.js → Shield01-AJKtqu6V.js} +1 -1
  33. package/dist/client/assets/{Star01-CX7sehwv.js → Star01-V_cJa9vj.js} +1 -1
  34. package/dist/client/assets/{Stars01-t24DtZ6l.js → Stars01-lyjrfUs0.js} +1 -1
  35. package/dist/client/assets/{Stars02-ClvdUYlR.js → Stars02-rewvvmPz.js} +1 -1
  36. package/dist/client/assets/{Sun-CsIYwDtS.js → Sun-CpZM49b3.js} +1 -1
  37. package/dist/client/assets/{SwitchHorizontal01-DgfOozo_.js → SwitchHorizontal01-dSDj2Pgu.js} +1 -1
  38. package/dist/client/assets/{Tool01-6VXqg1h8.js → Tool01-DEBYMlb3.js} +1 -1
  39. package/dist/client/assets/{Tool02-o2_4P3Xh.js → Tool02-CoqAsydP.js} +1 -1
  40. package/dist/client/assets/{Trash01-lsUUQ2pM.js → Trash01-bA8kHTuW.js} +1 -1
  41. package/dist/client/assets/{TrendUp01-DEjg3YIN.js → TrendUp01-DFPOvByM.js} +1 -1
  42. package/dist/client/assets/{Upload01-pj_BE6mb.js → Upload01-rR1_5Vq_.js} +1 -1
  43. package/dist/client/assets/{User01-CUIQml_a.js → User01-D4VTTM5J.js} +1 -1
  44. package/dist/client/assets/{Users01-C9o463l3.js → Users01-Drw-DHnH.js} +1 -1
  45. package/dist/client/assets/{Users03-BZlok_KE.js → Users03-HteG634u.js} +1 -1
  46. package/dist/client/assets/{X-DA4GerBb.js → X-CnAv-uVp.js} +1 -1
  47. package/dist/client/assets/{XCircle-CIgARBvB.js → XCircle-ByngP7PS.js} +1 -1
  48. package/dist/client/assets/{XClose-DgL7Q41z.js → XClose-CLeFak--.js} +1 -1
  49. package/dist/client/assets/{Zap-Efc2ZBjp.js → Zap-AZ9VmVZ4.js} +1 -1
  50. package/dist/client/assets/{ZapSquare-CjylKLxd.js → ZapSquare-xOnopJUR.js} +1 -1
  51. package/dist/client/assets/{access-gate-Dimm02Jr.js → access-gate-3ESI0-XU.js} +1 -1
  52. package/dist/client/assets/{agent-icon-VJPkjNf1.js → agent-icon-DFAPzr3v.js} +1 -1
  53. package/dist/client/assets/{agents-list-qxyxfodi.js → agents-list-B0ptmmCO.js} +1 -1
  54. package/dist/client/assets/{ai-providers-D-vfsuta.js → ai-providers-Bf9Pbnye.js} +1 -1
  55. package/dist/client/assets/{alert-YY0VcVgA.js → alert-CcPfYaWU.js} +1 -1
  56. package/dist/client/assets/{alert-dialog-BaSzp1WL.js → alert-dialog-Bj-lqnKh.js} +1 -1
  57. package/dist/client/assets/{app-editor-ogsQGgod.js → app-editor-Co52Mgm4.js} +1 -1
  58. package/dist/client/assets/{auth-DecE6kJ-.js → auth-HJuo3oRQ.js} +1 -1
  59. package/dist/client/assets/{auth-catchall-BXW4c-CB.js → auth-catchall-BOgHEVxL.js} +1 -1
  60. package/dist/client/assets/{auth-entry-DWpYkoEn.js → auth-entry-FjY7FWpE.js} +1 -1
  61. package/dist/client/assets/{auth-split-layout-CSM7Dzw1.js → auth-split-layout-Bk6chN0p.js} +1 -1
  62. package/dist/client/assets/{authenticate-and-persist-oauth-DYT80JQR.js → authenticate-and-persist-oauth-Bo-Iw6sZ.js} +1 -1
  63. package/dist/client/assets/{automation-list-row-DvA-jDkk.js → automation-list-row-B0IgOPFf.js} +1 -1
  64. package/dist/client/assets/{automation-runs-4mKhrOMb.js → automation-runs-4YBHAHt7.js} +1 -1
  65. package/dist/client/assets/{automations-Bv1XHLZ3.js → automations-WIMj4wfD.js} +1 -1
  66. package/dist/client/assets/{avatar-Ccj7vaaW.js → avatar-DxHa5crr.js} +1 -1
  67. package/dist/client/assets/{badge-BIEmGyKc.js → badge-CQTU24Ml.js} +1 -1
  68. package/dist/client/assets/{billing-BAwb4E_H.js → billing-ZRLTF4t2.js} +1 -1
  69. package/dist/client/assets/{block-document-CmQtnP4c.js → block-document-DvJQtkTc.js} +1 -1
  70. package/dist/client/assets/{brand-context-WHzdFmjz.js → brand-context-B3fJiaAT.js} +1 -1
  71. package/dist/client/assets/{buckets-Cc1T3LiU.js → buckets-BKnuBT1S.js} +1 -1
  72. package/dist/client/assets/{bulk-category-panel-FA6V08Sn.js → bulk-category-panel-Y6X4LamP.js} +1 -1
  73. package/dist/client/assets/{capability-load-error-ByUDData.js → capability-load-error-DixQxG0b.js} +1 -1
  74. package/dist/client/assets/{card-O8eAb7Ps.js → card-CG-N9Hd_.js} +1 -1
  75. package/dist/client/assets/{cards-LapKxRjO.js → cards-CNjM1_SJ.js} +1 -1
  76. package/dist/client/assets/{category-editor-DW3aqPw3.js → category-editor-fAPUdpo4.js} +1 -1
  77. package/dist/client/assets/{chat-context-CvcG_XD0.js → chat-context-eIfOIkBh.js} +1 -1
  78. package/dist/client/assets/{checkbox-CAdk6Hog.js → checkbox-B_0yP1bR.js} +1 -1
  79. package/dist/client/assets/{cli-auth-success-lsAxZayz.js → cli-auth-success-B8G7KcNq.js} +1 -1
  80. package/dist/client/assets/{collection-detail-BRRU9B5X.js → collection-detail-WjjCmxts.js} +1 -1
  81. package/dist/client/assets/{collection-display-button-Cl4B8lEU.js → collection-display-button-BnU-0oTE.js} +1 -1
  82. package/dist/client/assets/{collection-search-CbL8M8nx.js → collection-search-DCEO-Aiv.js} +1 -1
  83. package/dist/client/assets/{collection-table-wrapper-D0R-jtC0.js → collection-table-wrapper-NbTdTN0r.js} +1 -1
  84. package/dist/client/assets/{collection-tabs-C07VhXwK.js → collection-tabs-CisVdAEc.js} +1 -1
  85. package/dist/client/assets/{command-C1UjWZix.js → command-CNe2z-zb.js} +1 -1
  86. package/dist/client/assets/{commerce-onboarding-D3tK65GG.js → commerce-onboarding-BRw61pDs.js} +1 -1
  87. package/dist/client/assets/{connect-CE98MgLU.js → connect-DvKvynzm.js} +1 -1
  88. package/dist/client/assets/{connection-CNLXOE7I.js → connection-BO0kR_lH.js} +1 -1
  89. package/dist/client/assets/{connection-card-OvtE-Aeh.js → connection-card-B5_7Hwt3.js} +1 -1
  90. package/dist/client/assets/{connection-detail-Cw6eU_TV.js → connection-detail-B-lAdpG4.js} +1 -1
  91. package/dist/client/assets/{connection-form-helpers-CmCakLL1.js → connection-form-helpers-ndCXct6V.js} +1 -1
  92. package/dist/client/assets/{connections-BswoqjoS.js → connections-DqUo2w77.js} +1 -1
  93. package/dist/client/assets/{decopilot-sse-pool-YWHIb7Qb.js → decopilot-sse-pool-AdBYpDln.js} +1 -1
  94. package/dist/client/assets/{dialog-6ATyA9Xm.js → dialog-CpfxMIGS.js} +1 -1
  95. package/dist/client/assets/{domain-settings-DmL0RZdV.js → domain-settings-CBu9r3A1.js} +1 -1
  96. package/dist/client/assets/{drawer-BsgAuu8Q.js → drawer-sKO31Ovm.js} +1 -1
  97. package/dist/client/assets/{dropdown-menu-BSE2oeGm.js → dropdown-menu-Djg6XZ0D.js} +1 -1
  98. package/dist/client/assets/{empty-state-29t0PYVV.js → empty-state-B-zq1u7N.js} +1 -1
  99. package/dist/client/assets/{extract-connection-data-Bw3oKcFQ.js → extract-connection-data-DOkhC5Rx.js} +1 -1
  100. package/dist/client/assets/{file-explorer-Ccy5_ygr.js → file-explorer-4O7m6Uwi.js} +1 -1
  101. package/dist/client/assets/{file-type-icon-DkHsw8q9.js → file-type-icon-CDWtqRuH.js} +1 -1
  102. package/dist/client/assets/{form-Co7brsJ6.js → form-ClkOia2l.js} +1 -1
  103. package/dist/client/assets/{general-B5GeoROJ.js → general-JlV_UD8H.js} +1 -1
  104. package/dist/client/assets/{github-repo-picker-DkA37I3_.js → github-repo-picker-DcZpEA93.js} +1 -1
  105. package/dist/client/assets/{hooks-B_-VM6ZX.js → hooks-GqfCwZi9.js} +1 -1
  106. package/dist/client/assets/{index-BcAPxZGN.js → index-BCMqtt4x.js} +1 -1
  107. package/dist/client/assets/{index-Bz3Oue1D.js → index-BReDO0SM.js} +1 -1
  108. package/dist/client/assets/{index-CK2N8xof.js → index-BVsiYOL1.js} +5 -5
  109. package/dist/client/assets/{index-COlLwef7.js → index-BZ_Hq36w.js} +1 -1
  110. package/dist/client/assets/{index-zUiSruJv.js → index-BhSBUjFQ.js} +3 -3
  111. package/dist/client/assets/{index-DN_xY6G5.js → index-CdlD77hI.js} +1 -1
  112. package/dist/client/assets/{index-Ce_ook4Q.js → index-Cs4Y2n-v.js} +1 -1
  113. package/dist/client/assets/{index-BrAD83wa.js → index-D5o-NzFN.js} +1 -1
  114. package/dist/client/assets/{index-BUAvCT1-.js → index-DET8ETMz.js} +1 -1
  115. package/dist/client/assets/{index-DFu2rSFa.js → index-LkbvE0kJ.js} +1 -1
  116. package/dist/client/assets/{index-redirect-BOifzy0H.js → index-redirect-CKNzwFrn.js} +1 -1
  117. package/dist/client/assets/{input-Rh1CljCe.js → input-C-Ds0Orp.js} +1 -1
  118. package/dist/client/assets/{integration-icon-BcbOkM50.js → integration-icon-BuTUdtR3.js} +1 -1
  119. package/dist/client/assets/{invite-member-dialog-crInf8b0.js → invite-member-dialog-OMotdj8i.js} +1 -1
  120. package/dist/client/assets/{label-B_vJTSgz.js → label-BmOkqdID.js} +1 -1
  121. package/dist/client/assets/{layout-DLVXRHZO.js → layout-BqFY2eOj.js} +1 -1
  122. package/dist/client/assets/{login-D89sB8dk.js → login-CSO-siQ5.js} +1 -1
  123. package/dist/client/assets/{mcp-oauth-DQb7Q4jY.js → mcp-oauth-BsUt_0Tq.js} +1 -1
  124. package/dist/client/assets/{members-Dldm_nM6.js → members-BD0jHl7v.js} +1 -1
  125. package/dist/client/assets/{monaco-editor-ZtSJIRKn.js → monaco-editor-CXeVG00h.js} +1 -1
  126. package/dist/client/assets/{monitoring-stats-row-Dfdhx0bJ.js → monitoring-stats-row-Ok2k_F5B.js} +1 -1
  127. package/dist/client/assets/{multi-select-xP3U2jT0.js → multi-select-B1LHm6I-.js} +1 -1
  128. package/dist/client/assets/{oauth-callback-CHdNnPM7.js → oauth-callback-CwMlHteh.js} +1 -1
  129. package/dist/client/assets/{oauth-callback-ai-provider-CwUGe9-n.js → oauth-callback-ai-provider-BJvu1jYn.js} +1 -1
  130. package/dist/client/assets/{onboarding-CesqLPbT.js → onboarding-DnLPUgLI.js} +1 -1
  131. package/dist/client/assets/{org-layout-YiNqH6jw.js → org-layout-BJa2RiSr.js} +1 -1
  132. package/dist/client/assets/{organization-choice-COd54ETO.js → organization-choice-HsO3IIEu.js} +1 -1
  133. package/dist/client/assets/{orgs-Cz0uaaqb.js → orgs-q6yyEB7R.js} +1 -1
  134. package/dist/client/assets/{page-seo-form-BGuG_6F3.js → page-seo-form-BSMaBG-f.js} +1 -1
  135. package/dist/client/assets/{popover-DOcF1z_v.js → popover-Bxj8hA4h.js} +1 -1
  136. package/dist/client/assets/{post-editor-CbjjhRLF.js → post-editor-J-XVyGE8.js} +1 -1
  137. package/dist/client/assets/{primitives-C4i60ijL.js → primitives-BcpywZZ8.js} +1 -1
  138. package/dist/client/assets/{profile-CeCw8nZ5.js → profile-BHvfZt1E.js} +1 -1
  139. package/dist/client/assets/{project-app-view-DkN9dcYv.js → project-app-view-CSYB5vig.js} +1 -1
  140. package/dist/client/assets/record-editor-BeSHwsT4.js +1 -0
  141. package/dist/client/assets/{redirect-editor-YYGWLlJ1.js → redirect-editor-CGj3kLm_.js} +1 -1
  142. package/dist/client/assets/registry-CHVE8KnD.js +2 -0
  143. package/dist/client/assets/{registry-layout-shV2_3JF.js → registry-layout-CRrj2CSN.js} +1 -1
  144. package/dist/client/assets/{reports-CQLJ-EOh.js → reports-B2UwC2kV.js} +22 -22
  145. package/dist/client/assets/{require-capability-B-GDGKUM.js → require-capability-DoNQPLLi.js} +1 -1
  146. package/dist/client/assets/{required-auth-layout-k292n9Pg.js → required-auth-layout-CJUHF26h.js} +1 -1
  147. package/dist/client/assets/{reset-password-Boo57BD2.js → reset-password-D6jdG42B.js} +1 -1
  148. package/dist/client/assets/{roles-fDKOKjaG.js → roles-DGp2qF1k.js} +1 -1
  149. package/dist/client/assets/{search-input-HeHkUWW8.js → search-input-DNJngBgA.js} +1 -1
  150. package/dist/client/assets/{secrets-B919iTKV.js → secrets-DkdMNSpW.js} +1 -1
  151. package/dist/client/assets/{sections-editor-CxU0FgEx.js → sections-editor-4IygaXXP.js} +1 -1
  152. package/dist/client/assets/{select-zqlIJQsk.js → select-DyYtIAIR.js} +1 -1
  153. package/dist/client/assets/{select-model-Th52BIx3.js → select-model-C8XDCyLQ.js} +1 -1
  154. package/dist/client/assets/{self-tool-result-BKwvpqNd.js → self-tool-result-Cf1-wDwO.js} +1 -1
  155. package/dist/client/assets/{seo-editor-CCS9eIhZ.js → seo-editor-CwXZp6Hq.js} +1 -1
  156. package/dist/client/assets/{settings-layout-DAnxiD-T.js → settings-layout-DWaTIlUE.js} +1 -1
  157. package/dist/client/assets/{settings-section-CfSo7nwa.js → settings-section-JC3iPsfa.js} +1 -1
  158. package/dist/client/assets/{shell-controls-BsZtQrwZ.js → shell-controls-4tN6cZcb.js} +1 -1
  159. package/dist/client/assets/{shell-layout-BIkhx8DU.js → shell-layout-DelK1l0s.js} +1 -1
  160. package/dist/client/assets/{sidebar-BXJUywWP.js → sidebar-CdN7y-oZ.js} +1 -1
  161. package/dist/client/assets/{skeleton-DMzpherQ.js → skeleton-D2rX-wFT.js} +1 -1
  162. package/dist/client/assets/{spinner-D7646OGs.js → spinner-CgIfhDcV.js} +1 -1
  163. package/dist/client/assets/{sso-BAz8TKJO.js → sso-Cc63rifA.js} +1 -1
  164. package/dist/client/assets/{store-CbdUAUVM.js → store-aLtghZFJ.js} +1 -1
  165. package/dist/client/assets/store-registry-BYvmxcfP.js +2 -0
  166. package/dist/client/assets/{studio-tools-B_bt7Swx.js → studio-tools-BEhBpPdk.js} +1 -1
  167. package/dist/client/assets/{switch-fWQ3omSD.js → switch-D_Gc05EJ.js} +1 -1
  168. package/dist/client/assets/{synced-repos-CC33JI6Q.js → synced-repos-Cl_S4gb8.js} +1 -1
  169. package/dist/client/assets/{tab-id-DM28xsnS.js → tab-id-BVZz2HwZ.js} +1 -1
  170. package/dist/client/assets/{table-fId7qJNc.js → table-DhObwI3B.js} +1 -1
  171. package/dist/client/assets/{tabs-DnfU3xxb.js → tabs-CyknFcwF.js} +1 -1
  172. package/dist/client/assets/{textarea-LzAVu7D3.js → textarea-DTuFQzPs.js} +1 -1
  173. package/dist/client/assets/{toggle-group-Bi7ycBfW.js → toggle-group-BYUy7yAJ.js} +1 -1
  174. package/dist/client/assets/{toolbar-C8wAn6M-.js → toolbar-Buy-Qrty.js} +1 -1
  175. package/dist/client/assets/{tooltip-DWDaDvOQ.js → tooltip-VCgWirKW.js} +1 -1
  176. package/dist/client/assets/{use-ai-providers-IN_Lc4N5.js → use-ai-providers-iwiQIKNO.js} +1 -1
  177. package/dist/client/assets/{use-automations-Bn8P7CjA.js → use-automations-D_Vugn7M.js} +1 -1
  178. package/dist/client/assets/{use-autosave-Byrj3HHv.js → use-autosave-BOBUiYgH.js} +1 -1
  179. package/dist/client/assets/{use-capability-CSe2vHsE.js → use-capability-DZ6GjOiO.js} +1 -1
  180. package/dist/client/assets/{use-clock-tick-zLSt-SvH.js → use-clock-tick-CQhbA3Zj.js} +1 -1
  181. package/dist/client/assets/{use-connection-zLrh9Cuf.js → use-connection-6ojr7GjP.js} +1 -1
  182. package/dist/client/assets/{use-copy-DgkgaNPy.js → use-copy-BgF2A1X_.js} +1 -1
  183. package/dist/client/assets/{use-create-virtual-mcp-Bcp0A32E.js → use-create-virtual-mcp-M0mlrEYm.js} +1 -1
  184. package/dist/client/assets/{use-debounced-autosave-DQpfAt4b.js → use-debounced-autosave-DBsULjUR.js} +1 -1
  185. package/dist/client/assets/{use-debounced-value-zALzkE8P.js → use-debounced-value-CCA9kVfE.js} +1 -1
  186. package/dist/client/assets/{use-deco-credits-CzKZzmP9.js → use-deco-credits-9c5owsXg.js} +1 -1
  187. package/dist/client/assets/{use-decopilot-events-C4s2uk6V.js → use-decopilot-events-BixTVs6f.js} +1 -1
  188. package/dist/client/assets/{use-delete-connection-sCkFK76g.js → use-delete-connection-B9ArQFXO.js} +1 -1
  189. package/dist/client/assets/{use-deployment-admin-DXmrQXr5.js → use-deployment-admin-C8JjcKRx.js} +1 -1
  190. package/dist/client/assets/{use-file-configs-IdVdbi5D.js → use-file-configs-D2dV5g_m.js} +1 -1
  191. package/dist/client/assets/{use-infinite-scroll-DRdB9nzV.js → use-infinite-scroll-Uv9OSITw.js} +1 -1
  192. package/dist/client/assets/{use-join-requests-DJVFJrwY.js → use-join-requests-DkP8yY9x.js} +1 -1
  193. package/dist/client/assets/{use-mcp-client-C6Fj1nqs.js → use-mcp-client-Klx7Tc0I.js} +1 -1
  194. package/dist/client/assets/{use-mcp-tools-BLZHAwxE.js → use-mcp-tools-Ct-Td2jG.js} +1 -1
  195. package/dist/client/assets/{use-members-D_rhpBEU.js → use-members-QcQn7ivc.js} +1 -1
  196. package/dist/client/assets/{use-mobile-Dki0CKRG.js → use-mobile-YZx5-gne.js} +1 -1
  197. package/dist/client/assets/{use-navigate-to-agent-3eoNvQTF.js → use-navigate-to-agent-33xb87jb.js} +1 -1
  198. package/dist/client/assets/{use-open-billing-url-A_16M4Cv.js → use-open-billing-url-C-jGNxq7.js} +1 -1
  199. package/dist/client/assets/{use-org-auth-client-DlzpZwRe.js → use-org-auth-client-B5Cu35-p.js} +1 -1
  200. package/dist/client/assets/{use-org-sso-CXe1qn6Y.js → use-org-sso-Csnh1NFJ.js} +1 -1
  201. package/dist/client/assets/{use-organization-roles-ER6yZdJ6.js → use-organization-roles-D0_vaB2w.js} +1 -1
  202. package/dist/client/assets/{use-organization-settings-BhV-sHza.js → use-organization-settings-DoFbjuju.js} +1 -1
  203. package/dist/client/assets/{use-registry-connections-D9ufbGFn.js → use-registry-connections-D_Z2d6xL.js} +1 -1
  204. package/dist/client/assets/{use-secrets-DPwj2rp7.js → use-secrets-CNuDOCpO.js} +1 -1
  205. package/dist/client/assets/{use-section-preview-base-DuGsY2RE.js → use-section-preview-base-Bc2fJPvu.js} +1 -1
  206. package/dist/client/assets/{use-status-sounds-tohttoG3.js → use-status-sounds-DhKr_WAU.js} +1 -1
  207. package/dist/client/assets/{use-tags-Cy3tUw1Z.js → use-tags-BLDAZVym.js} +1 -1
  208. package/dist/client/assets/{use-view-mode-DJDKG4gc.js → use-view-mode-DPqTuLJJ.js} +1 -1
  209. package/dist/client/assets/{use-virtual-mcp-MMFoczNM.js → use-virtual-mcp-YQKj8FPv.js} +1 -1
  210. package/dist/client/assets/useInfiniteQuery-B2mzkKMe.js +1 -0
  211. package/dist/client/assets/{useRouterState-Bo6iWHX4.js → useRouterState-D9G6qreG.js} +1 -1
  212. package/dist/client/assets/useSuspenseInfiniteQuery-DQGAX-hV.js +1 -0
  213. package/dist/client/assets/{users-DVopkff3.js → users-sZzx1W5U.js} +1 -1
  214. package/dist/client/assets/{variant-calendar-CozXuPi2.js → variant-calendar-DumutO13.js} +1 -1
  215. package/dist/client/assets/{view-mode-toggle-BI9loPTJ.js → view-mode-toggle-VD2zVNLa.js} +1 -1
  216. package/dist/client/index.html +1 -1
  217. package/dist/server/cli.js +262 -262
  218. package/dist/server/server.js +187 -187
  219. package/package.json +1 -1
  220. package/dist/client/assets/record-editor-BJAyc8QW.js +0 -1
  221. package/dist/client/assets/registry-CG6fGFCs.js +0 -2
  222. package/dist/client/assets/store-registry-DlCZz0ni.js +0 -2
  223. package/dist/client/assets/useInfiniteQuery-DyeAaggD.js +0 -1
  224. package/dist/client/assets/useSuspenseInfiniteQuery-D_iaHlim.js +0 -1
@@ -1 +1 @@
1
- import{c as M,b as B,j as t,y as Ut,B as te,Z as qt,$ as Kt,a2 as ht,a1 as pt,e as Gt,a as ae,r as H,aR as Xt,d as st,s as Qt,m as X,t as U,w as Wt,k as ke,p as R,F as oe,f as ot,u as it,L as Yt,D as Jt,I as Zt,G as en,K as at,o as tn,n as nn}from"./index-zUiSruJv.js";import{i as sn}from"./ChevronRight-CE8UVD3O.js";import{i as on}from"./X-DA4GerBb.js";import{aD as an,Q as ln,A as xt,g as rn,ae as cn}from"./agent-icon-VJPkjNf1.js";import{t as jt}from"./ChevronDown-BQ-Mj20Q.js";import{T as Ce,a as ye,c as Se}from"./tooltip-DWDaDvOQ.js";import{u as bt,d as vt,c as Ct}from"./sidebar-BXJUywWP.js";import{a as lt,i as dn,f as un,S as mn,u as fn}from"./use-mcp-client-C6Fj1nqs.js";import{a as gn,u as hn}from"./use-virtual-mcp-MMFoczNM.js";import{a as Le,b as yt,P as St}from"./popover-DOcF1z_v.js";import{i as Ee}from"./Check-CqTwbGPS.js";import{s as Ne}from"./Plus-CH7cgF_s.js";import{i as Nt}from"./SearchMd-DMM0mPEy.js";import{s as wt}from"./XClose-DgL7Q41z.js";import{A as pn,a as xn,b as jn,c as bn,e as vn,f as Cn,g as yn}from"./alert-dialog-BaSzp1WL.js";import{d as W,F as nt,a as Y,e as J,b as Z,f as Sn,c as ee}from"./form-Co7brsJ6.js";import{I as ie}from"./input-Rh1CljCe.js";import{S as Nn}from"./spinner-D7646OGs.js";import{T as _t}from"./toolbar-C8wAn6M-.js";import{S as wn}from"./skeleton-DMzpherQ.js";import{D as Dt,a as kt,b as At,c as _n,g as Dn,e as kn,f as An}from"./drawer-BsgAuu8Q.js";import{u as It}from"./use-mobile-Dki0CKRG.js";import{a as In,G as zn}from"./github-repo-picker-DkA37I3_.js";import{g as Tn,b as Pn,a as zt}from"./hooks-B_-VM6ZX.js";import{u as On,g as Mn,a as $n,b as Fn}from"./use-navigate-to-agent-3eoNvQTF.js";import{a as Bn,c as Tt}from"./agent-capabilities-cXfbMfjV.js";import{u as Pt}from"./shell-layout-BIkhx8DU.js";import{f as Ln}from"./reusable-new-chat-CouMjkYR.js";import{C as En}from"./collection-search-CbL8M8nx.js";import{g as Vn,a as Rn,b as Hn,e as Un}from"./extract-connection-data-Bw3oKcFQ.js";import{u as Ot,a as Mt,g as qn,C as Ye}from"./connection-card-OvtE-Aeh.js";import{e as $t,d as Ft,a as Bt,b as Lt,h as Kn,c as Gn}from"./dialog-6ATyA9Xm.js";import{S as Xn,a as Qn,b as Wn,c as Yn,d as De}from"./select-zqlIJQsk.js";import{T as Jn}from"./textarea-LzAVu7D3.js";import{b as Et}from"./use-connection-zLrh9Cuf.js";import{n as Be,i as Je}from"./Tool02-o2_4P3Xh.js";import{s as Ze}from"./Star01-CX7sehwv.js";import{c as Zn,i as $e,a as ut,E as es,p as ts,b as ns,d as ss}from"./connection-form-helpers-CmCakLL1.js";import{a as et}from"./authenticate-and-persist-oauth-DYT80JQR.js";import{g as os}from"./connection-slug-eyAPH6o3.js";import{C as is}from"./collection-tabs-C07VhXwK.js";import{u as mt}from"./use-infinite-scroll-DRdB9nzV.js";import{B as Fe}from"./badge-BIEmGyKc.js";import{u as as}from"./useSuspenseInfiniteQuery-D_iaHlim.js";import{g as Ve}from"./metadata-dUsYcpuu.js";import{u as ls}from"./studio-tools-B_bt7Swx.js";import{u as rs}from"./use-ai-providers-IN_Lc4N5.js";const cs="https://decoims.com/image?src=decocms%2F06b54678-5335-4671-b63a-e13d9e541155%2Fagataesteves.png&quality=original&fit=cover&width=160&height=160";function ds(){const n=M.c(13),e=B();let s;n[0]===Symbol.for("react.memo_cache_sentinel")?(s=t.jsx("img",{src:"/logos/summit/monte-carlo.svg",alt:"Monte Carlo",className:"h-14 w-[112px] shrink-0 self-start object-contain object-left brightness-0 invert"}),n[0]=s):s=n[0];let o;n[1]!==e?(o=e("routes.commerceOnboarding.connectModal.quote"),n[1]=e,n[2]=o):o=n[2];let i;n[3]!==o?(i=t.jsxs("blockquote",{className:"text-lg font-medium leading-[1.45] lg:text-xl",children:["“",o,"”"]}),n[3]=o,n[4]=i):i=n[4];let a;n[5]===Symbol.for("react.memo_cache_sentinel")?(a=t.jsx("img",{src:cs,alt:"",className:"size-10 shrink-0 rounded-full object-cover",loading:"lazy"}),n[5]=a):a=n[5];let l;n[6]!==e?(l=e("routes.commerceOnboarding.connectModal.quoteAuthor"),n[6]=e,n[7]=l):l=n[7];let c;n[8]!==l?(c=t.jsxs("figcaption",{className:"flex items-center gap-2.5",children:[a,t.jsx("span",{className:"text-base font-medium",children:l})]}),n[8]=l,n[9]=c):c=n[9];let r;return n[10]!==i||n[11]!==c?(r=t.jsxs("div",{className:"relative flex flex-col gap-8 text-white",children:[s,i,c]}),n[10]=i,n[11]=c,n[12]=r):r=n[12],r}function us(){const n=M.c(19),e=B();let s;n[0]!==e?(s=e("routes.commerceOnboarding.connectModal.trustRevoke"),n[0]=e,n[1]=s):s=n[1];let o;n[2]!==s?(o={Icon:an,label:s},n[2]=s,n[3]=o):o=n[3];let i;n[4]!==e?(i=e("routes.commerceOnboarding.connectModal.trustEncrypted"),n[4]=e,n[5]=i):i=n[5];let a;n[6]!==i?(a={Icon:Ut,label:i},n[6]=i,n[7]=a):a=n[7];let l;n[8]!==e?(l=e("routes.commerceOnboarding.connectModal.trustNeverSold"),n[8]=e,n[9]=l):l=n[9];let c;n[10]!==l?(c={Icon:ln,label:l},n[10]=l,n[11]=c):c=n[11];let r;n[12]!==o||n[13]!==a||n[14]!==c?(r=[o,a,c],n[12]=o,n[13]=a,n[14]=c,n[15]=r):r=n[15];const u=r;let m;n[16]===Symbol.for("react.memo_cache_sentinel")?(m=t.jsx("div",{className:"h-px w-full bg-white/15"}),n[16]=m):m=n[16];let f;return n[17]!==u?(f=t.jsxs("div",{className:"relative flex flex-col gap-2.5 text-white",children:[m,t.jsx("ul",{className:"mt-1 flex flex-col gap-2.5",children:u.map(ms)})]}),n[17]=u,n[18]=f):f=n[18],f}function ms(n){const{Icon:e,label:s}=n;return t.jsxs("li",{className:"flex items-center gap-2.5 text-[13px] leading-tight text-white/70",children:[t.jsx(e,{className:"size-4 shrink-0 opacity-85"}),s]},s)}function Xo(n){const e=M.c(22),{siteHost:s,footer:o,onClose:i,children:a}=n,l=B(),c=s?`https://www.google.com/s2/favicons?domain=${s}&sz=128`:null;let r;e[0]!==i||e[1]!==l?(r=i&&t.jsx("button",{type:"button",onClick:i,"aria-label":l("routes.commerceOnboarding.connectModal.close"),className:"absolute right-3 top-3 z-10 flex size-9 items-center justify-center rounded-lg text-muted-foreground transition-colors hover:bg-black/10 hover:text-foreground lg:text-white/80 lg:hover:bg-white/15 lg:hover:text-white",children:t.jsx(on,{size:18})}),e[0]=i,e[1]=l,e[2]=r):r=e[2];let u,m;e[3]===Symbol.for("react.memo_cache_sentinel")?(u=t.jsx("img",{src:"/logos/deco logo.svg",alt:"Deco",className:"size-7 shrink-0 dark:hidden"}),m=t.jsx("img",{src:"/logos/deco logo negative.svg",alt:"Deco",className:"hidden size-7 shrink-0 dark:block"}),e[3]=u,e[4]=m):(u=e[3],m=e[4]);let f;e[5]!==c||e[6]!==s?(f=s&&t.jsxs(t.Fragment,{children:[t.jsx(sn,{size:16,className:"shrink-0 text-foreground/25"}),c&&t.jsx("span",{className:"flex size-4 shrink-0 items-center justify-center overflow-hidden rounded bg-white",children:t.jsx("img",{src:c,alt:"",className:"size-full"})}),t.jsx("span",{className:"truncate text-[15px] leading-tight text-muted-foreground",children:s})]}),e[5]=c,e[6]=s,e[7]=f):f=e[7];let d;e[8]!==f?(d=t.jsxs("div",{className:"flex items-center gap-2",children:[u,m,f]}),e[8]=f,e[9]=d):d=e[9];let h;e[10]!==o?(h=t.jsx("div",{className:"flex shrink-0 flex-col gap-3",children:o}),e[10]=o,e[11]=h):h=e[11];let C;e[12]!==a||e[13]!==d||e[14]!==h?(C=t.jsxs("div",{className:"flex min-h-0 flex-1 flex-col gap-8 bg-background p-6 lg:p-8",children:[d,a,h]}),e[12]=a,e[13]=d,e[14]=h,e[15]=C):C=e[15];let p,g;e[16]===Symbol.for("react.memo_cache_sentinel")?(p=t.jsx("img",{src:"https://decoims.com/image?src=decocms%2F8191643a-1947-4c30-afb4-36b8073c90fb%2Fbg-quote.png&quality=original&fit=cover&width=880",alt:"",className:"absolute inset-0 size-full object-cover"}),g=t.jsx("div",{className:"absolute inset-0 bg-black/20"}),e[16]=p,e[17]=g):(p=e[16],g=e[17]);let j;e[18]===Symbol.for("react.memo_cache_sentinel")?(j=t.jsxs("aside",{className:"relative hidden shrink-0 overflow-hidden lg:flex lg:w-[440px] lg:flex-col lg:p-14",children:[p,g,t.jsxs("div",{className:"relative z-10 flex h-full flex-col",children:[t.jsx("div",{className:"flex-1"}),t.jsx(ds,{}),t.jsx("div",{className:"flex-1"}),t.jsx(us,{})]})]}),e[18]=j):j=e[18];let b;return e[19]!==r||e[20]!==C?(b=t.jsxs("div",{className:"relative flex min-h-0 flex-1 flex-col lg:flex-row",children:[r,C,j]}),e[19]=r,e[20]=C,e[21]=b):b=e[21],b}function Qo(n){const e=M.c(5),{ready:s,pending:o,label:i,onClick:a,children:l}=n,c=o||!s,r=s&&!o?l:null;let u;return e[0]!==i||e[1]!==a||e[2]!==c||e[3]!==r?(u=t.jsxs(te,{type:"button",size:"lg",className:"h-auto min-h-12 w-full whitespace-normal rounded-lg py-3 text-center text-base font-medium leading-tight",onClick:a,disabled:c,children:[i,r]}),e[0]=i,e[1]=a,e[2]=c,e[3]=r,e[4]=u):u=e[4],u}function ft(n){return n.toLowerCase().trim().replace(/[^a-z0-9\s_-]+/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const fs=qt({name:Kt().min(2,"Organization name is required")});function gs(n){const e=M.c(66),{open:s,onOpenChange:o}=n,i=B();let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a={resolver:ht(fs),defaultValues:{name:""}},e[0]=a):a=e[0];const l=pt(a);let c;e[1]!==i?(c=async V=>{const $=ft(V.name);if(!$)throw new Error(i("common.createOrganizationDialog.invalidSlug"));const K=await ae.organization.create({name:V.name,slug:$});if(K?.error)throw new Error(K.error.message||i("common.createOrganizationDialog.failedToCreate"));const q=K?.data?.slug??$;if(!q)throw new Error(i("common.createOrganizationDialog.failedToCreate"));return{orgSlug:q}},e[1]=i,e[2]=c):c=e[2];let r;e[3]===Symbol.for("react.memo_cache_sentinel")?(r=hs,e[3]=r):r=e[3];let u;e[4]!==c?(u={mutationFn:c,onSuccess:r},e[4]=c,e[5]=u):u=e[5];const m=Gt(u);let f;e[6]!==m.error||e[7]!==i?(f=m.error instanceof Error?m.error.message:m.error?i("common.createOrganizationDialog.failedToCreateGeneric"):null,e[6]=m.error,e[7]=i,e[8]=f):f=e[8];const d=f;let h;e[9]!==i?(h=i("common.createOrganizationDialog.title"),e[9]=i,e[10]=h):h=e[10];let C;e[11]!==h?(C=t.jsx(pn,{children:h}),e[11]=h,e[12]=C):C=e[12];let p;e[13]!==i?(p=i("common.createOrganizationDialog.description"),e[13]=i,e[14]=p):p=e[14];let g;e[15]!==p?(g=t.jsx(xn,{children:p}),e[15]=p,e[16]=g):g=e[16];let j;e[17]!==C||e[18]!==g?(j=t.jsxs(jn,{children:[C,g]}),e[17]=C,e[18]=g,e[19]=j):j=e[19];let b;if(e[20]!==m||e[21]!==l){let V;e[23]!==m?(V=$=>m.mutateAsync($),e[23]=m,e[24]=V):V=e[24],b=l.handleSubmit(V),e[20]=m,e[21]=l,e[22]=b}else b=e[22];let v;e[25]!==l.formState.isSubmitting||e[26]!==i?(v=V=>{const{field:$}=V;return t.jsxs(Y,{children:[t.jsx(J,{children:i("common.createOrganizationDialog.nameLabel")}),t.jsx(Z,{children:t.jsx(ie,{...$,placeholder:i("common.createOrganizationDialog.namePlaceholder"),disabled:l.formState.isSubmitting})}),t.jsx(Sn,{children:i("common.createOrganizationDialog.nameDescription")}),$.value&&t.jsxs("div",{className:"text-xs text-muted-foreground mt-1",children:[i("common.createOrganizationDialog.urlLabel")," ",t.jsxs("span",{className:"font-mono",children:[typeof window<"u"?globalThis.location.origin:"","/",ft($.value)]})]}),t.jsx(ee,{})]})},e[25]=l.formState.isSubmitting,e[26]=i,e[27]=v):v=e[27];let N;e[28]!==l.control||e[29]!==v?(N=t.jsx(W,{control:l.control,name:"name",render:v}),e[28]=l.control,e[29]=v,e[30]=N):N=e[30];let w;e[31]!==d?(w=d&&t.jsx("div",{className:"text-destructive text-sm mt-2",children:d}),e[31]=d,e[32]=w):w=e[32];const z=l.formState.isSubmitting;let P;e[33]!==m||e[34]!==l?(P=()=>{m.reset(),l.reset()},e[33]=m,e[34]=l,e[35]=P):P=e[35];let x;e[36]!==i?(x=i("common.createOrganizationDialog.cancel"),e[36]=i,e[37]=x):x=e[37];let _;e[38]!==l.formState.isSubmitting||e[39]!==P||e[40]!==x?(_=t.jsx(bn,{disabled:z,onClick:P,children:x}),e[38]=l.formState.isSubmitting,e[39]=P,e[40]=x,e[41]=_):_=e[41];const T=!l.formState.isValid||l.formState.isSubmitting;let S;e[42]!==l.formState.isSubmitting||e[43]!==i?(S=l.formState.isSubmitting?t.jsxs("span",{className:"flex items-center gap-2",children:[t.jsx(Nn,{size:"xs"})," ",i("common.createOrganizationDialog.creating")]}):i("common.createOrganizationDialog.createButton"),e[42]=l.formState.isSubmitting,e[43]=i,e[44]=S):S=e[44];let y;e[45]!==T||e[46]!==S?(y=t.jsx(te,{type:"submit",variant:"default",disabled:T,children:S}),e[45]=T,e[46]=S,e[47]=y):y=e[47];let I;e[48]!==_||e[49]!==y?(I=t.jsxs(vn,{children:[_,y]}),e[48]=_,e[49]=y,e[50]=I):I=e[50];let k;e[51]!==b||e[52]!==N||e[53]!==w||e[54]!==I?(k=t.jsxs("form",{className:"space-y-6",onSubmit:b,autoComplete:"off",children:[N,w,I]}),e[51]=b,e[52]=N,e[53]=w,e[54]=I,e[55]=k):k=e[55];let A;e[56]!==l||e[57]!==k?(A=t.jsx(nt,{...l,children:k}),e[56]=l,e[57]=k,e[58]=A):A=e[58];let O;e[59]!==j||e[60]!==A?(O=t.jsxs(Cn,{children:[j,A]}),e[59]=j,e[60]=A,e[61]=O):O=e[61];let E;return e[62]!==o||e[63]!==s||e[64]!==O?(E=t.jsx(yn,{open:s,onOpenChange:o,children:O}),e[62]=o,e[63]=s,e[64]=O,e[65]=E):E=e[65],E}function hs(n){const{orgSlug:e}=n;window.location.href=`/${e}`}function Vt(){const n=H.useContext(Xt),{data:e,refetch:s}=n.hooks.useListUserInvitations();return{invitations:(e??[]).filter(i=>i.status==="pending"&&new Date(i.expiresAt)>new Date),refetch:()=>s?.()}}function ps(n){let e=0;for(let o=0;o<n.length;o++)e=n.charCodeAt(o)+((e<<5)-e);const s=Math.abs(e)%360;return{backgroundColor:`hsl(${s} 55% 70%)`,color:`hsl(${s} 55% 20%)`}}function rt(n){const e=M.c(13),{org:s,size:o}=n,i=o===void 0?"sm":o,a=i==="xs"?"size-5":"size-6",l=i==="xs"?"text-[9px]":"text-xs";let c;e[0]!==a?(c=X(a,"shrink-0 rounded-md flex items-center justify-center border border-border/50 overflow-hidden"),e[0]=a,e[1]=c):c=e[1];let r;e[2]!==s.logo||e[3]!==s.name?(r=s.logo?void 0:ps(s.name),e[2]=s.logo,e[3]=s.name,e[4]=r):r=e[4];let u;e[5]!==s.logo||e[6]!==s.name||e[7]!==l?(u=s.logo?t.jsx("img",{src:s.logo,alt:"",className:"size-full object-cover"}):t.jsx("span",{className:X("font-semibold leading-none",l),children:s.name.slice(0,2).toUpperCase()}),e[5]=s.logo,e[6]=s.name,e[7]=l,e[8]=u):u=e[8];let m;return e[9]!==c||e[10]!==r||e[11]!==u?(m=t.jsx("div",{className:c,style:r,children:u}),e[9]=c,e[10]=r,e[11]=u,e[12]=m):m=e[12],m}function xs({invitation:n,onChanged:e}){const s=B(),[o,i]=H.useState(!1),a=n.organizationName??s("header.orgSwitcher.unknownOrganization"),l=async()=>{i(!0);try{const u=await ae.organization.acceptInvitation({invitationId:n.id});if(u.error){U.error(u.error.message),i(!1);return}}catch{U.error(s("header.orgSwitcher.failedToAcceptInvitation")),i(!1);return}U.success(s("header.orgSwitcher.joined",{name:a})),Wt();let r;try{r=(await ae.organization.getFullOrganization({query:{organizationId:n.organizationId}}))?.data?.slug}catch{}window.location.href=r?`/${r}`:"/"},c=async()=>{i(!0);try{const r=await ae.organization.rejectInvitation({invitationId:n.id});if(r.error){U.error(r.error.message),i(!1);return}U.success(s("header.orgSwitcher.invitationDeclined")),i(!1),e()}catch{U.error(s("header.orgSwitcher.failedToDeclineInvitation")),i(!1)}};return t.jsxs("div",{className:"flex items-center gap-3 rounded-md border border-dashed border-border px-3 py-2.5",children:[t.jsx(rt,{org:{name:a},size:"sm"}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("p",{className:"truncate text-sm font-medium",children:a}),t.jsx("p",{className:"truncate text-xs text-muted-foreground",children:s("header.orgSwitcher.invitedToJoin")})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[t.jsx(te,{size:"sm",variant:"default",className:"h-7 text-xs",onClick:l,disabled:o,children:s("header.orgSwitcher.accept")}),t.jsx(te,{size:"icon",variant:"ghost",className:"size-7 text-muted-foreground",onClick:c,disabled:o,"aria-label":s("header.orgSwitcher.declineInvitationTo",{name:a}),children:t.jsx(wt,{size:14})})]})]})}function js(n){const e=M.c(32),{orgParam:s,onSelectOrg:o,onCreateOrg:i}=n,a=B(),{data:l}=Qt(),{invitations:c,refetch:r}=Vt();let u;e[0]!==s?(u=(k,A)=>k.slug===s?-1:A.slug===s?1:k.name.localeCompare(A.name),e[0]=s,e[1]=u):u=e[1];const m=[...l??[]].sort(u),[f,d]=H.useState(""),h=f.toLowerCase(),C=h?m.filter(k=>k.name.toLowerCase().includes(h)||k.slug.toLowerCase().includes(h)):m;let p;e[2]===Symbol.for("react.memo_cache_sentinel")?(p=t.jsx(Nt,{size:16,className:"shrink-0 text-muted-foreground/60"}),e[2]=p):p=e[2];let g;e[3]===Symbol.for("react.memo_cache_sentinel")?(g=k=>d(k.target.value),e[3]=g):g=e[3];let j;e[4]!==f?(j=k=>k.key==="Escape"&&f&&d(""),e[4]=f,e[5]=j):j=e[5];let b;e[6]!==a?(b=a("header.orgSwitcher.searchOrganizations"),e[6]=a,e[7]=b):b=e[7];let v;e[8]!==f||e[9]!==j||e[10]!==b?(v=t.jsx("input",{"data-org-switcher-search":!0,autoFocus:!0,type:"text",value:f,onChange:g,onKeyDown:j,placeholder:b,className:"flex-1 min-w-0 bg-transparent text-sm outline-none placeholder:text-muted-foreground/60"}),e[8]=f,e[9]=j,e[10]=b,e[11]=v):v=e[11];let N;e[12]===Symbol.for("react.memo_cache_sentinel")?(N=t.jsx(Ne,{size:16}),e[12]=N):N=e[12];let w;e[13]!==i?(w=t.jsx("button",{type:"button",onClick:i,className:"flex items-center justify-center size-7 rounded-md text-muted-foreground hover:bg-accent/50 hover:text-foreground transition-colors",children:N}),e[13]=i,e[14]=w):w=e[14];let z;e[15]!==v||e[16]!==w?(z=t.jsxs("div",{className:"flex items-center gap-2 px-3 py-2.5 border-b border-border/50",children:[p,v,w]}),e[15]=v,e[16]=w,e[17]=z):z=e[17];const P="flex-1 min-h-0 overflow-y-auto p-1.5 flex flex-col gap-1";let x;e[18]!==c||e[19]!==f||e[20]!==r?(x=!f&&c.map(k=>t.jsx(xs,{invitation:k,onChanged:r},k.id)),e[18]=c,e[19]=f,e[20]=r,e[21]=x):x=e[21];const _=C.length===0&&t.jsx("p",{className:"px-3 py-4 text-sm text-muted-foreground/60 text-center",children:f?a("header.orgSwitcher.noOrganizationsMatch",{query:f}):a("header.orgSwitcher.noOrganizationsAvailable")});let T;e[22]!==o||e[23]!==s?(T=k=>t.jsxs("button",{type:"button",onClick:()=>o(k.slug),className:X("flex items-center gap-3 px-3 py-2.5 rounded-md text-sm text-left w-full transition-colors",k.slug===s?"bg-accent text-accent-foreground":"text-foreground hover:bg-accent/50"),children:[t.jsx(rt,{org:k,size:"sm"}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("p",{className:"text-sm font-medium truncate",children:k.name}),t.jsx("p",{className:"text-xs text-muted-foreground truncate",children:k.slug})]}),k.slug===s&&t.jsx(Ee,{size:14,className:"ml-auto text-muted-foreground shrink-0"})]},k.id),e[22]=o,e[23]=s,e[24]=T):T=e[24];const S=C.map(T);let y;e[25]!==x||e[26]!==_||e[27]!==S?(y=t.jsxs("div",{className:P,children:[x,_,S]}),e[25]=x,e[26]=_,e[27]=S,e[28]=y):y=e[28];let I;return e[29]!==y||e[30]!==z?(I=t.jsxs(t.Fragment,{children:[z,y]}),e[29]=y,e[30]=z,e[31]=I):I=e[31],I}function bs(n){const e=M.c(22),{trigger:s,orgParam:o,align:i,side:a}=n,l=i===void 0?"start":i,c=a===void 0?"bottom":a,r=st(),[u,m]=H.useState(!1),[f,d]=H.useState(!1);let h;e[0]!==s?(h=t.jsx(Le,{asChild:!0,children:s}),e[0]=s,e[1]=h):h=e[1];const C=String(u);let p;e[2]!==r?(p=z=>{m(!1),r({to:"/$org",params:{org:z}})},e[2]=r,e[3]=p):p=e[3];let g;e[4]===Symbol.for("react.memo_cache_sentinel")?(g=()=>{m(!1),d(!0)},e[4]=g):g=e[4];let j;e[5]!==o||e[6]!==C||e[7]!==p?(j=t.jsx(js,{orgParam:o,onSelectOrg:p,onCreateOrg:g},C),e[5]=o,e[6]=C,e[7]=p,e[8]=j):j=e[8];let b;e[9]!==l||e[10]!==c||e[11]!==j?(b=t.jsx(yt,{side:c,align:l,sideOffset:8,collisionPadding:16,className:"w-[300px] p-0 flex flex-col max-h-[440px]",onOpenAutoFocus:Cs,onCloseAutoFocus:vs,children:j}),e[9]=l,e[10]=c,e[11]=j,e[12]=b):b=e[12];let v;e[13]!==u||e[14]!==h||e[15]!==b?(v=t.jsxs(St,{open:u,onOpenChange:m,children:[h,b]}),e[13]=u,e[14]=h,e[15]=b,e[16]=v):v=e[16];let N;e[17]!==f?(N=t.jsx(gs,{open:f,onOpenChange:d}),e[17]=f,e[18]=N):N=e[18];let w;return e[19]!==N||e[20]!==v?(w=t.jsxs(t.Fragment,{children:[v,N]}),e[19]=N,e[20]=v,e[21]=w):w=e[21],w}function vs(n){return n.preventDefault()}function Cs(n){n.preventDefault(),n.currentTarget?.querySelector("[data-org-switcher-search]")?.focus()}function ys(n){const e=M.c(21),{value:s,onChange:o,placeholder:i,onKeyDown:a,className:l,isSearching:c,disabled:r}=n,u=i===void 0?"Search...":i;let m;e[0]!==l?(m=X("shrink-0 w-full border-b border-border h-12",l),e[0]=l,e[1]=m):m=e[1];const f=r?"cursor-not-allowed opacity-50":"cursor-text";let d;e[2]!==f?(d=X("flex items-center gap-2.5 h-12 px-4",f),e[2]=f,e[3]=d):d=e[3];let h;e[4]!==c?(h=c?t.jsx(ke,{size:16,className:"animate-spin text-muted-foreground shrink-0"}):t.jsx(Nt,{size:16,className:"text-muted-foreground shrink-0"}),e[4]=c,e[5]=h):h=e[5];let C;e[6]!==o?(C=b=>o(b.target.value),e[6]=o,e[7]=C):C=e[7];let p;e[8]!==r||e[9]!==a||e[10]!==u||e[11]!==C||e[12]!==s?(p=t.jsx("input",{type:"text",value:s,onChange:C,onKeyDown:a,placeholder:u,disabled:r,className:"flex-1 min-w-0 bg-transparent text-sm text-foreground placeholder:text-muted-foreground/50 outline-none"}),e[8]=r,e[9]=a,e[10]=u,e[11]=C,e[12]=s,e[13]=p):p=e[13];let g;e[14]!==d||e[15]!==h||e[16]!==p?(g=t.jsxs("label",{className:d,children:[h,p]}),e[14]=d,e[15]=h,e[16]=p,e[17]=g):g=e[17];let j;return e[18]!==m||e[19]!==g?(j=t.jsx("div",{className:m,children:g}),e[18]=m,e[19]=g,e[20]=j):j=e[20],j}function Ss(n,e,s){if(!s)return null;const o=Tn(n,e);return o?o.threads.get().find(a=>a.id===s)?.branch??null:null}function Ns(n){const e=M.c(6),{value:s,onChange:o}=n,i=B();let a;e[0]!==i?(a=i("sidebar.agentsSection.searchAgents"),e[0]=i,e[1]=a):a=e[1];let l;return e[2]!==o||e[3]!==a||e[4]!==s?(l=t.jsx(ys,{value:s,onChange:o,placeholder:a}),e[2]=o,e[3]=a,e[4]=s,e[5]=l):l=e[5],l}function ws(){const n=M.c(4),e=B();let s;n[0]!==e?(s=e("sidebar.agentsSection.noAgentsFound"),n[0]=e,n[1]=s):s=n[1];let o;return n[2]!==s?(o=t.jsx("div",{className:"flex items-center justify-center py-6 text-xs text-muted-foreground",children:s}),n[2]=s,n[3]=o):o=n[3],o}function _s(n){const e=M.c(10),{org:s,onClose:o}=n,i=B();let a;e[0]!==s.slug?(a={org:s.slug},e[0]=s.slug,e[1]=a):a=e[1];let l;e[2]!==o?(l=()=>o(),e[2]=o,e[3]=l):l=e[3];let c;e[4]!==i?(c=i("sidebar.agentsSection.seeAllAgents"),e[4]=i,e[5]=c):c=e[5];let r;return e[6]!==a||e[7]!==l||e[8]!==c?(r=t.jsx("div",{className:"border-t border-border px-3 py-2.5",children:t.jsx(Yt,{to:"/$org/settings/agents",params:a,onClick:l,className:"text-xs text-muted-foreground hover:text-foreground transition-colors flex items-center justify-center",children:c})}),e[6]=a,e[7]=l,e[8]=c,e[9]=r):r=e[9],r}function Ds(){const n=M.c(4),e=B();let s;n[0]!==e?(s=e("sidebar.agentsSection.agents"),n[0]=e,n[1]=s):s=n[1];let o;return n[2]!==s?(o=t.jsx(Rt,{children:s}),n[2]=s,n[3]=o):o=n[3],o}function ks(n){const e=M.c(11),{onImportFromGithub:s}=n,o=B();let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=t.jsx(zn,{className:"size-3.5"}),e[0]=i):i=e[0];let a;e[1]!==o?(a=o("sidebar.agentsSection.import"),e[1]=o,e[2]=a):a=e[2];let l;e[3]!==s||e[4]!==a?(l=t.jsxs("button",{type:"button",onClick:s,className:"flex items-center gap-1.5 rounded-md px-2 py-1 text-xs font-medium text-muted-foreground transition-colors hover:bg-accent/50 hover:text-foreground",children:[i,a]}),e[3]=s,e[4]=a,e[5]=l):l=e[5];let c;e[6]!==o?(c=o("sidebar.agentsSection.codeAgents"),e[6]=o,e[7]=c):c=e[7];let r;return e[8]!==l||e[9]!==c?(r=t.jsx(Rt,{action:l,children:c}),e[8]=l,e[9]=c,e[10]=r):r=e[10],r}function As(n){const e=M.c(11),{setOpen:s,emptyCtaClass:o}=n,i=B();let a;e[0]!==i?(a=i("sidebar.agentsSection.browseAgents"),e[0]=i,e[1]=a):a=e[1];let l;e[2]!==o?(l=X(o),e[2]=o,e[3]=l):l=e[3];let c;e[4]!==s?(c=()=>{R("agent_browser_opened",{surface:"mobile_drawer"}),s(!0)},e[4]=s,e[5]=c):c=e[5];let r;e[6]===Symbol.for("react.memo_cache_sentinel")?(r=t.jsx(Ne,{className:"size-4"}),e[6]=r):r=e[6];let u;return e[7]!==a||e[8]!==l||e[9]!==c?(u=t.jsx(_t,{"aria-label":a,className:l,onClick:c,children:r}),e[7]=a,e[8]=l,e[9]=c,e[10]=u):u=e[10],u}function Is(n){const e=M.c(17),{setOpen:s,highlightEmpty:o,emptyCtaClass:i}=n,a=B();let l;e[0]!==o||e[1]!==a?(l=o?void 0:a("sidebar.agentsSection.browseAgents"),e[0]=o,e[1]=a,e[2]=l):l=e[2];let c;e[3]!==i?(c=X(i),e[3]=i,e[4]=c):c=e[4];let r;e[5]!==s?(r=()=>{R("agent_browser_opened",{surface:"mobile_drawer"}),s(!0)},e[5]=s,e[6]=r):r=e[6];let u;e[7]===Symbol.for("react.memo_cache_sentinel")?(u=t.jsx(Ne,{}),e[7]=u):u=e[7];let m;e[8]!==a?(m=a("sidebar.agentsSection.newAgent"),e[8]=a,e[9]=m):m=e[9];let f;e[10]!==m?(f=t.jsx("span",{children:m}),e[10]=m,e[11]=f):f=e[11];let d;return e[12]!==l||e[13]!==c||e[14]!==r||e[15]!==f?(d=t.jsx(vt,{children:t.jsxs(Ct,{tooltip:l,className:c,onClick:r,children:[u,f]})}),e[12]=l,e[13]=c,e[14]=r,e[15]=f,e[16]=d):d=e[16],d}function zs(){const n=M.c(4),e=B();let s;n[0]!==e?(s=e("sidebar.agentsSection.browseAgents"),n[0]=e,n[1]=s):s=n[1];let o;return n[2]!==s?(o=t.jsx(At,{className:"sr-only",children:s}),n[2]=s,n[3]=o):o=n[3],o}function Ts(n){const e=M.c(8),{emptyCtaClass:s}=n,o=B();let i;e[0]!==o?(i=o("sidebar.agentsSection.browseAgents"),e[0]=o,e[1]=i):i=e[1];let a;e[2]!==s?(a=X(s),e[2]=s,e[3]=a):a=e[3];let l;e[4]===Symbol.for("react.memo_cache_sentinel")?(l=t.jsx(Ne,{className:"size-4"}),e[4]=l):l=e[4];let c;return e[5]!==i||e[6]!==a?(c=t.jsx(_t,{"aria-label":i,className:a,children:l}),e[5]=i,e[6]=a,e[7]=c):c=e[7],c}function Ps(n){const e=M.c(19),{wrapEmptyHint:s,highlightEmpty:o,emptyCtaClass:i}=n,a=B();let l;e[0]!==o||e[1]!==a?(l=o?void 0:a("sidebar.agentsSection.browseAgents"),e[0]=o,e[1]=a,e[2]=l):l=e[2];let c;e[3]!==i?(c=X(i),e[3]=i,e[4]=c):c=e[4];let r;e[5]===Symbol.for("react.memo_cache_sentinel")?(r=t.jsx(Ne,{}),e[5]=r):r=e[5];let u;e[6]!==a?(u=a("sidebar.agentsSection.newAgent"),e[6]=a,e[7]=u):u=e[7];let m;e[8]!==u?(m=t.jsx("span",{children:u}),e[8]=u,e[9]=m):m=e[9];let f;e[10]!==l||e[11]!==c||e[12]!==m?(f=t.jsx(Le,{asChild:!0,children:t.jsxs(Ct,{tooltip:l,className:c,children:[r,m]})}),e[10]=l,e[11]=c,e[12]=m,e[13]=f):f=e[13];let d;e[14]!==f||e[15]!==s?(d=s(f),e[14]=f,e[15]=s,e[16]=d):d=e[16];let h;return e[17]!==d?(h=t.jsx(vt,{children:d}),e[17]=d,e[18]=h):h=e[18],h}function Os(n){const e=M.c(9),{children:s}=n,o=B();let i;e[0]!==s?(i=t.jsx(Ce,{asChild:!0,children:s}),e[0]=s,e[1]=i):i=e[1];let a;e[2]!==o?(a=o("sidebar.agentsSection.selectAnExistingAgent"),e[2]=o,e[3]=a):a=e[3];let l;e[4]!==a?(l=t.jsx(ye,{side:"right",sideOffset:8,children:a}),e[4]=a,e[5]=l):l=e[5];let c;return e[6]!==i||e[7]!==l?(c=t.jsxs(Se,{defaultOpen:!0,delayDuration:0,children:[i,l]}),e[6]=i,e[7]=l,e[8]=c):c=e[8],c}function Ms(n){const e=st(),{create:s}=Pn(),{locator:o}=oe(),i=ot({strict:!1}),a=it({strict:!1});return async l=>{const c=crypto.randomUUID(),r=l===a.virtualmcpid?Ss(n,o,i.taskId??""):null;try{await s({id:c,virtual_mcp_id:l,...r?{branch:r}:{}})}catch{}e({to:"/$org/$taskId",params:{org:n,taskId:c},search:{virtualmcpid:l}})}}function tt(n){const e=M.c(20),{agent:s,selected:o,onClick:i}=n,a=o?"bg-accent text-accent-foreground":"text-foreground hover:bg-accent/50";let l;e[0]!==a?(l=X("flex items-center gap-3 px-3 py-2.5 rounded-md text-sm text-left w-full transition-colors",a),e[0]=a,e[1]=l):l=e[1];let c;e[2]!==s.icon||e[3]!==s.title?(c=t.jsx(xt,{icon:s.icon,name:s.title,size:"xs",className:"shrink-0"}),e[2]=s.icon,e[3]=s.title,e[4]=c):c=e[4];let r;e[5]!==s.title?(r=t.jsx("p",{className:"text-sm font-medium truncate",children:s.title}),e[5]=s.title,e[6]=r):r=e[6];let u;e[7]!==s.description?(u=s.description&&t.jsx("p",{className:"text-xs text-muted-foreground truncate",children:s.description}),e[7]=s.description,e[8]=u):u=e[8];let m;e[9]!==r||e[10]!==u?(m=t.jsxs("div",{className:"flex-1 min-w-0",children:[r,u]}),e[9]=r,e[10]=u,e[11]=m):m=e[11];let f;e[12]!==o?(f=o&&t.jsx(Ee,{size:14,className:"ml-auto text-muted-foreground shrink-0"}),e[12]=o,e[13]=f):f=e[13];let d;return e[14]!==i||e[15]!==l||e[16]!==c||e[17]!==m||e[18]!==f?(d=t.jsxs("button",{type:"button",onClick:i,className:l,children:[c,m,f]}),e[14]=i,e[15]=l,e[16]=c,e[17]=m,e[18]=f,e[19]=d):d=e[19],d}function Rt(n){const e=M.c(5),{children:s,action:o}=n;let i;e[0]!==s?(i=t.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:s}),e[0]=s,e[1]=i):i=e[1];let a;return e[2]!==o||e[3]!==i?(a=t.jsxs("div",{className:"flex items-center justify-between px-3 pb-1 pt-2",children:[i,o]}),e[2]=o,e[3]=i,e[4]=a):a=e[4],a}function $s(n){const e=M.c(23),{onClose:s,onSelectAgent:o,selectedAgentId:i,onImportFromGithub:a}=n,[l,c]=H.useState(""),r=gn(),u=r??[],{org:m}=oe(),{data:f}=ae.useSession(),d=f?.user?.id??"anon",h=Mn(r),C=$n(),p=Ms(m.slug),g=Bn(r),j=l.toLowerCase(),b=u.filter(Es).filter(L=>!g.has(L.id)).filter(Ls).filter(L=>!l||L.title.toLowerCase().includes(j)),v=b.filter(Bs),N=b.filter(Fs),w=lt(m.id),z=!l||w.title.toLowerCase().includes(j),P=!!(o&&z);let x;e[0]!==s||e[1]!==o?(x=()=>{o?.(null),s(),c("")},e[0]=s,e[1]=o,e[2]=x):x=e[2];const _=x,T=L=>{if(o){o(L.id),s(),c("");return}Fn({orgId:m.id,userId:d},L.id,h),C(),s(),c(""),p(L.id)},S="flex flex-col max-h-[min(640px,80dvh)]";let y;e[3]!==l?(y=t.jsx(Ns,{value:l,onChange:c}),e[3]=l,e[4]=y):y=e[4];const I="overflow-y-auto flex-1 min-h-0 p-1.5 flex flex-col gap-0.5",k=o&&z&&w&&t.jsx(tt,{agent:w,selected:!i||i===w.id,onClick:_}),A=(v.length>0||!l)&&t.jsx(ks,{onImportFromGithub:a}),O=v.map(L=>t.jsx(tt,{agent:L,selected:o?i===L.id:void 0,onClick:()=>T(L)},L.id)),E=N.length>0&&t.jsx(Ds,{}),V=N.map(L=>t.jsx(tt,{agent:L,selected:o?i===L.id:void 0,onClick:()=>T(L)},L.id));let $;e[5]!==P||e[6]!==l||e[7]!==b.length?($=b.length===0&&!P&&l&&t.jsx(ws,{}),e[5]=P,e[6]=l,e[7]=b.length,e[8]=$):$=e[8];let K;e[9]!==$||e[10]!==k||e[11]!==A||e[12]!==O||e[13]!==E||e[14]!==V?(K=t.jsxs("div",{className:I,children:[k,A,O,E,V,$]}),e[9]=$,e[10]=k,e[11]=A,e[12]=O,e[13]=E,e[14]=V,e[15]=K):K=e[15];let q;e[16]!==s||e[17]!==m?(q=t.jsx(_s,{org:m,onClose:s}),e[16]=s,e[17]=m,e[18]=q):q=e[18];let de;return e[19]!==K||e[20]!==q||e[21]!==y?(de=t.jsxs("div",{className:S,children:[y,K,q]}),e[19]=K,e[20]=q,e[21]=y,e[22]=de):de=e[22],de}function Fs(n){return!Tt(n.metadata)}function Bs(n){return Tt(n.metadata)}function Ls(n){return!un(n.id)}function Es(n){return!dn(n.id)}function Vs(n){const e=M.c(31);let s;e[0]!==n?(s=n===void 0?{}:n,e[0]=n,e[1]=s):s=e[1];const{compact:o,trigger:i,onSelectAgent:a,selectedAgentId:l,side:c,align:r}=s,u=o===void 0?!1:o,m=c===void 0?"right":c,f=r===void 0?"start":r,[d,h]=H.useState(!1),[C,p]=H.useState(!1),g=It(),{setOpenMobile:j}=bt(),b=On(),v=b?"border border-border":void 0;let N;e[2]!==b?(N=A=>b?t.jsx(Os,{children:A}):A,e[2]=b,e[3]=N):N=e[3];const w=N;let z;e[4]!==g||e[5]!==j?(z=()=>{h(!1),g&&j(!1)},e[4]=g,e[5]=j,e[6]=z):z=e[6];const P=z;let x;e[7]!==P?(x=()=>{P(),p(!0)},e[7]=P,e[8]=x):x=e[8];const _=x;let T;e[9]!==P||e[10]!==_||e[11]!==a||e[12]!==d||e[13]!==l?(T=d&&t.jsx(H.Suspense,{fallback:t.jsx("div",{className:"flex items-center justify-center py-8",children:t.jsx(wn,{className:"h-4 w-24"})}),children:t.jsx($s,{onClose:P,onSelectAgent:a,selectedAgentId:l,onImportFromGithub:_})}),e[9]=P,e[10]=_,e[11]=a,e[12]=d,e[13]=l,e[14]=T):T=e[14];const S=T;let y;e[15]!==f||e[16]!==u||e[17]!==v||e[18]!==b||e[19]!==g||e[20]!==d||e[21]!==S||e[22]!==m||e[23]!==i||e[24]!==w?(y=g?t.jsxs(t.Fragment,{children:[i?t.jsx("button",{type:"button",onClick:()=>h(!0),className:"contents",children:i}):u?w(t.jsx(As,{setOpen:h,emptyCtaClass:v})):t.jsx(Is,{setOpen:h,highlightEmpty:b,emptyCtaClass:v}),t.jsx(Dt,{open:d,onOpenChange:h,direction:"bottom",children:t.jsxs(kt,{className:"max-h-[85dvh] p-0",children:[t.jsx(zs,{}),S]})})]}):t.jsxs(St,{open:d,onOpenChange:A=>{A&&!d&&R("agent_browser_opened",{surface:"desktop_popover"}),h(A)},children:[i?t.jsx(Le,{asChild:!0,children:i}):u?w(t.jsx(Le,{asChild:!0,children:t.jsx(Ts,{emptyCtaClass:v})})):t.jsx(Ps,{wrapEmptyHint:w,highlightEmpty:b,emptyCtaClass:v}),t.jsx(yt,{className:"w-[380px] p-0 overflow-hidden",side:m,align:f,children:S})]}),e[15]=f,e[16]=u,e[17]=v,e[18]=b,e[19]=g,e[20]=d,e[21]=S,e[22]=m,e[23]=i,e[24]=w,e[25]=y):y=e[25];let I;e[26]!==C?(I=t.jsx(In,{open:C,onOpenChange:p,mode:"agent"}),e[26]=C,e[27]=I):I=e[27];let k;return e[28]!==I||e[29]!==y?(k=t.jsxs(t.Fragment,{children:[y,I]}),e[28]=I,e[29]=y,e[30]=k):k=e[30],k}const Rs="inline-flex items-center gap-1.5 min-w-0 rounded-md pl-1 pr-2 py-1.5 text-sm text-foreground hover:bg-accent/60 transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/50";function Hs(n){const e=M.c(29),{agentId:s,fallback:o,onOpenHome:i,onPick:a}=n,l=B(),c=hn(s)??o??null;let r,u,m,f,d;e[0]!==c?.title||e[1]!==i||e[2]!==l?(d=c?.title??l("header.shellBreadcrumb.superAgentDefaultName"),f="flex min-w-0 items-center gap-0",r="button",u=i,m=l("header.shellBreadcrumb.openAgentHome",{name:d}),e[0]=c?.title,e[1]=i,e[2]=l,e[3]=r,e[4]=u,e[5]=m,e[6]=f,e[7]=d):(r=e[3],u=e[4],m=e[5],f=e[6],d=e[7]);const h=c?.icon??null;let C;e[8]!==h||e[9]!==d?(C=t.jsx(xt,{icon:h,name:d,size:"xs"}),e[8]=h,e[9]=d,e[10]=C):C=e[10];let p;e[11]!==r||e[12]!==u||e[13]!==m||e[14]!==C?(p=t.jsx("button",{type:r,onClick:u,"aria-label":m,className:"flex items-center shrink-0 rounded-md p-1 hover:bg-accent/60 transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/50",children:C}),e[11]=r,e[12]=u,e[13]=m,e[14]=C,e[15]=p):p=e[15];let g;e[16]!==d?(g=t.jsx("span",{className:"truncate font-medium max-w-[8rem]",children:d}),e[16]=d,e[17]=g):g=e[17];let j;e[18]===Symbol.for("react.memo_cache_sentinel")?(j=t.jsx(jt,{size:14,className:"shrink-0 text-muted-foreground opacity-70"}),e[18]=j):j=e[18];let b;e[19]!==g?(b=t.jsxs("button",{type:"button",className:Rs,children:[g,j]}),e[19]=g,e[20]=b):b=e[20];let v;e[21]!==s||e[22]!==a||e[23]!==b?(v=t.jsx(Vs,{side:"bottom",align:"start",selectedAgentId:s,onSelectAgent:a,trigger:b}),e[21]=s,e[22]=a,e[23]=b,e[24]=v):v=e[24];let N;return e[25]!==v||e[26]!==f||e[27]!==p?(N=t.jsxs("div",{className:f,children:[p,v]}),e[25]=v,e[26]=f,e[27]=p,e[28]=N):N=e[28],N}function Wo(n){const e=M.c(30);let s;e[0]!==n?(s=n===void 0?{}:n,e[0]=n,e[1]=s):s=e[1];const{showName:o}=s,i=B(),{org:a}=oe(),{state:l,isMobile:c}=bt(),r=Vt().invitations.length>0,u=l==="collapsed"||c;let m;e[2]!==r||e[3]!==a.name||e[4]!==i?(m=r?i("header.shellBreadcrumb.switchOrganizationPendingInvitation",{name:a.name}):i("header.shellBreadcrumb.switchOrganization",{name:a.name}),e[2]=r,e[3]=a.name,e[4]=i,e[5]=m):m=e[5];let f;e[6]!==a?(f=t.jsx(rt,{org:a,size:"sm"}),e[6]=a,e[7]=f):f=e[7];let d;e[8]!==r||e[9]!==u?(d=r&&t.jsx("span",{className:X("absolute -right-1 size-2.5 rounded-full bg-destructive ring-2 ring-background",u?"-top-1":"top-1/2 -translate-y-1/2")}),e[8]=r,e[9]=u,e[10]=d):d=e[10];let h;e[11]!==f||e[12]!==d?(h=t.jsxs("span",{className:"relative inline-flex",children:[f,d]}),e[11]=f,e[12]=d,e[13]=h):h=e[13];let C;e[14]!==a.name||e[15]!==o?(C=o&&t.jsx("span",{className:"truncate text-sm font-medium text-foreground max-w-[10rem]",children:a.name}),e[14]=a.name,e[15]=o,e[16]=C):C=e[16];let p;e[17]===Symbol.for("react.memo_cache_sentinel")?(p=t.jsx(jt,{size:14,className:"shrink-0 text-muted-foreground opacity-70"}),e[17]=p):p=e[17];let g;e[18]!==m||e[19]!==h||e[20]!==C?(g=t.jsx(Ce,{asChild:!0,children:t.jsxs("button",{type:"button","aria-label":m,className:"flex items-center gap-1.5 shrink-0 rounded-lg pl-[5px] pr-1.5 py-1.5 hover:bg-accent/60 transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/50",children:[h,C,p]})}),e[18]=m,e[19]=h,e[20]=C,e[21]=g):g=e[21];let j;e[22]!==a.slug||e[23]!==g?(j=t.jsx(bs,{orgParam:a.slug,trigger:g}),e[22]=a.slug,e[23]=g,e[24]=j):j=e[24];let b;e[25]!==a.name?(b=t.jsx(ye,{side:"bottom",children:a.name}),e[25]=a.name,e[26]=b):b=e[26];let v;return e[27]!==b||e[28]!==j?(v=t.jsxs(Se,{children:[j,b]}),e[27]=b,e[28]=j,e[29]=v):v=e[29],v}function Yo(n){const e=M.c(22);let s;e[0]!==n?(s=n===void 0?{}:n,e[0]=n,e[1]=s):s=e[1];const{onNavigate:o}=s,{org:i}=oe();let a;e[2]===Symbol.for("react.memo_cache_sentinel")?(a={strict:!1},e[2]=a):a=e[2];const l=ot(a);let c;e[3]===Symbol.for("react.memo_cache_sentinel")?(c={strict:!1},e[3]=c):c=e[3];const r=it(c),{threads:u}=zt(),{data:m}=ae.useSession(),{setTaskId:f,createNewTask:d}=Pt();let h;e[4]!==i.id?(h=lt(i.id),e[4]=i.id,e[5]=h):h=e[5];const C=h,p=C.id,g=l.taskId?r.virtualmcpid??p:p;let j;e[6]!==d||e[7]!==p||e[8]!==o||e[9]!==m?.user?.id||e[10]!==f||e[11]!==u?(j=P=>{const x=P??p,_=Ln(u,x,m?.user?.id);_?f(_.id,x):d(x),o?.()},e[6]=d,e[7]=p,e[8]=o,e[9]=m?.user?.id,e[10]=f,e[11]=u,e[12]=j):j=e[12];const b=j;let v;e[13]===Symbol.for("react.memo_cache_sentinel")?(v=t.jsx("span",{className:"h-5 w-24 rounded bg-muted animate-pulse"}),e[13]=v):v=e[13];const N=g===p?C:void 0;let w;e[14]!==g||e[15]!==b?(w=()=>b(g),e[14]=g,e[15]=b,e[16]=w):w=e[16];let z;return e[17]!==g||e[18]!==b||e[19]!==N||e[20]!==w?(z=t.jsx(H.Suspense,{fallback:v,children:t.jsx(Hs,{agentId:g,fallback:N,onOpenHome:w,onPick:b})}),e[17]=g,e[18]=b,e[19]=N,e[20]=w,e[21]=z):z=e[21],z}function Jo(){const n=M.c(24),e=B(),{org:s}=oe();let o;n[0]===Symbol.for("react.memo_cache_sentinel")?(o={strict:!1},n[0]=o):o=n[0];const i=ot(o);let a;n[1]===Symbol.for("react.memo_cache_sentinel")?(a={strict:!1},n[1]=a):a=n[1];const l=it(a),{threads:c}=zt(),{createNewTask:r}=Pt();let u;n[2]!==s.id?(u=lt(s.id),n[2]=s.id,n[3]=u):u=n[3];const m=u.id,f=i.taskId?l.virtualmcpid??m:m;let d;n[4]!==i.taskId||n[5]!==c?(d=(i.taskId?c.find(z=>z.id===i.taskId)?.branch:null)??null,n[4]=i.taskId,n[5]=c,n[6]=d):d=n[6];const h=d;let C;n[7]!==f||n[8]!==r||n[9]!==h?(C=()=>{r(f,h)},n[7]=f,n[8]=r,n[9]=h,n[10]=C):C=n[10];const p=C;let g;n[11]!==e?(g=e("sidebar.taskGroupsList.newChat"),n[11]=e,n[12]=g):g=n[12];let j;n[13]===Symbol.for("react.memo_cache_sentinel")?(j=t.jsx(rn,{size:16}),n[13]=j):j=n[13];let b;n[14]!==p||n[15]!==g?(b=t.jsx(Ce,{asChild:!0,children:t.jsx("button",{type:"button",onClick:p,"aria-label":g,className:"flex shrink-0 items-center rounded-md p-1.5 text-muted-foreground transition-colors hover:bg-accent/60 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/50",children:j})}),n[14]=p,n[15]=g,n[16]=b):b=n[16];let v;n[17]!==e?(v=e("sidebar.taskGroupsList.newChat"),n[17]=e,n[18]=v):v=n[18];let N;n[19]!==v?(N=t.jsx(ye,{side:"bottom",children:v}),n[19]=v,n[20]=N):N=n[20];let w;return n[21]!==b||n[22]!==N?(w=t.jsxs(Se,{children:[b,N]}),n[21]=b,n[22]=N,n[23]=w):w=n[23],w}function Us({open:n,onOpenChange:e,onCreated:s}){const o=B(),{org:i}=oe(),{data:a}=ae.useSession(),{stdioEnabled:l}=Jt(),c=It(),r=Et(),u=Ot(),f=Mt(u,"").items,d=pt({resolver:ht(Zn),defaultValues:{title:"",description:null,icon:null,ui_type:"HTTP",connection_url:"",connection_token:null,npx_package:"",stdio_command:"",stdio_args:"",stdio_cwd:"",env_vars:[]}}),h=d.watch("ui_type"),C=d.watch("connection_url"),p=d.watch("npx_package"),g=$e({uiType:h,connectionUrl:C??"",npxPackage:p??""})??ut({uiType:h,connectionUrl:C??"",registryItems:f}),j=x=>{const _=x.trim();if(!_)return;const T=!!d.formState.dirtyFields.title,S=!!d.formState.dirtyFields.description,y=!!d.formState.dirtyFields.env_vars,I=A=>{if(A&&(!T&&!d.getValues("title").trim()&&A.title&&d.setValue("title",A.title,{shouldDirty:!1}),!S&&!(d.getValues("description")??"").trim()&&A.description&&d.setValue("description",A.description,{shouldDirty:!1}),!y&&A.envVarKeys?.length)){const O=d.getValues("env_vars")??[],E=new Set(O.map($=>$.key)),V=A.envVarKeys.filter($=>!E.has($));V.length>0&&d.setValue("env_vars",[...O,...V.map($=>({key:$,value:""}))],{shouldDirty:!0})}},k=ts(_);if(k&&l){d.setValue("ui_type","NPX",{shouldDirty:!0}),d.setValue("npx_package",k.packageName,{shouldDirty:!0}),d.setValue("connection_url","",{shouldDirty:!0}),d.setValue("connection_token",null,{shouldDirty:!0}),I($e({uiType:"NPX",npxPackage:k.packageName}));return}if(_.startsWith("http://")||_.startsWith("https://")){const A=h==="HTTP"||h==="SSE"||h==="Websocket"?h:"HTTP";d.setValue("ui_type",A,{shouldDirty:!0}),d.setValue("connection_url",_,{shouldDirty:!0}),I($e({uiType:A,connectionUrl:_})??ut({uiType:A,connectionUrl:_,registryItems:f}));return}h==="NPX"&&I($e({uiType:"NPX",npxPackage:_}))},b=x=>{x||d.reset(),e(x)},v=async x=>{let _,T=null,S=null,y=null;x.ui_type==="NPX"?(_="STDIO",T="",y=ns(x.npx_package||"",x.env_vars||[])):x.ui_type==="STDIO"?(_="STDIO",T="",y=ss(x.stdio_command||"",x.stdio_args||"",x.stdio_cwd,x.env_vars||[])):(_=x.ui_type,T=x.connection_url||"",S=x.connection_token||null);const I=Vn("conn");try{await r.create.mutateAsync({id:I,title:x.title,description:x.description||null,connection_type:_,connection_url:T,connection_token:S,created_at:new Date().toISOString(),updated_at:new Date().toISOString(),created_by:a?.user?.id||"system",organization_id:i.id,icon:x.icon??null,app_name:null,app_id:null,connection_headers:y,oauth_config:null,configuration_state:null,metadata:null,tools:null,bindings:null,status:"inactive"}),d.reset(),e(!1),s?.(I)}catch{U.error(o("connections.createConnectionDialog.failedToCreateConnection"))}},N=o("connections.createConnectionDialog.title"),w=o("connections.createConnectionDialog.description"),z=d.formState.isSubmitting?o("connections.createConnectionDialog.saving"):o("connections.createConnectionDialog.createButton"),P=t.jsxs("div",{className:"grid gap-4",children:[t.jsx(W,{control:d.control,name:"ui_type",render:({field:x})=>t.jsxs(Y,{children:[t.jsx(J,{children:o("connections.createConnectionDialog.typeLabel")}),t.jsxs(Xn,{value:x.value,onValueChange:x.onChange,children:[t.jsx(Z,{children:t.jsx(Qn,{children:t.jsx(Wn,{})})}),t.jsxs(Yn,{children:[t.jsx(De,{value:"HTTP",children:t.jsxs("span",{className:"flex items-center gap-2",children:[t.jsx(Ze,{className:"w-4 h-4"}),o("connections.createConnectionDialog.httpType")]})}),t.jsx(De,{value:"SSE",children:t.jsxs("span",{className:"flex items-center gap-2",children:[t.jsx(Ze,{className:"w-4 h-4"}),o("connections.createConnectionDialog.sseType")]})}),t.jsx(De,{value:"Websocket",children:t.jsxs("span",{className:"flex items-center gap-2",children:[t.jsx(Ze,{className:"w-4 h-4"}),o("connections.createConnectionDialog.websocketType")]})}),l&&t.jsxs(t.Fragment,{children:[t.jsx(De,{value:"NPX",children:t.jsxs("span",{className:"flex items-center gap-2",children:[t.jsx(Be,{className:"w-4 h-4"}),o("connections.createConnectionDialog.npxPackageType")]})}),t.jsx(De,{value:"STDIO",children:t.jsxs("span",{className:"flex items-center gap-2",children:[t.jsx(cn,{className:"w-4 h-4"}),o("connections.createConnectionDialog.customCommandType")]})})]})]})]}),t.jsx(ee,{})]})}),h==="NPX"&&t.jsx(W,{control:d.control,name:"npx_package",render:({field:x})=>t.jsxs(Y,{children:[t.jsx(J,{children:o("connections.createConnectionDialog.npmPackageLabel")}),t.jsx(Z,{children:t.jsx(ie,{placeholder:o("connections.createConnectionDialog.npmPackagePlaceholder"),...x,value:x.value??"",onPaste:_=>{const T=_.clipboardData.getData("text");T&&(_.preventDefault(),d.setValue("npx_package",T.trim(),{shouldDirty:!0}),j(T))},onBlur:_=>{j(_.target.value),x.onBlur()}})}),t.jsx(ee,{})]})}),h==="STDIO"&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"grid grid-cols-2 gap-4 items-start",children:[t.jsx(W,{control:d.control,name:"stdio_command",render:({field:x})=>t.jsxs(Y,{children:[t.jsx(J,{children:o("connections.createConnectionDialog.commandLabel")}),t.jsx(Z,{children:t.jsx(ie,{placeholder:o("connections.createConnectionDialog.commandPlaceholder"),...x,value:x.value??""})}),t.jsx(ee,{})]})}),t.jsx(W,{control:d.control,name:"stdio_args",render:({field:x})=>t.jsxs(Y,{children:[t.jsx(J,{children:o("connections.createConnectionDialog.argumentsLabel")}),t.jsx(Z,{children:t.jsx(ie,{placeholder:o("connections.createConnectionDialog.argumentsPlaceholder"),...x,value:x.value??""})}),t.jsx(ee,{})]})})]}),t.jsx(W,{control:d.control,name:"stdio_cwd",render:({field:x})=>t.jsxs(Y,{children:[t.jsx(J,{children:o("connections.createConnectionDialog.workingDirectoryLabel")}),t.jsx(Z,{children:t.jsx(ie,{placeholder:o("connections.createConnectionDialog.workingDirectoryPlaceholder"),...x,value:x.value??""})}),t.jsx("p",{className:"text-xs text-muted-foreground",children:o("connections.createConnectionDialog.workingDirectoryDescription")}),t.jsx(ee,{})]})})]}),(h==="NPX"||h==="STDIO")&&t.jsx(W,{control:d.control,name:"env_vars",render:({field:x})=>t.jsxs(Y,{children:[t.jsx(J,{children:o("connections.createConnectionDialog.environmentVariablesLabel")}),t.jsx(Z,{children:t.jsx(es,{value:x.value??[],onChange:x.onChange})}),t.jsx(ee,{})]})}),h!=="NPX"&&h!=="STDIO"&&t.jsxs(t.Fragment,{children:[t.jsx(W,{control:d.control,name:"connection_url",render:({field:x})=>t.jsxs(Y,{children:[t.jsx(J,{children:o("connections.createConnectionDialog.urlLabel")}),t.jsx(Z,{children:t.jsx(ie,{placeholder:o("connections.createConnectionDialog.urlPlaceholder"),...x,value:x.value??"",onPaste:_=>{const T=_.clipboardData.getData("text");T&&(_.preventDefault(),d.setValue("connection_url",T.trim(),{shouldDirty:!0}),j(T))},onBlur:_=>{j(_.target.value),x.onBlur()}})}),t.jsx(ee,{})]})}),t.jsx(W,{control:d.control,name:"connection_token",render:({field:x})=>t.jsxs(Y,{children:[t.jsx(J,{children:g?.token?.label??o("connections.createConnectionDialog.tokenLabelDefault")}),t.jsx(Z,{children:t.jsx(ie,{type:"password",placeholder:g?.token?.placeholder??o("connections.createConnectionDialog.tokenPlaceholderDefault"),className:"ph-no-capture",...x,value:x.value??""})}),g?.token?.helperText&&t.jsxs("p",{className:"text-xs text-muted-foreground",children:[g.token.helperText,g.id==="github"&&t.jsxs(t.Fragment,{children:[" ","·"," ",t.jsx("a",{className:"text-foreground underline underline-offset-4 hover:text-foreground/80",href:"https://github.com/settings/personal-access-tokens",target:"_blank",rel:"noreferrer",children:o("connections.createConnectionDialog.openGitHubPatSettings")})]})]}),t.jsx(ee,{})]})})]}),t.jsx(W,{control:d.control,name:"title",render:({field:x})=>t.jsxs(Y,{children:[t.jsx(J,{children:o("connections.createConnectionDialog.nameLabel")}),t.jsx(Z,{children:t.jsx(ie,{placeholder:o("connections.createConnectionDialog.namePlaceholder"),...x})}),t.jsx(ee,{})]})}),t.jsx(W,{control:d.control,name:"description",render:({field:x})=>t.jsxs(Y,{children:[t.jsx(J,{children:o("connections.createConnectionDialog.descriptionLabel")}),t.jsx(Z,{children:t.jsx(Jn,{placeholder:o("connections.createConnectionDialog.descriptionPlaceholder"),rows:3,...x,value:x.value??""})}),t.jsx(ee,{})]})})]});return c?t.jsx(Dt,{open:n,onOpenChange:b,children:t.jsxs(kt,{className:"max-h-[90vh]",children:[t.jsx(_n,{className:"pb-2",children:t.jsxs("div",{className:"flex items-start justify-between gap-4",children:[t.jsxs("div",{className:"flex-1 text-left",children:[t.jsx(At,{children:N}),t.jsx(Dn,{className:"mt-1",children:w})]}),t.jsx(kn,{asChild:!0,children:t.jsx(te,{variant:"ghost",size:"icon",className:"shrink-0 -mt-1",children:t.jsx(wt,{size:16})})})]})}),t.jsx(nt,{...d,children:t.jsxs("form",{onSubmit:d.handleSubmit(v),children:[t.jsx("div",{className:"overflow-y-auto px-4 pb-4",children:P}),t.jsx(An,{children:t.jsx(te,{type:"submit",disabled:d.formState.isSubmitting,className:"w-full",children:z})})]})})]})}):t.jsx($t,{open:n,onOpenChange:b,children:t.jsxs(Ft,{className:"sm:max-w-[525px]",children:[t.jsxs(Bt,{children:[t.jsx(Lt,{children:N}),t.jsx(Kn,{children:w})]}),t.jsx(nt,{...d,children:t.jsxs("form",{onSubmit:d.handleSubmit(v),children:[t.jsx("div",{className:"py-4",children:P}),t.jsxs(Gn,{children:[t.jsx(te,{type:"button",variant:"outline",onClick:()=>b(!1),children:o("connections.createConnectionDialog.cancelButton")}),t.jsx(te,{type:"submit",disabled:d.formState.isSubmitting,className:"min-w-40",children:z})]})]})})]})})}function qs(n){const e=M.c(72),{mode:s,agentId:o,addedConnectionIds:i,onAdd:a,onCloneAndAdd:l,onConnectAndAdd:c,connectingItemId:r,search:u,onCreateConnection:m,onBrowseNavigate:f,defaultTab:d}=n,h=s===void 0?"add":s,C=d===void 0?"connected":d,p=B(),{org:g}=oe(),j=H.useDeferredValue(u),b=u!==j;let v;e[0]!==j?(v=j.trim().toLowerCase(),e[0]=j,e[1]=v):v=e[1];const N=v;let w;e[2]!==C?(w=D=>D??C,e[2]=C,e[3]=w):w=e[3];const[z,P]=Zt(en.connectionsTab(g.slug)+(C==="all"?":home-modal":":agent-modal"),w);let x;e[4]!==z||e[5]!==P?(x=D=>{D!==z&&R("connections_dialog_tab_changed",{to_tab:D}),P(D)},e[4]=z,e[5]=P,e[6]=x):x=e[6];const _=x;let T;e[7]!==g.id||e[8]!==g.slug?(T={connectionId:mn,orgId:g.id,orgSlug:g.slug},e[7]=g.id,e[8]=g.slug,e[9]=T):T=e[9];const S=fn(T),y=j?.trim().split(/\s+/).filter(Boolean)??[],I=y.length>0?{operator:"or",conditions:y.flatMap(Zs)}:void 0,k={...I&&{where:I},orderBy:[{field:["updated_at"],direction:"asc"}],limit:100,offset:0},A=JSON.stringify(k),{data:O,fetchNextPage:E,hasNextPage:V,isFetchingNextPage:$}=as({queryKey:at.collectionListInfinite(S,g.id,"","CONNECTIONS",A),queryFn:async D=>{const{pageParam:F}=D,se=F===void 0?0:F;return(await S.callTool({name:"COLLECTION_CONNECTIONS_LIST",arguments:{...I&&{where:I},orderBy:[{field:["updated_at"],direction:"asc"}],limit:100,offset:se}})).structuredContent},initialPageParam:0,getNextPageParam:Ys,staleTime:3e4}),K=O?.pages.flatMap(Ws)??[],q=qn(K),de=new Set(K.filter(Qs).map(Xs)),L=Ot(),le=Mt(L,j),Re=mt(le.loadMore,le.hasMore,le.isLoadingMore),He=mt(E,V??!1,$),Q=z==="all"||!!N,ct=Q?le.items.filter(D=>{const F=Rn(D);if(F&&de.has(F))return!1;if(!N)return!0;const se=Ve(D._meta),re=[D.title,D.description,D.name,D.server?.title,D.server?.description,D.server?.name,se?.friendly_name,se?.friendlyName].filter(Boolean).join(" ").toLowerCase();return y.some(ne=>re.includes(ne.toLowerCase()))}):[],we=ct.filter(Gs),_e=ct.filter(Ks);let Ae;e[10]!==i?(Ae=D=>D.some(F=>i.has(F.id)),e[10]=i,e[11]=Ae):Ae=e[11];const Ue=Ae;let Ie;e[12]!==i||e[13]!==o||e[14]!==r||e[15]!==Ue||e[16]!==h||e[17]!==a||e[18]!==f||e[19]!==l||e[20]!==p?(Ie=(D,F,se,re,ne)=>{const Me=Ue(ne),ve=ne.find(ce=>!i.has(ce.id)),G=ne[0];if(h==="browse"){const ce=os(G);return t.jsx(Ye,{connection:{title:F,icon:se,description:ne.length>1?`${ne.length} instances`:re??void 0},fallbackIcon:t.jsx(Be,{}),headerActionsAlwaysVisible:!0,headerActions:t.jsxs(Fe,{variant:"secondary",className:"text-xs gap-1 font-normal",children:[t.jsx(Ee,{size:11})," ",p("virtualMcp.connectionDialogContent.connected")]}),onClick:()=>{R("connection_browse_clicked",{app_name:G.app_name??null,connection_id:G.id,instances_count:ne.length}),f?.(ce)}},D)}return t.jsx(Ye,{connection:{title:F,icon:se,description:re},fallbackIcon:t.jsx(Be,{}),headerActionsAlwaysVisible:!0,headerActions:t.jsxs("div",{className:"flex items-center gap-1.5",children:[Me&&t.jsxs(Fe,{variant:"secondary",className:"text-xs gap-1 font-normal",children:[t.jsx(Ee,{size:11})," ",p("virtualMcp.connectionDialogContent.added")]}),t.jsx(te,{variant:"outline",size:"sm",className:"h-7 px-3 text-xs font-medium",disabled:r!==null,onClick:ce=>{ce.stopPropagation(),ve?(R("connection_add_clicked",{action:"use_existing",app_name:G.app_name??null,connection_id:ve.id}),o&&R("agent_connection_attached",{agent_id:o,connection_id:ve.id,app_name:G.app_name??null,mode:"existing"}),a(ve.id)):(R("connection_add_clicked",{action:"clone",app_name:G.app_name??null,base_connection_id:G.id}),l(G))},children:p("virtualMcp.connectionDialogContent.add")})]})},D)},e[12]=i,e[13]=o,e[14]=r,e[15]=Ue,e[16]=h,e[17]=a,e[18]=f,e[19]=l,e[20]=p,e[21]=Ie):Ie=e[21];const ze=Ie;let Te;e[22]!==r||e[23]!==h||e[24]!==c||e[25]!==p?(Te=D=>{const F=Ve(D._meta),se=F?.friendlyName||F?.friendly_name||D.server?.title||D.title||D.server?.name||D.name||D.id||"",re=D.server?.description||D.description||null,ne=D.server?.icons?.[0]?.src||Hn(D.server?.repository)||null,Me=F?.official===!0,ve=F?.verified===!0,G=F?.owner==="deco";return t.jsx(Ye,{connection:{title:se,description:re,icon:ne},fallbackIcon:t.jsx(Be,{}),headerActionsAlwaysVisible:!0,headerActions:t.jsxs("div",{className:"flex items-center gap-1.5",children:[G&&t.jsxs(Se,{children:[t.jsx(Ce,{asChild:!0,children:t.jsx("span",{className:"inline-flex items-center justify-center size-5 rounded-md bg-muted shrink-0",children:t.jsx("img",{src:"/logos/deco logo.svg",alt:p("virtualMcp.connectionDialogContent.madeByDeco"),className:"size-3"})})}),t.jsx(ye,{children:p("virtualMcp.connectionDialogContent.builtByDeco")})]}),!G&&Me&&t.jsxs(Se,{children:[t.jsx(Ce,{asChild:!0,children:t.jsx(Fe,{variant:"outline",size:"icon",children:t.jsx(Je,{})})}),t.jsx(ye,{children:p("virtualMcp.connectionDialogContent.builtByOfficial")})]}),!G&&!Me&&ve&&t.jsxs(Se,{children:[t.jsx(Ce,{asChild:!0,children:t.jsx(Fe,{variant:"outline",size:"icon",children:t.jsx(Je,{})})}),t.jsx(ye,{children:p("virtualMcp.connectionDialogContent.verifiedByDeco")})]}),t.jsx(te,{variant:"outline",size:"sm",className:"h-7 px-3 text-xs font-medium",disabled:r!==null,onClick:ce=>{ce.stopPropagation(),R("connection_add_clicked",{action:"connect_new",registry_item_id:D.id,app_name:F?.friendlyName||D.server?.name||D.name||null}),c(D)},children:r===D.id?t.jsx(ke,{size:14,className:"animate-spin"}):p(h==="browse"?"virtualMcp.connectionDialogContent.connect":"virtualMcp.connectionDialogContent.add")})]})},`catalog-${D.id}`)},e[22]=r,e[23]=h,e[24]=c,e[25]=p,e[26]=Te):Te=e[26];const dt=Te;let ue;e[27]!==z||e[28]!==_||e[29]!==m||e[30]!==N||e[31]!==p?(ue=!N&&t.jsxs("div",{className:"flex items-center justify-between px-5 py-3 border-b border-border shrink-0",children:[t.jsx(is,{tabs:[{id:"all",label:p("virtualMcp.connectionDialogContent.tabAll")},{id:"connected",label:p("virtualMcp.connectionDialogContent.tabConnected")}],activeTab:z,onTabChange:D=>_(D)}),t.jsxs(te,{variant:"outline",size:"sm",className:"h-7 px-2 text-sm",onClick:()=>{R("connections_dialog_custom_clicked"),m()},children:[t.jsx(Ne,{size:12}),p("virtualMcp.connectionDialogContent.customConnection")]})]}),e[27]=z,e[28]=_,e[29]=m,e[30]=N,e[31]=p,e[32]=ue):ue=e[32];const qe=b&&"opacity-50 pointer-events-none";let me;e[33]!==qe?(me=X("flex-1 overflow-auto p-5 transition-opacity duration-150",qe),e[33]=qe,e[34]=me):me=e[34];const Ht="grid grid-cols-[repeat(auto-fill,minmax(260px,1fr))] gap-4";let Pe;e[35]!==ze?(Pe=D=>{if(D.type==="group")return ze(D.key,D.title,D.icon,null,D.connections);const F=D.connection;return ze(F.id,F.title,F.icon,F.description??null,[F])},e[35]=ze,e[36]=Pe):Pe=e[36];const Ke=q.map(Pe);let fe;e[37]!==He?(fe=t.jsx("div",{ref:He,className:"col-span-full h-1"}),e[37]=He,e[38]=fe):fe=e[38];let ge;e[39]!==$?(ge=$&&t.jsx("div",{className:"col-span-full flex justify-center py-6",children:t.jsx(ke,{size:24,className:"animate-spin text-muted-foreground"})}),e[39]=$,e[40]=ge):ge=e[40];const Ge=Q&&we.length>0&&t.jsxs("div",{className:"col-span-full flex items-center gap-2 mt-2",children:[t.jsx(Je,{size:13,className:"text-muted-foreground shrink-0"}),t.jsx("span",{className:"text-sm font-medium text-muted-foreground whitespace-nowrap",children:p("virtualMcp.connectionDialogContent.sectionVerified")}),t.jsx("div",{className:"flex-1 h-px bg-border"})]}),Xe=Q&&we.map(dt),Qe=Q&&_e.length>0&&t.jsxs("div",{className:"col-span-full flex items-center gap-2 mt-2",children:[t.jsx("span",{className:"text-sm font-medium text-muted-foreground whitespace-nowrap",children:p("virtualMcp.connectionDialogContent.sectionAllConnections")}),t.jsx("div",{className:"flex-1 h-px bg-border"})]}),We=Q&&_e.map(dt);let he;e[41]!==Re||e[42]!==L||e[43]!==Q?(he=Q&&L.length>0&&t.jsx("div",{ref:Re,className:"col-span-full h-1"}),e[41]=Re,e[42]=L,e[43]=Q,e[44]=he):he=e[44];let pe;e[45]!==le.isLoadingMore||e[46]!==Q?(pe=Q&&le.isLoadingMore&&t.jsx("div",{className:"col-span-full flex justify-center py-6",children:t.jsx(ke,{size:24,className:"animate-spin text-muted-foreground"})}),e[45]=le.isLoadingMore,e[46]=Q,e[47]=pe):pe=e[47];let xe;e[48]!==Ke||e[49]!==fe||e[50]!==ge||e[51]!==Ge||e[52]!==Xe||e[53]!==Qe||e[54]!==We||e[55]!==he||e[56]!==pe?(xe=t.jsxs("div",{className:Ht,children:[Ke,fe,ge,Ge,Xe,Qe,We,he,pe]}),e[48]=Ke,e[49]=fe,e[50]=ge,e[51]=Ge,e[52]=Xe,e[53]=Qe,e[54]=We,e[55]=he,e[56]=pe,e[57]=xe):xe=e[57];let je;e[58]!==z||e[59]!==q.length||e[60]!==_e||e[61]!==u||e[62]!==p||e[63]!==we?(je=q.length===0&&we.length===0&&_e.length===0&&t.jsx("div",{className:"flex items-center justify-center h-48 text-sm text-muted-foreground",children:u?p("virtualMcp.connectionDialogContent.emptyStateSearchNoMatch",{search:u}):p(z==="connected"?"virtualMcp.connectionDialogContent.emptyStateNoConnectionsYet":"virtualMcp.connectionDialogContent.emptyStateNoConnectionsAvailable")}),e[58]=z,e[59]=q.length,e[60]=_e,e[61]=u,e[62]=p,e[63]=we,e[64]=je):je=e[64];let be;e[65]!==me||e[66]!==xe||e[67]!==je?(be=t.jsxs("div",{className:me,children:[xe,je]}),e[65]=me,e[66]=xe,e[67]=je,e[68]=be):be=e[68];let Oe;return e[69]!==ue||e[70]!==be?(Oe=t.jsxs(t.Fragment,{children:[ue,be]}),e[69]=ue,e[70]=be,e[71]=Oe):Oe=e[71],Oe}function Ks(n){return!n.verified&&!Ve(n._meta)?.verified&&!n.meta?.verified}function Gs(n){return n.verified||Ve(n._meta)?.verified||n.meta?.verified}function Xs(n){return n.app_name}function Qs(n){return n.app_name}function Ws(n){return n?.items??[]}function Ys(n,e){if(n?.hasMore)return e.reduce(Js,0)}function Js(n,e){return n+(e?.items?.length??0)}function Zs(n){return[{field:["title"],operator:"contains",value:n},{field:["description"],operator:"contains",value:n}]}function Zo({open:n,onOpenChange:e,defaultTab:s,initialSearch:o="",...i}){const a=B(),l=i.mode??"add",c="agentId"in i?i.agentId:void 0,r="addedConnectionIds"in i?i.addedConnectionIds??new Set:new Set,u="onAdd"in i&&i.onAdd?i.onAdd:S=>{},m=(S,y,I)=>{c&&R("agent_connection_attached",{agent_id:c,connection_id:S,app_name:y,mode:I})},[f,d]=H.useState(null),[h,C]=H.useState(o),[p,g]=H.useState(!1),{org:j}=oe(),{data:b}=ae.useSession(),v=Et(),N=tn(),w=st(),z=S=>{e(!1),w({to:"/$org/settings/connections/$appSlug",params:{org:j.slug,appSlug:S}})},P=()=>{N.invalidateQueries({predicate:S=>{const y=S.queryKey;return y[1]===j.id&&y[3]==="collection"&&y[4]==="CONNECTIONS"}})},x=async(S,y)=>{R("connection_oauth_succeeded",{connection_id:S,flow:y});const I=new URL(`/api/${j.slug}/mcp/${S}`,window.location.origin);await N.invalidateQueries({queryKey:at.isMCPAuthenticated(I.href,null)}),P()},_=async S=>{d(S.app_name??S.id);try{const I=`${S.title.replace(/\s*\(\d+\)\s*$/,"")} (${Date.now().toString(36).slice(-4)})`,A=(await v.create.mutateAsync({title:I,description:S.description??null,connection_type:S.connection_type,connection_url:S.connection_url??null,connection_token:null,icon:S.icon??null,app_name:S.app_name??null,app_id:S.app_id??null,connection_headers:S.connection_headers??null})).id,O=await et({connectionId:A,orgId:j.id,orgSlug:j.slug,persistFallback:E=>v.update.mutateAsync({id:A,data:{connection_token:E}}).then(()=>{})});if(O.ran&&!O.ok){R("connection_oauth_failed",{connection_id:A,flow:"clone",error:O.error??"no_token"}),U.error(a("virtualMcp.addConnectionDialog.authenticationFailedError",{error:O.error??"no token received"})),await v.delete.mutateAsync(A);return}O.ran&&await x(A,"clone"),m(A,S.app_name??null,"clone"),u(A)}catch(y){console.error("Failed to add connection:",y),U.error(a("virtualMcp.addConnectionDialog.failedToAddConnection"))}finally{d(null)}},T=async S=>{if(!(!j||!b?.user?.id)){d(S.id);try{const y=Un(S,j.id,b.user.id,{remoteIndex:0}),I=y.connection_type==="STDIO",k=!!y.connection_url,A=I&&y.connection_headers&&typeof y.connection_headers=="object"&&"command"in y.connection_headers;if(!k&&!A){U.error(a("virtualMcp.addConnectionDialog.mcpServerConnectionError")),d(null);return}const{id:O}=await v.create.mutateAsync(y),E=await et({connectionId:O,orgId:j.id,orgSlug:j.slug,persistFallback:V=>v.update.mutateAsync({id:O,data:{connection_token:V}}).then(()=>{})});if(E.ran&&!E.ok){R("connection_oauth_failed",{connection_id:O,flow:"connect_new",error:E.error??"no_token"}),U.warning(a("virtualMcp.addConnectionDialog.signInFailedTitle"),{description:a("virtualMcp.addConnectionDialog.signInFailedDescription",{error:E.error??"no token received"})}),m(O,y.app_name??null,"new"),u(O);return}E.ran?(await x(O,"connect_new"),U.success(a("virtualMcp.addConnectionDialog.connectedAuthenticated"))):U.success(a("virtualMcp.addConnectionDialog.connected")),m(O,y.app_name??null,"new"),u(O)}catch(y){console.error("Failed to connect:",y),U.error(a("virtualMcp.addConnectionDialog.failedToConnect"))}finally{d(null)}}};return t.jsxs($t,{open:n,onOpenChange:e,children:[t.jsxs(Ft,{className:"sm:max-w-5xl h-[85vh] max-h-[85vh] flex flex-col p-0 gap-0 overflow-hidden w-[95vw]",children:[t.jsx(Bt,{className:"px-6 pt-5 pb-0 shrink-0",children:t.jsx(Lt,{className:"text-base font-semibold",children:a(l==="browse"?"virtualMcp.addConnectionDialog.connectionsTitle":"virtualMcp.addConnectionDialog.addConnectionTitle")})}),t.jsx("div",{className:"pt-3 shrink-0",children:t.jsx(En,{value:h,onChange:C,placeholder:a("virtualMcp.addConnectionDialog.searchConnectionsPlaceholder")})}),t.jsx(H.Suspense,{fallback:t.jsx("div",{className:"flex-1 flex items-center justify-center",children:t.jsx(ke,{size:24,className:"animate-spin text-muted-foreground"})}),children:t.jsx(qs,{mode:l,agentId:c,addedConnectionIds:r,onAdd:u,onCloneAndAdd:_,onConnectAndAdd:T,connectingItemId:f,search:h,onCreateConnection:()=>g(!0),onBrowseNavigate:z,defaultTab:s})})]}),t.jsx(Us,{open:p,onOpenChange:g,onCreated:async S=>{g(!1);const y=await et({connectionId:S,orgId:j.id,orgSlug:j.slug,persistFallback:I=>v.update.mutateAsync({id:S,data:{connection_token:I}}).then(()=>{})});if(y.ran&&!y.ok){R("connection_oauth_failed",{connection_id:S,flow:"custom_create",error:y.error??"no_token"}),U.warning(a("virtualMcp.addConnectionDialog.signInFailedTitle"),{description:a("virtualMcp.addConnectionDialog.signInFailedDescription",{error:y.error??"no token received"})}),m(S,null,"custom"),u(S),e(!1);return}y.ran&&await x(S,"custom_create"),m(S,null,"custom"),u(S),e(!1)}})]})}const gt=new Map;function ei(){const{org:n}=oe(),e=ls(),s=rs(),o=s.find(g=>g.providerId==="deco"),{data:i,isLoading:a,refetch:l,isFetching:c}=nn({queryKey:at.aiProviderCredits(n.id,"deco"),enabled:!!o,staleTime:6e4,queryFn:async()=>{try{return await e.call("AI_PROVIDER_CREDITS",{providerId:"deco"})}catch{return null}}}),r=i?.balanceCents??null,u=r!=null?r/100:null,m=H.useRef(new Map);if(r!=null){const g=gt.get(n.id);m.current.get(n.id)&&g!=null&&r>g&&R("credits_topped_up_detected",{organization_id:n.id,delta_cents:r-g,previous_balance_cents:g,new_balance_cents:r}),gt.set(n.id,r),m.current.set(n.id,!0)}const f=!!o,d=r!=null&&r>0,h=r!=null&&r===0,C=r!=null&&r===200,p=s.length>0&&s.every(g=>g.providerId==="deco");return{hasDecoKey:f,decoKeyId:o?.id??null,balanceCents:r,balanceDollars:u,hasCredits:d,isZeroBalance:h,isInitialFreeCredit:C,hasOnlyDecoProvider:p,isLoading:a,isFetching:c,refetch:l}}export{Yo as A,Xo as C,Jo as N,Wo as O,Qo as a,Zo as b,bs as c,rt as d,ei as u};
1
+ import{c as M,b as B,j as t,y as Ut,B as te,Z as qt,$ as Kt,a2 as ht,a1 as pt,e as Gt,a as ae,r as H,aR as Xt,d as st,s as Qt,m as X,t as U,w as Wt,k as ke,p as R,F as oe,f as ot,u as it,L as Yt,D as Jt,I as Zt,G as en,K as at,o as tn,n as nn}from"./index-BhSBUjFQ.js";import{i as sn}from"./ChevronRight-C3SZts0d.js";import{i as on}from"./X-CnAv-uVp.js";import{aD as an,Q as ln,A as xt,g as rn,ae as cn}from"./agent-icon-DFAPzr3v.js";import{t as jt}from"./ChevronDown-vt1NHoOA.js";import{T as Ce,a as ye,c as Se}from"./tooltip-VCgWirKW.js";import{u as bt,d as vt,c as Ct}from"./sidebar-CdN7y-oZ.js";import{a as lt,i as dn,f as un,S as mn,u as fn}from"./use-mcp-client-Klx7Tc0I.js";import{a as gn,u as hn}from"./use-virtual-mcp-YQKj8FPv.js";import{a as Le,b as yt,P as St}from"./popover-Bxj8hA4h.js";import{i as Ee}from"./Check-DzadTydo.js";import{s as Ne}from"./Plus-CMjdfynY.js";import{i as Nt}from"./SearchMd-B7U_-uKd.js";import{s as wt}from"./XClose-CLeFak--.js";import{A as pn,a as xn,b as jn,c as bn,e as vn,f as Cn,g as yn}from"./alert-dialog-Bj-lqnKh.js";import{d as W,F as nt,a as Y,e as J,b as Z,f as Sn,c as ee}from"./form-ClkOia2l.js";import{I as ie}from"./input-C-Ds0Orp.js";import{S as Nn}from"./spinner-CgIfhDcV.js";import{T as _t}from"./toolbar-Buy-Qrty.js";import{S as wn}from"./skeleton-D2rX-wFT.js";import{D as Dt,a as kt,b as At,c as _n,g as Dn,e as kn,f as An}from"./drawer-sKO31Ovm.js";import{u as It}from"./use-mobile-YZx5-gne.js";import{a as In,G as zn}from"./github-repo-picker-DcZpEA93.js";import{g as Tn,b as Pn,a as zt}from"./hooks-GqfCwZi9.js";import{u as On,g as Mn,a as $n,b as Fn}from"./use-navigate-to-agent-33xb87jb.js";import{a as Bn,c as Tt}from"./agent-capabilities-cXfbMfjV.js";import{u as Pt}from"./shell-layout-DelK1l0s.js";import{f as Ln}from"./reusable-new-chat-CouMjkYR.js";import{C as En}from"./collection-search-DCEO-Aiv.js";import{g as Vn,a as Rn,b as Hn,e as Un}from"./extract-connection-data-DOkhC5Rx.js";import{u as Ot,a as Mt,g as qn,C as Ye}from"./connection-card-B5_7Hwt3.js";import{e as $t,d as Ft,a as Bt,b as Lt,h as Kn,c as Gn}from"./dialog-CpfxMIGS.js";import{S as Xn,a as Qn,b as Wn,c as Yn,d as De}from"./select-DyYtIAIR.js";import{T as Jn}from"./textarea-DTuFQzPs.js";import{b as Et}from"./use-connection-6ojr7GjP.js";import{n as Be,i as Je}from"./Tool02-CoqAsydP.js";import{s as Ze}from"./Star01-V_cJa9vj.js";import{c as Zn,i as $e,a as ut,E as es,p as ts,b as ns,d as ss}from"./connection-form-helpers-ndCXct6V.js";import{a as et}from"./authenticate-and-persist-oauth-Bo-Iw6sZ.js";import{g as os}from"./connection-slug-eyAPH6o3.js";import{C as is}from"./collection-tabs-CisVdAEc.js";import{u as mt}from"./use-infinite-scroll-Uv9OSITw.js";import{B as Fe}from"./badge-CQTU24Ml.js";import{u as as}from"./useSuspenseInfiniteQuery-DQGAX-hV.js";import{g as Ve}from"./metadata-dUsYcpuu.js";import{u as ls}from"./studio-tools-BEhBpPdk.js";import{u as rs}from"./use-ai-providers-iwiQIKNO.js";const cs="https://decoims.com/image?src=decocms%2F06b54678-5335-4671-b63a-e13d9e541155%2Fagataesteves.png&quality=original&fit=cover&width=160&height=160";function ds(){const n=M.c(13),e=B();let s;n[0]===Symbol.for("react.memo_cache_sentinel")?(s=t.jsx("img",{src:"/logos/summit/monte-carlo.svg",alt:"Monte Carlo",className:"h-14 w-[112px] shrink-0 self-start object-contain object-left brightness-0 invert"}),n[0]=s):s=n[0];let o;n[1]!==e?(o=e("routes.commerceOnboarding.connectModal.quote"),n[1]=e,n[2]=o):o=n[2];let i;n[3]!==o?(i=t.jsxs("blockquote",{className:"text-lg font-medium leading-[1.45] lg:text-xl",children:["“",o,"”"]}),n[3]=o,n[4]=i):i=n[4];let a;n[5]===Symbol.for("react.memo_cache_sentinel")?(a=t.jsx("img",{src:cs,alt:"",className:"size-10 shrink-0 rounded-full object-cover",loading:"lazy"}),n[5]=a):a=n[5];let l;n[6]!==e?(l=e("routes.commerceOnboarding.connectModal.quoteAuthor"),n[6]=e,n[7]=l):l=n[7];let c;n[8]!==l?(c=t.jsxs("figcaption",{className:"flex items-center gap-2.5",children:[a,t.jsx("span",{className:"text-base font-medium",children:l})]}),n[8]=l,n[9]=c):c=n[9];let r;return n[10]!==i||n[11]!==c?(r=t.jsxs("div",{className:"relative flex flex-col gap-8 text-white",children:[s,i,c]}),n[10]=i,n[11]=c,n[12]=r):r=n[12],r}function us(){const n=M.c(19),e=B();let s;n[0]!==e?(s=e("routes.commerceOnboarding.connectModal.trustRevoke"),n[0]=e,n[1]=s):s=n[1];let o;n[2]!==s?(o={Icon:an,label:s},n[2]=s,n[3]=o):o=n[3];let i;n[4]!==e?(i=e("routes.commerceOnboarding.connectModal.trustEncrypted"),n[4]=e,n[5]=i):i=n[5];let a;n[6]!==i?(a={Icon:Ut,label:i},n[6]=i,n[7]=a):a=n[7];let l;n[8]!==e?(l=e("routes.commerceOnboarding.connectModal.trustNeverSold"),n[8]=e,n[9]=l):l=n[9];let c;n[10]!==l?(c={Icon:ln,label:l},n[10]=l,n[11]=c):c=n[11];let r;n[12]!==o||n[13]!==a||n[14]!==c?(r=[o,a,c],n[12]=o,n[13]=a,n[14]=c,n[15]=r):r=n[15];const u=r;let m;n[16]===Symbol.for("react.memo_cache_sentinel")?(m=t.jsx("div",{className:"h-px w-full bg-white/15"}),n[16]=m):m=n[16];let f;return n[17]!==u?(f=t.jsxs("div",{className:"relative flex flex-col gap-2.5 text-white",children:[m,t.jsx("ul",{className:"mt-1 flex flex-col gap-2.5",children:u.map(ms)})]}),n[17]=u,n[18]=f):f=n[18],f}function ms(n){const{Icon:e,label:s}=n;return t.jsxs("li",{className:"flex items-center gap-2.5 text-[13px] leading-tight text-white/70",children:[t.jsx(e,{className:"size-4 shrink-0 opacity-85"}),s]},s)}function Xo(n){const e=M.c(22),{siteHost:s,footer:o,onClose:i,children:a}=n,l=B(),c=s?`https://www.google.com/s2/favicons?domain=${s}&sz=128`:null;let r;e[0]!==i||e[1]!==l?(r=i&&t.jsx("button",{type:"button",onClick:i,"aria-label":l("routes.commerceOnboarding.connectModal.close"),className:"absolute right-3 top-3 z-10 flex size-9 items-center justify-center rounded-lg text-muted-foreground transition-colors hover:bg-black/10 hover:text-foreground lg:text-white/80 lg:hover:bg-white/15 lg:hover:text-white",children:t.jsx(on,{size:18})}),e[0]=i,e[1]=l,e[2]=r):r=e[2];let u,m;e[3]===Symbol.for("react.memo_cache_sentinel")?(u=t.jsx("img",{src:"/logos/deco logo.svg",alt:"Deco",className:"size-7 shrink-0 dark:hidden"}),m=t.jsx("img",{src:"/logos/deco logo negative.svg",alt:"Deco",className:"hidden size-7 shrink-0 dark:block"}),e[3]=u,e[4]=m):(u=e[3],m=e[4]);let f;e[5]!==c||e[6]!==s?(f=s&&t.jsxs(t.Fragment,{children:[t.jsx(sn,{size:16,className:"shrink-0 text-foreground/25"}),c&&t.jsx("span",{className:"flex size-4 shrink-0 items-center justify-center overflow-hidden rounded bg-white",children:t.jsx("img",{src:c,alt:"",className:"size-full"})}),t.jsx("span",{className:"truncate text-[15px] leading-tight text-muted-foreground",children:s})]}),e[5]=c,e[6]=s,e[7]=f):f=e[7];let d;e[8]!==f?(d=t.jsxs("div",{className:"flex items-center gap-2",children:[u,m,f]}),e[8]=f,e[9]=d):d=e[9];let h;e[10]!==o?(h=t.jsx("div",{className:"flex shrink-0 flex-col gap-3",children:o}),e[10]=o,e[11]=h):h=e[11];let C;e[12]!==a||e[13]!==d||e[14]!==h?(C=t.jsxs("div",{className:"flex min-h-0 flex-1 flex-col gap-8 bg-background p-6 lg:p-8",children:[d,a,h]}),e[12]=a,e[13]=d,e[14]=h,e[15]=C):C=e[15];let p,g;e[16]===Symbol.for("react.memo_cache_sentinel")?(p=t.jsx("img",{src:"https://decoims.com/image?src=decocms%2F8191643a-1947-4c30-afb4-36b8073c90fb%2Fbg-quote.png&quality=original&fit=cover&width=880",alt:"",className:"absolute inset-0 size-full object-cover"}),g=t.jsx("div",{className:"absolute inset-0 bg-black/20"}),e[16]=p,e[17]=g):(p=e[16],g=e[17]);let j;e[18]===Symbol.for("react.memo_cache_sentinel")?(j=t.jsxs("aside",{className:"relative hidden shrink-0 overflow-hidden lg:flex lg:w-[440px] lg:flex-col lg:p-14",children:[p,g,t.jsxs("div",{className:"relative z-10 flex h-full flex-col",children:[t.jsx("div",{className:"flex-1"}),t.jsx(ds,{}),t.jsx("div",{className:"flex-1"}),t.jsx(us,{})]})]}),e[18]=j):j=e[18];let b;return e[19]!==r||e[20]!==C?(b=t.jsxs("div",{className:"relative flex min-h-0 flex-1 flex-col lg:flex-row",children:[r,C,j]}),e[19]=r,e[20]=C,e[21]=b):b=e[21],b}function Qo(n){const e=M.c(5),{ready:s,pending:o,label:i,onClick:a,children:l}=n,c=o||!s,r=s&&!o?l:null;let u;return e[0]!==i||e[1]!==a||e[2]!==c||e[3]!==r?(u=t.jsxs(te,{type:"button",size:"lg",className:"h-auto min-h-12 w-full whitespace-normal rounded-lg py-3 text-center text-base font-medium leading-tight",onClick:a,disabled:c,children:[i,r]}),e[0]=i,e[1]=a,e[2]=c,e[3]=r,e[4]=u):u=e[4],u}function ft(n){return n.toLowerCase().trim().replace(/[^a-z0-9\s_-]+/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const fs=qt({name:Kt().min(2,"Organization name is required")});function gs(n){const e=M.c(66),{open:s,onOpenChange:o}=n,i=B();let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a={resolver:ht(fs),defaultValues:{name:""}},e[0]=a):a=e[0];const l=pt(a);let c;e[1]!==i?(c=async V=>{const $=ft(V.name);if(!$)throw new Error(i("common.createOrganizationDialog.invalidSlug"));const K=await ae.organization.create({name:V.name,slug:$});if(K?.error)throw new Error(K.error.message||i("common.createOrganizationDialog.failedToCreate"));const q=K?.data?.slug??$;if(!q)throw new Error(i("common.createOrganizationDialog.failedToCreate"));return{orgSlug:q}},e[1]=i,e[2]=c):c=e[2];let r;e[3]===Symbol.for("react.memo_cache_sentinel")?(r=hs,e[3]=r):r=e[3];let u;e[4]!==c?(u={mutationFn:c,onSuccess:r},e[4]=c,e[5]=u):u=e[5];const m=Gt(u);let f;e[6]!==m.error||e[7]!==i?(f=m.error instanceof Error?m.error.message:m.error?i("common.createOrganizationDialog.failedToCreateGeneric"):null,e[6]=m.error,e[7]=i,e[8]=f):f=e[8];const d=f;let h;e[9]!==i?(h=i("common.createOrganizationDialog.title"),e[9]=i,e[10]=h):h=e[10];let C;e[11]!==h?(C=t.jsx(pn,{children:h}),e[11]=h,e[12]=C):C=e[12];let p;e[13]!==i?(p=i("common.createOrganizationDialog.description"),e[13]=i,e[14]=p):p=e[14];let g;e[15]!==p?(g=t.jsx(xn,{children:p}),e[15]=p,e[16]=g):g=e[16];let j;e[17]!==C||e[18]!==g?(j=t.jsxs(jn,{children:[C,g]}),e[17]=C,e[18]=g,e[19]=j):j=e[19];let b;if(e[20]!==m||e[21]!==l){let V;e[23]!==m?(V=$=>m.mutateAsync($),e[23]=m,e[24]=V):V=e[24],b=l.handleSubmit(V),e[20]=m,e[21]=l,e[22]=b}else b=e[22];let v;e[25]!==l.formState.isSubmitting||e[26]!==i?(v=V=>{const{field:$}=V;return t.jsxs(Y,{children:[t.jsx(J,{children:i("common.createOrganizationDialog.nameLabel")}),t.jsx(Z,{children:t.jsx(ie,{...$,placeholder:i("common.createOrganizationDialog.namePlaceholder"),disabled:l.formState.isSubmitting})}),t.jsx(Sn,{children:i("common.createOrganizationDialog.nameDescription")}),$.value&&t.jsxs("div",{className:"text-xs text-muted-foreground mt-1",children:[i("common.createOrganizationDialog.urlLabel")," ",t.jsxs("span",{className:"font-mono",children:[typeof window<"u"?globalThis.location.origin:"","/",ft($.value)]})]}),t.jsx(ee,{})]})},e[25]=l.formState.isSubmitting,e[26]=i,e[27]=v):v=e[27];let N;e[28]!==l.control||e[29]!==v?(N=t.jsx(W,{control:l.control,name:"name",render:v}),e[28]=l.control,e[29]=v,e[30]=N):N=e[30];let w;e[31]!==d?(w=d&&t.jsx("div",{className:"text-destructive text-sm mt-2",children:d}),e[31]=d,e[32]=w):w=e[32];const z=l.formState.isSubmitting;let P;e[33]!==m||e[34]!==l?(P=()=>{m.reset(),l.reset()},e[33]=m,e[34]=l,e[35]=P):P=e[35];let x;e[36]!==i?(x=i("common.createOrganizationDialog.cancel"),e[36]=i,e[37]=x):x=e[37];let _;e[38]!==l.formState.isSubmitting||e[39]!==P||e[40]!==x?(_=t.jsx(bn,{disabled:z,onClick:P,children:x}),e[38]=l.formState.isSubmitting,e[39]=P,e[40]=x,e[41]=_):_=e[41];const T=!l.formState.isValid||l.formState.isSubmitting;let S;e[42]!==l.formState.isSubmitting||e[43]!==i?(S=l.formState.isSubmitting?t.jsxs("span",{className:"flex items-center gap-2",children:[t.jsx(Nn,{size:"xs"})," ",i("common.createOrganizationDialog.creating")]}):i("common.createOrganizationDialog.createButton"),e[42]=l.formState.isSubmitting,e[43]=i,e[44]=S):S=e[44];let y;e[45]!==T||e[46]!==S?(y=t.jsx(te,{type:"submit",variant:"default",disabled:T,children:S}),e[45]=T,e[46]=S,e[47]=y):y=e[47];let I;e[48]!==_||e[49]!==y?(I=t.jsxs(vn,{children:[_,y]}),e[48]=_,e[49]=y,e[50]=I):I=e[50];let k;e[51]!==b||e[52]!==N||e[53]!==w||e[54]!==I?(k=t.jsxs("form",{className:"space-y-6",onSubmit:b,autoComplete:"off",children:[N,w,I]}),e[51]=b,e[52]=N,e[53]=w,e[54]=I,e[55]=k):k=e[55];let A;e[56]!==l||e[57]!==k?(A=t.jsx(nt,{...l,children:k}),e[56]=l,e[57]=k,e[58]=A):A=e[58];let O;e[59]!==j||e[60]!==A?(O=t.jsxs(Cn,{children:[j,A]}),e[59]=j,e[60]=A,e[61]=O):O=e[61];let E;return e[62]!==o||e[63]!==s||e[64]!==O?(E=t.jsx(yn,{open:s,onOpenChange:o,children:O}),e[62]=o,e[63]=s,e[64]=O,e[65]=E):E=e[65],E}function hs(n){const{orgSlug:e}=n;window.location.href=`/${e}`}function Vt(){const n=H.useContext(Xt),{data:e,refetch:s}=n.hooks.useListUserInvitations();return{invitations:(e??[]).filter(i=>i.status==="pending"&&new Date(i.expiresAt)>new Date),refetch:()=>s?.()}}function ps(n){let e=0;for(let o=0;o<n.length;o++)e=n.charCodeAt(o)+((e<<5)-e);const s=Math.abs(e)%360;return{backgroundColor:`hsl(${s} 55% 70%)`,color:`hsl(${s} 55% 20%)`}}function rt(n){const e=M.c(13),{org:s,size:o}=n,i=o===void 0?"sm":o,a=i==="xs"?"size-5":"size-6",l=i==="xs"?"text-[9px]":"text-xs";let c;e[0]!==a?(c=X(a,"shrink-0 rounded-md flex items-center justify-center border border-border/50 overflow-hidden"),e[0]=a,e[1]=c):c=e[1];let r;e[2]!==s.logo||e[3]!==s.name?(r=s.logo?void 0:ps(s.name),e[2]=s.logo,e[3]=s.name,e[4]=r):r=e[4];let u;e[5]!==s.logo||e[6]!==s.name||e[7]!==l?(u=s.logo?t.jsx("img",{src:s.logo,alt:"",className:"size-full object-cover"}):t.jsx("span",{className:X("font-semibold leading-none",l),children:s.name.slice(0,2).toUpperCase()}),e[5]=s.logo,e[6]=s.name,e[7]=l,e[8]=u):u=e[8];let m;return e[9]!==c||e[10]!==r||e[11]!==u?(m=t.jsx("div",{className:c,style:r,children:u}),e[9]=c,e[10]=r,e[11]=u,e[12]=m):m=e[12],m}function xs({invitation:n,onChanged:e}){const s=B(),[o,i]=H.useState(!1),a=n.organizationName??s("header.orgSwitcher.unknownOrganization"),l=async()=>{i(!0);try{const u=await ae.organization.acceptInvitation({invitationId:n.id});if(u.error){U.error(u.error.message),i(!1);return}}catch{U.error(s("header.orgSwitcher.failedToAcceptInvitation")),i(!1);return}U.success(s("header.orgSwitcher.joined",{name:a})),Wt();let r;try{r=(await ae.organization.getFullOrganization({query:{organizationId:n.organizationId}}))?.data?.slug}catch{}window.location.href=r?`/${r}`:"/"},c=async()=>{i(!0);try{const r=await ae.organization.rejectInvitation({invitationId:n.id});if(r.error){U.error(r.error.message),i(!1);return}U.success(s("header.orgSwitcher.invitationDeclined")),i(!1),e()}catch{U.error(s("header.orgSwitcher.failedToDeclineInvitation")),i(!1)}};return t.jsxs("div",{className:"flex items-center gap-3 rounded-md border border-dashed border-border px-3 py-2.5",children:[t.jsx(rt,{org:{name:a},size:"sm"}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("p",{className:"truncate text-sm font-medium",children:a}),t.jsx("p",{className:"truncate text-xs text-muted-foreground",children:s("header.orgSwitcher.invitedToJoin")})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[t.jsx(te,{size:"sm",variant:"default",className:"h-7 text-xs",onClick:l,disabled:o,children:s("header.orgSwitcher.accept")}),t.jsx(te,{size:"icon",variant:"ghost",className:"size-7 text-muted-foreground",onClick:c,disabled:o,"aria-label":s("header.orgSwitcher.declineInvitationTo",{name:a}),children:t.jsx(wt,{size:14})})]})]})}function js(n){const e=M.c(32),{orgParam:s,onSelectOrg:o,onCreateOrg:i}=n,a=B(),{data:l}=Qt(),{invitations:c,refetch:r}=Vt();let u;e[0]!==s?(u=(k,A)=>k.slug===s?-1:A.slug===s?1:k.name.localeCompare(A.name),e[0]=s,e[1]=u):u=e[1];const m=[...l??[]].sort(u),[f,d]=H.useState(""),h=f.toLowerCase(),C=h?m.filter(k=>k.name.toLowerCase().includes(h)||k.slug.toLowerCase().includes(h)):m;let p;e[2]===Symbol.for("react.memo_cache_sentinel")?(p=t.jsx(Nt,{size:16,className:"shrink-0 text-muted-foreground/60"}),e[2]=p):p=e[2];let g;e[3]===Symbol.for("react.memo_cache_sentinel")?(g=k=>d(k.target.value),e[3]=g):g=e[3];let j;e[4]!==f?(j=k=>k.key==="Escape"&&f&&d(""),e[4]=f,e[5]=j):j=e[5];let b;e[6]!==a?(b=a("header.orgSwitcher.searchOrganizations"),e[6]=a,e[7]=b):b=e[7];let v;e[8]!==f||e[9]!==j||e[10]!==b?(v=t.jsx("input",{"data-org-switcher-search":!0,autoFocus:!0,type:"text",value:f,onChange:g,onKeyDown:j,placeholder:b,className:"flex-1 min-w-0 bg-transparent text-sm outline-none placeholder:text-muted-foreground/60"}),e[8]=f,e[9]=j,e[10]=b,e[11]=v):v=e[11];let N;e[12]===Symbol.for("react.memo_cache_sentinel")?(N=t.jsx(Ne,{size:16}),e[12]=N):N=e[12];let w;e[13]!==i?(w=t.jsx("button",{type:"button",onClick:i,className:"flex items-center justify-center size-7 rounded-md text-muted-foreground hover:bg-accent/50 hover:text-foreground transition-colors",children:N}),e[13]=i,e[14]=w):w=e[14];let z;e[15]!==v||e[16]!==w?(z=t.jsxs("div",{className:"flex items-center gap-2 px-3 py-2.5 border-b border-border/50",children:[p,v,w]}),e[15]=v,e[16]=w,e[17]=z):z=e[17];const P="flex-1 min-h-0 overflow-y-auto p-1.5 flex flex-col gap-1";let x;e[18]!==c||e[19]!==f||e[20]!==r?(x=!f&&c.map(k=>t.jsx(xs,{invitation:k,onChanged:r},k.id)),e[18]=c,e[19]=f,e[20]=r,e[21]=x):x=e[21];const _=C.length===0&&t.jsx("p",{className:"px-3 py-4 text-sm text-muted-foreground/60 text-center",children:f?a("header.orgSwitcher.noOrganizationsMatch",{query:f}):a("header.orgSwitcher.noOrganizationsAvailable")});let T;e[22]!==o||e[23]!==s?(T=k=>t.jsxs("button",{type:"button",onClick:()=>o(k.slug),className:X("flex items-center gap-3 px-3 py-2.5 rounded-md text-sm text-left w-full transition-colors",k.slug===s?"bg-accent text-accent-foreground":"text-foreground hover:bg-accent/50"),children:[t.jsx(rt,{org:k,size:"sm"}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("p",{className:"text-sm font-medium truncate",children:k.name}),t.jsx("p",{className:"text-xs text-muted-foreground truncate",children:k.slug})]}),k.slug===s&&t.jsx(Ee,{size:14,className:"ml-auto text-muted-foreground shrink-0"})]},k.id),e[22]=o,e[23]=s,e[24]=T):T=e[24];const S=C.map(T);let y;e[25]!==x||e[26]!==_||e[27]!==S?(y=t.jsxs("div",{className:P,children:[x,_,S]}),e[25]=x,e[26]=_,e[27]=S,e[28]=y):y=e[28];let I;return e[29]!==y||e[30]!==z?(I=t.jsxs(t.Fragment,{children:[z,y]}),e[29]=y,e[30]=z,e[31]=I):I=e[31],I}function bs(n){const e=M.c(22),{trigger:s,orgParam:o,align:i,side:a}=n,l=i===void 0?"start":i,c=a===void 0?"bottom":a,r=st(),[u,m]=H.useState(!1),[f,d]=H.useState(!1);let h;e[0]!==s?(h=t.jsx(Le,{asChild:!0,children:s}),e[0]=s,e[1]=h):h=e[1];const C=String(u);let p;e[2]!==r?(p=z=>{m(!1),r({to:"/$org",params:{org:z}})},e[2]=r,e[3]=p):p=e[3];let g;e[4]===Symbol.for("react.memo_cache_sentinel")?(g=()=>{m(!1),d(!0)},e[4]=g):g=e[4];let j;e[5]!==o||e[6]!==C||e[7]!==p?(j=t.jsx(js,{orgParam:o,onSelectOrg:p,onCreateOrg:g},C),e[5]=o,e[6]=C,e[7]=p,e[8]=j):j=e[8];let b;e[9]!==l||e[10]!==c||e[11]!==j?(b=t.jsx(yt,{side:c,align:l,sideOffset:8,collisionPadding:16,className:"w-[300px] p-0 flex flex-col max-h-[440px]",onOpenAutoFocus:Cs,onCloseAutoFocus:vs,children:j}),e[9]=l,e[10]=c,e[11]=j,e[12]=b):b=e[12];let v;e[13]!==u||e[14]!==h||e[15]!==b?(v=t.jsxs(St,{open:u,onOpenChange:m,children:[h,b]}),e[13]=u,e[14]=h,e[15]=b,e[16]=v):v=e[16];let N;e[17]!==f?(N=t.jsx(gs,{open:f,onOpenChange:d}),e[17]=f,e[18]=N):N=e[18];let w;return e[19]!==N||e[20]!==v?(w=t.jsxs(t.Fragment,{children:[v,N]}),e[19]=N,e[20]=v,e[21]=w):w=e[21],w}function vs(n){return n.preventDefault()}function Cs(n){n.preventDefault(),n.currentTarget?.querySelector("[data-org-switcher-search]")?.focus()}function ys(n){const e=M.c(21),{value:s,onChange:o,placeholder:i,onKeyDown:a,className:l,isSearching:c,disabled:r}=n,u=i===void 0?"Search...":i;let m;e[0]!==l?(m=X("shrink-0 w-full border-b border-border h-12",l),e[0]=l,e[1]=m):m=e[1];const f=r?"cursor-not-allowed opacity-50":"cursor-text";let d;e[2]!==f?(d=X("flex items-center gap-2.5 h-12 px-4",f),e[2]=f,e[3]=d):d=e[3];let h;e[4]!==c?(h=c?t.jsx(ke,{size:16,className:"animate-spin text-muted-foreground shrink-0"}):t.jsx(Nt,{size:16,className:"text-muted-foreground shrink-0"}),e[4]=c,e[5]=h):h=e[5];let C;e[6]!==o?(C=b=>o(b.target.value),e[6]=o,e[7]=C):C=e[7];let p;e[8]!==r||e[9]!==a||e[10]!==u||e[11]!==C||e[12]!==s?(p=t.jsx("input",{type:"text",value:s,onChange:C,onKeyDown:a,placeholder:u,disabled:r,className:"flex-1 min-w-0 bg-transparent text-sm text-foreground placeholder:text-muted-foreground/50 outline-none"}),e[8]=r,e[9]=a,e[10]=u,e[11]=C,e[12]=s,e[13]=p):p=e[13];let g;e[14]!==d||e[15]!==h||e[16]!==p?(g=t.jsxs("label",{className:d,children:[h,p]}),e[14]=d,e[15]=h,e[16]=p,e[17]=g):g=e[17];let j;return e[18]!==m||e[19]!==g?(j=t.jsx("div",{className:m,children:g}),e[18]=m,e[19]=g,e[20]=j):j=e[20],j}function Ss(n,e,s){if(!s)return null;const o=Tn(n,e);return o?o.threads.get().find(a=>a.id===s)?.branch??null:null}function Ns(n){const e=M.c(6),{value:s,onChange:o}=n,i=B();let a;e[0]!==i?(a=i("sidebar.agentsSection.searchAgents"),e[0]=i,e[1]=a):a=e[1];let l;return e[2]!==o||e[3]!==a||e[4]!==s?(l=t.jsx(ys,{value:s,onChange:o,placeholder:a}),e[2]=o,e[3]=a,e[4]=s,e[5]=l):l=e[5],l}function ws(){const n=M.c(4),e=B();let s;n[0]!==e?(s=e("sidebar.agentsSection.noAgentsFound"),n[0]=e,n[1]=s):s=n[1];let o;return n[2]!==s?(o=t.jsx("div",{className:"flex items-center justify-center py-6 text-xs text-muted-foreground",children:s}),n[2]=s,n[3]=o):o=n[3],o}function _s(n){const e=M.c(10),{org:s,onClose:o}=n,i=B();let a;e[0]!==s.slug?(a={org:s.slug},e[0]=s.slug,e[1]=a):a=e[1];let l;e[2]!==o?(l=()=>o(),e[2]=o,e[3]=l):l=e[3];let c;e[4]!==i?(c=i("sidebar.agentsSection.seeAllAgents"),e[4]=i,e[5]=c):c=e[5];let r;return e[6]!==a||e[7]!==l||e[8]!==c?(r=t.jsx("div",{className:"border-t border-border px-3 py-2.5",children:t.jsx(Yt,{to:"/$org/settings/agents",params:a,onClick:l,className:"text-xs text-muted-foreground hover:text-foreground transition-colors flex items-center justify-center",children:c})}),e[6]=a,e[7]=l,e[8]=c,e[9]=r):r=e[9],r}function Ds(){const n=M.c(4),e=B();let s;n[0]!==e?(s=e("sidebar.agentsSection.agents"),n[0]=e,n[1]=s):s=n[1];let o;return n[2]!==s?(o=t.jsx(Rt,{children:s}),n[2]=s,n[3]=o):o=n[3],o}function ks(n){const e=M.c(11),{onImportFromGithub:s}=n,o=B();let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=t.jsx(zn,{className:"size-3.5"}),e[0]=i):i=e[0];let a;e[1]!==o?(a=o("sidebar.agentsSection.import"),e[1]=o,e[2]=a):a=e[2];let l;e[3]!==s||e[4]!==a?(l=t.jsxs("button",{type:"button",onClick:s,className:"flex items-center gap-1.5 rounded-md px-2 py-1 text-xs font-medium text-muted-foreground transition-colors hover:bg-accent/50 hover:text-foreground",children:[i,a]}),e[3]=s,e[4]=a,e[5]=l):l=e[5];let c;e[6]!==o?(c=o("sidebar.agentsSection.codeAgents"),e[6]=o,e[7]=c):c=e[7];let r;return e[8]!==l||e[9]!==c?(r=t.jsx(Rt,{action:l,children:c}),e[8]=l,e[9]=c,e[10]=r):r=e[10],r}function As(n){const e=M.c(11),{setOpen:s,emptyCtaClass:o}=n,i=B();let a;e[0]!==i?(a=i("sidebar.agentsSection.browseAgents"),e[0]=i,e[1]=a):a=e[1];let l;e[2]!==o?(l=X(o),e[2]=o,e[3]=l):l=e[3];let c;e[4]!==s?(c=()=>{R("agent_browser_opened",{surface:"mobile_drawer"}),s(!0)},e[4]=s,e[5]=c):c=e[5];let r;e[6]===Symbol.for("react.memo_cache_sentinel")?(r=t.jsx(Ne,{className:"size-4"}),e[6]=r):r=e[6];let u;return e[7]!==a||e[8]!==l||e[9]!==c?(u=t.jsx(_t,{"aria-label":a,className:l,onClick:c,children:r}),e[7]=a,e[8]=l,e[9]=c,e[10]=u):u=e[10],u}function Is(n){const e=M.c(17),{setOpen:s,highlightEmpty:o,emptyCtaClass:i}=n,a=B();let l;e[0]!==o||e[1]!==a?(l=o?void 0:a("sidebar.agentsSection.browseAgents"),e[0]=o,e[1]=a,e[2]=l):l=e[2];let c;e[3]!==i?(c=X(i),e[3]=i,e[4]=c):c=e[4];let r;e[5]!==s?(r=()=>{R("agent_browser_opened",{surface:"mobile_drawer"}),s(!0)},e[5]=s,e[6]=r):r=e[6];let u;e[7]===Symbol.for("react.memo_cache_sentinel")?(u=t.jsx(Ne,{}),e[7]=u):u=e[7];let m;e[8]!==a?(m=a("sidebar.agentsSection.newAgent"),e[8]=a,e[9]=m):m=e[9];let f;e[10]!==m?(f=t.jsx("span",{children:m}),e[10]=m,e[11]=f):f=e[11];let d;return e[12]!==l||e[13]!==c||e[14]!==r||e[15]!==f?(d=t.jsx(vt,{children:t.jsxs(Ct,{tooltip:l,className:c,onClick:r,children:[u,f]})}),e[12]=l,e[13]=c,e[14]=r,e[15]=f,e[16]=d):d=e[16],d}function zs(){const n=M.c(4),e=B();let s;n[0]!==e?(s=e("sidebar.agentsSection.browseAgents"),n[0]=e,n[1]=s):s=n[1];let o;return n[2]!==s?(o=t.jsx(At,{className:"sr-only",children:s}),n[2]=s,n[3]=o):o=n[3],o}function Ts(n){const e=M.c(8),{emptyCtaClass:s}=n,o=B();let i;e[0]!==o?(i=o("sidebar.agentsSection.browseAgents"),e[0]=o,e[1]=i):i=e[1];let a;e[2]!==s?(a=X(s),e[2]=s,e[3]=a):a=e[3];let l;e[4]===Symbol.for("react.memo_cache_sentinel")?(l=t.jsx(Ne,{className:"size-4"}),e[4]=l):l=e[4];let c;return e[5]!==i||e[6]!==a?(c=t.jsx(_t,{"aria-label":i,className:a,children:l}),e[5]=i,e[6]=a,e[7]=c):c=e[7],c}function Ps(n){const e=M.c(19),{wrapEmptyHint:s,highlightEmpty:o,emptyCtaClass:i}=n,a=B();let l;e[0]!==o||e[1]!==a?(l=o?void 0:a("sidebar.agentsSection.browseAgents"),e[0]=o,e[1]=a,e[2]=l):l=e[2];let c;e[3]!==i?(c=X(i),e[3]=i,e[4]=c):c=e[4];let r;e[5]===Symbol.for("react.memo_cache_sentinel")?(r=t.jsx(Ne,{}),e[5]=r):r=e[5];let u;e[6]!==a?(u=a("sidebar.agentsSection.newAgent"),e[6]=a,e[7]=u):u=e[7];let m;e[8]!==u?(m=t.jsx("span",{children:u}),e[8]=u,e[9]=m):m=e[9];let f;e[10]!==l||e[11]!==c||e[12]!==m?(f=t.jsx(Le,{asChild:!0,children:t.jsxs(Ct,{tooltip:l,className:c,children:[r,m]})}),e[10]=l,e[11]=c,e[12]=m,e[13]=f):f=e[13];let d;e[14]!==f||e[15]!==s?(d=s(f),e[14]=f,e[15]=s,e[16]=d):d=e[16];let h;return e[17]!==d?(h=t.jsx(vt,{children:d}),e[17]=d,e[18]=h):h=e[18],h}function Os(n){const e=M.c(9),{children:s}=n,o=B();let i;e[0]!==s?(i=t.jsx(Ce,{asChild:!0,children:s}),e[0]=s,e[1]=i):i=e[1];let a;e[2]!==o?(a=o("sidebar.agentsSection.selectAnExistingAgent"),e[2]=o,e[3]=a):a=e[3];let l;e[4]!==a?(l=t.jsx(ye,{side:"right",sideOffset:8,children:a}),e[4]=a,e[5]=l):l=e[5];let c;return e[6]!==i||e[7]!==l?(c=t.jsxs(Se,{defaultOpen:!0,delayDuration:0,children:[i,l]}),e[6]=i,e[7]=l,e[8]=c):c=e[8],c}function Ms(n){const e=st(),{create:s}=Pn(),{locator:o}=oe(),i=ot({strict:!1}),a=it({strict:!1});return async l=>{const c=crypto.randomUUID(),r=l===a.virtualmcpid?Ss(n,o,i.taskId??""):null;try{await s({id:c,virtual_mcp_id:l,...r?{branch:r}:{}})}catch{}e({to:"/$org/$taskId",params:{org:n,taskId:c},search:{virtualmcpid:l}})}}function tt(n){const e=M.c(20),{agent:s,selected:o,onClick:i}=n,a=o?"bg-accent text-accent-foreground":"text-foreground hover:bg-accent/50";let l;e[0]!==a?(l=X("flex items-center gap-3 px-3 py-2.5 rounded-md text-sm text-left w-full transition-colors",a),e[0]=a,e[1]=l):l=e[1];let c;e[2]!==s.icon||e[3]!==s.title?(c=t.jsx(xt,{icon:s.icon,name:s.title,size:"xs",className:"shrink-0"}),e[2]=s.icon,e[3]=s.title,e[4]=c):c=e[4];let r;e[5]!==s.title?(r=t.jsx("p",{className:"text-sm font-medium truncate",children:s.title}),e[5]=s.title,e[6]=r):r=e[6];let u;e[7]!==s.description?(u=s.description&&t.jsx("p",{className:"text-xs text-muted-foreground truncate",children:s.description}),e[7]=s.description,e[8]=u):u=e[8];let m;e[9]!==r||e[10]!==u?(m=t.jsxs("div",{className:"flex-1 min-w-0",children:[r,u]}),e[9]=r,e[10]=u,e[11]=m):m=e[11];let f;e[12]!==o?(f=o&&t.jsx(Ee,{size:14,className:"ml-auto text-muted-foreground shrink-0"}),e[12]=o,e[13]=f):f=e[13];let d;return e[14]!==i||e[15]!==l||e[16]!==c||e[17]!==m||e[18]!==f?(d=t.jsxs("button",{type:"button",onClick:i,className:l,children:[c,m,f]}),e[14]=i,e[15]=l,e[16]=c,e[17]=m,e[18]=f,e[19]=d):d=e[19],d}function Rt(n){const e=M.c(5),{children:s,action:o}=n;let i;e[0]!==s?(i=t.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:s}),e[0]=s,e[1]=i):i=e[1];let a;return e[2]!==o||e[3]!==i?(a=t.jsxs("div",{className:"flex items-center justify-between px-3 pb-1 pt-2",children:[i,o]}),e[2]=o,e[3]=i,e[4]=a):a=e[4],a}function $s(n){const e=M.c(23),{onClose:s,onSelectAgent:o,selectedAgentId:i,onImportFromGithub:a}=n,[l,c]=H.useState(""),r=gn(),u=r??[],{org:m}=oe(),{data:f}=ae.useSession(),d=f?.user?.id??"anon",h=Mn(r),C=$n(),p=Ms(m.slug),g=Bn(r),j=l.toLowerCase(),b=u.filter(Es).filter(L=>!g.has(L.id)).filter(Ls).filter(L=>!l||L.title.toLowerCase().includes(j)),v=b.filter(Bs),N=b.filter(Fs),w=lt(m.id),z=!l||w.title.toLowerCase().includes(j),P=!!(o&&z);let x;e[0]!==s||e[1]!==o?(x=()=>{o?.(null),s(),c("")},e[0]=s,e[1]=o,e[2]=x):x=e[2];const _=x,T=L=>{if(o){o(L.id),s(),c("");return}Fn({orgId:m.id,userId:d},L.id,h),C(),s(),c(""),p(L.id)},S="flex flex-col max-h-[min(640px,80dvh)]";let y;e[3]!==l?(y=t.jsx(Ns,{value:l,onChange:c}),e[3]=l,e[4]=y):y=e[4];const I="overflow-y-auto flex-1 min-h-0 p-1.5 flex flex-col gap-0.5",k=o&&z&&w&&t.jsx(tt,{agent:w,selected:!i||i===w.id,onClick:_}),A=(v.length>0||!l)&&t.jsx(ks,{onImportFromGithub:a}),O=v.map(L=>t.jsx(tt,{agent:L,selected:o?i===L.id:void 0,onClick:()=>T(L)},L.id)),E=N.length>0&&t.jsx(Ds,{}),V=N.map(L=>t.jsx(tt,{agent:L,selected:o?i===L.id:void 0,onClick:()=>T(L)},L.id));let $;e[5]!==P||e[6]!==l||e[7]!==b.length?($=b.length===0&&!P&&l&&t.jsx(ws,{}),e[5]=P,e[6]=l,e[7]=b.length,e[8]=$):$=e[8];let K;e[9]!==$||e[10]!==k||e[11]!==A||e[12]!==O||e[13]!==E||e[14]!==V?(K=t.jsxs("div",{className:I,children:[k,A,O,E,V,$]}),e[9]=$,e[10]=k,e[11]=A,e[12]=O,e[13]=E,e[14]=V,e[15]=K):K=e[15];let q;e[16]!==s||e[17]!==m?(q=t.jsx(_s,{org:m,onClose:s}),e[16]=s,e[17]=m,e[18]=q):q=e[18];let de;return e[19]!==K||e[20]!==q||e[21]!==y?(de=t.jsxs("div",{className:S,children:[y,K,q]}),e[19]=K,e[20]=q,e[21]=y,e[22]=de):de=e[22],de}function Fs(n){return!Tt(n.metadata)}function Bs(n){return Tt(n.metadata)}function Ls(n){return!un(n.id)}function Es(n){return!dn(n.id)}function Vs(n){const e=M.c(31);let s;e[0]!==n?(s=n===void 0?{}:n,e[0]=n,e[1]=s):s=e[1];const{compact:o,trigger:i,onSelectAgent:a,selectedAgentId:l,side:c,align:r}=s,u=o===void 0?!1:o,m=c===void 0?"right":c,f=r===void 0?"start":r,[d,h]=H.useState(!1),[C,p]=H.useState(!1),g=It(),{setOpenMobile:j}=bt(),b=On(),v=b?"border border-border":void 0;let N;e[2]!==b?(N=A=>b?t.jsx(Os,{children:A}):A,e[2]=b,e[3]=N):N=e[3];const w=N;let z;e[4]!==g||e[5]!==j?(z=()=>{h(!1),g&&j(!1)},e[4]=g,e[5]=j,e[6]=z):z=e[6];const P=z;let x;e[7]!==P?(x=()=>{P(),p(!0)},e[7]=P,e[8]=x):x=e[8];const _=x;let T;e[9]!==P||e[10]!==_||e[11]!==a||e[12]!==d||e[13]!==l?(T=d&&t.jsx(H.Suspense,{fallback:t.jsx("div",{className:"flex items-center justify-center py-8",children:t.jsx(wn,{className:"h-4 w-24"})}),children:t.jsx($s,{onClose:P,onSelectAgent:a,selectedAgentId:l,onImportFromGithub:_})}),e[9]=P,e[10]=_,e[11]=a,e[12]=d,e[13]=l,e[14]=T):T=e[14];const S=T;let y;e[15]!==f||e[16]!==u||e[17]!==v||e[18]!==b||e[19]!==g||e[20]!==d||e[21]!==S||e[22]!==m||e[23]!==i||e[24]!==w?(y=g?t.jsxs(t.Fragment,{children:[i?t.jsx("button",{type:"button",onClick:()=>h(!0),className:"contents",children:i}):u?w(t.jsx(As,{setOpen:h,emptyCtaClass:v})):t.jsx(Is,{setOpen:h,highlightEmpty:b,emptyCtaClass:v}),t.jsx(Dt,{open:d,onOpenChange:h,direction:"bottom",children:t.jsxs(kt,{className:"max-h-[85dvh] p-0",children:[t.jsx(zs,{}),S]})})]}):t.jsxs(St,{open:d,onOpenChange:A=>{A&&!d&&R("agent_browser_opened",{surface:"desktop_popover"}),h(A)},children:[i?t.jsx(Le,{asChild:!0,children:i}):u?w(t.jsx(Le,{asChild:!0,children:t.jsx(Ts,{emptyCtaClass:v})})):t.jsx(Ps,{wrapEmptyHint:w,highlightEmpty:b,emptyCtaClass:v}),t.jsx(yt,{className:"w-[380px] p-0 overflow-hidden",side:m,align:f,children:S})]}),e[15]=f,e[16]=u,e[17]=v,e[18]=b,e[19]=g,e[20]=d,e[21]=S,e[22]=m,e[23]=i,e[24]=w,e[25]=y):y=e[25];let I;e[26]!==C?(I=t.jsx(In,{open:C,onOpenChange:p,mode:"agent"}),e[26]=C,e[27]=I):I=e[27];let k;return e[28]!==I||e[29]!==y?(k=t.jsxs(t.Fragment,{children:[y,I]}),e[28]=I,e[29]=y,e[30]=k):k=e[30],k}const Rs="inline-flex items-center gap-1.5 min-w-0 rounded-md pl-1 pr-2 py-1.5 text-sm text-foreground hover:bg-accent/60 transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/50";function Hs(n){const e=M.c(29),{agentId:s,fallback:o,onOpenHome:i,onPick:a}=n,l=B(),c=hn(s)??o??null;let r,u,m,f,d;e[0]!==c?.title||e[1]!==i||e[2]!==l?(d=c?.title??l("header.shellBreadcrumb.superAgentDefaultName"),f="flex min-w-0 items-center gap-0",r="button",u=i,m=l("header.shellBreadcrumb.openAgentHome",{name:d}),e[0]=c?.title,e[1]=i,e[2]=l,e[3]=r,e[4]=u,e[5]=m,e[6]=f,e[7]=d):(r=e[3],u=e[4],m=e[5],f=e[6],d=e[7]);const h=c?.icon??null;let C;e[8]!==h||e[9]!==d?(C=t.jsx(xt,{icon:h,name:d,size:"xs"}),e[8]=h,e[9]=d,e[10]=C):C=e[10];let p;e[11]!==r||e[12]!==u||e[13]!==m||e[14]!==C?(p=t.jsx("button",{type:r,onClick:u,"aria-label":m,className:"flex items-center shrink-0 rounded-md p-1 hover:bg-accent/60 transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/50",children:C}),e[11]=r,e[12]=u,e[13]=m,e[14]=C,e[15]=p):p=e[15];let g;e[16]!==d?(g=t.jsx("span",{className:"truncate font-medium max-w-[8rem]",children:d}),e[16]=d,e[17]=g):g=e[17];let j;e[18]===Symbol.for("react.memo_cache_sentinel")?(j=t.jsx(jt,{size:14,className:"shrink-0 text-muted-foreground opacity-70"}),e[18]=j):j=e[18];let b;e[19]!==g?(b=t.jsxs("button",{type:"button",className:Rs,children:[g,j]}),e[19]=g,e[20]=b):b=e[20];let v;e[21]!==s||e[22]!==a||e[23]!==b?(v=t.jsx(Vs,{side:"bottom",align:"start",selectedAgentId:s,onSelectAgent:a,trigger:b}),e[21]=s,e[22]=a,e[23]=b,e[24]=v):v=e[24];let N;return e[25]!==v||e[26]!==f||e[27]!==p?(N=t.jsxs("div",{className:f,children:[p,v]}),e[25]=v,e[26]=f,e[27]=p,e[28]=N):N=e[28],N}function Wo(n){const e=M.c(30);let s;e[0]!==n?(s=n===void 0?{}:n,e[0]=n,e[1]=s):s=e[1];const{showName:o}=s,i=B(),{org:a}=oe(),{state:l,isMobile:c}=bt(),r=Vt().invitations.length>0,u=l==="collapsed"||c;let m;e[2]!==r||e[3]!==a.name||e[4]!==i?(m=r?i("header.shellBreadcrumb.switchOrganizationPendingInvitation",{name:a.name}):i("header.shellBreadcrumb.switchOrganization",{name:a.name}),e[2]=r,e[3]=a.name,e[4]=i,e[5]=m):m=e[5];let f;e[6]!==a?(f=t.jsx(rt,{org:a,size:"sm"}),e[6]=a,e[7]=f):f=e[7];let d;e[8]!==r||e[9]!==u?(d=r&&t.jsx("span",{className:X("absolute -right-1 size-2.5 rounded-full bg-destructive ring-2 ring-background",u?"-top-1":"top-1/2 -translate-y-1/2")}),e[8]=r,e[9]=u,e[10]=d):d=e[10];let h;e[11]!==f||e[12]!==d?(h=t.jsxs("span",{className:"relative inline-flex",children:[f,d]}),e[11]=f,e[12]=d,e[13]=h):h=e[13];let C;e[14]!==a.name||e[15]!==o?(C=o&&t.jsx("span",{className:"truncate text-sm font-medium text-foreground max-w-[10rem]",children:a.name}),e[14]=a.name,e[15]=o,e[16]=C):C=e[16];let p;e[17]===Symbol.for("react.memo_cache_sentinel")?(p=t.jsx(jt,{size:14,className:"shrink-0 text-muted-foreground opacity-70"}),e[17]=p):p=e[17];let g;e[18]!==m||e[19]!==h||e[20]!==C?(g=t.jsx(Ce,{asChild:!0,children:t.jsxs("button",{type:"button","aria-label":m,className:"flex items-center gap-1.5 shrink-0 rounded-lg pl-[5px] pr-1.5 py-1.5 hover:bg-accent/60 transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/50",children:[h,C,p]})}),e[18]=m,e[19]=h,e[20]=C,e[21]=g):g=e[21];let j;e[22]!==a.slug||e[23]!==g?(j=t.jsx(bs,{orgParam:a.slug,trigger:g}),e[22]=a.slug,e[23]=g,e[24]=j):j=e[24];let b;e[25]!==a.name?(b=t.jsx(ye,{side:"bottom",children:a.name}),e[25]=a.name,e[26]=b):b=e[26];let v;return e[27]!==b||e[28]!==j?(v=t.jsxs(Se,{children:[j,b]}),e[27]=b,e[28]=j,e[29]=v):v=e[29],v}function Yo(n){const e=M.c(22);let s;e[0]!==n?(s=n===void 0?{}:n,e[0]=n,e[1]=s):s=e[1];const{onNavigate:o}=s,{org:i}=oe();let a;e[2]===Symbol.for("react.memo_cache_sentinel")?(a={strict:!1},e[2]=a):a=e[2];const l=ot(a);let c;e[3]===Symbol.for("react.memo_cache_sentinel")?(c={strict:!1},e[3]=c):c=e[3];const r=it(c),{threads:u}=zt(),{data:m}=ae.useSession(),{setTaskId:f,createNewTask:d}=Pt();let h;e[4]!==i.id?(h=lt(i.id),e[4]=i.id,e[5]=h):h=e[5];const C=h,p=C.id,g=l.taskId?r.virtualmcpid??p:p;let j;e[6]!==d||e[7]!==p||e[8]!==o||e[9]!==m?.user?.id||e[10]!==f||e[11]!==u?(j=P=>{const x=P??p,_=Ln(u,x,m?.user?.id);_?f(_.id,x):d(x),o?.()},e[6]=d,e[7]=p,e[8]=o,e[9]=m?.user?.id,e[10]=f,e[11]=u,e[12]=j):j=e[12];const b=j;let v;e[13]===Symbol.for("react.memo_cache_sentinel")?(v=t.jsx("span",{className:"h-5 w-24 rounded bg-muted animate-pulse"}),e[13]=v):v=e[13];const N=g===p?C:void 0;let w;e[14]!==g||e[15]!==b?(w=()=>b(g),e[14]=g,e[15]=b,e[16]=w):w=e[16];let z;return e[17]!==g||e[18]!==b||e[19]!==N||e[20]!==w?(z=t.jsx(H.Suspense,{fallback:v,children:t.jsx(Hs,{agentId:g,fallback:N,onOpenHome:w,onPick:b})}),e[17]=g,e[18]=b,e[19]=N,e[20]=w,e[21]=z):z=e[21],z}function Jo(){const n=M.c(24),e=B(),{org:s}=oe();let o;n[0]===Symbol.for("react.memo_cache_sentinel")?(o={strict:!1},n[0]=o):o=n[0];const i=ot(o);let a;n[1]===Symbol.for("react.memo_cache_sentinel")?(a={strict:!1},n[1]=a):a=n[1];const l=it(a),{threads:c}=zt(),{createNewTask:r}=Pt();let u;n[2]!==s.id?(u=lt(s.id),n[2]=s.id,n[3]=u):u=n[3];const m=u.id,f=i.taskId?l.virtualmcpid??m:m;let d;n[4]!==i.taskId||n[5]!==c?(d=(i.taskId?c.find(z=>z.id===i.taskId)?.branch:null)??null,n[4]=i.taskId,n[5]=c,n[6]=d):d=n[6];const h=d;let C;n[7]!==f||n[8]!==r||n[9]!==h?(C=()=>{r(f,h)},n[7]=f,n[8]=r,n[9]=h,n[10]=C):C=n[10];const p=C;let g;n[11]!==e?(g=e("sidebar.taskGroupsList.newChat"),n[11]=e,n[12]=g):g=n[12];let j;n[13]===Symbol.for("react.memo_cache_sentinel")?(j=t.jsx(rn,{size:16}),n[13]=j):j=n[13];let b;n[14]!==p||n[15]!==g?(b=t.jsx(Ce,{asChild:!0,children:t.jsx("button",{type:"button",onClick:p,"aria-label":g,className:"flex shrink-0 items-center rounded-md p-1.5 text-muted-foreground transition-colors hover:bg-accent/60 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/50",children:j})}),n[14]=p,n[15]=g,n[16]=b):b=n[16];let v;n[17]!==e?(v=e("sidebar.taskGroupsList.newChat"),n[17]=e,n[18]=v):v=n[18];let N;n[19]!==v?(N=t.jsx(ye,{side:"bottom",children:v}),n[19]=v,n[20]=N):N=n[20];let w;return n[21]!==b||n[22]!==N?(w=t.jsxs(Se,{children:[b,N]}),n[21]=b,n[22]=N,n[23]=w):w=n[23],w}function Us({open:n,onOpenChange:e,onCreated:s}){const o=B(),{org:i}=oe(),{data:a}=ae.useSession(),{stdioEnabled:l}=Jt(),c=It(),r=Et(),u=Ot(),f=Mt(u,"").items,d=pt({resolver:ht(Zn),defaultValues:{title:"",description:null,icon:null,ui_type:"HTTP",connection_url:"",connection_token:null,npx_package:"",stdio_command:"",stdio_args:"",stdio_cwd:"",env_vars:[]}}),h=d.watch("ui_type"),C=d.watch("connection_url"),p=d.watch("npx_package"),g=$e({uiType:h,connectionUrl:C??"",npxPackage:p??""})??ut({uiType:h,connectionUrl:C??"",registryItems:f}),j=x=>{const _=x.trim();if(!_)return;const T=!!d.formState.dirtyFields.title,S=!!d.formState.dirtyFields.description,y=!!d.formState.dirtyFields.env_vars,I=A=>{if(A&&(!T&&!d.getValues("title").trim()&&A.title&&d.setValue("title",A.title,{shouldDirty:!1}),!S&&!(d.getValues("description")??"").trim()&&A.description&&d.setValue("description",A.description,{shouldDirty:!1}),!y&&A.envVarKeys?.length)){const O=d.getValues("env_vars")??[],E=new Set(O.map($=>$.key)),V=A.envVarKeys.filter($=>!E.has($));V.length>0&&d.setValue("env_vars",[...O,...V.map($=>({key:$,value:""}))],{shouldDirty:!0})}},k=ts(_);if(k&&l){d.setValue("ui_type","NPX",{shouldDirty:!0}),d.setValue("npx_package",k.packageName,{shouldDirty:!0}),d.setValue("connection_url","",{shouldDirty:!0}),d.setValue("connection_token",null,{shouldDirty:!0}),I($e({uiType:"NPX",npxPackage:k.packageName}));return}if(_.startsWith("http://")||_.startsWith("https://")){const A=h==="HTTP"||h==="SSE"||h==="Websocket"?h:"HTTP";d.setValue("ui_type",A,{shouldDirty:!0}),d.setValue("connection_url",_,{shouldDirty:!0}),I($e({uiType:A,connectionUrl:_})??ut({uiType:A,connectionUrl:_,registryItems:f}));return}h==="NPX"&&I($e({uiType:"NPX",npxPackage:_}))},b=x=>{x||d.reset(),e(x)},v=async x=>{let _,T=null,S=null,y=null;x.ui_type==="NPX"?(_="STDIO",T="",y=ns(x.npx_package||"",x.env_vars||[])):x.ui_type==="STDIO"?(_="STDIO",T="",y=ss(x.stdio_command||"",x.stdio_args||"",x.stdio_cwd,x.env_vars||[])):(_=x.ui_type,T=x.connection_url||"",S=x.connection_token||null);const I=Vn("conn");try{await r.create.mutateAsync({id:I,title:x.title,description:x.description||null,connection_type:_,connection_url:T,connection_token:S,created_at:new Date().toISOString(),updated_at:new Date().toISOString(),created_by:a?.user?.id||"system",organization_id:i.id,icon:x.icon??null,app_name:null,app_id:null,connection_headers:y,oauth_config:null,configuration_state:null,metadata:null,tools:null,bindings:null,status:"inactive"}),d.reset(),e(!1),s?.(I)}catch{U.error(o("connections.createConnectionDialog.failedToCreateConnection"))}},N=o("connections.createConnectionDialog.title"),w=o("connections.createConnectionDialog.description"),z=d.formState.isSubmitting?o("connections.createConnectionDialog.saving"):o("connections.createConnectionDialog.createButton"),P=t.jsxs("div",{className:"grid gap-4",children:[t.jsx(W,{control:d.control,name:"ui_type",render:({field:x})=>t.jsxs(Y,{children:[t.jsx(J,{children:o("connections.createConnectionDialog.typeLabel")}),t.jsxs(Xn,{value:x.value,onValueChange:x.onChange,children:[t.jsx(Z,{children:t.jsx(Qn,{children:t.jsx(Wn,{})})}),t.jsxs(Yn,{children:[t.jsx(De,{value:"HTTP",children:t.jsxs("span",{className:"flex items-center gap-2",children:[t.jsx(Ze,{className:"w-4 h-4"}),o("connections.createConnectionDialog.httpType")]})}),t.jsx(De,{value:"SSE",children:t.jsxs("span",{className:"flex items-center gap-2",children:[t.jsx(Ze,{className:"w-4 h-4"}),o("connections.createConnectionDialog.sseType")]})}),t.jsx(De,{value:"Websocket",children:t.jsxs("span",{className:"flex items-center gap-2",children:[t.jsx(Ze,{className:"w-4 h-4"}),o("connections.createConnectionDialog.websocketType")]})}),l&&t.jsxs(t.Fragment,{children:[t.jsx(De,{value:"NPX",children:t.jsxs("span",{className:"flex items-center gap-2",children:[t.jsx(Be,{className:"w-4 h-4"}),o("connections.createConnectionDialog.npxPackageType")]})}),t.jsx(De,{value:"STDIO",children:t.jsxs("span",{className:"flex items-center gap-2",children:[t.jsx(cn,{className:"w-4 h-4"}),o("connections.createConnectionDialog.customCommandType")]})})]})]})]}),t.jsx(ee,{})]})}),h==="NPX"&&t.jsx(W,{control:d.control,name:"npx_package",render:({field:x})=>t.jsxs(Y,{children:[t.jsx(J,{children:o("connections.createConnectionDialog.npmPackageLabel")}),t.jsx(Z,{children:t.jsx(ie,{placeholder:o("connections.createConnectionDialog.npmPackagePlaceholder"),...x,value:x.value??"",onPaste:_=>{const T=_.clipboardData.getData("text");T&&(_.preventDefault(),d.setValue("npx_package",T.trim(),{shouldDirty:!0}),j(T))},onBlur:_=>{j(_.target.value),x.onBlur()}})}),t.jsx(ee,{})]})}),h==="STDIO"&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"grid grid-cols-2 gap-4 items-start",children:[t.jsx(W,{control:d.control,name:"stdio_command",render:({field:x})=>t.jsxs(Y,{children:[t.jsx(J,{children:o("connections.createConnectionDialog.commandLabel")}),t.jsx(Z,{children:t.jsx(ie,{placeholder:o("connections.createConnectionDialog.commandPlaceholder"),...x,value:x.value??""})}),t.jsx(ee,{})]})}),t.jsx(W,{control:d.control,name:"stdio_args",render:({field:x})=>t.jsxs(Y,{children:[t.jsx(J,{children:o("connections.createConnectionDialog.argumentsLabel")}),t.jsx(Z,{children:t.jsx(ie,{placeholder:o("connections.createConnectionDialog.argumentsPlaceholder"),...x,value:x.value??""})}),t.jsx(ee,{})]})})]}),t.jsx(W,{control:d.control,name:"stdio_cwd",render:({field:x})=>t.jsxs(Y,{children:[t.jsx(J,{children:o("connections.createConnectionDialog.workingDirectoryLabel")}),t.jsx(Z,{children:t.jsx(ie,{placeholder:o("connections.createConnectionDialog.workingDirectoryPlaceholder"),...x,value:x.value??""})}),t.jsx("p",{className:"text-xs text-muted-foreground",children:o("connections.createConnectionDialog.workingDirectoryDescription")}),t.jsx(ee,{})]})})]}),(h==="NPX"||h==="STDIO")&&t.jsx(W,{control:d.control,name:"env_vars",render:({field:x})=>t.jsxs(Y,{children:[t.jsx(J,{children:o("connections.createConnectionDialog.environmentVariablesLabel")}),t.jsx(Z,{children:t.jsx(es,{value:x.value??[],onChange:x.onChange})}),t.jsx(ee,{})]})}),h!=="NPX"&&h!=="STDIO"&&t.jsxs(t.Fragment,{children:[t.jsx(W,{control:d.control,name:"connection_url",render:({field:x})=>t.jsxs(Y,{children:[t.jsx(J,{children:o("connections.createConnectionDialog.urlLabel")}),t.jsx(Z,{children:t.jsx(ie,{placeholder:o("connections.createConnectionDialog.urlPlaceholder"),...x,value:x.value??"",onPaste:_=>{const T=_.clipboardData.getData("text");T&&(_.preventDefault(),d.setValue("connection_url",T.trim(),{shouldDirty:!0}),j(T))},onBlur:_=>{j(_.target.value),x.onBlur()}})}),t.jsx(ee,{})]})}),t.jsx(W,{control:d.control,name:"connection_token",render:({field:x})=>t.jsxs(Y,{children:[t.jsx(J,{children:g?.token?.label??o("connections.createConnectionDialog.tokenLabelDefault")}),t.jsx(Z,{children:t.jsx(ie,{type:"password",placeholder:g?.token?.placeholder??o("connections.createConnectionDialog.tokenPlaceholderDefault"),className:"ph-no-capture",...x,value:x.value??""})}),g?.token?.helperText&&t.jsxs("p",{className:"text-xs text-muted-foreground",children:[g.token.helperText,g.id==="github"&&t.jsxs(t.Fragment,{children:[" ","·"," ",t.jsx("a",{className:"text-foreground underline underline-offset-4 hover:text-foreground/80",href:"https://github.com/settings/personal-access-tokens",target:"_blank",rel:"noreferrer",children:o("connections.createConnectionDialog.openGitHubPatSettings")})]})]}),t.jsx(ee,{})]})})]}),t.jsx(W,{control:d.control,name:"title",render:({field:x})=>t.jsxs(Y,{children:[t.jsx(J,{children:o("connections.createConnectionDialog.nameLabel")}),t.jsx(Z,{children:t.jsx(ie,{placeholder:o("connections.createConnectionDialog.namePlaceholder"),...x})}),t.jsx(ee,{})]})}),t.jsx(W,{control:d.control,name:"description",render:({field:x})=>t.jsxs(Y,{children:[t.jsx(J,{children:o("connections.createConnectionDialog.descriptionLabel")}),t.jsx(Z,{children:t.jsx(Jn,{placeholder:o("connections.createConnectionDialog.descriptionPlaceholder"),rows:3,...x,value:x.value??""})}),t.jsx(ee,{})]})})]});return c?t.jsx(Dt,{open:n,onOpenChange:b,children:t.jsxs(kt,{className:"max-h-[90vh]",children:[t.jsx(_n,{className:"pb-2",children:t.jsxs("div",{className:"flex items-start justify-between gap-4",children:[t.jsxs("div",{className:"flex-1 text-left",children:[t.jsx(At,{children:N}),t.jsx(Dn,{className:"mt-1",children:w})]}),t.jsx(kn,{asChild:!0,children:t.jsx(te,{variant:"ghost",size:"icon",className:"shrink-0 -mt-1",children:t.jsx(wt,{size:16})})})]})}),t.jsx(nt,{...d,children:t.jsxs("form",{onSubmit:d.handleSubmit(v),children:[t.jsx("div",{className:"overflow-y-auto px-4 pb-4",children:P}),t.jsx(An,{children:t.jsx(te,{type:"submit",disabled:d.formState.isSubmitting,className:"w-full",children:z})})]})})]})}):t.jsx($t,{open:n,onOpenChange:b,children:t.jsxs(Ft,{className:"sm:max-w-[525px]",children:[t.jsxs(Bt,{children:[t.jsx(Lt,{children:N}),t.jsx(Kn,{children:w})]}),t.jsx(nt,{...d,children:t.jsxs("form",{onSubmit:d.handleSubmit(v),children:[t.jsx("div",{className:"py-4",children:P}),t.jsxs(Gn,{children:[t.jsx(te,{type:"button",variant:"outline",onClick:()=>b(!1),children:o("connections.createConnectionDialog.cancelButton")}),t.jsx(te,{type:"submit",disabled:d.formState.isSubmitting,className:"min-w-40",children:z})]})]})})]})})}function qs(n){const e=M.c(72),{mode:s,agentId:o,addedConnectionIds:i,onAdd:a,onCloneAndAdd:l,onConnectAndAdd:c,connectingItemId:r,search:u,onCreateConnection:m,onBrowseNavigate:f,defaultTab:d}=n,h=s===void 0?"add":s,C=d===void 0?"connected":d,p=B(),{org:g}=oe(),j=H.useDeferredValue(u),b=u!==j;let v;e[0]!==j?(v=j.trim().toLowerCase(),e[0]=j,e[1]=v):v=e[1];const N=v;let w;e[2]!==C?(w=D=>D??C,e[2]=C,e[3]=w):w=e[3];const[z,P]=Zt(en.connectionsTab(g.slug)+(C==="all"?":home-modal":":agent-modal"),w);let x;e[4]!==z||e[5]!==P?(x=D=>{D!==z&&R("connections_dialog_tab_changed",{to_tab:D}),P(D)},e[4]=z,e[5]=P,e[6]=x):x=e[6];const _=x;let T;e[7]!==g.id||e[8]!==g.slug?(T={connectionId:mn,orgId:g.id,orgSlug:g.slug},e[7]=g.id,e[8]=g.slug,e[9]=T):T=e[9];const S=fn(T),y=j?.trim().split(/\s+/).filter(Boolean)??[],I=y.length>0?{operator:"or",conditions:y.flatMap(Zs)}:void 0,k={...I&&{where:I},orderBy:[{field:["updated_at"],direction:"asc"}],limit:100,offset:0},A=JSON.stringify(k),{data:O,fetchNextPage:E,hasNextPage:V,isFetchingNextPage:$}=as({queryKey:at.collectionListInfinite(S,g.id,"","CONNECTIONS",A),queryFn:async D=>{const{pageParam:F}=D,se=F===void 0?0:F;return(await S.callTool({name:"COLLECTION_CONNECTIONS_LIST",arguments:{...I&&{where:I},orderBy:[{field:["updated_at"],direction:"asc"}],limit:100,offset:se}})).structuredContent},initialPageParam:0,getNextPageParam:Ys,staleTime:3e4}),K=O?.pages.flatMap(Ws)??[],q=qn(K),de=new Set(K.filter(Qs).map(Xs)),L=Ot(),le=Mt(L,j),Re=mt(le.loadMore,le.hasMore,le.isLoadingMore),He=mt(E,V??!1,$),Q=z==="all"||!!N,ct=Q?le.items.filter(D=>{const F=Rn(D);if(F&&de.has(F))return!1;if(!N)return!0;const se=Ve(D._meta),re=[D.title,D.description,D.name,D.server?.title,D.server?.description,D.server?.name,se?.friendly_name,se?.friendlyName].filter(Boolean).join(" ").toLowerCase();return y.some(ne=>re.includes(ne.toLowerCase()))}):[],we=ct.filter(Gs),_e=ct.filter(Ks);let Ae;e[10]!==i?(Ae=D=>D.some(F=>i.has(F.id)),e[10]=i,e[11]=Ae):Ae=e[11];const Ue=Ae;let Ie;e[12]!==i||e[13]!==o||e[14]!==r||e[15]!==Ue||e[16]!==h||e[17]!==a||e[18]!==f||e[19]!==l||e[20]!==p?(Ie=(D,F,se,re,ne)=>{const Me=Ue(ne),ve=ne.find(ce=>!i.has(ce.id)),G=ne[0];if(h==="browse"){const ce=os(G);return t.jsx(Ye,{connection:{title:F,icon:se,description:ne.length>1?`${ne.length} instances`:re??void 0},fallbackIcon:t.jsx(Be,{}),headerActionsAlwaysVisible:!0,headerActions:t.jsxs(Fe,{variant:"secondary",className:"text-xs gap-1 font-normal",children:[t.jsx(Ee,{size:11})," ",p("virtualMcp.connectionDialogContent.connected")]}),onClick:()=>{R("connection_browse_clicked",{app_name:G.app_name??null,connection_id:G.id,instances_count:ne.length}),f?.(ce)}},D)}return t.jsx(Ye,{connection:{title:F,icon:se,description:re},fallbackIcon:t.jsx(Be,{}),headerActionsAlwaysVisible:!0,headerActions:t.jsxs("div",{className:"flex items-center gap-1.5",children:[Me&&t.jsxs(Fe,{variant:"secondary",className:"text-xs gap-1 font-normal",children:[t.jsx(Ee,{size:11})," ",p("virtualMcp.connectionDialogContent.added")]}),t.jsx(te,{variant:"outline",size:"sm",className:"h-7 px-3 text-xs font-medium",disabled:r!==null,onClick:ce=>{ce.stopPropagation(),ve?(R("connection_add_clicked",{action:"use_existing",app_name:G.app_name??null,connection_id:ve.id}),o&&R("agent_connection_attached",{agent_id:o,connection_id:ve.id,app_name:G.app_name??null,mode:"existing"}),a(ve.id)):(R("connection_add_clicked",{action:"clone",app_name:G.app_name??null,base_connection_id:G.id}),l(G))},children:p("virtualMcp.connectionDialogContent.add")})]})},D)},e[12]=i,e[13]=o,e[14]=r,e[15]=Ue,e[16]=h,e[17]=a,e[18]=f,e[19]=l,e[20]=p,e[21]=Ie):Ie=e[21];const ze=Ie;let Te;e[22]!==r||e[23]!==h||e[24]!==c||e[25]!==p?(Te=D=>{const F=Ve(D._meta),se=F?.friendlyName||F?.friendly_name||D.server?.title||D.title||D.server?.name||D.name||D.id||"",re=D.server?.description||D.description||null,ne=D.server?.icons?.[0]?.src||Hn(D.server?.repository)||null,Me=F?.official===!0,ve=F?.verified===!0,G=F?.owner==="deco";return t.jsx(Ye,{connection:{title:se,description:re,icon:ne},fallbackIcon:t.jsx(Be,{}),headerActionsAlwaysVisible:!0,headerActions:t.jsxs("div",{className:"flex items-center gap-1.5",children:[G&&t.jsxs(Se,{children:[t.jsx(Ce,{asChild:!0,children:t.jsx("span",{className:"inline-flex items-center justify-center size-5 rounded-md bg-muted shrink-0",children:t.jsx("img",{src:"/logos/deco logo.svg",alt:p("virtualMcp.connectionDialogContent.madeByDeco"),className:"size-3"})})}),t.jsx(ye,{children:p("virtualMcp.connectionDialogContent.builtByDeco")})]}),!G&&Me&&t.jsxs(Se,{children:[t.jsx(Ce,{asChild:!0,children:t.jsx(Fe,{variant:"outline",size:"icon",children:t.jsx(Je,{})})}),t.jsx(ye,{children:p("virtualMcp.connectionDialogContent.builtByOfficial")})]}),!G&&!Me&&ve&&t.jsxs(Se,{children:[t.jsx(Ce,{asChild:!0,children:t.jsx(Fe,{variant:"outline",size:"icon",children:t.jsx(Je,{})})}),t.jsx(ye,{children:p("virtualMcp.connectionDialogContent.verifiedByDeco")})]}),t.jsx(te,{variant:"outline",size:"sm",className:"h-7 px-3 text-xs font-medium",disabled:r!==null,onClick:ce=>{ce.stopPropagation(),R("connection_add_clicked",{action:"connect_new",registry_item_id:D.id,app_name:F?.friendlyName||D.server?.name||D.name||null}),c(D)},children:r===D.id?t.jsx(ke,{size:14,className:"animate-spin"}):p(h==="browse"?"virtualMcp.connectionDialogContent.connect":"virtualMcp.connectionDialogContent.add")})]})},`catalog-${D.id}`)},e[22]=r,e[23]=h,e[24]=c,e[25]=p,e[26]=Te):Te=e[26];const dt=Te;let ue;e[27]!==z||e[28]!==_||e[29]!==m||e[30]!==N||e[31]!==p?(ue=!N&&t.jsxs("div",{className:"flex items-center justify-between px-5 py-3 border-b border-border shrink-0",children:[t.jsx(is,{tabs:[{id:"all",label:p("virtualMcp.connectionDialogContent.tabAll")},{id:"connected",label:p("virtualMcp.connectionDialogContent.tabConnected")}],activeTab:z,onTabChange:D=>_(D)}),t.jsxs(te,{variant:"outline",size:"sm",className:"h-7 px-2 text-sm",onClick:()=>{R("connections_dialog_custom_clicked"),m()},children:[t.jsx(Ne,{size:12}),p("virtualMcp.connectionDialogContent.customConnection")]})]}),e[27]=z,e[28]=_,e[29]=m,e[30]=N,e[31]=p,e[32]=ue):ue=e[32];const qe=b&&"opacity-50 pointer-events-none";let me;e[33]!==qe?(me=X("flex-1 overflow-auto p-5 transition-opacity duration-150",qe),e[33]=qe,e[34]=me):me=e[34];const Ht="grid grid-cols-[repeat(auto-fill,minmax(260px,1fr))] gap-4";let Pe;e[35]!==ze?(Pe=D=>{if(D.type==="group")return ze(D.key,D.title,D.icon,null,D.connections);const F=D.connection;return ze(F.id,F.title,F.icon,F.description??null,[F])},e[35]=ze,e[36]=Pe):Pe=e[36];const Ke=q.map(Pe);let fe;e[37]!==He?(fe=t.jsx("div",{ref:He,className:"col-span-full h-1"}),e[37]=He,e[38]=fe):fe=e[38];let ge;e[39]!==$?(ge=$&&t.jsx("div",{className:"col-span-full flex justify-center py-6",children:t.jsx(ke,{size:24,className:"animate-spin text-muted-foreground"})}),e[39]=$,e[40]=ge):ge=e[40];const Ge=Q&&we.length>0&&t.jsxs("div",{className:"col-span-full flex items-center gap-2 mt-2",children:[t.jsx(Je,{size:13,className:"text-muted-foreground shrink-0"}),t.jsx("span",{className:"text-sm font-medium text-muted-foreground whitespace-nowrap",children:p("virtualMcp.connectionDialogContent.sectionVerified")}),t.jsx("div",{className:"flex-1 h-px bg-border"})]}),Xe=Q&&we.map(dt),Qe=Q&&_e.length>0&&t.jsxs("div",{className:"col-span-full flex items-center gap-2 mt-2",children:[t.jsx("span",{className:"text-sm font-medium text-muted-foreground whitespace-nowrap",children:p("virtualMcp.connectionDialogContent.sectionAllConnections")}),t.jsx("div",{className:"flex-1 h-px bg-border"})]}),We=Q&&_e.map(dt);let he;e[41]!==Re||e[42]!==L||e[43]!==Q?(he=Q&&L.length>0&&t.jsx("div",{ref:Re,className:"col-span-full h-1"}),e[41]=Re,e[42]=L,e[43]=Q,e[44]=he):he=e[44];let pe;e[45]!==le.isLoadingMore||e[46]!==Q?(pe=Q&&le.isLoadingMore&&t.jsx("div",{className:"col-span-full flex justify-center py-6",children:t.jsx(ke,{size:24,className:"animate-spin text-muted-foreground"})}),e[45]=le.isLoadingMore,e[46]=Q,e[47]=pe):pe=e[47];let xe;e[48]!==Ke||e[49]!==fe||e[50]!==ge||e[51]!==Ge||e[52]!==Xe||e[53]!==Qe||e[54]!==We||e[55]!==he||e[56]!==pe?(xe=t.jsxs("div",{className:Ht,children:[Ke,fe,ge,Ge,Xe,Qe,We,he,pe]}),e[48]=Ke,e[49]=fe,e[50]=ge,e[51]=Ge,e[52]=Xe,e[53]=Qe,e[54]=We,e[55]=he,e[56]=pe,e[57]=xe):xe=e[57];let je;e[58]!==z||e[59]!==q.length||e[60]!==_e||e[61]!==u||e[62]!==p||e[63]!==we?(je=q.length===0&&we.length===0&&_e.length===0&&t.jsx("div",{className:"flex items-center justify-center h-48 text-sm text-muted-foreground",children:u?p("virtualMcp.connectionDialogContent.emptyStateSearchNoMatch",{search:u}):p(z==="connected"?"virtualMcp.connectionDialogContent.emptyStateNoConnectionsYet":"virtualMcp.connectionDialogContent.emptyStateNoConnectionsAvailable")}),e[58]=z,e[59]=q.length,e[60]=_e,e[61]=u,e[62]=p,e[63]=we,e[64]=je):je=e[64];let be;e[65]!==me||e[66]!==xe||e[67]!==je?(be=t.jsxs("div",{className:me,children:[xe,je]}),e[65]=me,e[66]=xe,e[67]=je,e[68]=be):be=e[68];let Oe;return e[69]!==ue||e[70]!==be?(Oe=t.jsxs(t.Fragment,{children:[ue,be]}),e[69]=ue,e[70]=be,e[71]=Oe):Oe=e[71],Oe}function Ks(n){return!n.verified&&!Ve(n._meta)?.verified&&!n.meta?.verified}function Gs(n){return n.verified||Ve(n._meta)?.verified||n.meta?.verified}function Xs(n){return n.app_name}function Qs(n){return n.app_name}function Ws(n){return n?.items??[]}function Ys(n,e){if(n?.hasMore)return e.reduce(Js,0)}function Js(n,e){return n+(e?.items?.length??0)}function Zs(n){return[{field:["title"],operator:"contains",value:n},{field:["description"],operator:"contains",value:n}]}function Zo({open:n,onOpenChange:e,defaultTab:s,initialSearch:o="",...i}){const a=B(),l=i.mode??"add",c="agentId"in i?i.agentId:void 0,r="addedConnectionIds"in i?i.addedConnectionIds??new Set:new Set,u="onAdd"in i&&i.onAdd?i.onAdd:S=>{},m=(S,y,I)=>{c&&R("agent_connection_attached",{agent_id:c,connection_id:S,app_name:y,mode:I})},[f,d]=H.useState(null),[h,C]=H.useState(o),[p,g]=H.useState(!1),{org:j}=oe(),{data:b}=ae.useSession(),v=Et(),N=tn(),w=st(),z=S=>{e(!1),w({to:"/$org/settings/connections/$appSlug",params:{org:j.slug,appSlug:S}})},P=()=>{N.invalidateQueries({predicate:S=>{const y=S.queryKey;return y[1]===j.id&&y[3]==="collection"&&y[4]==="CONNECTIONS"}})},x=async(S,y)=>{R("connection_oauth_succeeded",{connection_id:S,flow:y});const I=new URL(`/api/${j.slug}/mcp/${S}`,window.location.origin);await N.invalidateQueries({queryKey:at.isMCPAuthenticated(I.href,null)}),P()},_=async S=>{d(S.app_name??S.id);try{const I=`${S.title.replace(/\s*\(\d+\)\s*$/,"")} (${Date.now().toString(36).slice(-4)})`,A=(await v.create.mutateAsync({title:I,description:S.description??null,connection_type:S.connection_type,connection_url:S.connection_url??null,connection_token:null,icon:S.icon??null,app_name:S.app_name??null,app_id:S.app_id??null,connection_headers:S.connection_headers??null})).id,O=await et({connectionId:A,orgId:j.id,orgSlug:j.slug,persistFallback:E=>v.update.mutateAsync({id:A,data:{connection_token:E}}).then(()=>{})});if(O.ran&&!O.ok){R("connection_oauth_failed",{connection_id:A,flow:"clone",error:O.error??"no_token"}),U.error(a("virtualMcp.addConnectionDialog.authenticationFailedError",{error:O.error??"no token received"})),await v.delete.mutateAsync(A);return}O.ran&&await x(A,"clone"),m(A,S.app_name??null,"clone"),u(A)}catch(y){console.error("Failed to add connection:",y),U.error(a("virtualMcp.addConnectionDialog.failedToAddConnection"))}finally{d(null)}},T=async S=>{if(!(!j||!b?.user?.id)){d(S.id);try{const y=Un(S,j.id,b.user.id,{remoteIndex:0}),I=y.connection_type==="STDIO",k=!!y.connection_url,A=I&&y.connection_headers&&typeof y.connection_headers=="object"&&"command"in y.connection_headers;if(!k&&!A){U.error(a("virtualMcp.addConnectionDialog.mcpServerConnectionError")),d(null);return}const{id:O}=await v.create.mutateAsync(y),E=await et({connectionId:O,orgId:j.id,orgSlug:j.slug,persistFallback:V=>v.update.mutateAsync({id:O,data:{connection_token:V}}).then(()=>{})});if(E.ran&&!E.ok){R("connection_oauth_failed",{connection_id:O,flow:"connect_new",error:E.error??"no_token"}),U.warning(a("virtualMcp.addConnectionDialog.signInFailedTitle"),{description:a("virtualMcp.addConnectionDialog.signInFailedDescription",{error:E.error??"no token received"})}),m(O,y.app_name??null,"new"),u(O);return}E.ran?(await x(O,"connect_new"),U.success(a("virtualMcp.addConnectionDialog.connectedAuthenticated"))):U.success(a("virtualMcp.addConnectionDialog.connected")),m(O,y.app_name??null,"new"),u(O)}catch(y){console.error("Failed to connect:",y),U.error(a("virtualMcp.addConnectionDialog.failedToConnect"))}finally{d(null)}}};return t.jsxs($t,{open:n,onOpenChange:e,children:[t.jsxs(Ft,{className:"sm:max-w-5xl h-[85vh] max-h-[85vh] flex flex-col p-0 gap-0 overflow-hidden w-[95vw]",children:[t.jsx(Bt,{className:"px-6 pt-5 pb-0 shrink-0",children:t.jsx(Lt,{className:"text-base font-semibold",children:a(l==="browse"?"virtualMcp.addConnectionDialog.connectionsTitle":"virtualMcp.addConnectionDialog.addConnectionTitle")})}),t.jsx("div",{className:"pt-3 shrink-0",children:t.jsx(En,{value:h,onChange:C,placeholder:a("virtualMcp.addConnectionDialog.searchConnectionsPlaceholder")})}),t.jsx(H.Suspense,{fallback:t.jsx("div",{className:"flex-1 flex items-center justify-center",children:t.jsx(ke,{size:24,className:"animate-spin text-muted-foreground"})}),children:t.jsx(qs,{mode:l,agentId:c,addedConnectionIds:r,onAdd:u,onCloneAndAdd:_,onConnectAndAdd:T,connectingItemId:f,search:h,onCreateConnection:()=>g(!0),onBrowseNavigate:z,defaultTab:s})})]}),t.jsx(Us,{open:p,onOpenChange:g,onCreated:async S=>{g(!1);const y=await et({connectionId:S,orgId:j.id,orgSlug:j.slug,persistFallback:I=>v.update.mutateAsync({id:S,data:{connection_token:I}}).then(()=>{})});if(y.ran&&!y.ok){R("connection_oauth_failed",{connection_id:S,flow:"custom_create",error:y.error??"no_token"}),U.warning(a("virtualMcp.addConnectionDialog.signInFailedTitle"),{description:a("virtualMcp.addConnectionDialog.signInFailedDescription",{error:y.error??"no token received"})}),m(S,null,"custom"),u(S),e(!1);return}y.ran&&await x(S,"custom_create"),m(S,null,"custom"),u(S),e(!1)}})]})}const gt=new Map;function ei(){const{org:n}=oe(),e=ls(),s=rs(),o=s.find(g=>g.providerId==="deco"),{data:i,isLoading:a,refetch:l,isFetching:c}=nn({queryKey:at.aiProviderCredits(n.id,"deco"),enabled:!!o,staleTime:6e4,queryFn:async()=>{try{return await e.call("AI_PROVIDER_CREDITS",{providerId:"deco"})}catch{return null}}}),r=i?.balanceCents??null,u=r!=null?r/100:null,m=H.useRef(new Map);if(r!=null){const g=gt.get(n.id);m.current.get(n.id)&&g!=null&&r>g&&R("credits_topped_up_detected",{organization_id:n.id,delta_cents:r-g,previous_balance_cents:g,new_balance_cents:r}),gt.set(n.id,r),m.current.set(n.id,!0)}const f=!!o,d=r!=null&&r>0,h=r!=null&&r===0,C=r!=null&&r===200,p=s.length>0&&s.every(g=>g.providerId==="deco");return{hasDecoKey:f,decoKeyId:o?.id??null,balanceCents:r,balanceDollars:u,hasCredits:d,isZeroBalance:h,isInitialFreeCredit:C,hasOnlyDecoProvider:p,isLoading:a,isFetching:c,refetch:l}}export{Yo as A,Xo as C,Jo as N,Wo as O,Qo as a,Zo as b,bs as c,rt as d,ei as u};
@@ -1 +1 @@
1
- import{r as s}from"./index-zUiSruJv.js";import{d as R,c as u}from"./decopilot-sse-pool-YWHIb7Qb.js";const f=()=>0;function g(E){const{orgSlug:t,taskId:a,enabled:n=!0,onStep:o,onFinish:S,onTaskStatus:i}=E,l=s.useRef({taskId:a,onStep:o,onFinish:S,onTaskStatus:i});l.current={taskId:a,onStep:o,onFinish:S,onTaskStatus:i};const c=s.useRef(null),p=s.useRef(n),b=s.useRef(t);(!c.current||p.current!==n||b.current!==t)&&(p.current=n,b.current=t,c.current=d=>{if(!n||!t)return()=>{};const k=T=>{let e;try{e=JSON.parse(T.data)}catch{return}const r=l.current;if(!(r.taskId&&e.subject!==r.taskId)){switch(e.type){case u.STEP:r.onStep?.(e);break;case u.FINISH:r.onFinish?.(e);break;case u.THREAD_STATUS:r.onTaskStatus?.(e);break}d()}};return R.subscribe(t,k)}),s.useSyncExternalStore(c.current,f,f)}export{g as u};
1
+ import{r as s}from"./index-BhSBUjFQ.js";import{d as R,c as u}from"./decopilot-sse-pool-AdBYpDln.js";const f=()=>0;function g(E){const{orgSlug:t,taskId:a,enabled:n=!0,onStep:o,onFinish:S,onTaskStatus:i}=E,l=s.useRef({taskId:a,onStep:o,onFinish:S,onTaskStatus:i});l.current={taskId:a,onStep:o,onFinish:S,onTaskStatus:i};const c=s.useRef(null),p=s.useRef(n),b=s.useRef(t);(!c.current||p.current!==n||b.current!==t)&&(p.current=n,b.current=t,c.current=d=>{if(!n||!t)return()=>{};const k=T=>{let e;try{e=JSON.parse(T.data)}catch{return}const r=l.current;if(!(r.taskId&&e.subject!==r.taskId)){switch(e.type){case u.STEP:r.onStep?.(e);break;case u.FINISH:r.onFinish?.(e);break;case u.THREAD_STATUS:r.onTaskStatus?.(e);break}d()}};return R.subscribe(t,k)}),s.useSyncExternalStore(c.current,f,f)}export{g as u};
@@ -1 +1 @@
1
- import{c as oe,b as le,j as n,F as se,o as ie,r as ce,t as Y,ba as re,bb as ae}from"./index-zUiSruJv.js";import{A as z,a as G,b as V,c as X,d as Z,e as ee,f as te,g as ne}from"./alert-dialog-BaSzp1WL.js";import{u as de}from"./studio-tools-B_bt7Swx.js";function ue(B){const e=oe.c(86),{deleteState:s,cancelDelete:a,confirmDelete:d,confirmForceDelete:c}=B,t=le(),w=s.mode==="deleting";let m;e[0]!==a?(m=W=>{W||a()},e[0]=a,e[1]=m):m=e[1];let u;e[2]!==t?(u=t("common.deleteConnectionDialogs.title"),e[2]=t,e[3]=u):u=e[3];let D;e[4]!==u?(D=n.jsx(z,{children:u}),e[4]=u,e[5]=D):D=e[5];let C;e[6]!==t?(C=t("common.deleteConnectionDialogs.description"),e[6]=t,e[7]=C):C=e[7];const H=s.mode==="deleting"&&s.connection.title;let o;e[8]!==H?(o=n.jsx("span",{className:"font-medium text-foreground",children:H}),e[8]=H,e[9]=o):o=e[9];let l;e[10]!==C||e[11]!==o?(l=n.jsxs(G,{children:[C," ",o,"."]}),e[10]=C,e[11]=o,e[12]=l):l=e[12];let i;e[13]!==D||e[14]!==l?(i=n.jsxs(V,{children:[D,l]}),e[13]=D,e[14]=l,e[15]=i):i=e[15];let f;e[16]!==t?(f=t("common.deleteConnectionDialogs.cancel"),e[16]=t,e[17]=f):f=e[17];let r;e[18]!==f?(r=n.jsx(X,{children:f}),e[18]=f,e[19]=r):r=e[19];let g;e[20]!==t?(g=t("common.deleteConnectionDialogs.delete"),e[20]=t,e[21]=g):g=e[21];let x;e[22]!==d||e[23]!==g?(x=n.jsx(Z,{onClick:d,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:g}),e[22]=d,e[23]=g,e[24]=x):x=e[24];let h;e[25]!==r||e[26]!==x?(h=n.jsxs(ee,{children:[r,x]}),e[25]=r,e[26]=x,e[27]=h):h=e[27];let j;e[28]!==h||e[29]!==i?(j=n.jsxs(te,{children:[i,h]}),e[28]=h,e[29]=i,e[30]=j):j=e[30];let p;e[31]!==w||e[32]!==j||e[33]!==m?(p=n.jsx(ne,{open:w,onOpenChange:m,children:j}),e[31]=w,e[32]=j,e[33]=m,e[34]=p):p=e[34];const J=s.mode==="force-deleting";let N;e[35]!==a?(N=W=>{W||a()},e[35]=a,e[36]=N):N=e[36];let E;e[37]!==t?(E=t("common.deleteConnectionDialogs.forceDeleteTitle"),e[37]=t,e[38]=E):E=e[38];let y;e[39]!==E?(y=n.jsx(z,{children:E}),e[39]=E,e[40]=y):y=e[40];let O;e[41]!==t?(O=t("common.deleteConnectionDialogs.forceDeleteDescription"),e[41]=t,e[42]=O):O=e[42];const M=s.mode==="force-deleting"&&s.connection.title;let v;e[43]!==M?(v=n.jsx("span",{className:"font-medium text-foreground",children:M}),e[43]=M,e[44]=v):v=e[44];let S;e[45]!==t?(S=t("common.deleteConnectionDialogs.isUsedByAgents"),e[45]=t,e[46]=S):S=e[46];const P=s.mode==="force-deleting"&&s.agentNames;let T;e[47]!==P?(T=n.jsx("span",{className:"font-medium text-foreground",children:P}),e[47]=P,e[48]=T):T=e[48];let A;e[49]!==O||e[50]!==v||e[51]!==S||e[52]!==T?(A=n.jsxs("p",{children:[O," ",v," ",S," ",T,"."]}),e[49]=O,e[50]=v,e[51]=S,e[52]=T,e[53]=A):A=e[53];let _;e[54]!==t?(_=t("common.deleteConnectionDialogs.forceDeleteWarning"),e[54]=t,e[55]=_):_=e[55];let b;e[56]!==_?(b=n.jsx("p",{className:"mt-2",children:_}),e[56]=_,e[57]=b):b=e[57];let F;e[58]!==A||e[59]!==b?(F=n.jsx(G,{asChild:!0,children:n.jsxs("div",{children:[A,b]})}),e[58]=A,e[59]=b,e[60]=F):F=e[60];let I;e[61]!==y||e[62]!==F?(I=n.jsxs(V,{children:[y,F]}),e[61]=y,e[62]=F,e[63]=I):I=e[63];let L;e[64]!==t?(L=t("common.deleteConnectionDialogs.cancel"),e[64]=t,e[65]=L):L=e[65];let R;e[66]!==L?(R=n.jsx(X,{children:L}),e[66]=L,e[67]=R):R=e[67];let q;e[68]!==t?(q=t("common.deleteConnectionDialogs.deleteAnyway"),e[68]=t,e[69]=q):q=e[69];let U;e[70]!==c||e[71]!==q?(U=n.jsx(Z,{onClick:c,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:q}),e[70]=c,e[71]=q,e[72]=U):U=e[72];let K;e[73]!==R||e[74]!==U?(K=n.jsxs(ee,{children:[R,U]}),e[73]=R,e[74]=U,e[75]=K):K=e[75];let $;e[76]!==I||e[77]!==K?($=n.jsxs(te,{children:[I,K]}),e[76]=I,e[77]=K,e[78]=$):$=e[78];let k;e[79]!==J||e[80]!==N||e[81]!==$?(k=n.jsx(ne,{open:J,onOpenChange:N,children:$}),e[79]=J,e[80]=N,e[81]=$,e[82]=k):k=e[82];let Q;return e[83]!==p||e[84]!==k?(Q=n.jsxs(n.Fragment,{children:[p,k]}),e[83]=p,e[84]=k,e[85]=Q):Q=e[85],Q}function De({onSuccess:B}={}){const{org:e}=se(),s=ie(),a=de(),[d,c]=ce.useState({mode:"idle"}),t=()=>{s.invalidateQueries({predicate:o=>{const l=o.queryKey;return l[1]===e.id&&l[3]==="collection"&&l[4]==="CONNECTIONS"}})},w=o=>{re(o),s.invalidateQueries({predicate:l=>l.queryKey[1]===ae&&l.queryKey[3]===o})},m=o=>{t(),w(o),Y.success("Connection deleted successfully"),c({mode:"idle"}),B?.()};return{deleteState:d,requestDelete:o=>{c({mode:"deleting",connection:o})},cancelDelete:()=>{c({mode:"idle"})},confirmDelete:async()=>{if(d.mode!=="deleting")return;const o=d.connection;c({mode:"idle"});try{await a.call("COLLECTION_CONNECTIONS_DELETE",{id:o.id}),m(o.id)}catch(l){const i=l instanceof Error?l.message:String(l),f=i.replace(/^Error:\s*/,"");try{const r=JSON.parse(f);if(r.code==="CONNECTION_IN_USE"&&r.agentNames){c({mode:"force-deleting",connection:o,agentNames:r.agentNames.map(g=>`"${g}"`).join(", ")});return}}catch{}Y.error(`Failed to delete connection: ${i}`)}},confirmForceDelete:async()=>{if(d.mode!=="force-deleting")return;const o=d.connection.id;c({mode:"idle"});try{await a.call("COLLECTION_CONNECTIONS_DELETE",{id:o,force:!0}),m(o)}catch(l){const i=l instanceof Error?l.message:String(l);Y.error(`Failed to delete connection: ${i}`)}}}}export{ue as D,De as u};
1
+ import{c as oe,b as le,j as n,F as se,o as ie,r as ce,t as Y,ba as re,bb as ae}from"./index-BhSBUjFQ.js";import{A as z,a as G,b as V,c as X,d as Z,e as ee,f as te,g as ne}from"./alert-dialog-Bj-lqnKh.js";import{u as de}from"./studio-tools-BEhBpPdk.js";function ue(B){const e=oe.c(86),{deleteState:s,cancelDelete:a,confirmDelete:d,confirmForceDelete:c}=B,t=le(),w=s.mode==="deleting";let m;e[0]!==a?(m=W=>{W||a()},e[0]=a,e[1]=m):m=e[1];let u;e[2]!==t?(u=t("common.deleteConnectionDialogs.title"),e[2]=t,e[3]=u):u=e[3];let D;e[4]!==u?(D=n.jsx(z,{children:u}),e[4]=u,e[5]=D):D=e[5];let C;e[6]!==t?(C=t("common.deleteConnectionDialogs.description"),e[6]=t,e[7]=C):C=e[7];const H=s.mode==="deleting"&&s.connection.title;let o;e[8]!==H?(o=n.jsx("span",{className:"font-medium text-foreground",children:H}),e[8]=H,e[9]=o):o=e[9];let l;e[10]!==C||e[11]!==o?(l=n.jsxs(G,{children:[C," ",o,"."]}),e[10]=C,e[11]=o,e[12]=l):l=e[12];let i;e[13]!==D||e[14]!==l?(i=n.jsxs(V,{children:[D,l]}),e[13]=D,e[14]=l,e[15]=i):i=e[15];let f;e[16]!==t?(f=t("common.deleteConnectionDialogs.cancel"),e[16]=t,e[17]=f):f=e[17];let r;e[18]!==f?(r=n.jsx(X,{children:f}),e[18]=f,e[19]=r):r=e[19];let g;e[20]!==t?(g=t("common.deleteConnectionDialogs.delete"),e[20]=t,e[21]=g):g=e[21];let x;e[22]!==d||e[23]!==g?(x=n.jsx(Z,{onClick:d,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:g}),e[22]=d,e[23]=g,e[24]=x):x=e[24];let h;e[25]!==r||e[26]!==x?(h=n.jsxs(ee,{children:[r,x]}),e[25]=r,e[26]=x,e[27]=h):h=e[27];let j;e[28]!==h||e[29]!==i?(j=n.jsxs(te,{children:[i,h]}),e[28]=h,e[29]=i,e[30]=j):j=e[30];let p;e[31]!==w||e[32]!==j||e[33]!==m?(p=n.jsx(ne,{open:w,onOpenChange:m,children:j}),e[31]=w,e[32]=j,e[33]=m,e[34]=p):p=e[34];const J=s.mode==="force-deleting";let N;e[35]!==a?(N=W=>{W||a()},e[35]=a,e[36]=N):N=e[36];let E;e[37]!==t?(E=t("common.deleteConnectionDialogs.forceDeleteTitle"),e[37]=t,e[38]=E):E=e[38];let y;e[39]!==E?(y=n.jsx(z,{children:E}),e[39]=E,e[40]=y):y=e[40];let O;e[41]!==t?(O=t("common.deleteConnectionDialogs.forceDeleteDescription"),e[41]=t,e[42]=O):O=e[42];const M=s.mode==="force-deleting"&&s.connection.title;let v;e[43]!==M?(v=n.jsx("span",{className:"font-medium text-foreground",children:M}),e[43]=M,e[44]=v):v=e[44];let S;e[45]!==t?(S=t("common.deleteConnectionDialogs.isUsedByAgents"),e[45]=t,e[46]=S):S=e[46];const P=s.mode==="force-deleting"&&s.agentNames;let T;e[47]!==P?(T=n.jsx("span",{className:"font-medium text-foreground",children:P}),e[47]=P,e[48]=T):T=e[48];let A;e[49]!==O||e[50]!==v||e[51]!==S||e[52]!==T?(A=n.jsxs("p",{children:[O," ",v," ",S," ",T,"."]}),e[49]=O,e[50]=v,e[51]=S,e[52]=T,e[53]=A):A=e[53];let _;e[54]!==t?(_=t("common.deleteConnectionDialogs.forceDeleteWarning"),e[54]=t,e[55]=_):_=e[55];let b;e[56]!==_?(b=n.jsx("p",{className:"mt-2",children:_}),e[56]=_,e[57]=b):b=e[57];let F;e[58]!==A||e[59]!==b?(F=n.jsx(G,{asChild:!0,children:n.jsxs("div",{children:[A,b]})}),e[58]=A,e[59]=b,e[60]=F):F=e[60];let I;e[61]!==y||e[62]!==F?(I=n.jsxs(V,{children:[y,F]}),e[61]=y,e[62]=F,e[63]=I):I=e[63];let L;e[64]!==t?(L=t("common.deleteConnectionDialogs.cancel"),e[64]=t,e[65]=L):L=e[65];let R;e[66]!==L?(R=n.jsx(X,{children:L}),e[66]=L,e[67]=R):R=e[67];let q;e[68]!==t?(q=t("common.deleteConnectionDialogs.deleteAnyway"),e[68]=t,e[69]=q):q=e[69];let U;e[70]!==c||e[71]!==q?(U=n.jsx(Z,{onClick:c,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:q}),e[70]=c,e[71]=q,e[72]=U):U=e[72];let K;e[73]!==R||e[74]!==U?(K=n.jsxs(ee,{children:[R,U]}),e[73]=R,e[74]=U,e[75]=K):K=e[75];let $;e[76]!==I||e[77]!==K?($=n.jsxs(te,{children:[I,K]}),e[76]=I,e[77]=K,e[78]=$):$=e[78];let k;e[79]!==J||e[80]!==N||e[81]!==$?(k=n.jsx(ne,{open:J,onOpenChange:N,children:$}),e[79]=J,e[80]=N,e[81]=$,e[82]=k):k=e[82];let Q;return e[83]!==p||e[84]!==k?(Q=n.jsxs(n.Fragment,{children:[p,k]}),e[83]=p,e[84]=k,e[85]=Q):Q=e[85],Q}function De({onSuccess:B}={}){const{org:e}=se(),s=ie(),a=de(),[d,c]=ce.useState({mode:"idle"}),t=()=>{s.invalidateQueries({predicate:o=>{const l=o.queryKey;return l[1]===e.id&&l[3]==="collection"&&l[4]==="CONNECTIONS"}})},w=o=>{re(o),s.invalidateQueries({predicate:l=>l.queryKey[1]===ae&&l.queryKey[3]===o})},m=o=>{t(),w(o),Y.success("Connection deleted successfully"),c({mode:"idle"}),B?.()};return{deleteState:d,requestDelete:o=>{c({mode:"deleting",connection:o})},cancelDelete:()=>{c({mode:"idle"})},confirmDelete:async()=>{if(d.mode!=="deleting")return;const o=d.connection;c({mode:"idle"});try{await a.call("COLLECTION_CONNECTIONS_DELETE",{id:o.id}),m(o.id)}catch(l){const i=l instanceof Error?l.message:String(l),f=i.replace(/^Error:\s*/,"");try{const r=JSON.parse(f);if(r.code==="CONNECTION_IN_USE"&&r.agentNames){c({mode:"force-deleting",connection:o,agentNames:r.agentNames.map(g=>`"${g}"`).join(", ")});return}}catch{}Y.error(`Failed to delete connection: ${i}`)}},confirmForceDelete:async()=>{if(d.mode!=="force-deleting")return;const o=d.connection.id;c({mode:"idle"});try{await a.call("COLLECTION_CONNECTIONS_DELETE",{id:o,force:!0}),m(o)}catch(l){const i=l instanceof Error?l.message:String(l);Y.error(`Failed to delete connection: ${i}`)}}}}export{ue as D,De as u};
@@ -1 +1 @@
1
- import{c as s,n as m,K as c}from"./index-zUiSruJv.js";function l(){const e=s.c(5);let t;e[0]===Symbol.for("react.memo_cache_sentinel")?(t={queryKey:c.deploymentAdminMe(),queryFn:d,staleTime:1/0,retry:2},e[0]=t):t=e[0];const{data:a,isLoading:i}=m(t),r=a==="admin",o=a==="unverified";let n;return e[1]!==i||e[2]!==r||e[3]!==o?(n={isAdmin:r,loading:i,needsEmailVerification:o},e[1]=i,e[2]=r,e[3]=o,e[4]=n):n=e[4],n}async function d(){const e=await fetch("/api/_admin/me",{credentials:"include"});if(e.status>=500)throw new Error(`admin/me request failed: ${e.status}`);return e.ok?"admin":(await e.json().catch(u)).error==="email_not_verified"?"unverified":"denied"}function u(){return{}}export{l as u};
1
+ import{c as s,n as m,K as c}from"./index-BhSBUjFQ.js";function l(){const e=s.c(5);let t;e[0]===Symbol.for("react.memo_cache_sentinel")?(t={queryKey:c.deploymentAdminMe(),queryFn:d,staleTime:1/0,retry:2},e[0]=t):t=e[0];const{data:a,isLoading:i}=m(t),r=a==="admin",o=a==="unverified";let n;return e[1]!==i||e[2]!==r||e[3]!==o?(n={isAdmin:r,loading:i,needsEmailVerification:o},e[1]=i,e[2]=r,e[3]=o,e[4]=n):n=e[4],n}async function d(){const e=await fetch("/api/_admin/me",{credentials:"include"});if(e.status>=500)throw new Error(`admin/me request failed: ${e.status}`);return e.ok?"admin":(await e.json().catch(u)).error==="email_not_verified"?"unverified":"denied"}function u(){return{}}export{l as u};
@@ -1 +1 @@
1
- import{c as u,F as c,K as r,n as d,x as y,o as C,e as F}from"./index-zUiSruJv.js";import{u as f}from"./studio-tools-B_bt7Swx.js";function m(){const e=u.c(7),{org:n}=c(),o=f();let i;e[0]!==n.id?(i=r.fileConfigs(n.id),e[0]=n.id,e[1]=i):i=e[1];let t;e[2]!==o?(t=()=>o.call("FILE_CONFIG_LIST",{}),e[2]=o,e[3]=t):t=e[3];let s;e[4]!==i||e[5]!==t?(s={queryKey:i,staleTime:6e4,queryFn:t},e[4]=i,e[5]=t,e[6]=s):s=e[6];const{data:l}=y(s);return l.configs}function I(){const e=u.c(7),{org:n}=c(),o=f();let i;e[0]!==n.id?(i=r.fileConfigs(n.id),e[0]=n.id,e[1]=i):i=e[1];let t;e[2]!==o?(t=()=>o.call("FILE_CONFIG_LIST",{}),e[2]=o,e[3]=t):t=e[3];let s;return e[4]!==i||e[5]!==t?(s={queryKey:i,staleTime:6e4,queryFn:t},e[4]=i,e[5]=t,e[6]=s):s=e[6],d(s)}function q(){const e=u.c(8),{org:n}=c(),o=f(),i=C();let t;e[0]!==o?(t=a=>o.call("FILE_CONFIG_CREATE",{...a}),e[0]=o,e[1]=t):t=e[1];let s;e[2]!==n||e[3]!==i?(s=()=>{i.invalidateQueries({queryKey:r.fileConfigs(n.id)})},e[2]=n,e[3]=i,e[4]=s):s=e[4];let l;return e[5]!==t||e[6]!==s?(l={mutationFn:t,onSuccess:s},e[5]=t,e[6]=s,e[7]=l):l=e[7],F(l)}function _(){const e=u.c(8),{org:n}=c(),o=f(),i=C();let t;e[0]!==o?(t=a=>o.call("FILE_CONFIG_DELETE",{id:a}),e[0]=o,e[1]=t):t=e[1];let s;e[2]!==n||e[3]!==i?(s=()=>{i.invalidateQueries({queryKey:r.fileConfigs(n.id)})},e[2]=n,e[3]=i,e[4]=s):s=e[4];let l;return e[5]!==t||e[6]!==s?(l={mutationFn:t,onSuccess:s},e[5]=t,e[6]=s,e[7]=l):l=e[7],F(l)}export{I as a,q as b,_ as c,m as u};
1
+ import{c as u,F as c,K as r,n as d,x as y,o as C,e as F}from"./index-BhSBUjFQ.js";import{u as f}from"./studio-tools-BEhBpPdk.js";function m(){const e=u.c(7),{org:n}=c(),o=f();let i;e[0]!==n.id?(i=r.fileConfigs(n.id),e[0]=n.id,e[1]=i):i=e[1];let t;e[2]!==o?(t=()=>o.call("FILE_CONFIG_LIST",{}),e[2]=o,e[3]=t):t=e[3];let s;e[4]!==i||e[5]!==t?(s={queryKey:i,staleTime:6e4,queryFn:t},e[4]=i,e[5]=t,e[6]=s):s=e[6];const{data:l}=y(s);return l.configs}function I(){const e=u.c(7),{org:n}=c(),o=f();let i;e[0]!==n.id?(i=r.fileConfigs(n.id),e[0]=n.id,e[1]=i):i=e[1];let t;e[2]!==o?(t=()=>o.call("FILE_CONFIG_LIST",{}),e[2]=o,e[3]=t):t=e[3];let s;return e[4]!==i||e[5]!==t?(s={queryKey:i,staleTime:6e4,queryFn:t},e[4]=i,e[5]=t,e[6]=s):s=e[6],d(s)}function q(){const e=u.c(8),{org:n}=c(),o=f(),i=C();let t;e[0]!==o?(t=a=>o.call("FILE_CONFIG_CREATE",{...a}),e[0]=o,e[1]=t):t=e[1];let s;e[2]!==n||e[3]!==i?(s=()=>{i.invalidateQueries({queryKey:r.fileConfigs(n.id)})},e[2]=n,e[3]=i,e[4]=s):s=e[4];let l;return e[5]!==t||e[6]!==s?(l={mutationFn:t,onSuccess:s},e[5]=t,e[6]=s,e[7]=l):l=e[7],F(l)}function _(){const e=u.c(8),{org:n}=c(),o=f(),i=C();let t;e[0]!==o?(t=a=>o.call("FILE_CONFIG_DELETE",{id:a}),e[0]=o,e[1]=t):t=e[1];let s;e[2]!==n||e[3]!==i?(s=()=>{i.invalidateQueries({queryKey:r.fileConfigs(n.id)})},e[2]=n,e[3]=i,e[4]=s):s=e[4];let l;return e[5]!==t||e[6]!==s?(l={mutationFn:t,onSuccess:s},e[5]=t,e[6]=s,e[7]=l):l=e[7],F(l)}export{I as a,q as b,_ as c,m as u};
@@ -1 +1 @@
1
- import{aU as l,e2 as d,e3 as v,r as i}from"./index-zUiSruJv.js";var p=class extends l{constructor(e,t){super(e,t)}bindMethods(){super.bindMethods(),this.fetchNextPage=this.fetchNextPage.bind(this),this.fetchPreviousPage=this.fetchPreviousPage.bind(this)}setOptions(e){e._type="infinite",super.setOptions(e)}getOptimisticResult(e){return e._type="infinite",super.getOptimisticResult(e)}fetchNextPage(e){return this.fetch({...e,meta:{fetchMore:{direction:"forward"}}})}fetchPreviousPage(e){return this.fetch({...e,meta:{fetchMore:{direction:"backward"}}})}createResult(e,t){const{state:n}=e,u=super.createResult(e,t),{isFetching:r,isRefetching:h,isError:a,isRefetchError:g}=u,s=n.fetchMeta?.fetchMore?.direction,o=a&&s==="forward",P=r&&s==="forward",c=a&&s==="backward",f=r&&s==="backward";return{...u,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:v(t,n.data),hasPreviousPage:d(t,n.data),isFetchNextPageError:o,isFetchingNextPage:P,isFetchPreviousPageError:c,isFetchingPreviousPage:f,isRefetchError:g&&!o&&!c,isRefetching:h&&!P&&!f}}};function b(e,t,n=!1,u){const r=i.useRef(null),h=i.useRef(null),a=i.useRef(e),g=i.useRef(t),s=i.useRef(n),o=i.useRef(u);a.current=e,g.current=t,s.current=n,o.current=u;const[P]=i.useState(()=>c=>{h.current=c,r.current&&(r.current.disconnect(),r.current=null),c&&queueMicrotask(()=>{if(h.current!==c)return;const f=new IntersectionObserver(R=>{R[0]?.isIntersecting&&g.current&&!s.current&&a.current()},{root:o.current?.current??null,rootMargin:"0px 0px 200px 0px"});f.observe(c),r.current=f})});return P}export{p as I,b as u};
1
+ import{aU as l,e2 as d,e3 as v,r as i}from"./index-BhSBUjFQ.js";var p=class extends l{constructor(e,t){super(e,t)}bindMethods(){super.bindMethods(),this.fetchNextPage=this.fetchNextPage.bind(this),this.fetchPreviousPage=this.fetchPreviousPage.bind(this)}setOptions(e){e._type="infinite",super.setOptions(e)}getOptimisticResult(e){return e._type="infinite",super.getOptimisticResult(e)}fetchNextPage(e){return this.fetch({...e,meta:{fetchMore:{direction:"forward"}}})}fetchPreviousPage(e){return this.fetch({...e,meta:{fetchMore:{direction:"backward"}}})}createResult(e,t){const{state:n}=e,u=super.createResult(e,t),{isFetching:r,isRefetching:h,isError:a,isRefetchError:g}=u,s=n.fetchMeta?.fetchMore?.direction,o=a&&s==="forward",P=r&&s==="forward",c=a&&s==="backward",f=r&&s==="backward";return{...u,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:v(t,n.data),hasPreviousPage:d(t,n.data),isFetchNextPageError:o,isFetchingNextPage:P,isFetchPreviousPageError:c,isFetchingPreviousPage:f,isRefetchError:g&&!o&&!c,isRefetching:h&&!P&&!f}}};function b(e,t,n=!1,u){const r=i.useRef(null),h=i.useRef(null),a=i.useRef(e),g=i.useRef(t),s=i.useRef(n),o=i.useRef(u);a.current=e,g.current=t,s.current=n,o.current=u;const[P]=i.useState(()=>c=>{h.current=c,r.current&&(r.current.disconnect(),r.current=null),c&&queueMicrotask(()=>{if(h.current!==c)return;const f=new IntersectionObserver(R=>{R[0]?.isIntersecting&&g.current&&!s.current&&a.current()},{root:o.current?.current??null,rootMargin:"0px 0px 200px 0px"});f.observe(c),r.current=f})});return P}export{p as I,b as u};
@@ -1 +1 @@
1
- import{c as g,F as N,K as y,n as _,o as A,e as I,t as q}from"./index-zUiSruJv.js";import{a as S}from"./use-capability-CSe2vHsE.js";import{u as O}from"./studio-tools-B_bt7Swx.js";function b(){const e=g.c(10),{org:r}=N(),u=O(),{capabilities:a,isPrivileged:c}=S(),d=c||!!a["members:manage"];let t;e[0]!==r.id?(t=y.organizationJoinRequests(r.id),e[0]=r.id,e[1]=t):t=e[1];let s;e[2]!==u?(s=()=>u.call("ORGANIZATION_JOIN_REQUEST_LIST",{}),e[2]=u,e[3]=s):s=e[3];const i=!!r.id&&d;let n;e[4]!==t||e[5]!==s||e[6]!==i?(n={queryKey:t,queryFn:s,enabled:i},e[4]=t,e[5]=s,e[6]=i,e[7]=n):n=e[7];const{data:l}=_(n);let o;return e[8]!==l?.requests?(o=l?.requests??[],e[8]=l?.requests,e[9]=o):o=e[9],o}function K(){const e=g.c(21),{org:r,locator:u}=N(),a=O(),c=A();let d;e[0]!==u||e[1]!==r||e[2]!==c?(d=()=>{c.invalidateQueries({queryKey:y.organizationJoinRequests(r.id)}),c.invalidateQueries({queryKey:y.members(u)})},e[0]=u,e[1]=r,e[2]=c,e[3]=d):d=e[3];const t=d;let s;e[4]!==a?(s=R=>a.call("ORGANIZATION_JOIN_REQUEST_APPROVE",{requestId:R}),e[4]=a,e[5]=s):s=e[5];let i;e[6]!==t?(i=()=>{t(),q.success("Request approved")},e[6]=t,e[7]=i):i=e[7];let n;e[8]!==s||e[9]!==i?(n={mutationFn:s,onSuccess:i,onError:v},e[8]=s,e[9]=i,e[10]=n):n=e[10];const l=I(n);let o;e[11]!==a?(o=R=>a.call("ORGANIZATION_JOIN_REQUEST_DENY",{requestId:R}),e[11]=a,e[12]=o):o=e[12];let f;e[13]!==t?(f=()=>{t(),q.success("Request denied")},e[13]=t,e[14]=f):f=e[14];let m;e[15]!==o||e[16]!==f?(m={mutationFn:o,onSuccess:f,onError:T},e[15]=o,e[16]=f,e[17]=m):m=e[17];const E=I(m);let p;return e[18]!==l||e[19]!==E?(p={approve:l,deny:E},e[18]=l,e[19]=E,e[20]=p):p=e[20],p}function T(e){return q.error(e instanceof Error?e.message:"Failed to deny")}function v(e){return q.error(e instanceof Error?e.message:"Failed to approve")}export{K as a,b as u};
1
+ import{c as g,F as N,K as y,n as _,o as A,e as I,t as q}from"./index-BhSBUjFQ.js";import{a as S}from"./use-capability-DZ6GjOiO.js";import{u as O}from"./studio-tools-BEhBpPdk.js";function b(){const e=g.c(10),{org:r}=N(),u=O(),{capabilities:a,isPrivileged:c}=S(),d=c||!!a["members:manage"];let t;e[0]!==r.id?(t=y.organizationJoinRequests(r.id),e[0]=r.id,e[1]=t):t=e[1];let s;e[2]!==u?(s=()=>u.call("ORGANIZATION_JOIN_REQUEST_LIST",{}),e[2]=u,e[3]=s):s=e[3];const i=!!r.id&&d;let n;e[4]!==t||e[5]!==s||e[6]!==i?(n={queryKey:t,queryFn:s,enabled:i},e[4]=t,e[5]=s,e[6]=i,e[7]=n):n=e[7];const{data:l}=_(n);let o;return e[8]!==l?.requests?(o=l?.requests??[],e[8]=l?.requests,e[9]=o):o=e[9],o}function K(){const e=g.c(21),{org:r,locator:u}=N(),a=O(),c=A();let d;e[0]!==u||e[1]!==r||e[2]!==c?(d=()=>{c.invalidateQueries({queryKey:y.organizationJoinRequests(r.id)}),c.invalidateQueries({queryKey:y.members(u)})},e[0]=u,e[1]=r,e[2]=c,e[3]=d):d=e[3];const t=d;let s;e[4]!==a?(s=R=>a.call("ORGANIZATION_JOIN_REQUEST_APPROVE",{requestId:R}),e[4]=a,e[5]=s):s=e[5];let i;e[6]!==t?(i=()=>{t(),q.success("Request approved")},e[6]=t,e[7]=i):i=e[7];let n;e[8]!==s||e[9]!==i?(n={mutationFn:s,onSuccess:i,onError:v},e[8]=s,e[9]=i,e[10]=n):n=e[10];const l=I(n);let o;e[11]!==a?(o=R=>a.call("ORGANIZATION_JOIN_REQUEST_DENY",{requestId:R}),e[11]=a,e[12]=o):o=e[12];let f;e[13]!==t?(f=()=>{t(),q.success("Request denied")},e[13]=t,e[14]=f):f=e[14];let m;e[15]!==o||e[16]!==f?(m={mutationFn:o,onSuccess:f,onError:T},e[15]=o,e[16]=f,e[17]=m):m=e[17];const E=I(m);let p;return e[18]!==l||e[19]!==E?(p={approve:l,deny:E},e[18]=l,e[19]=E,e[20]=p):p=e[20],p}function T(e){return q.error(e instanceof Error?e.message:"Failed to deny")}function v(e){return q.error(e instanceof Error?e.message:"Failed to approve")}export{K as a,b as u};
@@ -1,4 +1,4 @@
1
- import{da as fe,db as pe,dc as me,cf as _e,dd as ge,bU as _,bV as w,de as we,df as Te,dg as ye,dh as $,di as ve,dj as V,dk as ke,dl as M,dm as Se,dn as G,dp as Re,dq as Ce,dr as Ee,ds as K,bx as be,bz as Ie,bu as Ae,ca as re,cm as qe,cs as Me,cq as Pe,cD as Oe,dt as $e,du as Ne,dv as N,dw as He,dx as Ue,cr as De,cn as xe,co as je,cp as Le,bv as Fe,dy as Ve,dz as Ge,dA as ze,ch as Qe,dB as We,dC as Ke,cz as D,dD as Je,bt as j,c as oe,x as ae,K as Q}from"./index-zUiSruJv.js";import{U as P,a as H,e as J}from"./auth-DecE6kJ-.js";const qt={SELF:a=>`${a}_self`,REGISTRY:a=>`${a}_registry`,COMMUNITY_REGISTRY:a=>`${a}_community-registry`,DEV_ASSETS:a=>`${a}_dev-assets`,SITE_DIAGNOSTICS:a=>`site-diagnostics_${a}`,COMMERCE_DISCOVERY:a=>`${a}_commerce-discovery`},Mt="get_my_diagnostic",Pt="https://github.com/decocms.png",Ye="self";function R(a){return{is(e){return!e||!e.startsWith(a)?null:e.slice(a.length)||null},get(e){return`${a}${e}`}}}function Be(a){return{id:a.id,organization_id:a.organizationId,title:a.title,description:a.description,icon:a.icon,status:"active",created_at:new Date().toISOString(),updated_at:new Date().toISOString(),created_by:"system",updated_by:void 0,metadata:{instructions:a.instructions??null,...a.ui?{ui:a.ui}:{}},pinned:!1,connections:[]}}const ne=R("decopilot_"),Ot=ne.is,Ze=ne.get,ie=R("dev_"),$t=ie.get,Nt=ie.is,Xe="https://assets.decocache.com/decocms/fd07a578-6b1c-40f1-bc05-88a3b981695d/f7fc4ffa81aec04e37ae670c3cd4936643a7b269.png",et="#f59e0b",Ht=`https://api.iconify.design/lucide:bug.svg?color=${encodeURIComponent(et)}`,tt="#6366f1",Ut=`https://api.iconify.design/lucide:file-search.svg?color=${encodeURIComponent(tt)}`;function Dt(a){return Be({id:Ze(a),organizationId:a,title:"Super Agent",description:"Default agent that aggregates all organization connections",icon:Xe,ui:{layout:{defaultMainView:{type:"overview"},chatDefaultOpen:!0}}})}const st=R("commerce-discovery_"),xt=st.get,C={AGENT_MANAGER:R("studio-agent-manager_"),AUTOMATION_MANAGER:R("studio-automation-manager_"),CONNECTION_MANAGER:R("studio-connection-manager_"),API_KEY_MANAGER:R("studio-api-key-manager_"),STORE_MANAGER:R("studio-store-manager_"),BRAND_MANAGER:R("studio-brand-manager_"),TASK_MANAGER:R("studio-task-manager_"),USAGE_MANAGER:R("studio-usage-manager_")},jt={AGENT_MANAGER:C.AGENT_MANAGER.get,AUTOMATION_MANAGER:C.AUTOMATION_MANAGER.get,CONNECTION_MANAGER:C.CONNECTION_MANAGER.get,API_KEY_MANAGER:C.API_KEY_MANAGER.get,STORE_MANAGER:C.STORE_MANAGER.get,BRAND_MANAGER:C.BRAND_MANAGER.get,TASK_MANAGER:C.TASK_MANAGER.get,USAGE_MANAGER:C.USAGE_MANAGER.get};function Lt(a){return a?Object.values(C).some(e=>e.is(a)!==null):!1}function x(a){return!!a._zod}function b(a,e){return x(a)?fe(a,e):a.safeParse(e)}function ce(a){if(!a)return;let e;if(x(a)?e=a._zod?.def?.shape:e=a.shape,!!e){if(typeof e=="function")try{return e()}catch{return}return e}}function rt(a){if(x(a)){const o=a._zod?.def;if(o){if(o.value!==void 0)return o.value;if(Array.isArray(o.values)&&o.values.length>0)return o.values[0]}}const t=a._def;if(t){if(t.value!==void 0)return t.value;if(Array.isArray(t.values)&&t.values.length>0)return t.values[0]}const s=a.value;if(s!==void 0)return s}function I(a){return a==="completed"||a==="failed"||a==="cancelled"}function Y(a){const t=ce(a)?.method;if(!t)throw new Error("Schema is missing a method literal");const s=rt(t);if(typeof s!="string")throw new Error("Schema method literal must be a string");return s}function B(a,e){const t=b(a,e);if(!t.success)throw t.error;return t.data}const ot=6e4;class at{constructor(e){this._options=e,this._requestMessageId=0,this._requestHandlers=new Map,this._requestHandlerAbortControllers=new Map,this._notificationHandlers=new Map,this._responseHandlers=new Map,this._progressHandlers=new Map,this._timeoutInfo=new Map,this._pendingDebouncedNotifications=new Set,this._taskProgressTokens=new Map,this._requestResolvers=new Map,this.setNotificationHandler(pe,t=>{this._oncancel(t)}),this.setNotificationHandler(me,t=>{this._onprogress(t)}),this.setRequestHandler(_e,t=>({})),this._taskStore=e?.taskStore,this._taskMessageQueue=e?.taskMessageQueue,this._taskStore&&(this.setRequestHandler(ge,async(t,s)=>{const r=await this._taskStore.getTask(t.params.taskId,s.sessionId);if(!r)throw new _(w.InvalidParams,"Failed to retrieve task: Task not found");return{...r}}),this.setRequestHandler(we,async(t,s)=>{const r=async()=>{const o=t.params.taskId;if(this._taskMessageQueue){let i;for(;i=await this._taskMessageQueue.dequeue(o,s.sessionId);){if(i.type==="response"||i.type==="error"){const u=i.message,p=u.id,l=this._requestResolvers.get(p);if(l)if(this._requestResolvers.delete(p),i.type==="response")l(u);else{const d=u,f=new _(d.error.code,d.error.message,d.error.data);l(f)}else{const d=i.type==="response"?"Response":"Error";this._onerror(new Error(`${d} handler missing for request ${p}`))}continue}await this._transport?.send(i.message,{relatedRequestId:s.requestId})}}const n=await this._taskStore.getTask(o,s.sessionId);if(!n)throw new _(w.InvalidParams,`Task not found: ${o}`);if(!I(n.status))return await this._waitForTaskUpdate(o,s.signal),await r();if(I(n.status)){const i=await this._taskStore.getTaskResult(o,s.sessionId);return this._clearTaskQueue(o),{...i,_meta:{...i._meta,[M]:{taskId:o}}}}return await r()};return await r()}),this.setRequestHandler(Te,async(t,s)=>{try{const{tasks:r,nextCursor:o}=await this._taskStore.listTasks(t.params?.cursor,s.sessionId);return{tasks:r,nextCursor:o,_meta:{}}}catch(r){throw new _(w.InvalidParams,`Failed to list tasks: ${r instanceof Error?r.message:String(r)}`)}}),this.setRequestHandler(ye,async(t,s)=>{try{const r=await this._taskStore.getTask(t.params.taskId,s.sessionId);if(!r)throw new _(w.InvalidParams,`Task not found: ${t.params.taskId}`);if(I(r.status))throw new _(w.InvalidParams,`Cannot cancel task in terminal status: ${r.status}`);await this._taskStore.updateTaskStatus(t.params.taskId,"cancelled","Client cancelled task execution.",s.sessionId),this._clearTaskQueue(t.params.taskId);const o=await this._taskStore.getTask(t.params.taskId,s.sessionId);if(!o)throw new _(w.InvalidParams,`Task not found after cancellation: ${t.params.taskId}`);return{_meta:{},...o}}catch(r){throw r instanceof _?r:new _(w.InvalidRequest,`Failed to cancel task: ${r instanceof Error?r.message:String(r)}`)}}))}async _oncancel(e){if(!e.params.requestId)return;this._requestHandlerAbortControllers.get(e.params.requestId)?.abort(e.params.reason)}_setupTimeout(e,t,s,r,o=!1){this._timeoutInfo.set(e,{timeoutId:setTimeout(r,t),startTime:Date.now(),timeout:t,maxTotalTimeout:s,resetTimeoutOnProgress:o,onTimeout:r})}_resetTimeout(e){const t=this._timeoutInfo.get(e);if(!t)return!1;const s=Date.now()-t.startTime;if(t.maxTotalTimeout&&s>=t.maxTotalTimeout)throw this._timeoutInfo.delete(e),_.fromError(w.RequestTimeout,"Maximum total timeout exceeded",{maxTotalTimeout:t.maxTotalTimeout,totalElapsed:s});return clearTimeout(t.timeoutId),t.timeoutId=setTimeout(t.onTimeout,t.timeout),!0}_cleanupTimeout(e){const t=this._timeoutInfo.get(e);t&&(clearTimeout(t.timeoutId),this._timeoutInfo.delete(e))}async connect(e){if(this._transport)throw new Error("Already connected to a transport. Call close() before connecting to a new transport, or use a separate Protocol instance per connection.");this._transport=e;const t=this.transport?.onclose;this._transport.onclose=()=>{t?.(),this._onclose()};const s=this.transport?.onerror;this._transport.onerror=o=>{s?.(o),this._onerror(o)};const r=this._transport?.onmessage;this._transport.onmessage=(o,n)=>{r?.(o,n),$(o)||ve(o)?this._onresponse(o):V(o)?this._onrequest(o,n):ke(o)?this._onnotification(o):this._onerror(new Error(`Unknown message type: ${JSON.stringify(o)}`))},await this._transport.start()}_onclose(){const e=this._responseHandlers;this._responseHandlers=new Map,this._progressHandlers.clear(),this._taskProgressTokens.clear(),this._pendingDebouncedNotifications.clear();for(const s of this._timeoutInfo.values())clearTimeout(s.timeoutId);this._timeoutInfo.clear();for(const s of this._requestHandlerAbortControllers.values())s.abort();this._requestHandlerAbortControllers.clear();const t=_.fromError(w.ConnectionClosed,"Connection closed");this._transport=void 0,this.onclose?.();for(const s of e.values())s(t)}_onerror(e){this.onerror?.(e)}_onnotification(e){const t=this._notificationHandlers.get(e.method)??this.fallbackNotificationHandler;t!==void 0&&Promise.resolve().then(()=>t(e)).catch(s=>this._onerror(new Error(`Uncaught error in notification handler: ${s}`)))}_onrequest(e,t){const s=this._requestHandlers.get(e.method)??this.fallbackRequestHandler,r=this._transport,o=e.params?._meta?.[M]?.taskId;if(s===void 0){const l={jsonrpc:"2.0",id:e.id,error:{code:w.MethodNotFound,message:"Method not found"}};o&&this._taskMessageQueue?this._enqueueTaskMessage(o,{type:"error",message:l,timestamp:Date.now()},r?.sessionId).catch(d=>this._onerror(new Error(`Failed to enqueue error response: ${d}`))):r?.send(l).catch(d=>this._onerror(new Error(`Failed to send an error response: ${d}`)));return}const n=new AbortController;this._requestHandlerAbortControllers.set(e.id,n);const i=Se(e.params)?e.params.task:void 0,u=this._taskStore?this.requestTaskStore(e,r?.sessionId):void 0,p={signal:n.signal,sessionId:r?.sessionId,_meta:e.params?._meta,sendNotification:async l=>{if(n.signal.aborted)return;const d={relatedRequestId:e.id};o&&(d.relatedTask={taskId:o}),await this.notification(l,d)},sendRequest:async(l,d,f)=>{if(n.signal.aborted)throw new _(w.ConnectionClosed,"Request was cancelled");const m={...f,relatedRequestId:e.id};o&&!m.relatedTask&&(m.relatedTask={taskId:o});const T=m.relatedTask?.taskId??o;return T&&u&&await u.updateTaskStatus(T,"input_required"),await this.request(l,d,m)},authInfo:t?.authInfo,requestId:e.id,requestInfo:t?.requestInfo,taskId:o,taskStore:u,taskRequestedTtl:i?.ttl,closeSSEStream:t?.closeSSEStream,closeStandaloneSSEStream:t?.closeStandaloneSSEStream};Promise.resolve().then(()=>{i&&this.assertTaskHandlerCapability(e.method)}).then(()=>s(e,p)).then(async l=>{if(n.signal.aborted)return;const d={result:l,jsonrpc:"2.0",id:e.id};o&&this._taskMessageQueue?await this._enqueueTaskMessage(o,{type:"response",message:d,timestamp:Date.now()},r?.sessionId):await r?.send(d)},async l=>{if(n.signal.aborted)return;const d={jsonrpc:"2.0",id:e.id,error:{code:Number.isSafeInteger(l.code)?l.code:w.InternalError,message:l.message??"Internal error",...l.data!==void 0&&{data:l.data}}};o&&this._taskMessageQueue?await this._enqueueTaskMessage(o,{type:"error",message:d,timestamp:Date.now()},r?.sessionId):await r?.send(d)}).catch(l=>this._onerror(new Error(`Failed to send response: ${l}`))).finally(()=>{this._requestHandlerAbortControllers.get(e.id)===n&&this._requestHandlerAbortControllers.delete(e.id)})}_onprogress(e){const{progressToken:t,...s}=e.params,r=Number(t),o=this._progressHandlers.get(r);if(!o){this._onerror(new Error(`Received a progress notification for an unknown token: ${JSON.stringify(e)}`));return}const n=this._responseHandlers.get(r),i=this._timeoutInfo.get(r);if(i&&n&&i.resetTimeoutOnProgress)try{this._resetTimeout(r)}catch(u){this._responseHandlers.delete(r),this._progressHandlers.delete(r),this._cleanupTimeout(r),n(u);return}o(s)}_onresponse(e){const t=Number(e.id),s=this._requestResolvers.get(t);if(s){if(this._requestResolvers.delete(t),$(e))s(e);else{const n=new _(e.error.code,e.error.message,e.error.data);s(n)}return}const r=this._responseHandlers.get(t);if(r===void 0){this._onerror(new Error(`Received a response for an unknown message ID: ${JSON.stringify(e)}`));return}this._responseHandlers.delete(t),this._cleanupTimeout(t);let o=!1;if($(e)&&e.result&&typeof e.result=="object"){const n=e.result;if(n.task&&typeof n.task=="object"){const i=n.task;typeof i.taskId=="string"&&(o=!0,this._taskProgressTokens.set(i.taskId,t))}}if(o||this._progressHandlers.delete(t),$(e))r(e);else{const n=_.fromError(e.error.code,e.error.message,e.error.data);r(n)}}get transport(){return this._transport}async close(){await this._transport?.close()}async*requestStream(e,t,s){const{task:r}=s??{};if(!r){try{yield{type:"result",result:await this.request(e,t,s)}}catch(n){yield{type:"error",error:n instanceof _?n:new _(w.InternalError,String(n))}}return}let o;try{const n=await this.request(e,G,s);if(n.task)o=n.task.taskId,yield{type:"taskCreated",task:n.task};else throw new _(w.InternalError,"Task creation did not return a task");for(;;){const i=await this.getTask({taskId:o},s);if(yield{type:"taskStatus",task:i},I(i.status)){i.status==="completed"?yield{type:"result",result:await this.getTaskResult({taskId:o},t,s)}:i.status==="failed"?yield{type:"error",error:new _(w.InternalError,`Task ${o} failed`)}:i.status==="cancelled"&&(yield{type:"error",error:new _(w.InternalError,`Task ${o} was cancelled`)});return}if(i.status==="input_required"){yield{type:"result",result:await this.getTaskResult({taskId:o},t,s)};return}const u=i.pollInterval??this._options?.defaultTaskPollInterval??1e3;await new Promise(p=>setTimeout(p,u)),s?.signal?.throwIfAborted()}}catch(n){yield{type:"error",error:n instanceof _?n:new _(w.InternalError,String(n))}}}request(e,t,s){const{relatedRequestId:r,resumptionToken:o,onresumptiontoken:n,task:i,relatedTask:u}=s??{};return new Promise((p,l)=>{const d=c=>{l(c)};if(!this._transport){d(new Error("Not connected"));return}if(this._options?.enforceStrictCapabilities===!0)try{this.assertCapabilityForMethod(e.method),i&&this.assertTaskCapability(e.method)}catch(c){d(c);return}s?.signal?.throwIfAborted();const f=this._requestMessageId++,m={...e,jsonrpc:"2.0",id:f};s?.onprogress&&(this._progressHandlers.set(f,s.onprogress),m.params={...e.params,_meta:{...e.params?._meta||{},progressToken:f}}),i&&(m.params={...m.params,task:i}),u&&(m.params={...m.params,_meta:{...m.params?._meta||{},[M]:u}});const T=c=>{this._responseHandlers.delete(f),this._progressHandlers.delete(f),this._cleanupTimeout(f),this._transport?.send({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:f,reason:String(c)}},{relatedRequestId:r,resumptionToken:o,onresumptiontoken:n}).catch(k=>this._onerror(new Error(`Failed to send cancellation: ${k}`)));const g=c instanceof _?c:new _(w.RequestTimeout,String(c));l(g)};this._responseHandlers.set(f,c=>{if(!s?.signal?.aborted){if(c instanceof Error)return l(c);try{const g=b(t,c.result);g.success?p(g.data):l(g.error)}catch(g){l(g)}}}),s?.signal?.addEventListener("abort",()=>{T(s?.signal?.reason)});const y=s?.timeout??ot,v=()=>T(_.fromError(w.RequestTimeout,"Request timed out",{timeout:y}));this._setupTimeout(f,y,s?.maxTotalTimeout,v,s?.resetTimeoutOnProgress??!1);const h=u?.taskId;if(h){const c=g=>{const k=this._responseHandlers.get(f);k?k(g):this._onerror(new Error(`Response handler missing for side-channeled request ${f}`))};this._requestResolvers.set(f,c),this._enqueueTaskMessage(h,{type:"request",message:m,timestamp:Date.now()}).catch(g=>{this._cleanupTimeout(f),l(g)})}else this._transport.send(m,{relatedRequestId:r,resumptionToken:o,onresumptiontoken:n}).catch(c=>{this._cleanupTimeout(f),l(c)})})}async getTask(e,t){return this.request({method:"tasks/get",params:e},Re,t)}async getTaskResult(e,t,s){return this.request({method:"tasks/result",params:e},t,s)}async listTasks(e,t){return this.request({method:"tasks/list",params:e},Ce,t)}async cancelTask(e,t){return this.request({method:"tasks/cancel",params:e},Ee,t)}async notification(e,t){if(!this._transport)throw new Error("Not connected");this.assertNotificationCapability(e.method);const s=t?.relatedTask?.taskId;if(s){const i={...e,jsonrpc:"2.0",params:{...e.params,_meta:{...e.params?._meta||{},[M]:t.relatedTask}}};await this._enqueueTaskMessage(s,{type:"notification",message:i,timestamp:Date.now()});return}if((this._options?.debouncedNotificationMethods??[]).includes(e.method)&&!e.params&&!t?.relatedRequestId&&!t?.relatedTask){if(this._pendingDebouncedNotifications.has(e.method))return;this._pendingDebouncedNotifications.add(e.method),Promise.resolve().then(()=>{if(this._pendingDebouncedNotifications.delete(e.method),!this._transport)return;let i={...e,jsonrpc:"2.0"};t?.relatedTask&&(i={...i,params:{...i.params,_meta:{...i.params?._meta||{},[M]:t.relatedTask}}}),this._transport?.send(i,t).catch(u=>this._onerror(u))});return}let n={...e,jsonrpc:"2.0"};t?.relatedTask&&(n={...n,params:{...n.params,_meta:{...n.params?._meta||{},[M]:t.relatedTask}}}),await this._transport.send(n,t)}setRequestHandler(e,t){const s=Y(e);this.assertRequestHandlerCapability(s),this._requestHandlers.set(s,(r,o)=>{const n=B(e,r);return Promise.resolve(t(n,o))})}removeRequestHandler(e){this._requestHandlers.delete(e)}assertCanSetRequestHandler(e){if(this._requestHandlers.has(e))throw new Error(`A request handler for ${e} already exists, which would be overridden`)}setNotificationHandler(e,t){const s=Y(e);this._notificationHandlers.set(s,r=>{const o=B(e,r);return Promise.resolve(t(o))})}removeNotificationHandler(e){this._notificationHandlers.delete(e)}_cleanupTaskProgressHandler(e){const t=this._taskProgressTokens.get(e);t!==void 0&&(this._progressHandlers.delete(t),this._taskProgressTokens.delete(e))}async _enqueueTaskMessage(e,t,s){if(!this._taskStore||!this._taskMessageQueue)throw new Error("Cannot enqueue task message: taskStore and taskMessageQueue are not configured");const r=this._options?.maxTaskQueueSize;await this._taskMessageQueue.enqueue(e,t,s,r)}async _clearTaskQueue(e,t){if(this._taskMessageQueue){const s=await this._taskMessageQueue.dequeueAll(e,t);for(const r of s)if(r.type==="request"&&V(r.message)){const o=r.message.id,n=this._requestResolvers.get(o);n?(n(new _(w.InternalError,"Task cancelled or completed")),this._requestResolvers.delete(o)):this._onerror(new Error(`Resolver missing for request ${o} during task ${e} cleanup`))}}}async _waitForTaskUpdate(e,t){let s=this._options?.defaultTaskPollInterval??1e3;try{const r=await this._taskStore?.getTask(e);r?.pollInterval&&(s=r.pollInterval)}catch{}return new Promise((r,o)=>{if(t.aborted){o(new _(w.InvalidRequest,"Request cancelled"));return}const n=setTimeout(r,s);t.addEventListener("abort",()=>{clearTimeout(n),o(new _(w.InvalidRequest,"Request cancelled"))},{once:!0})})}requestTaskStore(e,t){const s=this._taskStore;if(!s)throw new Error("No task store configured");return{createTask:async r=>{if(!e)throw new Error("No request provided");return await s.createTask(r,e.id,{method:e.method,params:e.params},t)},getTask:async r=>{const o=await s.getTask(r,t);if(!o)throw new _(w.InvalidParams,"Failed to retrieve task: Task not found");return o},storeTaskResult:async(r,o,n)=>{await s.storeTaskResult(r,o,n,t);const i=await s.getTask(r,t);if(i){const u=K.parse({method:"notifications/tasks/status",params:i});await this.notification(u),I(i.status)&&this._cleanupTaskProgressHandler(r)}},getTaskResult:r=>s.getTaskResult(r,t),updateTaskStatus:async(r,o,n)=>{const i=await s.getTask(r,t);if(!i)throw new _(w.InvalidParams,`Task "${r}" not found - it may have been cleaned up`);if(I(i.status))throw new _(w.InvalidParams,`Cannot update task "${r}" from terminal status "${i.status}" to "${o}". Terminal states (completed, failed, cancelled) cannot transition to other states.`);await s.updateTaskStatus(r,o,n,t);const u=await s.getTask(r,t);if(u){const p=K.parse({method:"notifications/tasks/status",params:u});await this.notification(p),I(u.status)&&this._cleanupTaskProgressHandler(r)}},listTasks:r=>s.listTasks(r,t)}}}function Z(a){return a!==null&&typeof a=="object"&&!Array.isArray(a)}function nt(a,e){const t={...a};for(const s in e){const r=s,o=e[r];if(o===void 0)continue;const n=t[r];Z(n)&&Z(o)?t[r]={...n,...o}:t[r]=o}return t}var it=Ie();const ct=be(it);function lt(){const a=new ct({strict:!1,validateFormats:!0,validateSchema:!1,allErrors:!0});return Ae(a),a}class ut{constructor(e){this._ajv=e??lt()}getValidator(e){const t="$id"in e&&typeof e.$id=="string"?this._ajv.getSchema(e.$id)??this._ajv.compile(e):this._ajv.compile(e);return s=>t(s)?{valid:!0,data:s,errorMessage:void 0}:{valid:!1,data:void 0,errorMessage:this._ajv.errorsText(t.errors)}}}class dt{constructor(e){this._client=e}async*callToolStream(e,t=re,s){const r=this._client,o={...s,task:s?.task??(r.isToolTask(e.name)?{}:void 0)},n=r.requestStream({method:"tools/call",params:e},t,o),i=r.getToolOutputValidator(e.name);for await(const u of n){if(u.type==="result"&&i){const p=u.result;if(!p.structuredContent&&!p.isError){yield{type:"error",error:new _(w.InvalidRequest,`Tool ${e.name} has an output schema but did not return structured content`)};return}if(p.structuredContent)try{const l=i(p.structuredContent);if(!l.valid){yield{type:"error",error:new _(w.InvalidParams,`Structured content does not match the tool's output schema: ${l.errorMessage}`)};return}}catch(l){if(l instanceof _){yield{type:"error",error:l};return}yield{type:"error",error:new _(w.InvalidParams,`Failed to validate structured content: ${l instanceof Error?l.message:String(l)}`)};return}}yield u}}async getTask(e,t){return this._client.getTask({taskId:e},t)}async getTaskResult(e,t,s){return this._client.getTaskResult({taskId:e},t,s)}async listTasks(e,t){return this._client.listTasks(e?{cursor:e}:void 0,t)}async cancelTask(e,t){return this._client.cancelTask({taskId:e},t)}requestStream(e,t,s){return this._client.requestStream(e,t,s)}}function ht(a,e,t){if(!a)throw new Error(`${t} does not support task creation (required for ${e})`);switch(e){case"tools/call":if(!a.tools?.call)throw new Error(`${t} does not support task creation for tools/call (required for ${e})`);break}}function ft(a,e,t){if(!a)throw new Error(`${t} does not support task creation (required for ${e})`);switch(e){case"sampling/createMessage":if(!a.sampling?.createMessage)throw new Error(`${t} does not support task creation for sampling/createMessage (required for ${e})`);break;case"elicitation/create":if(!a.elicitation?.create)throw new Error(`${t} does not support task creation for elicitation/create (required for ${e})`);break}}function U(a,e){if(!(!a||e===null||typeof e!="object")){if(a.type==="object"&&a.properties&&typeof a.properties=="object"){const t=e,s=a.properties;for(const r of Object.keys(s)){const o=s[r];t[r]===void 0&&Object.prototype.hasOwnProperty.call(o,"default")&&(t[r]=o.default),t[r]!==void 0&&U(o,t[r])}}if(Array.isArray(a.anyOf))for(const t of a.anyOf)typeof t!="boolean"&&U(t,e);if(Array.isArray(a.oneOf))for(const t of a.oneOf)typeof t!="boolean"&&U(t,e)}}function pt(a){if(!a)return{supportsFormMode:!1,supportsUrlMode:!1};const e=a.form!==void 0,t=a.url!==void 0;return{supportsFormMode:e||!e&&!t,supportsUrlMode:t}}let mt=class extends at{constructor(e,t){super(t),this._clientInfo=e,this._cachedToolOutputValidators=new Map,this._cachedKnownTaskTools=new Set,this._cachedRequiredTaskTools=new Set,this._listChangedDebounceTimers=new Map,this._capabilities=t?.capabilities??{},this._jsonSchemaValidator=t?.jsonSchemaValidator??new ut,t?.listChanged&&(this._pendingListChangedConfig=t.listChanged)}_setupListChangedHandlers(e){e.tools&&this._serverCapabilities?.tools?.listChanged&&this._setupListChangedHandler("tools",qe,e.tools,async()=>(await this.listTools()).tools),e.prompts&&this._serverCapabilities?.prompts?.listChanged&&this._setupListChangedHandler("prompts",Me,e.prompts,async()=>(await this.listPrompts()).prompts),e.resources&&this._serverCapabilities?.resources?.listChanged&&this._setupListChangedHandler("resources",Pe,e.resources,async()=>(await this.listResources()).resources)}get experimental(){return this._experimental||(this._experimental={tasks:new dt(this)}),this._experimental}registerCapabilities(e){if(this.transport)throw new Error("Cannot register capabilities after connecting to transport");this._capabilities=nt(this._capabilities,e)}setRequestHandler(e,t){const r=ce(e)?.method;if(!r)throw new Error("Schema is missing a method literal");let o;if(x(r)){const i=r;o=i._zod?.def?.value??i.value}else{const i=r;o=i._def?.value??i.value}if(typeof o!="string")throw new Error("Schema method literal must be a string");const n=o;if(n==="elicitation/create"){const i=async(u,p)=>{const l=b(Ge,u);if(!l.success){const c=l.error instanceof Error?l.error.message:String(l.error);throw new _(w.InvalidParams,`Invalid elicitation request: ${c}`)}const{params:d}=l.data;d.mode=d.mode??"form";const{supportsFormMode:f,supportsUrlMode:m}=pt(this._capabilities.elicitation);if(d.mode==="form"&&!f)throw new _(w.InvalidParams,"Client does not support form-mode elicitation requests");if(d.mode==="url"&&!m)throw new _(w.InvalidParams,"Client does not support URL-mode elicitation requests");const T=await Promise.resolve(t(u,p));if(d.task){const c=b(G,T);if(!c.success){const g=c.error instanceof Error?c.error.message:String(c.error);throw new _(w.InvalidParams,`Invalid task creation result: ${g}`)}return c.data}const y=b(ze,T);if(!y.success){const c=y.error instanceof Error?y.error.message:String(y.error);throw new _(w.InvalidParams,`Invalid elicitation result: ${c}`)}const v=y.data,h=d.mode==="form"?d.requestedSchema:void 0;if(d.mode==="form"&&v.action==="accept"&&v.content&&h&&this._capabilities.elicitation?.form?.applyDefaults)try{U(h,v.content)}catch{}return v};return super.setRequestHandler(e,i)}if(n==="sampling/createMessage"){const i=async(u,p)=>{const l=b(Qe,u);if(!l.success){const v=l.error instanceof Error?l.error.message:String(l.error);throw new _(w.InvalidParams,`Invalid sampling request: ${v}`)}const{params:d}=l.data,f=await Promise.resolve(t(u,p));if(d.task){const v=b(G,f);if(!v.success){const h=v.error instanceof Error?v.error.message:String(v.error);throw new _(w.InvalidParams,`Invalid task creation result: ${h}`)}return v.data}const T=d.tools||d.toolChoice?We:Ke,y=b(T,f);if(!y.success){const v=y.error instanceof Error?y.error.message:String(y.error);throw new _(w.InvalidParams,`Invalid sampling result: ${v}`)}return y.data};return super.setRequestHandler(e,i)}return super.setRequestHandler(e,t)}assertCapability(e,t){if(!this._serverCapabilities?.[e])throw new Error(`Server does not support ${e} (required for ${t})`)}async connect(e,t){if(await super.connect(e),e.sessionId===void 0)try{const s=await this.request({method:"initialize",params:{protocolVersion:Oe,capabilities:this._capabilities,clientInfo:this._clientInfo}},$e,t);if(s===void 0)throw new Error(`Server sent invalid initialize result: ${s}`);if(!Ne.includes(s.protocolVersion))throw new Error(`Server's protocol version is not supported: ${s.protocolVersion}`);this._serverCapabilities=s.capabilities,this._serverVersion=s.serverInfo,e.setProtocolVersion&&e.setProtocolVersion(s.protocolVersion),this._instructions=s.instructions,await this.notification({method:"notifications/initialized"}),this._pendingListChangedConfig&&(this._setupListChangedHandlers(this._pendingListChangedConfig),this._pendingListChangedConfig=void 0)}catch(s){throw this.close(),s}}getServerCapabilities(){return this._serverCapabilities}getServerVersion(){return this._serverVersion}getInstructions(){return this._instructions}assertCapabilityForMethod(e){switch(e){case"logging/setLevel":if(!this._serverCapabilities?.logging)throw new Error(`Server does not support logging (required for ${e})`);break;case"prompts/get":case"prompts/list":if(!this._serverCapabilities?.prompts)throw new Error(`Server does not support prompts (required for ${e})`);break;case"resources/list":case"resources/templates/list":case"resources/read":case"resources/subscribe":case"resources/unsubscribe":if(!this._serverCapabilities?.resources)throw new Error(`Server does not support resources (required for ${e})`);if(e==="resources/subscribe"&&!this._serverCapabilities.resources.subscribe)throw new Error(`Server does not support resource subscriptions (required for ${e})`);break;case"tools/call":case"tools/list":if(!this._serverCapabilities?.tools)throw new Error(`Server does not support tools (required for ${e})`);break;case"completion/complete":if(!this._serverCapabilities?.completions)throw new Error(`Server does not support completions (required for ${e})`);break}}assertNotificationCapability(e){switch(e){case"notifications/roots/list_changed":if(!this._capabilities.roots?.listChanged)throw new Error(`Client does not support roots list changed notifications (required for ${e})`);break}}assertRequestHandlerCapability(e){if(this._capabilities)switch(e){case"sampling/createMessage":if(!this._capabilities.sampling)throw new Error(`Client does not support sampling capability (required for ${e})`);break;case"elicitation/create":if(!this._capabilities.elicitation)throw new Error(`Client does not support elicitation capability (required for ${e})`);break;case"roots/list":if(!this._capabilities.roots)throw new Error(`Client does not support roots capability (required for ${e})`);break;case"tasks/get":case"tasks/list":case"tasks/result":case"tasks/cancel":if(!this._capabilities.tasks)throw new Error(`Client does not support tasks capability (required for ${e})`);break}}assertTaskCapability(e){ht(this._serverCapabilities?.tasks?.requests,e,"Server")}assertTaskHandlerCapability(e){this._capabilities&&ft(this._capabilities.tasks?.requests,e,"Client")}async ping(e){return this.request({method:"ping"},N,e)}async complete(e,t){return this.request({method:"completion/complete",params:e},He,t)}async setLoggingLevel(e,t){return this.request({method:"logging/setLevel",params:{level:e}},N,t)}async getPrompt(e,t){return this.request({method:"prompts/get",params:e},Ue,t)}async listPrompts(e,t){return this.request({method:"prompts/list",params:e},De,t)}async listResources(e,t){return this.request({method:"resources/list",params:e},xe,t)}async listResourceTemplates(e,t){return this.request({method:"resources/templates/list",params:e},je,t)}async readResource(e,t){return this.request({method:"resources/read",params:e},Le,t)}async subscribeResource(e,t){return this.request({method:"resources/subscribe",params:e},N,t)}async unsubscribeResource(e,t){return this.request({method:"resources/unsubscribe",params:e},N,t)}async callTool(e,t=re,s){if(this.isToolTaskRequired(e.name))throw new _(w.InvalidRequest,`Tool "${e.name}" requires task-based execution. Use client.experimental.tasks.callToolStream() instead.`);const r=await this.request({method:"tools/call",params:e},t,s),o=this.getToolOutputValidator(e.name);if(o){if(!r.structuredContent&&!r.isError)throw new _(w.InvalidRequest,`Tool ${e.name} has an output schema but did not return structured content`);if(r.structuredContent)try{const n=o(r.structuredContent);if(!n.valid)throw new _(w.InvalidParams,`Structured content does not match the tool's output schema: ${n.errorMessage}`)}catch(n){throw n instanceof _?n:new _(w.InvalidParams,`Failed to validate structured content: ${n instanceof Error?n.message:String(n)}`)}}return r}isToolTask(e){return this._serverCapabilities?.tasks?.requests?.tools?.call?this._cachedKnownTaskTools.has(e):!1}isToolTaskRequired(e){return this._cachedRequiredTaskTools.has(e)}cacheToolMetadata(e){this._cachedToolOutputValidators.clear(),this._cachedKnownTaskTools.clear(),this._cachedRequiredTaskTools.clear();for(const t of e){if(t.outputSchema){const r=this._jsonSchemaValidator.getValidator(t.outputSchema);this._cachedToolOutputValidators.set(t.name,r)}const s=t.execution?.taskSupport;(s==="required"||s==="optional")&&this._cachedKnownTaskTools.add(t.name),s==="required"&&this._cachedRequiredTaskTools.add(t.name)}}getToolOutputValidator(e){return this._cachedToolOutputValidators.get(e)}async listTools(e,t){const s=await this.request({method:"tools/list",params:e},Fe,t);return this.cacheToolMetadata(s.tools),s}_setupListChangedHandler(e,t,s,r){const o=Ve.safeParse(s);if(!o.success)throw new Error(`Invalid ${e} listChanged options: ${o.error.message}`);if(typeof s.onChanged!="function")throw new Error(`Invalid ${e} listChanged options: onChanged must be a function`);const{autoRefresh:n,debounceMs:i}=o.data,{onChanged:u}=s,p=async()=>{if(!n){u(null,null);return}try{const d=await r();u(null,d)}catch(d){const f=d instanceof Error?d:new Error(String(d));u(f,null)}},l=()=>{if(i){const d=this._listChangedDebounceTimers.get(e);d&&clearTimeout(d);const f=setTimeout(p,i);this._listChangedDebounceTimers.set(e,f)}else p()};this.setNotificationHandler(t,l)}async sendRootsListChanged(){return this.notification({method:"notifications/roots/list_changed"})}};const L=a=>[{type:"text",text:a}];function _t(a){const e=D(a,typeof window<"u"?window.location.origin:void 0);if(!e)throw new Error("RestSelfClient requires either studioUrl or a browser environment.");const t={"Content-Type":"application/json",Accept:"application/json",...a.token?{Authorization:`Bearer ${a.token}`}:{}},s=u=>new URL(`/api/${encodeURIComponent(a.orgSlug)}${u}`,e).href,r=async u=>{let p;try{p=await fetch(s(`/tools/${encodeURIComponent(u.name)}`),{method:"POST",headers:t,credentials:"include",body:JSON.stringify(u.arguments??{})})}catch(d){const f=d instanceof Error?d.message:"Network error";return{content:L(f),isError:!0}}if(!p.ok){let d=`${u.name} failed (${p.status})`;try{const f=await p.json();f?.error&&(d=f.error)}catch{}return{content:L(d),isError:!0}}const l=await p.json().catch(()=>({}));return{content:L(typeof l=="string"?l:JSON.stringify(l)),structuredContent:l}},o=async()=>{const u=await fetch(s("/tools"),{method:"GET",headers:t,credentials:"include"});return u.ok?await u.json():{tools:[]}},n=u=>()=>Promise.reject(new Error(`RestSelfClient: ${u} is not supported over REST for the self connection`));return{callTool:r,listTools:o,listPrompts:n("listPrompts"),getPrompt:n("getPrompt"),listResources:n("listResources"),readResource:n("readResource"),listResourceTemplates:n("listResourceTemplates"),close:()=>Promise.resolve(),toJSON:()=>a.toJSONString}}function z(a){return a?a instanceof Headers?Object.fromEntries(a.entries()):Array.isArray(a)?Object.fromEntries(a):{...a}:{}}function gt(a=fetch,e){return e?async(t,s)=>{const r={...e,...s,headers:s?.headers?{...z(e.headers),...z(s.headers)}:e.headers};return a(t,r)}:a}class X extends Error{constructor(e,t){super(e),this.name="ParseError",this.type=t.type,this.field=t.field,this.value=t.value,this.line=t.line}}const ee=10,wt=13,A=32;function F(a){}function Tt(a){if(typeof a=="function")throw new TypeError("`callbacks` must be an object, got a function instead. Did you mean `{onEvent: fn}`?");const{onEvent:e=F,onError:t=F,onRetry:s=F,onComment:r}=a,o=[];let n=!0,i,u="",p=0,l;function d(h){if(n&&(n=!1,h.charCodeAt(0)===239&&h.charCodeAt(1)===187&&h.charCodeAt(2)===191&&(h=h.slice(3))),o.length===0){const k=f(h);k!==""&&o.push(k);return}if(h.indexOf(`
1
+ import{da as fe,db as pe,dc as me,cf as _e,dd as ge,bU as _,bV as w,de as we,df as Te,dg as ye,dh as $,di as ve,dj as V,dk as ke,dl as M,dm as Se,dn as G,dp as Re,dq as Ce,dr as Ee,ds as K,bx as be,bz as Ie,bu as Ae,ca as re,cm as qe,cs as Me,cq as Pe,cD as Oe,dt as $e,du as Ne,dv as N,dw as He,dx as Ue,cr as De,cn as xe,co as je,cp as Le,bv as Fe,dy as Ve,dz as Ge,dA as ze,ch as Qe,dB as We,dC as Ke,cz as D,dD as Je,bt as j,c as oe,x as ae,K as Q}from"./index-BhSBUjFQ.js";import{U as P,a as H,e as J}from"./auth-HJuo3oRQ.js";const qt={SELF:a=>`${a}_self`,REGISTRY:a=>`${a}_registry`,COMMUNITY_REGISTRY:a=>`${a}_community-registry`,DEV_ASSETS:a=>`${a}_dev-assets`,SITE_DIAGNOSTICS:a=>`site-diagnostics_${a}`,COMMERCE_DISCOVERY:a=>`${a}_commerce-discovery`},Mt="get_my_diagnostic",Pt="https://github.com/decocms.png",Ye="self";function R(a){return{is(e){return!e||!e.startsWith(a)?null:e.slice(a.length)||null},get(e){return`${a}${e}`}}}function Be(a){return{id:a.id,organization_id:a.organizationId,title:a.title,description:a.description,icon:a.icon,status:"active",created_at:new Date().toISOString(),updated_at:new Date().toISOString(),created_by:"system",updated_by:void 0,metadata:{instructions:a.instructions??null,...a.ui?{ui:a.ui}:{}},pinned:!1,connections:[]}}const ne=R("decopilot_"),Ot=ne.is,Ze=ne.get,ie=R("dev_"),$t=ie.get,Nt=ie.is,Xe="https://assets.decocache.com/decocms/fd07a578-6b1c-40f1-bc05-88a3b981695d/f7fc4ffa81aec04e37ae670c3cd4936643a7b269.png",et="#f59e0b",Ht=`https://api.iconify.design/lucide:bug.svg?color=${encodeURIComponent(et)}`,tt="#6366f1",Ut=`https://api.iconify.design/lucide:file-search.svg?color=${encodeURIComponent(tt)}`;function Dt(a){return Be({id:Ze(a),organizationId:a,title:"Super Agent",description:"Default agent that aggregates all organization connections",icon:Xe,ui:{layout:{defaultMainView:{type:"overview"},chatDefaultOpen:!0}}})}const st=R("commerce-discovery_"),xt=st.get,C={AGENT_MANAGER:R("studio-agent-manager_"),AUTOMATION_MANAGER:R("studio-automation-manager_"),CONNECTION_MANAGER:R("studio-connection-manager_"),API_KEY_MANAGER:R("studio-api-key-manager_"),STORE_MANAGER:R("studio-store-manager_"),BRAND_MANAGER:R("studio-brand-manager_"),TASK_MANAGER:R("studio-task-manager_"),USAGE_MANAGER:R("studio-usage-manager_")},jt={AGENT_MANAGER:C.AGENT_MANAGER.get,AUTOMATION_MANAGER:C.AUTOMATION_MANAGER.get,CONNECTION_MANAGER:C.CONNECTION_MANAGER.get,API_KEY_MANAGER:C.API_KEY_MANAGER.get,STORE_MANAGER:C.STORE_MANAGER.get,BRAND_MANAGER:C.BRAND_MANAGER.get,TASK_MANAGER:C.TASK_MANAGER.get,USAGE_MANAGER:C.USAGE_MANAGER.get};function Lt(a){return a?Object.values(C).some(e=>e.is(a)!==null):!1}function x(a){return!!a._zod}function b(a,e){return x(a)?fe(a,e):a.safeParse(e)}function ce(a){if(!a)return;let e;if(x(a)?e=a._zod?.def?.shape:e=a.shape,!!e){if(typeof e=="function")try{return e()}catch{return}return e}}function rt(a){if(x(a)){const o=a._zod?.def;if(o){if(o.value!==void 0)return o.value;if(Array.isArray(o.values)&&o.values.length>0)return o.values[0]}}const t=a._def;if(t){if(t.value!==void 0)return t.value;if(Array.isArray(t.values)&&t.values.length>0)return t.values[0]}const s=a.value;if(s!==void 0)return s}function I(a){return a==="completed"||a==="failed"||a==="cancelled"}function Y(a){const t=ce(a)?.method;if(!t)throw new Error("Schema is missing a method literal");const s=rt(t);if(typeof s!="string")throw new Error("Schema method literal must be a string");return s}function B(a,e){const t=b(a,e);if(!t.success)throw t.error;return t.data}const ot=6e4;class at{constructor(e){this._options=e,this._requestMessageId=0,this._requestHandlers=new Map,this._requestHandlerAbortControllers=new Map,this._notificationHandlers=new Map,this._responseHandlers=new Map,this._progressHandlers=new Map,this._timeoutInfo=new Map,this._pendingDebouncedNotifications=new Set,this._taskProgressTokens=new Map,this._requestResolvers=new Map,this.setNotificationHandler(pe,t=>{this._oncancel(t)}),this.setNotificationHandler(me,t=>{this._onprogress(t)}),this.setRequestHandler(_e,t=>({})),this._taskStore=e?.taskStore,this._taskMessageQueue=e?.taskMessageQueue,this._taskStore&&(this.setRequestHandler(ge,async(t,s)=>{const r=await this._taskStore.getTask(t.params.taskId,s.sessionId);if(!r)throw new _(w.InvalidParams,"Failed to retrieve task: Task not found");return{...r}}),this.setRequestHandler(we,async(t,s)=>{const r=async()=>{const o=t.params.taskId;if(this._taskMessageQueue){let i;for(;i=await this._taskMessageQueue.dequeue(o,s.sessionId);){if(i.type==="response"||i.type==="error"){const u=i.message,p=u.id,l=this._requestResolvers.get(p);if(l)if(this._requestResolvers.delete(p),i.type==="response")l(u);else{const d=u,f=new _(d.error.code,d.error.message,d.error.data);l(f)}else{const d=i.type==="response"?"Response":"Error";this._onerror(new Error(`${d} handler missing for request ${p}`))}continue}await this._transport?.send(i.message,{relatedRequestId:s.requestId})}}const n=await this._taskStore.getTask(o,s.sessionId);if(!n)throw new _(w.InvalidParams,`Task not found: ${o}`);if(!I(n.status))return await this._waitForTaskUpdate(o,s.signal),await r();if(I(n.status)){const i=await this._taskStore.getTaskResult(o,s.sessionId);return this._clearTaskQueue(o),{...i,_meta:{...i._meta,[M]:{taskId:o}}}}return await r()};return await r()}),this.setRequestHandler(Te,async(t,s)=>{try{const{tasks:r,nextCursor:o}=await this._taskStore.listTasks(t.params?.cursor,s.sessionId);return{tasks:r,nextCursor:o,_meta:{}}}catch(r){throw new _(w.InvalidParams,`Failed to list tasks: ${r instanceof Error?r.message:String(r)}`)}}),this.setRequestHandler(ye,async(t,s)=>{try{const r=await this._taskStore.getTask(t.params.taskId,s.sessionId);if(!r)throw new _(w.InvalidParams,`Task not found: ${t.params.taskId}`);if(I(r.status))throw new _(w.InvalidParams,`Cannot cancel task in terminal status: ${r.status}`);await this._taskStore.updateTaskStatus(t.params.taskId,"cancelled","Client cancelled task execution.",s.sessionId),this._clearTaskQueue(t.params.taskId);const o=await this._taskStore.getTask(t.params.taskId,s.sessionId);if(!o)throw new _(w.InvalidParams,`Task not found after cancellation: ${t.params.taskId}`);return{_meta:{},...o}}catch(r){throw r instanceof _?r:new _(w.InvalidRequest,`Failed to cancel task: ${r instanceof Error?r.message:String(r)}`)}}))}async _oncancel(e){if(!e.params.requestId)return;this._requestHandlerAbortControllers.get(e.params.requestId)?.abort(e.params.reason)}_setupTimeout(e,t,s,r,o=!1){this._timeoutInfo.set(e,{timeoutId:setTimeout(r,t),startTime:Date.now(),timeout:t,maxTotalTimeout:s,resetTimeoutOnProgress:o,onTimeout:r})}_resetTimeout(e){const t=this._timeoutInfo.get(e);if(!t)return!1;const s=Date.now()-t.startTime;if(t.maxTotalTimeout&&s>=t.maxTotalTimeout)throw this._timeoutInfo.delete(e),_.fromError(w.RequestTimeout,"Maximum total timeout exceeded",{maxTotalTimeout:t.maxTotalTimeout,totalElapsed:s});return clearTimeout(t.timeoutId),t.timeoutId=setTimeout(t.onTimeout,t.timeout),!0}_cleanupTimeout(e){const t=this._timeoutInfo.get(e);t&&(clearTimeout(t.timeoutId),this._timeoutInfo.delete(e))}async connect(e){if(this._transport)throw new Error("Already connected to a transport. Call close() before connecting to a new transport, or use a separate Protocol instance per connection.");this._transport=e;const t=this.transport?.onclose;this._transport.onclose=()=>{t?.(),this._onclose()};const s=this.transport?.onerror;this._transport.onerror=o=>{s?.(o),this._onerror(o)};const r=this._transport?.onmessage;this._transport.onmessage=(o,n)=>{r?.(o,n),$(o)||ve(o)?this._onresponse(o):V(o)?this._onrequest(o,n):ke(o)?this._onnotification(o):this._onerror(new Error(`Unknown message type: ${JSON.stringify(o)}`))},await this._transport.start()}_onclose(){const e=this._responseHandlers;this._responseHandlers=new Map,this._progressHandlers.clear(),this._taskProgressTokens.clear(),this._pendingDebouncedNotifications.clear();for(const s of this._timeoutInfo.values())clearTimeout(s.timeoutId);this._timeoutInfo.clear();for(const s of this._requestHandlerAbortControllers.values())s.abort();this._requestHandlerAbortControllers.clear();const t=_.fromError(w.ConnectionClosed,"Connection closed");this._transport=void 0,this.onclose?.();for(const s of e.values())s(t)}_onerror(e){this.onerror?.(e)}_onnotification(e){const t=this._notificationHandlers.get(e.method)??this.fallbackNotificationHandler;t!==void 0&&Promise.resolve().then(()=>t(e)).catch(s=>this._onerror(new Error(`Uncaught error in notification handler: ${s}`)))}_onrequest(e,t){const s=this._requestHandlers.get(e.method)??this.fallbackRequestHandler,r=this._transport,o=e.params?._meta?.[M]?.taskId;if(s===void 0){const l={jsonrpc:"2.0",id:e.id,error:{code:w.MethodNotFound,message:"Method not found"}};o&&this._taskMessageQueue?this._enqueueTaskMessage(o,{type:"error",message:l,timestamp:Date.now()},r?.sessionId).catch(d=>this._onerror(new Error(`Failed to enqueue error response: ${d}`))):r?.send(l).catch(d=>this._onerror(new Error(`Failed to send an error response: ${d}`)));return}const n=new AbortController;this._requestHandlerAbortControllers.set(e.id,n);const i=Se(e.params)?e.params.task:void 0,u=this._taskStore?this.requestTaskStore(e,r?.sessionId):void 0,p={signal:n.signal,sessionId:r?.sessionId,_meta:e.params?._meta,sendNotification:async l=>{if(n.signal.aborted)return;const d={relatedRequestId:e.id};o&&(d.relatedTask={taskId:o}),await this.notification(l,d)},sendRequest:async(l,d,f)=>{if(n.signal.aborted)throw new _(w.ConnectionClosed,"Request was cancelled");const m={...f,relatedRequestId:e.id};o&&!m.relatedTask&&(m.relatedTask={taskId:o});const T=m.relatedTask?.taskId??o;return T&&u&&await u.updateTaskStatus(T,"input_required"),await this.request(l,d,m)},authInfo:t?.authInfo,requestId:e.id,requestInfo:t?.requestInfo,taskId:o,taskStore:u,taskRequestedTtl:i?.ttl,closeSSEStream:t?.closeSSEStream,closeStandaloneSSEStream:t?.closeStandaloneSSEStream};Promise.resolve().then(()=>{i&&this.assertTaskHandlerCapability(e.method)}).then(()=>s(e,p)).then(async l=>{if(n.signal.aborted)return;const d={result:l,jsonrpc:"2.0",id:e.id};o&&this._taskMessageQueue?await this._enqueueTaskMessage(o,{type:"response",message:d,timestamp:Date.now()},r?.sessionId):await r?.send(d)},async l=>{if(n.signal.aborted)return;const d={jsonrpc:"2.0",id:e.id,error:{code:Number.isSafeInteger(l.code)?l.code:w.InternalError,message:l.message??"Internal error",...l.data!==void 0&&{data:l.data}}};o&&this._taskMessageQueue?await this._enqueueTaskMessage(o,{type:"error",message:d,timestamp:Date.now()},r?.sessionId):await r?.send(d)}).catch(l=>this._onerror(new Error(`Failed to send response: ${l}`))).finally(()=>{this._requestHandlerAbortControllers.get(e.id)===n&&this._requestHandlerAbortControllers.delete(e.id)})}_onprogress(e){const{progressToken:t,...s}=e.params,r=Number(t),o=this._progressHandlers.get(r);if(!o){this._onerror(new Error(`Received a progress notification for an unknown token: ${JSON.stringify(e)}`));return}const n=this._responseHandlers.get(r),i=this._timeoutInfo.get(r);if(i&&n&&i.resetTimeoutOnProgress)try{this._resetTimeout(r)}catch(u){this._responseHandlers.delete(r),this._progressHandlers.delete(r),this._cleanupTimeout(r),n(u);return}o(s)}_onresponse(e){const t=Number(e.id),s=this._requestResolvers.get(t);if(s){if(this._requestResolvers.delete(t),$(e))s(e);else{const n=new _(e.error.code,e.error.message,e.error.data);s(n)}return}const r=this._responseHandlers.get(t);if(r===void 0){this._onerror(new Error(`Received a response for an unknown message ID: ${JSON.stringify(e)}`));return}this._responseHandlers.delete(t),this._cleanupTimeout(t);let o=!1;if($(e)&&e.result&&typeof e.result=="object"){const n=e.result;if(n.task&&typeof n.task=="object"){const i=n.task;typeof i.taskId=="string"&&(o=!0,this._taskProgressTokens.set(i.taskId,t))}}if(o||this._progressHandlers.delete(t),$(e))r(e);else{const n=_.fromError(e.error.code,e.error.message,e.error.data);r(n)}}get transport(){return this._transport}async close(){await this._transport?.close()}async*requestStream(e,t,s){const{task:r}=s??{};if(!r){try{yield{type:"result",result:await this.request(e,t,s)}}catch(n){yield{type:"error",error:n instanceof _?n:new _(w.InternalError,String(n))}}return}let o;try{const n=await this.request(e,G,s);if(n.task)o=n.task.taskId,yield{type:"taskCreated",task:n.task};else throw new _(w.InternalError,"Task creation did not return a task");for(;;){const i=await this.getTask({taskId:o},s);if(yield{type:"taskStatus",task:i},I(i.status)){i.status==="completed"?yield{type:"result",result:await this.getTaskResult({taskId:o},t,s)}:i.status==="failed"?yield{type:"error",error:new _(w.InternalError,`Task ${o} failed`)}:i.status==="cancelled"&&(yield{type:"error",error:new _(w.InternalError,`Task ${o} was cancelled`)});return}if(i.status==="input_required"){yield{type:"result",result:await this.getTaskResult({taskId:o},t,s)};return}const u=i.pollInterval??this._options?.defaultTaskPollInterval??1e3;await new Promise(p=>setTimeout(p,u)),s?.signal?.throwIfAborted()}}catch(n){yield{type:"error",error:n instanceof _?n:new _(w.InternalError,String(n))}}}request(e,t,s){const{relatedRequestId:r,resumptionToken:o,onresumptiontoken:n,task:i,relatedTask:u}=s??{};return new Promise((p,l)=>{const d=c=>{l(c)};if(!this._transport){d(new Error("Not connected"));return}if(this._options?.enforceStrictCapabilities===!0)try{this.assertCapabilityForMethod(e.method),i&&this.assertTaskCapability(e.method)}catch(c){d(c);return}s?.signal?.throwIfAborted();const f=this._requestMessageId++,m={...e,jsonrpc:"2.0",id:f};s?.onprogress&&(this._progressHandlers.set(f,s.onprogress),m.params={...e.params,_meta:{...e.params?._meta||{},progressToken:f}}),i&&(m.params={...m.params,task:i}),u&&(m.params={...m.params,_meta:{...m.params?._meta||{},[M]:u}});const T=c=>{this._responseHandlers.delete(f),this._progressHandlers.delete(f),this._cleanupTimeout(f),this._transport?.send({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:f,reason:String(c)}},{relatedRequestId:r,resumptionToken:o,onresumptiontoken:n}).catch(k=>this._onerror(new Error(`Failed to send cancellation: ${k}`)));const g=c instanceof _?c:new _(w.RequestTimeout,String(c));l(g)};this._responseHandlers.set(f,c=>{if(!s?.signal?.aborted){if(c instanceof Error)return l(c);try{const g=b(t,c.result);g.success?p(g.data):l(g.error)}catch(g){l(g)}}}),s?.signal?.addEventListener("abort",()=>{T(s?.signal?.reason)});const y=s?.timeout??ot,v=()=>T(_.fromError(w.RequestTimeout,"Request timed out",{timeout:y}));this._setupTimeout(f,y,s?.maxTotalTimeout,v,s?.resetTimeoutOnProgress??!1);const h=u?.taskId;if(h){const c=g=>{const k=this._responseHandlers.get(f);k?k(g):this._onerror(new Error(`Response handler missing for side-channeled request ${f}`))};this._requestResolvers.set(f,c),this._enqueueTaskMessage(h,{type:"request",message:m,timestamp:Date.now()}).catch(g=>{this._cleanupTimeout(f),l(g)})}else this._transport.send(m,{relatedRequestId:r,resumptionToken:o,onresumptiontoken:n}).catch(c=>{this._cleanupTimeout(f),l(c)})})}async getTask(e,t){return this.request({method:"tasks/get",params:e},Re,t)}async getTaskResult(e,t,s){return this.request({method:"tasks/result",params:e},t,s)}async listTasks(e,t){return this.request({method:"tasks/list",params:e},Ce,t)}async cancelTask(e,t){return this.request({method:"tasks/cancel",params:e},Ee,t)}async notification(e,t){if(!this._transport)throw new Error("Not connected");this.assertNotificationCapability(e.method);const s=t?.relatedTask?.taskId;if(s){const i={...e,jsonrpc:"2.0",params:{...e.params,_meta:{...e.params?._meta||{},[M]:t.relatedTask}}};await this._enqueueTaskMessage(s,{type:"notification",message:i,timestamp:Date.now()});return}if((this._options?.debouncedNotificationMethods??[]).includes(e.method)&&!e.params&&!t?.relatedRequestId&&!t?.relatedTask){if(this._pendingDebouncedNotifications.has(e.method))return;this._pendingDebouncedNotifications.add(e.method),Promise.resolve().then(()=>{if(this._pendingDebouncedNotifications.delete(e.method),!this._transport)return;let i={...e,jsonrpc:"2.0"};t?.relatedTask&&(i={...i,params:{...i.params,_meta:{...i.params?._meta||{},[M]:t.relatedTask}}}),this._transport?.send(i,t).catch(u=>this._onerror(u))});return}let n={...e,jsonrpc:"2.0"};t?.relatedTask&&(n={...n,params:{...n.params,_meta:{...n.params?._meta||{},[M]:t.relatedTask}}}),await this._transport.send(n,t)}setRequestHandler(e,t){const s=Y(e);this.assertRequestHandlerCapability(s),this._requestHandlers.set(s,(r,o)=>{const n=B(e,r);return Promise.resolve(t(n,o))})}removeRequestHandler(e){this._requestHandlers.delete(e)}assertCanSetRequestHandler(e){if(this._requestHandlers.has(e))throw new Error(`A request handler for ${e} already exists, which would be overridden`)}setNotificationHandler(e,t){const s=Y(e);this._notificationHandlers.set(s,r=>{const o=B(e,r);return Promise.resolve(t(o))})}removeNotificationHandler(e){this._notificationHandlers.delete(e)}_cleanupTaskProgressHandler(e){const t=this._taskProgressTokens.get(e);t!==void 0&&(this._progressHandlers.delete(t),this._taskProgressTokens.delete(e))}async _enqueueTaskMessage(e,t,s){if(!this._taskStore||!this._taskMessageQueue)throw new Error("Cannot enqueue task message: taskStore and taskMessageQueue are not configured");const r=this._options?.maxTaskQueueSize;await this._taskMessageQueue.enqueue(e,t,s,r)}async _clearTaskQueue(e,t){if(this._taskMessageQueue){const s=await this._taskMessageQueue.dequeueAll(e,t);for(const r of s)if(r.type==="request"&&V(r.message)){const o=r.message.id,n=this._requestResolvers.get(o);n?(n(new _(w.InternalError,"Task cancelled or completed")),this._requestResolvers.delete(o)):this._onerror(new Error(`Resolver missing for request ${o} during task ${e} cleanup`))}}}async _waitForTaskUpdate(e,t){let s=this._options?.defaultTaskPollInterval??1e3;try{const r=await this._taskStore?.getTask(e);r?.pollInterval&&(s=r.pollInterval)}catch{}return new Promise((r,o)=>{if(t.aborted){o(new _(w.InvalidRequest,"Request cancelled"));return}const n=setTimeout(r,s);t.addEventListener("abort",()=>{clearTimeout(n),o(new _(w.InvalidRequest,"Request cancelled"))},{once:!0})})}requestTaskStore(e,t){const s=this._taskStore;if(!s)throw new Error("No task store configured");return{createTask:async r=>{if(!e)throw new Error("No request provided");return await s.createTask(r,e.id,{method:e.method,params:e.params},t)},getTask:async r=>{const o=await s.getTask(r,t);if(!o)throw new _(w.InvalidParams,"Failed to retrieve task: Task not found");return o},storeTaskResult:async(r,o,n)=>{await s.storeTaskResult(r,o,n,t);const i=await s.getTask(r,t);if(i){const u=K.parse({method:"notifications/tasks/status",params:i});await this.notification(u),I(i.status)&&this._cleanupTaskProgressHandler(r)}},getTaskResult:r=>s.getTaskResult(r,t),updateTaskStatus:async(r,o,n)=>{const i=await s.getTask(r,t);if(!i)throw new _(w.InvalidParams,`Task "${r}" not found - it may have been cleaned up`);if(I(i.status))throw new _(w.InvalidParams,`Cannot update task "${r}" from terminal status "${i.status}" to "${o}". Terminal states (completed, failed, cancelled) cannot transition to other states.`);await s.updateTaskStatus(r,o,n,t);const u=await s.getTask(r,t);if(u){const p=K.parse({method:"notifications/tasks/status",params:u});await this.notification(p),I(u.status)&&this._cleanupTaskProgressHandler(r)}},listTasks:r=>s.listTasks(r,t)}}}function Z(a){return a!==null&&typeof a=="object"&&!Array.isArray(a)}function nt(a,e){const t={...a};for(const s in e){const r=s,o=e[r];if(o===void 0)continue;const n=t[r];Z(n)&&Z(o)?t[r]={...n,...o}:t[r]=o}return t}var it=Ie();const ct=be(it);function lt(){const a=new ct({strict:!1,validateFormats:!0,validateSchema:!1,allErrors:!0});return Ae(a),a}class ut{constructor(e){this._ajv=e??lt()}getValidator(e){const t="$id"in e&&typeof e.$id=="string"?this._ajv.getSchema(e.$id)??this._ajv.compile(e):this._ajv.compile(e);return s=>t(s)?{valid:!0,data:s,errorMessage:void 0}:{valid:!1,data:void 0,errorMessage:this._ajv.errorsText(t.errors)}}}class dt{constructor(e){this._client=e}async*callToolStream(e,t=re,s){const r=this._client,o={...s,task:s?.task??(r.isToolTask(e.name)?{}:void 0)},n=r.requestStream({method:"tools/call",params:e},t,o),i=r.getToolOutputValidator(e.name);for await(const u of n){if(u.type==="result"&&i){const p=u.result;if(!p.structuredContent&&!p.isError){yield{type:"error",error:new _(w.InvalidRequest,`Tool ${e.name} has an output schema but did not return structured content`)};return}if(p.structuredContent)try{const l=i(p.structuredContent);if(!l.valid){yield{type:"error",error:new _(w.InvalidParams,`Structured content does not match the tool's output schema: ${l.errorMessage}`)};return}}catch(l){if(l instanceof _){yield{type:"error",error:l};return}yield{type:"error",error:new _(w.InvalidParams,`Failed to validate structured content: ${l instanceof Error?l.message:String(l)}`)};return}}yield u}}async getTask(e,t){return this._client.getTask({taskId:e},t)}async getTaskResult(e,t,s){return this._client.getTaskResult({taskId:e},t,s)}async listTasks(e,t){return this._client.listTasks(e?{cursor:e}:void 0,t)}async cancelTask(e,t){return this._client.cancelTask({taskId:e},t)}requestStream(e,t,s){return this._client.requestStream(e,t,s)}}function ht(a,e,t){if(!a)throw new Error(`${t} does not support task creation (required for ${e})`);switch(e){case"tools/call":if(!a.tools?.call)throw new Error(`${t} does not support task creation for tools/call (required for ${e})`);break}}function ft(a,e,t){if(!a)throw new Error(`${t} does not support task creation (required for ${e})`);switch(e){case"sampling/createMessage":if(!a.sampling?.createMessage)throw new Error(`${t} does not support task creation for sampling/createMessage (required for ${e})`);break;case"elicitation/create":if(!a.elicitation?.create)throw new Error(`${t} does not support task creation for elicitation/create (required for ${e})`);break}}function U(a,e){if(!(!a||e===null||typeof e!="object")){if(a.type==="object"&&a.properties&&typeof a.properties=="object"){const t=e,s=a.properties;for(const r of Object.keys(s)){const o=s[r];t[r]===void 0&&Object.prototype.hasOwnProperty.call(o,"default")&&(t[r]=o.default),t[r]!==void 0&&U(o,t[r])}}if(Array.isArray(a.anyOf))for(const t of a.anyOf)typeof t!="boolean"&&U(t,e);if(Array.isArray(a.oneOf))for(const t of a.oneOf)typeof t!="boolean"&&U(t,e)}}function pt(a){if(!a)return{supportsFormMode:!1,supportsUrlMode:!1};const e=a.form!==void 0,t=a.url!==void 0;return{supportsFormMode:e||!e&&!t,supportsUrlMode:t}}let mt=class extends at{constructor(e,t){super(t),this._clientInfo=e,this._cachedToolOutputValidators=new Map,this._cachedKnownTaskTools=new Set,this._cachedRequiredTaskTools=new Set,this._listChangedDebounceTimers=new Map,this._capabilities=t?.capabilities??{},this._jsonSchemaValidator=t?.jsonSchemaValidator??new ut,t?.listChanged&&(this._pendingListChangedConfig=t.listChanged)}_setupListChangedHandlers(e){e.tools&&this._serverCapabilities?.tools?.listChanged&&this._setupListChangedHandler("tools",qe,e.tools,async()=>(await this.listTools()).tools),e.prompts&&this._serverCapabilities?.prompts?.listChanged&&this._setupListChangedHandler("prompts",Me,e.prompts,async()=>(await this.listPrompts()).prompts),e.resources&&this._serverCapabilities?.resources?.listChanged&&this._setupListChangedHandler("resources",Pe,e.resources,async()=>(await this.listResources()).resources)}get experimental(){return this._experimental||(this._experimental={tasks:new dt(this)}),this._experimental}registerCapabilities(e){if(this.transport)throw new Error("Cannot register capabilities after connecting to transport");this._capabilities=nt(this._capabilities,e)}setRequestHandler(e,t){const r=ce(e)?.method;if(!r)throw new Error("Schema is missing a method literal");let o;if(x(r)){const i=r;o=i._zod?.def?.value??i.value}else{const i=r;o=i._def?.value??i.value}if(typeof o!="string")throw new Error("Schema method literal must be a string");const n=o;if(n==="elicitation/create"){const i=async(u,p)=>{const l=b(Ge,u);if(!l.success){const c=l.error instanceof Error?l.error.message:String(l.error);throw new _(w.InvalidParams,`Invalid elicitation request: ${c}`)}const{params:d}=l.data;d.mode=d.mode??"form";const{supportsFormMode:f,supportsUrlMode:m}=pt(this._capabilities.elicitation);if(d.mode==="form"&&!f)throw new _(w.InvalidParams,"Client does not support form-mode elicitation requests");if(d.mode==="url"&&!m)throw new _(w.InvalidParams,"Client does not support URL-mode elicitation requests");const T=await Promise.resolve(t(u,p));if(d.task){const c=b(G,T);if(!c.success){const g=c.error instanceof Error?c.error.message:String(c.error);throw new _(w.InvalidParams,`Invalid task creation result: ${g}`)}return c.data}const y=b(ze,T);if(!y.success){const c=y.error instanceof Error?y.error.message:String(y.error);throw new _(w.InvalidParams,`Invalid elicitation result: ${c}`)}const v=y.data,h=d.mode==="form"?d.requestedSchema:void 0;if(d.mode==="form"&&v.action==="accept"&&v.content&&h&&this._capabilities.elicitation?.form?.applyDefaults)try{U(h,v.content)}catch{}return v};return super.setRequestHandler(e,i)}if(n==="sampling/createMessage"){const i=async(u,p)=>{const l=b(Qe,u);if(!l.success){const v=l.error instanceof Error?l.error.message:String(l.error);throw new _(w.InvalidParams,`Invalid sampling request: ${v}`)}const{params:d}=l.data,f=await Promise.resolve(t(u,p));if(d.task){const v=b(G,f);if(!v.success){const h=v.error instanceof Error?v.error.message:String(v.error);throw new _(w.InvalidParams,`Invalid task creation result: ${h}`)}return v.data}const T=d.tools||d.toolChoice?We:Ke,y=b(T,f);if(!y.success){const v=y.error instanceof Error?y.error.message:String(y.error);throw new _(w.InvalidParams,`Invalid sampling result: ${v}`)}return y.data};return super.setRequestHandler(e,i)}return super.setRequestHandler(e,t)}assertCapability(e,t){if(!this._serverCapabilities?.[e])throw new Error(`Server does not support ${e} (required for ${t})`)}async connect(e,t){if(await super.connect(e),e.sessionId===void 0)try{const s=await this.request({method:"initialize",params:{protocolVersion:Oe,capabilities:this._capabilities,clientInfo:this._clientInfo}},$e,t);if(s===void 0)throw new Error(`Server sent invalid initialize result: ${s}`);if(!Ne.includes(s.protocolVersion))throw new Error(`Server's protocol version is not supported: ${s.protocolVersion}`);this._serverCapabilities=s.capabilities,this._serverVersion=s.serverInfo,e.setProtocolVersion&&e.setProtocolVersion(s.protocolVersion),this._instructions=s.instructions,await this.notification({method:"notifications/initialized"}),this._pendingListChangedConfig&&(this._setupListChangedHandlers(this._pendingListChangedConfig),this._pendingListChangedConfig=void 0)}catch(s){throw this.close(),s}}getServerCapabilities(){return this._serverCapabilities}getServerVersion(){return this._serverVersion}getInstructions(){return this._instructions}assertCapabilityForMethod(e){switch(e){case"logging/setLevel":if(!this._serverCapabilities?.logging)throw new Error(`Server does not support logging (required for ${e})`);break;case"prompts/get":case"prompts/list":if(!this._serverCapabilities?.prompts)throw new Error(`Server does not support prompts (required for ${e})`);break;case"resources/list":case"resources/templates/list":case"resources/read":case"resources/subscribe":case"resources/unsubscribe":if(!this._serverCapabilities?.resources)throw new Error(`Server does not support resources (required for ${e})`);if(e==="resources/subscribe"&&!this._serverCapabilities.resources.subscribe)throw new Error(`Server does not support resource subscriptions (required for ${e})`);break;case"tools/call":case"tools/list":if(!this._serverCapabilities?.tools)throw new Error(`Server does not support tools (required for ${e})`);break;case"completion/complete":if(!this._serverCapabilities?.completions)throw new Error(`Server does not support completions (required for ${e})`);break}}assertNotificationCapability(e){switch(e){case"notifications/roots/list_changed":if(!this._capabilities.roots?.listChanged)throw new Error(`Client does not support roots list changed notifications (required for ${e})`);break}}assertRequestHandlerCapability(e){if(this._capabilities)switch(e){case"sampling/createMessage":if(!this._capabilities.sampling)throw new Error(`Client does not support sampling capability (required for ${e})`);break;case"elicitation/create":if(!this._capabilities.elicitation)throw new Error(`Client does not support elicitation capability (required for ${e})`);break;case"roots/list":if(!this._capabilities.roots)throw new Error(`Client does not support roots capability (required for ${e})`);break;case"tasks/get":case"tasks/list":case"tasks/result":case"tasks/cancel":if(!this._capabilities.tasks)throw new Error(`Client does not support tasks capability (required for ${e})`);break}}assertTaskCapability(e){ht(this._serverCapabilities?.tasks?.requests,e,"Server")}assertTaskHandlerCapability(e){this._capabilities&&ft(this._capabilities.tasks?.requests,e,"Client")}async ping(e){return this.request({method:"ping"},N,e)}async complete(e,t){return this.request({method:"completion/complete",params:e},He,t)}async setLoggingLevel(e,t){return this.request({method:"logging/setLevel",params:{level:e}},N,t)}async getPrompt(e,t){return this.request({method:"prompts/get",params:e},Ue,t)}async listPrompts(e,t){return this.request({method:"prompts/list",params:e},De,t)}async listResources(e,t){return this.request({method:"resources/list",params:e},xe,t)}async listResourceTemplates(e,t){return this.request({method:"resources/templates/list",params:e},je,t)}async readResource(e,t){return this.request({method:"resources/read",params:e},Le,t)}async subscribeResource(e,t){return this.request({method:"resources/subscribe",params:e},N,t)}async unsubscribeResource(e,t){return this.request({method:"resources/unsubscribe",params:e},N,t)}async callTool(e,t=re,s){if(this.isToolTaskRequired(e.name))throw new _(w.InvalidRequest,`Tool "${e.name}" requires task-based execution. Use client.experimental.tasks.callToolStream() instead.`);const r=await this.request({method:"tools/call",params:e},t,s),o=this.getToolOutputValidator(e.name);if(o){if(!r.structuredContent&&!r.isError)throw new _(w.InvalidRequest,`Tool ${e.name} has an output schema but did not return structured content`);if(r.structuredContent)try{const n=o(r.structuredContent);if(!n.valid)throw new _(w.InvalidParams,`Structured content does not match the tool's output schema: ${n.errorMessage}`)}catch(n){throw n instanceof _?n:new _(w.InvalidParams,`Failed to validate structured content: ${n instanceof Error?n.message:String(n)}`)}}return r}isToolTask(e){return this._serverCapabilities?.tasks?.requests?.tools?.call?this._cachedKnownTaskTools.has(e):!1}isToolTaskRequired(e){return this._cachedRequiredTaskTools.has(e)}cacheToolMetadata(e){this._cachedToolOutputValidators.clear(),this._cachedKnownTaskTools.clear(),this._cachedRequiredTaskTools.clear();for(const t of e){if(t.outputSchema){const r=this._jsonSchemaValidator.getValidator(t.outputSchema);this._cachedToolOutputValidators.set(t.name,r)}const s=t.execution?.taskSupport;(s==="required"||s==="optional")&&this._cachedKnownTaskTools.add(t.name),s==="required"&&this._cachedRequiredTaskTools.add(t.name)}}getToolOutputValidator(e){return this._cachedToolOutputValidators.get(e)}async listTools(e,t){const s=await this.request({method:"tools/list",params:e},Fe,t);return this.cacheToolMetadata(s.tools),s}_setupListChangedHandler(e,t,s,r){const o=Ve.safeParse(s);if(!o.success)throw new Error(`Invalid ${e} listChanged options: ${o.error.message}`);if(typeof s.onChanged!="function")throw new Error(`Invalid ${e} listChanged options: onChanged must be a function`);const{autoRefresh:n,debounceMs:i}=o.data,{onChanged:u}=s,p=async()=>{if(!n){u(null,null);return}try{const d=await r();u(null,d)}catch(d){const f=d instanceof Error?d:new Error(String(d));u(f,null)}},l=()=>{if(i){const d=this._listChangedDebounceTimers.get(e);d&&clearTimeout(d);const f=setTimeout(p,i);this._listChangedDebounceTimers.set(e,f)}else p()};this.setNotificationHandler(t,l)}async sendRootsListChanged(){return this.notification({method:"notifications/roots/list_changed"})}};const L=a=>[{type:"text",text:a}];function _t(a){const e=D(a,typeof window<"u"?window.location.origin:void 0);if(!e)throw new Error("RestSelfClient requires either studioUrl or a browser environment.");const t={"Content-Type":"application/json",Accept:"application/json",...a.token?{Authorization:`Bearer ${a.token}`}:{}},s=u=>new URL(`/api/${encodeURIComponent(a.orgSlug)}${u}`,e).href,r=async u=>{let p;try{p=await fetch(s(`/tools/${encodeURIComponent(u.name)}`),{method:"POST",headers:t,credentials:"include",body:JSON.stringify(u.arguments??{})})}catch(d){const f=d instanceof Error?d.message:"Network error";return{content:L(f),isError:!0}}if(!p.ok){let d=`${u.name} failed (${p.status})`;try{const f=await p.json();f?.error&&(d=f.error)}catch{}return{content:L(d),isError:!0}}const l=await p.json().catch(()=>({}));return{content:L(typeof l=="string"?l:JSON.stringify(l)),structuredContent:l}},o=async()=>{const u=await fetch(s("/tools"),{method:"GET",headers:t,credentials:"include"});return u.ok?await u.json():{tools:[]}},n=u=>()=>Promise.reject(new Error(`RestSelfClient: ${u} is not supported over REST for the self connection`));return{callTool:r,listTools:o,listPrompts:n("listPrompts"),getPrompt:n("getPrompt"),listResources:n("listResources"),readResource:n("readResource"),listResourceTemplates:n("listResourceTemplates"),close:()=>Promise.resolve(),toJSON:()=>a.toJSONString}}function z(a){return a?a instanceof Headers?Object.fromEntries(a.entries()):Array.isArray(a)?Object.fromEntries(a):{...a}:{}}function gt(a=fetch,e){return e?async(t,s)=>{const r={...e,...s,headers:s?.headers?{...z(e.headers),...z(s.headers)}:e.headers};return a(t,r)}:a}class X extends Error{constructor(e,t){super(e),this.name="ParseError",this.type=t.type,this.field=t.field,this.value=t.value,this.line=t.line}}const ee=10,wt=13,A=32;function F(a){}function Tt(a){if(typeof a=="function")throw new TypeError("`callbacks` must be an object, got a function instead. Did you mean `{onEvent: fn}`?");const{onEvent:e=F,onError:t=F,onRetry:s=F,onComment:r}=a,o=[];let n=!0,i,u="",p=0,l;function d(h){if(n&&(n=!1,h.charCodeAt(0)===239&&h.charCodeAt(1)===187&&h.charCodeAt(2)===191&&(h=h.slice(3))),o.length===0){const k=f(h);k!==""&&o.push(k);return}if(h.indexOf(`
2
2
  `)===-1&&h.indexOf("\r")===-1){o.push(h);return}o.push(h);const c=o.join("");o.length=0;const g=f(c);g!==""&&o.push(g)}function f(h){let c=0;if(h.indexOf("\r")===-1){let g=h.indexOf(`
3
3
  `,c);for(;g!==-1;){if(c===g){p>0&&e({id:i,event:l,data:u}),i=void 0,u="",p=0,l=void 0,c=g+1,g=h.indexOf(`
4
4
  `,c);continue}const k=h.charCodeAt(c);if(te(h,c,k)){const S=h.charCodeAt(c+5)===A?c+6:c+5,E=h.slice(S,g);if(p===0&&h.charCodeAt(g+1)===ee){e({id:i,event:l,data:E}),i=void 0,u="",l=void 0,c=g+2,g=h.indexOf(`