decocms 2.309.0 → 2.310.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (442) hide show
  1. package/dist/client/assets/{AlertCircle-DfpOj9uk.js → AlertCircle-Cty0PLzG.js} +1 -1
  2. package/dist/client/assets/{ArrowNarrowLeft-CGsSFJZH.js → ArrowNarrowLeft-GsAWuH-U.js} +1 -1
  3. package/dist/client/assets/{ArrowUpRight-DtiNC8xj.js → ArrowUpRight-Ck_tkMu3.js} +1 -1
  4. package/dist/client/assets/{Check-DXPBjwC9.js → Check-3abToiit.js} +1 -1
  5. package/dist/client/assets/{CheckCircle-DenvulPR.js → CheckCircle-gN0xOzFk.js} +1 -1
  6. package/dist/client/assets/{ChevronDown-BzUdsdeu.js → ChevronDown-Du1srzFH.js} +1 -1
  7. package/dist/client/assets/{ChevronRight-8RBDSI4c.js → ChevronRight-CZd3BLjH.js} +1 -1
  8. package/dist/client/assets/{ChevronUp-CkOPdM7g.js → ChevronUp-CgHHKXV-.js} +1 -1
  9. package/dist/client/assets/{Container-B2b9FJMR.js → Container-DV6TDqni.js} +1 -1
  10. package/dist/client/assets/{DotsVertical-CCxgBVsk.js → DotsVertical-D7_daHaX.js} +1 -1
  11. package/dist/client/assets/{LinkExternal01-C_eUHFUm.js → LinkExternal01-CLwRaqiP.js} +1 -1
  12. package/dist/client/assets/{Lock01-SmEMRGOb.js → Lock01-DW1KfF8p.js} +1 -1
  13. package/dist/client/assets/{Palette-qMNBtXtx.js → Palette-DgoZ3R-C.js} +1 -1
  14. package/dist/client/assets/{Play-DmVY8R1A.js → Play-ZbM8yAk4.js} +1 -1
  15. package/dist/client/assets/{Plus-B19lTgl_.js → Plus-xUHEWwhK.js} +1 -1
  16. package/dist/client/assets/{RefreshCcw01-DDZo1WKt.js → RefreshCcw01-DOURBTJB.js} +1 -1
  17. package/dist/client/assets/{SearchMd-BvQQOrkm.js → SearchMd-D05lbITN.js} +1 -1
  18. package/dist/client/assets/{Settings02-CYadYmOF.js → Settings02-YbowrI3C.js} +1 -1
  19. package/dist/client/assets/{Shield01-GS3q0eea.js → Shield01-C9nMXmPC.js} +1 -1
  20. package/dist/client/assets/{Star01-BM8AlGEC.js → Star01-Dcuqy8Xk.js} +1 -1
  21. package/dist/client/assets/{Sun-B2OKfrtR.js → Sun-s1inzqGI.js} +1 -1
  22. package/dist/client/assets/{Tool01-CIMPkAjR.js → Tool01-BxwtRzVa.js} +1 -1
  23. package/dist/client/assets/{Trash01-4PBXkXRo.js → Trash01-Bgq8zueU.js} +1 -1
  24. package/dist/client/assets/{User01-nh8Rby1P.js → User01-C3dKJDdx.js} +1 -1
  25. package/dist/client/assets/{Users03-CItFKGX1.js → Users03-DBewd1K5.js} +1 -1
  26. package/dist/client/assets/{X-CGShNfee.js → X-BANQifhl.js} +1 -1
  27. package/dist/client/assets/{XCircle-CTrtJtfR.js → XCircle-BOat1iVu.js} +1 -1
  28. package/dist/client/assets/{XClose-BnCJyyB-.js → XClose-B0qkWAhQ.js} +1 -1
  29. package/dist/client/assets/{Zap-D7WiwjAV.js → Zap-Cq3RtLSB.js} +1 -1
  30. package/dist/client/assets/{ZapSquare-DhbSIk6a.js → ZapSquare-BajF09ms.js} +1 -1
  31. package/dist/client/assets/{accordion-CgT_Vu18.js → accordion-Bm-v7xME.js} +1 -1
  32. package/dist/client/assets/{agent-icon-GBX3RKid.js → agent-icon-SBMo6sYE.js} +1 -1
  33. package/dist/client/assets/{agents-list--TECSTo0.js → agents-list-GJhbrN0t.js} +1 -1
  34. package/dist/client/assets/ai-providers-CGGe3rZi.js +1 -0
  35. package/dist/client/assets/{alert-dialog-CZ6BxFHK.js → alert-dialog-Bht5ffLL.js} +1 -1
  36. package/dist/client/assets/{auth-catchall-CzFa67HB.js → auth-catchall-BywQWWLa.js} +1 -1
  37. package/dist/client/assets/{automation-list-row-DC7TfwMb.js → automation-list-row-Bf0t7EtN.js} +1 -1
  38. package/dist/client/assets/{automations-DPy2yPJ7.js → automations-TTGgZ4_x.js} +1 -1
  39. package/dist/client/assets/{avatar-BbisflHp.js → avatar-C0tjLWvd.js} +1 -1
  40. package/dist/client/assets/{badge-B32WzuEH.js → badge-CETVYtBV.js} +1 -1
  41. package/dist/client/assets/{brand-context-CNm1jHaQ.js → brand-context-BYQ1b567.js} +1 -1
  42. package/dist/client/assets/{card-DdVfFEw2.js → card-CGYKd1RQ.js} +1 -1
  43. package/dist/client/assets/{chat-context-BnJMVusJ.js → chat-context-CNhlOw91.js} +1 -1
  44. package/dist/client/assets/{checkbox-BJiR6nKO.js → checkbox-GOJe-fLe.js} +1 -1
  45. package/dist/client/assets/{collection-detail-tyzI1jcV.js → collection-detail-D2LL1NRS.js} +1 -1
  46. package/dist/client/assets/{collection-display-button-Tq0uOlxA.js → collection-display-button-D33z-MiQ.js} +1 -1
  47. package/dist/client/assets/{collection-search-BBFkmets.js → collection-search-DKsJLeUf.js} +1 -1
  48. package/dist/client/assets/{collection-search-D62A0L7U.js → collection-search-pRmMMUTu.js} +1 -1
  49. package/dist/client/assets/{collection-table-wrapper-CjFwfKJr.js → collection-table-wrapper-DkvuPVRT.js} +1 -1
  50. package/dist/client/assets/{collection-tabs--b599n6J.js → collection-tabs-Dm7Azh1U.js} +1 -1
  51. package/dist/client/assets/{collections-C5AWnYf0.js → collections-CRk11Z8a.js} +1 -1
  52. package/dist/client/assets/{command-DK-j4arJ.js → command-BUpWRvBK.js} +1 -1
  53. package/dist/client/assets/{connection-card--P5ycKzL.js → connection-card-D9OhH-Fq.js} +1 -1
  54. package/dist/client/assets/{connection-detail-CUNWcOPp.js → connection-detail-CQU5Tvmh.js} +1 -1
  55. package/dist/client/assets/{connection-form-helpers-BeJI6IBg.js → connection-form-helpers-D1bN8HX-.js} +1 -1
  56. package/dist/client/assets/{connections-DWQtsigZ.js → connections-CgifR5uL.js} +1 -1
  57. package/dist/client/assets/{constants-CnfWGYKH.js → constants-BCHiURE4.js} +1 -1
  58. package/dist/client/assets/{constants-sHQufsXI.js → constants-Cp5N7awu.js} +1 -1
  59. package/dist/client/assets/{dialog-BZytMGON.js → dialog-C67OG62k.js} +1 -1
  60. package/dist/client/assets/{domain-settings-bUM7Hn2b.js → domain-settings-tkR1Nxgx.js} +1 -1
  61. package/dist/client/assets/{drawer-D-6kJz55.js → drawer-dxlczq_i.js} +1 -1
  62. package/dist/client/assets/{dropdown-menu-BpdWPWdq.js → dropdown-menu-CW5XsoI8.js} +1 -1
  63. package/dist/client/assets/{dynamic-plugin-layout-CZeZv3Kn.js → dynamic-plugin-layout-tEvbHH60.js} +1 -1
  64. package/dist/client/assets/{empty-state-BQISF-I3.js → empty-state-Ci5HFdKD.js} +1 -1
  65. package/dist/client/assets/{empty-state-DuLPP0P_.js → empty-state-CmG4puLG.js} +1 -1
  66. package/dist/client/assets/{extract-connection-data-Bj_pawjK.js → extract-connection-data-hFQpz6Ey.js} +1 -1
  67. package/dist/client/assets/{features-92AWt8WI.js → features-BVz7FR1H.js} +1 -1
  68. package/dist/client/assets/{form-Bi1l8-LL.js → form-DPfW-AID.js} +1 -1
  69. package/dist/client/assets/{general-CJgzv-Wx.js → general-CU3b0SfV.js} +1 -1
  70. package/dist/client/assets/{index-YDo551Ci.js → index-BFPJC5eE.js} +1 -1
  71. package/dist/client/assets/{index-gC4su7X_.js → index-C9J0IAed.js} +1 -1
  72. package/dist/client/assets/{index-Dr1V1Dds.js → index-CKp44BR_.js} +1 -1
  73. package/dist/client/assets/{index-BheN5Hjz.js → index-CMBuSnHj.js} +1 -1
  74. package/dist/client/assets/{index-CzZgNQPp.js → index-COeQARzy.js} +1 -1
  75. package/dist/client/assets/{index-R0jE9KSj.js → index-Cg8Nu4CY.js} +3 -3
  76. package/dist/client/assets/{index-C39RwBnQ.js → index-ClSJa_a-.js} +1 -1
  77. package/dist/client/assets/{index-BydJ2WUR.js → index-DGiQyM9G.js} +1 -1
  78. package/dist/client/assets/index-DP8Jy3jt.js +1 -0
  79. package/dist/client/assets/{index--ghksYAo.js → index-DS-a6wyz.js} +1 -1
  80. package/dist/client/assets/{index-C03HvIgQ.js → index-Ddo0iMq6.js} +1 -1
  81. package/dist/client/assets/{index-DSzBgSpo.js → index-HbxcCsnZ.js} +1 -1
  82. package/dist/client/assets/{index-CE54Jnz-.js → index-QuRKY5U6.js} +1 -1
  83. package/dist/client/assets/{index-Cbpr6CGx.js → index-akTmUiSO.js} +1 -1
  84. package/dist/client/assets/{index-BFIwa8W4.js → index-e7eEqZQD.js} +2 -2
  85. package/dist/client/assets/{index-BgSyGi69.js → index-hiuu-64i.js} +1 -1
  86. package/dist/client/assets/{infiniteQueryObserver-NmUU_rOy.js → infiniteQueryObserver-CHiY1NnZ.js} +1 -1
  87. package/dist/client/assets/{input-C66FZPPf.js → input-B8x8lV8_.js} +1 -1
  88. package/dist/client/assets/{integration-icon-fPkSifk0.js → integration-icon-Bfmqyrf_.js} +1 -1
  89. package/dist/client/assets/{label-BMe1SNEP.js → label-BU7N79Fq.js} +1 -1
  90. package/dist/client/assets/{layout-DbOAzt16.js → layout-Dnq67rSm.js} +1 -1
  91. package/dist/client/assets/{lean-canvas-recruit-modal-BP1iZHjy.js → lean-canvas-recruit-modal-C70LSjWJ.js} +1 -1
  92. package/dist/client/assets/{login-CRXuvxd9.js → login-_Q9L7mst.js} +1 -1
  93. package/dist/client/assets/{members-BwleeoVp.js → members-D-VFZlys.js} +1 -1
  94. package/dist/client/assets/{monaco-editor-C457mqYB.js → monaco-editor-BXyi5viY.js} +1 -1
  95. package/dist/client/assets/{monitoring-stats-row-DKl9Ubde.js → monitoring-stats-row-CEoUxcHm.js} +1 -1
  96. package/dist/client/assets/{oauth-callback-1dC9VVpc.js → oauth-callback-B5dtt4y6.js} +1 -1
  97. package/dist/client/assets/{oauth-callback-ai-provider-BGY5Uat_.js → oauth-callback-ai-provider-Cc_nFPdq.js} +1 -1
  98. package/dist/client/assets/{onboarding-C1bM-up9.js → onboarding-uWZePAti.js} +1 -1
  99. package/dist/client/assets/{org-layout-Cll4mSr3.js → org-layout-BK5cWTcx.js} +1 -1
  100. package/dist/client/assets/{org-plugin-layout-qjkMXyOy.js → org-plugin-layout-C0ezKAgt.js} +1 -1
  101. package/dist/client/assets/{pair-Bl_sqsCX.js → pair-BTwp6bTc.js} +1 -1
  102. package/dist/client/assets/{plugin-empty-state-DCQUcDfK.js → plugin-empty-state-CjfGiA5F.js} +1 -1
  103. package/dist/client/assets/{plugin-header-Deqthnjp.js → plugin-header-D9DU3BMG.js} +1 -1
  104. package/dist/client/assets/{plugin-layout-m0OkUjnq.js → plugin-layout-DSjok7-L.js} +1 -1
  105. package/dist/client/assets/{popover-DIqVWKAH.js → popover-3D5jsJh1.js} +1 -1
  106. package/dist/client/assets/{profile-Ck6jHCNy.js → profile-BdmoV93F.js} +1 -1
  107. package/dist/client/assets/{project-app-view-D--E6naM.js → project-app-view-CmNwDiw0.js} +1 -1
  108. package/dist/client/assets/registry-C8zMtgwr.js +2 -0
  109. package/dist/client/assets/{registry-layout-BaLlt8iJ.js → registry-layout-xyKYdVRG.js} +1 -1
  110. package/dist/client/assets/{required-auth-layout-4lbvRXP9.js → required-auth-layout-W0nsPTz2.js} +1 -1
  111. package/dist/client/assets/{reset-password-E281j__o.js → reset-password-BVEdYLL2.js} +1 -1
  112. package/dist/client/assets/{roles-CG_umLTJ.js → roles-CtNr9Xv_.js} +1 -1
  113. package/dist/client/assets/{scroll-area-Dpf0WEDP.js → scroll-area-D71z0--k.js} +1 -1
  114. package/dist/client/assets/{search-input-BcoDzgCL.js → search-input-C1sIJN1c.js} +1 -1
  115. package/dist/client/assets/{select-CsQfJ0qv.js → select-mWz1b_ZH.js} +1 -1
  116. package/dist/client/assets/{select-model-Vwe69qWq.js → select-model-tmulvVLX.js} +1 -1
  117. package/dist/client/assets/{settings-layout-Cw1Oq9lP.js → settings-layout-BqXIUoEI.js} +1 -1
  118. package/dist/client/assets/{settings-section-Bcn_yZSc.js → settings-section-OvOVUTcw.js} +1 -1
  119. package/dist/client/assets/{shell-layout-BQPFdNnv.js → shell-layout-5NI7-V2p.js} +1 -1
  120. package/dist/client/assets/{skeleton-DFE9g6JF.js → skeleton-Bq5_S0j2.js} +1 -1
  121. package/dist/client/assets/{sso-DFJ1V_Eq.js → sso-CbTsdhS9.js} +1 -1
  122. package/dist/client/assets/{store-BupAo568.js → store-Dfk_RNXS.js} +1 -1
  123. package/dist/client/assets/store-registry-Cc1z30ih.js +2 -0
  124. package/dist/client/assets/{switch-B9pehtZv.js → switch-KcpCgqTm.js} +1 -1
  125. package/dist/client/assets/{table-CvhbCrhO.js → table-Dcu4orQb.js} +1 -1
  126. package/dist/client/assets/{tabs-Dxl_bMcE.js → tabs-yr1sdiKv.js} +1 -1
  127. package/dist/client/assets/{task-status-BWs0NSVc.js → task-status-feSWSO3m.js} +1 -1
  128. package/dist/client/assets/{textarea-DH2INXqG.js → textarea-B5KVzuoV.js} +1 -1
  129. package/dist/client/assets/{toggle-group-BKADQha7.js → toggle-group-DhgFoVFU.js} +1 -1
  130. package/dist/client/assets/{tools-list-CVKmigbN.js → tools-list-B0Yp2GUj.js} +1 -1
  131. package/dist/client/assets/{tooltip-CzkIRbGJ.js → tooltip-BPT840gf.js} +1 -1
  132. package/dist/client/assets/{types-CiOXD-c9.js → types-9jOTGnHq.js} +1 -1
  133. package/dist/client/assets/{use-ai-providers-BSpy6MGb.js → use-ai-providers-D69mlQI8.js} +1 -1
  134. package/dist/client/assets/{use-collections-BgNhuD43.js → use-collections-DwvEVl8v.js} +1 -1
  135. package/dist/client/assets/{use-connection-BypaB8s_.js → use-connection-JJHjF6rv.js} +1 -1
  136. package/dist/client/assets/{use-copy-DUQETT2i.js → use-copy-C9_Hg3HJ.js} +1 -1
  137. package/dist/client/assets/{use-create-virtual-mcp-Cr6RxP_0.js → use-create-virtual-mcp-D-lXC80m.js} +1 -1
  138. package/dist/client/assets/{use-debounced-autosave-DO41C7Df.js → use-debounced-autosave-DFbpcKm7.js} +1 -1
  139. package/dist/client/assets/{use-decopilot-events-Bd5bEjkf.js → use-decopilot-events-BcK-yZDw.js} +1 -1
  140. package/dist/client/assets/{use-delete-connection-v1LXlIsA.js → use-delete-connection-CPz0jmtA.js} +1 -1
  141. package/dist/client/assets/{use-infinite-scroll-QOTO_hJO.js → use-infinite-scroll-B1xILXLP.js} +1 -1
  142. package/dist/client/assets/{use-list-state-C_A7sIoE.js → use-list-state-BZRsAUdo.js} +1 -1
  143. package/dist/client/assets/{use-mcp-tools-Dneo9PV9.js → use-mcp-tools-D73stCOo.js} +1 -1
  144. package/dist/client/assets/{use-members-ClknS2e8.js → use-members-DsN3ITf2.js} +1 -1
  145. package/dist/client/assets/{use-navigate-to-agent-jsYNoTy7.js → use-navigate-to-agent-CJDDIver.js} +1 -1
  146. package/dist/client/assets/{use-org-auth-client-piAjQuqe.js → use-org-auth-client-Bq9q7Hza.js} +1 -1
  147. package/dist/client/assets/{use-org-sso-BbOiG5xt.js → use-org-sso-D22xZlY0.js} +1 -1
  148. package/dist/client/assets/{use-organization-roles-DRnvDp6V.js → use-organization-roles-Q3jXj8C7.js} +1 -1
  149. package/dist/client/assets/{use-organization-settings-Cl63rukI.js → use-organization-settings-DC8b5MPT.js} +1 -1
  150. package/dist/client/assets/{use-registry-connections-nKQr071c.js → use-registry-connections-XqvUTmE5.js} +1 -1
  151. package/dist/client/assets/{use-status-sounds-DNBT8d2Q.js → use-status-sounds-CCFuBFY0.js} +1 -1
  152. package/dist/client/assets/{use-tasks-D6w8iRzc.js → use-tasks-Btt8g-fe.js} +1 -1
  153. package/dist/client/assets/{use-view-mode-EFwbm8pp.js → use-view-mode-BvotgnsQ.js} +1 -1
  154. package/dist/client/assets/{use-virtual-mcp-BW1ujP1y.js → use-virtual-mcp-BgZ2h4E7.js} +1 -1
  155. package/dist/client/assets/useInfiniteQuery-DxaE8j48.js +1 -0
  156. package/dist/client/assets/useSuspenseInfiniteQuery-CgPS4Lvz.js +1 -0
  157. package/dist/client/assets/{user-B9J8wn-0.js → user-C-74yDDj.js} +1 -1
  158. package/dist/client/assets/{view-mode-toggle-P1fMVeBh.js → view-mode-toggle-BX0KOixc.js} +1 -1
  159. package/dist/client/assets/{workflow-Bk-2rBg-.js → workflow-D8djL2VH.js} +1 -1
  160. package/dist/client/assets/workflow-detail-eNmJkRLG.js +1 -0
  161. package/dist/client/index.html +1 -1
  162. package/dist/server/cli.js +2 -2
  163. package/dist/server/node_modules/get-east-asian-width/index.d.ts +60 -0
  164. package/dist/server/node_modules/get-east-asian-width/index.js +30 -0
  165. package/dist/server/node_modules/get-east-asian-width/lookup-data.js +18 -0
  166. package/dist/server/node_modules/get-east-asian-width/lookup.js +135 -0
  167. package/dist/server/node_modules/get-east-asian-width/package.json +71 -0
  168. package/dist/server/node_modules/get-east-asian-width/readme.md +65 -0
  169. package/dist/server/node_modules/get-east-asian-width/utilities.js +24 -0
  170. package/dist/server/node_modules/ink/build/ansi-tokenizer.d.ts +38 -0
  171. package/dist/server/node_modules/ink/build/ansi-tokenizer.js +316 -0
  172. package/dist/server/node_modules/ink/build/ansi-tokenizer.js.map +1 -0
  173. package/dist/server/node_modules/ink/build/apply-styles.js +175 -0
  174. package/dist/server/node_modules/ink/build/build-layout.js +77 -0
  175. package/dist/server/node_modules/ink/build/calculate-wrapped-text.js +53 -0
  176. package/dist/server/node_modules/ink/build/colorize.d.ts +3 -0
  177. package/dist/server/node_modules/ink/build/colorize.js +48 -0
  178. package/dist/server/node_modules/ink/build/colorize.js.map +1 -0
  179. package/dist/server/node_modules/ink/build/components/AccessibilityContext.d.ts +3 -0
  180. package/dist/server/node_modules/ink/build/components/AccessibilityContext.js +5 -0
  181. package/dist/server/node_modules/ink/build/components/AccessibilityContext.js.map +1 -0
  182. package/dist/server/node_modules/ink/build/components/App.d.ts +18 -0
  183. package/dist/server/node_modules/ink/build/components/App.js +351 -0
  184. package/dist/server/node_modules/ink/build/components/App.js.map +1 -0
  185. package/dist/server/node_modules/ink/build/components/AppContext.d.ts +15 -0
  186. package/dist/server/node_modules/ink/build/components/AppContext.js +11 -0
  187. package/dist/server/node_modules/ink/build/components/AppContext.js.map +1 -0
  188. package/dist/server/node_modules/ink/build/components/BackgroundContext.d.ts +4 -0
  189. package/dist/server/node_modules/ink/build/components/BackgroundContext.js +3 -0
  190. package/dist/server/node_modules/ink/build/components/BackgroundContext.js.map +1 -0
  191. package/dist/server/node_modules/ink/build/components/Box.d.ts +117 -0
  192. package/dist/server/node_modules/ink/build/components/Box.js +34 -0
  193. package/dist/server/node_modules/ink/build/components/Box.js.map +1 -0
  194. package/dist/server/node_modules/ink/build/components/Color.js +62 -0
  195. package/dist/server/node_modules/ink/build/components/Cursor.d.ts +83 -0
  196. package/dist/server/node_modules/ink/build/components/Cursor.js +53 -0
  197. package/dist/server/node_modules/ink/build/components/Cursor.js.map +1 -0
  198. package/dist/server/node_modules/ink/build/components/CursorContext.d.ts +11 -0
  199. package/dist/server/node_modules/ink/build/components/CursorContext.js +8 -0
  200. package/dist/server/node_modules/ink/build/components/CursorContext.js.map +1 -0
  201. package/dist/server/node_modules/ink/build/components/ErrorBoundary.d.ts +18 -0
  202. package/dist/server/node_modules/ink/build/components/ErrorBoundary.js +23 -0
  203. package/dist/server/node_modules/ink/build/components/ErrorBoundary.js.map +1 -0
  204. package/dist/server/node_modules/ink/build/components/ErrorOverview.d.ts +6 -0
  205. package/dist/server/node_modules/ink/build/components/ErrorOverview.js +84 -0
  206. package/dist/server/node_modules/ink/build/components/ErrorOverview.js.map +1 -0
  207. package/dist/server/node_modules/ink/build/components/FocusContext.d.ts +16 -0
  208. package/dist/server/node_modules/ink/build/components/FocusContext.js +17 -0
  209. package/dist/server/node_modules/ink/build/components/FocusContext.js.map +1 -0
  210. package/dist/server/node_modules/ink/build/components/Newline.d.ts +13 -0
  211. package/dist/server/node_modules/ink/build/components/Newline.js +8 -0
  212. package/dist/server/node_modules/ink/build/components/Newline.js.map +1 -0
  213. package/dist/server/node_modules/ink/build/components/Spacer.d.ts +7 -0
  214. package/dist/server/node_modules/ink/build/components/Spacer.js +11 -0
  215. package/dist/server/node_modules/ink/build/components/Spacer.js.map +1 -0
  216. package/dist/server/node_modules/ink/build/components/Static.d.ts +24 -0
  217. package/dist/server/node_modules/ink/build/components/Static.js +28 -0
  218. package/dist/server/node_modules/ink/build/components/Static.js.map +1 -0
  219. package/dist/server/node_modules/ink/build/components/StderrContext.d.ts +15 -0
  220. package/dist/server/node_modules/ink/build/components/StderrContext.js +13 -0
  221. package/dist/server/node_modules/ink/build/components/StderrContext.js.map +1 -0
  222. package/dist/server/node_modules/ink/build/components/StdinContext.d.ts +22 -0
  223. package/dist/server/node_modules/ink/build/components/StdinContext.js +19 -0
  224. package/dist/server/node_modules/ink/build/components/StdinContext.js.map +1 -0
  225. package/dist/server/node_modules/ink/build/components/StdoutContext.d.ts +15 -0
  226. package/dist/server/node_modules/ink/build/components/StdoutContext.js +13 -0
  227. package/dist/server/node_modules/ink/build/components/StdoutContext.js.map +1 -0
  228. package/dist/server/node_modules/ink/build/components/Text.d.ts +55 -0
  229. package/dist/server/node_modules/ink/build/components/Text.js +50 -0
  230. package/dist/server/node_modules/ink/build/components/Text.js.map +1 -0
  231. package/dist/server/node_modules/ink/build/components/Transform.d.ts +16 -0
  232. package/dist/server/node_modules/ink/build/components/Transform.js +15 -0
  233. package/dist/server/node_modules/ink/build/components/Transform.js.map +1 -0
  234. package/dist/server/node_modules/ink/build/cursor-helpers.d.ts +38 -0
  235. package/dist/server/node_modules/ink/build/cursor-helpers.js +56 -0
  236. package/dist/server/node_modules/ink/build/cursor-helpers.js.map +1 -0
  237. package/dist/server/node_modules/ink/build/devtools-window-polyfill.d.ts +1 -0
  238. package/dist/server/node_modules/ink/build/devtools-window-polyfill.js +65 -0
  239. package/dist/server/node_modules/ink/build/devtools-window-polyfill.js.map +1 -0
  240. package/dist/server/node_modules/ink/build/devtools.d.ts +1 -0
  241. package/dist/server/node_modules/ink/build/devtools.js +11 -0
  242. package/dist/server/node_modules/ink/build/devtools.js.map +1 -0
  243. package/dist/server/node_modules/ink/build/dom.d.ts +56 -0
  244. package/dist/server/node_modules/ink/build/dom.js +124 -0
  245. package/dist/server/node_modules/ink/build/dom.js.map +1 -0
  246. package/dist/server/node_modules/ink/build/experimental/apply-style.js +140 -0
  247. package/dist/server/node_modules/ink/build/experimental/dom.js +123 -0
  248. package/dist/server/node_modules/ink/build/experimental/output.js +91 -0
  249. package/dist/server/node_modules/ink/build/experimental/reconciler.js +141 -0
  250. package/dist/server/node_modules/ink/build/experimental/renderer.js +81 -0
  251. package/dist/server/node_modules/ink/build/get-max-width.d.ts +3 -0
  252. package/dist/server/node_modules/ink/build/get-max-width.js +10 -0
  253. package/dist/server/node_modules/ink/build/get-max-width.js.map +1 -0
  254. package/dist/server/node_modules/ink/build/hooks/use-app.d.ts +5 -0
  255. package/dist/server/node_modules/ink/build/hooks/use-app.js +8 -0
  256. package/dist/server/node_modules/ink/build/hooks/use-app.js.map +1 -0
  257. package/dist/server/node_modules/ink/build/hooks/use-cursor.d.ts +12 -0
  258. package/dist/server/node_modules/ink/build/hooks/use-cursor.js +29 -0
  259. package/dist/server/node_modules/ink/build/hooks/use-cursor.js.map +1 -0
  260. package/dist/server/node_modules/ink/build/hooks/use-focus-manager.d.ts +28 -0
  261. package/dist/server/node_modules/ink/build/hooks/use-focus-manager.js +17 -0
  262. package/dist/server/node_modules/ink/build/hooks/use-focus-manager.js.map +1 -0
  263. package/dist/server/node_modules/ink/build/hooks/use-focus.d.ts +29 -0
  264. package/dist/server/node_modules/ink/build/hooks/use-focus.js +42 -0
  265. package/dist/server/node_modules/ink/build/hooks/use-focus.js.map +1 -0
  266. package/dist/server/node_modules/ink/build/hooks/use-input.d.ts +131 -0
  267. package/dist/server/node_modules/ink/build/hooks/use-input.js +124 -0
  268. package/dist/server/node_modules/ink/build/hooks/use-input.js.map +1 -0
  269. package/dist/server/node_modules/ink/build/hooks/use-is-screen-reader-enabled.d.ts +5 -0
  270. package/dist/server/node_modules/ink/build/hooks/use-is-screen-reader-enabled.js +11 -0
  271. package/dist/server/node_modules/ink/build/hooks/use-is-screen-reader-enabled.js.map +1 -0
  272. package/dist/server/node_modules/ink/build/hooks/use-stderr.d.ts +5 -0
  273. package/dist/server/node_modules/ink/build/hooks/use-stderr.js +8 -0
  274. package/dist/server/node_modules/ink/build/hooks/use-stderr.js.map +1 -0
  275. package/dist/server/node_modules/ink/build/hooks/use-stdin.d.ts +5 -0
  276. package/dist/server/node_modules/ink/build/hooks/use-stdin.js +8 -0
  277. package/dist/server/node_modules/ink/build/hooks/use-stdin.js.map +1 -0
  278. package/dist/server/node_modules/ink/build/hooks/use-stdout.d.ts +5 -0
  279. package/dist/server/node_modules/ink/build/hooks/use-stdout.js +8 -0
  280. package/dist/server/node_modules/ink/build/hooks/use-stdout.js.map +1 -0
  281. package/dist/server/node_modules/ink/build/hooks/useInput.js +38 -0
  282. package/dist/server/node_modules/ink/build/index.d.ts +34 -0
  283. package/dist/server/node_modules/ink/build/index.js +20 -0
  284. package/dist/server/node_modules/ink/build/index.js.map +1 -0
  285. package/dist/server/node_modules/ink/build/ink.d.ts +90 -0
  286. package/dist/server/node_modules/ink/build/ink.js +637 -0
  287. package/dist/server/node_modules/ink/build/ink.js.map +1 -0
  288. package/dist/server/node_modules/ink/build/input-parser.d.ts +7 -0
  289. package/dist/server/node_modules/ink/build/input-parser.js +154 -0
  290. package/dist/server/node_modules/ink/build/input-parser.js.map +1 -0
  291. package/dist/server/node_modules/ink/build/instance.js +205 -0
  292. package/dist/server/node_modules/ink/build/instances.d.ts +3 -0
  293. package/dist/server/node_modules/ink/build/instances.js +8 -0
  294. package/dist/server/node_modules/ink/build/instances.js.map +1 -0
  295. package/dist/server/node_modules/ink/build/kitty-keyboard.d.ts +23 -0
  296. package/dist/server/node_modules/ink/build/kitty-keyboard.js +32 -0
  297. package/dist/server/node_modules/ink/build/kitty-keyboard.js.map +1 -0
  298. package/dist/server/node_modules/ink/build/layout.d.ts +7 -0
  299. package/dist/server/node_modules/ink/build/layout.js +33 -0
  300. package/dist/server/node_modules/ink/build/layout.js.map +1 -0
  301. package/dist/server/node_modules/ink/build/log-update.d.ts +19 -0
  302. package/dist/server/node_modules/ink/build/log-update.js +242 -0
  303. package/dist/server/node_modules/ink/build/log-update.js.map +1 -0
  304. package/dist/server/node_modules/ink/build/measure-element.d.ts +16 -0
  305. package/dist/server/node_modules/ink/build/measure-element.js +9 -0
  306. package/dist/server/node_modules/ink/build/measure-element.js.map +1 -0
  307. package/dist/server/node_modules/ink/build/measure-text.d.ts +6 -0
  308. package/dist/server/node_modules/ink/build/measure-text.js +21 -0
  309. package/dist/server/node_modules/ink/build/measure-text.js.map +1 -0
  310. package/dist/server/node_modules/ink/build/options.d.ts +52 -0
  311. package/dist/server/node_modules/ink/build/options.js +2 -0
  312. package/dist/server/node_modules/ink/build/options.js.map +1 -0
  313. package/dist/server/node_modules/ink/build/output.d.ts +35 -0
  314. package/dist/server/node_modules/ink/build/output.js +183 -0
  315. package/dist/server/node_modules/ink/build/output.js.map +1 -0
  316. package/dist/server/node_modules/ink/build/parse-keypress.d.ts +22 -0
  317. package/dist/server/node_modules/ink/build/parse-keypress.js +493 -0
  318. package/dist/server/node_modules/ink/build/parse-keypress.js.map +1 -0
  319. package/dist/server/node_modules/ink/build/reconciler.d.ts +4 -0
  320. package/dist/server/node_modules/ink/build/reconciler.js +274 -0
  321. package/dist/server/node_modules/ink/build/reconciler.js.map +1 -0
  322. package/dist/server/node_modules/ink/build/render-background.d.ts +4 -0
  323. package/dist/server/node_modules/ink/build/render-background.js +25 -0
  324. package/dist/server/node_modules/ink/build/render-background.js.map +1 -0
  325. package/dist/server/node_modules/ink/build/render-border.d.ts +4 -0
  326. package/dist/server/node_modules/ink/build/render-border.js +73 -0
  327. package/dist/server/node_modules/ink/build/render-border.js.map +1 -0
  328. package/dist/server/node_modules/ink/build/render-node-to-output.d.ts +14 -0
  329. package/dist/server/node_modules/ink/build/render-node-to-output.js +147 -0
  330. package/dist/server/node_modules/ink/build/render-node-to-output.js.map +1 -0
  331. package/dist/server/node_modules/ink/build/render-to-string.d.ts +38 -0
  332. package/dist/server/node_modules/ink/build/render-to-string.js +115 -0
  333. package/dist/server/node_modules/ink/build/render-to-string.js.map +1 -0
  334. package/dist/server/node_modules/ink/build/render.d.ts +121 -0
  335. package/dist/server/node_modules/ink/build/render.js +55 -0
  336. package/dist/server/node_modules/ink/build/render.js.map +1 -0
  337. package/dist/server/node_modules/ink/build/renderer.d.ts +8 -0
  338. package/dist/server/node_modules/ink/build/renderer.js +55 -0
  339. package/dist/server/node_modules/ink/build/renderer.js.map +1 -0
  340. package/dist/server/node_modules/ink/build/sanitize-ansi.d.ts +2 -0
  341. package/dist/server/node_modules/ink/build/sanitize-ansi.js +27 -0
  342. package/dist/server/node_modules/ink/build/sanitize-ansi.js.map +1 -0
  343. package/dist/server/node_modules/ink/build/screen-reader-update.d.ts +13 -0
  344. package/dist/server/node_modules/ink/build/screen-reader-update.js +38 -0
  345. package/dist/server/node_modules/ink/build/screen-reader-update.js.map +1 -0
  346. package/dist/server/node_modules/ink/build/squash-text-nodes.d.ts +3 -0
  347. package/dist/server/node_modules/ink/build/squash-text-nodes.js +36 -0
  348. package/dist/server/node_modules/ink/build/squash-text-nodes.js.map +1 -0
  349. package/dist/server/node_modules/ink/build/styles.d.ts +240 -0
  350. package/dist/server/node_modules/ink/build/styles.js +232 -0
  351. package/dist/server/node_modules/ink/build/styles.js.map +1 -0
  352. package/dist/server/node_modules/ink/build/utils.d.ts +2 -0
  353. package/dist/server/node_modules/ink/build/utils.js +4 -0
  354. package/dist/server/node_modules/ink/build/utils.js.map +1 -0
  355. package/dist/server/node_modules/ink/build/wrap-text.d.ts +3 -0
  356. package/dist/server/node_modules/ink/build/wrap-text.js +31 -0
  357. package/dist/server/node_modules/ink/build/wrap-text.js.map +1 -0
  358. package/dist/server/node_modules/ink/build/write-synchronized.d.ts +4 -0
  359. package/dist/server/node_modules/ink/build/write-synchronized.js +7 -0
  360. package/dist/server/node_modules/ink/build/write-synchronized.js.map +1 -0
  361. package/dist/server/node_modules/{figures → ink}/license +1 -0
  362. package/dist/server/node_modules/ink/package.json +201 -0
  363. package/dist/server/node_modules/ink/readme.md +2636 -0
  364. package/dist/server/node_modules/slice-ansi/index.d.ts +19 -0
  365. package/dist/server/node_modules/slice-ansi/index.js +260 -0
  366. package/dist/server/node_modules/{widest-line → slice-ansi}/license +1 -0
  367. package/dist/server/node_modules/slice-ansi/package.json +59 -0
  368. package/dist/server/node_modules/slice-ansi/readme.md +54 -0
  369. package/dist/server/node_modules/slice-ansi/tokenize-ansi.js +752 -0
  370. package/dist/server/server.js +1 -1
  371. package/package.json +1 -1
  372. package/dist/client/assets/ai-providers-C-HLT43p.js +0 -1
  373. package/dist/client/assets/index-BlefTMU9.js +0 -1
  374. package/dist/client/assets/registry-DSbGbl6G.js +0 -2
  375. package/dist/client/assets/store-registry-CHPlZpA7.js +0 -2
  376. package/dist/client/assets/useInfiniteQuery-B0aJ536b.js +0 -1
  377. package/dist/client/assets/useSuspenseInfiniteQuery-DMQVbZ7w.js +0 -1
  378. package/dist/client/assets/workflow-detail-cax1DGc8.js +0 -1
  379. package/dist/server/node_modules/cli-truncate/index.d.ts +0 -118
  380. package/dist/server/node_modules/cli-truncate/index.js +0 -168
  381. package/dist/server/node_modules/cli-truncate/package.json +0 -52
  382. package/dist/server/node_modules/cli-truncate/readme.md +0 -154
  383. package/dist/server/node_modules/deepmerge/.editorconfig +0 -7
  384. package/dist/server/node_modules/deepmerge/.eslintcache +0 -1
  385. package/dist/server/node_modules/deepmerge/changelog.md +0 -167
  386. package/dist/server/node_modules/deepmerge/dist/cjs.js +0 -133
  387. package/dist/server/node_modules/deepmerge/dist/umd.js +0 -139
  388. package/dist/server/node_modules/deepmerge/index.d.ts +0 -20
  389. package/dist/server/node_modules/deepmerge/index.js +0 -106
  390. package/dist/server/node_modules/deepmerge/license.txt +0 -21
  391. package/dist/server/node_modules/deepmerge/package.json +0 -42
  392. package/dist/server/node_modules/deepmerge/readme.md +0 -264
  393. package/dist/server/node_modules/deepmerge/rollup.config.js +0 -22
  394. package/dist/server/node_modules/figures/index.d.ts +0 -279
  395. package/dist/server/node_modules/figures/index.js +0 -292
  396. package/dist/server/node_modules/figures/package.json +0 -49
  397. package/dist/server/node_modules/figures/readme.md +0 -337
  398. package/dist/server/node_modules/mimic-fn/index.d.ts +0 -54
  399. package/dist/server/node_modules/mimic-fn/index.js +0 -13
  400. package/dist/server/node_modules/mimic-fn/license +0 -9
  401. package/dist/server/node_modules/mimic-fn/package.json +0 -42
  402. package/dist/server/node_modules/mimic-fn/readme.md +0 -69
  403. package/dist/server/node_modules/pg-int8/LICENSE +0 -13
  404. package/dist/server/node_modules/pg-int8/README.md +0 -16
  405. package/dist/server/node_modules/pg-int8/index.js +0 -100
  406. package/dist/server/node_modules/pg-int8/package.json +0 -24
  407. package/dist/server/node_modules/postgres-array/index.d.ts +0 -4
  408. package/dist/server/node_modules/postgres-array/index.js +0 -97
  409. package/dist/server/node_modules/postgres-array/license +0 -21
  410. package/dist/server/node_modules/postgres-array/package.json +0 -35
  411. package/dist/server/node_modules/postgres-array/readme.md +0 -43
  412. package/dist/server/node_modules/postgres-bytea/index.js +0 -33
  413. package/dist/server/node_modules/postgres-bytea/license +0 -21
  414. package/dist/server/node_modules/postgres-bytea/package.json +0 -34
  415. package/dist/server/node_modules/postgres-bytea/readme.md +0 -34
  416. package/dist/server/node_modules/postgres-date/index.js +0 -116
  417. package/dist/server/node_modules/postgres-date/license +0 -21
  418. package/dist/server/node_modules/postgres-date/package.json +0 -33
  419. package/dist/server/node_modules/postgres-date/readme.md +0 -49
  420. package/dist/server/node_modules/postgres-interval/index.d.ts +0 -20
  421. package/dist/server/node_modules/postgres-interval/index.js +0 -125
  422. package/dist/server/node_modules/postgres-interval/license +0 -21
  423. package/dist/server/node_modules/postgres-interval/package.json +0 -36
  424. package/dist/server/node_modules/postgres-interval/readme.md +0 -48
  425. package/dist/server/node_modules/split2/LICENSE +0 -13
  426. package/dist/server/node_modules/split2/README.md +0 -85
  427. package/dist/server/node_modules/split2/bench.js +0 -27
  428. package/dist/server/node_modules/split2/index.js +0 -141
  429. package/dist/server/node_modules/split2/package.json +0 -39
  430. package/dist/server/node_modules/split2/test.js +0 -409
  431. package/dist/server/node_modules/widest-line/index.d.ts +0 -12
  432. package/dist/server/node_modules/widest-line/index.js +0 -11
  433. package/dist/server/node_modules/widest-line/package.json +0 -60
  434. package/dist/server/node_modules/widest-line/readme.md +0 -26
  435. package/dist/server/node_modules/xtend/.jshintrc +0 -30
  436. package/dist/server/node_modules/xtend/LICENSE +0 -20
  437. package/dist/server/node_modules/xtend/README.md +0 -32
  438. package/dist/server/node_modules/xtend/immutable.js +0 -19
  439. package/dist/server/node_modules/xtend/mutable.js +0 -17
  440. package/dist/server/node_modules/xtend/package.json +0 -55
  441. package/dist/server/node_modules/xtend/test.js +0 -103
  442. /package/dist/server/node_modules/{cli-truncate → get-east-asian-width}/license +0 -0
@@ -1,5 +1,5 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/project-app-view-D--E6naM.js","assets/index-BFIwa8W4.js","assets/index-CpHJcJk3.css","assets/pair-Bl_sqsCX.js","assets/agent-icon-GBX3RKid.js","assets/AlertCircle-DfpOj9uk.js","assets/Tool01-CIMPkAjR.js","assets/XClose-BnCJyyB-.js","assets/RefreshCcw01-DDZo1WKt.js","assets/ArrowNarrowLeft-CGsSFJZH.js","assets/XCircle-CTrtJtfR.js","assets/ArrowUpRight-DtiNC8xj.js","assets/ZapSquare-DhbSIk6a.js","assets/Users03-CItFKGX1.js","assets/CheckCircle-DenvulPR.js","assets/Check-DXPBjwC9.js","assets/ChevronDown-BzUdsdeu.js","assets/ChevronRight-8RBDSI4c.js","assets/ChevronUp-CkOPdM7g.js","assets/DotsVertical-CCxgBVsk.js","assets/Container-B2b9FJMR.js","assets/Star01-BM8AlGEC.js","assets/Palette-qMNBtXtx.js","assets/SearchMd-BvQQOrkm.js","assets/index-CE54Jnz-.js","assets/tooltip-CzkIRbGJ.js","assets/X-CGShNfee.js","assets/LinkExternal01-C_eUHFUm.js","assets/Lock01-SmEMRGOb.js","assets/Sun-B2OKfrtR.js","assets/Play-DmVY8R1A.js","assets/Plus-B19lTgl_.js","assets/Settings02-CYadYmOF.js","assets/Shield01-GS3q0eea.js","assets/Trash01-4PBXkXRo.js","assets/User01-nh8Rby1P.js","assets/Zap-D7WiwjAV.js","assets/index-C39RwBnQ.js","assets/use-copy-DUQETT2i.js","assets/differenceInSeconds-NQ4PDo0z.js","assets/dialog-BZytMGON.js","assets/content-blocks-o63cs2vh.js","assets/types-CiOXD-c9.js","assets/constants-CnfWGYKH.js","assets/chat-context-BnJMVusJ.js","assets/use-virtual-mcp-BW1ujP1y.js","assets/use-collections-BgNhuD43.js","assets/use-ai-providers-BSpy6MGb.js","assets/use-decopilot-events-Bd5bEjkf.js","assets/create-sse-subscription-CxkOgzKf.js","assets/use-tasks-D6w8iRzc.js","assets/use-organization-settings-Cl63rukI.js","assets/shell-layout-BQPFdNnv.js","assets/required-auth-layout-4lbvRXP9.js","assets/use-org-sso-BbOiG5xt.js","assets/integration-icon-fPkSifk0.js","assets/use-mcp-tools-Dneo9PV9.js"])))=>i.map(i=>d[i]);
2
- import{o as ms,r as P,p as $l,q as Fl,e as W,s as xe,K as $s,n as Jo,a as Zo,c as ie,j as o,l as Ae,B as ne,E as Ut,b as Ti,v as di,f as Lt,d as nn,w as Hl,x as ge,y as Wl,V as Ul,t as we,z as Qo,C as Vl,D as Ht,F as Kl,G as Nn,L as ql,H as Ui,I as ii,J as ut,M as ea,P as Gl,_ as Yl,Q as ta,R as sa,T as Xl,g as Jl}from"./index-BFIwa8W4.js";import{C as Ee,u as Zl,w as Ql,A as ec,T as tc,a as sc,S as ic}from"./index-BgSyGi69.js";import{I as _s}from"./integration-icon-fPkSifk0.js";import{S as Ot,u as We,g as ia,a as ra}from"./constants-CnfWGYKH.js";import{u as Nt,a as rc}from"./use-virtual-mcp-BW1ujP1y.js";import{a as nc}from"./Users03-CItFKGX1.js";import{u as na,a as bt,b as Ri,c as ps,t as oc,d as jn}from"./chat-context-BnJMVusJ.js";import{i as Fs}from"./AlertCircle-DfpOj9uk.js";import{i as ac}from"./CheckCircle-DenvulPR.js";import{n as En,a as lc}from"./ZapSquare-DhbSIk6a.js";import{i as cc,a as hc,b as dc,c as Di,d as uc}from"./XCircle-CTrtJtfR.js";import{s as ds,i as fc}from"./XClose-BnCJyyB-.js";import{c as mc,r as _c,p as oa,f as Tn,a as pc,F as gc,t as Rn,M as on,G as aa,L as vc,i as xc,b as bc,d as Sc,e as yc}from"./pair-Bl_sqsCX.js";import{C as wc,a as Dn,b as Mn,c as Cc,d as kc,e as Nc,f as jc}from"./command-DK-j4arJ.js";import{P as Gs,a as Ys,b as Xs}from"./popover-DIqVWKAH.js";import{i as Bs,a as Si,b as Ec,c as Tc,p as Mi,g as Ii,d as an,e as la,h as pr,f as Vi,j as In,A as An,k as ca,l as Rc,m as Dc,n as Mc,t as Ic,o as Ac,q as ui,r as ha,s as da,u as ua,v as Bn,w as Bc,x as Ps,y as Pc,z as Lc,B as fa}from"./agent-icon-GBX3RKid.js";import{u as gs,a as Oc}from"./use-mcp-tools-Dneo9PV9.js";import{u as zc,a as $c}from"./use-ai-providers-BSpy6MGb.js";import{g as Gt,c as Pn,u as Fc,b as gr,d as Hc,e as Wc,f as Uc,T as Vc}from"./index--ghksYAo.js";import{u as Ai,i as Kc}from"./shell-layout-BQPFdNnv.js";import{i as qc,P as ht,u as Gc,c as Yc,d as Xc,e as Jc}from"./index-CE54Jnz-.js";import{u as ma,T as Ge,a as Ye,b as Xe,c as Zc}from"./tooltip-CzkIRbGJ.js";import{u as Qc}from"./use-status-sounds-DNBT8d2Q.js";import{E as Hs}from"./empty-state-DuLPP0P_.js";import{A as eh,a as th,b as sh,c as ih,R as _a,d as rh,e as nh}from"./accordion-CgT_Vu18.js";import{u as Bi,a as ln,b as oh}from"./use-connection-BypaB8s_.js";import{g as ah}from"./constants-sHQufsXI.js";import{u as lh,g as ch}from"./types-CiOXD-c9.js";import{u as pa,G as hh}from"./lean-canvas-recruit-modal-BP1iZHjy.js";import{U as ga}from"./user-B9J8wn-0.js";import{T as dh,u as va}from"./tools-list-CVKmigbN.js";import{u as uh}from"./unwrap-tool-result-BYXdCQMg.js";import{s as xa,g as fh}from"./connection-slug-eyAPH6o3.js";import{A as ba,a as Sa,b as ya,c as wa,d as Ca,e as ka,f as Na,g as ja}from"./alert-dialog-CZ6BxFHK.js";import{D as mh,a as cn,b as hn,c as Ea,d as Ta}from"./dialog-BZytMGON.js";import{C as _h,a as Ln}from"./card-DdVfFEw2.js";import{I as vs}from"./input-C66FZPPf.js";import{L as Ls}from"./label-BMe1SNEP.js";import{S as rs,a as ns,b as os,c as as,d as Pt}from"./select-CsQfJ0qv.js";import{S as vr}from"./switch-B9pehtZv.js";import{T as On}from"./textarea-DH2INXqG.js";import{i as fi}from"./Play-DmVY8R1A.js";import{s as us}from"./Plus-B19lTgl_.js";import{a as ph}from"./Settings02-CYadYmOF.js";import{t as Ra,i as gh}from"./Tool01-CIMPkAjR.js";import{s as xr}from"./Trash01-4PBXkXRo.js";import{u as Da}from"./use-debounced-autosave-DO41C7Df.js";import{S as Ma}from"./scroll-area-Dpf0WEDP.js";import{i as Ia,a as vh}from"./SearchMd-BvQQOrkm.js";import{C as xh}from"./collection-tabs--b599n6J.js";import{C as bh}from"./checkbox-BJiR6nKO.js";import{u as Sh,T as Ki,a as yh,b as wh,c as qi}from"./tabs-Dxl_bMcE.js";import{D as Ch,a as kh,b as Nh}from"./drawer-D-6kJz55.js";import{i as Pi}from"./Check-DXPBjwC9.js";import{n as Yt}from"./LinkExternal01-C_eUHFUm.js";import{S as jh}from"./index-C39RwBnQ.js";import{D as ls,a as cs,b as hs,c as kt,d as Eh,e as Th,f as Rh}from"./dropdown-menu-BpdWPWdq.js";import{t as br}from"./ChevronDown-BzUdsdeu.js";import{i as Aa}from"./RefreshCcw01-DDZo1WKt.js";import{V as Dh}from"./view-mode-toggle-P1fMVeBh.js";import{M as Mh}from"./select-model-Vwe69qWq.js";import{u as Ih}from"./use-organization-settings-Cl63rukI.js";import{u as Js,a as Ah,b as Bh,c as Ph,A as Lh,d as Oh}from"./automation-list-row-DC7TfwMb.js";import{i as Ws}from"./Zap-D7WiwjAV.js";import{S as zh}from"./search-input-BcoDzgCL.js";import"./use-navigate-to-agent-jsYNoTy7.js";import"./use-tasks-D6w8iRzc.js";import"./use-collections-BgNhuD43.js";import"./collection-search-BBFkmets.js";import"./form-Bi1l8-LL.js";import"./Star01-BM8AlGEC.js";import"./Lock01-SmEMRGOb.js";import"./X-CGShNfee.js";import"./toggle-group-BKADQha7.js";import"./index-C03HvIgQ.js";import"./question-004-sINsf4GQ.js";import"./ai-providers-logos-DD3qZ33J.js";import"./connection-card--P5ycKzL.js";import"./use-registry-connections-nKQr071c.js";import"./useInfiniteQuery-B0aJ536b.js";import"./infiniteQueryObserver-NmUU_rOy.js";import"./extract-connection-data-Bj_pawjK.js";import"./Container-B2b9FJMR.js";import"./connection-form-helpers-BeJI6IBg.js";import"./use-infinite-scroll-QOTO_hJO.js";import"./useSuspenseInfiniteQuery-DMQVbZ7w.js";import"./badge-B32WzuEH.js";import"./ChevronRight-8RBDSI4c.js";import"./use-decopilot-events-Bd5bEjkf.js";import"./create-sse-subscription-CxkOgzKf.js";import"./use-copy-DUQETT2i.js";import"./differenceInSeconds-NQ4PDo0z.js";import"./content-blocks-o63cs2vh.js";import"./Sun-B2OKfrtR.js";import"./index-DSzBgSpo.js";import"./ArrowNarrowLeft-CGsSFJZH.js";import"./ArrowUpRight-DtiNC8xj.js";import"./ChevronUp-CkOPdM7g.js";import"./DotsVertical-CCxgBVsk.js";import"./Palette-qMNBtXtx.js";import"./Shield01-GS3q0eea.js";import"./User01-nh8Rby1P.js";import"./skeleton-DFE9g6JF.js";import"./avatar-BbisflHp.js";import"./index-CzZgNQPp.js";import"./collection-search-D62A0L7U.js";import"./use-create-virtual-mcp-Cr6RxP_0.js";import"./task-status-BWs0NSVc.js";import"./required-auth-layout-4lbvRXP9.js";import"./use-org-sso-BbOiG5xt.js";import"./collections-C5AWnYf0.js";import"./settings-section-Bcn_yZSc.js";import"./formatDistanceToNow-Cb2QZZJn.js";function $h(t,e){const s=ms(e);return Fh({filters:{...t,status:"pending"}},s).length}function zn(t,e){return t.findAll(e.filters).map(s=>e.select?e.select(s):s.state)}function Fh(t={},e){const s=ms(e).getMutationCache(),i=P.useRef(t),r=P.useRef(null);return r.current===null&&(r.current=zn(s,t)),P.useEffect(()=>{i.current=t}),P.useSyncExternalStore(P.useCallback(n=>s.subscribe(()=>{const a=$l(r.current,zn(s,i.current));r.current!==a&&(r.current=a,Fl.schedule(n))}),[s]),()=>r.current,()=>r.current)}function Hh(t,e){const s=W.c(40),{org:i,locator:r}=xe();let n;s[0]!==i.id||s[1]!==i.slug?(n={connectionId:Ot,orgId:i.id,orgSlug:i.slug},s[0]=i.id,s[1]=i.slug,s[2]=n):n=s[2];const a=We(n),l=ms();let h;s[3]!==t||s[4]!==i.id?(h=$s.ensureTask(i.id,t),s[3]=t,s[4]=i.id,s[5]=h):h=s[5];let c;s[6]!==a||s[7]!==t?(c=async()=>(await a.callTool({name:"COLLECTION_THREADS_GET",arguments:{id:t}})).structuredContent?.item??null,s[6]=a,s[7]=t,s[8]=c):c=s[8];const u=t.length>0;let d;s[9]!==h||s[10]!==c||s[11]!==u?(d={queryKey:h,queryFn:c,enabled:u,retry:!1,refetchOnWindowFocus:!1},s[9]=h,s[10]=c,s[11]=u,s[12]=d):d=s[12];const f=Jo(d);let _;s[13]!==a||s[14]!==e?(_=async b=>{const y=await a.callTool({name:"COLLECTION_THREADS_CREATE",arguments:{data:{id:b,virtual_mcp_id:e}}});if(y.isError){const C=y.content,D=Array.isArray(C)&&C[0]&&typeof C[0]=="object"?C[0].text??"Create failed":"Create failed";throw new Error(D)}return y.structuredContent.item},s[13]=a,s[14]=e,s[15]=_):_=s[15];let m;s[16]!==r||s[17]!==i.id||s[18]!==f||s[19]!==l?(m=()=>{l.invalidateQueries({predicate:b=>b.queryKey[1]===i.id&&b.queryKey[3]==="collection"&&b.queryKey[4]==="THREADS"}),l.invalidateQueries({queryKey:$s.tasksPrefix(r)}),f.refetch()},s[16]=r,s[17]=i.id,s[18]=f,s[19]=l,s[20]=m):m=s[20];let p;s[21]!==_||s[22]!==m?(p={mutationFn:_,onSuccess:m},s[21]=_,s[22]=m,s[23]=p):p=s[23];const g=Zo(p);let v,x;if(s[24]!==g||s[25]!==t||s[26]!==f.data||s[27]!==f.isSuccess?(v=()=>{t&&(!f.isSuccess||f.data||g.isPending||g.variables!==t&&g.mutate(t))},x=[t,f.isSuccess,f.data,g],s[24]=g,s[25]=t,s[26]=f.data,s[27]=f.isSuccess,s[28]=v,s[29]=x):(v=s[28],x=s[29]),P.useEffect(v,x),!t){let b;return s[30]===Symbol.for("react.memo_cache_sentinel")?(b={status:"ready",task:null},s[30]=b):b=s[30],b}if(f.isLoading){let b;return s[31]===Symbol.for("react.memo_cache_sentinel")?(b={status:"loading"},s[31]=b):b=s[31],b}if(f.isError){const b=f.error;let y;return s[32]!==b?(y={status:"error",error:b},s[32]=b,s[33]=y):y=s[33],y}if(f.isSuccess&&f.data){let b;return s[34]!==f.data?(b={status:"ready",task:f.data},s[34]=f.data,s[35]=b):b=s[35],b}if(g.isPending||f.isSuccess&&!f.data){let b;return s[36]===Symbol.for("react.memo_cache_sentinel")?(b={status:"creating"},s[36]=b):b=s[36],b}if(g.isError){let b;return s[37]!==g.error?(b={status:"error",error:g.error},s[37]=g.error,s[38]=b):b=s[38],b}let S;return s[39]===Symbol.for("react.memo_cache_sentinel")?(S={status:"loading"},s[39]=S):S=s[39],S}function ws(t){return t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}k`:String(t)}function $n(t){if(!t)return"—";const e=typeof t=="string"?new Date(t):t;return isNaN(e.getTime())?"—":e.toLocaleString("en-US",{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit"})}function Wh(t){return t?t.replace(/-\d{8}(?:-[a-z0-9]+)*$/i,"").replace(/-/g," "):"—"}function Uh(t){const e=W.c(4),{items:s}=t;let i;e[0]!==s?(i=s.map(Vh),e[0]=s,e[1]=i):i=e[1];let r;return e[2]!==i?(r=o.jsx("div",{className:"grid grid-cols-2 gap-x-8 gap-y-6",children:i}),e[2]=i,e[3]=r):r=e[3],r}function Vh(t){return o.jsxs("div",{className:"flex flex-col gap-1 min-w-0",children:[o.jsx("span",{className:"text-xs text-muted-foreground truncate",children:t.label}),o.jsx("span",{className:"text-sm text-foreground tabular-nums truncate",children:t.value})]},t.label)}function Kh(t){const e=W.c(30),{userTokens:s,assistantTokens:i,otherTokens:r}=t,n=s+i+r,a=n>0?s/n*100:0,l=n>0?i/n*100:0,h=n>0?r/n*100:0;let c;e[0]!==a?(c=a>0&&o.jsx("div",{className:"h-full bg-chart-1",style:{width:`${a}%`}}),e[0]=a,e[1]=c):c=e[1];let u;e[2]!==l?(u=l>0&&o.jsx("div",{className:"h-full bg-chart-2",style:{width:`${l}%`}}),e[2]=l,e[3]=u):u=e[3];let d;e[4]!==h?(d=h>0&&o.jsx("div",{className:"h-full bg-muted-foreground/30",style:{width:`${h}%`}}),e[4]=h,e[5]=d):d=e[5];let f;e[6]!==c||e[7]!==u||e[8]!==d?(f=o.jsxs("div",{className:"flex h-2 w-full overflow-hidden rounded-full bg-muted",children:[c,u,d]}),e[6]=c,e[7]=u,e[8]=d,e[9]=f):f=e[9];let _;e[10]===Symbol.for("react.memo_cache_sentinel")?(_=o.jsx("span",{className:"inline-block h-2 w-2 rounded-sm bg-chart-1 shrink-0"}),e[10]=_):_=e[10];let m;e[11]!==a?(m=a.toFixed(1),e[11]=a,e[12]=m):m=e[12];let p;e[13]!==m?(p=o.jsxs("div",{className:"flex items-center gap-1.5",children:[_,o.jsxs("span",{className:"text-xs text-muted-foreground",children:["User ",m,"%"]})]}),e[13]=m,e[14]=p):p=e[14];let g;e[15]===Symbol.for("react.memo_cache_sentinel")?(g=o.jsx("span",{className:"inline-block h-2 w-2 rounded-sm bg-chart-2 shrink-0"}),e[15]=g):g=e[15];let v;e[16]!==l?(v=l.toFixed(1),e[16]=l,e[17]=v):v=e[17];let x;e[18]!==v?(x=o.jsxs("div",{className:"flex items-center gap-1.5",children:[g,o.jsxs("span",{className:"text-xs text-muted-foreground",children:["Assistant ",v,"%"]})]}),e[18]=v,e[19]=x):x=e[19];let S;e[20]!==h||e[21]!==r?(S=r>0&&o.jsxs("div",{className:"flex items-center gap-1.5",children:[o.jsx("span",{className:"inline-block h-2 w-2 rounded-sm bg-muted-foreground/30 shrink-0"}),o.jsxs("span",{className:"text-xs text-muted-foreground",children:["Other ",h.toFixed(1),"%"]})]}),e[20]=h,e[21]=r,e[22]=S):S=e[22];let b;e[23]!==x||e[24]!==S||e[25]!==p?(b=o.jsxs("div",{className:"flex flex-wrap gap-x-3 gap-y-1",children:[p,x,S]}),e[23]=x,e[24]=S,e[25]=p,e[26]=b):b=e[26];let y;return e[27]!==b||e[28]!==f?(y=o.jsxs("div",{className:"flex flex-col gap-2",children:[f,b]}),e[27]=b,e[28]=f,e[29]=y):y=e[29],y}function qh(t){const e=W.c(19),{part:s}=t,i=s.input?.agent_id,r=Nt(i),n=r?.title??"Subtask",a=r?.icon??null,l=s.state==="input-streaming"||s.state==="input-available"||s.state==="output-available"&&s.preliminary===!0,h=s.state==="output-error",c=s.state==="approval-requested";let u;e[0]!==a||e[1]!==n?(u=o.jsx(_s,{icon:a,name:n,size:"xs",className:"size-6 rounded-md shrink-0"}),e[0]=a,e[1]=n,e[2]=u):u=e[2];const d=h?"text-destructive":"text-foreground";let f;e[3]!==d?(f=ie("shrink-0 font-medium",d),e[3]=d,e[4]=f):f=e[4];let _;e[5]!==n||e[6]!==f?(_=o.jsx("span",{className:f,children:n}),e[5]=n,e[6]=f,e[7]=_):_=e[7];let m;e[8]!==s.input?(m=s.input?.prompt&&o.jsxs(o.Fragment,{children:[o.jsx("span",{className:"text-muted-foreground/50",children:"·"}),o.jsx("span",{className:"truncate text-muted-foreground",children:s.input.prompt})]}),e[8]=s.input,e[9]=m):m=e[9];let p;e[10]!==c||e[11]!==h||e[12]!==l?(p=o.jsx("span",{className:"ml-auto shrink-0",children:l?o.jsx(Ae,{size:12,className:"animate-spin text-muted-foreground"}):h?o.jsx(cc,{size:12,className:"text-destructive"}):c?o.jsx(Fs,{size:12,className:"text-warning"}):o.jsx(ac,{size:12,className:"text-emerald-500"})}),e[10]=c,e[11]=h,e[12]=l,e[13]=p):p=e[13];let g;return e[14]!==u||e[15]!==_||e[16]!==m||e[17]!==p?(g=o.jsxs("div",{className:"flex items-center gap-2 text-xs min-w-0",children:[u,_,m,p]}),e[14]=u,e[15]=_,e[16]=m,e[17]=p,e[18]=g):g=e[18],g}function Gh(t){const e=W.c(58),{onClose:s,back:i,className:r}=t,[n,a]=P.useState(null),{messages:l}=na(),{tasks:h,taskId:c}=bt(),{selectedModel:u,selectedVirtualMcp:d}=Ri();let f,_,m,p,g,v,x,S;if(e[0]!==i||e[1]!==r||e[2]!==l||e[3]!==s||e[4]!==n?.id||e[5]!==u||e[6]!==d?.title||e[7]!==c||e[8]!==h){S=Symbol.for("react.early_return_sentinel");e:{let N;e[17]!==c?(N=G=>G.id===c,e[17]=c,e[18]=N):N=e[18];const C=h.find(N),D=mc(l),R=[...l].reverse().find(nd),B=R?.metadata?.usage,M=R?.metadata?.modelLimits?.contextWindow??u?.limits?.contextWindow??null,E=B?.contextTokens??B?.totalTokens??0,k=M&&M>0?(E/M*100).toFixed(1):null,w=l;let j;e[19]!==w?(j=w.filter(rd).reduce(id,0),e[19]=w,e[20]=j):j=e[20];const T=j,I=l;let A;e[21]!==I?(A=I.filter(sd).reduce(td,0),e[21]=I,e[22]=A):A=e[22];const O=A,q=Math.max(0,D.totalTokens-T-O),U=l[0],V=l.at(-1),J=U?.metadata?.created_at??C?.created_at,Z=V?.metadata?.created_at??C?.updated_at,F=l.filter(ed),$=l.flatMap(Zh),H=u?.modelId?Wh(u.modelId):"—",Q=d?.title??"Decopilot",L=[{label:"Session",value:C?.title??"New chat"},{label:"Messages",value:F.length},{label:"Agent",value:Q},{label:"Model",value:H},{label:"Context Limit",value:M?ws(M):"—"},{label:"Session Tokens (billed)",value:D.totalTokens>0?ws(D.totalTokens):"0"},{label:"Usage",value:k!==null?`${k}%`:"—"},{label:"Input Tokens",value:D.inputTokens>0?ws(D.inputTokens):"0"},{label:"Output Tokens",value:D.outputTokens>0?ws(D.outputTokens):"0"},{label:"Reasoning Tokens",value:D.reasoningTokens>0?ws(D.reasoningTokens):"0"},{label:"Cost",value:D.cost>0?`$${D.cost<.001?D.cost.toFixed(6):D.cost.toFixed(4)}`:"$0.00"},{label:"Session Created",value:$n(J)},{label:"Last Activity",value:$n(Z)}];if(!C&&F.length===0){let G;e[23]!==r?(G=ie("flex flex-col h-full w-full border-l border-border bg-background",r),e[23]=r,e[24]=G):G=e[24];let he;e[25]===Symbol.for("react.memo_cache_sentinel")?(he=o.jsx("span",{className:"text-sm font-medium text-foreground",children:"Context"}),e[25]=he):he=e[25];let fe;e[26]!==i?(fe=i?o.jsx(En,{size:14,className:"text-muted-foreground"}):o.jsx(ds,{size:14,className:"text-muted-foreground"}),e[26]=i,e[27]=fe):fe=e[27];let de;e[28]!==s||e[29]!==fe?(de=o.jsxs("div",{className:"h-11 px-4 flex items-center justify-between shrink-0 border-b border-border/50",children:[he,o.jsx("button",{type:"button",onClick:s,className:"flex size-6 items-center justify-center rounded hover:bg-accent transition-colors",children:fe})]}),e[28]=s,e[29]=fe,e[30]=de):de=e[30];let ue;e[31]===Symbol.for("react.memo_cache_sentinel")?(ue=o.jsx("div",{className:"flex-1 flex items-center justify-center px-4 text-center",children:o.jsx("p",{className:"text-xs text-muted-foreground",children:"Start a conversation to see context"})}),e[31]=ue):ue=e[31];let pe;e[32]!==G||e[33]!==de?(pe=o.jsxs("div",{className:G,children:[de,ue]}),e[32]=G,e[33]=de,e[34]=pe):pe=e[34],S=pe;break e}e[35]!==r?(v=ie("flex flex-col h-full w-full border-l border-border bg-background overflow-y-auto",r),e[35]=r,e[36]=v):v=e[36];let ee;e[37]===Symbol.for("react.memo_cache_sentinel")?(ee=o.jsx("span",{className:"text-sm font-medium text-foreground",children:"Context"}),e[37]=ee):ee=e[37];let se;e[38]!==i?(se=i?o.jsx(En,{size:14}):o.jsx(ds,{size:14}),e[38]=i,e[39]=se):se=e[39],e[40]!==s||e[41]!==se?(x=o.jsxs("div",{className:"flex h-11 shrink-0 items-center justify-between border-b border-border/50 px-4",children:[ee,o.jsx("button",{type:"button",onClick:s,className:"flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-accent hover:text-foreground",children:se})]}),e[40]=s,e[41]=se,e[42]=x):x=e[42],f="flex flex-col gap-8 p-6",_=$.length>0&&o.jsxs("div",{className:"flex flex-col gap-3",children:[o.jsx("span",{className:"text-xs text-muted-foreground",children:"Subtasks"}),o.jsx("div",{className:"flex flex-col gap-1",children:$.map(Jh)})]}),m=o.jsx(Uh,{items:L});let te;e[43]===Symbol.for("react.memo_cache_sentinel")?(te=o.jsx("span",{className:"text-xs text-muted-foreground",children:"Context Breakdown"}),e[43]=te):te=e[43],e[44]!==O||e[45]!==q||e[46]!==T?(p=o.jsxs("div",{className:"flex flex-col gap-3",children:[te,o.jsx(Kh,{userTokens:T,assistantTokens:O,otherTokens:q})]}),e[44]=O,e[45]=q,e[46]=T,e[47]=p):p=e[47],g=F.length>0&&o.jsxs("div",{className:"flex flex-col gap-3",children:[o.jsx("span",{className:"text-xs text-muted-foreground",children:"Raw messages"}),o.jsx("div",{className:"flex flex-col gap-1",children:F.map(G=>{const he=G.metadata?.created_at,fe=n?.id===G.id;return o.jsxs("div",{className:"rounded-md border border-border/50 overflow-hidden",children:[o.jsxs("button",{type:"button",onClick:()=>a(fe?null:G),className:"flex items-center justify-between gap-2 px-3 py-2 text-xs hover:bg-accent/50 w-full text-left cursor-pointer",children:[o.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[o.jsx("span",{className:ie("shrink-0 font-medium",G.role==="user"?"text-chart-1":"text-chart-2"),children:G.role}),o.jsx("span",{className:"text-muted-foreground",children:"•"}),o.jsx("span",{className:"truncate text-muted-foreground font-mono",children:G.id})]}),he&&o.jsx("span",{className:"shrink-0 text-muted-foreground tabular-nums",children:new Date(he).toLocaleString("en-US",{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit"})})]}),fe&&o.jsxs(o.Fragment,{children:[G.role==="assistant"&&(()=>{const de=G.metadata?._request;if(!de)return null;const ue=de.systemSections??[],pe=Math.max(1,...ue.map(Xh)),De=ue.reduce(Yh,0);return o.jsxs("div",{className:"border-t border-border/50 px-3 py-2.5 text-xs space-y-2.5",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("span",{className:"font-medium text-foreground",children:"Request"}),o.jsxs("span",{className:"text-muted-foreground tabular-nums",children:[de.activeTools??0," / ",de.tools??0," ","tools active"]})]}),ue.length>0&&o.jsxs("div",{className:"space-y-1.5",children:[o.jsxs("div",{className:"text-muted-foreground",children:["System prompt"," ",o.jsxs("span",{className:"tabular-nums",children:["~",Math.round(De/4).toLocaleString()," ","tok"]})]}),ue.map((Ue,Ke)=>{const Qe=Ue.preview.match(/^<([a-z-]+)/i)?.[1]??`section ${Ke}`,me=Ue.chars/pe*100,Tt=Math.round(Ue.chars/4);return o.jsxs("div",{className:"space-y-0.5",children:[o.jsxs("div",{className:"flex items-center justify-between gap-2",children:[o.jsx("span",{className:"font-mono text-foreground truncate",children:Qe}),o.jsxs("span",{className:"text-muted-foreground tabular-nums shrink-0",children:["~",Tt.toLocaleString()," tok"]})]}),o.jsx("div",{className:"h-1 w-full rounded-full bg-muted overflow-hidden",children:o.jsx("div",{className:"h-full rounded-full bg-chart-3",style:{width:`${me}%`}})})]},Ke)})]})]})})(),o.jsx("pre",{className:"text-xs font-mono bg-muted px-3 py-2 overflow-auto whitespace-pre-wrap break-all border-t border-border/50 max-h-64",children:JSON.stringify(G,null,2)})]})]},G.id)})})]})}e[0]=i,e[1]=r,e[2]=l,e[3]=s,e[4]=n?.id,e[5]=u,e[6]=d?.title,e[7]=c,e[8]=h,e[9]=f,e[10]=_,e[11]=m,e[12]=p,e[13]=g,e[14]=v,e[15]=x,e[16]=S}else f=e[9],_=e[10],m=e[11],p=e[12],g=e[13],v=e[14],x=e[15],S=e[16];if(S!==Symbol.for("react.early_return_sentinel"))return S;let b;e[48]!==f||e[49]!==_||e[50]!==m||e[51]!==p||e[52]!==g?(b=o.jsxs("div",{className:f,children:[_,m,p,g]}),e[48]=f,e[49]=_,e[50]=m,e[51]=p,e[52]=g,e[53]=b):b=e[53];let y;return e[54]!==v||e[55]!==x||e[56]!==b?(y=o.jsxs("div",{className:v,children:[x,b]}),e[54]=v,e[55]=x,e[56]=b,e[57]=y):y=e[57],y}function Yh(t,e){return t+e.chars}function Xh(t){return t.chars}function Jh(t,e){return o.jsx(qh,{part:t},e)}function Zh(t){return(t.parts??[]).filter(Qh)}function Qh(t){return t.type==="tool-subtask"}function ed(t){return t.role!=="system"}function td(t,e){const s=e.metadata?.usage;return t+(s?.outputTokens??0)}function sd(t){return t.role==="assistant"}function id(t,e){const s=e.metadata?.usage;return t+(s?.inputTokens??0)}function rd(t){return t.role==="user"}function nd(t){return t.role==="assistant"&&t.metadata?.usage}const Fn=["amber","bold","bright","calm","crimson","coral","daring","deep","dusty","eager","faint","fierce","frozen","gentle","golden","grand","green","hollow","iron","ivory","keen","lasting","lunar","mellow","misty","noble","olive","pale","prime","quiet","rapid","rustic","serene","sharp","silver","sleek","solar","stark","still","swift","tawny","tender","thin","true","vast","velvet","warm","wild","young","zen"],Hn=["anchor","birch","brook","cedar","cliff","cove","crane","dune","echo","ember","falcon","fern","flint","forge","frost","glade","grove","harbor","hawk","iris","jade","lark","maple","marsh","mesa","opal","orbit","peak","pine","plume","quartz","rapids","reef","ridge","river","sage","shore","slate","spruce","stone","summit","thorn","tide","trail","vale","wren","aspen","delta","crest","spark"];function od(){const t=Fn[Math.floor(Math.random()*Fn.length)],e=Hn[Math.floor(Math.random()*Hn.length)];return`deco/${t}-${e}`}function ad(t){const e=t;if(e.structuredContent)return e.structuredContent;const s=e.content?.find(i=>i.type==="text")?.text;if(s)try{return JSON.parse(s)}catch{return[]}return[]}function ld(t){const e=W.c(26),{orgId:s,orgSlug:i,userId:r,connectionId:n,vmMap:a,owner:l,repo:h,enabled:c}=t,u=c===void 0?!0:c,d=n??null;let f;e[0]!==s||e[1]!==i||e[2]!==d?(f={connectionId:d,orgId:s,orgSlug:i},e[0]=s,e[1]=i,e[2]=d,e[3]=f):f=e[3];const _=We(f);let m;e[4]!==l||e[5]!==h?(m={owner:l,repo:h},e[4]=l,e[5]=h,e[6]=m):m=e[6];const p=u&&!!n&&!!l&&!!h;let g;e[7]!==_||e[8]!==m||e[9]!==p?(g={client:_,toolName:"list_branches",toolArguments:m,enabled:p,staleTime:3e4,select:ud},e[7]=_,e[8]=m,e[9]=p,e[10]=g):g=e[10];const{data:v,isLoading:x,isError:S}=gs(g);let b,y;e[11]!==r||e[12]!==a?(y=new Set(Object.keys(a?.[r]??{})),b=[...y].sort().map(dd),e[11]=r,e[12]=a,e[13]=b,e[14]=y):(b=e[13],y=e[14]);const N=b;let C;if(e[15]!==v||e[16]!==y){const M=Array.isArray(v)?v:v?.branches??[];let E;e[18]!==y?(E=k=>!y.has(k.name),e[18]=y,e[19]=E):E=e[19],C=M.filter(hd).filter(E).map(cd),e[15]=v,e[16]=y,e[17]=C}else C=e[17];const D=C,R=Array.isArray(v)?null:v?.default_branch??null;let B;return e[20]!==R||e[21]!==S||e[22]!==x||e[23]!==D||e[24]!==N?(B={yours:N,others:D,defaultBase:R,isLoading:x,isError:S},e[20]=R,e[21]=S,e[22]=x,e[23]=D,e[24]=N,e[25]=B):B=e[25],B}function cd(t){return{name:t.name,source:"other",author:typeof t.commit?.author=="string"?t.commit.author:t.commit?.author?.login??null}}function hd(t){return typeof t.name=="string"}function dd(t){return{name:t,source:"yours"}}function ud(t){return ad(t)}function fd(t){const e=W.c(42),{orgId:s,orgSlug:i,userId:r,connectionId:n,owner:a,repo:l,vmMap:h,value:c,onChange:u}=t,[d,f]=P.useState(!1);let _;e[0]!==n||e[1]!==d||e[2]!==s||e[3]!==i||e[4]!==a||e[5]!==l||e[6]!==r||e[7]!==h?(_={orgId:s,orgSlug:i,userId:r,connectionId:n,vmMap:h,owner:a,repo:l,enabled:d},e[0]=n,e[1]=d,e[2]=s,e[3]=i,e[4]=a,e[5]=l,e[6]=r,e[7]=h,e[8]=_):_=e[8];const{yours:m,others:p,isLoading:g,isError:v}=ld(_);let x;e[9]!==u?(x=T=>{u(T),f(!1)},e[9]=u,e[10]=x):x=e[10];const S=x,b=c??"Select branch…";let y;e[11]===Symbol.for("react.memo_cache_sentinel")?(y=o.jsx(Bs,{className:"h-3.5 w-3.5"}),e[11]=y):y=e[11];let N;e[12]!==b?(N=o.jsx(Gs,{asChild:!0,children:o.jsxs(ne,{variant:"outline",size:"sm",className:"h-7 gap-1.5 px-2 font-mono text-xs",children:[y,o.jsx("span",{className:"max-w-[200px] truncate",children:b})]})}),e[12]=b,e[13]=N):N=e[13];let C;e[14]===Symbol.for("react.memo_cache_sentinel")?(C=o.jsx(kc,{placeholder:"Search branches…"}),e[14]=C):C=e[14];let D;e[15]!==S?(D=o.jsxs("div",{className:"flex items-center border-b pr-2 [&>[data-slot=command-input-wrapper]]:flex-1 [&>[data-slot=command-input-wrapper]]:border-b-0",children:[C,o.jsx(ne,{variant:"outline",size:"sm",className:"h-7 shrink-0",onClick:()=>S(od()),children:"New"})]}),e[15]=S,e[16]=D):D=e[16];let R;e[17]!==v?(R=v&&o.jsx("div",{className:"p-3 text-xs text-muted-foreground",children:"Couldn't load branches from GitHub. You can still pick from your branches."}),e[17]=v,e[18]=R):R=e[18];let B;e[19]!==v||e[20]!==g||e[21]!==p.length||e[22]!==m.length?(B=!v&&!g&&m.length===0&&p.length===0&&o.jsx(wc,{children:"No branches found."}),e[19]=v,e[20]=g,e[21]=p.length,e[22]=m.length,e[23]=B):B=e[23];let M;e[24]!==S||e[25]!==m?(M=m.length>0&&o.jsx(Dn,{heading:"Your branches",children:m.map(T=>o.jsxs(Mn,{value:T.name,onSelect:()=>S(T.name),children:[o.jsx(Bs,{className:"mr-2 h-4 w-4"}),o.jsx("span",{className:"flex-1 truncate",children:T.name})]},T.name))}),e[24]=S,e[25]=m,e[26]=M):M=e[26];let E;e[27]!==p||e[28]!==S?(E=p.length>0&&o.jsxs(o.Fragment,{children:[o.jsx(Cc,{}),o.jsx(Dn,{heading:"Other branches in repo",children:p.map(T=>o.jsxs(Mn,{value:T.name,onSelect:()=>S(T.name),children:[o.jsx(Bs,{className:"mr-2 h-4 w-4"}),o.jsx("span",{className:"flex-1 truncate",children:T.name}),T.author&&o.jsxs("span",{className:"text-xs text-muted-foreground",children:["@",T.author]})]},T.name))})]}),e[27]=p,e[28]=S,e[29]=E):E=e[29];let k;e[30]!==E||e[31]!==R||e[32]!==B||e[33]!==M?(k=o.jsxs(Nc,{children:[R,B,M,E]}),e[30]=E,e[31]=R,e[32]=B,e[33]=M,e[34]=k):k=e[34];let w;e[35]!==k||e[36]!==D?(w=o.jsx(Ys,{className:"w-[min(420px,calc(100vw-2rem))] p-0",align:"start",children:o.jsxs(jc,{children:[D,k]})}),e[35]=k,e[36]=D,e[37]=w):w=e[37];let j;return e[38]!==d||e[39]!==w||e[40]!==N?(j=o.jsxs(Xs,{open:d,onOpenChange:f,children:[N,w]}),e[38]=d,e[39]=w,e[40]=N,e[41]=j):j=e[41],j}function md(){const t=W.c(27),{org:e}=xe(),{selectedVirtualMcp:s}=Ri(),{data:i}=Ti.useSession(),{currentBranch:r,setCurrentTaskBranch:n}=bt();let a;t[0]!==e.id?(a=ia(e.id),t[0]=e.id,t[1]=a):a=t[1];const h=s??a,c=Nt(h.id),u=i?.user?.id??"",d=c?.metadata?.githubRepo??null,f=!!d?.connectionId&&!!u;let _;t[2]===Symbol.for("react.memo_cache_sentinel")?(_=o.jsx(nc,{size:32}),t[2]=_):_=t[2];let m;t[3]!==h.icon||t[4]!==h.title?(m=o.jsx(_s,{icon:h.icon,name:h.title,size:"lg",fallbackIcon:_,className:"size-10 min-w-10 md:size-[60px]! md:min-w-[60px] rounded-xl md:rounded-[18px]!"}),t[3]=h.icon,t[4]=h.title,t[5]=m):m=t[5];let p;t[6]!==h.title?(p=o.jsx("h3",{className:"text-base md:text-xl font-medium text-foreground",children:h.title}),t[6]=h.title,t[7]=p):p=t[7];const g=h.description??"Ask anything about configuring model providers or using MCP Mesh.";let v;t[8]!==g?(v=o.jsx("div",{className:"text-muted-foreground text-center text-base max-w-md line-clamp-2",children:g}),t[8]=g,t[9]=v):v=t[9];let x;t[10]!==r||t[11]!==c?.metadata?.vmMap||t[12]!==d||t[13]!==e.id||t[14]!==e.slug||t[15]!==n||t[16]!==f||t[17]!==u?(x=f&&o.jsx("div",{className:"mt-2",children:o.jsx(fd,{orgId:e.id,orgSlug:e.slug,userId:u,connectionId:d.connectionId,owner:d.owner,repo:d.name,vmMap:c?.metadata?.vmMap,value:r??void 0,onChange:n})}),t[10]=r,t[11]=c?.metadata?.vmMap,t[12]=d,t[13]=e.id,t[14]=e.slug,t[15]=n,t[16]=f,t[17]=u,t[18]=x):x=t[18];let S;t[19]!==m||t[20]!==p||t[21]!==v||t[22]!==x?(S=o.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 md:gap-4 text-center",children:[m,p,v,x]}),t[19]=m,t[20]=p,t[21]=v,t[22]=x,t[23]=S):S=t[23];let b;t[24]===Symbol.for("react.memo_cache_sentinel")?(b=o.jsx("div",{className:"w-full max-w-3xl mx-auto",children:o.jsx(Ee.IceBreakers,{})}),t[24]=b):b=t[24];let y;return t[25]!==S?(y=o.jsxs("div",{className:"h-full w-full flex flex-col items-center justify-center gap-6 px-4",children:[S,b]}),t[25]=S,t[26]=y):y=t[26],y}function _d(){const t=W.c(26),{org:e}=xe(),s=zc(),{isChatEmpty:i}=na(),[r,n]=P.useState("chat"),a=Zl();if(s.length===0){let S;return t[0]===Symbol.for("react.memo_cache_sentinel")?(S=o.jsx(Ee,{className:"animate-in fade-in-0 duration-200",children:o.jsx(Ee.Main,{className:"flex flex-col items-center",children:o.jsx(Ee.EmptyState,{children:o.jsx(Ee.NoAiProviderEmptyState,{})})})}),t[0]=S):S=t[0],S}let l;t[1]!==a.hasDecoKey||t[2]!==a.hasOnlyDecoProvider||t[3]!==a.isLoading||t[4]!==a.isZeroBalance||t[5]!==i||t[6]!==e?(l=a.hasDecoKey&&a.isZeroBalance&&a.hasOnlyDecoProvider&&!a.isLoading&&i&&!Ql(e.id),t[1]=a.hasDecoKey,t[2]=a.hasOnlyDecoProvider,t[3]=a.isLoading,t[4]=a.isZeroBalance,t[5]=i,t[6]=e,t[7]=l):l=t[7];const h=l;let c;t[8]!==h?(c=h&&o.jsx(Ee.CreditsEmptyState,{}),t[8]=h,t[9]=c):c=t[9];const u=r!=="chat"?"opacity-0 pointer-events-none":"opacity-100";let d;t[10]!==u?(d=ie("absolute inset-0 flex flex-col transition-opacity duration-100 ease-out",u),t[10]=u,t[11]=d):d=t[11];let f;t[12]!==i?(f=i?o.jsxs(o.Fragment,{children:[o.jsx(Ee.Main,{children:o.jsx(md,{})}),o.jsx(Ee.Footer,{children:o.jsx(Ee.Input,{onOpenContextPanel:()=>n("context")})})]}):o.jsxs(o.Fragment,{children:[o.jsx(Ee.Main,{children:o.jsx(Ee.Messages,{})}),o.jsx(Ee.Footer,{children:o.jsx(Ee.Input,{onOpenContextPanel:()=>n("context")})})]}),t[12]=i,t[13]=f):f=t[13];let _;t[14]!==d||t[15]!==f?(_=o.jsx("div",{className:d,children:f}),t[14]=d,t[15]=f,t[16]=_):_=t[16];const m=r==="context"?"opacity-100":"opacity-0 pointer-events-none";let p;t[17]!==m?(p=ie("absolute inset-0 flex flex-col transition-opacity duration-100 ease-out",m),t[17]=m,t[18]=p):p=t[18];let g;t[19]===Symbol.for("react.memo_cache_sentinel")?(g=o.jsx(Gh,{back:!0,onClose:()=>n("chat")}),t[19]=g):g=t[19];let v;t[20]!==p?(v=o.jsx("div",{className:p,children:g}),t[20]=p,t[21]=v):v=t[21];let x;return t[22]!==c||t[23]!==_||t[24]!==v?(x=o.jsxs(Ee,{className:"relative overflow-hidden animate-in fade-in-0 duration-200",children:[c,_,v]}),t[22]=c,t[23]=_,t[24]=v,t[25]=x):x=t[25],x}function Ba(){const t=W.c(2);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=o.jsx(Ee.Skeleton,{}),t[0]=e):e=t[0];let s;return t[1]===Symbol.for("react.memo_cache_sentinel")?(s=o.jsx(Ut,{fallback:e,children:o.jsx(P.Suspense,{fallback:o.jsx(Ee.Skeleton,{}),children:o.jsx(_d,{})})}),t[1]=s):s=t[1],s}async function pd(t,e,s){const i=await t.callTool({name:e,arguments:s});if(i.isError){const r=i.content?.[0]?.text??`Tool ${e} failed without a message`;throw new Error(r)}return i}const Pa=["VM_START"],ri=new Map,gd=t=>`${t.virtualMcpId}::${t.branch??""}`,Gi=new Set,yi={mark:(t,e)=>Gi.add(`${t}::${e}`),clear:(t,e)=>Gi.delete(`${t}::${e}`),isStopped:(t,e)=>Gi.has(`${t}::${e}`)};function dn(t){const e=ms();return Zo({mutationKey:Pa,mutationFn:async s=>{s.branch&&yi.clear(s.virtualMcpId,s.branch);const i=gd(s),r=ri.get(i);if(r)return r;const n=(async()=>(await pd(t,"VM_START",s)).structuredContent)();ri.set(i,n);try{return await n}finally{ri.get(i)===n&&ri.delete(i)}},onSuccess:()=>{di(e)}})}function La(t,e){const s=W.c(3);let i;return s[0]!==e||s[1]!==t?(i={mutationKey:Pa,predicate:n=>{if(!t)return!1;const a=n.state.variables;return!a||a.virtualMcpId!==t?!1:(a.branch??"")===(e??"")}},s[0]=e,s[1]=t,s[2]=i):i=s[2],$h(i)>0}const vd={settings:Tc,automations:Ec,env:Si,preview:hc,git:Bs};function Wn(t){const e=Mi(t);if(e.type==="icon"){const s=Ii(e.name);return s?{kind:"component",Component:s}:null}return e.type==="url"?{kind:"url",src:e.url}:null}function Yi(t){if(t.kind==="system")return{kind:"component",Component:vd[t.tabId]};const e=Wn(t.iconUrl);if(e)return e;if(!t.appId)return{kind:"fallback"};const s=t.connections.find(r=>r.id===t.appId);if(!s)return{kind:"fallback"};const i=Wn(s.icon);return i||{kind:"fallback"}}function xd(t){const{org:e}=xe(),s=We({connectionId:Ot,orgId:e.id,orgSlug:e.slug}),{data:i}=Hl({queryKey:$s.threadMetadata(t),queryFn:async()=>{if(!s||!t)return null;try{const r=await s.callTool({name:"COLLECTION_THREADS_GET",arguments:{id:t}});return(r.structuredContent??r).item?.metadata??null}catch{return null}},staleTime:3e4});return i}function Oa(t){const e=W.c(8),s=Lt();let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i={strict:!1},e[0]=i):i=e[0];const r=nn(i),n=Nt(t.virtualMcpId),a=xd(t.taskId),{currentBranch:l}=bt(),h=n?.metadata?.ui??null,c=h?.layout??null,u=c?.tabs??[],d=h?.pinnedViews??[],f=a?.expanded_tools??[],_=!!(n&&Gt(n));let m;e[1]===Symbol.for("react.memo_cache_sentinel")?(m={includeVirtual:!0},e[1]=m):m=e[1];const p=Bi(m),{activeTab:g,mainOpen:v}=_c({mainParam:r.main,metadata:c?{defaultMainView:c.defaultMainView??null,tabs:u.map(bd)}:null}),x=oa(g),S=[];_&&(S.push({id:"preview",title:"Preview"}),S.push({id:"env",title:"Terminal"}),S.push({id:"git",title:l??"git"})),S.push({id:"settings",title:"Settings"}),S.push({id:"automations",title:"Automations"});const b=new Map;for(const R of f){const B=Tn(R.appId,R.toolName);b.set(B,{id:B,title:R.toolName,appId:R.appId,iconKey:R.toolName})}for(const R of d){const B=Tn(R.connectionId,R.toolName);b.set(B,{id:B,title:R.label||R.toolName,appId:R.connectionId,iconKey:R.toolName,iconUrl:R.icon??null})}let y;e[2]!==p?(y=R=>({id:R.id,title:R.title,kind:"agent",icon:Yi({tabId:R.id,kind:"agent",appId:R.view.appId,connections:p})}),e[2]=p,e[3]=y):y=e[3];const N=[...u.map(y),...Array.from(b.values()).map(R=>({id:R.id,title:R.title,kind:"expanded",icon:Yi({tabId:R.iconKey,kind:"expanded",appId:R.appId,iconUrl:R.iconUrl,connections:p})})),...S.map(R=>({id:R.id,title:R.title,kind:"system",icon:Yi({tabId:R.id,kind:"system",connections:p})}))];let C;return e[4]!==g||e[5]!==v||e[6]!==s?(C=R=>{const B=pc({clickedId:R,activeTab:g,mainOpen:v});s({to:".",search:M=>({...M,main:B}),replace:!0})},e[4]=g,e[5]=v,e[6]=s,e[7]=C):C=e[7],{activeTab:g,mainOpen:v,setActiveTab:C,systemTabs:S,layoutTabs:u,expandedTools:f,automationTabParsed:x,tabs:N}}function bd(t){return{id:t.id}}function za(t){const{managerAgentId:e,managerName:s,kind:i,id:r,instructions:n}=t,a=` to improve the instructions of ${i} "${r}". Here are its current instructions.
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/project-app-view-CmNwDiw0.js","assets/index-e7eEqZQD.js","assets/index-CpHJcJk3.css","assets/pair-BTwp6bTc.js","assets/agent-icon-SBMo6sYE.js","assets/AlertCircle-Cty0PLzG.js","assets/Tool01-BxwtRzVa.js","assets/XClose-B0qkWAhQ.js","assets/RefreshCcw01-DOURBTJB.js","assets/ArrowNarrowLeft-GsAWuH-U.js","assets/XCircle-BOat1iVu.js","assets/ArrowUpRight-Ck_tkMu3.js","assets/ZapSquare-BajF09ms.js","assets/Users03-DBewd1K5.js","assets/CheckCircle-gN0xOzFk.js","assets/Check-3abToiit.js","assets/ChevronDown-Du1srzFH.js","assets/ChevronRight-CZd3BLjH.js","assets/ChevronUp-CgHHKXV-.js","assets/DotsVertical-D7_daHaX.js","assets/Container-DV6TDqni.js","assets/Star01-Dcuqy8Xk.js","assets/Palette-DgoZ3R-C.js","assets/SearchMd-D05lbITN.js","assets/index-QuRKY5U6.js","assets/tooltip-BPT840gf.js","assets/X-BANQifhl.js","assets/LinkExternal01-CLwRaqiP.js","assets/Lock01-DW1KfF8p.js","assets/Sun-s1inzqGI.js","assets/Play-ZbM8yAk4.js","assets/Plus-xUHEWwhK.js","assets/Settings02-YbowrI3C.js","assets/Shield01-C9nMXmPC.js","assets/Trash01-Bgq8zueU.js","assets/User01-C3dKJDdx.js","assets/Zap-Cq3RtLSB.js","assets/index-ClSJa_a-.js","assets/use-copy-C9_Hg3HJ.js","assets/differenceInSeconds-NQ4PDo0z.js","assets/dialog-C67OG62k.js","assets/content-blocks-o63cs2vh.js","assets/types-9jOTGnHq.js","assets/constants-BCHiURE4.js","assets/chat-context-CNhlOw91.js","assets/use-virtual-mcp-BgZ2h4E7.js","assets/use-collections-DwvEVl8v.js","assets/use-ai-providers-D69mlQI8.js","assets/use-decopilot-events-BcK-yZDw.js","assets/create-sse-subscription-CxkOgzKf.js","assets/use-tasks-Btt8g-fe.js","assets/use-organization-settings-DC8b5MPT.js","assets/shell-layout-5NI7-V2p.js","assets/required-auth-layout-W0nsPTz2.js","assets/use-org-sso-D22xZlY0.js","assets/integration-icon-Bfmqyrf_.js","assets/use-mcp-tools-D73stCOo.js"])))=>i.map(i=>d[i]);
2
+ import{o as ms,r as P,p as $l,q as Fl,e as W,s as xe,K as $s,n as Jo,a as Zo,c as ie,j as o,l as Ae,B as ne,E as Ut,b as Ti,v as di,f as Lt,d as nn,w as Hl,x as ge,y as Wl,V as Ul,t as we,z as Qo,C as Vl,D as Ht,F as Kl,G as Nn,L as ql,H as Ui,I as ii,J as ut,M as ea,P as Gl,_ as Yl,Q as ta,R as sa,T as Xl,g as Jl}from"./index-e7eEqZQD.js";import{C as Ee,u as Zl,w as Ql,A as ec,T as tc,a as sc,S as ic}from"./index-hiuu-64i.js";import{I as _s}from"./integration-icon-Bfmqyrf_.js";import{S as Ot,u as We,g as ia,a as ra}from"./constants-BCHiURE4.js";import{u as Nt,a as rc}from"./use-virtual-mcp-BgZ2h4E7.js";import{a as nc}from"./Users03-DBewd1K5.js";import{u as na,a as bt,b as Ri,c as ps,t as oc,d as jn}from"./chat-context-CNhlOw91.js";import{i as Fs}from"./AlertCircle-Cty0PLzG.js";import{i as ac}from"./CheckCircle-gN0xOzFk.js";import{n as En,a as lc}from"./ZapSquare-BajF09ms.js";import{i as cc,a as hc,b as dc,c as Di,d as uc}from"./XCircle-BOat1iVu.js";import{s as ds,i as fc}from"./XClose-B0qkWAhQ.js";import{c as mc,r as _c,p as oa,f as Tn,a as pc,F as gc,t as Rn,M as on,G as aa,L as vc,i as xc,b as bc,d as Sc,e as yc}from"./pair-BTwp6bTc.js";import{C as wc,a as Dn,b as Mn,c as Cc,d as kc,e as Nc,f as jc}from"./command-BUpWRvBK.js";import{P as Gs,a as Ys,b as Xs}from"./popover-3D5jsJh1.js";import{i as Bs,a as Si,b as Ec,c as Tc,p as Mi,g as Ii,d as an,e as la,h as pr,f as Vi,j as In,A as An,k as ca,l as Rc,m as Dc,n as Mc,t as Ic,o as Ac,q as ui,r as ha,s as da,u as ua,v as Bn,w as Bc,x as Ps,y as Pc,z as Lc,B as fa}from"./agent-icon-SBMo6sYE.js";import{u as gs,a as Oc}from"./use-mcp-tools-D73stCOo.js";import{u as zc,a as $c}from"./use-ai-providers-D69mlQI8.js";import{g as Gt,c as Pn,u as Fc,b as gr,d as Hc,e as Wc,f as Uc,T as Vc}from"./index-DS-a6wyz.js";import{u as Ai,i as Kc}from"./shell-layout-5NI7-V2p.js";import{i as qc,P as ht,u as Gc,c as Yc,d as Xc,e as Jc}from"./index-QuRKY5U6.js";import{u as ma,T as Ge,a as Ye,b as Xe,c as Zc}from"./tooltip-BPT840gf.js";import{u as Qc}from"./use-status-sounds-CCFuBFY0.js";import{E as Hs}from"./empty-state-CmG4puLG.js";import{A as eh,a as th,b as sh,c as ih,R as _a,d as rh,e as nh}from"./accordion-Bm-v7xME.js";import{u as Bi,a as ln,b as oh}from"./use-connection-JJHjF6rv.js";import{g as ah}from"./constants-Cp5N7awu.js";import{u as lh,g as ch}from"./types-9jOTGnHq.js";import{u as pa,G as hh}from"./lean-canvas-recruit-modal-C70LSjWJ.js";import{U as ga}from"./user-C-74yDDj.js";import{T as dh,u as va}from"./tools-list-B0Yp2GUj.js";import{u as uh}from"./unwrap-tool-result-BYXdCQMg.js";import{s as xa,g as fh}from"./connection-slug-eyAPH6o3.js";import{A as ba,a as Sa,b as ya,c as wa,d as Ca,e as ka,f as Na,g as ja}from"./alert-dialog-Bht5ffLL.js";import{D as mh,a as cn,b as hn,c as Ea,d as Ta}from"./dialog-C67OG62k.js";import{C as _h,a as Ln}from"./card-CGYKd1RQ.js";import{I as vs}from"./input-B8x8lV8_.js";import{L as Ls}from"./label-BU7N79Fq.js";import{S as rs,a as ns,b as os,c as as,d as Pt}from"./select-mWz1b_ZH.js";import{S as vr}from"./switch-KcpCgqTm.js";import{T as On}from"./textarea-B5KVzuoV.js";import{i as fi}from"./Play-ZbM8yAk4.js";import{s as us}from"./Plus-xUHEWwhK.js";import{a as ph}from"./Settings02-YbowrI3C.js";import{t as Ra,i as gh}from"./Tool01-BxwtRzVa.js";import{s as xr}from"./Trash01-Bgq8zueU.js";import{u as Da}from"./use-debounced-autosave-DFbpcKm7.js";import{S as Ma}from"./scroll-area-D71z0--k.js";import{i as Ia,a as vh}from"./SearchMd-D05lbITN.js";import{C as xh}from"./collection-tabs-Dm7Azh1U.js";import{C as bh}from"./checkbox-GOJe-fLe.js";import{u as Sh,T as Ki,a as yh,b as wh,c as qi}from"./tabs-yr1sdiKv.js";import{D as Ch,a as kh,b as Nh}from"./drawer-dxlczq_i.js";import{i as Pi}from"./Check-3abToiit.js";import{n as Yt}from"./LinkExternal01-CLwRaqiP.js";import{S as jh}from"./index-ClSJa_a-.js";import{D as ls,a as cs,b as hs,c as kt,d as Eh,e as Th,f as Rh}from"./dropdown-menu-CW5XsoI8.js";import{t as br}from"./ChevronDown-Du1srzFH.js";import{i as Aa}from"./RefreshCcw01-DOURBTJB.js";import{V as Dh}from"./view-mode-toggle-BX0KOixc.js";import{M as Mh}from"./select-model-tmulvVLX.js";import{u as Ih}from"./use-organization-settings-DC8b5MPT.js";import{u as Js,a as Ah,b as Bh,c as Ph,A as Lh,d as Oh}from"./automation-list-row-Bf0t7EtN.js";import{i as Ws}from"./Zap-Cq3RtLSB.js";import{S as zh}from"./search-input-C1sIJN1c.js";import"./use-navigate-to-agent-CJDDIver.js";import"./use-tasks-Btt8g-fe.js";import"./use-collections-DwvEVl8v.js";import"./collection-search-DKsJLeUf.js";import"./form-DPfW-AID.js";import"./Star01-Dcuqy8Xk.js";import"./Lock01-DW1KfF8p.js";import"./X-BANQifhl.js";import"./toggle-group-DhgFoVFU.js";import"./index-Ddo0iMq6.js";import"./question-004-sINsf4GQ.js";import"./ai-providers-logos-DD3qZ33J.js";import"./connection-card-D9OhH-Fq.js";import"./use-registry-connections-XqvUTmE5.js";import"./useInfiniteQuery-DxaE8j48.js";import"./infiniteQueryObserver-CHiY1NnZ.js";import"./extract-connection-data-hFQpz6Ey.js";import"./Container-DV6TDqni.js";import"./connection-form-helpers-D1bN8HX-.js";import"./use-infinite-scroll-B1xILXLP.js";import"./useSuspenseInfiniteQuery-CgPS4Lvz.js";import"./badge-CETVYtBV.js";import"./ChevronRight-CZd3BLjH.js";import"./use-decopilot-events-BcK-yZDw.js";import"./create-sse-subscription-CxkOgzKf.js";import"./use-copy-C9_Hg3HJ.js";import"./differenceInSeconds-NQ4PDo0z.js";import"./content-blocks-o63cs2vh.js";import"./Sun-s1inzqGI.js";import"./index-HbxcCsnZ.js";import"./ArrowNarrowLeft-GsAWuH-U.js";import"./ArrowUpRight-Ck_tkMu3.js";import"./ChevronUp-CgHHKXV-.js";import"./DotsVertical-D7_daHaX.js";import"./Palette-DgoZ3R-C.js";import"./Shield01-C9nMXmPC.js";import"./User01-C3dKJDdx.js";import"./skeleton-Bq5_S0j2.js";import"./avatar-C0tjLWvd.js";import"./index-COeQARzy.js";import"./collection-search-pRmMMUTu.js";import"./use-create-virtual-mcp-D-lXC80m.js";import"./task-status-feSWSO3m.js";import"./required-auth-layout-W0nsPTz2.js";import"./use-org-sso-D22xZlY0.js";import"./collections-CRk11Z8a.js";import"./settings-section-OvOVUTcw.js";import"./formatDistanceToNow-Cb2QZZJn.js";function $h(t,e){const s=ms(e);return Fh({filters:{...t,status:"pending"}},s).length}function zn(t,e){return t.findAll(e.filters).map(s=>e.select?e.select(s):s.state)}function Fh(t={},e){const s=ms(e).getMutationCache(),i=P.useRef(t),r=P.useRef(null);return r.current===null&&(r.current=zn(s,t)),P.useEffect(()=>{i.current=t}),P.useSyncExternalStore(P.useCallback(n=>s.subscribe(()=>{const a=$l(r.current,zn(s,i.current));r.current!==a&&(r.current=a,Fl.schedule(n))}),[s]),()=>r.current,()=>r.current)}function Hh(t,e){const s=W.c(40),{org:i,locator:r}=xe();let n;s[0]!==i.id||s[1]!==i.slug?(n={connectionId:Ot,orgId:i.id,orgSlug:i.slug},s[0]=i.id,s[1]=i.slug,s[2]=n):n=s[2];const a=We(n),l=ms();let h;s[3]!==t||s[4]!==i.id?(h=$s.ensureTask(i.id,t),s[3]=t,s[4]=i.id,s[5]=h):h=s[5];let c;s[6]!==a||s[7]!==t?(c=async()=>(await a.callTool({name:"COLLECTION_THREADS_GET",arguments:{id:t}})).structuredContent?.item??null,s[6]=a,s[7]=t,s[8]=c):c=s[8];const u=t.length>0;let d;s[9]!==h||s[10]!==c||s[11]!==u?(d={queryKey:h,queryFn:c,enabled:u,retry:!1,refetchOnWindowFocus:!1},s[9]=h,s[10]=c,s[11]=u,s[12]=d):d=s[12];const f=Jo(d);let _;s[13]!==a||s[14]!==e?(_=async b=>{const y=await a.callTool({name:"COLLECTION_THREADS_CREATE",arguments:{data:{id:b,virtual_mcp_id:e}}});if(y.isError){const C=y.content,D=Array.isArray(C)&&C[0]&&typeof C[0]=="object"?C[0].text??"Create failed":"Create failed";throw new Error(D)}return y.structuredContent.item},s[13]=a,s[14]=e,s[15]=_):_=s[15];let m;s[16]!==r||s[17]!==i.id||s[18]!==f||s[19]!==l?(m=()=>{l.invalidateQueries({predicate:b=>b.queryKey[1]===i.id&&b.queryKey[3]==="collection"&&b.queryKey[4]==="THREADS"}),l.invalidateQueries({queryKey:$s.tasksPrefix(r)}),f.refetch()},s[16]=r,s[17]=i.id,s[18]=f,s[19]=l,s[20]=m):m=s[20];let p;s[21]!==_||s[22]!==m?(p={mutationFn:_,onSuccess:m},s[21]=_,s[22]=m,s[23]=p):p=s[23];const g=Zo(p);let v,x;if(s[24]!==g||s[25]!==t||s[26]!==f.data||s[27]!==f.isSuccess?(v=()=>{t&&(!f.isSuccess||f.data||g.isPending||g.variables!==t&&g.mutate(t))},x=[t,f.isSuccess,f.data,g],s[24]=g,s[25]=t,s[26]=f.data,s[27]=f.isSuccess,s[28]=v,s[29]=x):(v=s[28],x=s[29]),P.useEffect(v,x),!t){let b;return s[30]===Symbol.for("react.memo_cache_sentinel")?(b={status:"ready",task:null},s[30]=b):b=s[30],b}if(f.isLoading){let b;return s[31]===Symbol.for("react.memo_cache_sentinel")?(b={status:"loading"},s[31]=b):b=s[31],b}if(f.isError){const b=f.error;let y;return s[32]!==b?(y={status:"error",error:b},s[32]=b,s[33]=y):y=s[33],y}if(f.isSuccess&&f.data){let b;return s[34]!==f.data?(b={status:"ready",task:f.data},s[34]=f.data,s[35]=b):b=s[35],b}if(g.isPending||f.isSuccess&&!f.data){let b;return s[36]===Symbol.for("react.memo_cache_sentinel")?(b={status:"creating"},s[36]=b):b=s[36],b}if(g.isError){let b;return s[37]!==g.error?(b={status:"error",error:g.error},s[37]=g.error,s[38]=b):b=s[38],b}let S;return s[39]===Symbol.for("react.memo_cache_sentinel")?(S={status:"loading"},s[39]=S):S=s[39],S}function ws(t){return t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}k`:String(t)}function $n(t){if(!t)return"—";const e=typeof t=="string"?new Date(t):t;return isNaN(e.getTime())?"—":e.toLocaleString("en-US",{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit"})}function Wh(t){return t?t.replace(/-\d{8}(?:-[a-z0-9]+)*$/i,"").replace(/-/g," "):"—"}function Uh(t){const e=W.c(4),{items:s}=t;let i;e[0]!==s?(i=s.map(Vh),e[0]=s,e[1]=i):i=e[1];let r;return e[2]!==i?(r=o.jsx("div",{className:"grid grid-cols-2 gap-x-8 gap-y-6",children:i}),e[2]=i,e[3]=r):r=e[3],r}function Vh(t){return o.jsxs("div",{className:"flex flex-col gap-1 min-w-0",children:[o.jsx("span",{className:"text-xs text-muted-foreground truncate",children:t.label}),o.jsx("span",{className:"text-sm text-foreground tabular-nums truncate",children:t.value})]},t.label)}function Kh(t){const e=W.c(30),{userTokens:s,assistantTokens:i,otherTokens:r}=t,n=s+i+r,a=n>0?s/n*100:0,l=n>0?i/n*100:0,h=n>0?r/n*100:0;let c;e[0]!==a?(c=a>0&&o.jsx("div",{className:"h-full bg-chart-1",style:{width:`${a}%`}}),e[0]=a,e[1]=c):c=e[1];let u;e[2]!==l?(u=l>0&&o.jsx("div",{className:"h-full bg-chart-2",style:{width:`${l}%`}}),e[2]=l,e[3]=u):u=e[3];let d;e[4]!==h?(d=h>0&&o.jsx("div",{className:"h-full bg-muted-foreground/30",style:{width:`${h}%`}}),e[4]=h,e[5]=d):d=e[5];let f;e[6]!==c||e[7]!==u||e[8]!==d?(f=o.jsxs("div",{className:"flex h-2 w-full overflow-hidden rounded-full bg-muted",children:[c,u,d]}),e[6]=c,e[7]=u,e[8]=d,e[9]=f):f=e[9];let _;e[10]===Symbol.for("react.memo_cache_sentinel")?(_=o.jsx("span",{className:"inline-block h-2 w-2 rounded-sm bg-chart-1 shrink-0"}),e[10]=_):_=e[10];let m;e[11]!==a?(m=a.toFixed(1),e[11]=a,e[12]=m):m=e[12];let p;e[13]!==m?(p=o.jsxs("div",{className:"flex items-center gap-1.5",children:[_,o.jsxs("span",{className:"text-xs text-muted-foreground",children:["User ",m,"%"]})]}),e[13]=m,e[14]=p):p=e[14];let g;e[15]===Symbol.for("react.memo_cache_sentinel")?(g=o.jsx("span",{className:"inline-block h-2 w-2 rounded-sm bg-chart-2 shrink-0"}),e[15]=g):g=e[15];let v;e[16]!==l?(v=l.toFixed(1),e[16]=l,e[17]=v):v=e[17];let x;e[18]!==v?(x=o.jsxs("div",{className:"flex items-center gap-1.5",children:[g,o.jsxs("span",{className:"text-xs text-muted-foreground",children:["Assistant ",v,"%"]})]}),e[18]=v,e[19]=x):x=e[19];let S;e[20]!==h||e[21]!==r?(S=r>0&&o.jsxs("div",{className:"flex items-center gap-1.5",children:[o.jsx("span",{className:"inline-block h-2 w-2 rounded-sm bg-muted-foreground/30 shrink-0"}),o.jsxs("span",{className:"text-xs text-muted-foreground",children:["Other ",h.toFixed(1),"%"]})]}),e[20]=h,e[21]=r,e[22]=S):S=e[22];let b;e[23]!==x||e[24]!==S||e[25]!==p?(b=o.jsxs("div",{className:"flex flex-wrap gap-x-3 gap-y-1",children:[p,x,S]}),e[23]=x,e[24]=S,e[25]=p,e[26]=b):b=e[26];let y;return e[27]!==b||e[28]!==f?(y=o.jsxs("div",{className:"flex flex-col gap-2",children:[f,b]}),e[27]=b,e[28]=f,e[29]=y):y=e[29],y}function qh(t){const e=W.c(19),{part:s}=t,i=s.input?.agent_id,r=Nt(i),n=r?.title??"Subtask",a=r?.icon??null,l=s.state==="input-streaming"||s.state==="input-available"||s.state==="output-available"&&s.preliminary===!0,h=s.state==="output-error",c=s.state==="approval-requested";let u;e[0]!==a||e[1]!==n?(u=o.jsx(_s,{icon:a,name:n,size:"xs",className:"size-6 rounded-md shrink-0"}),e[0]=a,e[1]=n,e[2]=u):u=e[2];const d=h?"text-destructive":"text-foreground";let f;e[3]!==d?(f=ie("shrink-0 font-medium",d),e[3]=d,e[4]=f):f=e[4];let _;e[5]!==n||e[6]!==f?(_=o.jsx("span",{className:f,children:n}),e[5]=n,e[6]=f,e[7]=_):_=e[7];let m;e[8]!==s.input?(m=s.input?.prompt&&o.jsxs(o.Fragment,{children:[o.jsx("span",{className:"text-muted-foreground/50",children:"·"}),o.jsx("span",{className:"truncate text-muted-foreground",children:s.input.prompt})]}),e[8]=s.input,e[9]=m):m=e[9];let p;e[10]!==c||e[11]!==h||e[12]!==l?(p=o.jsx("span",{className:"ml-auto shrink-0",children:l?o.jsx(Ae,{size:12,className:"animate-spin text-muted-foreground"}):h?o.jsx(cc,{size:12,className:"text-destructive"}):c?o.jsx(Fs,{size:12,className:"text-warning"}):o.jsx(ac,{size:12,className:"text-emerald-500"})}),e[10]=c,e[11]=h,e[12]=l,e[13]=p):p=e[13];let g;return e[14]!==u||e[15]!==_||e[16]!==m||e[17]!==p?(g=o.jsxs("div",{className:"flex items-center gap-2 text-xs min-w-0",children:[u,_,m,p]}),e[14]=u,e[15]=_,e[16]=m,e[17]=p,e[18]=g):g=e[18],g}function Gh(t){const e=W.c(58),{onClose:s,back:i,className:r}=t,[n,a]=P.useState(null),{messages:l}=na(),{tasks:h,taskId:c}=bt(),{selectedModel:u,selectedVirtualMcp:d}=Ri();let f,_,m,p,g,v,x,S;if(e[0]!==i||e[1]!==r||e[2]!==l||e[3]!==s||e[4]!==n?.id||e[5]!==u||e[6]!==d?.title||e[7]!==c||e[8]!==h){S=Symbol.for("react.early_return_sentinel");e:{let N;e[17]!==c?(N=G=>G.id===c,e[17]=c,e[18]=N):N=e[18];const C=h.find(N),D=mc(l),R=[...l].reverse().find(nd),B=R?.metadata?.usage,M=R?.metadata?.modelLimits?.contextWindow??u?.limits?.contextWindow??null,E=B?.contextTokens??B?.totalTokens??0,k=M&&M>0?(E/M*100).toFixed(1):null,w=l;let j;e[19]!==w?(j=w.filter(rd).reduce(id,0),e[19]=w,e[20]=j):j=e[20];const T=j,I=l;let A;e[21]!==I?(A=I.filter(sd).reduce(td,0),e[21]=I,e[22]=A):A=e[22];const O=A,q=Math.max(0,D.totalTokens-T-O),U=l[0],V=l.at(-1),J=U?.metadata?.created_at??C?.created_at,Z=V?.metadata?.created_at??C?.updated_at,F=l.filter(ed),$=l.flatMap(Zh),H=u?.modelId?Wh(u.modelId):"—",Q=d?.title??"Decopilot",L=[{label:"Session",value:C?.title??"New chat"},{label:"Messages",value:F.length},{label:"Agent",value:Q},{label:"Model",value:H},{label:"Context Limit",value:M?ws(M):"—"},{label:"Session Tokens (billed)",value:D.totalTokens>0?ws(D.totalTokens):"0"},{label:"Usage",value:k!==null?`${k}%`:"—"},{label:"Input Tokens",value:D.inputTokens>0?ws(D.inputTokens):"0"},{label:"Output Tokens",value:D.outputTokens>0?ws(D.outputTokens):"0"},{label:"Reasoning Tokens",value:D.reasoningTokens>0?ws(D.reasoningTokens):"0"},{label:"Cost",value:D.cost>0?`$${D.cost<.001?D.cost.toFixed(6):D.cost.toFixed(4)}`:"$0.00"},{label:"Session Created",value:$n(J)},{label:"Last Activity",value:$n(Z)}];if(!C&&F.length===0){let G;e[23]!==r?(G=ie("flex flex-col h-full w-full border-l border-border bg-background",r),e[23]=r,e[24]=G):G=e[24];let he;e[25]===Symbol.for("react.memo_cache_sentinel")?(he=o.jsx("span",{className:"text-sm font-medium text-foreground",children:"Context"}),e[25]=he):he=e[25];let fe;e[26]!==i?(fe=i?o.jsx(En,{size:14,className:"text-muted-foreground"}):o.jsx(ds,{size:14,className:"text-muted-foreground"}),e[26]=i,e[27]=fe):fe=e[27];let de;e[28]!==s||e[29]!==fe?(de=o.jsxs("div",{className:"h-11 px-4 flex items-center justify-between shrink-0 border-b border-border/50",children:[he,o.jsx("button",{type:"button",onClick:s,className:"flex size-6 items-center justify-center rounded hover:bg-accent transition-colors",children:fe})]}),e[28]=s,e[29]=fe,e[30]=de):de=e[30];let ue;e[31]===Symbol.for("react.memo_cache_sentinel")?(ue=o.jsx("div",{className:"flex-1 flex items-center justify-center px-4 text-center",children:o.jsx("p",{className:"text-xs text-muted-foreground",children:"Start a conversation to see context"})}),e[31]=ue):ue=e[31];let pe;e[32]!==G||e[33]!==de?(pe=o.jsxs("div",{className:G,children:[de,ue]}),e[32]=G,e[33]=de,e[34]=pe):pe=e[34],S=pe;break e}e[35]!==r?(v=ie("flex flex-col h-full w-full border-l border-border bg-background overflow-y-auto",r),e[35]=r,e[36]=v):v=e[36];let ee;e[37]===Symbol.for("react.memo_cache_sentinel")?(ee=o.jsx("span",{className:"text-sm font-medium text-foreground",children:"Context"}),e[37]=ee):ee=e[37];let se;e[38]!==i?(se=i?o.jsx(En,{size:14}):o.jsx(ds,{size:14}),e[38]=i,e[39]=se):se=e[39],e[40]!==s||e[41]!==se?(x=o.jsxs("div",{className:"flex h-11 shrink-0 items-center justify-between border-b border-border/50 px-4",children:[ee,o.jsx("button",{type:"button",onClick:s,className:"flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-accent hover:text-foreground",children:se})]}),e[40]=s,e[41]=se,e[42]=x):x=e[42],f="flex flex-col gap-8 p-6",_=$.length>0&&o.jsxs("div",{className:"flex flex-col gap-3",children:[o.jsx("span",{className:"text-xs text-muted-foreground",children:"Subtasks"}),o.jsx("div",{className:"flex flex-col gap-1",children:$.map(Jh)})]}),m=o.jsx(Uh,{items:L});let te;e[43]===Symbol.for("react.memo_cache_sentinel")?(te=o.jsx("span",{className:"text-xs text-muted-foreground",children:"Context Breakdown"}),e[43]=te):te=e[43],e[44]!==O||e[45]!==q||e[46]!==T?(p=o.jsxs("div",{className:"flex flex-col gap-3",children:[te,o.jsx(Kh,{userTokens:T,assistantTokens:O,otherTokens:q})]}),e[44]=O,e[45]=q,e[46]=T,e[47]=p):p=e[47],g=F.length>0&&o.jsxs("div",{className:"flex flex-col gap-3",children:[o.jsx("span",{className:"text-xs text-muted-foreground",children:"Raw messages"}),o.jsx("div",{className:"flex flex-col gap-1",children:F.map(G=>{const he=G.metadata?.created_at,fe=n?.id===G.id;return o.jsxs("div",{className:"rounded-md border border-border/50 overflow-hidden",children:[o.jsxs("button",{type:"button",onClick:()=>a(fe?null:G),className:"flex items-center justify-between gap-2 px-3 py-2 text-xs hover:bg-accent/50 w-full text-left cursor-pointer",children:[o.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[o.jsx("span",{className:ie("shrink-0 font-medium",G.role==="user"?"text-chart-1":"text-chart-2"),children:G.role}),o.jsx("span",{className:"text-muted-foreground",children:"•"}),o.jsx("span",{className:"truncate text-muted-foreground font-mono",children:G.id})]}),he&&o.jsx("span",{className:"shrink-0 text-muted-foreground tabular-nums",children:new Date(he).toLocaleString("en-US",{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit"})})]}),fe&&o.jsxs(o.Fragment,{children:[G.role==="assistant"&&(()=>{const de=G.metadata?._request;if(!de)return null;const ue=de.systemSections??[],pe=Math.max(1,...ue.map(Xh)),De=ue.reduce(Yh,0);return o.jsxs("div",{className:"border-t border-border/50 px-3 py-2.5 text-xs space-y-2.5",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("span",{className:"font-medium text-foreground",children:"Request"}),o.jsxs("span",{className:"text-muted-foreground tabular-nums",children:[de.activeTools??0," / ",de.tools??0," ","tools active"]})]}),ue.length>0&&o.jsxs("div",{className:"space-y-1.5",children:[o.jsxs("div",{className:"text-muted-foreground",children:["System prompt"," ",o.jsxs("span",{className:"tabular-nums",children:["~",Math.round(De/4).toLocaleString()," ","tok"]})]}),ue.map((Ue,Ke)=>{const Qe=Ue.preview.match(/^<([a-z-]+)/i)?.[1]??`section ${Ke}`,me=Ue.chars/pe*100,Tt=Math.round(Ue.chars/4);return o.jsxs("div",{className:"space-y-0.5",children:[o.jsxs("div",{className:"flex items-center justify-between gap-2",children:[o.jsx("span",{className:"font-mono text-foreground truncate",children:Qe}),o.jsxs("span",{className:"text-muted-foreground tabular-nums shrink-0",children:["~",Tt.toLocaleString()," tok"]})]}),o.jsx("div",{className:"h-1 w-full rounded-full bg-muted overflow-hidden",children:o.jsx("div",{className:"h-full rounded-full bg-chart-3",style:{width:`${me}%`}})})]},Ke)})]})]})})(),o.jsx("pre",{className:"text-xs font-mono bg-muted px-3 py-2 overflow-auto whitespace-pre-wrap break-all border-t border-border/50 max-h-64",children:JSON.stringify(G,null,2)})]})]},G.id)})})]})}e[0]=i,e[1]=r,e[2]=l,e[3]=s,e[4]=n?.id,e[5]=u,e[6]=d?.title,e[7]=c,e[8]=h,e[9]=f,e[10]=_,e[11]=m,e[12]=p,e[13]=g,e[14]=v,e[15]=x,e[16]=S}else f=e[9],_=e[10],m=e[11],p=e[12],g=e[13],v=e[14],x=e[15],S=e[16];if(S!==Symbol.for("react.early_return_sentinel"))return S;let b;e[48]!==f||e[49]!==_||e[50]!==m||e[51]!==p||e[52]!==g?(b=o.jsxs("div",{className:f,children:[_,m,p,g]}),e[48]=f,e[49]=_,e[50]=m,e[51]=p,e[52]=g,e[53]=b):b=e[53];let y;return e[54]!==v||e[55]!==x||e[56]!==b?(y=o.jsxs("div",{className:v,children:[x,b]}),e[54]=v,e[55]=x,e[56]=b,e[57]=y):y=e[57],y}function Yh(t,e){return t+e.chars}function Xh(t){return t.chars}function Jh(t,e){return o.jsx(qh,{part:t},e)}function Zh(t){return(t.parts??[]).filter(Qh)}function Qh(t){return t.type==="tool-subtask"}function ed(t){return t.role!=="system"}function td(t,e){const s=e.metadata?.usage;return t+(s?.outputTokens??0)}function sd(t){return t.role==="assistant"}function id(t,e){const s=e.metadata?.usage;return t+(s?.inputTokens??0)}function rd(t){return t.role==="user"}function nd(t){return t.role==="assistant"&&t.metadata?.usage}const Fn=["amber","bold","bright","calm","crimson","coral","daring","deep","dusty","eager","faint","fierce","frozen","gentle","golden","grand","green","hollow","iron","ivory","keen","lasting","lunar","mellow","misty","noble","olive","pale","prime","quiet","rapid","rustic","serene","sharp","silver","sleek","solar","stark","still","swift","tawny","tender","thin","true","vast","velvet","warm","wild","young","zen"],Hn=["anchor","birch","brook","cedar","cliff","cove","crane","dune","echo","ember","falcon","fern","flint","forge","frost","glade","grove","harbor","hawk","iris","jade","lark","maple","marsh","mesa","opal","orbit","peak","pine","plume","quartz","rapids","reef","ridge","river","sage","shore","slate","spruce","stone","summit","thorn","tide","trail","vale","wren","aspen","delta","crest","spark"];function od(){const t=Fn[Math.floor(Math.random()*Fn.length)],e=Hn[Math.floor(Math.random()*Hn.length)];return`deco/${t}-${e}`}function ad(t){const e=t;if(e.structuredContent)return e.structuredContent;const s=e.content?.find(i=>i.type==="text")?.text;if(s)try{return JSON.parse(s)}catch{return[]}return[]}function ld(t){const e=W.c(26),{orgId:s,orgSlug:i,userId:r,connectionId:n,vmMap:a,owner:l,repo:h,enabled:c}=t,u=c===void 0?!0:c,d=n??null;let f;e[0]!==s||e[1]!==i||e[2]!==d?(f={connectionId:d,orgId:s,orgSlug:i},e[0]=s,e[1]=i,e[2]=d,e[3]=f):f=e[3];const _=We(f);let m;e[4]!==l||e[5]!==h?(m={owner:l,repo:h},e[4]=l,e[5]=h,e[6]=m):m=e[6];const p=u&&!!n&&!!l&&!!h;let g;e[7]!==_||e[8]!==m||e[9]!==p?(g={client:_,toolName:"list_branches",toolArguments:m,enabled:p,staleTime:3e4,select:ud},e[7]=_,e[8]=m,e[9]=p,e[10]=g):g=e[10];const{data:v,isLoading:x,isError:S}=gs(g);let b,y;e[11]!==r||e[12]!==a?(y=new Set(Object.keys(a?.[r]??{})),b=[...y].sort().map(dd),e[11]=r,e[12]=a,e[13]=b,e[14]=y):(b=e[13],y=e[14]);const N=b;let C;if(e[15]!==v||e[16]!==y){const M=Array.isArray(v)?v:v?.branches??[];let E;e[18]!==y?(E=k=>!y.has(k.name),e[18]=y,e[19]=E):E=e[19],C=M.filter(hd).filter(E).map(cd),e[15]=v,e[16]=y,e[17]=C}else C=e[17];const D=C,R=Array.isArray(v)?null:v?.default_branch??null;let B;return e[20]!==R||e[21]!==S||e[22]!==x||e[23]!==D||e[24]!==N?(B={yours:N,others:D,defaultBase:R,isLoading:x,isError:S},e[20]=R,e[21]=S,e[22]=x,e[23]=D,e[24]=N,e[25]=B):B=e[25],B}function cd(t){return{name:t.name,source:"other",author:typeof t.commit?.author=="string"?t.commit.author:t.commit?.author?.login??null}}function hd(t){return typeof t.name=="string"}function dd(t){return{name:t,source:"yours"}}function ud(t){return ad(t)}function fd(t){const e=W.c(42),{orgId:s,orgSlug:i,userId:r,connectionId:n,owner:a,repo:l,vmMap:h,value:c,onChange:u}=t,[d,f]=P.useState(!1);let _;e[0]!==n||e[1]!==d||e[2]!==s||e[3]!==i||e[4]!==a||e[5]!==l||e[6]!==r||e[7]!==h?(_={orgId:s,orgSlug:i,userId:r,connectionId:n,vmMap:h,owner:a,repo:l,enabled:d},e[0]=n,e[1]=d,e[2]=s,e[3]=i,e[4]=a,e[5]=l,e[6]=r,e[7]=h,e[8]=_):_=e[8];const{yours:m,others:p,isLoading:g,isError:v}=ld(_);let x;e[9]!==u?(x=T=>{u(T),f(!1)},e[9]=u,e[10]=x):x=e[10];const S=x,b=c??"Select branch…";let y;e[11]===Symbol.for("react.memo_cache_sentinel")?(y=o.jsx(Bs,{className:"h-3.5 w-3.5"}),e[11]=y):y=e[11];let N;e[12]!==b?(N=o.jsx(Gs,{asChild:!0,children:o.jsxs(ne,{variant:"outline",size:"sm",className:"h-7 gap-1.5 px-2 font-mono text-xs",children:[y,o.jsx("span",{className:"max-w-[200px] truncate",children:b})]})}),e[12]=b,e[13]=N):N=e[13];let C;e[14]===Symbol.for("react.memo_cache_sentinel")?(C=o.jsx(kc,{placeholder:"Search branches…"}),e[14]=C):C=e[14];let D;e[15]!==S?(D=o.jsxs("div",{className:"flex items-center border-b pr-2 [&>[data-slot=command-input-wrapper]]:flex-1 [&>[data-slot=command-input-wrapper]]:border-b-0",children:[C,o.jsx(ne,{variant:"outline",size:"sm",className:"h-7 shrink-0",onClick:()=>S(od()),children:"New"})]}),e[15]=S,e[16]=D):D=e[16];let R;e[17]!==v?(R=v&&o.jsx("div",{className:"p-3 text-xs text-muted-foreground",children:"Couldn't load branches from GitHub. You can still pick from your branches."}),e[17]=v,e[18]=R):R=e[18];let B;e[19]!==v||e[20]!==g||e[21]!==p.length||e[22]!==m.length?(B=!v&&!g&&m.length===0&&p.length===0&&o.jsx(wc,{children:"No branches found."}),e[19]=v,e[20]=g,e[21]=p.length,e[22]=m.length,e[23]=B):B=e[23];let M;e[24]!==S||e[25]!==m?(M=m.length>0&&o.jsx(Dn,{heading:"Your branches",children:m.map(T=>o.jsxs(Mn,{value:T.name,onSelect:()=>S(T.name),children:[o.jsx(Bs,{className:"mr-2 h-4 w-4"}),o.jsx("span",{className:"flex-1 truncate",children:T.name})]},T.name))}),e[24]=S,e[25]=m,e[26]=M):M=e[26];let E;e[27]!==p||e[28]!==S?(E=p.length>0&&o.jsxs(o.Fragment,{children:[o.jsx(Cc,{}),o.jsx(Dn,{heading:"Other branches in repo",children:p.map(T=>o.jsxs(Mn,{value:T.name,onSelect:()=>S(T.name),children:[o.jsx(Bs,{className:"mr-2 h-4 w-4"}),o.jsx("span",{className:"flex-1 truncate",children:T.name}),T.author&&o.jsxs("span",{className:"text-xs text-muted-foreground",children:["@",T.author]})]},T.name))})]}),e[27]=p,e[28]=S,e[29]=E):E=e[29];let k;e[30]!==E||e[31]!==R||e[32]!==B||e[33]!==M?(k=o.jsxs(Nc,{children:[R,B,M,E]}),e[30]=E,e[31]=R,e[32]=B,e[33]=M,e[34]=k):k=e[34];let w;e[35]!==k||e[36]!==D?(w=o.jsx(Ys,{className:"w-[min(420px,calc(100vw-2rem))] p-0",align:"start",children:o.jsxs(jc,{children:[D,k]})}),e[35]=k,e[36]=D,e[37]=w):w=e[37];let j;return e[38]!==d||e[39]!==w||e[40]!==N?(j=o.jsxs(Xs,{open:d,onOpenChange:f,children:[N,w]}),e[38]=d,e[39]=w,e[40]=N,e[41]=j):j=e[41],j}function md(){const t=W.c(27),{org:e}=xe(),{selectedVirtualMcp:s}=Ri(),{data:i}=Ti.useSession(),{currentBranch:r,setCurrentTaskBranch:n}=bt();let a;t[0]!==e.id?(a=ia(e.id),t[0]=e.id,t[1]=a):a=t[1];const h=s??a,c=Nt(h.id),u=i?.user?.id??"",d=c?.metadata?.githubRepo??null,f=!!d?.connectionId&&!!u;let _;t[2]===Symbol.for("react.memo_cache_sentinel")?(_=o.jsx(nc,{size:32}),t[2]=_):_=t[2];let m;t[3]!==h.icon||t[4]!==h.title?(m=o.jsx(_s,{icon:h.icon,name:h.title,size:"lg",fallbackIcon:_,className:"size-10 min-w-10 md:size-[60px]! md:min-w-[60px] rounded-xl md:rounded-[18px]!"}),t[3]=h.icon,t[4]=h.title,t[5]=m):m=t[5];let p;t[6]!==h.title?(p=o.jsx("h3",{className:"text-base md:text-xl font-medium text-foreground",children:h.title}),t[6]=h.title,t[7]=p):p=t[7];const g=h.description??"Ask anything about configuring model providers or using MCP Mesh.";let v;t[8]!==g?(v=o.jsx("div",{className:"text-muted-foreground text-center text-base max-w-md line-clamp-2",children:g}),t[8]=g,t[9]=v):v=t[9];let x;t[10]!==r||t[11]!==c?.metadata?.vmMap||t[12]!==d||t[13]!==e.id||t[14]!==e.slug||t[15]!==n||t[16]!==f||t[17]!==u?(x=f&&o.jsx("div",{className:"mt-2",children:o.jsx(fd,{orgId:e.id,orgSlug:e.slug,userId:u,connectionId:d.connectionId,owner:d.owner,repo:d.name,vmMap:c?.metadata?.vmMap,value:r??void 0,onChange:n})}),t[10]=r,t[11]=c?.metadata?.vmMap,t[12]=d,t[13]=e.id,t[14]=e.slug,t[15]=n,t[16]=f,t[17]=u,t[18]=x):x=t[18];let S;t[19]!==m||t[20]!==p||t[21]!==v||t[22]!==x?(S=o.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 md:gap-4 text-center",children:[m,p,v,x]}),t[19]=m,t[20]=p,t[21]=v,t[22]=x,t[23]=S):S=t[23];let b;t[24]===Symbol.for("react.memo_cache_sentinel")?(b=o.jsx("div",{className:"w-full max-w-3xl mx-auto",children:o.jsx(Ee.IceBreakers,{})}),t[24]=b):b=t[24];let y;return t[25]!==S?(y=o.jsxs("div",{className:"h-full w-full flex flex-col items-center justify-center gap-6 px-4",children:[S,b]}),t[25]=S,t[26]=y):y=t[26],y}function _d(){const t=W.c(26),{org:e}=xe(),s=zc(),{isChatEmpty:i}=na(),[r,n]=P.useState("chat"),a=Zl();if(s.length===0){let S;return t[0]===Symbol.for("react.memo_cache_sentinel")?(S=o.jsx(Ee,{className:"animate-in fade-in-0 duration-200",children:o.jsx(Ee.Main,{className:"flex flex-col items-center",children:o.jsx(Ee.EmptyState,{children:o.jsx(Ee.NoAiProviderEmptyState,{})})})}),t[0]=S):S=t[0],S}let l;t[1]!==a.hasDecoKey||t[2]!==a.hasOnlyDecoProvider||t[3]!==a.isLoading||t[4]!==a.isZeroBalance||t[5]!==i||t[6]!==e?(l=a.hasDecoKey&&a.isZeroBalance&&a.hasOnlyDecoProvider&&!a.isLoading&&i&&!Ql(e.id),t[1]=a.hasDecoKey,t[2]=a.hasOnlyDecoProvider,t[3]=a.isLoading,t[4]=a.isZeroBalance,t[5]=i,t[6]=e,t[7]=l):l=t[7];const h=l;let c;t[8]!==h?(c=h&&o.jsx(Ee.CreditsEmptyState,{}),t[8]=h,t[9]=c):c=t[9];const u=r!=="chat"?"opacity-0 pointer-events-none":"opacity-100";let d;t[10]!==u?(d=ie("absolute inset-0 flex flex-col transition-opacity duration-100 ease-out",u),t[10]=u,t[11]=d):d=t[11];let f;t[12]!==i?(f=i?o.jsxs(o.Fragment,{children:[o.jsx(Ee.Main,{children:o.jsx(md,{})}),o.jsx(Ee.Footer,{children:o.jsx(Ee.Input,{onOpenContextPanel:()=>n("context")})})]}):o.jsxs(o.Fragment,{children:[o.jsx(Ee.Main,{children:o.jsx(Ee.Messages,{})}),o.jsx(Ee.Footer,{children:o.jsx(Ee.Input,{onOpenContextPanel:()=>n("context")})})]}),t[12]=i,t[13]=f):f=t[13];let _;t[14]!==d||t[15]!==f?(_=o.jsx("div",{className:d,children:f}),t[14]=d,t[15]=f,t[16]=_):_=t[16];const m=r==="context"?"opacity-100":"opacity-0 pointer-events-none";let p;t[17]!==m?(p=ie("absolute inset-0 flex flex-col transition-opacity duration-100 ease-out",m),t[17]=m,t[18]=p):p=t[18];let g;t[19]===Symbol.for("react.memo_cache_sentinel")?(g=o.jsx(Gh,{back:!0,onClose:()=>n("chat")}),t[19]=g):g=t[19];let v;t[20]!==p?(v=o.jsx("div",{className:p,children:g}),t[20]=p,t[21]=v):v=t[21];let x;return t[22]!==c||t[23]!==_||t[24]!==v?(x=o.jsxs(Ee,{className:"relative overflow-hidden animate-in fade-in-0 duration-200",children:[c,_,v]}),t[22]=c,t[23]=_,t[24]=v,t[25]=x):x=t[25],x}function Ba(){const t=W.c(2);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=o.jsx(Ee.Skeleton,{}),t[0]=e):e=t[0];let s;return t[1]===Symbol.for("react.memo_cache_sentinel")?(s=o.jsx(Ut,{fallback:e,children:o.jsx(P.Suspense,{fallback:o.jsx(Ee.Skeleton,{}),children:o.jsx(_d,{})})}),t[1]=s):s=t[1],s}async function pd(t,e,s){const i=await t.callTool({name:e,arguments:s});if(i.isError){const r=i.content?.[0]?.text??`Tool ${e} failed without a message`;throw new Error(r)}return i}const Pa=["VM_START"],ri=new Map,gd=t=>`${t.virtualMcpId}::${t.branch??""}`,Gi=new Set,yi={mark:(t,e)=>Gi.add(`${t}::${e}`),clear:(t,e)=>Gi.delete(`${t}::${e}`),isStopped:(t,e)=>Gi.has(`${t}::${e}`)};function dn(t){const e=ms();return Zo({mutationKey:Pa,mutationFn:async s=>{s.branch&&yi.clear(s.virtualMcpId,s.branch);const i=gd(s),r=ri.get(i);if(r)return r;const n=(async()=>(await pd(t,"VM_START",s)).structuredContent)();ri.set(i,n);try{return await n}finally{ri.get(i)===n&&ri.delete(i)}},onSuccess:()=>{di(e)}})}function La(t,e){const s=W.c(3);let i;return s[0]!==e||s[1]!==t?(i={mutationKey:Pa,predicate:n=>{if(!t)return!1;const a=n.state.variables;return!a||a.virtualMcpId!==t?!1:(a.branch??"")===(e??"")}},s[0]=e,s[1]=t,s[2]=i):i=s[2],$h(i)>0}const vd={settings:Tc,automations:Ec,env:Si,preview:hc,git:Bs};function Wn(t){const e=Mi(t);if(e.type==="icon"){const s=Ii(e.name);return s?{kind:"component",Component:s}:null}return e.type==="url"?{kind:"url",src:e.url}:null}function Yi(t){if(t.kind==="system")return{kind:"component",Component:vd[t.tabId]};const e=Wn(t.iconUrl);if(e)return e;if(!t.appId)return{kind:"fallback"};const s=t.connections.find(r=>r.id===t.appId);if(!s)return{kind:"fallback"};const i=Wn(s.icon);return i||{kind:"fallback"}}function xd(t){const{org:e}=xe(),s=We({connectionId:Ot,orgId:e.id,orgSlug:e.slug}),{data:i}=Hl({queryKey:$s.threadMetadata(t),queryFn:async()=>{if(!s||!t)return null;try{const r=await s.callTool({name:"COLLECTION_THREADS_GET",arguments:{id:t}});return(r.structuredContent??r).item?.metadata??null}catch{return null}},staleTime:3e4});return i}function Oa(t){const e=W.c(8),s=Lt();let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i={strict:!1},e[0]=i):i=e[0];const r=nn(i),n=Nt(t.virtualMcpId),a=xd(t.taskId),{currentBranch:l}=bt(),h=n?.metadata?.ui??null,c=h?.layout??null,u=c?.tabs??[],d=h?.pinnedViews??[],f=a?.expanded_tools??[],_=!!(n&&Gt(n));let m;e[1]===Symbol.for("react.memo_cache_sentinel")?(m={includeVirtual:!0},e[1]=m):m=e[1];const p=Bi(m),{activeTab:g,mainOpen:v}=_c({mainParam:r.main,metadata:c?{defaultMainView:c.defaultMainView??null,tabs:u.map(bd)}:null}),x=oa(g),S=[];_&&(S.push({id:"preview",title:"Preview"}),S.push({id:"env",title:"Terminal"}),S.push({id:"git",title:l??"git"})),S.push({id:"settings",title:"Settings"}),S.push({id:"automations",title:"Automations"});const b=new Map;for(const R of f){const B=Tn(R.appId,R.toolName);b.set(B,{id:B,title:R.toolName,appId:R.appId,iconKey:R.toolName})}for(const R of d){const B=Tn(R.connectionId,R.toolName);b.set(B,{id:B,title:R.label||R.toolName,appId:R.connectionId,iconKey:R.toolName,iconUrl:R.icon??null})}let y;e[2]!==p?(y=R=>({id:R.id,title:R.title,kind:"agent",icon:Yi({tabId:R.id,kind:"agent",appId:R.view.appId,connections:p})}),e[2]=p,e[3]=y):y=e[3];const N=[...u.map(y),...Array.from(b.values()).map(R=>({id:R.id,title:R.title,kind:"expanded",icon:Yi({tabId:R.iconKey,kind:"expanded",appId:R.appId,iconUrl:R.iconUrl,connections:p})})),...S.map(R=>({id:R.id,title:R.title,kind:"system",icon:Yi({tabId:R.id,kind:"system",connections:p})}))];let C;return e[4]!==g||e[5]!==v||e[6]!==s?(C=R=>{const B=pc({clickedId:R,activeTab:g,mainOpen:v});s({to:".",search:M=>({...M,main:B}),replace:!0})},e[4]=g,e[5]=v,e[6]=s,e[7]=C):C=e[7],{activeTab:g,mainOpen:v,setActiveTab:C,systemTabs:S,layoutTabs:u,expandedTools:f,automationTabParsed:x,tabs:N}}function bd(t){return{id:t.id}}function za(t){const{managerAgentId:e,managerName:s,kind:i,id:r,instructions:n}=t,a=` to improve the instructions of ${i} "${r}". Here are its current instructions.
3
3
  <current_instructions>${n}</current_instructions>`;return{type:"doc",content:[{type:"paragraph",content:[{type:"text",text:"Use "},{type:"mention",attrs:{id:e,name:s,char:"@",metadata:{agentId:e,title:s}}},{type:"text",text:a}]}]}}function Sd(t){const e=W.c(84),{value:s,onChange:i,onColorChange:r,name:n,size:a,className:l,avatarClassName:h,showHoverOverlay:c,disabled:u}=t,d=a===void 0?"lg":a,f=c===void 0?!0:c,_=u===void 0?!1:u,[m,p]=P.useState(!1),[g,v]=P.useState("icons"),[x,S]=P.useState(""),[b,y]=P.useState("blue");let N;e[0]!==s?(N=Mi(s),e[0]=s,e[1]=N):N=e[1];const C=N,D=C.type==="icon"||C.type==="url"&&C.color?C.color:b;let R;e[2]!==i||e[3]!==D?(R=me=>{i(Vi(me,D))},e[2]=i,e[3]=D,e[4]=R):R=e[4];const B=R;let M;e[5]!==i||e[6]!==r||e[7]!==C.name||e[8]!==C.type||e[9]!==C.url?(M=me=>{y(me),r?.(me),C.type==="icon"?i(Vi(C.name,me)):C.type==="url"&&i(In(C.url,me))},e[5]=i,e[6]=r,e[7]=C.name,e[8]=C.type,e[9]=C.url,e[10]=M):M=e[10];const E=M;let k;e[11]!==i||e[12]!==D?(k=me=>{i(In(me,D)),p(!1)},e[11]=i,e[12]=D,e[13]=k):k=e[13];const w=k;let j;e[14]!==i||e[15]!==D?(j=()=>{const me=an(),Tt=me[Math.floor(Math.random()*me.length)];i(Vi(Tt,D))},e[14]=i,e[15]=D,e[16]=j):j=e[16];const T=j;let I,A,O,q,U,V,J,Z;if(e[17]!==l||e[18]!==_||e[19]!==m||e[20]!==d){const me={xs:"rounded-md",sm:"rounded-lg","sm+":"rounded-xl",md:"rounded-xl",lg:"rounded-2xl",xl:"rounded-2xl"};A=Xs,V=_?!1:m,J=p,I=Gs,U=!0,Z="button",O=_,q=ie("relative group overflow-hidden",_?"cursor-default opacity-50":"cursor-pointer",me[d],l),e[17]=l,e[18]=_,e[19]=m,e[20]=d,e[21]=I,e[22]=A,e[23]=O,e[24]=q,e[25]=U,e[26]=V,e[27]=J,e[28]=Z}else I=e[21],A=e[22],O=e[23],q=e[24],U=e[25],V=e[26],J=e[27],Z=e[28];let F;e[29]!==h||e[30]!==n||e[31]!==d||e[32]!==s?(F=o.jsx(An,{icon:s,name:n,size:d,className:h}),e[29]=h,e[30]=n,e[31]=d,e[32]=s,e[33]=F):F=e[33];let $;e[34]!==_||e[35]!==f?($=f&&!_&&o.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/50 opacity-0 group-hover:opacity-100 transition-opacity",children:o.jsx(ca,{size:16,className:"text-white"})}),e[34]=_,e[35]=f,e[36]=$):$=e[36];let H;e[37]!==O||e[38]!==q||e[39]!==F||e[40]!==$||e[41]!==Z?(H=o.jsxs("button",{type:Z,disabled:O,className:q,children:[F,$]}),e[37]=O,e[38]=q,e[39]=F,e[40]=$,e[41]=Z,e[42]=H):H=e[42];let Q;e[43]!==I||e[44]!==U||e[45]!==H?(Q=o.jsx(I,{asChild:U,children:H}),e[43]=I,e[44]=U,e[45]=H,e[46]=Q):Q=e[46];let L;e[47]!==n||e[48]!==s?(L=o.jsx("div",{className:"flex items-center justify-center py-4",children:o.jsx(An,{icon:s,name:n,size:"xl"})}),e[47]=n,e[48]=s,e[49]=L):L=e[49];let ee;e[50]===Symbol.for("react.memo_cache_sentinel")?(ee=()=>v("icons"),e[50]=ee):ee=e[50];const se=g==="icons"?"border-foreground text-foreground":"border-transparent text-muted-foreground hover:text-foreground";let te;e[51]!==se?(te=ie("px-3 py-2 text-sm font-medium border-b-2 -mb-px transition-colors",se),e[51]=se,e[52]=te):te=e[52];let G;e[53]!==te?(G=o.jsx("button",{type:"button",onClick:ee,className:te,children:"Icons"}),e[53]=te,e[54]=G):G=e[54];let he;e[55]===Symbol.for("react.memo_cache_sentinel")?(he=()=>v("upload"),e[55]=he):he=e[55];const fe=g==="upload"?"border-foreground text-foreground":"border-transparent text-muted-foreground hover:text-foreground";let de;e[56]!==fe?(de=ie("px-3 py-2 text-sm font-medium border-b-2 -mb-px transition-colors",fe),e[56]=fe,e[57]=de):de=e[57];let ue;e[58]!==de?(ue=o.jsx("button",{type:"button",onClick:he,className:de,children:"Upload"}),e[58]=de,e[59]=ue):ue=e[59];let pe;e[60]===Symbol.for("react.memo_cache_sentinel")?(pe=o.jsx("div",{className:"flex-1"}),e[60]=pe):pe=e[60];let De;e[61]!==G||e[62]!==ue?(De=o.jsxs("div",{className:"flex items-center border-b border-border px-3",children:[G,ue,pe]}),e[61]=G,e[62]=ue,e[63]=De):De=e[63];let Ue;e[64]!==E||e[65]!==T||e[66]!==B||e[67]!==w||e[68]!==C.name||e[69]!==C.type||e[70]!==x||e[71]!==D||e[72]!==g?(Ue=g==="icons"?o.jsx(kd,{search:x,onSearchChange:S,selectedColor:D,onColorChange:E,onSelectIcon:B,onRandom:T,currentIconName:C.type==="icon"?C.name:null}):o.jsx(Nd,{onUpload:w}),e[64]=E,e[65]=T,e[66]=B,e[67]=w,e[68]=C.name,e[69]=C.type,e[70]=x,e[71]=D,e[72]=g,e[73]=Ue):Ue=e[73];let Ke;e[74]!==L||e[75]!==De||e[76]!==Ue?(Ke=o.jsx(Ys,{align:"start",className:"w-80 p-0",onOpenAutoFocus:yd,children:o.jsxs("div",{className:"flex flex-col",children:[L,De,Ue]})}),e[74]=L,e[75]=De,e[76]=Ue,e[77]=Ke):Ke=e[77];let Qe;return e[78]!==A||e[79]!==V||e[80]!==J||e[81]!==Q||e[82]!==Ke?(Qe=o.jsxs(A,{open:V,onOpenChange:J,children:[Q,Ke]}),e[78]=A,e[79]=V,e[80]=J,e[81]=Q,e[82]=Ke,e[83]=Qe):Qe=e[83],Qe}function yd(t){return t.preventDefault()}function wd(t){const e=W.c(27),{selectedColor:s,onColorChange:i}=t,[r,n]=P.useState(!1);let a,l,h,c,u,d,f;if(e[0]!==r||e[1]!==s){const x=la(s);l=Xs,d=r,f=n,a=Gs,u=!0,h="button",c=ie("h-6 w-6 rounded-full shrink-0 ring-2 ring-offset-2 ring-offset-background transition-all cursor-pointer hover:scale-110",x.dot,"ring-foreground/20"),e[0]=r,e[1]=s,e[2]=a,e[3]=l,e[4]=h,e[5]=c,e[6]=u,e[7]=d,e[8]=f}else a=e[2],l=e[3],h=e[4],c=e[5],u=e[6],d=e[7],f=e[8];let _;e[9]!==h||e[10]!==c?(_=o.jsx("button",{type:h,className:c,title:"Change color"}),e[9]=h,e[10]=c,e[11]=_):_=e[11];let m;e[12]!==a||e[13]!==u||e[14]!==_?(m=o.jsx(a,{asChild:u,children:_}),e[12]=a,e[13]=u,e[14]=_,e[15]=m):m=e[15];let p;e[16]!==i||e[17]!==s?(p=Dc.map(x=>o.jsx("button",{type:"button",onClick:()=>{i(x.name),n(!1)},className:ie("h-5 w-5 rounded-full transition-all shrink-0 cursor-pointer",x.dot,s===x.name?"ring-2 ring-offset-1 ring-offset-background ring-foreground/30 scale-110":"hover:scale-110"),title:x.name},x.name)),e[16]=i,e[17]=s,e[18]=p):p=e[18];let g;e[19]!==p?(g=o.jsx(Ys,{align:"start",side:"right",sideOffset:8,className:"w-auto p-2",onOpenAutoFocus:Cd,children:o.jsx("div",{className:"grid grid-cols-4 gap-1",children:p})}),e[19]=p,e[20]=g):g=e[20];let v;return e[21]!==l||e[22]!==d||e[23]!==f||e[24]!==m||e[25]!==g?(v=o.jsxs(l,{open:d,onOpenChange:f,children:[m,g]}),e[21]=l,e[22]=d,e[23]=f,e[24]=m,e[25]=g,e[26]=v):v=e[26],v}function Cd(t){return t.preventDefault()}function kd(t){const e=W.c(44),{search:s,onSearchChange:i,selectedColor:r,onColorChange:n,onSelectIcon:a,onRandom:l,currentIconName:h}=t;let c,u,d,f,_,m,p;if(e[0]!==h||e[1]!==n||e[2]!==l||e[3]!==i||e[4]!==a||e[5]!==s||e[6]!==r){const b=an(),y=la(r);u=s.trim()?b.filter(E=>{const k=pr(E),w=s.toLowerCase();return k.includes(w)||E.toLowerCase().includes(w)}):b,m="flex flex-col";let N;e[14]===Symbol.for("react.memo_cache_sentinel")?(N=o.jsx(Ia,{size:14,className:"absolute left-2 top-1/2 -translate-y-1/2 text-muted-foreground pointer-events-none"}),e[14]=N):N=e[14];let C;e[15]!==i?(C=E=>i(E.target.value),e[15]=i,e[16]=C):C=e[16];let D;e[17]!==s||e[18]!==C?(D=o.jsxs("div",{className:"relative flex-1",children:[N,o.jsx(vs,{value:s,onChange:C,placeholder:"Filter...",className:"h-8 text-xs pl-7"})]}),e[17]=s,e[18]=C,e[19]=D):D=e[19];let R;e[20]===Symbol.for("react.memo_cache_sentinel")?(R=o.jsx(Rc,{size:14,className:"text-muted-foreground"}),e[20]=R):R=e[20];let B;e[21]!==l?(B=o.jsx("button",{type:"button",onClick:l,className:"h-8 w-8 flex items-center justify-center rounded-md border border-border hover:bg-accent transition-colors shrink-0",title:"Random icon",children:R}),e[21]=l,e[22]=B):B=e[22];let M;e[23]!==n||e[24]!==r?(M=o.jsx(wd,{selectedColor:r,onColorChange:n}),e[23]=n,e[24]=r,e[25]=M):M=e[25],e[26]!==B||e[27]!==M||e[28]!==D?(p=o.jsxs("div",{className:"flex items-center gap-2 px-3 py-2",children:[D,B,M]}),e[26]=B,e[27]=M,e[28]=D,e[29]=p):p=e[29],c=Ma,_="h-56",d="grid grid-cols-9 gap-0.5 px-2 pb-2",f=u.map(E=>{const k=Ii(E);return k?o.jsx("button",{type:"button",onClick:()=>a(E),className:ie("h-8 w-8 flex items-center justify-center rounded-md transition-colors cursor-pointer",h===E?ie(y.bg,y.text):ie(y.text,"hover:bg-accent")),title:E,children:o.jsx(k,{size:18})},E):null}),e[0]=h,e[1]=n,e[2]=l,e[3]=i,e[4]=a,e[5]=s,e[6]=r,e[7]=c,e[8]=u,e[9]=d,e[10]=f,e[11]=_,e[12]=m,e[13]=p}else c=e[7],u=e[8],d=e[9],f=e[10],_=e[11],m=e[12],p=e[13];let g;e[30]!==d||e[31]!==f?(g=o.jsx("div",{className:d,children:f}),e[30]=d,e[31]=f,e[32]=g):g=e[32];let v;e[33]!==u.length?(v=u.length===0&&o.jsx("div",{className:"flex items-center justify-center py-8 text-sm text-muted-foreground",children:"No icons found"}),e[33]=u.length,e[34]=v):v=e[34];let x;e[35]!==c||e[36]!==_||e[37]!==g||e[38]!==v?(x=o.jsxs(c,{className:_,children:[g,v]}),e[35]=c,e[36]=_,e[37]=g,e[38]=v,e[39]=x):x=e[39];let S;return e[40]!==m||e[41]!==p||e[42]!==x?(S=o.jsxs("div",{className:m,children:[p,x]}),e[40]=m,e[41]=p,e[42]=x,e[43]=S):S=e[43],S}function Nd(t){const e=W.c(27),{onUpload:s}=t,i=P.useRef(null);let r;e[0]!==s?(r=N=>{const C=N.target.files?.[0];if(!C)return;if(C.size>2097152){ge.error("Image must be smaller than 2MB"),N.target.value="";return}const D=new FileReader;D.onerror=()=>{ge.error("Failed to read image file"),i.current&&(i.current.value="")},D.onloadend=()=>{D.readyState===FileReader.DONE&&D.result&&s(D.result),i.current&&(i.current.value="")},D.readAsDataURL(C)},e[0]=s,e[1]=r):r=e[1];const n=r,[a,l]=P.useState("");let h;e[2]!==s||e[3]!==a?(h=()=>{const N=a.trim();N&&(s(N),l(""))},e[2]=s,e[3]=a,e[4]=h):h=e[4];const c=h;let u;e[5]!==n?(u=o.jsx("input",{type:"file",ref:i,className:"hidden",accept:"image/*",onChange:n}),e[5]=n,e[6]=u):u=e[6];let d;e[7]===Symbol.for("react.memo_cache_sentinel")?(d=()=>i.current?.click(),e[7]=d):d=e[7];let f;e[8]===Symbol.for("react.memo_cache_sentinel")?(f=o.jsxs("button",{type:"button",onClick:d,className:"h-24 rounded-lg border-2 border-dashed border-border hover:border-foreground/50 hover:bg-accent/50 transition-colors flex flex-col items-center justify-center gap-2 text-muted-foreground hover:text-foreground",children:[o.jsx(dc,{size:20}),o.jsx("span",{className:"text-xs",children:"Click to upload an image (max 2MB)"})]}),e[8]=f):f=e[8];let _;e[9]===Symbol.for("react.memo_cache_sentinel")?(_=o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("span",{className:"text-xs text-muted-foreground",children:"or"}),o.jsx("div",{className:"flex-1 h-px bg-border"})]}),e[9]=_):_=e[9];let m;e[10]===Symbol.for("react.memo_cache_sentinel")?(m=N=>l(N.target.value),e[10]=m):m=e[10];let p;e[11]!==c?(p=N=>{N.key==="Enter"&&(N.preventDefault(),c())},e[11]=c,e[12]=p):p=e[12];let g;e[13]!==a||e[14]!==p?(g=o.jsx(vs,{value:a,onChange:m,placeholder:"Paste image URL...",className:"h-8 text-xs flex-1",onKeyDown:p}),e[13]=a,e[14]=p,e[15]=g):g=e[15];let v;e[16]!==a?(v=a.trim(),e[16]=a,e[17]=v):v=e[17];const x=!v;let S;e[18]!==c||e[19]!==x?(S=o.jsx(ne,{variant:"outline",size:"sm",className:"h-8 px-3 text-xs shrink-0",onClick:c,disabled:x,children:"Apply"}),e[18]=c,e[19]=x,e[20]=S):S=e[20];let b;e[21]!==S||e[22]!==g?(b=o.jsxs("div",{className:"flex items-center gap-1.5",children:[g,S]}),e[21]=S,e[22]=g,e[23]=b):b=e[23];let y;return e[24]!==b||e[25]!==u?(y=o.jsxs("div",{className:"flex flex-col gap-3 p-4",children:[u,f,_,b]}),e[24]=b,e[25]=u,e[26]=y):y=e[26],y}function jd(t){const e=W.c(5),{value:s}=t;let i;if(e[0]!==s){i=Symbol.for("react.early_return_sentinel");e:{const n=Mi(s);if(n.type==="icon"){const a=Ii(n.name);if(a){let l;e[2]!==a?(l=o.jsx(a,{size:16,className:"text-muted-foreground"}),e[2]=a,e[3]=l):l=e[3],i=l;break e}}}e[0]=s,e[1]=i}else i=e[1];if(i!==Symbol.for("react.early_return_sentinel"))return i;let r;return e[4]===Symbol.for("react.memo_cache_sentinel")?(r=o.jsx(qc,{size:16,className:"text-muted-foreground"}),e[4]=r):r=e[4],r}function Ed(t){const e=W.c(66),{value:s,onChange:i,className:r,disabled:n}=t,[a,l]=P.useState(!1),[h,c]=P.useState("");let u;e[0]!==s?(u=Mi(s),e[0]=s,e[1]=u):u=e[1];const d=u,f=d.type==="icon"?d.name:null;let _,m,p,g,v,x,S,b,y,N,C,D,R,B,M;if(e[2]!==r||e[3]!==f||e[4]!==n||e[5]!==i||e[6]!==a||e[7]!==h||e[8]!==s){const A=an();g=h.trim()?A.filter(F=>{const $=h.toLowerCase();return pr(F).includes($)||F.toLowerCase().includes($)}):A,p=Xs,v=n?!1:a,x=l;const O=n?"cursor-default opacity-50":"cursor-pointer hover:bg-accent";let q;e[24]!==r||e[25]!==O?(q=ie("size-7 shrink-0 rounded-md transition-colors flex items-center justify-center",O,r),e[24]=r,e[25]=O,e[26]=q):q=e[26];let U;e[27]!==s?(U=o.jsx(jd,{value:s}),e[27]=s,e[28]=U):U=e[28],e[29]!==n||e[30]!==q||e[31]!==U?(S=o.jsx(Gs,{asChild:!0,children:o.jsx("button",{type:"button",disabled:n,className:q,children:U})}),e[29]=n,e[30]=q,e[31]=U,e[32]=S):S=e[32],m=Ys,R="start",B="w-64 p-0",M=Td,C="flex flex-col";let V;e[33]===Symbol.for("react.memo_cache_sentinel")?(V=o.jsx(Ia,{size:14,className:"absolute left-2 top-1/2 -translate-y-1/2 text-muted-foreground pointer-events-none"}),e[33]=V):V=e[33];let J;e[34]===Symbol.for("react.memo_cache_sentinel")?(J=F=>c(F.target.value),e[34]=J):J=e[34],e[35]!==h?(D=o.jsx("div",{className:"px-2 py-2",children:o.jsxs("div",{className:"relative",children:[V,o.jsx(vs,{value:h,onChange:J,placeholder:"Filter...",className:"h-7 text-xs pl-7"})]})}),e[35]=h,e[36]=D):D=e[36],_=Ma,N="h-48",b="grid grid-cols-8 gap-0.5 px-2 pb-2";let Z;e[37]!==f||e[38]!==i?(Z=F=>{const $=Ii(F);return $?o.jsx("button",{type:"button",onClick:()=>{i(`icon://${F}`),l(!1)},className:ie("h-7 w-7 flex items-center justify-center rounded-md transition-colors cursor-pointer",f===F?"bg-accent text-foreground":"text-muted-foreground hover:bg-accent hover:text-foreground"),title:pr(F),children:o.jsx($,{size:16})},F):null},e[37]=f,e[38]=i,e[39]=Z):Z=e[39],y=g.map(Z),e[2]=r,e[3]=f,e[4]=n,e[5]=i,e[6]=a,e[7]=h,e[8]=s,e[9]=_,e[10]=m,e[11]=p,e[12]=g,e[13]=v,e[14]=x,e[15]=S,e[16]=b,e[17]=y,e[18]=N,e[19]=C,e[20]=D,e[21]=R,e[22]=B,e[23]=M}else _=e[9],m=e[10],p=e[11],g=e[12],v=e[13],x=e[14],S=e[15],b=e[16],y=e[17],N=e[18],C=e[19],D=e[20],R=e[21],B=e[22],M=e[23];let E;e[40]!==b||e[41]!==y?(E=o.jsx("div",{className:b,children:y}),e[40]=b,e[41]=y,e[42]=E):E=e[42];let k;e[43]!==g.length?(k=g.length===0&&o.jsx("div",{className:"flex items-center justify-center py-6 text-xs text-muted-foreground",children:"No icons found"}),e[43]=g.length,e[44]=k):k=e[44];let w;e[45]!==_||e[46]!==E||e[47]!==k||e[48]!==N?(w=o.jsxs(_,{className:N,children:[E,k]}),e[45]=_,e[46]=E,e[47]=k,e[48]=N,e[49]=w):w=e[49];let j;e[50]!==w||e[51]!==C||e[52]!==D?(j=o.jsxs("div",{className:C,children:[D,w]}),e[50]=w,e[51]=C,e[52]=D,e[53]=j):j=e[53];let T;e[54]!==m||e[55]!==j||e[56]!==R||e[57]!==B||e[58]!==M?(T=o.jsx(m,{align:R,className:B,onOpenAutoFocus:M,children:j}),e[54]=m,e[55]=j,e[56]=R,e[57]=B,e[58]=M,e[59]=T):T=e[59];let I;return e[60]!==p||e[61]!==v||e[62]!==x||e[63]!==S||e[64]!==T?(I=o.jsxs(p,{open:v,onOpenChange:x,children:[S,T]}),e[60]=p,e[61]=v,e[62]=x,e[63]=S,e[64]=T,e[65]=I):I=e[65],I}function Td(t){return t.preventDefault()}function mi(){const t=W.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=o.jsx("div",{className:"flex items-center justify-center h-32",children:o.jsx(Ae,{className:"animate-spin text-muted-foreground",size:24})}),t[0]=e):e=t[0],e}function Xi(t){return({error:e})=>e?.message?.includes("Method not found")||e?.code===-32601?o.jsx("div",{className:"flex-1 overflow-auto px-4 py-3 space-y-1",children:o.jsx("div",{className:"flex items-center justify-center h-32 text-sm text-muted-foreground",children:t})}):o.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center h-full p-6 text-center space-y-4",children:[o.jsx("div",{className:"bg-destructive/10 p-3 rounded-full",children:o.jsx(Wl,{className:"h-6 w-6 text-destructive"})}),o.jsxs("div",{className:"space-y-2",children:[o.jsx("h3",{className:"text-lg font-medium",children:"Something went wrong"}),o.jsx("p",{className:"text-sm text-muted-foreground max-w-xs mx-auto",children:e?.message?e.message.length>200?`${e.message.slice(0,200)}...`:e.message:"An unexpected error occurred"})]})]})}function Rd(t){const e=W.c(23),{item:s,isSelected:i,onToggle:r,disabled:n}=t,a=n?"cursor-not-allowed opacity-50":"cursor-pointer",l=i?"bg-accent/25":"hover:bg-muted/50";let h;e[0]!==a||e[1]!==l?(h=ie("flex items-start gap-3 p-4 rounded-lg transition-colors",a,l),e[0]=a,e[1]=l,e[2]=h):h=e[2];let c;e[3]!==s.name?(c=o.jsx("p",{className:"text-sm font-medium leading-none truncate",children:s.name}),e[3]=s.name,e[4]=c):c=e[4];let u;e[5]!==s.tags?(u=s.tags&&o.jsx("span",{className:"shrink-0",children:s.tags}),e[5]=s.tags,e[6]=u):u=e[6];let d;e[7]!==c||e[8]!==u?(d=o.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[c,u]}),e[7]=c,e[8]=u,e[9]=d):d=e[9];let f;e[10]!==s.description?(f=s.description&&o.jsx("p",{className:"text-xs text-muted-foreground line-clamp-2",children:s.description}),e[10]=s.description,e[11]=f):f=e[11];let _;e[12]!==d||e[13]!==f?(_=o.jsxs("div",{className:"flex-1 min-w-0 space-y-2",children:[d,f]}),e[12]=d,e[13]=f,e[14]=_):_=e[14];let m;e[15]!==n||e[16]!==i||e[17]!==r?(m=o.jsx(bh,{checked:i,onCheckedChange:r,disabled:n,className:"mt-0.5"}),e[15]=n,e[16]=i,e[17]=r,e[18]=m):m=e[18];let p;return e[19]!==h||e[20]!==_||e[21]!==m?(p=o.jsxs("label",{className:h,children:[_,m]}),e[19]=h,e[20]=_,e[21]=m,e[22]=p):p=e[22],p}function un(t){const e=W.c(13),{items:s,selections:i,onToggle:r,emptyMessage:n,disabled:a}=t;let l,h,c;if(e[0]!==a||e[1]!==n||e[2]!==s||e[3]!==r||e[4]!==i){c=Symbol.for("react.early_return_sentinel");e:{const d=s.map(Dd);if(s.length===0){let f;e[8]!==n?(f=o.jsx("div",{className:"flex-1 overflow-auto px-4 py-3 space-y-1",children:o.jsx("div",{className:"flex items-center justify-center h-32 text-sm text-muted-foreground",children:n})}),e[8]=n,e[9]=f):f=e[9],c=f;break e}l="flex-1 overflow-auto px-4 py-3 space-y-1",h=s.map(f=>o.jsx(Rd,{item:f,isSelected:i===null||i?.includes(f.id),onToggle:()=>r(f.id,d),disabled:a},f.id))}e[0]=a,e[1]=n,e[2]=s,e[3]=r,e[4]=i,e[5]=l,e[6]=h,e[7]=c}else l=e[5],h=e[6],c=e[7];if(c!==Symbol.for("react.early_return_sentinel"))return c;let u;return e[10]!==l||e[11]!==h?(u=o.jsx("div",{className:l,children:h}),e[10]=l,e[11]=h,e[12]=u):u=e[12],u}function Dd(t){return t.id}function Md(t){const e=W.c(13),{connectionId:s,selections:i,onToggle:r,disabled:n}=t,{org:a}=xe();let l;e[0]!==s||e[1]!==a.id||e[2]!==a.slug?(l={connectionId:s,orgId:a.id,orgSlug:a.slug},e[0]=s,e[1]=a.id,e[2]=a.slug,e[3]=l):l=e[3];const h=We(l);let c;e[4]!==h?(c={client:h},e[4]=h,e[5]=c):c=e[5];const{data:u}=Oc(c);let d;e[6]!==u.tools?(d=u.tools.map(Id),e[6]=u.tools,e[7]=d):d=e[7];const f=d;let _;return e[8]!==n||e[9]!==f||e[10]!==r||e[11]!==i?(_=o.jsx(un,{items:f,selections:i,onToggle:r,emptyMessage:"No tools available",disabled:n}),e[8]=n,e[9]=f,e[10]=r,e[11]=i,e[12]=_):_=e[12],_}function Id(t){return{id:t.name,name:t.name,description:t.description,tags:o.jsx(dh,{annotations:t.annotations,_meta:t._meta})}}function Ad(t){const e=W.c(13),{connectionId:s,selections:i,onToggle:r,disabled:n}=t,{org:a}=xe();let l;e[0]!==s||e[1]!==a.id||e[2]!==a.slug?(l={connectionId:s,orgId:a.id,orgSlug:a.slug},e[0]=s,e[1]=a.id,e[2]=a.slug,e[3]=l):l=e[3];const h=We(l);let c;e[4]!==h?(c={client:h},e[4]=h,e[5]=c):c=e[5];const{data:u}=lh(c);let d;e[6]!==u.resources?(d=u.resources.map(Bd),e[6]=u.resources,e[7]=d):d=e[7];const f=d;let _;return e[8]!==n||e[9]!==f||e[10]!==r||e[11]!==i?(_=o.jsx(un,{items:f,selections:i,onToggle:r,emptyMessage:"No resources available",disabled:n}),e[8]=n,e[9]=f,e[10]=r,e[11]=i,e[12]=_):_=e[12],_}function Bd(t){return{id:t.name||t.uri,name:t.name||t.uri,description:t.description}}function Pd(t){const e=W.c(13),{connectionId:s,selections:i,onToggle:r,disabled:n}=t,{org:a}=xe();let l;e[0]!==s||e[1]!==a.id||e[2]!==a.slug?(l={connectionId:s,orgId:a.id,orgSlug:a.slug},e[0]=s,e[1]=a.id,e[2]=a.slug,e[3]=l):l=e[3];const h=We(l);let c;e[4]!==h?(c={client:h},e[4]=h,e[5]=c):c=e[5];const{data:u}=Sh(c);let d;e[6]!==u.prompts?(d=u.prompts.map(Ld),e[6]=u.prompts,e[7]=d):d=e[7];const f=d;let _;return e[8]!==n||e[9]!==f||e[10]!==r||e[11]!==i?(_=o.jsx(un,{items:f,selections:i,onToggle:r,emptyMessage:"No prompts available",disabled:n}),e[8]=n,e[9]=f,e[10]=r,e[11]=i,e[12]=_):_=e[12],_}function Ld(t){return{id:t.name,name:t.name,description:t.description}}function Od(t){const e=W.c(54),{currentConnection:s,activeTab:i,selectedId:r,formData:n,toggleTool:a,toggleResource:l,togglePrompt:h,toggleAllTools:c,toggleAllResources:u,toggleAllPrompts:d,onTabChange:f}=t,_=n[r],m=i==="tools"?_?.tools===null:i==="resources"?_?.resources===null:_?.prompts===null;let p;e[0]!==i||e[1]!==r||e[2]!==d||e[3]!==u||e[4]!==c?(p=()=>{i==="tools"?c(r):i==="resources"?u(r):d(r)},e[0]=i,e[1]=r,e[2]=d,e[3]=u,e[4]=c,e[5]=p):p=e[5];const g=p;let v;e[6]!==s.icon||e[7]!==s.title?(v=o.jsx(_s,{icon:s.icon,name:s.title,size:"sm",className:"shrink-0"}),e[6]=s.icon,e[7]=s.title,e[8]=v):v=e[8];let x;e[9]!==s.title?(x=o.jsx("h2",{className:"text-base font-semibold truncate",children:s.title}),e[9]=s.title,e[10]=x):x=e[10];let S;e[11]!==s.description?(S=s.description&&o.jsx("p",{className:"text-xs text-muted-foreground truncate",children:s.description}),e[11]=s.description,e[12]=S):S=e[12];let b;e[13]!==x||e[14]!==S?(b=o.jsxs("div",{className:"flex-1 min-w-0",children:[x,S]}),e[13]=x,e[14]=S,e[15]=b):b=e[15];let y;e[16]!==v||e[17]!==b?(y=o.jsx("div",{className:"px-6 pt-5 pb-4 shrink-0",children:o.jsxs("div",{className:"flex items-center gap-3",children:[v,b]})}),e[16]=v,e[17]=b,e[18]=y):y=e[18];let N;e[19]===Symbol.for("react.memo_cache_sentinel")?(N=[{id:"tools",label:"Tools"},{id:"resources",label:"Resources"},{id:"prompts",label:"Prompts"}],e[19]=N):N=e[19];let C;e[20]!==f?(C=I=>f(I),e[20]=f,e[21]=C):C=e[21];let D;e[22]!==i||e[23]!==C?(D=o.jsx(xh,{tabs:N,activeTab:i,onTabChange:C}),e[22]=i,e[23]=C,e[24]=D):D=e[24];const R=m?"Deselect all":"Select all";let B;e[25]!==g||e[26]!==R?(B=o.jsx("button",{type:"button",onClick:g,className:"text-xs text-muted-foreground hover:text-foreground transition-colors",children:R}),e[25]=g,e[26]=R,e[27]=B):B=e[27];let M;e[28]!==B||e[29]!==D?(M=o.jsxs("div",{className:"flex items-center justify-between px-6 py-3 border-t border-border shrink-0",children:[D,B]}),e[28]=B,e[29]=D,e[30]=M):M=e[30];let E;e[31]!==i||e[32]!==n||e[33]!==r||e[34]!==a?(E=i==="tools"&&o.jsx(Ut,{fallback:Xi("Tools not supported by this server"),children:o.jsx(P.Suspense,{fallback:o.jsx(mi,{}),children:o.jsx(Md,{connectionId:r,selections:n[r]?n[r].tools:[],onToggle:(I,A)=>a(r,I,A)})})}),e[31]=i,e[32]=n,e[33]=r,e[34]=a,e[35]=E):E=e[35];let k;e[36]!==i||e[37]!==n||e[38]!==r||e[39]!==l?(k=i==="resources"&&o.jsx(Ut,{fallback:Xi("Resources not supported by this server"),children:o.jsx(P.Suspense,{fallback:o.jsx(mi,{}),children:o.jsx(Ad,{connectionId:r,selections:n[r]?n[r].resources:[],onToggle:(I,A)=>l(r,I,A)})})}),e[36]=i,e[37]=n,e[38]=r,e[39]=l,e[40]=k):k=e[40];let w;e[41]!==i||e[42]!==n||e[43]!==r||e[44]!==h?(w=i==="prompts"&&o.jsx(Ut,{fallback:Xi("Prompts not supported by this server"),children:o.jsx(P.Suspense,{fallback:o.jsx(mi,{}),children:o.jsx(Pd,{connectionId:r,selections:n[r]?n[r].prompts:[],onToggle:(I,A)=>h(r,I,A)})})}),e[41]=i,e[42]=n,e[43]=r,e[44]=h,e[45]=w):w=e[45];let j;e[46]!==E||e[47]!==k||e[48]!==w?(j=o.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[E,k,w]}),e[46]=E,e[47]=k,e[48]=w,e[49]=j):j=e[49];let T;return e[50]!==M||e[51]!==j||e[52]!==y?(T=o.jsxs(o.Fragment,{children:[y,M,j]}),e[50]=M,e[51]=j,e[52]=y,e[53]=T):T=e[53],T}function zd(t){const e=W.c(11),{connectionId:s,onAuthenticate:i,children:r}=t;let n;e[0]!==s?(n={connectionId:s},e[0]=s,e[1]=n):n=e[1];const a=va(n);if(a.supportsOAuth&&!a.isAuthenticated){let c;e[2]===Symbol.for("react.memo_cache_sentinel")?(c=o.jsx("div",{className:"flex items-center justify-center size-12 rounded-full bg-muted",children:o.jsx(Mc,{size:22,className:"text-muted-foreground"})}),e[2]=c):c=e[2];let u;e[3]===Symbol.for("react.memo_cache_sentinel")?(u=o.jsxs("div",{className:"space-y-1",children:[o.jsx("p",{className:"text-sm font-medium",children:"Authorization required"}),o.jsx("p",{className:"text-xs text-muted-foreground max-w-xs",children:"This connection needs to be authorized before you can configure its tools and resources."})]}),e[3]=u):u=e[3];let d;e[4]!==s||e[5]!==i?(d=i&&o.jsx(ne,{variant:"outline",size:"sm",onClick:()=>i(s),children:"Authorize"}),e[4]=s,e[5]=i,e[6]=d):d=e[6];let f;return e[7]!==d?(f=o.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center gap-4 p-8 text-center",children:[c,u,d]}),e[7]=d,e[8]=f):f=e[8],f}let h;return e[9]!==r?(h=o.jsx(o.Fragment,{children:r}),e[9]=r,e[10]=h):h=e[10],h}function $d(t){const e={};for(const s of t)e[s.connection_id]={tools:s.selected_tools,resources:s.selected_resources??null,prompts:s.selected_prompts??null};return e}function Un(t){return Object.entries(t).map(([e,s])=>({connection_id:e,selected_tools:s.tools,selected_resources:s.resources,selected_prompts:s.prompts}))}function Fd(t,e){return e.type==="SET_ACTIVE_TAB"?{...t,activeTab:e.payload}:t}function Hd(t){const e=W.c(49),{open:s,onOpenChange:i,selectedId:r,form:n,connections:a,onAuthenticate:l}=t;let h;e[0]===Symbol.for("react.memo_cache_sentinel")?(h={activeTab:"tools"},e[0]=h):h=e[0];const[c,u]=P.useReducer(Fd,h),d=ln(r??"");let f;e[1]!==a?(f=a??[],e[1]=a,e[2]=f):f=e[2];let _;e[3]!==f?(_=$d(f),e[3]=f,e[4]=_):_=e[4];const m=_;let p;e[5]!==n||e[6]!==m?(p=(V,J,Z,F)=>{const $=m[V]?.[J];let H;$===null?H=F.filter(L=>L!==Z):$?.includes(Z)?H=$.filter(L=>L!==Z):(H=[...$??[],Z],H.length===F.length&&(H=null));const Q={...m};Q[V]?Q[V]={...Q[V]}:Q[V]={tools:null,resources:null,prompts:null},Q[V][J]=H,n.setValue("connections",Un(Q),{shouldDirty:!0,shouldTouch:!0})},e[5]=n,e[6]=m,e[7]=p):p=e[7];const g=p;let v;e[8]!==n||e[9]!==m?(v=(V,J)=>{const F=m[V]?.[J]===null?[]:null,$={...m};$[V]?$[V]={...$[V]}:$[V]={tools:null,resources:null,prompts:null},$[V][J]=F,n.setValue("connections",Un($),{shouldDirty:!0,shouldTouch:!0})},e[8]=n,e[9]=m,e[10]=v):v=e[10];const x=v;let S;e[11]!==g?(S=(V,J,Z)=>g(V,"tools",J,Z),e[11]=g,e[12]=S):S=e[12];const b=S;let y;e[13]!==g?(y=(V,J,Z)=>g(V,"resources",J,Z),e[13]=g,e[14]=y):y=e[14];const N=y;let C;e[15]!==g?(C=(V,J,Z)=>g(V,"prompts",J,Z),e[15]=g,e[16]=C):C=e[16];const D=C;let R;e[17]!==x?(R=V=>x(V,"tools"),e[17]=x,e[18]=R):R=e[18];const B=R;let M;e[19]!==x?(M=V=>x(V,"resources"),e[19]=x,e[20]=M):M=e[20];const E=M;let k;e[21]!==x?(k=V=>x(V,"prompts"),e[21]=x,e[22]=k):k=e[22];const w=k;if(!r||!d)return null;let j;e[23]===Symbol.for("react.memo_cache_sentinel")?(j=o.jsx(mi,{}),e[23]=j):j=e[23];let T;e[24]===Symbol.for("react.memo_cache_sentinel")?(T=V=>u({type:"SET_ACTIVE_TAB",payload:V}),e[24]=T):T=e[24];let I;e[25]!==d||e[26]!==c.activeTab||e[27]!==m||e[28]!==r||e[29]!==w||e[30]!==E||e[31]!==B||e[32]!==D||e[33]!==N||e[34]!==b?(I=o.jsx(Od,{currentConnection:d,activeTab:c.activeTab,selectedId:r,formData:m,toggleTool:b,toggleResource:N,togglePrompt:D,toggleAllTools:B,toggleAllResources:E,toggleAllPrompts:w,onTabChange:T},r),e[25]=d,e[26]=c.activeTab,e[27]=m,e[28]=r,e[29]=w,e[30]=E,e[31]=B,e[32]=D,e[33]=N,e[34]=b,e[35]=I):I=e[35];let A;e[36]!==l||e[37]!==r||e[38]!==I?(A=o.jsx(P.Suspense,{fallback:j,children:o.jsx(zd,{connectionId:r,onAuthenticate:l,children:I})}),e[36]=l,e[37]=r,e[38]=I,e[39]=A):A=e[39];let O;e[40]!==i?(O=o.jsx(mh,{className:"px-6 py-4 border-t border-border shrink-0",children:o.jsx(ne,{variant:"outline",onClick:()=>i(!1),children:"Done"})}),e[40]=i,e[41]=O):O=e[41];let q;e[42]!==A||e[43]!==O?(q=o.jsxs(cn,{className:"sm:max-w-2xl h-[75vh] max-h-[75vh] flex flex-col p-0 gap-0 overflow-hidden w-[95vw]",children:[A,O]}),e[42]=A,e[43]=O,e[44]=q):q=e[44];let U;return e[45]!==i||e[46]!==s||e[47]!==q?(U=o.jsx(hn,{open:s,onOpenChange:i,children:q}),e[45]=i,e[46]=s,e[47]=q,e[48]=U):U=e[48],U}const Ji={tools:null,resources:null,prompts:null},Wd=Ul.pick({status:!0,title:!0,description:!0,icon:!0,metadata:!0,connections:!0});function Ud(t){const s=new TextEncoder().encode(t),i=Array.from(s,r=>String.fromCharCode(r)).join("");return btoa(i)}function Vd(t){const e=W.c(11),{url:s,agentId:i}=t,[r,n]=P.useState(!1);let a;e[0]!==i||e[1]!==s?(a=async()=>{we("agent_connect_action",{agent_id:i,action:"copy_url"}),await navigator.clipboard.writeText(s),n(!0),ge.success("Agent URL copied to clipboard"),setTimeout(()=>n(!1),2e3)},e[0]=i,e[1]=s,e[2]=a):a=e[2];const l=a;let h;e[3]!==r?(h=r?o.jsx(Pi,{size:20,className:"text-green-600"}):o.jsx(Di,{size:20}),e[3]=r,e[4]=h):h=e[4];const c=r?"Copied!":"Copy URL";let u;e[5]!==c?(u=o.jsx("span",{className:"text-xs font-medium",children:c}),e[5]=c,e[6]=u):u=e[6];let d;return e[7]!==l||e[8]!==h||e[9]!==u?(d=o.jsxs(ne,{type:"button",variant:"outline",onClick:l,className:"h-auto py-3 px-4 flex flex-col items-center gap-2",children:[h,u]}),e[7]=l,e[8]=h,e[9]=u,e[10]=d):d=e[10],d}function Kd(t){const e=W.c(8),{url:s,serverName:i,agentId:r}=t;let n;e[0]!==r||e[1]!==i||e[2]!==s?(n=()=>{we("agent_connect_action",{agent_id:r,action:"install_cursor"});const u=xa(i),f=Ud(JSON.stringify({type:"http",url:s,headers:{"x-mesh-client":"Cursor"}},null,2)),_=`cursor://anysphere.cursor-deeplink/mcp/install?name=${encodeURIComponent(u)}&config=${encodeURIComponent(f)}`;window.open(_,"_blank"),ge.success("Opening Cursor...")},e[0]=r,e[1]=i,e[2]=s,e[3]=n):n=e[3];const a=n;let l,h;e[4]===Symbol.for("react.memo_cache_sentinel")?(l=o.jsx("img",{src:"/logos/cursor.svg",alt:"Cursor",className:"h-5 w-5",style:{filter:"brightness(0) saturate(100%) invert(11%) sepia(8%) saturate(785%) hue-rotate(1deg) brightness(95%) contrast(89%)"}}),h=o.jsx("span",{className:"text-xs font-medium",children:"Install on Cursor"}),e[4]=l,e[5]=h):(l=e[4],h=e[5]);let c;return e[6]!==a?(c=o.jsxs(ne,{type:"button",variant:"outline",onClick:a,className:"h-auto py-3 px-4 flex flex-col items-center gap-2",children:[l,h]}),e[6]=a,e[7]=c):c=e[7],c}function qd(t){const e=W.c(12),{url:s,serverName:i,agentId:r}=t,[n,a]=P.useState(!1);let l;e[0]!==r||e[1]!==i||e[2]!==s?(l=async()=>{we("agent_connect_action",{agent_id:r,action:"install_claude_code"});const _=xa(i),p=JSON.stringify({type:"http",url:s,headers:{"x-mesh-client":"Claude Code"}},null,2),g=`claude mcp add-json "${_}" '${p.replace(/'/g,"'\\''")}' --scope user`;await navigator.clipboard.writeText(g),a(!0),ge.success("Claude Code command copied to clipboard"),setTimeout(()=>a(!1),2e3)},e[0]=r,e[1]=i,e[2]=s,e[3]=l):l=e[3];const h=l;let c;e[4]!==n?(c=n?o.jsx(Pi,{size:20,className:"text-green-600"}):o.jsx("img",{src:"/logos/Claude Code.svg",alt:"Claude Code",className:"h-5 w-5",style:{filter:"brightness(0) saturate(100%) invert(55%) sepia(31%) saturate(1264%) hue-rotate(331deg) brightness(92%) contrast(86%)"}}),e[4]=n,e[5]=c):c=e[5];const u=n?"Copied!":"Install on Claude Code";let d;e[6]!==u?(d=o.jsx("span",{className:"text-xs font-medium",children:u}),e[6]=u,e[7]=d):d=e[7];let f;return e[8]!==h||e[9]!==c||e[10]!==d?(f=o.jsxs(ne,{type:"button",variant:"outline",onClick:h,className:"h-auto py-3 px-4 flex flex-col items-center gap-2",children:[c,d]}),e[8]=h,e[9]=c,e[10]=d,e[11]=f):f=e[11],f}function Gd({virtualMcp:t}){const{org:e}=xe(),s=We({connectionId:Ot,orgId:e.id,orgSlug:e.slug}),[i,r]=P.useState(null),[n,a]=P.useState(!1),[l,h]=P.useState(!1),c=t.id,u=t.title||`agent-${c.slice(0,8)}`,d=i?`bunx @decocms/typegen@latest --mcp ${c} --key ${i} --output client.ts`:`bunx @decocms/typegen@latest --mcp ${c} --key <api-key> --output client.ts`,f=async()=>{a(!0);try{const p=(await s.callTool({name:"API_KEY_CREATE",arguments:{name:`typegen-${u}`,permissions:{[c]:["*"]}}})).structuredContent?.key;if(!p)throw new Error("No key in response");r(p),we("agent_typegen_key_generated",{agent_id:c})}catch{we("agent_typegen_key_failed",{agent_id:c}),ge.error("Failed to generate API key")}finally{a(!1)}},_=async()=>{we("agent_connect_action",{agent_id:c,action:"typegen_copy_command",has_api_key:!!i}),await navigator.clipboard.writeText(d),h(!0),ge.success("Command copied to clipboard"),setTimeout(()=>h(!1),2e3)};return o.jsxs("div",{className:"flex min-w-0 flex-col gap-3",children:[o.jsxs("div",{className:"flex items-start justify-between gap-3",children:[o.jsxs("div",{className:"flex flex-col gap-0.5",children:[o.jsx("h4",{className:"text-sm font-medium text-foreground",children:"Generate typed client"}),o.jsxs("p",{className:"text-xs text-muted-foreground",children:["Introspects this agent and writes a typed"," ",o.jsx("code",{className:"font-mono",children:"client.ts"})," you can import directly."]})]}),!i&&o.jsxs(ne,{type:"button",variant:"outline",size:"sm",className:"shrink-0 gap-1.5",onClick:f,disabled:n,children:[n?o.jsx(Ae,{size:14,className:"animate-spin"}):o.jsx(vh,{size:14}),o.jsx("span",{children:n?"Generating…":"Generate API key"})]})]}),i&&o.jsx("p",{className:"rounded-md border border-amber-200 bg-amber-50 px-3 py-2 text-xs text-amber-700",children:"Store this key securely — it won't be shown again."}),o.jsx("p",{className:"text-xs font-medium text-muted-foreground",children:"Generate client"}),o.jsx("div",{className:"rounded-md border border-input bg-muted/50 px-3 py-2.5",children:o.jsxs("div",{className:"flex items-start gap-2",children:[o.jsx("code",{className:"min-w-0 flex-1 break-all font-mono text-xs text-muted-foreground",children:d}),o.jsx(ne,{type:"button",variant:"ghost",size:"icon",className:"size-6 shrink-0",onClick:_,children:l?o.jsx(Pi,{size:12,className:"text-green-600"}):o.jsx(Di,{size:12})})]})}),o.jsx("p",{className:"text-xs font-medium text-muted-foreground",children:"Runtime variables"}),o.jsx(Yd,{apiKey:i,agentId:c})]})}function Yd(t){const e=W.c(21),{apiKey:s,agentId:i}=t,[r,n]=P.useState(!1),a=window.location.origin,l=s?`MESH_API_KEY=${s}`:"MESH_API_KEY=<api-key>",h=`MESH_BASE_URL=${a}`,c=`${l}
4
4
  ${h}`;let u;e[0]!==i||e[1]!==s||e[2]!==c?(u=async()=>{we("agent_connect_action",{agent_id:i,action:"typegen_copy_env",has_api_key:!!s}),await navigator.clipboard.writeText(c),n(!0),setTimeout(()=>n(!1),2e3)},e[0]=i,e[1]=s,e[2]=c,e[3]=u):u=e[3];const d=u,f=!s;let _;e[4]!==f?(_=ie({"opacity-50":f}),e[4]=f,e[5]=_):_=e[5];let m;e[6]!==l||e[7]!==_?(m=o.jsx("span",{className:_,children:l}),e[6]=l,e[7]=_,e[8]=m):m=e[8];let p,g;e[9]===Symbol.for("react.memo_cache_sentinel")?(p=o.jsx("br",{}),g=o.jsx("span",{children:h}),e[9]=p,e[10]=g):(p=e[9],g=e[10]);let v;e[11]!==m?(v=o.jsxs("code",{className:"min-w-0 flex-1 font-mono text-xs text-muted-foreground",children:[m,p,g]}),e[11]=m,e[12]=v):v=e[12];let x;e[13]!==r?(x=r?o.jsx(Pi,{size:12,className:"text-green-600"}):o.jsx(Di,{size:12}),e[13]=r,e[14]=x):x=e[14];let S;e[15]!==d||e[16]!==x?(S=o.jsx(ne,{type:"button",variant:"ghost",size:"icon",className:"size-6 shrink-0",onClick:d,children:x}),e[15]=d,e[16]=x,e[17]=S):S=e[17];let b;return e[18]!==v||e[19]!==S?(b=o.jsx("div",{className:"rounded-md border border-input bg-muted/50 px-3 py-2.5",children:o.jsxs("div",{className:"flex items-start gap-2",children:[v,S]})}),e[18]=v,e[19]=S,e[20]=b):b=e[20],b}function Xd(t){const e=W.c(3),{virtualMcp:s}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=o.jsx("div",{className:"h-20 animate-pulse rounded-md bg-muted"}),e[0]=i):i=e[0];let r;return e[1]!==s?(r=o.jsx(P.Suspense,{fallback:i,children:o.jsx(Gd,{virtualMcp:s})}),e[1]=s,e[2]=r):r=e[2],r}function Jd(t){const e=W.c(37),{open:s,onOpenChange:i,virtualMcp:r}=t,{org:n}=xe(),a=`/api/${n.slug}/mcp/virtual-mcp/${r.id}`;let l;e[0]!==a?(l=new URL(a,window.location.origin),e[0]=a,e[1]=l):l=e[1];const h=l;let c;e[2]!==r.id||e[3]!==r.title?(c=r.title||`agent-${r.id?.slice(0,8)??"default"}`,e[2]=r.id,e[3]=r.title,e[4]=c):c=e[4];const u=c,d=ma();let f;e[5]!==r.id||e[6]!==h.href?(f=o.jsx(Vd,{url:h.href,agentId:r.id}),e[5]=r.id,e[6]=h.href,e[7]=f):f=e[7];let _,m;e[8]!==u||e[9]!==r.id||e[10]!==h.href?(_=o.jsx(Kd,{url:h.href,serverName:u,agentId:r.id}),m=o.jsx(qd,{url:h.href,serverName:u,agentId:r.id}),e[8]=u,e[9]=r.id,e[10]=h.href,e[11]=_,e[12]=m):(_=e[11],m=e[12]);let p;e[13]!==f||e[14]!==_||e[15]!==m?(p=o.jsx("div",{className:"flex flex-col gap-3 pt-2",children:o.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[f,_,m]})}),e[13]=f,e[14]=_,e[15]=m,e[16]=p):p=e[16];let g;e[17]===Symbol.for("react.memo_cache_sentinel")?(g=o.jsx("div",{className:"border-t border-border"}),e[17]=g):g=e[17];let v;e[18]!==r?(v=o.jsx(Xd,{virtualMcp:r}),e[18]=r,e[19]=v):v=e[19];let x;e[20]!==p||e[21]!==v?(x=o.jsxs("div",{className:"flex flex-col gap-6",children:[p,g,v]}),e[20]=p,e[21]=v,e[22]=x):x=e[22];const S=x;if(d){let C;e[23]===Symbol.for("react.memo_cache_sentinel")?(C=o.jsx(Ch,{className:"mt-4 mb-4 text-base font-semibold",children:"Connect"}),e[23]=C):C=e[23];let D;e[24]!==S?(D=o.jsx(kh,{children:o.jsxs("div",{className:"flex-1 overflow-y-auto px-4 pb-6 [touch-action:pan-y]",children:[C,S]})}),e[24]=S,e[25]=D):D=e[25];let R;return e[26]!==i||e[27]!==s||e[28]!==D?(R=o.jsx(Nh,{open:s,onOpenChange:i,children:D}),e[26]=i,e[27]=s,e[28]=D,e[29]=R):R=e[29],R}let b;e[30]===Symbol.for("react.memo_cache_sentinel")?(b=o.jsx(Ea,{children:o.jsx(Ta,{children:"Connect"})}),e[30]=b):b=e[30];let y;e[31]!==S?(y=o.jsxs(cn,{className:"max-h-[80vh] overflow-y-auto sm:max-w-2xl",children:[b,S]}),e[31]=S,e[32]=y):y=e[32];let N;return e[33]!==i||e[34]!==s||e[35]!==y?(N=o.jsx(hn,{open:s,onOpenChange:i,children:y}),e[33]=i,e[34]=s,e[35]=y,e[36]=N):N=e[36],N}function Zd(t,e){switch(e.type){case"SET_SHARE_DIALOG_OPEN":return{...t,shareDialogOpen:e.payload};case"SET_ADD_DIALOG_OPEN":return{...t,addDialogOpen:e.payload};case"OPEN_SETTINGS":return{...t,settingsDialogOpen:!0,settingsConnectionId:e.payload};case"CLOSE_SETTINGS":return{...t,settingsDialogOpen:!1,settingsConnectionId:null};default:return t}}function Qd(t){const e=W.c(22),{connection_id:s,usedConnectionIds:i,onOpenSettings:r,onRemove:n,onAuthenticate:a,onSwitchInstance:l,onNewInstance:h}=t,c=ln(s),{org:u}=xe();if(!c)return null;let d;e[0]!==c?(d=fh(c),e[0]=c,e[1]=d):d=e[1];const f=d;let _;e[2]!==s?(_=o.jsx(iu,{connection_id:s}),e[2]=s,e[3]=_):_=e[3];let m;e[4]!==c.app_name||e[5]!==c.connection_type||e[6]!==c.description||e[7]!==c.icon||e[8]!==c.title||e[9]!==s||e[10]!==a||e[11]!==h||e[12]!==r||e[13]!==n||e[14]!==l||e[15]!==u.slug||e[16]!==f||e[17]!==i?(m=o.jsx(su,{connection_id:s,connectionTitle:c.title,connectionDescription:c.description,connectionIcon:c.icon,connectionType:c.connection_type,slug:f,orgSlug:u.slug,appName:c.app_name,usedConnectionIds:i,onOpenSettings:r,onRemove:n,onAuthenticate:a,onSwitchInstance:l,onNewInstance:h}),e[4]=c.app_name,e[5]=c.connection_type,e[6]=c.description,e[7]=c.icon,e[8]=c.title,e[9]=s,e[10]=a,e[11]=h,e[12]=r,e[13]=n,e[14]=l,e[15]=u.slug,e[16]=f,e[17]=i,e[18]=m):m=e[18];let p;return e[19]!==_||e[20]!==m?(p=o.jsx(P.Suspense,{fallback:_,children:m}),e[19]=_,e[20]=m,e[21]=p):p=e[21],p}const Vn="__new_instance__";async function eu(t,e){const s=t?.idToken??null;if(s){const r=Kn(s);if(r)return r}const i=t?.userinfoEndpoint??null;if(i)try{const r=await fetch(i,{headers:{Authorization:`Bearer ${e}`}});if(r.ok){const n=await r.json(),a=typeof n.email=="string"?n.email:typeof n.upn=="string"?n.upn:typeof n.preferred_username=="string"?n.preferred_username:null;if(a)return a}}catch{}return Kn(e)}function Kn(t){try{const e=t.split(".");if(e.length===3&&e[1]){const s=JSON.parse(atob(e[1].replace(/-/g,"+").replace(/_/g,"/")));if(typeof s.email=="string")return s.email;if(typeof s.upn=="string")return s.upn;if(typeof s.preferred_username=="string")return s.preferred_username}}catch{}return null}function tu(t){const e=W.c(23),{appName:s,connectionId:i,usedConnectionIds:r,onSwitchInstance:n,onNewInstance:a}=t;let l;e[0]!==s?(l={filters:[{column:"app_name",value:s}]},e[0]=s,e[1]=l):l=e[1];const h=Bi(l);if(h.length<=1)return null;let c;e[2]!==i||e[3]!==a||e[4]!==n?(c=p=>{p===Vn?a?.():n(i,p)},e[2]=i,e[3]=a,e[4]=n,e[5]=c):c=e[5];let u;e[6]===Symbol.for("react.memo_cache_sentinel")?(u=o.jsx(ns,{size:"sm",className:"w-auto text-xs gap-1 px-2 shadow-none",children:o.jsx(os,{})}),e[6]=u):u=e[6];let d;if(e[7]!==i||e[8]!==h||e[9]!==r){let p;e[11]!==i||e[12]!==r?(p=g=>o.jsx(Pt,{value:g.id,className:"text-xs",disabled:g.id!==i&&r.has(g.id),children:g.title},g.id),e[11]=i,e[12]=r,e[13]=p):p=e[13],d=h.map(p),e[7]=i,e[8]=h,e[9]=r,e[10]=d}else d=e[10];let f;e[14]!==a?(f=a&&o.jsx(Pt,{value:Vn,className:"text-xs text-muted-foreground",children:"+ New instance"}),e[14]=a,e[15]=f):f=e[15];let _;e[16]!==d||e[17]!==f?(_=o.jsxs(as,{children:[d,f]}),e[16]=d,e[17]=f,e[18]=_):_=e[18];let m;return e[19]!==i||e[20]!==c||e[21]!==_?(m=o.jsxs(rs,{value:i,onValueChange:c,children:[u,_]}),e[19]=i,e[20]=c,e[21]=_,e[22]=m):m=e[22],m}function su(t){const e=W.c(55),{connection_id:s,connectionTitle:i,connectionDescription:r,connectionIcon:n,connectionType:a,slug:l,orgSlug:h,appName:c,usedConnectionIds:u,onOpenSettings:d,onRemove:f,onAuthenticate:_,onSwitchInstance:m,onNewInstance:p}=t;let g;e[0]!==s?(g={connectionId:s},e[0]=s,e[1]=g):g=e[1];const v=va(g),S=!(a==="VIRTUAL")&&v.supportsOAuth&&!v.isAuthenticated,b=S?"border-destructive/50 bg-destructive/5":"border-border";let y;e[2]!==b?(y=ie("rounded-xl border overflow-hidden transition-colors",b),e[2]=b,e[3]=y):y=e[3];let N;e[4]!==h||e[5]!==l?(N={org:h,appSlug:l},e[4]=h,e[5]=l,e[6]=N):N=e[6];let C;e[7]!==n||e[8]!==i?(C=o.jsx(_s,{icon:n,name:i,size:"sm",className:"shrink-0"}),e[7]=n,e[8]=i,e[9]=C):C=e[9];let D;e[10]!==i?(D=o.jsx("p",{className:"text-sm font-medium truncate",children:i}),e[10]=i,e[11]=D):D=e[11];let R;e[12]!==r||e[13]!==S?(R=S?o.jsx("span",{className:"text-xs text-destructive font-medium",children:"Needs authorization"}):r&&o.jsx("p",{className:"text-xs text-muted-foreground truncate",children:r}),e[12]=r,e[13]=S,e[14]=R):R=e[14];let B;e[15]!==D||e[16]!==R?(B=o.jsxs("div",{className:"flex-1 min-w-0",children:[D,R]}),e[15]=D,e[16]=R,e[17]=B):B=e[17];let M;e[18]!==s||e[19]!==S||e[20]!==_?(M=S?o.jsx(ne,{variant:"outline",size:"sm",className:"h-7 text-xs shrink-0",onClick:F=>{F.preventDefault(),F.stopPropagation(),_(s)},children:"Authorize"}):o.jsxs(Ge,{delayDuration:0,children:[o.jsx(Ye,{asChild:!0,children:o.jsx("span",{className:"inline-flex items-center justify-center rounded-md h-7 w-7 hover:bg-accent text-muted-foreground shrink-0 transition-colors",children:o.jsx(ph,{size:16})})}),o.jsx(Xe,{side:"bottom",children:"Connection settings"})]}),e[18]=s,e[19]=S,e[20]=_,e[21]=M):M=e[21];let E;e[22]!==N||e[23]!==C||e[24]!==B||e[25]!==M?(E=o.jsxs(ql,{to:"/$org/settings/connections/$appSlug",params:N,className:"flex items-center gap-3 px-4 py-3 cursor-pointer hover:bg-muted/50 transition-colors",children:[C,B,M]}),e[22]=N,e[23]=C,e[24]=B,e[25]=M,e[26]=E):E=e[26];let k;e[27]!==c||e[28]!==s||e[29]!==p||e[30]!==m||e[31]!==u?(k=c&&o.jsx(tu,{appName:c,connectionId:s,usedConnectionIds:u,onSwitchInstance:m,onNewInstance:p}),e[27]=c,e[28]=s,e[29]=p,e[30]=m,e[31]=u,e[32]=k):k=e[32];let w;e[33]===Symbol.for("react.memo_cache_sentinel")?(w=o.jsx(Ac,{size:13}),e[33]=w):w=e[33];let j;e[34]!==d?(j=o.jsx(Ye,{asChild:!0,children:o.jsx(ne,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:d,"aria-label":"Configure resources",children:w})}),e[34]=d,e[35]=j):j=e[35];let T;e[36]===Symbol.for("react.memo_cache_sentinel")?(T=o.jsx(Xe,{side:"bottom",children:"Configure resources"}),e[36]=T):T=e[36];let I;e[37]!==j?(I=o.jsxs(Ge,{delayDuration:0,children:[j,T]}),e[37]=j,e[38]=I):I=e[38];let A;e[39]===Symbol.for("react.memo_cache_sentinel")?(A=o.jsx(ds,{size:13}),e[39]=A):A=e[39];let O;e[40]!==f?(O=o.jsx(Ye,{asChild:!0,children:o.jsx(ne,{variant:"ghost",size:"icon",className:"h-7 w-7 text-muted-foreground hover:text-destructive",onClick:f,"aria-label":"Remove connection",children:A})}),e[40]=f,e[41]=O):O=e[41];let q;e[42]===Symbol.for("react.memo_cache_sentinel")?(q=o.jsx(Xe,{side:"bottom",children:"Remove"}),e[42]=q):q=e[42];let U;e[43]!==O?(U=o.jsxs(Ge,{delayDuration:0,children:[O,q]}),e[43]=O,e[44]=U):U=e[44];let V;e[45]!==I||e[46]!==U?(V=o.jsxs("div",{className:"flex items-center gap-0.5 ml-auto",children:[I,U]}),e[45]=I,e[46]=U,e[47]=V):V=e[47];let J;e[48]!==k||e[49]!==V?(J=o.jsxs("div",{className:"flex items-center gap-3 px-4 py-2 border-t border-border bg-muted/25",children:[k,V]}),e[48]=k,e[49]=V,e[50]=J):J=e[50];let Z;return e[51]!==E||e[52]!==J||e[53]!==y?(Z=o.jsxs("div",{className:y,children:[E,J]}),e[51]=E,e[52]=J,e[53]=y,e[54]=Z):Z=e[54],Z}function iu(t){const e=W.c(17),{connection_id:s}=t,i=ln(s);if(!i){let d;return e[0]===Symbol.for("react.memo_cache_sentinel")?(d=o.jsx($a,{}),e[0]=d):d=e[0],d}let r;e[1]!==i.icon||e[2]!==i.title?(r=o.jsx(_s,{icon:i.icon,name:i.title,size:"sm",className:"shrink-0"}),e[1]=i.icon,e[2]=i.title,e[3]=r):r=e[3];let n;e[4]!==i.title?(n=o.jsx("p",{className:"text-sm font-medium truncate",children:i.title}),e[4]=i.title,e[5]=n):n=e[5];let a;e[6]!==i.description?(a=i.description&&o.jsx("p",{className:"text-xs text-muted-foreground truncate",children:i.description}),e[6]=i.description,e[7]=a):a=e[7];let l;e[8]!==n||e[9]!==a?(l=o.jsxs("div",{className:"flex-1 min-w-0",children:[n,a]}),e[8]=n,e[9]=a,e[10]=l):l=e[10];let h;e[11]!==r||e[12]!==l?(h=o.jsxs("div",{className:"flex items-center gap-3 px-4 py-3",children:[r,l]}),e[11]=r,e[12]=l,e[13]=h):h=e[13];let c;e[14]===Symbol.for("react.memo_cache_sentinel")?(c=o.jsx("div",{className:"flex items-center px-4 py-2 border-t border-border bg-muted/25",children:o.jsx("div",{className:"h-5 w-20 rounded bg-muted animate-pulse"})}),e[14]=c):c=e[14];let u;return e[15]!==h?(u=o.jsxs("div",{className:"rounded-xl border border-border overflow-hidden",children:[h,c]}),e[15]=h,e[16]=u):u=e[16],u}function $a(){const t=W.c(3);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=o.jsx("div",{className:"size-8 rounded-md bg-muted animate-pulse shrink-0"}),t[0]=e):e=t[0];let s;t[1]===Symbol.for("react.memo_cache_sentinel")?(s=o.jsxs("div",{className:"flex items-center gap-3 px-4 py-3",children:[e,o.jsxs("div",{className:"flex-1 space-y-1.5",children:[o.jsx("div",{className:"h-4 w-32 rounded bg-muted animate-pulse"}),o.jsx("div",{className:"h-3 w-48 rounded bg-muted animate-pulse"})]})]}),t[1]=s):s=t[1];let i;return t[2]===Symbol.for("react.memo_cache_sentinel")?(i=o.jsxs("div",{className:"rounded-xl border border-border overflow-hidden",children:[s,o.jsx("div",{className:"flex items-center px-4 py-2 border-t border-border bg-muted/25",children:o.jsx("div",{className:"h-5 w-20 rounded bg-muted animate-pulse"})})]}),t[2]=i):i=t[2],i}function ru({virtualMcpId:t,form:e,debouncedSave:s,flushAndSave:i}){const{org:r}=xe(),n=We({connectionId:Ot,orgId:r.id,orgSlug:r.slug}),a=Nt(t),l=(a?.connections??[]).map(w=>w.connection_id).sort(),{data:h}=Jo({queryKey:$s.projectConnectionDetails(t,l),enabled:l.length>0,queryFn:async()=>await Promise.all(l.map(async j=>{try{const T=await n.callTool({name:"COLLECTION_CONNECTIONS_GET",arguments:{id:j}}),{item:I}=uh(T),A=(I?.tools??[]).filter(O=>!!ch(O._meta)).map(O=>({name:O.name,description:O.description}));return{fetchOk:!0,id:j,title:I?.title??j,icon:I?.icon??null,uiTools:A}}catch{return{fetchOk:!1,id:j,title:j,icon:null,uiTools:[]}}}))}),c=(h??[]).filter(w=>w.uiTools.length>0),u=new Set(gc),d=e.watch("metadata.ui.pinnedViews")??[],f=e.watch("metadata.ui.layout")??null,_=f?.defaultMainView??null,m=f?.chatDefaultOpen??!1,p=!_||_.type==="chat"?"chat":_.type==="instructions"||_.type==="connections"||_.type==="layout"?"settings":u.has(_.type)?_.type:`${_.type}:${_.id??""}:${_.toolName??""}`,g=w=>{const[j,T,I]=w.split(":");return j?j==="chat"?{type:j}:u.has(j)?{type:j}:j==="ext-apps"&&T?{type:"ext-apps",id:T,toolName:I||void 0}:null:null},v=w=>{e.setValue("metadata.ui.pinnedViews",w,{shouldDirty:!0})},x=w=>{e.setValue("metadata.ui.layout",{...f,...w},{shouldDirty:!0})},S=P.useRef(!1);if(h&&h.length>0&&!S.current){S.current=!0;const w=new Set((h??[]).filter(I=>I.fetchOk).map(I=>I.id)),j=new Set(c.flatMap(I=>I.uiTools.map(A=>`${I.id}:${A.name}`))),T=d.filter(I=>!w.has(I.connectionId)||j.has(`${I.connectionId}:${I.toolName}`));T.length!==d.length&&(v(T),_?.type==="ext-apps"&&!T.some(I=>I.connectionId===_.id&&I.toolName===_.toolName)&&x({defaultMainView:{type:"chat"}}),s())}const b=(w,j)=>{if(d.some(I=>I.connectionId===w&&I.toolName===j)){const I=d.filter(O=>!(O.connectionId===w&&O.toolName===j));v(I);const A=`ext-apps:${w}:${j}`;p===A&&x({defaultMainView:{type:"chat"}})}else v([...d,{connectionId:w,toolName:j,label:Rn(j),icon:null}]);i()},y=(w,j,T)=>{v(d.map(I=>I.connectionId===w&&I.toolName===j?{...I,label:T}:I)),s()},N=()=>{i()},C=(w,j,T)=>{v(d.map(I=>I.connectionId===w&&I.toolName===j?{...I,icon:T}:I)),i()},D=w=>{x({defaultMainView:g(w)}),i()},R=l.length===0,B=h&&c.length===0,M=!!Gt(a),E=[{value:"chat",label:"Chat"},{value:"settings",label:"Settings"},{value:"automations",label:"Automations"}];M&&(E.push({value:"env",label:"Terminal"}),E.push({value:"preview",label:"Preview"}));for(const w of d)E.push({value:`ext-apps:${w.connectionId}:${w.toolName}`,label:w.label||w.toolName});const k=c.length>0||R||B;return o.jsxs("div",{className:"flex flex-col gap-3",children:[o.jsx("div",{className:"flex items-center justify-between gap-3",children:o.jsx("h2",{className:"text-sm font-medium text-foreground",children:"Layout"})}),o.jsxs(_h,{className:"p-6 gap-5",children:[o.jsxs(Ln,{className:"p-0 space-y-5",children:[o.jsxs("div",{className:"flex items-center justify-between gap-4",children:[o.jsxs("div",{className:"space-y-0.5 min-w-0",children:[o.jsx(Ls,{className:"font-normal text-foreground",children:"Main view"}),o.jsx("p",{className:"text-xs text-muted-foreground",children:"What users see when they first open this agent."})]}),o.jsxs(rs,{value:p,onValueChange:D,children:[o.jsx(ns,{className:"w-44 h-8 text-sm capitalize shrink-0",children:o.jsx(os,{})}),o.jsx(as,{children:E.map(w=>o.jsx(Pt,{value:w.value,className:"capitalize",children:w.label},w.value))})]})]}),o.jsxs("div",{className:"flex items-center justify-between gap-4",children:[o.jsxs("div",{className:"space-y-0.5 min-w-0",children:[o.jsx(Ls,{className:"font-normal text-foreground",children:"Show chat"}),o.jsx("p",{className:"text-xs text-muted-foreground",children:"Display the chat panel alongside the main view."})]}),o.jsxs(Ge,{delayDuration:0,children:[o.jsx(Ye,{asChild:!0,children:o.jsx("span",{className:"shrink-0",children:o.jsx(vr,{checked:p==="chat"?!0:m,disabled:p==="chat",onCheckedChange:w=>{x({chatDefaultOpen:w}),i()}})})}),p==="chat"&&o.jsx(Xe,{side:"top",children:"Chat is always shown when it is the default view"})]})]})]}),k&&o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"border-t border-border -mx-6"}),o.jsxs(Ln,{className:"p-0 space-y-3",children:[o.jsx("div",{className:"flex items-center justify-between gap-4",children:o.jsxs("div",{className:"space-y-0.5 min-w-0",children:[o.jsx(Ls,{className:"font-normal text-foreground",children:"Pinned views"}),o.jsx("p",{className:"text-xs text-muted-foreground",children:"Surface interactive tools as top-level tabs in the agent."})]})}),R&&o.jsx("p",{className:"text-xs text-muted-foreground",children:"Add a connection above to configure pinned views."}),B&&!R&&o.jsx("p",{className:"text-xs text-muted-foreground",children:"None of the connected servers expose interactive tools."}),c.length>0&&o.jsx("div",{className:"space-y-4 pt-1",children:c.map((w,j)=>o.jsxs("div",{children:[j>0&&o.jsx("div",{className:"border-t border-border -mx-6 mb-4"}),o.jsxs("div",{className:"flex items-center gap-2 mb-2.5",children:[o.jsx(_s,{icon:w.icon,name:w.title,size:"xs",className:"shrink-0"}),o.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:w.title})]}),o.jsx("div",{className:"space-y-1.5",children:w.uiTools.map(T=>{const I=d.some(O=>O.connectionId===w.id&&O.toolName===T.name),A=d.find(O=>O.connectionId===w.id&&O.toolName===T.name);return o.jsxs("div",{className:ie("flex items-center justify-between gap-3 px-3 py-2 rounded-lg border transition-colors",I?"bg-accent/40 border-border":"bg-transparent border-border"),children:[o.jsxs("div",{className:"min-w-0 flex-1 flex items-center gap-2",children:[o.jsx(Ed,{value:A?.icon??null,onChange:O=>C(w.id,T.name,O),disabled:!I}),o.jsx(vs,{value:I&&A?A.label:Rn(T.name),onChange:O=>y(w.id,T.name,O.target.value),onBlur:N,className:"h-7 text-sm w-40",disabled:!I,readOnly:!I})]}),o.jsx(vr,{checked:I,onCheckedChange:()=>b(w.id,T.name)})]},T.name)})})]},w.id))})]})]})]})]})}function nu({virtualMcp:t,hideOwnTitle:e}){const{org:s}=xe(),i=rc(),r=oh(),n=ms(),a=We({connectionId:Ot,orgId:s.id,orgSlug:s.slug}),l=Qo({resolver:Vl(Wd),defaultValues:t}),h=l.watch("connections"),c=!!Gt(t),[u,d]=P.useReducer(Zd,{shareDialogOpen:!1,addDialogOpen:!1,settingsDialogOpen:!1,settingsConnectionId:null}),[f,_]=P.useState(!1),[m,p]=P.useState(!1),{createNewTask:g,setChatOpen:v}=Ai(),{sendMessage:x}=ps(),S=pa(),b=async()=>{if(m)return;const L=l.getValues("metadata.instructions");if(L?.trim()){p(!0);try{E(),we("agent_instructions_improve_clicked",{agent_id:t.id,instructions_length:L.length}),await S(["studio-agent-manager"]),v(!0),await x({tiptapDoc:za({managerAgentId:ra.AGENT_MANAGER(s.id),managerName:"Agent Manager",kind:"agent",id:t.id,instructions:L})})}finally{p(!1)}}},y=()=>{E(),we("agent_test_clicked",{agent_id:t.id}),g()},N=P.useRef(null),C=P.useRef(new Set),D=P.useRef(0),R=P.useRef(null),B=P.useRef(null),M=3e4,E=()=>{B.current&&(clearTimeout(B.current),B.current=null),N.current!==null&&(we("agent_updated",{agent_id:t.id,fields:Array.from(C.current),instructions_length:R.current,save_count:D.current,edit_duration_ms:Date.now()-N.current}),N.current=null,C.current=new Set,D.current=0,R.current=null)},k=async()=>{const L=Object.keys(l.formState.dirtyFields);if(L.length===0)return;const ee=L.includes("metadata"),se=l.getValues(),te=await i.update.mutateAsync({id:t.id,data:se});N.current===null&&(N.current=Date.now());for(const G of L)C.current.add(G);D.current+=1,ee&&(R.current=se.metadata?.instructions?.length??0),B.current&&clearTimeout(B.current),B.current=setTimeout(E,M),l.reset(te)},{schedule:w,flush:j}=Da({save:k}),T=()=>{we("connections_dialog_opened",{source:"agent_settings",mode:"add"}),d({type:"SET_ADD_DIALOG_OPEN",payload:!0})},I=async L=>{const ee=l.getValues("connections");if(ee.some(G=>G.connection_id===L))return;l.setValue("connections",[...ee,{connection_id:L,selected_tools:Ji.tools,selected_resources:Ji.resources,selected_prompts:Ji.prompts}],{shouldDirty:!0}),w(),d({type:"SET_ADD_DIALOG_OPEN",payload:!1});const se=new URL(`/api/${s.slug}/mcp/${L}`,window.location.origin),te=await Nn({url:se.href,token:null,orgId:s.id});te.supportsOAuth&&!te.isAuthenticated&&await V(L)},A=L=>{const se=l.getValues("connections").filter(te=>te.connection_id!==L);l.setValue("connections",se,{shouldDirty:!0}),w()},O=(L,ee)=>{const se=l.getValues("connections");if(se.some(te=>te.connection_id===ee)){ge.error("This instance is already added to the agent");return}l.setValue("connections",se.map(te=>te.connection_id===L?{...te,connection_id:ee}:te),{shouldDirty:!0}),w()},q=async L=>{if(l.getValues("connections").find(se=>se.connection_id===L))try{const se=await a.callTool({name:"COLLECTION_CONNECTIONS_GET",arguments:{id:L}}),{item:te}=se.structuredContent??{};if(!te)return;const G=te.title.replace(/\s*\(.*?\)\s*$/,""),he=ah("conn"),fe=`${G} (${Date.now().toString(36).slice(-4)})`;await r.create.mutateAsync({id:he,title:fe,description:te.description??null,connection_type:te.connection_type,connection_url:te.connection_url??null,connection_token:null,icon:te.icon??null,app_name:te.app_name??null,app_id:te.app_id??null,connection_headers:te.connection_headers??null});const de=new URL(`/api/${s.slug}/mcp/${he}`,window.location.origin),ue=await Nn({url:de.href,token:null,orgId:s.id});if(ue.supportsOAuth&&!ue.isAuthenticated){const pe=await V(he);if(!pe){await r.delete.mutateAsync(he);return}await r.update.mutateAsync({id:he,data:{title:`${G} (${pe})`}})}O(L,he),ge.success("New instance created")}catch(se){console.error("Failed to create instance:",se),ge.error("Failed to create instance")}},U=L=>{d({type:"OPEN_SETTINGS",payload:L})},V=async L=>{const{token:ee,tokenInfo:se,error:te}=await Kl({connectionId:L,orgSlug:s.slug,scope:"offline_access"});if(te||!ee)return ge.error(`Authentication failed: ${te}`),null;if(se)try{const he=await fetch(`/api/${s.slug}/connections/${L}/oauth-token`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({accessToken:se.accessToken,refreshToken:se.refreshToken,expiresIn:se.expiresIn,scope:se.scope,clientId:se.clientId,clientSecret:se.clientSecret,tokenEndpoint:se.tokenEndpoint})});if(!he.ok)console.error("Failed to save OAuth token:",await he.text()),await r.update.mutateAsync({id:L,data:{connection_token:ee}});else try{await r.update.mutateAsync({id:L,data:{}})}catch(fe){console.warn("Failed to refresh connection tools after OAuth:",fe)}}catch(he){console.error("Error saving OAuth token:",he),await r.update.mutateAsync({id:L,data:{connection_token:ee}})}else await r.update.mutateAsync({id:L,data:{connection_token:ee}});const G=new URL(`/api/${s.slug}/mcp/${L}`,window.location.origin);return await n.invalidateQueries({queryKey:$s.isMCPAuthenticated(G.href,null)}),ge.success("Authentication successful"),eu(se,ee)},J=()=>{const L=l.getValues("metadata.instructions")??"",ee=`<role>
5
5
  Define who this agent is and what it specializes in.
@@ -179,4 +179,4 @@ WARNING: This link could potentially be dangerous`)){let s=window.open();if(s){t
179
179
  `,e)}paste(t){this._core.paste(t)}refresh(t,e){this._verifyIntegers(t,e),this._core.refresh(t,e)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(t){this._addonManager.loadAddon(this,t)}static get strings(){return{get promptLabel(){return Sr.get()},set promptLabel(t){Sr.set(t)},get tooMuchOutput(){return yr.get()},set tooMuchOutput(t){yr.set(t)}}}_verifyIntegers(...t){for(mt of t)if(mt===1/0||isNaN(mt)||mt%1!==0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...t){for(mt of t)if(mt&&(mt===1/0||isNaN(mt)||mt%1!==0||mt<0))throw new Error("This API only accepts positive integers")}};var Dp=2,Mp=1,Ip=class{activate(t){this._terminal=t}dispose(){}fit(){let t=this.proposeDimensions();if(!t||!this._terminal||isNaN(t.cols)||isNaN(t.rows))return;let e=this._terminal._core;(this._terminal.rows!==t.rows||this._terminal.cols!==t.cols)&&(e._renderService.clear(),this._terminal.resize(t.cols,t.rows))}proposeDimensions(){if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let t=this._terminal._core._renderService.dimensions;if(t.css.cell.width===0||t.css.cell.height===0)return;let e=this._terminal.options.scrollback===0?0:this._terminal.options.overviewRuler?.width||14,s=window.getComputedStyle(this._terminal.element.parentElement),i=parseInt(s.getPropertyValue("height")),r=Math.max(0,parseInt(s.getPropertyValue("width"))),n=window.getComputedStyle(this._terminal.element),a={top:parseInt(n.getPropertyValue("padding-top")),bottom:parseInt(n.getPropertyValue("padding-bottom")),right:parseInt(n.getPropertyValue("padding-right")),left:parseInt(n.getPropertyValue("padding-left"))},l=a.top+a.bottom,h=a.right+a.left,c=i-l,u=r-h-e;return{cols:Math.max(Dp,Math.floor(u/t.css.cell.width)),rows:Math.max(Mp,Math.floor(c/t.css.cell.height))}}};function Ap({source:t,onReady:e,onSelectionChange:s,className:i}){const r=P.useRef(null),n=P.useRef(null),a=P.useRef(s);a.current=s;const l=Xt(),h=P.useRef(t);return h.current=t,ef((c,u)=>{c===h.current&&n.current?.write(u)}),P.useEffect(()=>{const c=r.current;if(!c)return;const u=getComputedStyle(document.documentElement),d=v=>u.getPropertyValue(v).trim()||void 0,f=new Rp({allowTransparency:!1,fontFamily:d("--font-mono")||"ui-monospace, SFMono-Regular, Menlo, Consolas, monospace",fontSize:12.5,lineHeight:1.5,scrollback:5e3,cursorBlink:!1,disableStdin:!0,theme:{background:d("--sidebar")||d("--card")||d("--background")||"#1e1e1e",cursor:"transparent",foreground:d("--foreground")||"#d4d4d4",selectionBackground:d("--accent"),selectionForeground:d("--accent-foreground"),black:d("--muted"),red:d("--destructive"),green:d("--success"),yellow:d("--warning"),blue:d("--chart-1"),magenta:d("--chart-3"),cyan:d("--chart-5"),white:d("--foreground"),brightBlack:d("--muted-foreground"),brightRed:d("--destructive"),brightGreen:d("--success"),brightYellow:d("--warning"),brightBlue:d("--chart-1"),brightMagenta:d("--chart-3"),brightCyan:d("--chart-5"),brightWhite:d("--foreground")}}),_=new Ip;f.loadAddon(_),f.open(c),_.fit();const m=l.getBuffer(t);m&&f.write(m),n.current=f,e?.(f);const p=f.onSelectionChange(()=>{const v=!!f.getSelection();a.current?.(v,()=>f.getSelection())}),g=new ResizeObserver(()=>{_.fit()});return g.observe(c),()=>{p.dispose(),g.disconnect(),n.current=null,f.dispose()}},[]),o.jsx("div",{ref:r,className:ie("overflow-hidden bg-sidebar px-4 py-3 [&_.xterm]:h-full [&_.xterm-screen]:min-h-full [&_.xterm-viewport]:overscroll-contain",i)})}function Bp(){const t=W.c(2),s=Cn()?.entity;let i;return t[0]!==s?(i=Gt(s),t[0]=s,t[1]=i):i=t[1],i}const Pp={npm:{install:"npm install",run:t=>`npm run ${t}`,runtime:"node"},pnpm:{install:"pnpm install",run:t=>`pnpm run ${t}`,runtime:"node"},yarn:{install:"yarn install",run:t=>`yarn run ${t}`,runtime:"node"},bun:{install:"bun install",run:t=>`bun run ${t}`,runtime:"bun"},deno:{install:"deno install",run:t=>`deno task ${t}`,runtime:"deno"}},Uo=["dev","start"];function Lp({daemonOpen:t=!1}){const{org:e}=xe(),s=Cn(),i=ms(),{data:r}=Ti.useSession(),{currentBranch:n,setCurrentTaskBranch:a}=bt(),l=r?.user?.id,h=s?.entity?.metadata,c=l&&n?h?.vmMap?.[l]?.[n]:void 0,u=c&&n?{previewUrl:c.previewUrl,vmId:c.vmId,branch:n,runnerKind:c.runnerKind}:null,[d,f]=P.useState(null),[_,m]=P.useState(""),[p,g]=P.useState(""),[v,x]=P.useState(!1),[S,b]=P.useState(new Set),y=P.useRef(!1),N=P.useRef(Date.now()),[C,D]=P.useState("setup"),[R,B]=P.useState([]),M=P.useRef(new Map),{sendMessage:E}=ps(),{setChatOpen:k}=Ai(),[w,j]=P.useState(!1),T=P.useRef(null),I=Y=>{D(Y),j(!1),T.current=null},A=(Y,ae,je)=>{Y===C&&(j(ae),T.current=ae?je:null)},O=()=>{const Y=T.current?.();if(!Y)return;k(!0),E({parts:[{type:"text",text:`<server-logs>
180
180
  ${Y}
181
181
  </server-logs>`}]}),M.current.get(C)?.clearSelection()},q=We({connectionId:Ot,orgId:e.id,orgSlug:e.slug}),U=Xt(),V=La(s?.entity?.id,n??void 0),J=U.suspended?"suspended":U.notFound?"creating":u?"running":V?"creating":"idle",Z=d??J;P.useEffect(()=>{d==="creating"&&J==="running"&&f(null),d==="stopping"&&J==="idle"&&f(null)},[J,d]);const F=dn(q),{mutate:$,isPending:H}=F,Q=s?.entity?.id,L=U.notFound?c?.vmId??null:null,ee=P.useRef(null);P.useEffect(()=>{if(!L||!Q||H||ee.current===L)return;ee.current=L;const Y={virtualMcpId:Q};n&&(Y.branch=n),$(Y,{onError:ae=>{console.error("[env] reprovision VM_START failed",ae)}})},[L,Q,n,H,$]);const se=P.useRef(!1);P.useEffect(()=>{if(U.scripts.length>0&&!se.current){se.current=!0;for(const Y of Uo)if(U.scripts.includes(Y)){B([Y]),I(Y);break}}},[U.scripts]);const te=async(Y,ae)=>{const je=await q.callTool({name:Y,arguments:ae}),dt=je.content;if(dt?.[0]?.text?.startsWith("Error:"))throw new Error(dt[0].text);return je.structuredContent??je},G=async Y=>{if(!(v||!u||!Q||!n)){x(!0);try{const ae=new URLSearchParams({virtualMcpId:Q,branch:n}).toString(),je=await fetch(`/api/${encodeURIComponent(e.slug)}/vm-exec/exec/${encodeURIComponent(Y)}?${ae}`,{method:"POST"});if(!je.ok)throw new Error(`Exec failed: ${je.statusText}`);b(dt=>{const Zt=new Set(dt);return Zt.delete(Y),Zt})}finally{x(!1)}}},he=async Y=>{if(!(v||!u||!Q||!n)){x(!0);try{const ae=new URLSearchParams({virtualMcpId:Q,branch:n}).toString(),je=await fetch(`/api/${encodeURIComponent(e.slug)}/vm-exec/kill/${encodeURIComponent(Y)}?${ae}`,{method:"POST"});if(!je.ok)throw new Error(`Kill failed: ${je.statusText}`);b(dt=>new Set(dt).add(Y))}finally{x(!1)}}},fe=Y=>{R.includes(Y)||B(ae=>[...ae,Y]),I(Y),G(Y)},de=async()=>{if(!y.current){y.current=!0,s?.entity?.id&&n&&yi.clear(s.entity.id,n),N.current=Date.now(),f("creating"),m("Connecting..."),g(""),se.current=!1,B([]),I("setup");try{if(!s?.entity)throw new Error("No virtual MCP context");const Y={virtualMcpId:s.entity.id};n&&(Y.branch=n);const ae=await te("VM_START",Y);if(!ae.vmId||!ae.branch)throw new Error("Invalid VM response — missing fields");n||a(ae.branch),m(""),di(i)}catch(Y){f("error"),g(Y instanceof Error?Y.message:"Failed to start VM")}finally{y.current=!1}}},ue=async()=>{const Y=u?.branch??n;f("stopping");const ae=s?.entity?.id;if(ae&&Y&&yi.mark(ae,Y),ae&&Y)try{await q.callTool({name:"VM_DELETE",arguments:{virtualMcpId:ae,branch:Y}})}catch{}di(i)},pe=Bp(),De=s?.entity?.metadata?.runtime,Ue="__none__",Ke=Object.keys(Pp),Qe=async(Y,ae)=>{if(s?.entity)try{await q.callTool({name:"COLLECTION_VIRTUAL_MCP_UPDATE",arguments:{id:s.entity.id,data:{metadata:{runtime:{...De,[Y]:ae}}}}}),di(i)}catch{ge.error("Failed to update setting")}};if(Z==="idle"||Z==="stopping"){const Y=Z==="stopping";return o.jsx("div",{className:"flex flex-col items-center justify-center w-full h-full p-6",children:o.jsxs("div",{className:"flex flex-col gap-4 w-full max-w-xs",children:[pe&&o.jsxs("a",{href:`https://github.com/${pe.owner}/${pe.name}`,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-3 p-4 rounded-lg border border-border hover:bg-accent/50 transition-colors",children:[o.jsx(hh,{size:24}),o.jsxs("div",{className:"flex flex-col gap-0.5 min-w-0 flex-1",children:[o.jsxs("span",{className:"text-sm font-medium truncate",children:[pe.owner,"/",pe.name]}),o.jsxs("span",{className:"text-xs text-muted-foreground truncate",children:["github.com/",pe.owner,"/",pe.name]})]}),o.jsx(Yt,{size:14,className:"text-muted-foreground shrink-0"})]}),o.jsxs("div",{className:"flex flex-wrap items-end justify-between gap-2 w-full",children:[o.jsxs("div",{className:"flex flex-col gap-1",children:[o.jsx(Ls,{htmlFor:"env-runtime",className:"text-xs font-medium",children:"Runtime"}),o.jsxs(rs,{value:De?.selected??Ue,onValueChange:ae=>Qe("selected",ae===Ue?null:ae),children:[o.jsx(ns,{id:"env-runtime",className:"w-28",children:o.jsx(os,{placeholder:"None"})}),o.jsxs(as,{children:[o.jsx(Pt,{value:Ue,children:"None"}),Ke.map(ae=>o.jsx(Pt,{value:ae,children:ae},ae))]})]})]}),o.jsxs("div",{className:"flex flex-col gap-1",children:[o.jsx(Ls,{htmlFor:"env-port",className:"text-xs font-medium",children:"Port"}),o.jsx(vs,{id:"env-port",placeholder:"3001",className:"w-20 h-8",defaultValue:De?.port??"",onBlur:ae=>Qe("port",ae.target.value||null)})]}),o.jsxs(ne,{onClick:de,disabled:Y,children:[Y?o.jsx(Ae,{size:14,className:"animate-spin"}):o.jsx(fi,{size:14}),Y?"Stopping...":"Run"]})]})]})})}if(Z==="creating"){const Y=U.notFound?"Sandbox was stopped, we're restarting it…":_;return o.jsxs("div",{className:"flex flex-col items-center justify-center w-full h-full gap-4",children:[o.jsx(Ae,{size:24,className:"animate-spin text-muted-foreground"}),o.jsx("p",{className:"text-sm text-muted-foreground",children:Y}),o.jsx(vc,{since:N.current})]})}if(Z==="error")return o.jsx(Ka,{errorMsg:p,onRetry:de});if(Z==="suspended")return o.jsx(Va,{onResume:de});const me=["setup",...R,...t?["daemon"]:[]],Tt=U.scripts.filter(Y=>!R.includes(Y));return o.jsx("div",{className:"flex flex-col w-full h-full",children:o.jsxs("div",{className:"flex flex-col h-full",children:[o.jsxs("div",{className:"flex h-12 items-center border-b border-border px-2 shrink-0",children:[me.map(Y=>o.jsx("button",{type:"button",onClick:()=>I(Y),className:ie("flex items-center h-full px-3 text-sm whitespace-nowrap border-b-2 mb-[-1px] capitalize transition-all hover:text-foreground",C===Y?"text-foreground border-primary":"text-muted-foreground border-transparent"),children:Y},Y)),Tt.length>0&&o.jsxs(ls,{children:[o.jsx(cs,{asChild:!0,children:o.jsx("button",{type:"button",className:"flex items-center h-full px-2 text-muted-foreground hover:text-foreground transition-colors",children:o.jsx(us,{size:14})})}),o.jsx(hs,{align:"start",children:Tt.map(Y=>o.jsx(kt,{onClick:()=>fe(Y),children:Y},Y))})]}),o.jsx("div",{className:"flex-1 flex justify-center",children:u?.vmId&&o.jsxs("div",{className:"flex items-center",children:[o.jsxs(Ge,{children:[o.jsx(Ye,{asChild:!0,children:o.jsx("button",{type:"button",className:"shrink-0 rounded-l bg-muted px-1.5 py-0.5 text-[10px] font-mono text-muted-foreground cursor-pointer hover:bg-accent hover:text-foreground transition-colors border-r border-border/50",onClick:()=>navigator.clipboard.writeText(u?.vmId??""),children:u.vmId})}),o.jsx(Xe,{side:"bottom",children:"Copy VM ID"})]}),o.jsxs(ls,{children:[o.jsx(cs,{asChild:!0,children:o.jsx("button",{type:"button",className:"shrink-0 self-stretch rounded-r bg-muted px-0.5 text-[10px] text-muted-foreground cursor-pointer hover:bg-accent hover:text-foreground transition-colors",children:o.jsx(br,{size:10})})}),o.jsx(hs,{align:"center",children:o.jsxs(kt,{onClick:ue,children:[o.jsx(Bn,{size:12}),"Stop Server"]})})]})]})}),o.jsxs("div",{className:"flex items-center gap-1",children:[w&&o.jsxs("button",{type:"button",onClick:O,className:"flex items-center gap-1 rounded-md border border-border px-2 py-1 text-xs font-medium text-muted-foreground hover:text-foreground hover:bg-muted transition-colors",children:[o.jsx(Bc,{size:12}),"Add to chat"]}),C!=="setup"&&C!=="daemon"&&R.includes(C)&&(()=>{const Y=Uo.includes(C),ae=U.appStatus?.status==="up"||U.appStatus?.status==="starting",je=Y?ae:U.activeProcesses.includes(C)&&!S.has(C),dt=()=>G(C),Zt=()=>he(C);return o.jsxs("div",{className:"flex items-center",children:[o.jsxs("button",{type:"button",disabled:v,onClick:dt,className:ie("flex items-center gap-1 border border-border px-2 py-1 text-xs font-medium text-muted-foreground hover:text-foreground hover:bg-muted transition-colors disabled:opacity-50",je?"rounded-l-md border-r-0":"rounded-md"),children:[v?o.jsx(Ae,{size:12,className:"animate-spin"}):o.jsx(fi,{size:12}),v?"Running...":je?"Restart":"Run"]}),je&&o.jsxs(ls,{children:[o.jsx(cs,{asChild:!0,children:o.jsx("button",{type:"button",disabled:v,className:"flex items-center self-stretch rounded-r-md border border-border px-1 text-xs text-muted-foreground hover:text-foreground hover:bg-muted transition-colors disabled:opacity-50",children:o.jsx(br,{size:12})})}),o.jsx(hs,{align:"end",children:o.jsxs(kt,{onClick:Zt,children:[o.jsx(Bn,{size:12}),Y?"Stop":"Stop Process"]})})]})]})})()]})]}),o.jsx("div",{className:"flex-1 overflow-hidden",children:me.map(Y=>o.jsx("div",{className:ie("h-full",C===Y?"block":"hidden"),children:U.hasData(Y)||Y==="setup"||Y==="daemon"?o.jsx(Ap,{source:Y,onReady:ae=>{M.current.set(Y,ae)},onSelectionChange:(ae,je)=>A(Y,ae,je),className:"h-full"}):o.jsx(Hs,{className:"h-full",image:null,title:`Script "${Y}" not running`,description:`Click Run to start "${Y}".`,actions:o.jsxs(ne,{variant:"outline",size:"sm",disabled:v,onClick:()=>G(Y),children:[v?o.jsx(Ae,{size:14,className:"animate-spin"}):o.jsx(fi,{size:14}),"Run"]})})},Y))})]})})}function Op(t){const e=W.c(1);let s;return e[0]===Symbol.for("react.memo_cache_sentinel")?(s=o.jsx(Lp,{}),e[0]=s):s=e[0],s}function zs(t){const e=t.trim().split(/\s+/);return e.length!==5?!1:e.every(s=>/^[\d*/,-]+$/.test(s))}function zp(t){if(!t)return"Unknown schedule";const e=t.trim();if(e==="* * * * *")return"Every minute";if(e==="0 * * * *")return"Every hour";if(e==="0 0 * * *")return"Every day";if(e==="0 0 * * 1")return"Every week";const s=e.match(/^\*\/(\d+)\s+\*\s+\*\s+\*\s+\*$/);if(s)return`Every ${s[1]} minutes`;const i=e.match(/^0\s+\*\/(\d+)\s+\*\s+\*\s+\*$/);if(i)return`Every ${i[1]} hours`;const r=e.match(/^0\s+0\s+\*\/(\d+)\s+\*\s+\*$/);if(r){const l=parseInt(r[1]??"1");return l%7===0?`Every ${l/7} weeks`:`Every ${l} days`}const n=e.match(/^(\d+)\s+(\d+)\s+\*\s+\*\s+\*$/);if(n){const l=(n[2]??"0").padStart(2,"0"),h=(n[1]??"0").padStart(2,"0");return`Every day at ${l}:${h} UTC`}const a=e.match(/^(\d+)\s+(\d+)\s+\*\s+\*\s+(\d)$/);if(a){const h=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"][parseInt(a[3]??"0")]??"day",c=(a[2]??"0").padStart(2,"0"),u=(a[1]??"0").padStart(2,"0");return`Every ${h} at ${c}:${u} UTC`}return t}function $p(t,e){const s=Math.max(1,t);switch(e){case"minutes":return s===1?"* * * * *":`*/${s} * * * *`;case"hours":return s===1?"0 * * * *":`0 */${s} * * *`;case"days":return s===1?"0 0 * * *":`0 0 */${s} * *`;case"weeks":return s===1?"0 0 * * 1":`0 0 */${s*7} * *`}}function Fp(t){const e=t.trim();if(e==="* * * * *")return{count:1,unit:"minutes"};if(e==="0 * * * *")return{count:1,unit:"hours"};if(e==="0 0 * * *")return{count:1,unit:"days"};if(e==="0 0 * * 1")return{count:1,unit:"weeks"};const s=e.match(/^\*\/(\d+)\s+\*\s+\*\s+\*\s+\*$/);if(s)return{count:parseInt(s[1]),unit:"minutes"};const i=e.match(/^0\s+\*\/(\d+)\s+\*\s+\*\s+\*$/);if(i)return{count:parseInt(i[1]),unit:"hours"};const r=e.match(/^0\s+0\s+\*\/(\d+)\s+\*\s+\*$/);if(r){const n=parseInt(r[1]);return n%7===0?{count:n/7,unit:"weeks"}:{count:n,unit:"days"}}return null}function Hp(t,e){return e===1?{minutes:"minute",hours:"hour",days:"day",weeks:"week"}[t]??t:t}const Wp=[{label:"Minute",cron:"* * * * *"},{label:"Hour",cron:"0 * * * *"},{label:"Day",cron:"0 0 * * *"},{label:"Week",cron:"0 0 * * 1"}];function Up(t){const e=W.c(33),{automationId:s,open:i,onOpenChange:r,onCustomSelect:n,onEventSelect:a}=t,{triggerAdd:l}=Js(),[h,c]=P.useState(!1),u=i??h;let d;e[0]!==r?(d=M=>{r?r(M):c(M)},e[0]=r,e[1]=d):d=e[1];const f=d;let _;e[2]!==l||e[3]!==s||e[4]!==f?(_=async M=>{try{await l.mutateAsync({automation_id:s,type:"cron",cron_expression:M}),ge.success("Starter added"),f(!1)}catch(E){const k=E,w=k instanceof Error?k.message:"Failed to add starter";ge.error(w)}},e[2]=l,e[3]=s,e[4]=f,e[5]=_):_=e[5];const m=_;let p;e[6]===Symbol.for("react.memo_cache_sentinel")?(p=o.jsx(cs,{asChild:!0,children:o.jsxs(ne,{variant:"outline",size:"sm",children:[o.jsx(us,{size:14}),"Add Starter"]})}),e[6]=p):p=e[6];let g;e[7]===Symbol.for("react.memo_cache_sentinel")?(g=o.jsxs(Eh,{className:"gap-2.5",children:[o.jsx(Ps,{size:14,className:"text-muted-foreground shrink-0"}),"Every..."]}),e[7]=g):g=e[7];let v;e[8]!==l||e[9]!==m?(v=Wp.map(M=>o.jsxs(kt,{className:"gap-2.5",onSelect:()=>m(M.cron),disabled:l.isPending,children:[o.jsx(Ps,{size:14,className:"text-muted-foreground shrink-0"}),"Every ",M.label]},M.cron)),e[8]=l,e[9]=m,e[10]=v):v=e[10];let x;e[11]!==v?(x=o.jsxs(Th,{children:[g,o.jsx(Rh,{className:"w-[160px]",children:v})]}),e[11]=v,e[12]=x):x=e[12];let S;e[13]!==f||e[14]!==n?(S=()=>{f(!1),n?.()},e[13]=f,e[14]=n,e[15]=S):S=e[15];let b;e[16]===Symbol.for("react.memo_cache_sentinel")?(b=o.jsx(Ps,{size:14,className:"text-muted-foreground shrink-0"}),e[16]=b):b=e[16];let y;e[17]!==S?(y=o.jsxs(kt,{className:"gap-2.5",onSelect:S,children:[b,"Custom (cron)"]}),e[17]=S,e[18]=y):y=e[18];let N;e[19]!==f||e[20]!==a?(N=()=>{f(!1),a?.()},e[19]=f,e[20]=a,e[21]=N):N=e[21];let C;e[22]===Symbol.for("react.memo_cache_sentinel")?(C=o.jsx(Ws,{size:14,className:"text-muted-foreground shrink-0"}),e[22]=C):C=e[22];let D;e[23]!==N?(D=o.jsxs(kt,{className:"gap-2.5",onSelect:N,children:[C,"Event"]}),e[23]=N,e[24]=D):D=e[24];let R;e[25]!==D||e[26]!==x||e[27]!==y?(R=o.jsxs(hs,{align:"end",className:"w-[200px]",children:[x,y,D]}),e[25]=D,e[26]=x,e[27]=y,e[28]=R):R=e[28];let B;return e[29]!==f||e[30]!==u||e[31]!==R?(B=o.jsxs(ls,{open:u,onOpenChange:f,children:[p,R]}),e[29]=f,e[30]=u,e[31]=R,e[32]=B):B=e[32],B}function Vp(t){const e=W.c(60),{trigger:s,automationId:i,connectionName:r}=t,{triggerAdd:n,triggerRemove:a}=Js(),[l,h]=P.useState(!1);let c;e[0]!==s.cron_expression?(c=s.cron_expression?Fp(s.cron_expression):null,e[0]=s.cron_expression,e[1]=c):c=e[1];const u=c,[d,f]=P.useState(u?.count??1),[_,m]=P.useState(!1),[p,g]=P.useState(s.cron_expression??""),v=a.isPending||n.isPending,x=s.type==="cron";let S;e[2]!==i||e[3]!==a||e[4]!==s.id?(S=async()=>{try{await a.mutateAsync({trigger_id:s.id,automation_id:i}),ge.success("Starter removed")}catch{ge.error("Failed to remove starter")}h(!1)},e[2]=i,e[3]=a,e[4]=s.id,e[5]=S):S=e[5];const b=S;let y;e[6]!==n||e[7]!==i||e[8]!==p||e[9]!==a||e[10]!==s.cron_expression||e[11]!==s.id?(y=async()=>{const U=p.trim();if(!U||!zs(U)||U===s.cron_expression){m(!1),g(s.cron_expression??"");return}try{await n.mutateAsync({automation_id:i,type:"cron",cron_expression:U}),await a.mutateAsync({trigger_id:s.id,automation_id:i}),m(!1)}catch{ge.error("Failed to update starter"),g(s.cron_expression??""),m(!1)}},e[6]=n,e[7]=i,e[8]=p,e[9]=a,e[10]=s.cron_expression,e[11]=s.id,e[12]=y):y=e[12];const N=y;let C;e[13]!==n||e[14]!==i||e[15]!==u||e[16]!==a||e[17]!==s.cron_expression||e[18]!==s.id?(C=async U=>{if(!u)return;const V=Math.max(1,U),J=$p(V,u.unit);if(J!==s.cron_expression)try{await n.mutateAsync({automation_id:i,type:"cron",cron_expression:J}),await a.mutateAsync({trigger_id:s.id,automation_id:i})}catch{ge.error("Failed to update starter"),f(u.count)}},e[13]=n,e[14]=i,e[15]=u,e[16]=a,e[17]=s.cron_expression,e[18]=s.id,e[19]=C):C=e[19];const D=C;let R;e[20]!==x?(R=x?o.jsx(Ps,{size:14,className:"text-muted-foreground shrink-0"}):o.jsx(Ws,{size:14,className:"text-muted-foreground shrink-0"}),e[20]=x,e[21]=R):R=e[21];let B;e[22]!==r||e[23]!==d||e[24]!==p||e[25]!==D||e[26]!==N||e[27]!==u||e[28]!==x||e[29]!==_||e[30]!==v||e[31]!==s.cron_expression||e[32]!==s.event_type||e[33]!==s.params?(B=u&&x?o.jsxs(o.Fragment,{children:[o.jsx("span",{className:"text-sm text-muted-foreground",children:"Every"}),o.jsx("input",{type:"number",min:1,value:d,onChange:U=>f(parseInt(U.target.value)||1),onBlur:()=>D(d),onKeyDown:U=>{U.key==="Enter"&&U.target.blur(),U.key==="Escape"&&f(u.count)},disabled:v,className:"w-12 text-center text-sm h-7 border border-border rounded-md bg-background px-1 focus:outline-none focus:ring-1 focus:ring-ring"}),o.jsx("span",{className:"text-sm",children:Hp(u.unit,d)})]}):x&&_?o.jsxs(o.Fragment,{children:[o.jsx("input",{type:"text",value:p,onChange:U=>g(U.target.value),onBlur:N,onKeyDown:U=>{U.key==="Enter"&&U.target.blur(),U.key==="Escape"&&(m(!1),g(s.cron_expression??""))},className:"flex-1 text-sm font-mono bg-transparent outline-none",autoFocus:!0}),p&&!zs(p)&&o.jsx("span",{className:"text-xs text-muted-foreground/60 shrink-0",children:"invalid"})]}):o.jsxs("div",{className:"flex flex-col gap-0.5 flex-1 min-w-0",children:[o.jsx("span",{className:"text-sm font-mono text-xs text-muted-foreground truncate",children:x?zp(s.cron_expression??""):`${s.event_type}${r?` · ${r}`:""}`}),!x&&s.params&&Object.keys(s.params).length>0&&o.jsx("span",{className:"text-xs text-muted-foreground/60 truncate",children:Object.entries(s.params).map(Kp).join(", ")})]}),e[22]=r,e[23]=d,e[24]=p,e[25]=D,e[26]=N,e[27]=u,e[28]=x,e[29]=_,e[30]=v,e[31]=s.cron_expression,e[32]=s.event_type,e[33]=s.params,e[34]=B):B=e[34];let M;e[35]!==v?(M=v&&o.jsx(Ae,{size:13,className:"animate-spin text-muted-foreground"}),e[35]=v,e[36]=M):M=e[36];let E;e[37]!==u||e[38]!==x||e[39]!==_||e[40]!==s.cron_expression?(E=x&&!u&&!_&&o.jsx(ne,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 opacity-0 group-hover:opacity-100 transition-opacity",onClick:()=>{g(s.cron_expression??""),m(!0)},children:o.jsx(gh,{size:13,className:"text-muted-foreground"})}),e[37]=u,e[38]=x,e[39]=_,e[40]=s.cron_expression,e[41]=E):E=e[41];let k;e[42]===Symbol.for("react.memo_cache_sentinel")?(k=o.jsx(ne,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 opacity-0 group-hover:opacity-100 transition-opacity",onClick:()=>h(!0),children:o.jsx(ds,{size:13,className:"text-muted-foreground"})}),e[42]=k):k=e[42];let w;e[43]!==M||e[44]!==E?(w=o.jsxs("div",{className:"ml-auto flex items-center gap-1",children:[M,E,k]}),e[43]=M,e[44]=E,e[45]=w):w=e[45];let j;e[46]!==w||e[47]!==R||e[48]!==B?(j=o.jsxs("div",{className:"flex items-center gap-2.5 px-3 py-2.5 rounded-lg border border-border bg-background group",children:[R,B,w]}),e[46]=w,e[47]=R,e[48]=B,e[49]=j):j=e[49];let T;e[50]===Symbol.for("react.memo_cache_sentinel")?(T=o.jsxs(ya,{children:[o.jsx(wa,{children:"Remove Starter"}),o.jsx(Ca,{children:"Are you sure you want to remove this starter?"})]}),e[50]=T):T=e[50];let I;e[51]===Symbol.for("react.memo_cache_sentinel")?(I=o.jsx(Na,{children:"Cancel"}),e[51]=I):I=e[51];let A;e[52]!==b?(A=o.jsxs(Sa,{children:[T,o.jsxs(ka,{children:[I,o.jsx(ja,{onClick:b,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Remove"})]})]}),e[52]=b,e[53]=A):A=e[53];let O;e[54]!==l||e[55]!==A?(O=o.jsx(ba,{open:l,onOpenChange:h,children:A}),e[54]=l,e[55]=A,e[56]=O):O=e[56];let q;return e[57]!==j||e[58]!==O?(q=o.jsxs(o.Fragment,{children:[j,O]}),e[57]=j,e[58]=O,e[59]=q):q=e[59],q}function Kp(t){const[e,s]=t;return`${e}: ${s}`}function qp(t){const e=W.c(55),{automationId:s,onDone:i}=t;let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r={binding:"TRIGGER"},e[0]=r):r=e[0];const n=Bi(r),[a,l]=P.useState(),[h,c]=P.useState();let u;e[1]===Symbol.for("react.memo_cache_sentinel")?(u={},e[1]=u):u=e[1];const[d,f]=P.useState(u),{triggerAdd:_}=Js(),{data:m,isLoading:p}=Ah(a);let g,v,x,S,b,y;if(e[2]!==_||e[3]!==s||e[4]!==a||e[5]!==h||e[6]!==p||e[7]!==i||e[8]!==d||e[9]!==n||e[10]!==m){const D=m?.find(A=>A.type===h);let R;e[17]!==_||e[18]!==s||e[19]!==a||e[20]!==h||e[21]!==i||e[22]!==d?(R=async()=>{if(!(!a||!h))try{await _.mutateAsync({automation_id:s,type:"event",event_type:h,connection_id:a,params:d}),we("automation_trigger_added",{automation_id:s,trigger_type:"event",connection_id:a,event_type:h}),ge.success("Event trigger added"),i()}catch{ge.error("Failed to add event trigger")}},e[17]=_,e[18]=s,e[19]=a,e[20]=h,e[21]=i,e[22]=d,e[23]=R):R=e[23],g=R,v="flex flex-col gap-3 px-3 py-3 rounded-lg border border-border bg-background";let B,M;e[24]===Symbol.for("react.memo_cache_sentinel")?(M=o.jsx(Ws,{size:14,className:"text-muted-foreground shrink-0"}),B=o.jsx("span",{className:"text-sm font-medium",children:"Event trigger"}),e[24]=B,e[25]=M):(B=e[24],M=e[25]);let E;e[26]===Symbol.for("react.memo_cache_sentinel")?(E=o.jsx(ds,{size:13}),e[26]=E):E=e[26],e[27]!==i?(x=o.jsxs("div",{className:"flex items-center gap-2",children:[M,B,o.jsx("button",{type:"button",className:"ml-auto shrink-0 p-0.5 rounded text-muted-foreground hover:text-foreground",onClick:i,children:E})]}),e[27]=i,e[28]=x):x=e[28];const k=a??"";let w;e[29]===Symbol.for("react.memo_cache_sentinel")?(w=A=>{l(A),c(void 0),f({})},e[29]=w):w=e[29];let j;e[30]===Symbol.for("react.memo_cache_sentinel")?(j=o.jsx(ns,{className:"w-full",children:o.jsx(os,{placeholder:"Select connection..."})}),e[30]=j):j=e[30];let T;e[31]!==n?(T=n.length===0?o.jsx("div",{className:"px-2 py-3 text-center text-xs text-muted-foreground",children:"No connections with trigger support"}):n.map(Xp),e[31]=n,e[32]=T):T=e[32];let I;e[33]!==T?(I=o.jsx(as,{children:T}),e[33]=T,e[34]=I):I=e[34],e[35]!==k||e[36]!==I?(S=o.jsxs(rs,{value:k,onValueChange:w,children:[j,I]}),e[35]=k,e[36]=I,e[37]=S):S=e[37],e[38]!==a||e[39]!==h||e[40]!==p||e[41]!==m?(b=a&&o.jsxs(rs,{value:h??"",onValueChange:A=>{c(A),f({})},children:[o.jsx(ns,{className:"w-full",children:p?o.jsxs("span",{className:"flex items-center gap-2 text-muted-foreground",children:[o.jsx(Ae,{size:13,className:"animate-spin"}),"Loading events..."]}):o.jsx(os,{placeholder:"Select event type...",children:h??"Select event type..."})}),o.jsx(as,{children:m?.map(Yp)})]}),e[38]=a,e[39]=h,e[40]=p,e[41]=m,e[42]=b):b=e[42],y=D?.paramsSchema&&Object.keys(D.paramsSchema).length>0&&o.jsx("div",{className:"flex flex-col gap-2",children:Object.entries(D.paramsSchema).map(A=>{const[O,q]=A;return o.jsxs("div",{className:"flex flex-col gap-1",children:[o.jsxs("label",{className:"text-xs text-muted-foreground",children:[O,q.description&&o.jsxs("span",{className:"text-muted-foreground/60",children:[" ","— ",q.description]})]}),q.enum?o.jsxs(rs,{value:d[O]??"",onValueChange:U=>f(V=>({...V,[O]:U})),children:[o.jsx(ns,{className:"w-full",children:o.jsx(os,{placeholder:`Select ${O}...`})}),o.jsx(as,{children:q.enum.map(Gp)})]}):o.jsx("input",{type:"text",value:d[O]??"",onChange:U=>f(V=>({...V,[O]:U.target.value})),placeholder:q.description??O,className:"text-sm border border-border rounded-md bg-background px-2 py-1.5 focus:outline-none focus:ring-1 focus:ring-ring"})]},O)})}),e[2]=_,e[3]=s,e[4]=a,e[5]=h,e[6]=p,e[7]=i,e[8]=d,e[9]=n,e[10]=m,e[11]=g,e[12]=v,e[13]=x,e[14]=S,e[15]=b,e[16]=y}else g=e[11],v=e[12],x=e[13],S=e[14],b=e[15],y=e[16];let N;e[43]!==_||e[44]!==a||e[45]!==h||e[46]!==g?(N=a&&h&&o.jsx(ne,{size:"sm",onClick:g,disabled:_.isPending,children:_.isPending?o.jsx(Ae,{size:13,className:"animate-spin"}):"Add trigger"}),e[43]=_,e[44]=a,e[45]=h,e[46]=g,e[47]=N):N=e[47];let C;return e[48]!==v||e[49]!==x||e[50]!==S||e[51]!==b||e[52]!==y||e[53]!==N?(C=o.jsxs("div",{className:v,children:[x,S,b,y,N]}),e[48]=v,e[49]=x,e[50]=S,e[51]=b,e[52]=y,e[53]=N,e[54]=C):C=e[54],C}function Gp(t){return o.jsx(Pt,{value:t,children:t},t)}function Yp(t){return o.jsx(Pt,{value:t.type,children:o.jsxs("div",{className:"flex flex-col",children:[o.jsx("span",{children:t.type}),o.jsx("span",{className:"text-xs text-muted-foreground",children:t.description})]})},t.type)}function Xp(t){return o.jsx(Pt,{value:t.id,children:t.title},t.id)}function Jp({automationId:t,automation:e,onBack:s,onDelete:i}){const r=e.virtual_mcp_id,{org:n}=xe(),{update:a,triggerAdd:l}=Js(),h=Bi(),c=new Map(h.map(re=>[re.id,re.title])),{createTaskWithMessage:u}=bt(),{setModel:d,setSimpleModeTier:f,credentialId:_,selectedModel:m}=Ri(),p=Ih(),{setChatOpen:g}=Ai(),{sendMessage:v}=ps(),x=pa(),[S,b]=Gl(),y=e.messages?.[0]?.metadata?.tiptapDoc??void 0,[N,C]=P.useState(y),[D,R]=P.useState(!1),[B,M]=P.useState(!1),[E,k]=P.useState(""),[w,j]=P.useState(!1),[T,I]=P.useState(!1),A=P.useRef(!1),O=P.useRef(!1),q=P.useRef(y),U=async()=>{if(T)return;const Fe=jn(N).filter(Ss=>Ss.type==="text").map(Ss=>Ss.text).join(`
182
- `);if(Fe.trim()){I(!0);try{Ke(),we("automation_improve_clicked",{automation_id:t,agent_id:r,instructions_length:Fe.length}),await x(["studio-automation-manager"]),g(!0),await v({tiptapDoc:za({managerAgentId:ra.AUTOMATION_MANAGER(n.id),managerName:"Automation Manager",kind:"automation",id:t,instructions:Fe})})}finally{I(!1)}}},V=e.models?.credentialId||_||"",J=e.models?.thinking?.id||m?.modelId||"",Z=e.models?.tier??"",F=Qo({defaultValues:{name:e.name,active:e.active,credential_id:V,model_id:J,tier:Z}}),$=F.watch("active"),H=F.watch("credential_id"),Q=F.watch("model_id"),{models:L,isLoading:ee}=$c(H||void 0),se=L.find(re=>re.modelId===Q)??null,te=F.watch("tier"),G=["fast","smart","thinking"].find(re=>p.chat[re]?.modelId===Q&&p.chat[re]?.keyId===H),he=te||G||"smart",fe=re=>{const Fe=p.chat[re];Fe&&(F.setValue("credential_id",Fe.keyId),F.setValue("model_id",Fe.modelId),F.setValue("tier",re),me("credential_id"),me("model_id"),me("tier"),Y())},de=P.useRef(null),ue=P.useRef(new Set),pe=P.useRef(0),De=P.useRef(null),Ue=3e4,Ke=()=>{De.current&&(clearTimeout(De.current),De.current=null),de.current!==null&&(we("automation_updated",{automation_id:t,agent_id:r,fields:Array.from(ue.current),save_count:pe.current,edit_duration_ms:Date.now()-de.current}),de.current=null,ue.current=new Set,pe.current=0)},Qe=P.useRef(new Set),me=re=>{Qe.current.add(re)},Tt=async()=>{const re=Array.from(Qe.current);if(!(re.length>0)&&!O.current)return!0;const Ss=O.current;O.current=!1,Qe.current=new Set;const rt=F.getValues(),Ll=q.current;try{const ys=rt.credential_id&&rt.model_id?rt.credential_id:"",Wi=rt.credential_id&&rt.model_id?rt.model_id:"",kn=p.enabled?rt.tier||G:rt.tier||void 0,Ol={id:t,name:rt.name,active:rt.active,models:{credentialId:ys,thinking:{id:Wi},...kn?{tier:kn}:{}},messages:oc(Ll),temperature:0};await a.mutateAsync(Ol),de.current===null&&(de.current=Date.now());for(const zl of re)ue.current.add(zl);return Ss&&ue.current.add("messages"),pe.current+=1,De.current&&clearTimeout(De.current),De.current=setTimeout(Ke,Ue),ys!==rt.credential_id&&F.setValue("credential_id",ys),Wi!==rt.model_id&&F.setValue("model_id",Wi),!0}catch{O.current=!0;for(const ys of re)Qe.current.add(ys);return!1}},{schedule:Y,flush:ae}=Da({save:Tt}),je=re=>{re&&me(re),Y()},dt=re=>{if(q.current=re,C(re),!A.current){A.current=!0;return}O.current=!0,Y()},Zt=async()=>{we("automation_test_clicked",{automation_id:t,agent_id:r});const re=await ae();if(Ke(),!re)return;if(!N){ge.error("No instructions configured for this automation");return}p.enabled?f(he):se&&H&&d({...se,keyId:H}),g(!0),b({...S,toolApprovalLevel:"auto"});const Fe=jn(N);u({message:{tiptapDoc:N,parts:Fe},virtualMcpId:r||void 0})};return o.jsxs(o.Fragment,{children:[s&&o.jsx("div",{className:"flex items-center pb-4 shrink-0",children:o.jsxs(ne,{variant:"ghost",size:"sm",onClick:s,children:[o.jsx(Aa,{size:14}),"Back to list"]})}),o.jsxs("div",{className:"flex flex-col gap-8",children:[o.jsxs("div",{className:"flex flex-col gap-1.5",children:[o.jsxs("div",{className:"flex items-center justify-between gap-4",children:[o.jsx(Ht,{control:F.control,name:"name",render:({field:re})=>o.jsx(vs,{...re,onChange:Fe=>{re.onChange(Fe),je("name")},placeholder:"Automation name",className:"border border-transparent shadow-none px-0 text-lg font-medium h-auto focus-visible:ring-0 focus-visible:border-border bg-transparent flex-1",style:{boxShadow:"none"}})}),i&&o.jsx(ne,{variant:"ghost",size:"icon",className:"text-muted-foreground hover:text-destructive shrink-0",onClick:i,children:o.jsx(xr,{size:14})})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(Ht,{control:F.control,name:"active",render:({field:re})=>o.jsx(vr,{checked:re.value,onCheckedChange:Fe=>{re.onChange(Fe),me("active"),setTimeout(()=>ae(),0)},className:"cursor-pointer"})}),o.jsx("span",{className:"text-sm text-muted-foreground",children:$?"Active":"Inactive"}),o.jsx("span",{className:"text-muted-foreground/50 text-sm",children:"·"}),o.jsx(ga,{id:e.created_by,size:"2xs",className:"text-sm text-muted-foreground"})]})]}),o.jsxs("div",{className:"flex flex-col gap-2.5",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("span",{className:"text-xs font-semibold text-muted-foreground/60",children:"Starter"}),o.jsx(Up,{automationId:t,open:D,onOpenChange:R,onCustomSelect:()=>{M(!0),j(!1),k("")},onEventSelect:()=>{j(!0),M(!1)}})]}),e.triggers.length===0&&!B?o.jsx("div",{className:"rounded-lg border border-dashed border-border px-4 py-6 text-center",children:o.jsxs("p",{className:"text-sm text-muted-foreground",children:["When should this automation run?"," ",o.jsx("button",{type:"button",className:"text-foreground underline underline-offset-2 cursor-pointer hover:text-foreground/80 transition-colors",onClick:()=>R(!0),children:"Add a starter"})," ","to get going."]})}):o.jsx("div",{className:"flex flex-col gap-2",children:e.triggers.map(re=>o.jsx(Vp,{trigger:re,automationId:t,connectionName:re.connection_id?c.get(re.connection_id):void 0},re.id))}),B&&o.jsxs("div",{className:"flex items-center gap-2.5 px-3 py-2.5 rounded-lg border border-border bg-background group",children:[o.jsx(Ps,{size:14,className:"text-muted-foreground shrink-0"}),o.jsx("input",{type:"text",value:E,onChange:re=>k(re.target.value),onBlur:async()=>{const re=E.trim();if(!(!re||!zs(re)))try{await l.mutateAsync({automation_id:t,type:"cron",cron_expression:re}),we("automation_trigger_added",{automation_id:t,trigger_type:"cron"}),ge.success("Starter added"),M(!1),k("")}catch{ge.error("Failed to add starter")}},onKeyDown:async re=>{const Fe=E.trim();re.key==="Enter"&&Fe&&zs(Fe)&&re.target.blur(),re.key==="Escape"&&(M(!1),k(""))},placeholder:"0 9 * * 1-5",className:"flex-1 text-sm font-mono bg-transparent outline-none placeholder:text-muted-foreground/40",autoFocus:!0}),E&&!zs(E)&&o.jsx("span",{className:"text-xs text-muted-foreground/60 shrink-0",children:"invalid"}),l.isPending&&o.jsx(Ae,{size:13,className:"animate-spin text-muted-foreground shrink-0"}),o.jsx("button",{type:"button",className:"shrink-0 p-0.5 rounded text-muted-foreground opacity-0 group-hover:opacity-100 hover:text-foreground transition-opacity",onClick:()=>{M(!1),k("")},children:o.jsx(ds,{size:13})})]}),w&&o.jsx(P.Suspense,{fallback:o.jsxs("div",{className:"flex items-center gap-2 px-3 py-3 rounded-lg border border-border bg-background",children:[o.jsx(Ae,{size:13,className:"animate-spin text-muted-foreground"}),o.jsx("span",{className:"text-sm text-muted-foreground",children:"Loading connections..."})]}),children:o.jsx(qp,{automationId:t,onDone:()=>j(!1)})})]}),o.jsxs("div",{className:"flex flex-col gap-2.5",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("span",{className:"text-xs font-semibold text-muted-foreground/60",children:"Instructions"}),o.jsxs(ne,{variant:"outline",size:"sm",className:"h-7 gap-1.5 px-2 text-xs",disabled:T||!N,onClick:U,children:[o.jsx(Ra,{size:13}),"Improve"]})]}),o.jsx(tc,{tiptapDoc:N,setTiptapDoc:dt,placeholder:"What should this automation do?",children:o.jsxs("div",{className:"rounded-xl border border-border min-h-[120px] flex flex-col",children:[o.jsx(sc,{virtualMcpId:r||null,className:"max-h-[45vh]"}),o.jsxs("div",{className:"flex items-center justify-end gap-1.5 p-2.5",children:[p.enabled?o.jsx(ic,{tier:he,onSelect:fe}):o.jsx(Mh,{model:se,isLoading:ee,credentialId:H||null,onCredentialChange:re=>{F.setValue("credential_id",re??""),F.setValue("model_id",""),F.setValue("tier",""),me("credential_id"),me("model_id"),me("tier"),Y()},onModelChange:re=>{F.setValue("model_id",re.modelId),F.setValue("tier",""),me("tier"),je("model_id")},placeholder:"Model"}),o.jsxs(Ge,{children:[o.jsx(Ye,{asChild:!0,children:o.jsxs(ne,{type:"button",variant:"default",className:"h-8 gap-1.5 rounded-md px-3 text-sm font-medium",onClick:Zt,disabled:!r,children:[o.jsx(fc,{size:16}),"Test"]})}),o.jsx(Xe,{children:"Test Automation"})]})]})]})})]})]})]})}function Zp(t){const e=W.c(5),{tabId:s}=t;let i;e[0]!==s?(i=oa(s),e[0]=s,e[1]=i):i=e[1];const r=i;if(!r)return null;let n;e[2]===Symbol.for("react.memo_cache_sentinel")?(n=o.jsx("div",{className:"flex-1 flex items-center justify-center",children:o.jsx(Ae,{size:20,className:"animate-spin text-muted-foreground"})}),e[2]=n):n=e[2];let a;return e[3]!==r.id?(a=o.jsx(ht,{children:o.jsx(ht.Content,{children:o.jsx(ht.Body,{children:o.jsx(P.Suspense,{fallback:n,children:o.jsx(Qp,{id:r.id})})})})}),e[3]=r.id,e[4]=a):a=e[4],a}function Qp(t){const e=W.c(8),{id:s}=t,i=Lt(),{data:r,isLoading:n}=Bh(s);let a;e[0]!==i?(a=()=>i({to:".",search:eg,replace:!0}),e[0]=i,e[1]=a):a=e[1];const l=a;if(n){let c;return e[2]===Symbol.for("react.memo_cache_sentinel")?(c=o.jsx("div",{className:"flex-1 flex items-center justify-center",children:o.jsx(Ae,{size:20,className:"animate-spin text-muted-foreground"})}),e[2]=c):c=e[2],c}if(!r){let c;return e[3]===Symbol.for("react.memo_cache_sentinel")?(c=o.jsx("div",{className:"flex-1 flex items-center justify-center text-sm text-muted-foreground",children:"Automation not found"}),e[3]=c):c=e[3],c}let h;return e[4]!==r||e[5]!==s||e[6]!==l?(h=o.jsx(Jp,{automationId:s,automation:r,onBack:l}),e[4]=r,e[5]=s,e[6]=l,e[7]=h):h=e[7],h}function eg(t){return{...t,main:"automations"}}function tg(t){const e=W.c(20),{virtualMcpId:s}=t,i=Lt(),{data:r}=Ph(s),n=r===void 0?[]:r,{create:a}=Js(),{selectedModel:l,credentialId:h}=Ri(),[c,u]=P.useState(""),d=c.toLowerCase(),f=n.filter(E=>E.name.toLowerCase().includes(d));let _;e[0]!==i?(_=E=>i({to:".",search:k=>({...k,main:"automation:"+E}),replace:!0}),e[0]=i,e[1]=_):_=e[1];const m=_,p=async()=>{if(a.isPending)return;we("automation_new_clicked",{virtual_mcp_id:s,existing_count:n.length});const E=l?.modelId&&h?{credentialId:h,modelId:l.modelId}:null,k=await a.mutateAsync(Oh(s,E));m(k.id)},g=ht,v=ht,x=ht;let S;e[2]===Symbol.for("react.memo_cache_sentinel")?(S=o.jsx(ht.Title,{children:"Automations"}),e[2]=S):S=e[2];const b=n.length>0&&o.jsx(zh,{value:c,onChange:u,placeholder:"Search automations...",className:"w-full md:w-[375px]"});let y;e[3]===Symbol.for("react.memo_cache_sentinel")?(y=o.jsx(us,{size:14}),e[3]=y):y=e[3];let N;e[4]!==a.isPending||e[5]!==p?(N=o.jsxs(ne,{size:"sm",onClick:p,disabled:a.isPending,children:[y,"New automation"]}),e[4]=a.isPending,e[5]=p,e[6]=N):N=e[6];let C;e[7]!==b||e[8]!==N?(C=o.jsxs("div",{className:"flex flex-col gap-6",children:[S,o.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[b,N]})]}),e[7]=b,e[8]=N,e[9]=C):C=e[9];const D=n.length===0?o.jsx("div",{className:"flex items-center justify-center py-20",children:o.jsx(Hs,{image:o.jsx(Ws,{size:48,className:"text-muted-foreground"}),title:"No automations yet",description:"Create your first automation to run this agent on a schedule or in response to events.",actions:o.jsxs(ne,{size:"sm",onClick:p,disabled:a.isPending,children:[o.jsx(us,{size:14}),"New automation"]})})}):f.length===0?o.jsx("div",{className:"flex items-center justify-center py-20",children:o.jsx(Hs,{image:o.jsx(Ws,{size:48,className:"text-muted-foreground"}),title:"No automations found",description:`No automations match "${c}"`})}):o.jsx("div",{className:"mt-6 rounded-xl border border-border overflow-hidden",children:f.map(E=>o.jsx(Lh,{automation:E,onClick:()=>m(E.id)},E.id))});let R;e[10]!==D||e[11]!==x.Body||e[12]!==C?(R=o.jsxs(x.Body,{children:[C,D]}),e[10]=D,e[11]=x.Body,e[12]=C,e[13]=R):R=e[13];let B;e[14]!==R||e[15]!==v.Content?(B=o.jsx(v.Content,{children:R}),e[14]=R,e[15]=v.Content,e[16]=B):B=e[16];let M;return e[17]!==g||e[18]!==B?(M=o.jsx(g,{children:B}),e[17]=g,e[18]=B,e[19]=M):M=e[19],M}function sg(t){const e=W.c(3),{virtualMcpId:s}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=o.jsx("div",{className:"flex-1 flex items-center justify-center",children:o.jsx(Ae,{size:20,className:"animate-spin text-muted-foreground"})}),e[0]=i):i=e[0];let r;return e[1]!==s?(r=o.jsx(P.Suspense,{fallback:i,children:o.jsx(tg,{virtualMcpId:s})}),e[1]=s,e[2]=r):r=e[2],r}const Vo=P.lazy(()=>Yl(()=>import("./project-app-view-D--E6naM.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56])).then(t=>({default:t.AppViewContent})));function ig(t){const e=W.c(43),{taskId:s,virtualMcpId:i}=t;let r;e[0]!==s||e[1]!==i?(r={virtualMcpId:i,taskId:s},e[0]=s,e[1]=i,e[2]=r):r=e[2];const{activeTab:n,layoutTabs:a,expandedTools:l,automationTabParsed:h}=Oa(r);if(xc(n)){let m;return e[3]!==i?(m=o.jsx(qn,{virtualMcpId:i}),e[3]=i,e[4]=m):m=e[4],m}if(n==="git"){let m;return e[5]!==i?(m=o.jsx(Ou,{virtualMcpId:i}),e[5]=i,e[6]=m):m=e[6],m}if(n==="automations"){let m;return e[7]!==i?(m=o.jsx(sg,{virtualMcpId:i}),e[7]=i,e[8]=m):m=e[8],m}if(n==="env"){let m;return e[9]!==i?(m=o.jsx(Op,{virtualMcpId:i}),e[9]=i,e[10]=m):m=e[10],m}if(n==="preview"){let m;return e[11]!==i?(m=o.jsx(Sf,{virtualMcpId:i}),e[11]=i,e[12]=m):m=e[12],m}if(h){let m;return e[13]!==n?(m=o.jsx(Zp,{tabId:n}),e[13]=n,e[14]=m):m=e[14],m}let c;e[15]!==n?(c=bc(n),e[15]=n,e[16]=c):c=e[16];const u=c;if(u){let m;if(e[17]!==l||e[18]!==u.connectionId||e[19]!==u.toolName){let S;e[21]!==u.connectionId||e[22]!==u.toolName?(S=b=>b.appId===u.connectionId&&b.toolName===u.toolName,e[21]=u.connectionId,e[22]=u.toolName,e[23]=S):S=e[23],m=l.find(S),e[17]=l,e[18]=u.connectionId,e[19]=u.toolName,e[20]=m}else m=e[20];const p=m;let g;e[24]===Symbol.for("react.memo_cache_sentinel")?(g=o.jsx("div",{className:"h-full w-full flex items-center justify-center",children:o.jsx(Ae,{size:20,className:"animate-spin text-muted-foreground"})}),e[24]=g):g=e[24];const v=p?.args;let x;return e[25]!==n||e[26]!==u.connectionId||e[27]!==u.toolName||e[28]!==v?(x=o.jsx(P.Suspense,{fallback:g,children:o.jsx(Vo,{connectionId:u.connectionId,toolName:u.toolName,args:v},n)}),e[25]=n,e[26]=u.connectionId,e[27]=u.toolName,e[28]=v,e[29]=x):x=e[29],x}let d;if(e[30]!==n||e[31]!==a){let m;e[33]!==n?(m=p=>p.id===n,e[33]=n,e[34]=m):m=e[34],d=a.find(m),e[30]=n,e[31]=a,e[32]=d}else d=e[32];const f=d;if(f){let m;e[35]===Symbol.for("react.memo_cache_sentinel")?(m=o.jsx("div",{className:"h-full w-full flex items-center justify-center",children:o.jsx(Ae,{size:20,className:"animate-spin text-muted-foreground"})}),e[35]=m):m=e[35];let p;return e[36]!==n||e[37]!==f.id||e[38]!==f.view.appId||e[39]!==f.view.args?(p=o.jsx(P.Suspense,{fallback:m,children:o.jsx(Vo,{connectionId:f.view.appId,toolName:f.id,args:f.view.args},n)}),e[36]=n,e[37]=f.id,e[38]=f.view.appId,e[39]=f.view.args,e[40]=p):p=e[40],p}let _;return e[41]!==i?(_=o.jsx(qn,{virtualMcpId:i}),e[41]=i,e[42]=_):_=e[42],_}function rg(t){const e=W.c(7),{children:s,defaultSize:i}=t,[,r]=P.useTransition();let n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=sa.decoChatPanelWidth(),e[0]=n):n=e[0];const[a,l]=ta(n,45),h=i>0&&i<100?a:i;let c;e[1]!==l?(c=f=>r(()=>{f>0&&f<100&&l(f)}),e[1]=l,e[2]=c):c=e[2];const u=c;let d;return e[3]!==s||e[4]!==h||e[5]!==u?(d=o.jsx(_a,{defaultSize:h,minSize:20,collapsible:!0,collapsedSize:0,className:"min-w-0 overflow-hidden bg-sidebar",onResize:u,order:1,children:s}),e[3]=s,e[4]=h,e[5]=u,e[6]=d):d=e[6],d}function ng(t){const e=W.c(30),{virtualMcpId:s,taskId:i,chatOpen:r,mainOpen:n,chatContent:a}=t;let l;e[0]!==r||e[1]!==n?(l=Pn(r,n),e[0]=r,e[1]=n,e[2]=l):l=e[2];const h=l;let c;e[3]===Symbol.for("react.memo_cache_sentinel")?(c=sa.decoChatPanelWidth(),e[3]=c):c=e[3];const[u]=ta(c,45),d=P.useRef(null);let f,_;e[4]!==r||e[5]!==n||e[6]!==u?(f=()=>{const B=d.current;if(!B)return;const M=Pn(r,n),E=M.chat>0&&M.chat<100?u:M.chat,k=M.chat>0&&M.chat<100?100-u:M.main;B.setLayout([E,k])},_=[r,n,u],e[4]=r,e[5]=n,e[6]=u,e[7]=f,e[8]=_):(f=e[7],_=e[8]),P.useEffect(f,_);const m=`${s}-${i}`;let p;e[9]===Symbol.for("react.memo_cache_sentinel")?(p={overflow:"visible"},e[9]=p):p=e[9];let g;e[10]!==a?(g=a??o.jsx(Ba,{}),e[10]=a,e[11]=g):g=e[11];let v;e[12]!==g?(v=o.jsx("div",{className:"h-full p-0.5 pt-0.25",children:o.jsx("div",{className:"h-full bg-background rounded-[0.75rem] overflow-hidden card-shadow",children:g})}),e[12]=g,e[13]=v):v=e[13];let x;e[14]!==h.chat||e[15]!==v?(x=o.jsx(rg,{defaultSize:h.chat,children:v}),e[14]=h.chat,e[15]=v,e[16]=x):x=e[16];let S;e[17]===Symbol.for("react.memo_cache_sentinel")?(S=o.jsx(rh,{className:"bg-sidebar"}),e[17]=S):S=e[17];const b=h.main;let y;e[18]===Symbol.for("react.memo_cache_sentinel")?(y={overflow:"visible"},e[18]=y):y=e[18];let N;e[19]===Symbol.for("react.memo_cache_sentinel")?(N=ie("flex flex-col h-full min-h-0 bg-background overflow-hidden","card-shadow","transition-[border-radius] duration-200 ease-[var(--ease-out-quart)]","rounded-[0.75rem]"),e[19]=N):N=e[19];let C;e[20]!==i||e[21]!==s?(C=o.jsx("div",{className:"h-full p-0.5 pt-0.25",children:o.jsx("div",{className:N,children:o.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:o.jsx(Ut,{children:o.jsx(ig,{taskId:i,virtualMcpId:s})})})})}),e[20]=i,e[21]=s,e[22]=C):C=e[22];let D;e[23]!==h.main||e[24]!==C?(D=o.jsx(_a,{className:"min-w-0 flex flex-col",order:2,defaultSize:b,style:y,collapsible:!0,collapsedSize:0,minSize:20,children:C}),e[23]=h.main,e[24]=C,e[25]=D):D=e[25];let R;return e[26]!==D||e[27]!==m||e[28]!==x?(R=o.jsxs(nh,{ref:d,direction:"horizontal",className:"flex-1 min-h-0 pb-1 pr-1 pl-0 pt-0",style:p,children:[x,S,D]},m),e[26]=D,e[27]=m,e[28]=x,e[29]=R):R=e[29],R}const mr="flex size-7 shrink-0 items-center justify-center rounded-md transition-colors",Ko="bg-sidebar-accent text-sidebar-foreground",_r="text-sidebar-foreground/60 hover:bg-sidebar-accent hover:text-sidebar-foreground";function og(t){const e=W.c(47),{chatOpen:s,toggleChat:i,onNewTask:r}=t,{tasksOpen:n,toggleTasks:a}=Fc(),l=!!r;let h;e[0]!==n||e[1]!==a?(h=()=>{we("agent_toolbar_toggled",{button:"tasks",next_state:n?"closed":"open"}),a()},e[0]=n,e[1]=a,e[2]=h):h=e[2];const c=n?Ko:_r;let u;e[3]!==c?(u=ie(mr,c),e[3]=c,e[4]=u):u=e[4];let d;e[5]===Symbol.for("react.memo_cache_sentinel")?(d=o.jsx(Pc,{size:16}),e[5]=d):d=e[5];let f;e[6]!==h||e[7]!==u||e[8]!==n?(f=o.jsx(Ye,{asChild:!0,children:o.jsx("button",{type:"button",onClick:h,"aria-pressed":n,className:u,children:d})}),e[6]=h,e[7]=u,e[8]=n,e[9]=f):f=e[9];let _;e[10]===Symbol.for("react.memo_cache_sentinel")?(_=o.jsx(Xe,{side:"bottom",children:"Tasks"}),e[10]=_):_=e[10];let m;e[11]!==f?(m=o.jsxs(Ge,{delayDuration:300,children:[f,_]}),e[11]=f,e[12]=m):m=e[12];let p;e[13]!==s||e[14]!==i?(p=()=>{we("agent_toolbar_toggled",{button:"chat",next_state:s?"closed":"open"}),i()},e[13]=s,e[14]=i,e[15]=p):p=e[15];const g=s?Ko:_r;let v;e[16]!==g?(v=ie(mr,g),e[16]=g,e[17]=v):v=e[17];let x;e[18]===Symbol.for("react.memo_cache_sentinel")?(x=o.jsx(Lc,{size:16}),e[18]=x):x=e[18];let S;e[19]!==s||e[20]!==v||e[21]!==p?(S=o.jsx(Ye,{asChild:!0,children:o.jsx("button",{type:"button",onClick:p,"aria-pressed":s,className:v,children:x})}),e[19]=s,e[20]=v,e[21]=p,e[22]=S):S=e[22];let b;e[23]===Symbol.for("react.memo_cache_sentinel")?(b=o.jsx(Xe,{side:"bottom",children:"Chat"}),e[23]=b):b=e[23];let y;e[24]!==S?(y=o.jsxs(Ge,{delayDuration:300,children:[S,b]}),e[24]=S,e[25]=y):y=e[25];const N=l?"grid-cols-[1fr]":"grid-cols-[0fr]";let C;e[26]!==N?(C=ie("grid transition-[grid-template-columns] duration-200 ease-[var(--ease-out-quart)]",N),e[26]=N,e[27]=C):C=e[27];const D=!l,R=l?0:-1,B=!l,M=l?"translate-x-0 opacity-100":"-translate-x-2 opacity-0";let E;e[28]!==M?(E=ie(mr,_r,"transition-[transform,opacity] duration-200 ease-[var(--ease-out-quart)] will-change-transform",M),e[28]=M,e[29]=E):E=e[29];let k;e[30]===Symbol.for("react.memo_cache_sentinel")?(k=o.jsx(ca,{size:16}),e[30]=k):k=e[30];let w;e[31]!==r||e[32]!==D||e[33]!==R||e[34]!==B||e[35]!==E?(w=o.jsx(Ye,{asChild:!0,children:o.jsx("button",{type:"button",onClick:r,disabled:D,tabIndex:R,"aria-hidden":B,className:E,children:k})}),e[31]=r,e[32]=D,e[33]=R,e[34]=B,e[35]=E,e[36]=w):w=e[36];let j;e[37]===Symbol.for("react.memo_cache_sentinel")?(j=o.jsx(Xe,{side:"bottom",children:"New task"}),e[37]=j):j=e[37];let T;e[38]!==w?(T=o.jsx("div",{className:"overflow-hidden",children:o.jsxs(Ge,{delayDuration:300,children:[w,j]})}),e[38]=w,e[39]=T):T=e[39];let I;e[40]!==C||e[41]!==T?(I=o.jsx("div",{className:C,children:T}),e[40]=C,e[41]=T,e[42]=I):I=e[42];let A;return e[43]!==y||e[44]!==I||e[45]!==m?(A=o.jsxs(o.Fragment,{children:[m,y,I]}),e[43]=y,e[44]=I,e[45]=m,e[46]=A):A=e[46],A}function ag(t,e,s){if(t.length<=s)return{visible:t,overflow:[]};const i=t.slice(0,s),r=t.slice(s);if(e==null)return{visible:i,overflow:r};if(i.some(d=>d.id===e))return{visible:i,overflow:r};const a=r.findIndex(d=>d.id===e);if(a===-1)return{visible:i,overflow:r};const l=i[i.length-1],h=r[a],c=[...i.slice(0,-1),h],u=[l,...r.slice(0,a),...r.slice(a+1)];return{visible:c,overflow:u}}function lg(t){const e=W.c(13),{title:s,icon:i,active:r,onClick:n}=t,a=r?"bg-sidebar-accent text-sidebar-foreground":"text-sidebar-foreground/60 hover:bg-sidebar-accent hover:text-sidebar-foreground";let l;e[0]!==a?(l=ie("shrink-0 flex items-center gap-1.5 h-8 rounded-md px-2","[transition:background-color_180ms_ease,color_180ms_ease]",a),e[0]=a,e[1]=l):l=e[1];let h;e[2]!==i?(h=o.jsx("span",{className:"flex size-5 items-center justify-center shrink-0",children:o.jsx(cg,{icon:i})}),e[2]=i,e[3]=h):h=e[3];let c;e[4]!==s?(c=o.jsx("span",{className:"whitespace-nowrap text-sm font-medium leading-none",children:s}),e[4]=s,e[5]=c):c=e[5];let u;return e[6]!==r||e[7]!==n||e[8]!==l||e[9]!==h||e[10]!==c||e[11]!==s?(u=o.jsxs("button",{type:"button",onClick:n,"aria-pressed":r,"aria-label":s,className:l,children:[h,c]}),e[6]=r,e[7]=n,e[8]=l,e[9]=h,e[10]=c,e[11]=s,e[12]=u):u=e[12],u}function cg(t){const e=W.c(5),{icon:s}=t;if(s.kind==="component"){const{Component:r}=s;let n;return e[0]!==r?(n=o.jsx(r,{className:"size-4"}),e[0]=r,e[1]=n):n=e[1],n}if(s.kind==="url"){let r;return e[2]!==s.src?(r=o.jsx("img",{src:s.src,alt:"",className:"size-4 rounded-sm object-cover"}),e[2]=s.src,e[3]=r):r=e[3],r}let i;return e[4]===Symbol.for("react.memo_cache_sentinel")?(i=o.jsx(fa,{className:"size-4"}),e[4]=i):i=e[4],i}function hg(t){const e=W.c(13),{overflow:s,onSelect:i}=t,[r,n]=P.useState(!1);let a;e[0]!==i?(a=f=>{n(!1),i(f)},e[0]=i,e[1]=a):a=e[1];const l=a;let h;e[2]===Symbol.for("react.memo_cache_sentinel")?(h=o.jsx(Gs,{asChild:!0,children:o.jsx("button",{type:"button",title:"More tabs","aria-label":"More tabs",className:"shrink-0 flex size-8 items-center justify-center rounded-md text-muted-foreground hover:bg-accent hover:text-foreground transition-colors",children:o.jsx(ha,{className:"size-4"})})}),e[2]=h):h=e[2];let c;if(e[3]!==l||e[4]!==s){let f;e[6]!==l?(f=_=>o.jsx("li",{children:o.jsxs("button",{type:"button",onClick:()=>l(_.id),className:"w-full flex items-center gap-2 px-3 py-2 rounded-md hover:bg-accent text-sm text-foreground",children:[o.jsx("span",{className:"flex size-5 items-center justify-center shrink-0",children:o.jsx(dg,{icon:_.icon})}),o.jsx("span",{className:"truncate",children:_.title})]})},_.id),e[6]=l,e[7]=f):f=e[7],c=s.map(f),e[3]=l,e[4]=s,e[5]=c}else c=e[5];let u;e[8]!==c?(u=o.jsx(Ys,{align:"end",className:"w-56 p-1",children:o.jsx("ul",{className:"flex flex-col",children:c})}),e[8]=c,e[9]=u):u=e[9];let d;return e[10]!==r||e[11]!==u?(d=o.jsxs(Xs,{open:r,onOpenChange:n,children:[h,u]}),e[10]=r,e[11]=u,e[12]=d):d=e[12],d}function dg(t){const e=W.c(5),{icon:s}=t;if(s.kind==="component"){const{Component:r}=s;let n;return e[0]!==r?(n=o.jsx(r,{className:"size-4"}),e[0]=r,e[1]=n):n=e[1],n}if(s.kind==="url"){let r;return e[2]!==s.src?(r=o.jsx("img",{src:s.src,alt:"",className:"size-4 rounded-sm object-cover"}),e[2]=s.src,e[3]=r):r=e[3],r}let i;return e[4]===Symbol.for("react.memo_cache_sentinel")?(i=o.jsx(fa,{className:"size-4"}),e[4]=i):i=e[4],i}const ug=6;function fg(t){const e=W.c(20),{virtualMcpId:s,taskId:i}=t,r=Lt();let n;e[0]!==i||e[1]!==s?(n={virtualMcpId:s,taskId:i},e[0]=i,e[1]=s,e[2]=n):n=e[2];const{tabs:a,activeTab:l,mainOpen:h,setActiveTab:c}=Oa(n);let u,d,f,_;if(e[3]!==l||e[4]!==h||e[5]!==r||e[6]!==c||e[7]!==a||e[8]!==s){const g=Sc({activeTab:l,mainOpen:h}),v=N=>N.id==="automations"?g:h&&N.id===l,S=a.find(N=>v(N))?.id??null,{visible:b,overflow:y}=ag(a,S,ug);d=y,u=N=>{const C=a.find(R=>R.id===N),D=S===N&&h;if(we("main_panel_tab_clicked",{virtual_mcp_id:s,tab_id:N,tab_kind:C?.kind??null,was_active:D}),N==="automations"){const R=yc({activeTab:l,mainOpen:h});r({to:".",search:B=>({...B,main:R}),replace:!0});return}c(N)},f="flex items-center min-w-0 ml-auto gap-0.5",_=b.map(N=>o.jsx(lg,{title:N.title,icon:N.icon,active:v(N),onClick:()=>u(N.id)},N.id)),e[3]=l,e[4]=h,e[5]=r,e[6]=c,e[7]=a,e[8]=s,e[9]=u,e[10]=d,e[11]=f,e[12]=_}else u=e[9],d=e[10],f=e[11],_=e[12];let m;e[13]!==u||e[14]!==d?(m=d.length>0&&o.jsx(hg,{overflow:d,onSelect:u}),e[13]=u,e[14]=d,e[15]=m):m=e[15];let p;return e[16]!==f||e[17]!==_||e[18]!==m?(p=o.jsxs("div",{className:f,children:[_,m]}),e[16]=f,e[17]=_,e[18]=m,e[19]=p):p=e[19],p}function mg(t){const e=W.c(12);let s,i,r,n;e[0]!==t?({className:s,orientation:r,decorative:n,...i}=t,e[0]=t,e[1]=s,e[2]=i,e[3]=r,e[4]=n):(s=e[1],i=e[2],r=e[3],n=e[4]);const a=r===void 0?"horizontal":r,l=n===void 0?!0:n;let h;e[5]!==s?(h=ie("bg-border shrink-0 data-[orientation=horizontal]:h-px data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-px",s),e[5]=s,e[6]=h):h=e[6];let c;return e[7]!==l||e[8]!==a||e[9]!==i||e[10]!==h?(c=o.jsx(Xl,{"data-slot":"separator-root",decorative:l,orientation:a,className:h,...i}),e[7]=l,e[8]=a,e[9]=i,e[10]=h,e[11]=c):c=e[11],c}function _g(t){const e=W.c(20),{prNumber:s,disabled:i,send:r}=t;let n;e[0]!==s||e[1]!==r?(n=()=>r(ju({prNumber:s})),e[0]=s,e[1]=r,e[2]=n):n=e[2];const a=n;let l;e[3]!==s||e[4]!==r?(l=()=>r(Nu({prNumber:s})),e[3]=s,e[4]=r,e[5]=l):l=e[5];const h=l;let c;e[6]!==i||e[7]!==a?(c=o.jsx(ne,{size:"sm",variant:"success",className:"rounded-r-none border-r border-success-foreground/20",disabled:i,onClick:a,children:"Publish"}),e[6]=i,e[7]=a,e[8]=c):c=e[8];let u;e[9]===Symbol.for("react.memo_cache_sentinel")?(u=o.jsx(br,{className:"h-3.5 w-3.5"}),e[9]=u):u=e[9];let d;e[10]!==i?(d=o.jsx(cs,{asChild:!0,children:o.jsx(ne,{size:"sm",variant:"success",className:"rounded-l-none px-2",disabled:i,"aria-label":"More actions",children:u})}),e[10]=i,e[11]=d):d=e[11];let f;e[12]!==h?(f=o.jsx(hs,{align:"end",children:o.jsx(kt,{onClick:h,children:"Review"})}),e[12]=h,e[13]=f):f=e[13];let _;e[14]!==d||e[15]!==f?(_=o.jsxs(ls,{children:[d,f]}),e[14]=d,e[15]=f,e[16]=_):_=e[16];let m;return e[17]!==c||e[18]!==_?(m=o.jsxs("div",{className:"inline-flex items-stretch rounded-md",children:[c,_]}),e[17]=c,e[18]=_,e[19]=m):m=e[19],m}const pg=new Set(["failure","timed_out","cancelled","action_required"]);function gg(t){return t.status==="completed"&&pg.has(t.conclusion)}function vg(t){return t.status==="queued"||t.status==="in_progress"}function xg(t){const{branchStatus:e,pr:s,checks:i,reviews:r,loading:n}=t;if(!e||n)return{label:"Loading…",disabled:!0,loading:!0,variant:"outline",tooltip:"Loading branch and pull request status"};switch(e.kind){case"initializing":return{label:"Starting sandbox…",disabled:!0,loading:!0,variant:"outline",tooltip:"Waiting for the sandbox daemon to come online"};case"cloning":return{label:"Cloning repo…",disabled:!0,loading:!0,variant:"outline",tooltip:"Cloning the project repository"};case"clone-failed":return{label:"Clone failed",disabled:!0,variant:"outline",tooltip:e.error||"git clone failed — see setup logs"};case"checking-out":return{label:`Switching to ${e.to}…`,disabled:!0,loading:!0,variant:"outline",tooltip:`Checking out ${e.to}`};case"checkout-failed":return{label:"Checkout failed",disabled:!0,variant:"outline",tooltip:e.error||"git checkout failed — see setup logs"}}const a=e;if(a.workingTreeDirty||a.unpushed>0)return{label:"Save changes",action:"commit-and-push",variant:"default",tooltip:"Commit and push local changes"};if(s?.merged)return!!a.headSha&&!!s.headSha&&a.headSha!==s.headSha?{label:"Continue",action:"create-pr",variant:"special",tooltip:"Open a new PR with the latest commits"}:{label:"Published",disabled:!0,variant:"outline",tooltip:`PR #${s.number} merged into ${s.base}`};if(a.aheadOfBase>0){if(s&&s.state==="closed"&&!s.merged)return{label:"Reopen",action:"reopen",variant:"default",tooltip:`Reopen PR #${s.number}`};if(!s)return{label:"Submit for review",action:"create-pr",variant:"default",tooltip:`Open a PR for ${a.branch} → ${a.base}`};if((r?.mergeableState??"unknown")==="dirty")return{label:`Sync with ${s.base}`,action:"rebase",variant:"default",tooltip:`Resolve conflicts with ${s.base} before merging`};const c=i.filter(gg).map(f=>f.name);if(c.length>0)return{label:"Fix tests",action:"fix-checks",variant:"default",tooltip:`Failing: ${c.join(", ")}`,meta:{failingChecks:c}};const u=i.filter(vg);if(u.length>0)return{label:"Running tests…",disabled:!0,loading:!0,variant:"outline",tooltip:`Waiting on ${u.length} check${u.length===1?"":"s"} to finish`};if(r?.draft)return{label:"Mark ready",action:"mark-ready",variant:"default",tooltip:"Mark draft PR ready for review"};const d=r?.unresolvedConversations??0;return d>0?{label:"Address feedback",action:"resolve-comments",variant:"default",tooltip:`${d} unresolved conversation${d===1?"":"s"}`}:r?.missingRequiredApprovals?{label:"Awaiting review",disabled:!0,variant:"outline",tooltip:"Waiting for required approvals"}:{label:"Publish",action:"merge-split",variant:"success",tooltip:`Squash-merge PR #${s.number} into ${s.base}`}}return{label:"Up to date",disabled:!0,variant:"outline",tooltip:`Branch is in sync with ${a.base}`}}function bg(){return Xt().branchStatus}const Sg=6e4,yg=3e4;function wg(t){const e=W.c(12);let s;e[0]!==t.connectionId||e[1]!==t.orgId||e[2]!==t.orgSlug?(s={connectionId:t.connectionId,orgId:t.orgId,orgSlug:t.orgSlug},e[0]=t.connectionId,e[1]=t.orgId,e[2]=t.orgSlug,e[3]=s):s=e[3];const i=We(s),r=t.prNumber??0;let n;e[4]!==t.owner||e[5]!==t.repo||e[6]!==r?(n={method:"get",owner:t.owner,repo:t.repo,pullNumber:r},e[4]=t.owner,e[5]=t.repo,e[6]=r,e[7]=n):n=e[7];const a=!!t.prNumber;let l;return e[8]!==i||e[9]!==n||e[10]!==a?(l={client:i,toolName:"pull_request_read",toolArguments:n,enabled:a,refetchInterval:Sg,refetchIntervalInBackground:!1,staleTime:yg,select:Cg},e[8]=i,e[9]=n,e[10]=a,e[11]=l):l=e[11],gs(l)}function Cg(t){const e=Zs(t);if(!e)return null;const s=e.mergeable_state??"unknown",i=!!(e.draft??!1),r=Number(e.review_comments??0),n=s==="blocked"&&r>0?r:0;return{draft:i,mergeableState:s,unresolvedConversations:n,missingRequiredApprovals:s==="blocked"&&n===0}}function kg(t){const e=W.c(42),{virtualMcpId:s}=t,{org:i}=xe(),r=Nt(s),{currentBranch:n}=bt(),a=ps(),l=r?.metadata?.githubRepo??null,h=bg(),c=l?.connectionId??"",u=l?.owner??"",d=l?.name??"",f=n??null;let _;e[0]!==i.id||e[1]!==i.slug||e[2]!==c||e[3]!==u||e[4]!==d||e[5]!==f?(_={orgId:i.id,orgSlug:i.slug,connectionId:c,owner:u,repo:d,branch:f},e[0]=i.id,e[1]=i.slug,e[2]=c,e[3]=u,e[4]=d,e[5]=f,e[6]=_):_=e[6];const m=Fa(_),p=m.data??null,g=l?.connectionId??"",v=l?.owner??"",x=l?.name??"",S=p&&p.state==="open"?p.number:null;let b;e[7]!==i.id||e[8]!==i.slug||e[9]!==g||e[10]!==v||e[11]!==x||e[12]!==S?(b={orgId:i.id,orgSlug:i.slug,connectionId:g,owner:v,repo:x,prNumber:S},e[7]=i.id,e[8]=i.slug,e[9]=g,e[10]=v,e[11]=x,e[12]=S,e[13]=b):b=e[13];const y=Wa(b),N=l?.connectionId??"",C=l?.owner??"",D=l?.name??"",R=p&&p.state==="open"?p.number:null;let B;e[14]!==i.id||e[15]!==i.slug||e[16]!==N||e[17]!==C||e[18]!==D||e[19]!==R?(B={orgId:i.id,orgSlug:i.slug,connectionId:N,owner:C,repo:D,prNumber:R},e[14]=i.id,e[15]=i.slug,e[16]=N,e[17]=C,e[18]=D,e[19]=R,e[20]=B):B=e[20];const M=wg(B);if(!l?.connectionId||!n)return null;let E;e[21]!==h||e[22]!==y.data||e[23]!==p||e[24]!==m.isPending||e[25]!==M.data?(E=xg({branchStatus:h,pr:p,checks:y.data??[],reviews:M.data??null,loading:m.isPending}),e[21]=h,e[22]=y.data,e[23]=p,e[24]=m.isPending,e[25]=M.data,e[26]=E):E=e[26];const k=E;let w;e[27]!==a?(w=V=>a.sendMessage({parts:[{type:"text",text:V}]}),e[27]=a,e[28]=w):w=e[28];const j=w,T=a.isStreaming;let I;e[29]!==n||e[30]!==k||e[31]!==T||e[32]!==p||e[33]!==j?(I=V=>{if(!T)switch(V){case"commit-and-push":{j(vu({branch:n}));return}case"create-pr":{j(xu({branch:n}));return}case"reopen":{p&&j(bu({prNumber:p.number}));return}case"rebase":{j(Su({branch:n}));return}case"fix-checks":{p&&j(wu({prNumber:p.number,failingChecks:k.meta?.failingChecks??[]}));return}case"mark-ready":{p&&j(Cu({prNumber:p.number}));return}case"resolve-comments":{p&&j(ku({prNumber:p.number}));return}case"merge-split":return}},e[29]=n,e[30]=k,e[31]=T,e[32]=p,e[33]=j,e[34]=I):I=e[34];const A=I;let O;e[35]===Symbol.for("react.memo_cache_sentinel")?(O=o.jsx(mg,{orientation:"vertical",className:"mx-2 data-[orientation=vertical]:h-5"}),e[35]=O):O=e[35];const q=p?.number;let U;return e[36]!==k||e[37]!==T||e[38]!==A||e[39]!==j||e[40]!==q?(U=o.jsxs(o.Fragment,{children:[O,o.jsx(Ng,{button:k,isStreaming:T,onActivate:A,prNumber:q,send:j})]}),e[36]=k,e[37]=T,e[38]=A,e[39]=j,e[40]=q,e[41]=U):U=e[41],U}function Ng(t){const e=W.c(21),{button:s,isStreaming:i}=t,r=!!s.disabled||i,n=i?"Chat is running":s.tooltip??null;if(s.action==="merge-split"&&t.prNumber!=null){let u;e[0]!==r||e[1]!==t.prNumber||e[2]!==t.send?(u=o.jsx(_g,{prNumber:t.prNumber,disabled:r,send:t.send}),e[0]=r,e[1]=t.prNumber,e[2]=t.send,e[3]=u):u=e[3];let d;return e[4]!==u||e[5]!==n?(d=o.jsx(qo,{label:n,children:u}),e[4]=u,e[5]=n,e[6]=d):d=e[6],d}let a;e[7]!==s.action||e[8]!==t?(a=()=>t.onActivate(s.action),e[7]=s.action,e[8]=t,e[9]=a):a=e[9];let l;e[10]!==s.loading?(l=s.loading?o.jsx(jh,{size:"xs",variant:"default"}):null,e[10]=s.loading,e[11]=l):l=e[11];let h;e[12]!==s.label||e[13]!==s.variant||e[14]!==r||e[15]!==a||e[16]!==l?(h=o.jsxs(ne,{size:"sm",variant:s.variant,disabled:r,onClick:a,children:[l,s.label]}),e[12]=s.label,e[13]=s.variant,e[14]=r,e[15]=a,e[16]=l,e[17]=h):h=e[17];let c;return e[18]!==h||e[19]!==n?(c=o.jsx(qo,{label:n,children:h}),e[18]=h,e[19]=n,e[20]=c):c=e[20],c}function qo(t){const e=W.c(9),{label:s,children:i}=t;if(!s){let l;return e[0]!==i?(l=o.jsx(o.Fragment,{children:i}),e[0]=i,e[1]=l):l=e[1],l}let r;e[2]!==i?(r=o.jsx(Ye,{asChild:!0,children:o.jsx("span",{children:i})}),e[2]=i,e[3]=r):r=e[3];let n;e[4]!==s?(n=o.jsx(Xe,{children:s}),e[4]=s,e[5]=n):n=e[5];let a;return e[6]!==r||e[7]!==n?(a=o.jsx(Zc,{children:o.jsxs(Ge,{children:[r,n]})}),e[6]=r,e[7]=n,e[8]=a):a=e[8],a}function jg(t){const e=W.c(2),{virtualMcp:s}=t;if(!!!(s.metadata?.githubRepo??null)?.connectionId)return null;let n;return e[0]!==s.id?(n=o.jsx(gr.Right,{children:o.jsx(kg,{virtualMcpId:s.id})}),e[0]=s.id,e[1]=n):n=e[1],n}const ss=P.createContext(null);function Cn(){return P.use(ss)}function Go(t){const e=W.c(7),{children:s}=t,{taskId:i}=bt();let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=o.jsx("div",{className:"flex-1 flex items-center justify-center text-sm text-muted-foreground",children:"Something went wrong loading the chat. Try refreshing."}),e[0]=r):r=e[0];let n;e[1]===Symbol.for("react.memo_cache_sentinel")?(n=o.jsx(Ee.Skeleton,{}),e[1]=n):n=e[1];let a;e[2]!==s?(a=s??o.jsx(Ba,{}),e[2]=s,e[3]=a):a=e[3];let l;return e[4]!==a||e[5]!==i?(l=o.jsx(Ut,{fallback:r,children:o.jsx(P.Suspense,{fallback:n,children:o.jsx(Ee.ActiveTaskProvider,{taskId:i,children:a})})}),e[4]=a,e[5]=i,e[6]=l):l=e[6],l}function Yo(t){const e=W.c(3),{onNewTaskRef:s,createNewTask:i}=t;let r;return e[0]!==i||e[1]!==s?(r=()=>(s.current=i,()=>{s.current=null}),e[0]=i,e[1]=s,e[2]=r):r=e[2],P.useLayoutEffect(r),null}function Eg(t){const e=W.c(3),{onOpenSidebar:s}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=o.jsx(lc,{size:20}),e[0]=i):i=e[0];let r;return e[1]!==s?(r=o.jsx("div",{className:"shrink-0 flex items-center justify-between px-3 h-12 bg-background border-b border-border",children:o.jsx("button",{type:"button",onClick:s,className:"flex size-8 items-center justify-center rounded-md text-foreground/60 hover:bg-accent hover:text-foreground transition-colors","aria-label":"Open menu",children:i})}),e[1]=s,e[2]=r):r=e[2],r}function Xo(t){const e=W.c(16),{virtualMcpId:s,hasActiveGithubRepo:i,vmMap:r,children:n}=t,{org:a}=xe(),{currentBranch:l}=bt(),{data:h}=Ti.useSession(),c=h?.user?.id;let u;e[0]!==a.id||e[1]!==a.slug?(u={connectionId:Ot,orgId:a.id,orgSlug:a.slug},e[0]=a.id,e[1]=a.slug,e[2]=u):u=e[2];const d=We(u),{mutate:f}=dn(d);let _;e[3]===Symbol.for("react.memo_cache_sentinel")?(_=new Set,e[3]=_):_=e[3];const m=P.useRef(_);let p,g;e[4]!==l||e[5]!==i||e[6]!==f||e[7]!==c||e[8]!==s||e[9]!==r?(p=()=>{if(i&&c&&l){if(r?.[c]?.[l]){m.current.add(l);return}m.current.has(l)||(m.current.add(l),f({virtualMcpId:s,branch:l},{onError:Tg}))}},g=[i,c,l,r,s,f],e[4]=l,e[5]=i,e[6]=f,e[7]=c,e[8]=s,e[9]=r,e[10]=p,e[11]=g):(p=e[10],g=e[11]),P.useEffect(p,g);const v=l??null;let x;return e[12]!==n||e[13]!==v||e[14]!==s?(x=o.jsx(Qu,{virtualMcpId:s,branch:v,children:n}),e[12]=n,e[13]=v,e[14]=s,e[15]=x):x=e[15],x}function Tg(t){console.error("[auto-start-vm] failed:",t)}function Rg(){const t=W.c(96),e=ma(),s=Lt(),{org:i}=xe(),r=Hc()?.tasksOpen??!1;Qc(i.slug);let n;t[0]===Symbol.for("react.memo_cache_sentinel")?(n={strict:!1},t[0]=n):n=t[0];const a=Jl(n),l=a.org??"";let h;t[1]===Symbol.for("react.memo_cache_sentinel")?(h={strict:!1},t[1]=h):h=t[1];const c=nn(h);let u;t[2]!==i.id||t[3]!==c.virtualmcpid?(u=c.virtualmcpid??ia(i.id).id,t[2]=i.id,t[3]=c.virtualmcpid,t[4]=u):u=t[4];const d=u,f=Hh(a.taskId??"",d),_=Nt(d),m=_?.metadata?.ui?.layout??null;let p;t[5]!==m?(p=m?{defaultMainView:m.defaultMainView??null,chatDefaultOpen:m.chatDefaultOpen??null}:null,t[5]=m,t[6]=p):p=t[6];const g=p;let v;t[7]!==_?(v=_&&Gt(_),t[7]=_,t[8]=v):v=t[8];const x=!!v;let S;t[9]!==l||t[10]!==d?(S={virtualMcpId:d,orgSlug:l,isAgentRoute:!0},t[9]=l,t[10]=d,t[11]=S):S=t[11];const b=Wc(g,S),{setOpenMobile:y,openMobile:N}=Gc(),C=y,D=P.useRef(null);let R,B;t[12]===Symbol.for("react.memo_cache_sentinel")?(R=()=>{const F=$=>{Kc($)&&$.shiftKey&&$.code==="KeyS"&&!$.repeat&&($.preventDefault(),D.current?.())};return document.addEventListener("keydown",F),()=>document.removeEventListener("keydown",F)},B=[],t[12]=R,t[13]=B):(R=t[12],B=t[13]),P.useEffect(R,B);const M=d;let E;t[14]!==_||t[15]!==d?(E={virtualMcpId:d,entity:_},t[14]=_,t[15]=d,t[16]=E):E=t[16];const k=E;if(f.status==="creating"||f.status==="loading"){let F;t[17]===Symbol.for("react.memo_cache_sentinel")?(F=o.jsx("div",{className:"flex-1 min-h-0 pr-1.5 pb-1.5 overflow-hidden",children:o.jsxs("div",{className:"flex h-full items-center justify-center bg-background card-shadow rounded-[0.75rem] text-sm text-muted-foreground",children:[o.jsx(Ae,{className:"size-4 animate-spin mr-2"}),"Creating task…"]})}),t[17]=F):F=t[17];let $;return t[18]!==k?($=o.jsx(ss,{value:k,children:F}),t[18]=k,t[19]=$):$=t[19],$}if(f.status==="error"){let F;t[20]===Symbol.for("react.memo_cache_sentinel")?(F=o.jsx("div",{className:"font-medium",children:"Task unavailable"}),t[20]=F):F=t[20];let $;t[21]!==f.error.message?($=o.jsx("div",{className:"flex-1 min-h-0 pr-1.5 pb-1.5 overflow-hidden",children:o.jsxs("div",{className:"flex flex-col h-full items-center justify-center gap-2 bg-background card-shadow rounded-[0.75rem] p-8 text-sm",children:[F,o.jsx("div",{className:"text-muted-foreground",children:f.error.message})]})}),t[21]=f.error.message,t[22]=$):$=t[22];let H;return t[23]!==k||t[24]!==$?(H=o.jsx(ss,{value:k,children:$}),t[23]=k,t[24]=$,t[25]=H):H=t[25],H}if(!_){let F;t[26]===Symbol.for("react.memo_cache_sentinel")?(F=o.jsx(Fs,{size:48,className:"text-muted-foreground"}),t[26]=F):F=t[26];const $=`The agent "${d}" does not exist in this organization.`;let H;t[27]!==s||t[28]!==l?(H=o.jsx(ne,{variant:"outline",onClick:()=>s({to:"/$org",params:{org:l}}),children:"Go to organization home"}),t[27]=s,t[28]=l,t[29]=H):H=t[29];let Q;t[30]!==$||t[31]!==H?(Q=o.jsx("div",{className:"flex-1 min-h-0 pr-1.5 pb-1.5 overflow-hidden",children:o.jsx("div",{className:"flex flex-col h-full bg-background overflow-hidden card-shadow rounded-[0.75rem]",children:o.jsx(Hs,{image:F,title:"Agent not found",description:$,actions:H})})}),t[30]=$,t[31]=H,t[32]=Q):Q=t[32];let L;return t[33]!==k||t[34]!==Q?(L=o.jsx(ss,{value:k,children:Q}),t[33]=k,t[34]=Q,t[35]=L):L=t[35],L}if(e){let F;t[36]===Symbol.for("react.memo_cache_sentinel")?(F=o.jsx(Yc,{className:"sr-only",children:"Navigation"}),t[36]=F):F=t[36];let $;t[37]!==C?($=o.jsx("div",{className:"w-14 shrink-0 bg-sidebar flex flex-col items-center border-r border-border overflow-y-auto group/sidebar","data-state":"collapsed",children:o.jsx(Uc,{onClose:()=>C(!1)})}),t[37]=C,t[38]=$):$=t[38];let H;t[39]===Symbol.for("react.memo_cache_sentinel")?(H=o.jsx("div",{className:"flex-1 min-w-0 overflow-hidden",children:o.jsx(Vc,{})}),t[39]=H):H=t[39];let Q;t[40]!==$?(Q=o.jsxs(Xc,{side:"left",hideCloseButton:!0,className:"w-[calc(100vw-3rem)] sm:max-w-md! p-0",children:[F,o.jsxs("div",{className:"flex h-full",children:[$,H]})]}),t[40]=$,t[41]=Q):Q=t[41];let L;t[42]!==N||t[43]!==C||t[44]!==Q?(L=o.jsx(Jc,{open:N,onOpenChange:C,children:Q}),t[42]=N,t[43]=C,t[44]=Q,t[45]=L):L=t[45];const ee=L,se=_?.metadata?.vmMap;let te;t[46]!==b.createNewTask?(te=o.jsx(Yo,{onNewTaskRef:D,createNewTask:b.createNewTask}),t[46]=b.createNewTask,t[47]=te):te=t[47];let G;t[48]!==C?(G=o.jsx(Eg,{onOpenSidebar:()=>C(!0)}),t[48]=C,t[49]=G):G=t[49];let he;t[50]===Symbol.for("react.memo_cache_sentinel")?(he=o.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:o.jsx(Go,{})}),t[50]=he):he=t[50];let fe;t[51]!==x||t[52]!==ee||t[53]!==se||t[54]!==te||t[55]!==G||t[56]!==d?(fe=o.jsxs(Xo,{virtualMcpId:d,hasActiveGithubRepo:x,vmMap:se,children:[te,G,he,ee]}),t[51]=x,t[52]=ee,t[53]=se,t[54]=te,t[55]=G,t[56]=d,t[57]=fe):fe=t[57];let de;t[58]!==M||t[59]!==fe?(de=o.jsx("div",{className:"flex flex-col flex-1 bg-background min-h-0",children:o.jsx(Ee.Provider,{virtualMcpId:M,children:fe},M)}),t[58]=M,t[59]=fe,t[60]=de):de=t[60];let ue;return t[61]!==k||t[62]!==de?(ue=o.jsx(ss,{value:k,children:de}),t[61]=k,t[62]=de,t[63]=ue):ue=t[63],ue}const w=r?void 0:b.createNewTask;let j;t[64]!==b.chatOpen||t[65]!==b.toggleChat||t[66]!==w?(j=o.jsx(gr.Toggles,{children:o.jsx(og,{chatOpen:b.chatOpen,toggleChat:b.toggleChat,onNewTask:w})}),t[64]=b.chatOpen,t[65]=b.toggleChat,t[66]=w,t[67]=j):j=t[67];let T;t[68]!==b.taskId||t[69]!==d?(T=o.jsx(gr.Tabs,{children:o.jsx(fg,{virtualMcpId:d,taskId:b.taskId})}),t[68]=b.taskId,t[69]=d,t[70]=T):T=t[70];const I=_?.metadata?.vmMap;let A;t[71]!==_?(A=o.jsx(jg,{virtualMcp:_}),t[71]=_,t[72]=A):A=t[72];let O;t[73]!==b.createNewTask?(O=o.jsx(Yo,{onNewTaskRef:D,createNewTask:b.createNewTask}),t[73]=b.createNewTask,t[74]=O):O=t[74];let q;t[75]===Symbol.for("react.memo_cache_sentinel")?(q=o.jsx(Go,{}),t[75]=q):q=t[75];let U;t[76]!==b.chatOpen||t[77]!==b.mainOpen||t[78]!==b.taskId||t[79]!==d?(U=o.jsx(ng,{virtualMcpId:d,taskId:b.taskId,chatOpen:b.chatOpen,mainOpen:b.mainOpen,chatContent:q}),t[76]=b.chatOpen,t[77]=b.mainOpen,t[78]=b.taskId,t[79]=d,t[80]=U):U=t[80];let V;t[81]!==x||t[82]!==I||t[83]!==A||t[84]!==O||t[85]!==U||t[86]!==d?(V=o.jsxs(Xo,{virtualMcpId:d,hasActiveGithubRepo:x,vmMap:I,children:[A,O,U]}),t[81]=x,t[82]=I,t[83]=A,t[84]=O,t[85]=U,t[86]=d,t[87]=V):V=t[87];let J;t[88]!==M||t[89]!==T||t[90]!==V?(J=o.jsxs(Ee.Provider,{virtualMcpId:M,children:[T,V]},M),t[88]=M,t[89]=T,t[90]=V,t[91]=J):J=t[91];let Z;return t[92]!==k||t[93]!==j||t[94]!==J?(Z=o.jsx("div",{className:"flex-1 min-w-0 flex flex-col",children:o.jsxs(ss,{value:k,children:[j,J]})}),t[92]=k,t[93]=j,t[94]=J,t[95]=Z):Z=t[95],Z}function O1(){const t=W.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=o.jsx(P.Suspense,{fallback:o.jsx("div",{className:"flex-1 flex items-center justify-center",children:o.jsx(Ae,{size:20,className:"animate-spin text-muted-foreground"})}),children:o.jsx(Rg,{})}),t[0]=e):e=t[0],e}export{O1 as default,Cn as useInsetContext};
182
+ `);if(Fe.trim()){I(!0);try{Ke(),we("automation_improve_clicked",{automation_id:t,agent_id:r,instructions_length:Fe.length}),await x(["studio-automation-manager"]),g(!0),await v({tiptapDoc:za({managerAgentId:ra.AUTOMATION_MANAGER(n.id),managerName:"Automation Manager",kind:"automation",id:t,instructions:Fe})})}finally{I(!1)}}},V=e.models?.credentialId||_||"",J=e.models?.thinking?.id||m?.modelId||"",Z=e.models?.tier??"",F=Qo({defaultValues:{name:e.name,active:e.active,credential_id:V,model_id:J,tier:Z}}),$=F.watch("active"),H=F.watch("credential_id"),Q=F.watch("model_id"),{models:L,isLoading:ee}=$c(H||void 0),se=L.find(re=>re.modelId===Q)??null,te=F.watch("tier"),G=["fast","smart","thinking"].find(re=>p.chat[re]?.modelId===Q&&p.chat[re]?.keyId===H),he=te||G||"smart",fe=re=>{const Fe=p.chat[re];Fe&&(F.setValue("credential_id",Fe.keyId),F.setValue("model_id",Fe.modelId),F.setValue("tier",re),me("credential_id"),me("model_id"),me("tier"),Y())},de=P.useRef(null),ue=P.useRef(new Set),pe=P.useRef(0),De=P.useRef(null),Ue=3e4,Ke=()=>{De.current&&(clearTimeout(De.current),De.current=null),de.current!==null&&(we("automation_updated",{automation_id:t,agent_id:r,fields:Array.from(ue.current),save_count:pe.current,edit_duration_ms:Date.now()-de.current}),de.current=null,ue.current=new Set,pe.current=0)},Qe=P.useRef(new Set),me=re=>{Qe.current.add(re)},Tt=async()=>{const re=Array.from(Qe.current);if(!(re.length>0)&&!O.current)return!0;const Ss=O.current;O.current=!1,Qe.current=new Set;const rt=F.getValues(),Ll=q.current;try{const ys=rt.credential_id&&rt.model_id?rt.credential_id:"",Wi=rt.credential_id&&rt.model_id?rt.model_id:"",kn=p.enabled?rt.tier||G:rt.tier||void 0,Ol={id:t,name:rt.name,active:rt.active,models:{credentialId:ys,thinking:{id:Wi},...kn?{tier:kn}:{}},messages:oc(Ll),temperature:0};await a.mutateAsync(Ol),de.current===null&&(de.current=Date.now());for(const zl of re)ue.current.add(zl);return Ss&&ue.current.add("messages"),pe.current+=1,De.current&&clearTimeout(De.current),De.current=setTimeout(Ke,Ue),ys!==rt.credential_id&&F.setValue("credential_id",ys),Wi!==rt.model_id&&F.setValue("model_id",Wi),!0}catch{O.current=!0;for(const ys of re)Qe.current.add(ys);return!1}},{schedule:Y,flush:ae}=Da({save:Tt}),je=re=>{re&&me(re),Y()},dt=re=>{if(q.current=re,C(re),!A.current){A.current=!0;return}O.current=!0,Y()},Zt=async()=>{we("automation_test_clicked",{automation_id:t,agent_id:r});const re=await ae();if(Ke(),!re)return;if(!N){ge.error("No instructions configured for this automation");return}p.enabled?f(he):se&&H&&d({...se,keyId:H}),g(!0),b({...S,toolApprovalLevel:"auto"});const Fe=jn(N);u({message:{tiptapDoc:N,parts:Fe},virtualMcpId:r||void 0})};return o.jsxs(o.Fragment,{children:[s&&o.jsx("div",{className:"flex items-center pb-4 shrink-0",children:o.jsxs(ne,{variant:"ghost",size:"sm",onClick:s,children:[o.jsx(Aa,{size:14}),"Back to list"]})}),o.jsxs("div",{className:"flex flex-col gap-8",children:[o.jsxs("div",{className:"flex flex-col gap-1.5",children:[o.jsxs("div",{className:"flex items-center justify-between gap-4",children:[o.jsx(Ht,{control:F.control,name:"name",render:({field:re})=>o.jsx(vs,{...re,onChange:Fe=>{re.onChange(Fe),je("name")},placeholder:"Automation name",className:"border border-transparent shadow-none px-0 text-lg font-medium h-auto focus-visible:ring-0 focus-visible:border-border bg-transparent flex-1",style:{boxShadow:"none"}})}),i&&o.jsx(ne,{variant:"ghost",size:"icon",className:"text-muted-foreground hover:text-destructive shrink-0",onClick:i,children:o.jsx(xr,{size:14})})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(Ht,{control:F.control,name:"active",render:({field:re})=>o.jsx(vr,{checked:re.value,onCheckedChange:Fe=>{re.onChange(Fe),me("active"),setTimeout(()=>ae(),0)},className:"cursor-pointer"})}),o.jsx("span",{className:"text-sm text-muted-foreground",children:$?"Active":"Inactive"}),o.jsx("span",{className:"text-muted-foreground/50 text-sm",children:"·"}),o.jsx(ga,{id:e.created_by,size:"2xs",className:"text-sm text-muted-foreground"})]})]}),o.jsxs("div",{className:"flex flex-col gap-2.5",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("span",{className:"text-xs font-semibold text-muted-foreground/60",children:"Starter"}),o.jsx(Up,{automationId:t,open:D,onOpenChange:R,onCustomSelect:()=>{M(!0),j(!1),k("")},onEventSelect:()=>{j(!0),M(!1)}})]}),e.triggers.length===0&&!B?o.jsx("div",{className:"rounded-lg border border-dashed border-border px-4 py-6 text-center",children:o.jsxs("p",{className:"text-sm text-muted-foreground",children:["When should this automation run?"," ",o.jsx("button",{type:"button",className:"text-foreground underline underline-offset-2 cursor-pointer hover:text-foreground/80 transition-colors",onClick:()=>R(!0),children:"Add a starter"})," ","to get going."]})}):o.jsx("div",{className:"flex flex-col gap-2",children:e.triggers.map(re=>o.jsx(Vp,{trigger:re,automationId:t,connectionName:re.connection_id?c.get(re.connection_id):void 0},re.id))}),B&&o.jsxs("div",{className:"flex items-center gap-2.5 px-3 py-2.5 rounded-lg border border-border bg-background group",children:[o.jsx(Ps,{size:14,className:"text-muted-foreground shrink-0"}),o.jsx("input",{type:"text",value:E,onChange:re=>k(re.target.value),onBlur:async()=>{const re=E.trim();if(!(!re||!zs(re)))try{await l.mutateAsync({automation_id:t,type:"cron",cron_expression:re}),we("automation_trigger_added",{automation_id:t,trigger_type:"cron"}),ge.success("Starter added"),M(!1),k("")}catch{ge.error("Failed to add starter")}},onKeyDown:async re=>{const Fe=E.trim();re.key==="Enter"&&Fe&&zs(Fe)&&re.target.blur(),re.key==="Escape"&&(M(!1),k(""))},placeholder:"0 9 * * 1-5",className:"flex-1 text-sm font-mono bg-transparent outline-none placeholder:text-muted-foreground/40",autoFocus:!0}),E&&!zs(E)&&o.jsx("span",{className:"text-xs text-muted-foreground/60 shrink-0",children:"invalid"}),l.isPending&&o.jsx(Ae,{size:13,className:"animate-spin text-muted-foreground shrink-0"}),o.jsx("button",{type:"button",className:"shrink-0 p-0.5 rounded text-muted-foreground opacity-0 group-hover:opacity-100 hover:text-foreground transition-opacity",onClick:()=>{M(!1),k("")},children:o.jsx(ds,{size:13})})]}),w&&o.jsx(P.Suspense,{fallback:o.jsxs("div",{className:"flex items-center gap-2 px-3 py-3 rounded-lg border border-border bg-background",children:[o.jsx(Ae,{size:13,className:"animate-spin text-muted-foreground"}),o.jsx("span",{className:"text-sm text-muted-foreground",children:"Loading connections..."})]}),children:o.jsx(qp,{automationId:t,onDone:()=>j(!1)})})]}),o.jsxs("div",{className:"flex flex-col gap-2.5",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("span",{className:"text-xs font-semibold text-muted-foreground/60",children:"Instructions"}),o.jsxs(ne,{variant:"outline",size:"sm",className:"h-7 gap-1.5 px-2 text-xs",disabled:T||!N,onClick:U,children:[o.jsx(Ra,{size:13}),"Improve"]})]}),o.jsx(tc,{tiptapDoc:N,setTiptapDoc:dt,placeholder:"What should this automation do?",children:o.jsxs("div",{className:"rounded-xl border border-border min-h-[120px] flex flex-col",children:[o.jsx(sc,{virtualMcpId:r||null,className:"max-h-[45vh]"}),o.jsxs("div",{className:"flex items-center justify-end gap-1.5 p-2.5",children:[p.enabled?o.jsx(ic,{tier:he,onSelect:fe}):o.jsx(Mh,{model:se,isLoading:ee,credentialId:H||null,onCredentialChange:re=>{F.setValue("credential_id",re??""),F.setValue("model_id",""),F.setValue("tier",""),me("credential_id"),me("model_id"),me("tier"),Y()},onModelChange:re=>{F.setValue("model_id",re.modelId),F.setValue("tier",""),me("tier"),je("model_id")},placeholder:"Model"}),o.jsxs(Ge,{children:[o.jsx(Ye,{asChild:!0,children:o.jsxs(ne,{type:"button",variant:"default",className:"h-8 gap-1.5 rounded-md px-3 text-sm font-medium",onClick:Zt,disabled:!r,children:[o.jsx(fc,{size:16}),"Test"]})}),o.jsx(Xe,{children:"Test Automation"})]})]})]})})]})]})]})}function Zp(t){const e=W.c(5),{tabId:s}=t;let i;e[0]!==s?(i=oa(s),e[0]=s,e[1]=i):i=e[1];const r=i;if(!r)return null;let n;e[2]===Symbol.for("react.memo_cache_sentinel")?(n=o.jsx("div",{className:"flex-1 flex items-center justify-center",children:o.jsx(Ae,{size:20,className:"animate-spin text-muted-foreground"})}),e[2]=n):n=e[2];let a;return e[3]!==r.id?(a=o.jsx(ht,{children:o.jsx(ht.Content,{children:o.jsx(ht.Body,{children:o.jsx(P.Suspense,{fallback:n,children:o.jsx(Qp,{id:r.id})})})})}),e[3]=r.id,e[4]=a):a=e[4],a}function Qp(t){const e=W.c(8),{id:s}=t,i=Lt(),{data:r,isLoading:n}=Bh(s);let a;e[0]!==i?(a=()=>i({to:".",search:eg,replace:!0}),e[0]=i,e[1]=a):a=e[1];const l=a;if(n){let c;return e[2]===Symbol.for("react.memo_cache_sentinel")?(c=o.jsx("div",{className:"flex-1 flex items-center justify-center",children:o.jsx(Ae,{size:20,className:"animate-spin text-muted-foreground"})}),e[2]=c):c=e[2],c}if(!r){let c;return e[3]===Symbol.for("react.memo_cache_sentinel")?(c=o.jsx("div",{className:"flex-1 flex items-center justify-center text-sm text-muted-foreground",children:"Automation not found"}),e[3]=c):c=e[3],c}let h;return e[4]!==r||e[5]!==s||e[6]!==l?(h=o.jsx(Jp,{automationId:s,automation:r,onBack:l}),e[4]=r,e[5]=s,e[6]=l,e[7]=h):h=e[7],h}function eg(t){return{...t,main:"automations"}}function tg(t){const e=W.c(20),{virtualMcpId:s}=t,i=Lt(),{data:r}=Ph(s),n=r===void 0?[]:r,{create:a}=Js(),{selectedModel:l,credentialId:h}=Ri(),[c,u]=P.useState(""),d=c.toLowerCase(),f=n.filter(E=>E.name.toLowerCase().includes(d));let _;e[0]!==i?(_=E=>i({to:".",search:k=>({...k,main:"automation:"+E}),replace:!0}),e[0]=i,e[1]=_):_=e[1];const m=_,p=async()=>{if(a.isPending)return;we("automation_new_clicked",{virtual_mcp_id:s,existing_count:n.length});const E=l?.modelId&&h?{credentialId:h,modelId:l.modelId}:null,k=await a.mutateAsync(Oh(s,E));m(k.id)},g=ht,v=ht,x=ht;let S;e[2]===Symbol.for("react.memo_cache_sentinel")?(S=o.jsx(ht.Title,{children:"Automations"}),e[2]=S):S=e[2];const b=n.length>0&&o.jsx(zh,{value:c,onChange:u,placeholder:"Search automations...",className:"w-full md:w-[375px]"});let y;e[3]===Symbol.for("react.memo_cache_sentinel")?(y=o.jsx(us,{size:14}),e[3]=y):y=e[3];let N;e[4]!==a.isPending||e[5]!==p?(N=o.jsxs(ne,{size:"sm",onClick:p,disabled:a.isPending,children:[y,"New automation"]}),e[4]=a.isPending,e[5]=p,e[6]=N):N=e[6];let C;e[7]!==b||e[8]!==N?(C=o.jsxs("div",{className:"flex flex-col gap-6",children:[S,o.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[b,N]})]}),e[7]=b,e[8]=N,e[9]=C):C=e[9];const D=n.length===0?o.jsx("div",{className:"flex items-center justify-center py-20",children:o.jsx(Hs,{image:o.jsx(Ws,{size:48,className:"text-muted-foreground"}),title:"No automations yet",description:"Create your first automation to run this agent on a schedule or in response to events.",actions:o.jsxs(ne,{size:"sm",onClick:p,disabled:a.isPending,children:[o.jsx(us,{size:14}),"New automation"]})})}):f.length===0?o.jsx("div",{className:"flex items-center justify-center py-20",children:o.jsx(Hs,{image:o.jsx(Ws,{size:48,className:"text-muted-foreground"}),title:"No automations found",description:`No automations match "${c}"`})}):o.jsx("div",{className:"mt-6 rounded-xl border border-border overflow-hidden",children:f.map(E=>o.jsx(Lh,{automation:E,onClick:()=>m(E.id)},E.id))});let R;e[10]!==D||e[11]!==x.Body||e[12]!==C?(R=o.jsxs(x.Body,{children:[C,D]}),e[10]=D,e[11]=x.Body,e[12]=C,e[13]=R):R=e[13];let B;e[14]!==R||e[15]!==v.Content?(B=o.jsx(v.Content,{children:R}),e[14]=R,e[15]=v.Content,e[16]=B):B=e[16];let M;return e[17]!==g||e[18]!==B?(M=o.jsx(g,{children:B}),e[17]=g,e[18]=B,e[19]=M):M=e[19],M}function sg(t){const e=W.c(3),{virtualMcpId:s}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=o.jsx("div",{className:"flex-1 flex items-center justify-center",children:o.jsx(Ae,{size:20,className:"animate-spin text-muted-foreground"})}),e[0]=i):i=e[0];let r;return e[1]!==s?(r=o.jsx(P.Suspense,{fallback:i,children:o.jsx(tg,{virtualMcpId:s})}),e[1]=s,e[2]=r):r=e[2],r}const Vo=P.lazy(()=>Yl(()=>import("./project-app-view-CmNwDiw0.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56])).then(t=>({default:t.AppViewContent})));function ig(t){const e=W.c(43),{taskId:s,virtualMcpId:i}=t;let r;e[0]!==s||e[1]!==i?(r={virtualMcpId:i,taskId:s},e[0]=s,e[1]=i,e[2]=r):r=e[2];const{activeTab:n,layoutTabs:a,expandedTools:l,automationTabParsed:h}=Oa(r);if(xc(n)){let m;return e[3]!==i?(m=o.jsx(qn,{virtualMcpId:i}),e[3]=i,e[4]=m):m=e[4],m}if(n==="git"){let m;return e[5]!==i?(m=o.jsx(Ou,{virtualMcpId:i}),e[5]=i,e[6]=m):m=e[6],m}if(n==="automations"){let m;return e[7]!==i?(m=o.jsx(sg,{virtualMcpId:i}),e[7]=i,e[8]=m):m=e[8],m}if(n==="env"){let m;return e[9]!==i?(m=o.jsx(Op,{virtualMcpId:i}),e[9]=i,e[10]=m):m=e[10],m}if(n==="preview"){let m;return e[11]!==i?(m=o.jsx(Sf,{virtualMcpId:i}),e[11]=i,e[12]=m):m=e[12],m}if(h){let m;return e[13]!==n?(m=o.jsx(Zp,{tabId:n}),e[13]=n,e[14]=m):m=e[14],m}let c;e[15]!==n?(c=bc(n),e[15]=n,e[16]=c):c=e[16];const u=c;if(u){let m;if(e[17]!==l||e[18]!==u.connectionId||e[19]!==u.toolName){let S;e[21]!==u.connectionId||e[22]!==u.toolName?(S=b=>b.appId===u.connectionId&&b.toolName===u.toolName,e[21]=u.connectionId,e[22]=u.toolName,e[23]=S):S=e[23],m=l.find(S),e[17]=l,e[18]=u.connectionId,e[19]=u.toolName,e[20]=m}else m=e[20];const p=m;let g;e[24]===Symbol.for("react.memo_cache_sentinel")?(g=o.jsx("div",{className:"h-full w-full flex items-center justify-center",children:o.jsx(Ae,{size:20,className:"animate-spin text-muted-foreground"})}),e[24]=g):g=e[24];const v=p?.args;let x;return e[25]!==n||e[26]!==u.connectionId||e[27]!==u.toolName||e[28]!==v?(x=o.jsx(P.Suspense,{fallback:g,children:o.jsx(Vo,{connectionId:u.connectionId,toolName:u.toolName,args:v},n)}),e[25]=n,e[26]=u.connectionId,e[27]=u.toolName,e[28]=v,e[29]=x):x=e[29],x}let d;if(e[30]!==n||e[31]!==a){let m;e[33]!==n?(m=p=>p.id===n,e[33]=n,e[34]=m):m=e[34],d=a.find(m),e[30]=n,e[31]=a,e[32]=d}else d=e[32];const f=d;if(f){let m;e[35]===Symbol.for("react.memo_cache_sentinel")?(m=o.jsx("div",{className:"h-full w-full flex items-center justify-center",children:o.jsx(Ae,{size:20,className:"animate-spin text-muted-foreground"})}),e[35]=m):m=e[35];let p;return e[36]!==n||e[37]!==f.id||e[38]!==f.view.appId||e[39]!==f.view.args?(p=o.jsx(P.Suspense,{fallback:m,children:o.jsx(Vo,{connectionId:f.view.appId,toolName:f.id,args:f.view.args},n)}),e[36]=n,e[37]=f.id,e[38]=f.view.appId,e[39]=f.view.args,e[40]=p):p=e[40],p}let _;return e[41]!==i?(_=o.jsx(qn,{virtualMcpId:i}),e[41]=i,e[42]=_):_=e[42],_}function rg(t){const e=W.c(7),{children:s,defaultSize:i}=t,[,r]=P.useTransition();let n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=sa.decoChatPanelWidth(),e[0]=n):n=e[0];const[a,l]=ta(n,45),h=i>0&&i<100?a:i;let c;e[1]!==l?(c=f=>r(()=>{f>0&&f<100&&l(f)}),e[1]=l,e[2]=c):c=e[2];const u=c;let d;return e[3]!==s||e[4]!==h||e[5]!==u?(d=o.jsx(_a,{defaultSize:h,minSize:20,collapsible:!0,collapsedSize:0,className:"min-w-0 overflow-hidden bg-sidebar",onResize:u,order:1,children:s}),e[3]=s,e[4]=h,e[5]=u,e[6]=d):d=e[6],d}function ng(t){const e=W.c(30),{virtualMcpId:s,taskId:i,chatOpen:r,mainOpen:n,chatContent:a}=t;let l;e[0]!==r||e[1]!==n?(l=Pn(r,n),e[0]=r,e[1]=n,e[2]=l):l=e[2];const h=l;let c;e[3]===Symbol.for("react.memo_cache_sentinel")?(c=sa.decoChatPanelWidth(),e[3]=c):c=e[3];const[u]=ta(c,45),d=P.useRef(null);let f,_;e[4]!==r||e[5]!==n||e[6]!==u?(f=()=>{const B=d.current;if(!B)return;const M=Pn(r,n),E=M.chat>0&&M.chat<100?u:M.chat,k=M.chat>0&&M.chat<100?100-u:M.main;B.setLayout([E,k])},_=[r,n,u],e[4]=r,e[5]=n,e[6]=u,e[7]=f,e[8]=_):(f=e[7],_=e[8]),P.useEffect(f,_);const m=`${s}-${i}`;let p;e[9]===Symbol.for("react.memo_cache_sentinel")?(p={overflow:"visible"},e[9]=p):p=e[9];let g;e[10]!==a?(g=a??o.jsx(Ba,{}),e[10]=a,e[11]=g):g=e[11];let v;e[12]!==g?(v=o.jsx("div",{className:"h-full p-0.5 pt-0.25",children:o.jsx("div",{className:"h-full bg-background rounded-[0.75rem] overflow-hidden card-shadow",children:g})}),e[12]=g,e[13]=v):v=e[13];let x;e[14]!==h.chat||e[15]!==v?(x=o.jsx(rg,{defaultSize:h.chat,children:v}),e[14]=h.chat,e[15]=v,e[16]=x):x=e[16];let S;e[17]===Symbol.for("react.memo_cache_sentinel")?(S=o.jsx(rh,{className:"bg-sidebar"}),e[17]=S):S=e[17];const b=h.main;let y;e[18]===Symbol.for("react.memo_cache_sentinel")?(y={overflow:"visible"},e[18]=y):y=e[18];let N;e[19]===Symbol.for("react.memo_cache_sentinel")?(N=ie("flex flex-col h-full min-h-0 bg-background overflow-hidden","card-shadow","transition-[border-radius] duration-200 ease-[var(--ease-out-quart)]","rounded-[0.75rem]"),e[19]=N):N=e[19];let C;e[20]!==i||e[21]!==s?(C=o.jsx("div",{className:"h-full p-0.5 pt-0.25",children:o.jsx("div",{className:N,children:o.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:o.jsx(Ut,{children:o.jsx(ig,{taskId:i,virtualMcpId:s})})})})}),e[20]=i,e[21]=s,e[22]=C):C=e[22];let D;e[23]!==h.main||e[24]!==C?(D=o.jsx(_a,{className:"min-w-0 flex flex-col",order:2,defaultSize:b,style:y,collapsible:!0,collapsedSize:0,minSize:20,children:C}),e[23]=h.main,e[24]=C,e[25]=D):D=e[25];let R;return e[26]!==D||e[27]!==m||e[28]!==x?(R=o.jsxs(nh,{ref:d,direction:"horizontal",className:"flex-1 min-h-0 pb-1 pr-1 pl-0 pt-0",style:p,children:[x,S,D]},m),e[26]=D,e[27]=m,e[28]=x,e[29]=R):R=e[29],R}const mr="flex size-7 shrink-0 items-center justify-center rounded-md transition-colors",Ko="bg-sidebar-accent text-sidebar-foreground",_r="text-sidebar-foreground/60 hover:bg-sidebar-accent hover:text-sidebar-foreground";function og(t){const e=W.c(47),{chatOpen:s,toggleChat:i,onNewTask:r}=t,{tasksOpen:n,toggleTasks:a}=Fc(),l=!!r;let h;e[0]!==n||e[1]!==a?(h=()=>{we("agent_toolbar_toggled",{button:"tasks",next_state:n?"closed":"open"}),a()},e[0]=n,e[1]=a,e[2]=h):h=e[2];const c=n?Ko:_r;let u;e[3]!==c?(u=ie(mr,c),e[3]=c,e[4]=u):u=e[4];let d;e[5]===Symbol.for("react.memo_cache_sentinel")?(d=o.jsx(Pc,{size:16}),e[5]=d):d=e[5];let f;e[6]!==h||e[7]!==u||e[8]!==n?(f=o.jsx(Ye,{asChild:!0,children:o.jsx("button",{type:"button",onClick:h,"aria-pressed":n,className:u,children:d})}),e[6]=h,e[7]=u,e[8]=n,e[9]=f):f=e[9];let _;e[10]===Symbol.for("react.memo_cache_sentinel")?(_=o.jsx(Xe,{side:"bottom",children:"Tasks"}),e[10]=_):_=e[10];let m;e[11]!==f?(m=o.jsxs(Ge,{delayDuration:300,children:[f,_]}),e[11]=f,e[12]=m):m=e[12];let p;e[13]!==s||e[14]!==i?(p=()=>{we("agent_toolbar_toggled",{button:"chat",next_state:s?"closed":"open"}),i()},e[13]=s,e[14]=i,e[15]=p):p=e[15];const g=s?Ko:_r;let v;e[16]!==g?(v=ie(mr,g),e[16]=g,e[17]=v):v=e[17];let x;e[18]===Symbol.for("react.memo_cache_sentinel")?(x=o.jsx(Lc,{size:16}),e[18]=x):x=e[18];let S;e[19]!==s||e[20]!==v||e[21]!==p?(S=o.jsx(Ye,{asChild:!0,children:o.jsx("button",{type:"button",onClick:p,"aria-pressed":s,className:v,children:x})}),e[19]=s,e[20]=v,e[21]=p,e[22]=S):S=e[22];let b;e[23]===Symbol.for("react.memo_cache_sentinel")?(b=o.jsx(Xe,{side:"bottom",children:"Chat"}),e[23]=b):b=e[23];let y;e[24]!==S?(y=o.jsxs(Ge,{delayDuration:300,children:[S,b]}),e[24]=S,e[25]=y):y=e[25];const N=l?"grid-cols-[1fr]":"grid-cols-[0fr]";let C;e[26]!==N?(C=ie("grid transition-[grid-template-columns] duration-200 ease-[var(--ease-out-quart)]",N),e[26]=N,e[27]=C):C=e[27];const D=!l,R=l?0:-1,B=!l,M=l?"translate-x-0 opacity-100":"-translate-x-2 opacity-0";let E;e[28]!==M?(E=ie(mr,_r,"transition-[transform,opacity] duration-200 ease-[var(--ease-out-quart)] will-change-transform",M),e[28]=M,e[29]=E):E=e[29];let k;e[30]===Symbol.for("react.memo_cache_sentinel")?(k=o.jsx(ca,{size:16}),e[30]=k):k=e[30];let w;e[31]!==r||e[32]!==D||e[33]!==R||e[34]!==B||e[35]!==E?(w=o.jsx(Ye,{asChild:!0,children:o.jsx("button",{type:"button",onClick:r,disabled:D,tabIndex:R,"aria-hidden":B,className:E,children:k})}),e[31]=r,e[32]=D,e[33]=R,e[34]=B,e[35]=E,e[36]=w):w=e[36];let j;e[37]===Symbol.for("react.memo_cache_sentinel")?(j=o.jsx(Xe,{side:"bottom",children:"New task"}),e[37]=j):j=e[37];let T;e[38]!==w?(T=o.jsx("div",{className:"overflow-hidden",children:o.jsxs(Ge,{delayDuration:300,children:[w,j]})}),e[38]=w,e[39]=T):T=e[39];let I;e[40]!==C||e[41]!==T?(I=o.jsx("div",{className:C,children:T}),e[40]=C,e[41]=T,e[42]=I):I=e[42];let A;return e[43]!==y||e[44]!==I||e[45]!==m?(A=o.jsxs(o.Fragment,{children:[m,y,I]}),e[43]=y,e[44]=I,e[45]=m,e[46]=A):A=e[46],A}function ag(t,e,s){if(t.length<=s)return{visible:t,overflow:[]};const i=t.slice(0,s),r=t.slice(s);if(e==null)return{visible:i,overflow:r};if(i.some(d=>d.id===e))return{visible:i,overflow:r};const a=r.findIndex(d=>d.id===e);if(a===-1)return{visible:i,overflow:r};const l=i[i.length-1],h=r[a],c=[...i.slice(0,-1),h],u=[l,...r.slice(0,a),...r.slice(a+1)];return{visible:c,overflow:u}}function lg(t){const e=W.c(13),{title:s,icon:i,active:r,onClick:n}=t,a=r?"bg-sidebar-accent text-sidebar-foreground":"text-sidebar-foreground/60 hover:bg-sidebar-accent hover:text-sidebar-foreground";let l;e[0]!==a?(l=ie("shrink-0 flex items-center gap-1.5 h-8 rounded-md px-2","[transition:background-color_180ms_ease,color_180ms_ease]",a),e[0]=a,e[1]=l):l=e[1];let h;e[2]!==i?(h=o.jsx("span",{className:"flex size-5 items-center justify-center shrink-0",children:o.jsx(cg,{icon:i})}),e[2]=i,e[3]=h):h=e[3];let c;e[4]!==s?(c=o.jsx("span",{className:"whitespace-nowrap text-sm font-medium leading-none",children:s}),e[4]=s,e[5]=c):c=e[5];let u;return e[6]!==r||e[7]!==n||e[8]!==l||e[9]!==h||e[10]!==c||e[11]!==s?(u=o.jsxs("button",{type:"button",onClick:n,"aria-pressed":r,"aria-label":s,className:l,children:[h,c]}),e[6]=r,e[7]=n,e[8]=l,e[9]=h,e[10]=c,e[11]=s,e[12]=u):u=e[12],u}function cg(t){const e=W.c(5),{icon:s}=t;if(s.kind==="component"){const{Component:r}=s;let n;return e[0]!==r?(n=o.jsx(r,{className:"size-4"}),e[0]=r,e[1]=n):n=e[1],n}if(s.kind==="url"){let r;return e[2]!==s.src?(r=o.jsx("img",{src:s.src,alt:"",className:"size-4 rounded-sm object-cover"}),e[2]=s.src,e[3]=r):r=e[3],r}let i;return e[4]===Symbol.for("react.memo_cache_sentinel")?(i=o.jsx(fa,{className:"size-4"}),e[4]=i):i=e[4],i}function hg(t){const e=W.c(13),{overflow:s,onSelect:i}=t,[r,n]=P.useState(!1);let a;e[0]!==i?(a=f=>{n(!1),i(f)},e[0]=i,e[1]=a):a=e[1];const l=a;let h;e[2]===Symbol.for("react.memo_cache_sentinel")?(h=o.jsx(Gs,{asChild:!0,children:o.jsx("button",{type:"button",title:"More tabs","aria-label":"More tabs",className:"shrink-0 flex size-8 items-center justify-center rounded-md text-muted-foreground hover:bg-accent hover:text-foreground transition-colors",children:o.jsx(ha,{className:"size-4"})})}),e[2]=h):h=e[2];let c;if(e[3]!==l||e[4]!==s){let f;e[6]!==l?(f=_=>o.jsx("li",{children:o.jsxs("button",{type:"button",onClick:()=>l(_.id),className:"w-full flex items-center gap-2 px-3 py-2 rounded-md hover:bg-accent text-sm text-foreground",children:[o.jsx("span",{className:"flex size-5 items-center justify-center shrink-0",children:o.jsx(dg,{icon:_.icon})}),o.jsx("span",{className:"truncate",children:_.title})]})},_.id),e[6]=l,e[7]=f):f=e[7],c=s.map(f),e[3]=l,e[4]=s,e[5]=c}else c=e[5];let u;e[8]!==c?(u=o.jsx(Ys,{align:"end",className:"w-56 p-1",children:o.jsx("ul",{className:"flex flex-col",children:c})}),e[8]=c,e[9]=u):u=e[9];let d;return e[10]!==r||e[11]!==u?(d=o.jsxs(Xs,{open:r,onOpenChange:n,children:[h,u]}),e[10]=r,e[11]=u,e[12]=d):d=e[12],d}function dg(t){const e=W.c(5),{icon:s}=t;if(s.kind==="component"){const{Component:r}=s;let n;return e[0]!==r?(n=o.jsx(r,{className:"size-4"}),e[0]=r,e[1]=n):n=e[1],n}if(s.kind==="url"){let r;return e[2]!==s.src?(r=o.jsx("img",{src:s.src,alt:"",className:"size-4 rounded-sm object-cover"}),e[2]=s.src,e[3]=r):r=e[3],r}let i;return e[4]===Symbol.for("react.memo_cache_sentinel")?(i=o.jsx(fa,{className:"size-4"}),e[4]=i):i=e[4],i}const ug=6;function fg(t){const e=W.c(20),{virtualMcpId:s,taskId:i}=t,r=Lt();let n;e[0]!==i||e[1]!==s?(n={virtualMcpId:s,taskId:i},e[0]=i,e[1]=s,e[2]=n):n=e[2];const{tabs:a,activeTab:l,mainOpen:h,setActiveTab:c}=Oa(n);let u,d,f,_;if(e[3]!==l||e[4]!==h||e[5]!==r||e[6]!==c||e[7]!==a||e[8]!==s){const g=Sc({activeTab:l,mainOpen:h}),v=N=>N.id==="automations"?g:h&&N.id===l,S=a.find(N=>v(N))?.id??null,{visible:b,overflow:y}=ag(a,S,ug);d=y,u=N=>{const C=a.find(R=>R.id===N),D=S===N&&h;if(we("main_panel_tab_clicked",{virtual_mcp_id:s,tab_id:N,tab_kind:C?.kind??null,was_active:D}),N==="automations"){const R=yc({activeTab:l,mainOpen:h});r({to:".",search:B=>({...B,main:R}),replace:!0});return}c(N)},f="flex items-center min-w-0 ml-auto gap-0.5",_=b.map(N=>o.jsx(lg,{title:N.title,icon:N.icon,active:v(N),onClick:()=>u(N.id)},N.id)),e[3]=l,e[4]=h,e[5]=r,e[6]=c,e[7]=a,e[8]=s,e[9]=u,e[10]=d,e[11]=f,e[12]=_}else u=e[9],d=e[10],f=e[11],_=e[12];let m;e[13]!==u||e[14]!==d?(m=d.length>0&&o.jsx(hg,{overflow:d,onSelect:u}),e[13]=u,e[14]=d,e[15]=m):m=e[15];let p;return e[16]!==f||e[17]!==_||e[18]!==m?(p=o.jsxs("div",{className:f,children:[_,m]}),e[16]=f,e[17]=_,e[18]=m,e[19]=p):p=e[19],p}function mg(t){const e=W.c(12);let s,i,r,n;e[0]!==t?({className:s,orientation:r,decorative:n,...i}=t,e[0]=t,e[1]=s,e[2]=i,e[3]=r,e[4]=n):(s=e[1],i=e[2],r=e[3],n=e[4]);const a=r===void 0?"horizontal":r,l=n===void 0?!0:n;let h;e[5]!==s?(h=ie("bg-border shrink-0 data-[orientation=horizontal]:h-px data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-px",s),e[5]=s,e[6]=h):h=e[6];let c;return e[7]!==l||e[8]!==a||e[9]!==i||e[10]!==h?(c=o.jsx(Xl,{"data-slot":"separator-root",decorative:l,orientation:a,className:h,...i}),e[7]=l,e[8]=a,e[9]=i,e[10]=h,e[11]=c):c=e[11],c}function _g(t){const e=W.c(20),{prNumber:s,disabled:i,send:r}=t;let n;e[0]!==s||e[1]!==r?(n=()=>r(ju({prNumber:s})),e[0]=s,e[1]=r,e[2]=n):n=e[2];const a=n;let l;e[3]!==s||e[4]!==r?(l=()=>r(Nu({prNumber:s})),e[3]=s,e[4]=r,e[5]=l):l=e[5];const h=l;let c;e[6]!==i||e[7]!==a?(c=o.jsx(ne,{size:"sm",variant:"success",className:"rounded-r-none border-r border-success-foreground/20",disabled:i,onClick:a,children:"Publish"}),e[6]=i,e[7]=a,e[8]=c):c=e[8];let u;e[9]===Symbol.for("react.memo_cache_sentinel")?(u=o.jsx(br,{className:"h-3.5 w-3.5"}),e[9]=u):u=e[9];let d;e[10]!==i?(d=o.jsx(cs,{asChild:!0,children:o.jsx(ne,{size:"sm",variant:"success",className:"rounded-l-none px-2",disabled:i,"aria-label":"More actions",children:u})}),e[10]=i,e[11]=d):d=e[11];let f;e[12]!==h?(f=o.jsx(hs,{align:"end",children:o.jsx(kt,{onClick:h,children:"Review"})}),e[12]=h,e[13]=f):f=e[13];let _;e[14]!==d||e[15]!==f?(_=o.jsxs(ls,{children:[d,f]}),e[14]=d,e[15]=f,e[16]=_):_=e[16];let m;return e[17]!==c||e[18]!==_?(m=o.jsxs("div",{className:"inline-flex items-stretch rounded-md",children:[c,_]}),e[17]=c,e[18]=_,e[19]=m):m=e[19],m}const pg=new Set(["failure","timed_out","cancelled","action_required"]);function gg(t){return t.status==="completed"&&pg.has(t.conclusion)}function vg(t){return t.status==="queued"||t.status==="in_progress"}function xg(t){const{branchStatus:e,pr:s,checks:i,reviews:r,loading:n}=t;if(!e||n)return{label:"Loading…",disabled:!0,loading:!0,variant:"outline",tooltip:"Loading branch and pull request status"};switch(e.kind){case"initializing":return{label:"Starting sandbox…",disabled:!0,loading:!0,variant:"outline",tooltip:"Waiting for the sandbox daemon to come online"};case"cloning":return{label:"Cloning repo…",disabled:!0,loading:!0,variant:"outline",tooltip:"Cloning the project repository"};case"clone-failed":return{label:"Clone failed",disabled:!0,variant:"outline",tooltip:e.error||"git clone failed — see setup logs"};case"checking-out":return{label:`Switching to ${e.to}…`,disabled:!0,loading:!0,variant:"outline",tooltip:`Checking out ${e.to}`};case"checkout-failed":return{label:"Checkout failed",disabled:!0,variant:"outline",tooltip:e.error||"git checkout failed — see setup logs"}}const a=e;if(a.workingTreeDirty||a.unpushed>0)return{label:"Save changes",action:"commit-and-push",variant:"default",tooltip:"Commit and push local changes"};if(s?.merged)return!!a.headSha&&!!s.headSha&&a.headSha!==s.headSha?{label:"Continue",action:"create-pr",variant:"special",tooltip:"Open a new PR with the latest commits"}:{label:"Published",disabled:!0,variant:"outline",tooltip:`PR #${s.number} merged into ${s.base}`};if(a.aheadOfBase>0){if(s&&s.state==="closed"&&!s.merged)return{label:"Reopen",action:"reopen",variant:"default",tooltip:`Reopen PR #${s.number}`};if(!s)return{label:"Submit for review",action:"create-pr",variant:"default",tooltip:`Open a PR for ${a.branch} → ${a.base}`};if((r?.mergeableState??"unknown")==="dirty")return{label:`Sync with ${s.base}`,action:"rebase",variant:"default",tooltip:`Resolve conflicts with ${s.base} before merging`};const c=i.filter(gg).map(f=>f.name);if(c.length>0)return{label:"Fix tests",action:"fix-checks",variant:"default",tooltip:`Failing: ${c.join(", ")}`,meta:{failingChecks:c}};const u=i.filter(vg);if(u.length>0)return{label:"Running tests…",disabled:!0,loading:!0,variant:"outline",tooltip:`Waiting on ${u.length} check${u.length===1?"":"s"} to finish`};if(r?.draft)return{label:"Mark ready",action:"mark-ready",variant:"default",tooltip:"Mark draft PR ready for review"};const d=r?.unresolvedConversations??0;return d>0?{label:"Address feedback",action:"resolve-comments",variant:"default",tooltip:`${d} unresolved conversation${d===1?"":"s"}`}:r?.missingRequiredApprovals?{label:"Awaiting review",disabled:!0,variant:"outline",tooltip:"Waiting for required approvals"}:{label:"Publish",action:"merge-split",variant:"success",tooltip:`Squash-merge PR #${s.number} into ${s.base}`}}return{label:"Up to date",disabled:!0,variant:"outline",tooltip:`Branch is in sync with ${a.base}`}}function bg(){return Xt().branchStatus}const Sg=6e4,yg=3e4;function wg(t){const e=W.c(12);let s;e[0]!==t.connectionId||e[1]!==t.orgId||e[2]!==t.orgSlug?(s={connectionId:t.connectionId,orgId:t.orgId,orgSlug:t.orgSlug},e[0]=t.connectionId,e[1]=t.orgId,e[2]=t.orgSlug,e[3]=s):s=e[3];const i=We(s),r=t.prNumber??0;let n;e[4]!==t.owner||e[5]!==t.repo||e[6]!==r?(n={method:"get",owner:t.owner,repo:t.repo,pullNumber:r},e[4]=t.owner,e[5]=t.repo,e[6]=r,e[7]=n):n=e[7];const a=!!t.prNumber;let l;return e[8]!==i||e[9]!==n||e[10]!==a?(l={client:i,toolName:"pull_request_read",toolArguments:n,enabled:a,refetchInterval:Sg,refetchIntervalInBackground:!1,staleTime:yg,select:Cg},e[8]=i,e[9]=n,e[10]=a,e[11]=l):l=e[11],gs(l)}function Cg(t){const e=Zs(t);if(!e)return null;const s=e.mergeable_state??"unknown",i=!!(e.draft??!1),r=Number(e.review_comments??0),n=s==="blocked"&&r>0?r:0;return{draft:i,mergeableState:s,unresolvedConversations:n,missingRequiredApprovals:s==="blocked"&&n===0}}function kg(t){const e=W.c(42),{virtualMcpId:s}=t,{org:i}=xe(),r=Nt(s),{currentBranch:n}=bt(),a=ps(),l=r?.metadata?.githubRepo??null,h=bg(),c=l?.connectionId??"",u=l?.owner??"",d=l?.name??"",f=n??null;let _;e[0]!==i.id||e[1]!==i.slug||e[2]!==c||e[3]!==u||e[4]!==d||e[5]!==f?(_={orgId:i.id,orgSlug:i.slug,connectionId:c,owner:u,repo:d,branch:f},e[0]=i.id,e[1]=i.slug,e[2]=c,e[3]=u,e[4]=d,e[5]=f,e[6]=_):_=e[6];const m=Fa(_),p=m.data??null,g=l?.connectionId??"",v=l?.owner??"",x=l?.name??"",S=p&&p.state==="open"?p.number:null;let b;e[7]!==i.id||e[8]!==i.slug||e[9]!==g||e[10]!==v||e[11]!==x||e[12]!==S?(b={orgId:i.id,orgSlug:i.slug,connectionId:g,owner:v,repo:x,prNumber:S},e[7]=i.id,e[8]=i.slug,e[9]=g,e[10]=v,e[11]=x,e[12]=S,e[13]=b):b=e[13];const y=Wa(b),N=l?.connectionId??"",C=l?.owner??"",D=l?.name??"",R=p&&p.state==="open"?p.number:null;let B;e[14]!==i.id||e[15]!==i.slug||e[16]!==N||e[17]!==C||e[18]!==D||e[19]!==R?(B={orgId:i.id,orgSlug:i.slug,connectionId:N,owner:C,repo:D,prNumber:R},e[14]=i.id,e[15]=i.slug,e[16]=N,e[17]=C,e[18]=D,e[19]=R,e[20]=B):B=e[20];const M=wg(B);if(!l?.connectionId||!n)return null;let E;e[21]!==h||e[22]!==y.data||e[23]!==p||e[24]!==m.isPending||e[25]!==M.data?(E=xg({branchStatus:h,pr:p,checks:y.data??[],reviews:M.data??null,loading:m.isPending}),e[21]=h,e[22]=y.data,e[23]=p,e[24]=m.isPending,e[25]=M.data,e[26]=E):E=e[26];const k=E;let w;e[27]!==a?(w=V=>a.sendMessage({parts:[{type:"text",text:V}]}),e[27]=a,e[28]=w):w=e[28];const j=w,T=a.isStreaming;let I;e[29]!==n||e[30]!==k||e[31]!==T||e[32]!==p||e[33]!==j?(I=V=>{if(!T)switch(V){case"commit-and-push":{j(vu({branch:n}));return}case"create-pr":{j(xu({branch:n}));return}case"reopen":{p&&j(bu({prNumber:p.number}));return}case"rebase":{j(Su({branch:n}));return}case"fix-checks":{p&&j(wu({prNumber:p.number,failingChecks:k.meta?.failingChecks??[]}));return}case"mark-ready":{p&&j(Cu({prNumber:p.number}));return}case"resolve-comments":{p&&j(ku({prNumber:p.number}));return}case"merge-split":return}},e[29]=n,e[30]=k,e[31]=T,e[32]=p,e[33]=j,e[34]=I):I=e[34];const A=I;let O;e[35]===Symbol.for("react.memo_cache_sentinel")?(O=o.jsx(mg,{orientation:"vertical",className:"mx-2 data-[orientation=vertical]:h-5"}),e[35]=O):O=e[35];const q=p?.number;let U;return e[36]!==k||e[37]!==T||e[38]!==A||e[39]!==j||e[40]!==q?(U=o.jsxs(o.Fragment,{children:[O,o.jsx(Ng,{button:k,isStreaming:T,onActivate:A,prNumber:q,send:j})]}),e[36]=k,e[37]=T,e[38]=A,e[39]=j,e[40]=q,e[41]=U):U=e[41],U}function Ng(t){const e=W.c(21),{button:s,isStreaming:i}=t,r=!!s.disabled||i,n=i?"Chat is running":s.tooltip??null;if(s.action==="merge-split"&&t.prNumber!=null){let u;e[0]!==r||e[1]!==t.prNumber||e[2]!==t.send?(u=o.jsx(_g,{prNumber:t.prNumber,disabled:r,send:t.send}),e[0]=r,e[1]=t.prNumber,e[2]=t.send,e[3]=u):u=e[3];let d;return e[4]!==u||e[5]!==n?(d=o.jsx(qo,{label:n,children:u}),e[4]=u,e[5]=n,e[6]=d):d=e[6],d}let a;e[7]!==s.action||e[8]!==t?(a=()=>t.onActivate(s.action),e[7]=s.action,e[8]=t,e[9]=a):a=e[9];let l;e[10]!==s.loading?(l=s.loading?o.jsx(jh,{size:"xs",variant:"default"}):null,e[10]=s.loading,e[11]=l):l=e[11];let h;e[12]!==s.label||e[13]!==s.variant||e[14]!==r||e[15]!==a||e[16]!==l?(h=o.jsxs(ne,{size:"sm",variant:s.variant,disabled:r,onClick:a,children:[l,s.label]}),e[12]=s.label,e[13]=s.variant,e[14]=r,e[15]=a,e[16]=l,e[17]=h):h=e[17];let c;return e[18]!==h||e[19]!==n?(c=o.jsx(qo,{label:n,children:h}),e[18]=h,e[19]=n,e[20]=c):c=e[20],c}function qo(t){const e=W.c(9),{label:s,children:i}=t;if(!s){let l;return e[0]!==i?(l=o.jsx(o.Fragment,{children:i}),e[0]=i,e[1]=l):l=e[1],l}let r;e[2]!==i?(r=o.jsx(Ye,{asChild:!0,children:o.jsx("span",{children:i})}),e[2]=i,e[3]=r):r=e[3];let n;e[4]!==s?(n=o.jsx(Xe,{children:s}),e[4]=s,e[5]=n):n=e[5];let a;return e[6]!==r||e[7]!==n?(a=o.jsx(Zc,{children:o.jsxs(Ge,{children:[r,n]})}),e[6]=r,e[7]=n,e[8]=a):a=e[8],a}function jg(t){const e=W.c(2),{virtualMcp:s}=t;if(!!!(s.metadata?.githubRepo??null)?.connectionId)return null;let n;return e[0]!==s.id?(n=o.jsx(gr.Right,{children:o.jsx(kg,{virtualMcpId:s.id})}),e[0]=s.id,e[1]=n):n=e[1],n}const ss=P.createContext(null);function Cn(){return P.use(ss)}function Go(t){const e=W.c(7),{children:s}=t,{taskId:i}=bt();let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=o.jsx("div",{className:"flex-1 flex items-center justify-center text-sm text-muted-foreground",children:"Something went wrong loading the chat. Try refreshing."}),e[0]=r):r=e[0];let n;e[1]===Symbol.for("react.memo_cache_sentinel")?(n=o.jsx(Ee.Skeleton,{}),e[1]=n):n=e[1];let a;e[2]!==s?(a=s??o.jsx(Ba,{}),e[2]=s,e[3]=a):a=e[3];let l;return e[4]!==a||e[5]!==i?(l=o.jsx(Ut,{fallback:r,children:o.jsx(P.Suspense,{fallback:n,children:o.jsx(Ee.ActiveTaskProvider,{taskId:i,children:a})})}),e[4]=a,e[5]=i,e[6]=l):l=e[6],l}function Yo(t){const e=W.c(3),{onNewTaskRef:s,createNewTask:i}=t;let r;return e[0]!==i||e[1]!==s?(r=()=>(s.current=i,()=>{s.current=null}),e[0]=i,e[1]=s,e[2]=r):r=e[2],P.useLayoutEffect(r),null}function Eg(t){const e=W.c(3),{onOpenSidebar:s}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=o.jsx(lc,{size:20}),e[0]=i):i=e[0];let r;return e[1]!==s?(r=o.jsx("div",{className:"shrink-0 flex items-center justify-between px-3 h-12 bg-background border-b border-border",children:o.jsx("button",{type:"button",onClick:s,className:"flex size-8 items-center justify-center rounded-md text-foreground/60 hover:bg-accent hover:text-foreground transition-colors","aria-label":"Open menu",children:i})}),e[1]=s,e[2]=r):r=e[2],r}function Xo(t){const e=W.c(16),{virtualMcpId:s,hasActiveGithubRepo:i,vmMap:r,children:n}=t,{org:a}=xe(),{currentBranch:l}=bt(),{data:h}=Ti.useSession(),c=h?.user?.id;let u;e[0]!==a.id||e[1]!==a.slug?(u={connectionId:Ot,orgId:a.id,orgSlug:a.slug},e[0]=a.id,e[1]=a.slug,e[2]=u):u=e[2];const d=We(u),{mutate:f}=dn(d);let _;e[3]===Symbol.for("react.memo_cache_sentinel")?(_=new Set,e[3]=_):_=e[3];const m=P.useRef(_);let p,g;e[4]!==l||e[5]!==i||e[6]!==f||e[7]!==c||e[8]!==s||e[9]!==r?(p=()=>{if(i&&c&&l){if(r?.[c]?.[l]){m.current.add(l);return}m.current.has(l)||(m.current.add(l),f({virtualMcpId:s,branch:l},{onError:Tg}))}},g=[i,c,l,r,s,f],e[4]=l,e[5]=i,e[6]=f,e[7]=c,e[8]=s,e[9]=r,e[10]=p,e[11]=g):(p=e[10],g=e[11]),P.useEffect(p,g);const v=l??null;let x;return e[12]!==n||e[13]!==v||e[14]!==s?(x=o.jsx(Qu,{virtualMcpId:s,branch:v,children:n}),e[12]=n,e[13]=v,e[14]=s,e[15]=x):x=e[15],x}function Tg(t){console.error("[auto-start-vm] failed:",t)}function Rg(){const t=W.c(96),e=ma(),s=Lt(),{org:i}=xe(),r=Hc()?.tasksOpen??!1;Qc(i.slug);let n;t[0]===Symbol.for("react.memo_cache_sentinel")?(n={strict:!1},t[0]=n):n=t[0];const a=Jl(n),l=a.org??"";let h;t[1]===Symbol.for("react.memo_cache_sentinel")?(h={strict:!1},t[1]=h):h=t[1];const c=nn(h);let u;t[2]!==i.id||t[3]!==c.virtualmcpid?(u=c.virtualmcpid??ia(i.id).id,t[2]=i.id,t[3]=c.virtualmcpid,t[4]=u):u=t[4];const d=u,f=Hh(a.taskId??"",d),_=Nt(d),m=_?.metadata?.ui?.layout??null;let p;t[5]!==m?(p=m?{defaultMainView:m.defaultMainView??null,chatDefaultOpen:m.chatDefaultOpen??null}:null,t[5]=m,t[6]=p):p=t[6];const g=p;let v;t[7]!==_?(v=_&&Gt(_),t[7]=_,t[8]=v):v=t[8];const x=!!v;let S;t[9]!==l||t[10]!==d?(S={virtualMcpId:d,orgSlug:l,isAgentRoute:!0},t[9]=l,t[10]=d,t[11]=S):S=t[11];const b=Wc(g,S),{setOpenMobile:y,openMobile:N}=Gc(),C=y,D=P.useRef(null);let R,B;t[12]===Symbol.for("react.memo_cache_sentinel")?(R=()=>{const F=$=>{Kc($)&&$.shiftKey&&$.code==="KeyS"&&!$.repeat&&($.preventDefault(),D.current?.())};return document.addEventListener("keydown",F),()=>document.removeEventListener("keydown",F)},B=[],t[12]=R,t[13]=B):(R=t[12],B=t[13]),P.useEffect(R,B);const M=d;let E;t[14]!==_||t[15]!==d?(E={virtualMcpId:d,entity:_},t[14]=_,t[15]=d,t[16]=E):E=t[16];const k=E;if(f.status==="creating"||f.status==="loading"){let F;t[17]===Symbol.for("react.memo_cache_sentinel")?(F=o.jsx("div",{className:"flex-1 min-h-0 pr-1.5 pb-1.5 overflow-hidden",children:o.jsxs("div",{className:"flex h-full items-center justify-center bg-background card-shadow rounded-[0.75rem] text-sm text-muted-foreground",children:[o.jsx(Ae,{className:"size-4 animate-spin mr-2"}),"Creating task…"]})}),t[17]=F):F=t[17];let $;return t[18]!==k?($=o.jsx(ss,{value:k,children:F}),t[18]=k,t[19]=$):$=t[19],$}if(f.status==="error"){let F;t[20]===Symbol.for("react.memo_cache_sentinel")?(F=o.jsx("div",{className:"font-medium",children:"Task unavailable"}),t[20]=F):F=t[20];let $;t[21]!==f.error.message?($=o.jsx("div",{className:"flex-1 min-h-0 pr-1.5 pb-1.5 overflow-hidden",children:o.jsxs("div",{className:"flex flex-col h-full items-center justify-center gap-2 bg-background card-shadow rounded-[0.75rem] p-8 text-sm",children:[F,o.jsx("div",{className:"text-muted-foreground",children:f.error.message})]})}),t[21]=f.error.message,t[22]=$):$=t[22];let H;return t[23]!==k||t[24]!==$?(H=o.jsx(ss,{value:k,children:$}),t[23]=k,t[24]=$,t[25]=H):H=t[25],H}if(!_){let F;t[26]===Symbol.for("react.memo_cache_sentinel")?(F=o.jsx(Fs,{size:48,className:"text-muted-foreground"}),t[26]=F):F=t[26];const $=`The agent "${d}" does not exist in this organization.`;let H;t[27]!==s||t[28]!==l?(H=o.jsx(ne,{variant:"outline",onClick:()=>s({to:"/$org",params:{org:l}}),children:"Go to organization home"}),t[27]=s,t[28]=l,t[29]=H):H=t[29];let Q;t[30]!==$||t[31]!==H?(Q=o.jsx("div",{className:"flex-1 min-h-0 pr-1.5 pb-1.5 overflow-hidden",children:o.jsx("div",{className:"flex flex-col h-full bg-background overflow-hidden card-shadow rounded-[0.75rem]",children:o.jsx(Hs,{image:F,title:"Agent not found",description:$,actions:H})})}),t[30]=$,t[31]=H,t[32]=Q):Q=t[32];let L;return t[33]!==k||t[34]!==Q?(L=o.jsx(ss,{value:k,children:Q}),t[33]=k,t[34]=Q,t[35]=L):L=t[35],L}if(e){let F;t[36]===Symbol.for("react.memo_cache_sentinel")?(F=o.jsx(Yc,{className:"sr-only",children:"Navigation"}),t[36]=F):F=t[36];let $;t[37]!==C?($=o.jsx("div",{className:"w-14 shrink-0 bg-sidebar flex flex-col items-center border-r border-border overflow-y-auto group/sidebar","data-state":"collapsed",children:o.jsx(Uc,{onClose:()=>C(!1)})}),t[37]=C,t[38]=$):$=t[38];let H;t[39]===Symbol.for("react.memo_cache_sentinel")?(H=o.jsx("div",{className:"flex-1 min-w-0 overflow-hidden",children:o.jsx(Vc,{})}),t[39]=H):H=t[39];let Q;t[40]!==$?(Q=o.jsxs(Xc,{side:"left",hideCloseButton:!0,className:"w-[calc(100vw-3rem)] sm:max-w-md! p-0",children:[F,o.jsxs("div",{className:"flex h-full",children:[$,H]})]}),t[40]=$,t[41]=Q):Q=t[41];let L;t[42]!==N||t[43]!==C||t[44]!==Q?(L=o.jsx(Jc,{open:N,onOpenChange:C,children:Q}),t[42]=N,t[43]=C,t[44]=Q,t[45]=L):L=t[45];const ee=L,se=_?.metadata?.vmMap;let te;t[46]!==b.createNewTask?(te=o.jsx(Yo,{onNewTaskRef:D,createNewTask:b.createNewTask}),t[46]=b.createNewTask,t[47]=te):te=t[47];let G;t[48]!==C?(G=o.jsx(Eg,{onOpenSidebar:()=>C(!0)}),t[48]=C,t[49]=G):G=t[49];let he;t[50]===Symbol.for("react.memo_cache_sentinel")?(he=o.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:o.jsx(Go,{})}),t[50]=he):he=t[50];let fe;t[51]!==x||t[52]!==ee||t[53]!==se||t[54]!==te||t[55]!==G||t[56]!==d?(fe=o.jsxs(Xo,{virtualMcpId:d,hasActiveGithubRepo:x,vmMap:se,children:[te,G,he,ee]}),t[51]=x,t[52]=ee,t[53]=se,t[54]=te,t[55]=G,t[56]=d,t[57]=fe):fe=t[57];let de;t[58]!==M||t[59]!==fe?(de=o.jsx("div",{className:"flex flex-col flex-1 bg-background min-h-0",children:o.jsx(Ee.Provider,{virtualMcpId:M,children:fe},M)}),t[58]=M,t[59]=fe,t[60]=de):de=t[60];let ue;return t[61]!==k||t[62]!==de?(ue=o.jsx(ss,{value:k,children:de}),t[61]=k,t[62]=de,t[63]=ue):ue=t[63],ue}const w=r?void 0:b.createNewTask;let j;t[64]!==b.chatOpen||t[65]!==b.toggleChat||t[66]!==w?(j=o.jsx(gr.Toggles,{children:o.jsx(og,{chatOpen:b.chatOpen,toggleChat:b.toggleChat,onNewTask:w})}),t[64]=b.chatOpen,t[65]=b.toggleChat,t[66]=w,t[67]=j):j=t[67];let T;t[68]!==b.taskId||t[69]!==d?(T=o.jsx(gr.Tabs,{children:o.jsx(fg,{virtualMcpId:d,taskId:b.taskId})}),t[68]=b.taskId,t[69]=d,t[70]=T):T=t[70];const I=_?.metadata?.vmMap;let A;t[71]!==_?(A=o.jsx(jg,{virtualMcp:_}),t[71]=_,t[72]=A):A=t[72];let O;t[73]!==b.createNewTask?(O=o.jsx(Yo,{onNewTaskRef:D,createNewTask:b.createNewTask}),t[73]=b.createNewTask,t[74]=O):O=t[74];let q;t[75]===Symbol.for("react.memo_cache_sentinel")?(q=o.jsx(Go,{}),t[75]=q):q=t[75];let U;t[76]!==b.chatOpen||t[77]!==b.mainOpen||t[78]!==b.taskId||t[79]!==d?(U=o.jsx(ng,{virtualMcpId:d,taskId:b.taskId,chatOpen:b.chatOpen,mainOpen:b.mainOpen,chatContent:q}),t[76]=b.chatOpen,t[77]=b.mainOpen,t[78]=b.taskId,t[79]=d,t[80]=U):U=t[80];let V;t[81]!==x||t[82]!==I||t[83]!==A||t[84]!==O||t[85]!==U||t[86]!==d?(V=o.jsxs(Xo,{virtualMcpId:d,hasActiveGithubRepo:x,vmMap:I,children:[A,O,U]}),t[81]=x,t[82]=I,t[83]=A,t[84]=O,t[85]=U,t[86]=d,t[87]=V):V=t[87];let J;t[88]!==M||t[89]!==T||t[90]!==V?(J=o.jsxs(Ee.Provider,{virtualMcpId:M,children:[T,V]},M),t[88]=M,t[89]=T,t[90]=V,t[91]=J):J=t[91];let Z;return t[92]!==k||t[93]!==j||t[94]!==J?(Z=o.jsx("div",{className:"flex-1 min-w-0 flex flex-col",children:o.jsxs(ss,{value:k,children:[j,J]})}),t[92]=k,t[93]=j,t[94]=J,t[95]=Z):Z=t[95],Z}function O1(){const t=W.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=o.jsx(P.Suspense,{fallback:o.jsx("div",{className:"flex-1 flex items-center justify-center",children:o.jsx(Ae,{size:20,className:"animate-spin text-muted-foreground"})}),children:o.jsx(Rg,{})}),t[0]=e):e=t[0],e}export{O1 as default,Cn as useInsetContext};