decocms 2.278.0 → 2.278.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (269) hide show
  1. package/dist/client/assets/{AlertCircle-DUgLKRqD.js → AlertCircle-RpY4bUJr.js} +1 -1
  2. package/dist/client/assets/{ArrowNarrowLeft-kCQ-qIL4.js → ArrowNarrowLeft-CJwdGPbT.js} +1 -1
  3. package/dist/client/assets/{CheckCircle-DGqHVO6J.js → CheckCircle-BI5IiZgb.js} +1 -1
  4. package/dist/client/assets/{ChevronDown-B24A-aAH.js → ChevronDown-BAXd7Lqd.js} +1 -1
  5. package/dist/client/assets/{ChevronRight-te-i08ST.js → ChevronRight-DKEbZtdl.js} +1 -1
  6. package/dist/client/assets/{ChevronUp-ClIw8oee.js → ChevronUp-DzlxkGUl.js} +1 -1
  7. package/dist/client/assets/{Container-BEpzzcWb.js → Container-DBgGfzNs.js} +1 -1
  8. package/dist/client/assets/{LinkExternal01-DGR8dD9K.js → LinkExternal01-BpU2Zg5G.js} +1 -1
  9. package/dist/client/assets/{Lock01-CgN6byUv.js → Lock01-C5ObVqfL.js} +1 -1
  10. package/dist/client/assets/{Palette-hGvX_iIm.js → Palette-CFaa6lnd.js} +1 -1
  11. package/dist/client/assets/{Play-B45MhCGv.js → Play-Z2rVo32r.js} +1 -1
  12. package/dist/client/assets/{Plus-DEi1gvs0.js → Plus-iqKMHcIY.js} +1 -1
  13. package/dist/client/assets/{SearchMd-Bb-t_BjN.js → SearchMd-CfDkq1If.js} +1 -1
  14. package/dist/client/assets/{Settings02-DqmMmEZU.js → Settings02-BnNqayNe.js} +1 -1
  15. package/dist/client/assets/{Star01-ByFKZL35.js → Star01-BTwJOW68.js} +1 -1
  16. package/dist/client/assets/{Sun-BSLTRNwf.js → Sun-CWTFdsIN.js} +1 -1
  17. package/dist/client/assets/{Tool01-A2H1ijQd.js → Tool01-R5WYUcbi.js} +1 -1
  18. package/dist/client/assets/{Trash01-Dtv8SktB.js → Trash01-DYSvj4Mr.js} +1 -1
  19. package/dist/client/assets/{Upload01-BnthyrUJ.js → Upload01-Cktx5YzE.js} +1 -1
  20. package/dist/client/assets/{User01-B6A46HmV.js → User01-BbQpT999.js} +1 -1
  21. package/dist/client/assets/{Users03-SGJicyFL.js → Users03-DCEUsmLl.js} +1 -1
  22. package/dist/client/assets/{X-ZYbgpGnr.js → X-mGheZZXr.js} +1 -1
  23. package/dist/client/assets/{XCircle-CQXPNkKc.js → XCircle-DayiQYw5.js} +1 -1
  24. package/dist/client/assets/{Zap-CT4bYj4K.js → Zap-BnPwXsSI.js} +1 -1
  25. package/dist/client/assets/{ZapSquare-BIpgOhjL.js → ZapSquare-DnGX7edB.js} +1 -1
  26. package/dist/client/assets/{accordion-DlHNJyYy.js → accordion-hSfs59TQ.js} +1 -1
  27. package/dist/client/assets/{agent-icon-BPm7_0O4.js → agent-icon-D6bLKQ2x.js} +1 -1
  28. package/dist/client/assets/{agents-list-DDy9vjua.js → agents-list-uDQGef9T.js} +1 -1
  29. package/dist/client/assets/ai-providers-DxjF0Bbg.js +1 -0
  30. package/dist/client/assets/{alert-dialog-BYfF9kq9.js → alert-dialog-Dw58KHOn.js} +1 -1
  31. package/dist/client/assets/{auth-catchall-IXiVEa8k.js → auth-catchall-CtfdphV2.js} +1 -1
  32. package/dist/client/assets/{automation-list-row-DdODiuWb.js → automation-list-row-DYTYU42X.js} +1 -1
  33. package/dist/client/assets/{automations-DaQmwJ_-.js → automations-DZS7BnlF.js} +1 -1
  34. package/dist/client/assets/{avatar-Cd7pOZ3k.js → avatar-Or2zrDA-.js} +1 -1
  35. package/dist/client/assets/{badge-XxgdnuAZ.js → badge-gQVaeFYL.js} +1 -1
  36. package/dist/client/assets/{brand-context-gdbCtW1V.js → brand-context-C8YhXjoC.js} +1 -1
  37. package/dist/client/assets/{card-ohyYL2jd.js → card-N_n9dJ1C.js} +1 -1
  38. package/dist/client/assets/{chat-context-BBBi8D2H.js → chat-context-0qKFTvd4.js} +10 -10
  39. package/dist/client/assets/{checkbox-CV6BjILT.js → checkbox-CPuyzGEM.js} +1 -1
  40. package/dist/client/assets/{collection-detail-BDC-qOMT.js → collection-detail-DFwTqhD1.js} +1 -1
  41. package/dist/client/assets/{collection-display-button-Dzc3fhoU.js → collection-display-button-njo6Xh2u.js} +1 -1
  42. package/dist/client/assets/{collection-search-RK7vbvUN.js → collection-search-CaS2n1cB.js} +1 -1
  43. package/dist/client/assets/{collection-table-wrapper-DSiZO_Rx.js → collection-table-wrapper-Dcn0zsHK.js} +1 -1
  44. package/dist/client/assets/{collection-tabs-BThF2_kc.js → collection-tabs-ByBcZvcT.js} +1 -1
  45. package/dist/client/assets/{collections-D4PM7cfP.js → collections-Djr3E20Q.js} +1 -1
  46. package/dist/client/assets/{command-D-rn-MCf.js → command-B51t2F-w.js} +1 -1
  47. package/dist/client/assets/{connection-card-C77H1oWc.js → connection-card-Mc71vwAD.js} +1 -1
  48. package/dist/client/assets/{connection-detail-B3eR0g_I.js → connection-detail-DtSaPCBM.js} +1 -1
  49. package/dist/client/assets/{connection-form-helpers-C9kgqFQD.js → connection-form-helpers-fgpIig1w.js} +1 -1
  50. package/dist/client/assets/{connections-DLnzLvDf.js → connections-DyzLArcN.js} +1 -1
  51. package/dist/client/assets/{constants-CBMPX4Nz.js → constants-Bp5-iYcY.js} +1 -1
  52. package/dist/client/assets/{constants-DV3gfGwj.js → constants-DML917gs.js} +1 -1
  53. package/dist/client/assets/{dialog-LWRIZTr3.js → dialog-6uxiP96k.js} +1 -1
  54. package/dist/client/assets/{drawer-D1pg0ocH.js → drawer-CbvLq5Uu.js} +1 -1
  55. package/dist/client/assets/{dropdown-menu-DLn7MpGb.js → dropdown-menu-BSSwgSj1.js} +1 -1
  56. package/dist/client/assets/{dynamic-plugin-layout-BSXEX5vh.js → dynamic-plugin-layout-0EJvlc60.js} +1 -1
  57. package/dist/client/assets/{empty-state-DkrYdGBA.js → empty-state-0hDWNUcx.js} +1 -1
  58. package/dist/client/assets/{empty-state-t8Y8fpWZ.js → empty-state-CU7_u48I.js} +1 -1
  59. package/dist/client/assets/{extract-connection-data-BhJroSSL.js → extract-connection-data-Cezio-s5.js} +1 -1
  60. package/dist/client/assets/{features-B5cMQOy4.js → features-DmtZ7olV.js} +1 -1
  61. package/dist/client/assets/{form-DYWw7BDT.js → form-oEblHddW.js} +1 -1
  62. package/dist/client/assets/{general-Bx99MR-8.js → general-CeUrSx0B.js} +1 -1
  63. package/dist/client/assets/{index-Ds-JIDUi.js → index-0wk7oXl7.js} +4 -4
  64. package/dist/client/assets/{index-CTb5Ivgi.js → index-C2YTBPmn.js} +1 -1
  65. package/dist/client/assets/{index-9mpD21lu.js → index-CNrMlOJM.js} +1 -1
  66. package/dist/client/assets/{index-dR4PVdxt.js → index-CSYRl1zg.js} +1 -1
  67. package/dist/client/assets/{index-DphB1nct.js → index-DYe52Cyo.js} +1 -1
  68. package/dist/client/assets/{index-DNVFRTN5.js → index-Db1p8aFu.js} +1 -1
  69. package/dist/client/assets/{index-DQr1bBCj.js → index-DlGWDjkU.js} +1 -1
  70. package/dist/client/assets/{index-BAPPcxpC.js → index-_3-Zp92L.js} +1 -1
  71. package/dist/client/assets/{index-RqKqA1J6.js → index-gAKn78NR.js} +1 -1
  72. package/dist/client/assets/{index-CAeiwvn1.js → index-yA3niX2v.js} +2 -2
  73. package/dist/client/assets/{infiniteQueryObserver-DgmIeDDw.js → infiniteQueryObserver-Kusj8ovY.js} +1 -1
  74. package/dist/client/assets/{input-bSmRFU9Y.js → input-B9sAUDOT.js} +1 -1
  75. package/dist/client/assets/{integration-icon-BCfLG4yN.js → integration-icon-LoNFtirH.js} +1 -1
  76. package/dist/client/assets/{label-DHm3L_Pw.js → label-WH1pO6UH.js} +1 -1
  77. package/dist/client/assets/{layout-Bi-oKYFz.js → layout-XdKnShqM.js} +1 -1
  78. package/dist/client/assets/{lean-canvas-recruit-modal-Y-73eqIT.js → lean-canvas-recruit-modal-C6N1BBPO.js} +1 -1
  79. package/dist/client/assets/{login-oTC9k0u0.js → login-vj34UALt.js} +1 -1
  80. package/dist/client/assets/{members-DXtluaQF.js → members-rAC4_0t4.js} +1 -1
  81. package/dist/client/assets/{monaco-editor-J6gXCbSf.js → monaco-editor-iXGMVCiz.js} +1 -1
  82. package/dist/client/assets/{monitoring-stats-row-COftXD12.js → monitoring-stats-row-BloCdgbG.js} +1 -1
  83. package/dist/client/assets/{oauth-callback-iJ681_o2.js → oauth-callback-CELgu_cO.js} +1 -1
  84. package/dist/client/assets/{oauth-callback-ai-provider-BG5KUhrn.js → oauth-callback-ai-provider-DsyvZ6lU.js} +1 -1
  85. package/dist/client/assets/{onboarding-CaPHCpYM.js → onboarding-BgyTCUN-.js} +1 -1
  86. package/dist/client/assets/{org-layout-tpbZft4k.js → org-layout-XurBF-Lt.js} +1 -1
  87. package/dist/client/assets/{org-plugin-layout-DKUGssvU.js → org-plugin-layout-BSk2n1gQ.js} +1 -1
  88. package/dist/client/assets/{plugin-empty-state-CjLoe77j.js → plugin-empty-state-CRqsi0ib.js} +1 -1
  89. package/dist/client/assets/{plugin-header-D-DgJiT_.js → plugin-header-BZp9Mspt.js} +1 -1
  90. package/dist/client/assets/{plugin-layout-BxoJjnAH.js → plugin-layout-BadNZHL3.js} +1 -1
  91. package/dist/client/assets/{popover-QXf8PVl2.js → popover-GxFgGfCj.js} +1 -1
  92. package/dist/client/assets/{profile-BXxDmHas.js → profile-CWbzz0se.js} +1 -1
  93. package/dist/client/assets/{project-app-view-CpeukqHC.js → project-app-view-Cgxq8Z9m.js} +1 -1
  94. package/dist/client/assets/registry-BN8y2uhx.js +2 -0
  95. package/dist/client/assets/{registry-layout-Dp1ULu6N.js → registry-layout-C8Qiz9yD.js} +1 -1
  96. package/dist/client/assets/{required-auth-layout-BQkYfP3n.js → required-auth-layout-OZ0PdFXR.js} +1 -1
  97. package/dist/client/assets/{reset-password-CU4ON9vN.js → reset-password-s2ukM5mp.js} +1 -1
  98. package/dist/client/assets/{scroll-area-CM6U9wSm.js → scroll-area-Bzy4HD_J.js} +1 -1
  99. package/dist/client/assets/{search-input-D1anatj6.js → search-input-Bnf2nHLo.js} +1 -1
  100. package/dist/client/assets/{select-DE9H0LNP.js → select-ReQwhRkA.js} +1 -1
  101. package/dist/client/assets/{select-model-C72ySuI7.js → select-model-D4OtA_w2.js} +1 -1
  102. package/dist/client/assets/{settings-layout-BcGWWnw4.js → settings-layout-BL-BX1UN.js} +1 -1
  103. package/dist/client/assets/{shell-layout-DbjX6AWI.js → shell-layout-BD0Xub-g.js} +1 -1
  104. package/dist/client/assets/{skeleton-DJZQh5Pk.js → skeleton-B313Ulm0.js} +1 -1
  105. package/dist/client/assets/{sso-330TvduR.js → sso-ZrM6U_dp.js} +1 -1
  106. package/dist/client/assets/{store-CValARVk.js → store-CbZTBfxH.js} +1 -1
  107. package/dist/client/assets/store-registry-CXWRsbL6.js +2 -0
  108. package/dist/client/assets/{switch-DXZpP3PP.js → switch-BXD1owGz.js} +1 -1
  109. package/dist/client/assets/{table-BC1vaa2h.js → table-rsOFtuU-.js} +1 -1
  110. package/dist/client/assets/{tabs-y_vyQ1bZ.js → tabs-DO4ygLuS.js} +1 -1
  111. package/dist/client/assets/{task-status-u0ZgPY9s.js → task-status-CaevYqis.js} +1 -1
  112. package/dist/client/assets/{textarea-BKBUm0h-.js → textarea-DDf010du.js} +1 -1
  113. package/dist/client/assets/{toggle-group-BGNuzMLR.js → toggle-group-Bo4IS3RK.js} +1 -1
  114. package/dist/client/assets/{tools-list-DnYw-GLl.js → tools-list-CIQ6CwYm.js} +1 -1
  115. package/dist/client/assets/{types-_e2R6uHw.js → types-952BCAPT.js} +1 -1
  116. package/dist/client/assets/{use-ai-providers-DA7fBB8t.js → use-ai-providers-BirgTm09.js} +1 -1
  117. package/dist/client/assets/{use-collections-B56DgGhQ.js → use-collections-By6uZJSr.js} +1 -1
  118. package/dist/client/assets/{use-connection-DmlqhQzU.js → use-connection-CZkpN1_f.js} +1 -1
  119. package/dist/client/assets/{use-copy-yDy37O6x.js → use-copy-DSXw9G_Y.js} +1 -1
  120. package/dist/client/assets/{use-create-virtual-mcp-St-hxc3T.js → use-create-virtual-mcp-BNzn74Vf.js} +1 -1
  121. package/dist/client/assets/{use-decopilot-events-C6hMvsnN.js → use-decopilot-events-Yr2IQvc8.js} +1 -1
  122. package/dist/client/assets/{use-delete-connection-9Vw8o7eu.js → use-delete-connection-BUM30EhS.js} +1 -1
  123. package/dist/client/assets/{use-infinite-scroll-BDoBJohW.js → use-infinite-scroll-DmTHG8QF.js} +1 -1
  124. package/dist/client/assets/{use-list-state-BSaQM_cf.js → use-list-state-9mz92TGW.js} +1 -1
  125. package/dist/client/assets/{use-mcp-tools-CrNS6JKZ.js → use-mcp-tools-D2wfRdQX.js} +1 -1
  126. package/dist/client/assets/{use-members-CuGMiyzy.js → use-members-COfO6YRW.js} +1 -1
  127. package/dist/client/assets/{use-mobile-Dcrjnr8n.js → use-mobile-cBCc1tkS.js} +1 -1
  128. package/dist/client/assets/{use-navigate-to-agent-CK6LXIOn.js → use-navigate-to-agent-8jFeFT9G.js} +1 -1
  129. package/dist/client/assets/{use-org-sso-CDZI8wr6.js → use-org-sso-B4d8umPM.js} +1 -1
  130. package/dist/client/assets/{use-organization-settings-Dz4Ob_xk.js → use-organization-settings-Bfqz0Dub.js} +1 -1
  131. package/dist/client/assets/{use-registry-connections-C4iSg1no.js → use-registry-connections-BX2aMDCo.js} +1 -1
  132. package/dist/client/assets/{use-status-sounds-BpX9On4z.js → use-status-sounds-B5cgRwGB.js} +1 -1
  133. package/dist/client/assets/{use-tasks-B1E3D-6c.js → use-tasks-C63aBSUV.js} +1 -1
  134. package/dist/client/assets/{use-view-mode-OuDPu3JY.js → use-view-mode-Btze869M.js} +1 -1
  135. package/dist/client/assets/{use-virtual-mcp-C84ySRY_.js → use-virtual-mcp-C3-aNrQY.js} +1 -1
  136. package/dist/client/assets/useInfiniteQuery-DBOEwCdJ.js +1 -0
  137. package/dist/client/assets/{user-D-ueNiJ9.js → user-zYk_lp5f.js} +1 -1
  138. package/dist/client/assets/{view-mode-toggle-JzxZIaam.js → view-mode-toggle-BrDfC5aK.js} +1 -1
  139. package/dist/client/assets/{workflow-DILBdxqV.js → workflow-BOdefRku.js} +1 -1
  140. package/dist/client/assets/workflow-detail-JXXWRY8y.js +1 -0
  141. package/dist/client/index.html +1 -1
  142. package/dist/server/cli.js +328 -328
  143. package/dist/server/node_modules/figures/index.d.ts +279 -0
  144. package/dist/server/node_modules/figures/index.js +292 -0
  145. package/dist/server/node_modules/{is-fullwidth-code-point → figures}/package.json +16 -20
  146. package/dist/server/node_modules/figures/readme.md +337 -0
  147. package/dist/server/node_modules/get-east-asian-width/index.d.ts +60 -0
  148. package/dist/server/node_modules/get-east-asian-width/index.js +30 -0
  149. package/dist/server/node_modules/get-east-asian-width/lookup-data.js +18 -0
  150. package/dist/server/node_modules/get-east-asian-width/lookup.js +135 -0
  151. package/dist/server/node_modules/get-east-asian-width/package.json +71 -0
  152. package/dist/server/node_modules/get-east-asian-width/readme.md +65 -0
  153. package/dist/server/node_modules/get-east-asian-width/utilities.js +24 -0
  154. package/dist/server/node_modules/pg/README.md +95 -0
  155. package/dist/server/node_modules/pg/esm/index.mjs +20 -0
  156. package/dist/server/node_modules/pg/lib/client.js +743 -0
  157. package/dist/server/node_modules/pg/lib/connection-parameters.js +171 -0
  158. package/dist/server/node_modules/pg/lib/connection.js +221 -0
  159. package/dist/server/node_modules/pg/lib/crypto/cert-signatures.js +122 -0
  160. package/dist/server/node_modules/pg/lib/crypto/sasl.js +212 -0
  161. package/dist/server/node_modules/pg/lib/crypto/utils-legacy.js +43 -0
  162. package/dist/server/node_modules/pg/lib/crypto/utils-webcrypto.js +89 -0
  163. package/dist/server/node_modules/pg/lib/crypto/utils.js +9 -0
  164. package/dist/server/node_modules/pg/lib/defaults.js +91 -0
  165. package/dist/server/node_modules/pg/lib/index.js +73 -0
  166. package/dist/server/node_modules/pg/lib/native/client.js +323 -0
  167. package/dist/server/node_modules/pg/lib/native/index.js +2 -0
  168. package/dist/server/node_modules/pg/lib/native/query.js +165 -0
  169. package/dist/server/node_modules/pg/lib/query.js +252 -0
  170. package/dist/server/node_modules/pg/lib/result.js +109 -0
  171. package/dist/server/node_modules/pg/lib/stream.js +83 -0
  172. package/dist/server/node_modules/pg/lib/type-overrides.js +35 -0
  173. package/dist/server/node_modules/pg/lib/utils.js +217 -0
  174. package/dist/server/node_modules/pg/package.json +76 -0
  175. package/dist/server/node_modules/postgres-bytea/index.js +33 -0
  176. package/dist/server/node_modules/{postgres-interval → postgres-bytea}/package.json +8 -10
  177. package/dist/server/node_modules/postgres-bytea/readme.md +34 -0
  178. package/dist/server/node_modules/slice-ansi/index.d.ts +19 -0
  179. package/dist/server/node_modules/slice-ansi/index.js +260 -0
  180. package/dist/server/node_modules/{is-unicode-supported → slice-ansi}/license +1 -0
  181. package/dist/server/node_modules/slice-ansi/package.json +59 -0
  182. package/dist/server/node_modules/slice-ansi/readme.md +54 -0
  183. package/dist/server/node_modules/slice-ansi/tokenize-ansi.js +752 -0
  184. package/dist/server/node_modules/split2/LICENSE +13 -0
  185. package/dist/server/node_modules/split2/README.md +85 -0
  186. package/dist/server/node_modules/split2/bench.js +27 -0
  187. package/dist/server/node_modules/split2/index.js +141 -0
  188. package/dist/server/node_modules/split2/package.json +39 -0
  189. package/dist/server/node_modules/split2/test.js +409 -0
  190. package/dist/server/node_modules/xtend/.jshintrc +30 -0
  191. package/dist/server/node_modules/{postgres-interval/license → xtend/LICENSE} +1 -2
  192. package/dist/server/node_modules/xtend/README.md +32 -0
  193. package/dist/server/node_modules/xtend/immutable.js +19 -0
  194. package/dist/server/node_modules/xtend/mutable.js +17 -0
  195. package/dist/server/node_modules/xtend/package.json +55 -0
  196. package/dist/server/node_modules/xtend/test.js +103 -0
  197. package/dist/server/server.js +270 -270
  198. package/package.json +1 -1
  199. package/dist/client/assets/ai-providers-B4zJ5gIB.js +0 -1
  200. package/dist/client/assets/registry-BwQkRfy5.js +0 -2
  201. package/dist/client/assets/store-registry-DxTZD8aD.js +0 -2
  202. package/dist/client/assets/useInfiniteQuery-C63zt5p0.js +0 -1
  203. package/dist/client/assets/workflow-detail-CbBLr-jD.js +0 -1
  204. package/dist/server/node_modules/convert-to-spaces/dist/index.d.ts +0 -2
  205. package/dist/server/node_modules/convert-to-spaces/dist/index.js +0 -4
  206. package/dist/server/node_modules/convert-to-spaces/license +0 -21
  207. package/dist/server/node_modules/convert-to-spaces/package.json +0 -40
  208. package/dist/server/node_modules/convert-to-spaces/readme.md +0 -39
  209. package/dist/server/node_modules/emoji-regex/LICENSE-MIT.txt +0 -20
  210. package/dist/server/node_modules/emoji-regex/README.md +0 -107
  211. package/dist/server/node_modules/emoji-regex/index.d.ts +0 -3
  212. package/dist/server/node_modules/emoji-regex/index.js +0 -4
  213. package/dist/server/node_modules/emoji-regex/index.mjs +0 -4
  214. package/dist/server/node_modules/emoji-regex/package.json +0 -45
  215. package/dist/server/node_modules/environment/index.d.ts +0 -74
  216. package/dist/server/node_modules/environment/index.js +0 -47
  217. package/dist/server/node_modules/environment/package.json +0 -74
  218. package/dist/server/node_modules/environment/readme.md +0 -94
  219. package/dist/server/node_modules/escape-string-regexp/index.d.ts +0 -18
  220. package/dist/server/node_modules/escape-string-regexp/index.js +0 -11
  221. package/dist/server/node_modules/escape-string-regexp/license +0 -9
  222. package/dist/server/node_modules/escape-string-regexp/package.json +0 -43
  223. package/dist/server/node_modules/escape-string-regexp/readme.md +0 -29
  224. package/dist/server/node_modules/is-fullwidth-code-point/index.d.ts +0 -17
  225. package/dist/server/node_modules/is-fullwidth-code-point/index.js +0 -12
  226. package/dist/server/node_modules/is-fullwidth-code-point/readme.md +0 -31
  227. package/dist/server/node_modules/is-unicode-supported/index.d.ts +0 -12
  228. package/dist/server/node_modules/is-unicode-supported/index.js +0 -21
  229. package/dist/server/node_modules/is-unicode-supported/package.json +0 -47
  230. package/dist/server/node_modules/is-unicode-supported/readme.md +0 -35
  231. package/dist/server/node_modules/pg-cloudflare/README.md +0 -112
  232. package/dist/server/node_modules/pg-cloudflare/dist/empty.d.ts +0 -2
  233. package/dist/server/node_modules/pg-cloudflare/dist/empty.js +0 -6
  234. package/dist/server/node_modules/pg-cloudflare/dist/empty.js.map +0 -1
  235. package/dist/server/node_modules/pg-cloudflare/dist/index.d.ts +0 -31
  236. package/dist/server/node_modules/pg-cloudflare/dist/index.js +0 -152
  237. package/dist/server/node_modules/pg-cloudflare/dist/index.js.map +0 -1
  238. package/dist/server/node_modules/pg-cloudflare/esm/index.mjs +0 -3
  239. package/dist/server/node_modules/pg-cloudflare/package.json +0 -39
  240. package/dist/server/node_modules/pg-cloudflare/src/empty.ts +0 -3
  241. package/dist/server/node_modules/pg-cloudflare/src/index.ts +0 -166
  242. package/dist/server/node_modules/pg-cloudflare/src/types.d.ts +0 -25
  243. package/dist/server/node_modules/pg-connection-string/LICENSE +0 -21
  244. package/dist/server/node_modules/pg-connection-string/README.md +0 -105
  245. package/dist/server/node_modules/pg-connection-string/esm/index.mjs +0 -8
  246. package/dist/server/node_modules/pg-connection-string/index.d.ts +0 -36
  247. package/dist/server/node_modules/pg-connection-string/index.js +0 -231
  248. package/dist/server/node_modules/pg-connection-string/package.json +0 -52
  249. package/dist/server/node_modules/postgres-array/index.d.ts +0 -4
  250. package/dist/server/node_modules/postgres-array/index.js +0 -97
  251. package/dist/server/node_modules/postgres-array/package.json +0 -35
  252. package/dist/server/node_modules/postgres-array/readme.md +0 -43
  253. package/dist/server/node_modules/postgres-interval/index.d.ts +0 -20
  254. package/dist/server/node_modules/postgres-interval/index.js +0 -125
  255. package/dist/server/node_modules/postgres-interval/readme.md +0 -48
  256. package/dist/server/node_modules/restore-cursor/index.d.ts +0 -11
  257. package/dist/server/node_modules/restore-cursor/index.js +0 -11
  258. package/dist/server/node_modules/restore-cursor/license +0 -9
  259. package/dist/server/node_modules/restore-cursor/package.json +0 -55
  260. package/dist/server/node_modules/restore-cursor/readme.md +0 -31
  261. package/dist/server/node_modules/string-width/index.d.ts +0 -39
  262. package/dist/server/node_modules/string-width/index.js +0 -82
  263. package/dist/server/node_modules/string-width/license +0 -9
  264. package/dist/server/node_modules/string-width/package.json +0 -64
  265. package/dist/server/node_modules/string-width/readme.md +0 -66
  266. /package/dist/server/node_modules/{environment → figures}/license +0 -0
  267. /package/dist/server/node_modules/{is-fullwidth-code-point → get-east-asian-width}/license +0 -0
  268. /package/dist/server/node_modules/{pg-cloudflare → pg}/LICENSE +0 -0
  269. /package/dist/server/node_modules/{postgres-array → postgres-bytea}/license +0 -0
@@ -1,5 +1,5 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/project-app-view-CpeukqHC.js","assets/index-CAeiwvn1.js","assets/index-B2LlXg0m.css","assets/task-status-u0ZgPY9s.js","assets/agent-icon-BPm7_0O4.js","assets/AlertCircle-DUgLKRqD.js","assets/Tool01-A2H1ijQd.js","assets/SearchMd-Bb-t_BjN.js","assets/ArrowNarrowLeft-kCQ-qIL4.js","assets/XCircle-CQXPNkKc.js","assets/ZapSquare-BIpgOhjL.js","assets/Users03-SGJicyFL.js","assets/CheckCircle-DGqHVO6J.js","assets/ChevronDown-B24A-aAH.js","assets/ChevronRight-te-i08ST.js","assets/ChevronUp-ClIw8oee.js","assets/Container-BEpzzcWb.js","assets/Star01-ByFKZL35.js","assets/Palette-hGvX_iIm.js","assets/index-dR4PVdxt.js","assets/use-mobile-Dcrjnr8n.js","assets/X-ZYbgpGnr.js","assets/LinkExternal01-DGR8dD9K.js","assets/Lock01-CgN6byUv.js","assets/Sun-BSLTRNwf.js","assets/Play-B45MhCGv.js","assets/Plus-DEi1gvs0.js","assets/Settings02-DqmMmEZU.js","assets/Trash01-Dtv8SktB.js","assets/Upload01-BnthyrUJ.js","assets/User01-B6A46HmV.js","assets/Zap-CT4bYj4K.js","assets/scroll-area-CM6U9wSm.js","assets/select-DE9H0LNP.js","assets/use-copy-yDy37O6x.js","assets/differenceInSeconds-NQ4PDo0z.js","assets/dialog-LWRIZTr3.js","assets/content-blocks-o63cs2vh.js","assets/types-_e2R6uHw.js","assets/constants-DV3gfGwj.js","assets/chat-context-BBBi8D2H.js","assets/use-virtual-mcp-C84ySRY_.js","assets/use-collections-B56DgGhQ.js","assets/use-ai-providers-DA7fBB8t.js","assets/use-decopilot-events-C6hMvsnN.js","assets/create-sse-subscription-CxkOgzKf.js","assets/use-tasks-B1E3D-6c.js","assets/use-organization-settings-Dz4Ob_xk.js","assets/shell-layout-DbjX6AWI.js","assets/required-auth-layout-BQkYfP3n.js","assets/use-org-sso-CDZI8wr6.js","assets/integration-icon-BCfLG4yN.js","assets/use-mcp-tools-CrNS6JKZ.js"])))=>i.map(i=>d[i]);
2
- import{o as Mt,r as S,p as Om,q as $m,e as B,s as be,K as lt,n as Fi,a as Br,v as Vs,w as Or,x as Hi,j as r,B as ne,y as Et,c as X,E as Cs,z as pe,C as Wi,_ as zm,t as se,f as Ke,D as yh,F as Fm,R as Sh,G as Hm,H as ys,I as So,J as ds,L as Wm,M as wo,P as Um,Q as Km,T as qm,U as Gm,V as wh,W as Ym,X as Xm,Y as Jm,Z as Qm,$ as lc,l as Ee,b as St,u as Zm,a0 as pr,a1 as vn,a2 as nl,a3 as ol,g as $r,a4 as Vh,d as vi,a5 as ep,a6 as tp,a7 as sp,a8 as ip,a9 as Ch,aa as jh,ab as rp,ac as np,ad as op,ae as Ft,af as ap,ag as lp,ah as cp,ai as dp,aj as Zi,ak as hp,al as up,am as fp,an as mp,ao as kh,ap as pp,aq as gp,ar as _p,as as xp,at as vp,au as bp,av as yp,aw as Sp,ax as wp,ay as Vp,az as Nh,aA as bn,aB as Cp,aC as Ai,aD as nn,aE as Ah,aF as jp,aG as kp}from"./index-CAeiwvn1.js";import{u as ni,a as Ui,b as es,A as Np,C as Ap,c as ia,d as Ep,e as Zn,f as cc,t as Ip}from"./chat-context-BBBi8D2H.js";import{d as eo,g as si,c as Rp,s as al,t as Tp,a as Dp,M as Mp,i as Pp,b as Cr,e as Lp,F as Bp,f as Eh,S as Op,u as $p,h as dc,j as zp,k as Fp,l as ra,r as Hp,m as Wp,p as Ih,n as Up,o as Kp,q as ll,G as qp,L as Gp,v as Yp,w as Xp,x as Jp,y as Qp}from"./task-status-u0ZgPY9s.js";import{S as jr,u as to,P as na,a as Zp,b as eg,c as tg,E as sg,i as ig,d as rg,e as Rh}from"./scroll-area-CM6U9wSm.js";import{T as Mi,u as Rs,a as tt,b as st,c as it}from"./use-mobile-Dcrjnr8n.js";import{D as Ts,a as Ds,b as cl,c as ms,d as ps,e as dl}from"./dialog-LWRIZTr3.js";import{D as so,a as bi,b as yi,c as Si,d as ng,e as og,f as ag}from"./drawer-D1pg0ocH.js";import{C as Th}from"./collection-search-RK7vbvUN.js";import{S as Wt,u as Me,g as io,i as Mn,c as lg,W as Os,a as cg,b as hl}from"./constants-DV3gfGwj.js";import{u as Dh,g as ul,T as Mh,a as yn,l as Pn,b as Vo,c as dg}from"./tabs-y_vyQ1bZ.js";import{F as Pi,a as It,b as Rt,c as rs,d as Tt,e as Dt,f as hg}from"./form-DYWw7BDT.js";import{I as bt}from"./input-bSmRFU9Y.js";import{i as Ph,u as zr,r as Lh}from"./shell-layout-DbjX6AWI.js";import{D as ot,a as Sn,b as wn,c as js,d as ks,e as Ns,f as Bh,g as Oh,h as hc}from"./dropdown-menu-DLn7MpGb.js";import{t as ug,i as $h,n as fg,A as zs,a as zh,b as fl,s as ii,c as mg,d as pg,e as Fh,f as Hh,g as gg,h as ml,j as gr,k as _g,l as pl,m as xg,o as vg,p as Fr,q as Hr,r as bg,u as uc,v as fc,w as yg,x as Sg,y as mc,z as wg,B as gl,C as Wh,D as oa,E as Co,F as pc,G as Vg,H as Cg,I as jg,J as kg,K as Uh,L as Kh,M as qh,N as Gh,O as gc,P as Ng,Q as _r,R as Ag,S as Eg,T as Ig,U as Yh}from"./agent-icon-BPm7_0O4.js";import{n as Xh,a as aa,i as Rg,b as Tg,c as Dg}from"./ZapSquare-BIpgOhjL.js";import{i as Jt,t as kr}from"./ChevronDown-B24A-aAH.js";import{s as Ti}from"./Star01-ByFKZL35.js";import{a as la,t as _l}from"./Tool01-A2H1ijQd.js";import{i as Jh}from"./Lock01-CgN6byUv.js";import{s as Qt}from"./Plus-DEi1gvs0.js";import{i as Qh}from"./Upload01-BnthyrUJ.js";import{i as fi}from"./X-ZYbgpGnr.js";import{i as ri}from"./AlertCircle-DUgLKRqD.js";import{S as Js,a as Qs,b as Ht,c as Zs,d as ei}from"./select-DE9H0LNP.js";import{i as xl,a as vl,b as Mg}from"./SearchMd-Bb-t_BjN.js";import{i as ro,t as Pg,a as Lg,b as Bg,c as Og,d as $g,e as Li,f as Zh}from"./XCircle-CQXPNkKc.js";import{T as eu,a as Ln}from"./toggle-group-BGNuzMLR.js";import{u as bl,a as tu}from"./use-ai-providers-DA7fBB8t.js";import{m as no,g as zg,i as Fg,a as su,M as iu,N as Hg}from"./select-model-C72ySuI7.js";import{S as Wg,A as Ug,a as Kg,b as qg,c as Gg,R as ru,d as Yg,e as Xg}from"./accordion-DlHNJyYy.js";import{r as nu,l as xr,u as Jg,g as Qg}from"./types-_e2R6uHw.js";import{u as oo,a as ts,b as yl}from"./use-virtual-mcp-C84ySRY_.js";import{u as Wr,a as Sl,b as wl}from"./use-connection-DmlqhQzU.js";import{p as Zg,q as _c}from"./question-004-sINsf4GQ.js";import{g as xc}from"./ai-providers-logos-CS4PCiqI.js";import{g as ou,s as au}from"./connection-slug-eyAPH6o3.js";import{u as lu,a as cu,g as e_,C as jo}from"./connection-card-C77H1oWc.js";import{C as du}from"./collection-tabs-BThF2_kc.js";import{g as hu}from"./constants-CBMPX4Nz.js";import{T as ca}from"./textarea-BKBUm0h-.js";import{n as Vn}from"./Container-BEpzzcWb.js";import{c as t_,i as on,a as vc,E as s_,p as i_,b as r_,d as n_}from"./connection-form-helpers-C9kgqFQD.js";import{u as bc}from"./use-infinite-scroll-BDoBJohW.js";import{u as o_,C as a_,a as yc,b as Sc,c as l_,d as c_,e as d_,f as h_}from"./command-D-rn-MCf.js";import{g as u_,e as f_,a as m_}from"./extract-connection-data-BhJroSSL.js";import{B as wc}from"./badge-XxgdnuAZ.js";import{i as Vl}from"./ChevronRight-te-i08ST.js";import{I as Ms}from"./integration-icon-BCfLG4yN.js";import{S as Bi}from"./skeleton-DJZQh5Pk.js";import{a as ao}from"./Users03-SGJicyFL.js";import{I as Bn,S as uu,G as p_,L as g_,a as __,b as fu}from"./lean-canvas-recruit-modal-Y-73eqIT.js";import{u as lo,a as mu}from"./use-navigate-to-agent-CK6LXIOn.js";import{u as pu}from"./use-create-virtual-mcp-St-hxc3T.js";import{i as x_}from"./CheckCircle-DGqHVO6J.js";import{P as oi,a as ai,b as li}from"./popover-QXf8PVl2.js";import{u as wi,a as v_}from"./use-mcp-tools-CrNS6JKZ.js";import{E as Oi}from"./empty-state-DkrYdGBA.js";import{u as b_}from"./use-decopilot-events-C6hMvsnN.js";import{i as $i}from"./Zap-CT4bYj4K.js";import{i as gu,S as Ur,a as Kr,b as gs,u as qr,c as us,d as Zt,e as _u,f as xu,g as y_,h as vu,j as bu,P as hs,k as S_,l as w_,m as V_,n as C_,o as j_,p as k_}from"./index-dR4PVdxt.js";import{A as Vc}from"./avatar-Cd7pOZ3k.js";import{n as N_,a as A_,i as E_}from"./Sun-BSLTRNwf.js";import{a as Gr}from"./Settings02-DqmMmEZU.js";import{A as Cl,a as jl,b as kl,c as Nl,d as Al,e as El,f as Il,g as yu}from"./alert-dialog-BYfF9kq9.js";import"./index-DphB1nct.js";import{u as Su}from"./use-tasks-B1E3D-6c.js";import{u as I_}from"./use-status-sounds-BpX9On4z.js";import{T as R_,u as wu}from"./tools-list-DnYw-GLl.js";import{u as ko}from"./unwrap-tool-result-BYXdCQMg.js";import{C as T_,a as Cc}from"./card-ohyYL2jd.js";import{L as vr}from"./label-DHm3L_Pw.js";import{S as da}from"./switch-DXZpP3PP.js";import{i as Cn}from"./Play-B45MhCGv.js";import{s as ha}from"./Trash01-Dtv8SktB.js";import{C as D_}from"./checkbox-CV6BjILT.js";import{n as Vi}from"./LinkExternal01-DGR8dD9K.js";import{V as M_}from"./view-mode-toggle-JzxZIaam.js";import{U as P_}from"./user-D-ueNiJ9.js";import{u as Yr,a as L_,b as B_,c as O_,A as $_,d as z_}from"./automation-list-row-DdODiuWb.js";import{S as F_}from"./search-input-D1anatj6.js";import"./use-collections-B56DgGhQ.js";import"./use-organization-settings-Dz4Ob_xk.js";import"./use-copy-yDy37O6x.js";import"./differenceInSeconds-NQ4PDo0z.js";import"./content-blocks-o63cs2vh.js";import"./required-auth-layout-BQkYfP3n.js";import"./use-org-sso-CDZI8wr6.js";import"./ArrowNarrowLeft-kCQ-qIL4.js";import"./ChevronUp-ClIw8oee.js";import"./Palette-hGvX_iIm.js";import"./User01-B6A46HmV.js";import"./formatDistanceToNow-Cb2QZZJn.js";import"./use-registry-connections-C4iSg1no.js";import"./useInfiniteQuery-C63zt5p0.js";import"./infiniteQueryObserver-DgmIeDDw.js";import"./collections-D4PM7cfP.js";import"./index-CTb5Ivgi.js";import"./create-sse-subscription-CxkOgzKf.js";function H_(t,e){const s=Mt(e);return W_({filters:{...t,status:"pending"}},s).length}function jc(t,e){return t.findAll(e.filters).map(s=>e.select?e.select(s):s.state)}function W_(t={},e){const s=Mt(e).getMutationCache(),i=S.useRef(t),n=S.useRef(null);return n.current===null&&(n.current=jc(s,t)),S.useEffect(()=>{i.current=t}),S.useSyncExternalStore(S.useCallback(o=>s.subscribe(()=>{const a=Om(n.current,jc(s,i.current));n.current!==a&&(n.current=a,$m.schedule(o))}),[s]),()=>n.current,()=>n.current)}function U_(t,e){const s=B.c(37),{org:i,locator:n}=be();let o;s[0]!==i.id?(o={connectionId:Wt,orgId:i.id},s[0]=i.id,s[1]=o):o=s[1];const a=Me(o),l=Mt();let c;s[2]!==t||s[3]!==i.id?(c=lt.ensureTask(i.id,t),s[2]=t,s[3]=i.id,s[4]=c):c=s[4];let d;s[5]!==a||s[6]!==t?(d=async()=>(await a.callTool({name:"COLLECTION_THREADS_GET",arguments:{id:t}})).structuredContent?.item??null,s[5]=a,s[6]=t,s[7]=d):d=s[7];let u;s[8]!==c||s[9]!==d?(u={queryKey:c,queryFn:d,retry:!1,refetchOnWindowFocus:!1},s[8]=c,s[9]=d,s[10]=u):u=s[10];const h=Fi(u);let f;s[11]!==a||s[12]!==e?(f=async b=>{const y=await a.callTool({name:"COLLECTION_THREADS_CREATE",arguments:{data:{id:b,virtual_mcp_id:e}}});if(y.isError){const j=y.content,V=Array.isArray(j)&&j[0]&&typeof j[0]=="object"?j[0].text??"Create failed":"Create failed";throw new Error(V)}return y.structuredContent.item},s[11]=a,s[12]=e,s[13]=f):f=s[13];let m;s[14]!==n||s[15]!==i.id||s[16]!==h||s[17]!==l?(m=()=>{l.invalidateQueries({predicate:b=>b.queryKey[1]===i.id&&b.queryKey[3]==="collection"&&b.queryKey[4]==="THREADS"}),l.invalidateQueries({queryKey:lt.tasksPrefix(n)}),h.refetch()},s[14]=n,s[15]=i.id,s[16]=h,s[17]=l,s[18]=m):m=s[18];let p;s[19]!==f||s[20]!==m?(p={mutationFn:f,onSuccess:m},s[19]=f,s[20]=m,s[21]=p):p=s[21];const g=Br(p);let _,v;if(s[22]!==g||s[23]!==t||s[24]!==h.data||s[25]!==h.isSuccess?(_=()=>{!h.isSuccess||h.data||g.isPending||g.variables!==t&&g.mutate(t)},v=[t,h.isSuccess,h.data,g],s[22]=g,s[23]=t,s[24]=h.data,s[25]=h.isSuccess,s[26]=_,s[27]=v):(_=s[26],v=s[27]),S.useEffect(_,v),h.isLoading){let b;return s[28]===Symbol.for("react.memo_cache_sentinel")?(b={status:"loading"},s[28]=b):b=s[28],b}if(h.isError){const b=h.error;let y;return s[29]!==b?(y={status:"error",error:b},s[29]=b,s[30]=y):y=s[30],y}if(h.isSuccess&&h.data){let b;return s[31]!==h.data?(b={status:"ready",task:h.data},s[31]=h.data,s[32]=b):b=s[32],b}if(g.isPending||h.isSuccess&&!h.data){let b;return s[33]===Symbol.for("react.memo_cache_sentinel")?(b={status:"creating"},s[33]=b):b=s[33],b}if(g.isError){let b;return s[34]!==g.error?(b={status:"error",error:g.error},s[34]=g.error,s[35]=b):b=s[35],b}let x;return s[36]===Symbol.for("react.memo_cache_sentinel")?(x={status:"loading"},s[36]=x):x=s[36],x}function K_(t){const e={};for(const s of t.arguments??[])e[s.name]=s.required?Et().min(1,"Required"):Et();return Vs(e)}function q_(t){const e={};for(const s of t.arguments??[])e[s.name]="";return e}function Rl(t){const e=B.c(65),{prompt:s,setPrompt:i,onSubmit:n}=t,o=S.useId();let a;if(e[0]!==s){const D=s?K_(s):Vs({});a=Or(D),e[0]=s,e[1]=a}else a=e[1];const c=a;let d;e[2]!==s?(d=s?q_(s):{},e[2]=s,e[3]=d):d=e[3];let u;e[4]!==c||e[5]!==d?(u={resolver:c,defaultValues:d,mode:"onChange"},e[4]=c,e[5]=d,e[6]=u):u=e[6];const h=Hi(u);let f;e[7]!==s?.arguments?(f=s?.arguments??[],e[7]=s?.arguments,e[8]=f):f=e[8];const m=f;let p;e[9]!==h||e[10]!==n||e[11]!==i?(p=async D=>{await n(D),i(null),h.reset()},e[9]=h,e[10]=n,e[11]=i,e[12]=p):p=e[12];const g=p;let _;e[13]!==h||e[14]!==i?(_=D=>{D||(h.reset(),i(null))},e[13]=h,e[14]=i,e[15]=_):_=e[15];const v=_;if(!s)return null;let x;e[16]!==s._meta||e[17]!==s.name||e[18]!==s.title?(x=s.title||eo(s.name,si(s._meta)),e[16]=s._meta,e[17]=s.name,e[18]=s.title,e[19]=x):x=e[19];let b;e[20]!==x?(b=r.jsx(Ts,{children:r.jsx("span",{className:"capitalize",children:x})}),e[20]=x,e[21]=b):b=e[21];let y;e[22]!==s.description?(y=s.description&&r.jsx("p",{className:"text-sm text-muted-foreground",children:s.description}),e[22]=s.description,e[23]=y):y=e[23];let C;e[24]!==y||e[25]!==b?(C=r.jsxs(Ds,{children:[b,y]}),e[24]=y,e[25]=b,e[26]=C):C=e[26];let j;e[27]!==h||e[28]!==g?(j=D=>{D.stopPropagation(),h.handleSubmit(g)(D)},e[27]=h,e[28]=g,e[29]=j):j=e[29];let V;if(e[30]!==m||e[31]!==h.control||e[32]!==h.formState.isSubmitting){let D;e[34]!==h.control||e[35]!==h.formState.isSubmitting?(D=P=>r.jsx(It,{control:h.control,name:P.name,render:O=>{const{field:z}=O;return r.jsxs(Rt,{children:[r.jsxs(rs,{className:"text-xs",children:[P.name,P.required?null:r.jsxs("span",{className:"text-muted-foreground font-normal",children:[" ","(optional)"]})]}),r.jsx(Tt,{children:r.jsx(bt,{...z,value:z.value??"",required:P.required,placeholder:P.description??"",className:"h-9",disabled:h.formState.isSubmitting})}),r.jsx(Dt,{})]})}},P.name),e[34]=h.control,e[35]=h.formState.isSubmitting,e[36]=D):D=e[36],V=m.map(D),e[30]=m,e[31]=h.control,e[32]=h.formState.isSubmitting,e[33]=V}else V=e[33];let w;e[37]!==v?(w=()=>v(!1),e[37]=v,e[38]=w):w=e[38];let k;e[39]!==h.formState.isSubmitting||e[40]!==w?(k=r.jsx(ne,{type:"button",variant:"ghost",onClick:w,disabled:h.formState.isSubmitting,children:"Cancel"}),e[39]=h.formState.isSubmitting,e[40]=w,e[41]=k):k=e[41];const T=!h.formState.isValid||h.formState.isSubmitting;let I;e[42]!==h.formState.isSubmitting?(I=h.formState.isSubmitting?r.jsxs("span",{className:"flex items-center gap-2",children:[r.jsx(jr,{size:"xs"}),"Loading..."]}):"Use prompt",e[42]=h.formState.isSubmitting,e[43]=I):I=e[43];let A;e[44]!==o||e[45]!==T||e[46]!==I?(A=r.jsx(ne,{type:"submit",form:o,disabled:T,children:I}),e[44]=o,e[45]=T,e[46]=I,e[47]=A):A=e[47];let N;e[48]!==k||e[49]!==A?(N=r.jsxs(cl,{children:[k,A]}),e[48]=k,e[49]=A,e[50]=N):N=e[50];let E;e[51]!==o||e[52]!==j||e[53]!==V||e[54]!==N?(E=r.jsxs("form",{id:o,className:"space-y-4 py-4",autoComplete:"off",onSubmit:j,children:[V,N]}),e[51]=o,e[52]=j,e[53]=V,e[54]=N,e[55]=E):E=e[55];let R;e[56]!==h||e[57]!==E?(R=r.jsx(Pi,{...h,children:E}),e[56]=h,e[57]=E,e[58]=R):R=e[58];let M;e[59]!==C||e[60]!==R?(M=r.jsxs(ms,{className:"sm:max-w-lg max-h-[80vh] overflow-y-auto",children:[C,R]}),e[59]=C,e[60]=R,e[61]=M):M=e[61];let L;return e[62]!==v||e[63]!==M?(L=r.jsx(ps,{open:!0,onOpenChange:v,children:M}),e[62]=v,e[63]=M,e[64]=L):L=e[64],L}function G_(t){return!t||!t.content||t.content.length===0?!0:t.content.every(e=>e.type==="paragraph"?!e.content||e.content.length===0?!0:e.content.every(s=>s.type==="hardBreak"||s.type==="text"&&(!s.text||s.text.trim()==="")):!1)}function Y_(t,e){return{type:"doc",content:[...t?.content??[],e].filter(Boolean)}}const kc=3,Vu="inline-flex items-center gap-2 px-5 py-2.5 rounded-full bg-muted text-muted-foreground text-sm font-medium transition-colors cursor-pointer",X_="flex flex-col gap-1.5 p-4 rounded-xl bg-accent/40 text-sm leading-snug transition-colors cursor-pointer text-left";function Cu(t){const e=B.c(46),{item:s,onSelect:i,isLoading:n,isDisabled:o,variant:a}=t,l=a===void 0?"pill":a,{prompt:c}=s;let d;if(e[0]!==c._meta||e[1]!==c.name||e[2]!==c.title){const V=si(c._meta);d=c.title??eo(c.name,V),e[0]=c._meta,e[1]=c.name,e[2]=c.title,e[3]=d}else d=e[3];const u=d,h=c.description||null;if(l==="card"){let V;e[4]!==i||e[5]!==c?(V=()=>i(c),e[4]=i,e[5]=c,e[6]=V):V=e[6];const w=o||n,k=n&&"bg-accent/40",T=(o||n)&&"cursor-not-allowed opacity-50";let I;e[7]!==k||e[8]!==T?(I=X(X_,"hover:bg-accent/60 text-foreground",k,T),e[7]=k,e[8]=T,e[9]=I):I=e[9];let A;e[10]!==u?(A=r.jsx("span",{className:"font-medium truncate capitalize",children:u}),e[10]=u,e[11]=A):A=e[11];let N;e[12]!==n?(N=n&&r.jsx(jr,{size:"xs"}),e[12]=n,e[13]=N):N=e[13];let E;e[14]!==A||e[15]!==N?(E=r.jsxs("div",{className:"flex items-center justify-between gap-2",children:[A,N]}),e[14]=A,e[15]=N,e[16]=E):E=e[16];let R;e[17]!==h?(R=h&&r.jsx("span",{className:"text-xs text-muted-foreground line-clamp-2",children:h}),e[17]=h,e[18]=R):R=e[18];let M;return e[19]!==E||e[20]!==R||e[21]!==V||e[22]!==w||e[23]!==I?(M=r.jsxs("button",{type:"button",onClick:V,disabled:w,className:I,children:[E,R]}),e[19]=E,e[20]=R,e[21]=V,e[22]=w,e[23]=I,e[24]=M):M=e[24],M}let f;e[25]!==i||e[26]!==c?(f=()=>i(c),e[25]=i,e[26]=c,e[27]=f):f=e[27];const m=o||n,p=n&&"bg-muted/50",g=(o||n)&&"cursor-not-allowed opacity-50";let _;e[28]!==p||e[29]!==g?(_=X(Vu,"hover:bg-muted/70 hover:text-foreground",p,g),e[28]=p,e[29]=g,e[30]=_):_=e[30];let v;e[31]!==u?(v=r.jsx("span",{className:"capitalize",children:u}),e[31]=u,e[32]=v):v=e[32];let x;e[33]!==n?(x=n&&r.jsx(jr,{size:"xs"}),e[33]=n,e[34]=x):x=e[34];let b;e[35]!==f||e[36]!==m||e[37]!==_||e[38]!==v||e[39]!==x?(b=r.jsx(tt,{asChild:!0,children:r.jsxs("button",{type:"button",onClick:f,disabled:m,className:_,children:[v,x]})}),e[35]=f,e[36]=m,e[37]=_,e[38]=v,e[39]=x,e[40]=b):b=e[40];const y=h??u;let C;e[41]!==y?(C=r.jsx(st,{side:"top",className:"max-w-xs",children:r.jsx("p",{className:"text-xs",children:y})}),e[41]=y,e[42]=C):C=e[42];let j;return e[43]!==b||e[44]!==C?(j=r.jsxs(it,{delayDuration:400,children:[b,C]}),e[43]=b,e[44]=C,e[45]=j):j=e[45],j}function J_(t){const e=B.c(41),{items:s,open:i,onOpenChange:n,onSelect:o,loadingPrompt:a}=t,[l,c]=S.useState(""),d=!!a;let u;e[0]!==s||e[1]!==l?(u=l.trim()?s.filter(w=>{const k=l.toLowerCase();return w.prompt.name.toLowerCase().includes(k)||(w.prompt.title??"").toLowerCase().includes(k)||(w.prompt.description??"").toLowerCase().includes(k)}):s,e[0]=s,e[1]=l,e[2]=u):u=e[2];const h=u,f=Rs();let m;e[3]!==h.length||e[4]!==l?(m=h.length===0&&r.jsxs("p",{className:"col-span-4 text-sm text-muted-foreground text-center py-8",children:["No prompts match “",l,"”"]}),e[3]=h.length,e[4]=l,e[5]=m):m=e[5];let p;if(e[6]!==h||e[7]!==d||e[8]!==a?.name||e[9]!==n||e[10]!==o){let w;e[12]!==d||e[13]!==a?.name||e[14]!==n||e[15]!==o?(w=k=>r.jsx(Cu,{item:k,variant:"card",onSelect:T=>{n(!1),o(T)},isLoading:a?.name===k.prompt.name,isDisabled:d&&a?.name!==k.prompt.name},k.prompt.name),e[12]=d,e[13]=a?.name,e[14]=n,e[15]=o,e[16]=w):w=e[16],p=h.map(w),e[6]=h,e[7]=d,e[8]=a?.name,e[9]=n,e[10]=o,e[11]=p}else p=e[11];let g;e[17]!==m||e[18]!==p?(g=r.jsx("div",{className:"flex-1 overflow-y-auto [scrollbar-gutter:stable]",children:r.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-4 gap-3 p-5",children:[m,p]})}),e[17]=m,e[18]=p,e[19]=g):g=e[19];const _=g;let v;e[20]===Symbol.for("react.memo_cache_sentinel")?(v=w=>{w.key==="Escape"&&c("")},e[20]=v):v=e[20];let x;e[21]!==l?(x=r.jsx(Th,{value:l,onChange:c,placeholder:"Search prompts...",onKeyDown:v}),e[21]=l,e[22]=x):x=e[22];const b=x;if(f){let w;e[23]===Symbol.for("react.memo_cache_sentinel")?(w=r.jsx(so,{className:"sr-only",children:r.jsx(bi,{children:"All prompts"})}),e[23]=w):w=e[23];let k;e[24]===Symbol.for("react.memo_cache_sentinel")?(k=r.jsx("div",{className:"flex items-center h-12 border-b border-border px-4 shrink-0",children:r.jsx("span",{className:"text-sm font-medium text-foreground",children:"Prompts"})}),e[24]=k):k=e[24];let T;e[25]!==_||e[26]!==b?(T=r.jsxs(yi,{className:"h-[85vh] flex flex-col p-0 gap-0",children:[w,k,b,_]}),e[25]=_,e[26]=b,e[27]=T):T=e[27];let I;return e[28]!==n||e[29]!==i||e[30]!==T?(I=r.jsx(Mi,{delayDuration:400,children:r.jsx(Si,{open:i,onOpenChange:n,children:T})}),e[28]=n,e[29]=i,e[30]=T,e[31]=I):I=e[31],I}let y;e[32]===Symbol.for("react.memo_cache_sentinel")?(y=r.jsx(Ds,{className:"sr-only",children:r.jsx(Ts,{children:"All prompts"})}),e[32]=y):y=e[32];let C;e[33]===Symbol.for("react.memo_cache_sentinel")?(C=r.jsx("div",{className:"flex items-center h-12 border-b border-border px-4 shrink-0",children:r.jsx("span",{className:"text-sm font-medium text-foreground",children:"Prompts"})}),e[33]=C):C=e[33];let j;e[34]!==_||e[35]!==b?(j=r.jsxs(ms,{className:"sm:max-w-[1100px] h-[680px] p-0 gap-0 overflow-hidden flex flex-col",children:[y,C,b,_]}),e[34]=_,e[35]=b,e[36]=j):j=e[36];let V;return e[37]!==n||e[38]!==i||e[39]!==j?(V=r.jsx(Mi,{delayDuration:400,children:r.jsx(ps,{open:i,onOpenChange:n,children:j})}),e[37]=n,e[38]=i,e[39]=j,e[40]=V):V=e[40],V}function Q_(t){const e=B.c(29),{items:s,onSelect:i,loadingPrompt:n,className:o}=t,[a,l]=S.useState(!1);if(s.length===0)return null;let c,d,u;if(e[0]!==s||e[1]!==n||e[2]!==i){const v=s.slice(0,kc);let x;e[6]!==s?(x=s.slice(kc),e[6]=s,e[7]=x):x=e[7],c=x,d=!!n;let b;e[8]!==d||e[9]!==n?.name||e[10]!==i?(b=y=>r.jsx(Cu,{item:y,onSelect:i,isLoading:n?.name===y.prompt.name,isDisabled:d&&n?.name!==y.prompt.name},y.prompt.name),e[8]=d,e[9]=n?.name,e[10]=i,e[11]=b):b=e[11],u=v.map(b),e[0]=s,e[1]=n,e[2]=i,e[3]=c,e[4]=d,e[5]=u}else c=e[3],d=e[4],u=e[5];const h=u;let f;e[12]!==o?(f=X("w-full flex flex-wrap gap-2 justify-center",o),e[12]=o,e[13]=f):f=e[13];let m;e[14]!==c.length||e[15]!==d?(m=c.length>0&&r.jsxs("button",{type:"button",disabled:d,onClick:()=>l(!0),className:X(Vu,"hover:bg-muted/70 hover:text-foreground",d&&"opacity-50 cursor-not-allowed"),children:["+",c.length," more"]}),e[14]=c.length,e[15]=d,e[16]=m):m=e[16];let p;e[17]!==h||e[18]!==f||e[19]!==m?(p=r.jsxs("div",{className:f,children:[h,m]}),e[17]=h,e[18]=f,e[19]=m,e[20]=p):p=e[20];let g;e[21]!==s||e[22]!==n||e[23]!==a||e[24]!==i?(g=r.jsx(J_,{items:s,open:a,onOpenChange:l,onSelect:i,loadingPrompt:n}),e[21]=s,e[22]=n,e[23]=a,e[24]=i,e[25]=g):g=e[25];let _;return e[26]!==p||e[27]!==g?(_=r.jsxs(Mi,{delayDuration:400,children:[p,g]}),e[26]=p,e[27]=g,e[28]=_):_=e[28],_}function Z_(){return null}function ex(t,e){switch(e.type){case"SELECT_PROMPT":return!e.prompt.arguments||e.prompt.arguments.length===0?{stage:"loading",prompt:e.prompt}:{stage:"idle"};case"START_LOADING":return{stage:"loading",prompt:e.prompt,arguments:e.arguments};case"RESET":return{stage:"idle"};default:return t}}function tx(t){const e=B.c(30),{connectionId:s}=t,{sendMessage:i}=Ui(),{tiptapDocRef:n}=ni(),{org:o}=be();let a;e[0]!==s||e[1]!==o.id?(a={connectionId:s,orgId:o.id},e[0]=s,e[1]=o.id,e[2]=a):a=e[2];const l=Me(a);let c;e[3]!==l?(c={client:l,staleTime:6e4},e[3]=l,e[4]=c):c=e[4];const{data:d}=Dh(c);let u;e[5]!==d?.prompts?(u=d?.prompts??[],e[5]=d?.prompts,e[6]=u):u=e[6];const h=u;let f;e[7]!==h?(f=h.map(sx),e[7]=h,e[8]=f):f=e[8];const m=f;let p;e[9]===Symbol.for("react.memo_cache_sentinel")?(p={stage:"idle"},e[9]=p):p=e[9];const[g,_]=S.useReducer(ex,p),[v,x]=S.useState(null);let b;e[10]!==l||e[11]!==i||e[12]!==n?(b=async(E,R)=>{if(!l){pe.error("MCP client not available"),_({type:"RESET"});return}try{const M=await ul(l,E.name,R);_({type:"RESET"});const L=Y_(n.current,{type:"paragraph",content:[Rp({id:E.name,name:al(E.name,si(E._meta)),metadata:M.messages,char:"/"})]});await i(L)}catch(M){console.error("[ice-breakers] Failed to fetch prompt:",M),pe.error("Failed to load prompt. Please try again."),_({type:"RESET"})}},e[10]=l,e[11]=i,e[12]=n,e[13]=b):b=e[13];const y=b;let C;e[14]!==y?(C=async E=>{if(E.arguments&&E.arguments.length>0){_({type:"SELECT_PROMPT",prompt:E}),x(E);return}_({type:"START_LOADING",prompt:E}),await y(E)},e[14]=y,e[15]=C):C=e[15];const j=C;let V;e[16]!==v||e[17]!==y?(V=async E=>{v&&(_({type:"START_LOADING",prompt:v,arguments:E}),x(null),await y(v,E))},e[16]=v,e[17]=y,e[18]=V):V=e[18];const w=V;if(m.length===0)return null;const k=g.stage==="loading"?g.prompt:null;let T;e[19]!==j||e[20]!==m||e[21]!==k?(T=r.jsx(Q_,{items:m,onSelect:j,loadingPrompt:k}),e[19]=j,e[20]=m,e[21]=k,e[22]=T):T=e[22];let I;e[23]===Symbol.for("react.memo_cache_sentinel")?(I=()=>{x(null),_({type:"RESET"})},e[23]=I):I=e[23];let A;e[24]!==v||e[25]!==w?(A=r.jsx(Rl,{prompt:v,setPrompt:I,onSubmit:w}),e[24]=v,e[25]=w,e[26]=A):A=e[26];let N;return e[27]!==T||e[28]!==A?(N=r.jsxs(r.Fragment,{children:[T,A]}),e[27]=T,e[28]=A,e[29]=N):N=e[29],N}function sx(t){return{prompt:t}}function ix(t){const e=B.c(13),{className:s}=t,{selectedVirtualMcp:i}=ni(),{org:n}=be();let o;e[0]!==n.id?(o=io(n.id),e[0]=n.id,e[1]=o):o=e[1];const a=o.id,l=i?.id??a;let c;e[2]!==s?(c=X("w-full @container",s),e[2]=s,e[3]=c):c=e[3];const d=l??"default";let u;e[4]===Symbol.for("react.memo_cache_sentinel")?(u=r.jsx(Z_,{}),e[4]=u):u=e[4];let h;e[5]!==l?(h=r.jsx(tx,{connectionId:l}),e[5]=l,e[6]=h):h=e[6];let f;e[7]!==d||e[8]!==h?(f=r.jsx(Cs,{fallback:null,children:r.jsx(S.Suspense,{fallback:u,children:h},d)}),e[7]=d,e[8]=h,e[9]=f):f=e[9];let m;return e[10]!==c||e[11]!==f?(m=r.jsx("div",{className:c,children:f}),e[10]=c,e[11]=f,e[12]=m):m=e[12],m}function ju(t){const e=B.c(21),{current:s,total:i,onPrev:n,onNext:o}=t;if(i<=1)return null;const a=s===0,l=s===0?"opacity-30 cursor-not-allowed":"hover:text-foreground cursor-pointer";let c;e[0]!==l?(c=X("p-0.5 rounded transition-colors",l),e[0]=l,e[1]=c):c=e[1];let d;e[2]===Symbol.for("react.memo_cache_sentinel")?(d=r.jsx(xl,{size:14}),e[2]=d):d=e[2];let u;e[3]!==n||e[4]!==a||e[5]!==c?(u=r.jsx("button",{type:"button",onClick:n,disabled:a,className:c,"aria-label":"Previous question",children:d}),e[3]=n,e[4]=a,e[5]=c,e[6]=u):u=e[6];const h=s+1;let f;e[7]!==h||e[8]!==i?(f=r.jsxs("span",{className:"tabular-nums text-xs",children:[h," of ",i]}),e[7]=h,e[8]=i,e[9]=f):f=e[9];const m=s===i-1,p=s===i-1?"opacity-30 cursor-not-allowed":"hover:text-foreground cursor-pointer";let g;e[10]!==p?(g=X("p-0.5 rounded transition-colors",p),e[10]=p,e[11]=g):g=e[11];let _;e[12]===Symbol.for("react.memo_cache_sentinel")?(_=r.jsx(ro,{size:14}),e[12]=_):_=e[12];let v;e[13]!==o||e[14]!==g||e[15]!==m?(v=r.jsx("button",{type:"button",onClick:o,disabled:m,className:g,"aria-label":"Next question",children:_}),e[13]=o,e[14]=g,e[15]=m,e[16]=v):v=e[16];let x;return e[17]!==v||e[18]!==u||e[19]!==f?(x=r.jsxs("div",{className:"flex items-center gap-1 text-sm text-muted-foreground",children:[u,f,v]}),e[17]=v,e[18]=u,e[19]=f,e[20]=x):x=e[20],x}function On(t){const e=B.c(18),{title:s,children:i,footerLeft:n,footerRight:o,className:a}=t,l=a??"border-border";let c;e[0]!==l?(c=X("flex flex-col rounded-xl bg-background border shadow-md w-[calc(100%-16px)] max-w-[584px] mx-auto mb-[-16px]",l),e[0]=l,e[1]=c):c=e[1];let d;e[2]!==s?(d=r.jsx("div",{className:"flex items-center gap-2 p-4",children:r.jsx("p",{className:"flex-1 text-base font-medium text-foreground min-w-0",children:s})}),e[2]=s,e[3]=d):d=e[3];let u;e[4]!==i?(u=r.jsx("div",{className:"overflow-clip pb-4",children:i}),e[4]=i,e[5]=u):u=e[5];let h;e[6]!==n?(h=r.jsx("div",{children:n}),e[6]=n,e[7]=h):h=e[7];let f;e[8]!==o?(f=r.jsx("div",{className:"flex items-center gap-2",children:o}),e[8]=o,e[9]=f):f=e[9];let m;e[10]!==h||e[11]!==f?(m=r.jsx("div",{className:"border-t border-border px-3 py-3 pb-6",children:r.jsxs("div",{className:"flex items-center justify-between",children:[h,f]})}),e[10]=h,e[11]=f,e[12]=m):m=e[12];let p;return e[13]!==c||e[14]!==d||e[15]!==u||e[16]!==m?(p=r.jsxs("div",{className:c,children:[d,u,m]}),e[13]=c,e[14]=d,e[15]=u,e[16]=m,e[17]=p):p=e[17],p}const rx="User denied this tool call, give other alternatives.",nx=[{value:"readonly",label:"Ask before edit"},{value:"auto",label:"Auto approve"}];function ox(t){const e=B.c(9),{onYolo:s}=t,[i,n]=Wi();let o;e[0]!==s||e[1]!==i||e[2]!==n?(o=u=>{const h=u;n({...i,toolApprovalLevel:h}),h==="auto"&&s()},e[0]=s,e[1]=i,e[2]=n,e[3]=o):o=e[3];const a=o;let l;e[4]===Symbol.for("react.memo_cache_sentinel")?(l=r.jsx(Zs,{size:"xs",className:"text-xs text-muted-foreground border-border/60 bg-transparent hover:bg-accent/60 h-7 gap-1",onClick:lx,children:r.jsx(ei,{})}),e[4]=l):l=e[4];let c;e[5]===Symbol.for("react.memo_cache_sentinel")?(c=r.jsx(Js,{children:nx.map(ax)}),e[5]=c):c=e[5];let d;return e[6]!==a||e[7]!==i.toolApprovalLevel?(d=r.jsxs(Qs,{value:i.toolApprovalLevel,onValueChange:a,children:[l,c]}),e[6]=a,e[7]=i.toolApprovalLevel,e[8]=d):d=e[8],d}function ax(t){return r.jsx(Ht,{value:t.value,children:t.label},t.value)}function lx(t){return t.stopPropagation()}function cx(t){const e=B.c(5),{input:s}=t;if(s==null){let o;return e[0]===Symbol.for("react.memo_cache_sentinel")?(o=r.jsx("div",{className:"px-4 text-xs text-muted-foreground",children:"No input"}),e[0]=o):o=e[0],o}let i;try{let o;e[1]!==s?(o=JSON.stringify(s,null,2),e[1]=s,e[2]=o):o=e[2],i=o}catch{i=String(s)}let n;return e[3]!==i?(n=r.jsx("div",{className:"px-4",children:r.jsx("pre",{className:"text-xs font-mono text-muted-foreground/70 whitespace-pre-wrap wrap-break-word max-h-32 overflow-y-auto rounded-md bg-muted/30 px-3 py-2",children:i})}),e[3]=i,e[4]=n):n=e[4],n}function dx(t){const e=B.c(42),{approvals:s,onRespond:i}=t,[n,o]=S.useState(0),a=Math.min(n,s.length-1),l=s[a];if(!l)return null;let c;e[0]!==l.approvalId||e[1]!==i?(c=()=>{i(l.approvalId,!1,rx)},e[0]=l.approvalId,e[1]=i,e[2]=c):c=e[2];const d=c;let u;e[3]!==l.approvalId||e[4]!==i?(u=()=>{i(l.approvalId,!0)},e[3]=l.approvalId,e[4]=i,e[5]=u):u=e[5];const h=u;let f;e[6]!==s||e[7]!==i?(f=()=>{for(const N of s)i(N.approvalId,!0)},e[6]=s,e[7]=i,e[8]=f):f=e[8];const m=f;let p;e[9]!==a?(p=()=>{a>0&&o(a-1)},e[9]=a,e[10]=p):p=e[10];const g=p;let _;e[11]!==s.length||e[12]!==a?(_=()=>{a<s.length-1&&o(a+1)},e[11]=s.length,e[12]=a,e[13]=_):_=e[13];const v=_;let x;e[14]!==m?(x=r.jsx(ox,{onYolo:m}),e[14]=m,e[15]=x):x=e[15];let b;e[16]!==s.length||e[17]!==v||e[18]!==g||e[19]!==a?(b=r.jsx(ju,{current:a,total:s.length,onPrev:g,onNext:v}),e[16]=s.length,e[17]=v,e[18]=g,e[19]=a,e[20]=b):b=e[20];let y;e[21]!==x||e[22]!==b?(y=r.jsxs("div",{className:"flex items-center gap-2",children:[x,b]}),e[21]=x,e[22]=b,e[23]=y):y=e[23];const C=y;let j;e[24]!==d?(j=r.jsx(ne,{type:"button",variant:"ghost",size:"sm",className:"h-7 px-2.5 text-xs text-muted-foreground [@media(hover:hover)]:hover:text-foreground active:scale-[0.97] transition-transform",onClick:d,children:"Deny"}),e[24]=d,e[25]=j):j=e[25];let V;e[26]!==s.length||e[27]!==m?(V=s.length>1&&r.jsx(ne,{type:"button",variant:"outline",size:"sm",className:"h-7 px-2.5 text-xs active:scale-[0.97] transition-transform",onClick:m,children:"Accept All"}),e[26]=s.length,e[27]=m,e[28]=V):V=e[28];let w;e[29]!==h?(w=r.jsx(ne,{type:"button",size:"sm",className:"h-7 px-2.5 text-xs active:scale-[0.97] transition-transform",onClick:h,children:"Accept"}),e[29]=h,e[30]=w):w=e[30];let k;e[31]!==V||e[32]!==w||e[33]!==j?(k=r.jsxs(r.Fragment,{children:[j,V,w]}),e[31]=V,e[32]=w,e[33]=j,e[34]=k):k=e[34];const T=k;let I;e[35]!==l.input?(I=r.jsx(cx,{input:l.input}),e[35]=l.input,e[36]=I):I=e[36];let A;return e[37]!==l.friendlyName||e[38]!==C||e[39]!==T||e[40]!==I?(A=r.jsx(On,{title:l.friendlyName,footerLeft:C,footerRight:T,children:I}),e[37]=l.friendlyName,e[38]=C,e[39]=T,e[40]=I,e[41]=A):A=e[41],A}function hx(){const t=B.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=r.jsxs("div",{className:"flex items-center gap-2 p-4 border border-dashed rounded-lg bg-accent/50 w-[calc(100%-16px)] max-w-[584px] mx-auto mb-2",children:[r.jsx(ug,{className:"size-5 text-muted-foreground shimmer"}),r.jsx("span",{className:"text-sm text-muted-foreground shimmer",children:"Preparing approval request..."})]}),t[0]=e):e=t[0],e}function ux(t){const e=B.c(4),{approvals:s,isStreaming:i,onRespond:n}=t;if(i&&s.length===0){let a;return e[0]===Symbol.for("react.memo_cache_sentinel")?(a=r.jsx(hx,{}),e[0]=a):a=e[0],a}if(s.length===0)return null;let o;return e[1]!==s||e[2]!==n?(o=r.jsx(dx,{approvals:s,onRespond:n}),e[1]=s,e[2]=n,e[3]=o):o=e[3],o}function fx(t){const e=[];for(const s of t)if("state"in s&&s.state==="approval-requested"&&"approval"in s&&s.approval?.id&&"toolCallId"in s&&s.toolCallId){const i="toolName"in s&&typeof s.toolName=="string"?s.toolName:s.type.startsWith("tool-")?s.type.replace("tool-",""):"Tool";e.push({approvalId:s.approval.id,toolCallId:s.toolCallId,toolName:i,friendlyName:Tp(Dp(i)),input:s.input})}return e}function mx(t){const e=B.c(15),{plan:s,onApprove:i,onDismiss:n}=t;let o;e[0]!==i||e[1]!==s.plan?(o=()=>{i(s.plan)},e[0]=i,e[1]=s.plan,e[2]=o):o=e[2];const a=o;let l;e[3]!==n?(l=r.jsx(ne,{type:"button",variant:"ghost",size:"sm",className:"h-7 px-2.5 text-xs text-muted-foreground [@media(hover:hover)]:hover:text-foreground active:scale-[0.97] transition-transform",onClick:n,children:"Keep iterating"}),e[3]=n,e[4]=l):l=e[4];let c;e[5]!==a?(c=r.jsx(ne,{type:"button",size:"sm",className:"h-7 px-2.5 text-xs bg-purple-600 hover:bg-purple-700 text-white active:scale-[0.97] transition-transform",onClick:a,children:"Let's go"}),e[5]=a,e[6]=c):c=e[6];let d;e[7]!==l||e[8]!==c?(d=r.jsxs(r.Fragment,{children:[l,c]}),e[7]=l,e[8]=c,e[9]=d):d=e[9];const u=d;let h;e[10]!==s.plan?(h=r.jsx("div",{className:"px-4 max-h-64 overflow-y-auto",children:r.jsx("div",{className:"prose prose-sm max-w-none text-sm",children:r.jsx(Mp,{id:"plan-preview",part:{type:"text",text:s.plan}})})}),e[10]=s.plan,e[11]=h):h=e[11];let f;return e[12]!==u||e[13]!==h?(f=r.jsx(On,{title:"Implementation Plan",footerRight:u,className:"border-dashed border-purple-500",children:h}),e[12]=u,e[13]=h,e[14]=f):f=e[14],f}function px(){const t=B.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=r.jsxs("div",{className:"flex items-center gap-2 p-4 border border-dashed border-purple-500/30 rounded-lg bg-purple-500/5 w-[calc(100%-16px)] max-w-[584px] mx-auto mb-2",children:[r.jsx(Jt,{className:"size-5 text-purple-500 shimmer"}),r.jsx("span",{className:"text-sm text-muted-foreground shimmer",children:"Preparing plan..."})]}),t[0]=e):e=t[0],e}function gx(t){const e=B.c(7),{plans:s,isStreaming:i,onApprove:n,onDismiss:o}=t;if(i&&s.length===0){let d;return e[0]===Symbol.for("react.memo_cache_sentinel")?(d=r.jsx(px,{}),e[0]=d):d=e[0],d}let a;e[1]!==s?(a=s.at(-1),e[1]=s,e[2]=a):a=e[2];const l=a;if(!l)return null;let c;return e[3]!==l||e[4]!==n||e[5]!==o?(c=r.jsx(mx,{plan:l,onApprove:n,onDismiss:o}),e[3]=l,e[4]=n,e[5]=o,e[6]=c):c=e[6],c}function _x(t){const e=[];for(const s of t)if("type"in s&&s.type==="tool-propose_plan"&&"state"in s&&s.state==="input-available"&&"toolCallId"in s&&"input"in s){const i=s.input;e.push({toolCallId:s.toolCallId,plan:i.plan,state:s.state})}return e}const Nc=Vs({response:Et().min(1,"Response is required")}),xx=Vs({response:Et().min(1,"Please select or enter an option")}),vx=Vs({response:zm(["yes","no"])});function bx(t){switch(t.type){case"text":return Nc;case"choice":return xx;case"confirm":return vx;default:return Nc}}function yx(t){const e={};for(const s of t)e[s.toolCallId]=bx(s.input);return Vs(e)}function Sx(t){const e=B.c(6),{control:s,name:i,placeholder:n}=t;let o;e[0]!==n?(o=l=>{const{field:c}=l;return r.jsxs(Rt,{children:[r.jsx(Tt,{children:r.jsx("div",{className:"px-2",children:r.jsxs("div",{className:"flex items-center gap-3 px-2 py-3 rounded-lg bg-accent/50",children:[r.jsx("span",{className:"flex items-center justify-center size-6 rounded-md bg-muted shrink-0",children:r.jsx($h,{size:16,className:"text-muted-foreground"})}),r.jsx("input",{...c,type:"text",placeholder:n||"Type your response...",autoFocus:!0,"aria-label":"Text response input",className:"flex-1 text-sm bg-transparent outline-none placeholder:text-foreground/25 text-foreground min-w-0"})]})})}),r.jsx(Dt,{})]})},e[0]=n,e[1]=o):o=e[1];let a;return e[2]!==s||e[3]!==i||e[4]!==o?(a=r.jsx(It,{control:s,name:i,render:o}),e[2]=s,e[3]=i,e[4]=o,e[5]=a):a=e[5],a}function ku(t,e){const s=B.c(4);let i,n;s[0]!==t||s[1]!==e?(i=()=>{const o=a=>{const l=a.target.tagName;if(l==="INPUT"||l==="TEXTAREA"||a.metaKey||a.ctrlKey||a.altKey)return;const c=Number.parseInt(a.key,10);c>=1&&c<=t&&(a.preventDefault(),e(c-1))};return document.addEventListener("keydown",o),()=>document.removeEventListener("keydown",o)},n=[t,e],s[0]=t,s[1]=e,s[2]=i,s[3]=n):(i=s[2],n=s[3]),S.useEffect(i,n)}function wx(t){const e=B.c(9),{control:s,name:i,options:n}=t,[o,a]=S.useState(!1),l=S.useRef(null),c=S.useRef(null);let d;if(e[0]!==n?(d=f=>{c.current?.onChange(n[f]??""),a(!1)},e[0]=n,e[1]=d):d=e[1],ku(n.length,d),n.length===0)return null;let u;e[2]!==o||e[3]!==n?(u=f=>{const{field:m}=f;c.current=m;const p=o||!!m.value&&!n.includes(m.value);return r.jsxs(Rt,{children:[r.jsx(Tt,{children:r.jsxs("div",{className:"flex flex-col px-2",role:"group","aria-label":"Choice options",children:[n.map((g,_)=>{const v=m.value===g;return r.jsxs("button",{type:"button",onClick:()=>{m.onChange(g??""),a(!1)},className:X("flex items-center gap-3 px-2 py-3 rounded-lg text-left transition-colors w-full",v&&"bg-accent/50",!v&&"hover:bg-accent/30"),"aria-label":`Select ${g}`,children:[r.jsx("span",{className:X("flex items-center justify-center size-6 rounded-md text-sm shrink-0",v?"bg-chart-1 text-white":"bg-muted text-foreground"),children:_+1}),r.jsx("span",{className:"text-sm text-foreground truncate",children:g})]},`${_}-${g}`)}),r.jsxs("div",{className:X("flex items-center gap-3 px-2 py-3 rounded-lg transition-colors w-full cursor-text",p&&"bg-accent/50",!p&&"hover:bg-accent/30"),onClick:()=>{a(!0),n.includes(m.value)&&m.onChange(""),setTimeout(()=>l.current?.focus(),0)},children:[r.jsx("span",{className:"flex items-center justify-center size-6 rounded-md bg-muted shrink-0",children:r.jsx($h,{size:16,className:"text-muted-foreground"})}),p?r.jsx("input",{ref:l,type:"text",value:m.value,onChange:g=>m.onChange(g.target.value),placeholder:"Something else...",autoFocus:!0,"aria-label":"Custom choice input",className:"flex-1 text-sm bg-transparent outline-none placeholder:text-foreground/25 text-foreground min-w-0"}):r.jsx("span",{className:"text-sm text-foreground/25",children:"Something else..."})]})]})}),r.jsx(Dt,{})]})},e[2]=o,e[3]=n,e[4]=u):u=e[4];let h;return e[5]!==s||e[6]!==i||e[7]!==u?(h=r.jsx(It,{control:s,name:i,render:u}),e[5]=s,e[6]=i,e[7]=u,e[8]=h):h=e[8],h}function Vx(t){const e=B.c(6),{control:s,name:i}=t;let n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=["yes","no"],e[0]=n):n=e[0];const o=n,a=S.useRef(null);let l;e[1]===Symbol.for("react.memo_cache_sentinel")?(l=u=>{a.current?.onChange(o[u]??"")},e[1]=l):l=e[1],ku(o.length,l);let c;e[2]===Symbol.for("react.memo_cache_sentinel")?(c=u=>{const{field:h}=u;return a.current=h,r.jsxs(Rt,{children:[r.jsx(Tt,{children:r.jsx("div",{className:"flex gap-2 px-2",role:"group","aria-label":"Confirmation options",children:o.map(f=>{const m=h.value===f;return r.jsxs("button",{type:"button",onClick:()=>h.onChange(f),className:X("flex items-center gap-3 px-4 py-3 rounded-lg text-left transition-colors flex-1",m&&"bg-accent/50",!m&&"hover:bg-accent/30"),"aria-label":`Confirm ${f}`,children:[r.jsx("span",{className:X("flex items-center justify-center size-6 rounded-md text-sm shrink-0",m?"bg-chart-1 text-white":"bg-muted text-foreground"),children:f==="yes"?1:2}),r.jsx("span",{className:"text-sm text-foreground capitalize",children:f})]},f)})})}),r.jsx(Dt,{})]})},e[2]=c):c=e[2];let d;return e[3]!==s||e[4]!==i?(d=r.jsx(It,{control:s,name:i,render:c}),e[3]=s,e[4]=i,e[5]=d):d=e[5],d}function Ac(t){const e=B.c(13),{input:s,control:i,name:n}=t;switch(s.type){case"text":{let o;return e[0]!==i||e[1]!==s.default||e[2]!==n?(o=r.jsx(Sx,{control:i,name:n,placeholder:s.default}),e[0]=i,e[1]=s.default,e[2]=n,e[3]=o):o=e[3],o}case"choice":{let o;e[4]!==s.options?(o=s.options?.filter(Boolean)??[],e[4]=s.options,e[5]=o):o=e[5];const a=o;let l;return e[6]!==i||e[7]!==n||e[8]!==a?(l=r.jsx(wx,{control:i,name:n,options:a}),e[6]=i,e[7]=n,e[8]=a,e[9]=l):l=e[9],l}case"confirm":{let o;return e[10]!==i||e[11]!==n?(o=r.jsx(Vx,{control:i,name:n}),e[10]=i,e[11]=n,e[12]=o):o=e[12],o}default:return null}}function Cx({parts:t,onSubmit:e}){const[s,i]=S.useState(t[0]?.toolCallId??""),n=yx(t.map(x=>({toolCallId:x.toolCallId,input:x.input}))),o=Hi({resolver:Or(n),defaultValues:Object.fromEntries(t.map(x=>[x.toolCallId,{response:""}]))}),a=o.watch(),l=t.findIndex(x=>x.toolCallId===s),c=!!a[s]?.response,d=t.every(x=>!!a[x.toolCallId]?.response),u=x=>{for(const b of t){const y=x[b.toolCallId]?.response;y&&e(b,y)}},h=x=>t.find(b=>!x[b.toolCallId]?.response&&b.toolCallId!==s)??null,f=()=>{const x=o.getValues();if(t.every(y=>!!x[y.toolCallId]?.response))o.handleSubmit(u)();else{const y=h(x);y&&i(y.toolCallId)}},m=()=>{o.setValue(`${s}.response`,"user has skip this question"),f()},p=()=>{if(l>0){const x=t[l-1];x&&i(x.toolCallId)}},g=()=>{if(l<t.length-1){const x=t[l+1];x&&i(x.toolCallId)}},_=r.jsxs(r.Fragment,{children:[r.jsx(ne,{type:"button",variant:"outline",size:"sm",onClick:m,className:"h-7",children:"Skip"}),r.jsx(ne,{type:"button",size:"sm",disabled:!c,onClick:f,className:X("h-7",c?"":"opacity-50"),children:d?"Submit":"Next"})]}),v=r.jsx(ju,{current:l,total:t.length,onPrev:p,onNext:g});if(t.length===1){const x=t[0];return x?.input?r.jsx(Pi,{...o,children:r.jsx("form",{onSubmit:o.handleSubmit(u),autoComplete:"off",children:r.jsx(On,{title:x.input?.prompt??"Question",footerRight:_,children:r.jsx(Ac,{input:x.input,control:o.control,name:`${x.toolCallId}.response`})})})}):null}return r.jsx(Pi,{...o,children:r.jsx("form",{onSubmit:o.handleSubmit(u),autoComplete:"off",children:r.jsx(Mh,{value:s,onValueChange:i,children:t.map(x=>r.jsx(yn,{value:x.toolCallId,className:"mt-0",children:r.jsx(On,{title:x.input?.prompt??"Question",footerLeft:v,footerRight:_,children:r.jsx(Ac,{input:x.input,control:o.control,name:`${x.toolCallId}.response`})})},x.toolCallId))})})})}function jx(){const t=B.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=r.jsxs("div",{className:"flex items-center gap-2 p-4 border border-dashed rounded-lg bg-accent/50 w-[calc(100%-16px)] max-w-[584px] mx-auto mb-2",children:[r.jsx(Pg,{className:"size-5 text-muted-foreground shimmer"}),r.jsx("span",{className:"text-sm text-muted-foreground shimmer",children:"Preparing question..."})]}),t[0]=e):e=t[0],e}function Nu(t){const e=B.c(6),{userAskParts:s,isStreaming:i,onSubmit:n}=t;let o;e[0]!==s?(o=s.filter(kx),e[0]=s,e[1]=o):o=e[1];const a=o;if(i){let c;return e[2]===Symbol.for("react.memo_cache_sentinel")?(c=r.jsx(jx,{}),e[2]=c):c=e[2],c}if(a.length===0)return null;let l;return e[3]!==n||e[4]!==a?(l=r.jsx(Cx,{parts:a,onSubmit:n}),e[3]=n,e[4]=a,e[5]=l):l=e[5],l}function kx(t){return t.state==="input-available"}const Ec=new Map;function co(){const{org:t}=be(),e=Me({connectionId:Wt,orgId:t.id}),s=bl(),i=s.find(_=>_.providerId==="deco"),{data:n,isLoading:o,refetch:a,isFetching:l}=Fi({queryKey:lt.aiProviderCredits(t.id,"deco"),enabled:!!i,staleTime:6e4,queryFn:async()=>{const _=await e.callTool({name:"AI_PROVIDER_CREDITS",arguments:{providerId:"deco"}});return _?.isError?null:_.structuredContent??null}}),c=n?.balanceCents??null,d=c!=null?c/100:null,u=S.useRef(new Map);if(c!=null){const _=Ec.get(t.id);u.current.get(t.id)&&_!=null&&c>_&&se("credits_topped_up_detected",{organization_id:t.id,delta_cents:c-_,previous_balance_cents:_,new_balance_cents:c}),Ec.set(t.id,c),u.current.set(t.id,!0)}const h=!!i,f=c!=null&&c>0,m=c!=null&&c===0,p=c!=null&&c===200,g=s.length>0&&s.every(_=>_.providerId==="deco");return{hasDecoKey:h,decoKeyId:i?.id??null,balanceCents:c,balanceDollars:d,hasCredits:f,isZeroBalance:m,isInitialFreeCredit:p,hasOnlyDecoProvider:g,isLoading:o,isFetching:l,refetch:a}}function Nx(t){return t?t.message.startsWith("[CREDITS]"):!1}const Ax={usd:[{dollars:10,label:"Starter"},{dollars:20,label:"Popular"},{dollars:100,label:"Best value"}],brl:[{dollars:50,label:"Starter"},{dollars:100,label:"Popular"},{dollars:500,label:"Best value"}]},Ex=["Access to 100+ AI models","Unified API, no separate keys needed","Pay only for what you use"];function Au(t){const e=B.c(43),{onDismiss:s}=t,{org:i}=be(),n=Ke(),{decoKeyId:o}=co();let a;e[0]!==i.id?(a={connectionId:Wt,orgId:i.id},e[0]=i.id,e[1]=a):a=e[1];const l=Me(a),[c,d]=S.useState(""),[u,h]=S.useState(!1),[f,m]=S.useState("usd"),p=f==="brl"?"R$":"$";let g,_;e[2]!==i.id?(g=()=>{se("credits_exhausted_shown",{organization_id:i.id})},_=[i.id],e[2]=i.id,e[3]=g,e[4]=_):(g=e[3],_=e[4]),S.useEffect(g,_);let v;e[5]!==l||e[6]!==f?(v=async D=>{const P=await l.callTool({name:"AI_PROVIDER_TOPUP_URL",arguments:{providerId:"deco",amountCents:D,currency:f}});if(P?.isError)throw new Error(P.content?.[0]?.text??"Failed to get top-up URL");return P.structuredContent?.url},e[5]=l,e[6]=f,e[7]=v):v=e[7];let x;e[8]!==s?(x=D=>{D&&window.open(D,"_blank","noopener,noreferrer"),s?.()},e[8]=s,e[9]=x):x=e[9];let b;e[10]!==v||e[11]!==x?(b={mutationFn:v,onSuccess:x,onError:Tx},e[10]=v,e[11]=x,e[12]=b):b=e[12];const{mutate:y,isPending:C}=Br(b),j=parseFloat(c),V=!isNaN(j)&&j>=1;let w;e[13]!==s?(w=D=>!D&&s?.(),e[13]=s,e[14]=w):w=e[14];let k;e[15]===Symbol.for("react.memo_cache_sentinel")?(k=["radial-gradient(ellipse 40% 200% at -5% 100%, rgba(165,149,255,0.5) 0%, transparent 100%)","radial-gradient(ellipse 40% 200% at 105% -10%, rgba(208,236,26,0.45) 0%, transparent 100%)"],e[15]=k):k=e[15];let T;e[16]===Symbol.for("react.memo_cache_sentinel")?(T=r.jsx("div",{className:"absolute inset-x-0 top-0 h-36 pointer-events-none",style:{backgroundImage:k.join(", "),maskImage:"linear-gradient(to bottom, black 0%, transparent 100%)",WebkitMaskImage:"linear-gradient(to bottom, black 0%, transparent 100%)"}}),e[16]=T):T=e[16];let I;e[17]===Symbol.for("react.memo_cache_sentinel")?(I=r.jsxs("div",{className:"relative px-8 pt-8 pb-2 overflow-hidden",children:[T,r.jsxs(Ds,{className:"relative gap-4",children:[r.jsx("img",{src:"/logos/deco%20logo.svg",alt:"Deco AI Gateway",className:"size-9 rounded-lg object-contain dark:bg-white dark:p-0.5"}),r.jsxs("div",{children:[r.jsx(Ts,{className:"text-xl font-semibold tracking-tight",children:"Top up to keep building"}),r.jsx(dl,{className:"mt-1.5 text-sm leading-relaxed",children:"Your credits are used up. Add more to continue using AI across all your agents."})]})]})]}),e[17]=I):I=e[17];let A;e[18]!==f||e[19]!==p||e[20]!==c||e[21]!==j||e[22]!==o||e[23]!==V||e[24]!==C||e[25]!==u||e[26]!==y?(A=o&&r.jsxs("div",{className:"px-8 pt-5 pb-6",children:[r.jsx("div",{className:"mb-4",children:r.jsxs(eu,{type:"single",variant:"outline",size:"sm",value:f,onValueChange:D=>{D&&m(D)},children:[r.jsx(Ln,{value:"usd",className:"h-8 px-3 text-xs",children:"USD"}),r.jsx(Ln,{value:"brl",className:"h-8 px-3 text-xs",children:"BRL"})]})}),r.jsxs("div",{className:"rounded-xl border border-border p-5",children:[r.jsx("div",{className:"grid grid-cols-3 gap-2.5",children:Ax[f].map(D=>{const{dollars:P,label:O}=D;return r.jsxs("button",{type:"button",disabled:C,onClick:()=>{se("credits_topup_clicked",{amount_cents:P*100,currency:f,tier_label:O,source:"exhausted_banner"}),y(P*100)},className:X("relative flex flex-col items-center gap-1 py-5 rounded-xl border transition-all duration-150 cursor-pointer","disabled:opacity-50 disabled:cursor-wait","border-border hover:border-foreground/20 hover:bg-muted/30"),children:[r.jsxs("span",{className:"text-2xl font-semibold tabular-nums text-foreground",children:[p,P]}),r.jsx("span",{className:"text-xs text-muted-foreground",children:O})]},P)})}),u?r.jsxs("div",{className:"flex gap-2 mt-3",children:[r.jsxs("div",{className:"relative flex-1",children:[r.jsx("span",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-sm text-muted-foreground select-none",children:p}),r.jsx(bt,{type:"number",min:"1",step:"1",placeholder:"50",value:c,onChange:D=>d(D.target.value),className:"h-10 text-sm pl-7",autoFocus:!0})]}),r.jsx(ne,{className:"h-10",disabled:!V||C,onClick:()=>{se("credits_topup_clicked",{amount_cents:Math.round(j*100),currency:f,tier_label:"custom",source:"exhausted_banner"}),y(Math.round(j*100))},children:C?"Opening...":"Add"})]}):r.jsx("button",{type:"button",className:"w-full mt-3 text-xs text-muted-foreground hover:text-foreground transition-colors py-1",onClick:()=>h(!0),children:"Enter custom amount"})]}),r.jsx("div",{className:"mt-5 rounded-xl bg-muted/25 border border-border/50 p-4 space-y-3",children:Ex.map(Ix)})]}),e[18]=f,e[19]=p,e[20]=c,e[21]=j,e[22]=o,e[23]=V,e[24]=C,e[25]=u,e[26]=y,e[27]=A):A=e[27];let N;e[28]!==s?(N=r.jsx(ne,{variant:"ghost",size:"sm",onClick:s,children:"Dismiss"}),e[28]=s,e[29]=N):N=e[29];let E;e[30]!==n||e[31]!==s||e[32]!==i.slug?(E=r.jsx("button",{type:"button",className:"text-xs text-muted-foreground hover:text-foreground transition-colors",onClick:()=>{n({to:"/$org/settings/ai-providers",params:{org:i.slug}}),s?.()},children:"Manage providers"}),e[30]=n,e[31]=s,e[32]=i.slug,e[33]=E):E=e[33];let R;e[34]!==N||e[35]!==E?(R=r.jsxs("div",{className:"px-8 py-4 border-t border-border bg-muted/30 flex items-center justify-between",children:[N,E]}),e[34]=N,e[35]=E,e[36]=R):R=e[36];let M;e[37]!==A||e[38]!==R?(M=r.jsxs(ms,{className:"sm:max-w-[520px] gap-0 p-0 overflow-hidden",onOpenAutoFocus:Rx,children:[I,A,R]}),e[37]=A,e[38]=R,e[39]=M):M=e[39];let L;return e[40]!==M||e[41]!==w?(L=r.jsx(ps,{open:!0,onOpenChange:w,children:M}),e[40]=M,e[41]=w,e[42]=L):L=e[42],L}function Ix(t){return r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("div",{className:"flex items-center justify-center size-5 rounded-full bg-[hsl(var(--chart-1))]/15 shrink-0",children:r.jsx(Jt,{size:12,className:"text-[hsl(var(--chart-1))]"})}),r.jsx("span",{className:"text-sm text-foreground/80",children:t})]},t)}function Rx(t){return t.preventDefault()}function Tx(t){pe.error(`Top-up failed: ${t.message}`)}const Dx={length:"Response reached the model's output limit. Different models have different limits. Try switching models or asking it to continue.","content-filter":"Response was filtered due to content policy.","tool-calls":"Response paused after tool execution to prevent infinite loops and save costs. Click continue to keep working."};function $n(t){const e=B.c(32),{variant:s,onDismiss:i}=t,n=s==="error",o=n?"Error occurred":"Response incomplete",a=n?t.error.message:Dx[t.finishReason]??`Response stopped unexpectedly: ${t.finishReason}`,l=n?"border-destructive/30 bg-destructive/5":"border-amber-500/30 bg-amber-500/5",c=n?"text-destructive":"text-amber-600 dark:text-amber-500",d=n?ri:yh;let u;e[0]!==l?(u=X("flex items-start gap-2 px-3 py-2.5 rounded-lg border border-dashed text-sm w-full mb-2 shadow",l),e[0]=l,e[1]=u):u=e[1];let h;e[2]!==c?(h=X("mt-0.5 shrink-0",c),e[2]=c,e[3]=h):h=e[3];let f;e[4]!==d?(f=r.jsx(d,{size:16}),e[4]=d,e[5]=f):f=e[5];let m;e[6]!==h||e[7]!==f?(m=r.jsx("div",{className:h,children:f}),e[6]=h,e[7]=f,e[8]=m):m=e[8];let p;e[9]!==c?(p=X("text-xs mb-1 font-medium",c),e[9]=c,e[10]=p):p=e[10];let g;e[11]!==p||e[12]!==o?(g=r.jsx("div",{className:p,children:o}),e[11]=p,e[12]=o,e[13]=g):g=e[13];let _;e[14]!==a?(_=r.jsx("div",{className:"text-xs line-clamp-2 text-muted-foreground mb-2",children:a}),e[14]=a,e[15]=_):_=e[15];let v;e[16]!==n||e[17]!==t.onContinue||e[18]!==t.onFixInChat?(v=r.jsx("div",{className:"flex gap-2",children:n?r.jsxs(r.Fragment,{children:[r.jsx(ne,{size:"sm",variant:"outline",onClick:t.onFixInChat,className:"h-7 text-xs",children:"Fix in chat"}),r.jsx(ne,{size:"sm",variant:"outline",disabled:!0,className:"h-7 text-xs",children:"Report"})]}):r.jsx(ne,{size:"sm",variant:"outline",onClick:t.onContinue,className:"h-7 text-xs",children:"Continue"})}),e[16]=n,e[17]=t.onContinue,e[18]=t.onFixInChat,e[19]=v):v=e[19];let x;e[20]!==g||e[21]!==_||e[22]!==v?(x=r.jsxs("div",{className:"flex-1 min-w-0",children:[g,_,v]}),e[20]=g,e[21]=_,e[22]=v,e[23]=x):x=e[23];let b;e[24]===Symbol.for("react.memo_cache_sentinel")?(b=r.jsx(fi,{size:14}),e[24]=b):b=e[24];let y;e[25]!==i?(y=r.jsx("button",{type:"button",onClick:i,className:"text-muted-foreground hover:text-foreground transition-colors shrink-0",title:"Dismiss",children:b}),e[25]=i,e[26]=y):y=e[26];let C;return e[27]!==u||e[28]!==y||e[29]!==m||e[30]!==x?(C=r.jsx("div",{className:"px-0.5",children:r.jsxs("div",{className:u,children:[m,x,y]})}),e[27]=u,e[28]=y,e[29]=m,e[30]=x,e[31]=C):C=e[31],C}function ho(){const t=B.c(41),{error:e,clearError:s,finishReason:i,clearFinishReason:n,messages:o,isStreaming:a,isWaitingForApprovals:l,addToolOutput:c,addToolApprovalResponse:d,sendMessage:u}=Ui(),[h,f]=Wi(),{virtualMcpId:m,createTaskWithMessage:p}=es();let g,_,v,x;if(t[0]!==o){const R=o.at(-1);x=R?.role==="assistant"?R.parts.filter(Lx):null,g=x?.filter(Px)?.length,_=R?.role==="assistant"?_x(R.parts):[],v=R?.role==="assistant"?fx(R.parts):[],t[0]=o,t[1]=g,t[2]=_,t[3]=v,t[4]=x}else g=t[1],_=t[2],v=t[3],x=t[4];const b=v;let y;t[5]!==e||t[6]!==u?(y=()=>{if(e){const M={type:"doc",content:[{type:"paragraph",content:[{type:"text",text:`I encountered this error: ${e.message}. Can you help me fix it?`}]}]};u(M)}},t[5]=e,t[6]=u,t[7]=y):y=t[7];const C=y;let j;t[8]!==u?(j=()=>{u({type:"doc",content:[{type:"paragraph",content:[{type:"text",text:"Please continue."}]}]})},t[8]=u,t[9]=j):j=t[9];const V=j;let w;t[10]!==c?(w=(R,M)=>{c({tool:"user_ask",toolCallId:R.toolCallId,output:{response:M}})},t[10]=c,t[11]=w):w=t[11];const k=w;let T;t[12]!==p||t[13]!==h||t[14]!==f||t[15]!==m?(T=R=>{f({...h,toolApprovalLevel:"auto"}),p({virtualMcpId:m,message:{parts:[{type:"text",text:`Implement this plan:
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/project-app-view-Cgxq8Z9m.js","assets/index-yA3niX2v.js","assets/index-B2LlXg0m.css","assets/task-status-CaevYqis.js","assets/agent-icon-D6bLKQ2x.js","assets/AlertCircle-RpY4bUJr.js","assets/Tool01-R5WYUcbi.js","assets/SearchMd-CfDkq1If.js","assets/ArrowNarrowLeft-CJwdGPbT.js","assets/XCircle-DayiQYw5.js","assets/ZapSquare-DnGX7edB.js","assets/Users03-DCEUsmLl.js","assets/CheckCircle-BI5IiZgb.js","assets/ChevronDown-BAXd7Lqd.js","assets/ChevronRight-DKEbZtdl.js","assets/ChevronUp-DzlxkGUl.js","assets/Container-DBgGfzNs.js","assets/Star01-BTwJOW68.js","assets/Palette-CFaa6lnd.js","assets/index-CSYRl1zg.js","assets/use-mobile-cBCc1tkS.js","assets/X-mGheZZXr.js","assets/LinkExternal01-BpU2Zg5G.js","assets/Lock01-C5ObVqfL.js","assets/Sun-CWTFdsIN.js","assets/Play-Z2rVo32r.js","assets/Plus-iqKMHcIY.js","assets/Settings02-BnNqayNe.js","assets/Trash01-DYSvj4Mr.js","assets/Upload01-Cktx5YzE.js","assets/User01-BbQpT999.js","assets/Zap-BnPwXsSI.js","assets/scroll-area-Bzy4HD_J.js","assets/select-ReQwhRkA.js","assets/use-copy-DSXw9G_Y.js","assets/differenceInSeconds-NQ4PDo0z.js","assets/dialog-6uxiP96k.js","assets/content-blocks-o63cs2vh.js","assets/types-952BCAPT.js","assets/constants-DML917gs.js","assets/chat-context-0qKFTvd4.js","assets/use-virtual-mcp-C3-aNrQY.js","assets/use-collections-By6uZJSr.js","assets/use-ai-providers-BirgTm09.js","assets/use-decopilot-events-Yr2IQvc8.js","assets/create-sse-subscription-CxkOgzKf.js","assets/use-tasks-C63aBSUV.js","assets/use-organization-settings-Bfqz0Dub.js","assets/shell-layout-BD0Xub-g.js","assets/required-auth-layout-OZ0PdFXR.js","assets/use-org-sso-B4d8umPM.js","assets/integration-icon-LoNFtirH.js","assets/use-mcp-tools-D2wfRdQX.js"])))=>i.map(i=>d[i]);
2
+ import{o as Mt,r as S,p as Om,q as $m,e as B,s as be,K as lt,n as Fi,a as Br,v as Vs,w as Or,x as Hi,j as r,B as ne,y as Et,c as X,E as Cs,z as pe,C as Wi,_ as zm,t as se,f as Ke,D as yh,F as Fm,R as Sh,G as Hm,H as ys,I as So,J as ds,L as Wm,M as wo,P as Um,Q as Km,T as qm,U as Gm,V as wh,W as Ym,X as Xm,Y as Jm,Z as Qm,$ as lc,l as Ee,b as St,u as Zm,a0 as pr,a1 as vn,a2 as nl,a3 as ol,g as $r,a4 as Vh,d as vi,a5 as ep,a6 as tp,a7 as sp,a8 as ip,a9 as Ch,aa as jh,ab as rp,ac as np,ad as op,ae as Ft,af as ap,ag as lp,ah as cp,ai as dp,aj as Zi,ak as hp,al as up,am as fp,an as mp,ao as kh,ap as pp,aq as gp,ar as _p,as as xp,at as vp,au as bp,av as yp,aw as Sp,ax as wp,ay as Vp,az as Nh,aA as bn,aB as Cp,aC as Ai,aD as nn,aE as Ah,aF as jp,aG as kp}from"./index-yA3niX2v.js";import{u as ni,a as Ui,b as es,A as Np,C as Ap,c as ia,d as Ep,e as Zn,f as cc,t as Ip}from"./chat-context-0qKFTvd4.js";import{d as eo,g as si,c as Rp,s as al,t as Tp,a as Dp,M as Mp,i as Pp,b as Cr,e as Lp,F as Bp,f as Eh,S as Op,u as $p,h as dc,j as zp,k as Fp,l as ra,r as Hp,m as Wp,p as Ih,n as Up,o as Kp,q as ll,G as qp,L as Gp,v as Yp,w as Xp,x as Jp,y as Qp}from"./task-status-CaevYqis.js";import{S as jr,u as to,P as na,a as Zp,b as eg,c as tg,E as sg,i as ig,d as rg,e as Rh}from"./scroll-area-Bzy4HD_J.js";import{T as Mi,u as Rs,a as tt,b as st,c as it}from"./use-mobile-cBCc1tkS.js";import{D as Ts,a as Ds,b as cl,c as ms,d as ps,e as dl}from"./dialog-6uxiP96k.js";import{D as so,a as bi,b as yi,c as Si,d as ng,e as og,f as ag}from"./drawer-CbvLq5Uu.js";import{C as Th}from"./collection-search-CaS2n1cB.js";import{S as Wt,u as Me,g as io,i as Mn,c as lg,W as Os,a as cg,b as hl}from"./constants-DML917gs.js";import{u as Dh,g as ul,T as Mh,a as yn,l as Pn,b as Vo,c as dg}from"./tabs-DO4ygLuS.js";import{F as Pi,a as It,b as Rt,c as rs,d as Tt,e as Dt,f as hg}from"./form-oEblHddW.js";import{I as bt}from"./input-B9sAUDOT.js";import{i as Ph,u as zr,r as Lh}from"./shell-layout-BD0Xub-g.js";import{D as ot,a as Sn,b as wn,c as js,d as ks,e as Ns,f as Bh,g as Oh,h as hc}from"./dropdown-menu-BSSwgSj1.js";import{t as ug,i as $h,n as fg,A as zs,a as zh,b as fl,s as ii,c as mg,d as pg,e as Fh,f as Hh,g as gg,h as ml,j as gr,k as _g,l as pl,m as xg,o as vg,p as Fr,q as Hr,r as bg,u as uc,v as fc,w as yg,x as Sg,y as mc,z as wg,B as gl,C as Wh,D as oa,E as Co,F as pc,G as Vg,H as Cg,I as jg,J as kg,K as Uh,L as Kh,M as qh,N as Gh,O as gc,P as Ng,Q as _r,R as Ag,S as Eg,T as Ig,U as Yh}from"./agent-icon-D6bLKQ2x.js";import{n as Xh,a as aa,i as Rg,b as Tg,c as Dg}from"./ZapSquare-DnGX7edB.js";import{i as Jt,t as kr}from"./ChevronDown-BAXd7Lqd.js";import{s as Ti}from"./Star01-BTwJOW68.js";import{a as la,t as _l}from"./Tool01-R5WYUcbi.js";import{i as Jh}from"./Lock01-C5ObVqfL.js";import{s as Qt}from"./Plus-iqKMHcIY.js";import{i as Qh}from"./Upload01-Cktx5YzE.js";import{i as fi}from"./X-mGheZZXr.js";import{i as ri}from"./AlertCircle-RpY4bUJr.js";import{S as Js,a as Qs,b as Ht,c as Zs,d as ei}from"./select-ReQwhRkA.js";import{i as xl,a as vl,b as Mg}from"./SearchMd-CfDkq1If.js";import{i as ro,t as Pg,a as Lg,b as Bg,c as Og,d as $g,e as Li,f as Zh}from"./XCircle-DayiQYw5.js";import{T as eu,a as Ln}from"./toggle-group-Bo4IS3RK.js";import{u as bl,a as tu}from"./use-ai-providers-BirgTm09.js";import{m as no,g as zg,i as Fg,a as su,M as iu,N as Hg}from"./select-model-D4OtA_w2.js";import{S as Wg,A as Ug,a as Kg,b as qg,c as Gg,R as ru,d as Yg,e as Xg}from"./accordion-hSfs59TQ.js";import{r as nu,l as xr,u as Jg,g as Qg}from"./types-952BCAPT.js";import{u as oo,a as ts,b as yl}from"./use-virtual-mcp-C3-aNrQY.js";import{u as Wr,a as Sl,b as wl}from"./use-connection-CZkpN1_f.js";import{p as Zg,q as _c}from"./question-004-sINsf4GQ.js";import{g as xc}from"./ai-providers-logos-CS4PCiqI.js";import{g as ou,s as au}from"./connection-slug-eyAPH6o3.js";import{u as lu,a as cu,g as e_,C as jo}from"./connection-card-Mc71vwAD.js";import{C as du}from"./collection-tabs-ByBcZvcT.js";import{g as hu}from"./constants-Bp5-iYcY.js";import{T as ca}from"./textarea-DDf010du.js";import{n as Vn}from"./Container-DBgGfzNs.js";import{c as t_,i as on,a as vc,E as s_,p as i_,b as r_,d as n_}from"./connection-form-helpers-fgpIig1w.js";import{u as bc}from"./use-infinite-scroll-DmTHG8QF.js";import{u as o_,C as a_,a as yc,b as Sc,c as l_,d as c_,e as d_,f as h_}from"./command-B51t2F-w.js";import{g as u_,e as f_,a as m_}from"./extract-connection-data-Cezio-s5.js";import{B as wc}from"./badge-gQVaeFYL.js";import{i as Vl}from"./ChevronRight-DKEbZtdl.js";import{I as Ms}from"./integration-icon-LoNFtirH.js";import{S as Bi}from"./skeleton-B313Ulm0.js";import{a as ao}from"./Users03-DCEUsmLl.js";import{I as Bn,S as uu,G as p_,L as g_,a as __,b as fu}from"./lean-canvas-recruit-modal-C6N1BBPO.js";import{u as lo,a as mu}from"./use-navigate-to-agent-8jFeFT9G.js";import{u as pu}from"./use-create-virtual-mcp-BNzn74Vf.js";import{i as x_}from"./CheckCircle-BI5IiZgb.js";import{P as oi,a as ai,b as li}from"./popover-GxFgGfCj.js";import{u as wi,a as v_}from"./use-mcp-tools-D2wfRdQX.js";import{E as Oi}from"./empty-state-0hDWNUcx.js";import{u as b_}from"./use-decopilot-events-Yr2IQvc8.js";import{i as $i}from"./Zap-BnPwXsSI.js";import{i as gu,S as Ur,a as Kr,b as gs,u as qr,c as us,d as Zt,e as _u,f as xu,g as y_,h as vu,j as bu,P as hs,k as S_,l as w_,m as V_,n as C_,o as j_,p as k_}from"./index-CSYRl1zg.js";import{A as Vc}from"./avatar-Or2zrDA-.js";import{n as N_,a as A_,i as E_}from"./Sun-CWTFdsIN.js";import{a as Gr}from"./Settings02-BnNqayNe.js";import{A as Cl,a as jl,b as kl,c as Nl,d as Al,e as El,f as Il,g as yu}from"./alert-dialog-Dw58KHOn.js";import"./index-DYe52Cyo.js";import{u as Su}from"./use-tasks-C63aBSUV.js";import{u as I_}from"./use-status-sounds-B5cgRwGB.js";import{T as R_,u as wu}from"./tools-list-CIQ6CwYm.js";import{u as ko}from"./unwrap-tool-result-BYXdCQMg.js";import{C as T_,a as Cc}from"./card-N_n9dJ1C.js";import{L as vr}from"./label-WH1pO6UH.js";import{S as da}from"./switch-BXD1owGz.js";import{i as Cn}from"./Play-Z2rVo32r.js";import{s as ha}from"./Trash01-DYSvj4Mr.js";import{C as D_}from"./checkbox-CPuyzGEM.js";import{n as Vi}from"./LinkExternal01-BpU2Zg5G.js";import{V as M_}from"./view-mode-toggle-BrDfC5aK.js";import{U as P_}from"./user-zYk_lp5f.js";import{u as Yr,a as L_,b as B_,c as O_,A as $_,d as z_}from"./automation-list-row-DYTYU42X.js";import{S as F_}from"./search-input-Bnf2nHLo.js";import"./use-collections-By6uZJSr.js";import"./use-organization-settings-Bfqz0Dub.js";import"./use-copy-DSXw9G_Y.js";import"./differenceInSeconds-NQ4PDo0z.js";import"./content-blocks-o63cs2vh.js";import"./required-auth-layout-OZ0PdFXR.js";import"./use-org-sso-B4d8umPM.js";import"./ArrowNarrowLeft-CJwdGPbT.js";import"./ChevronUp-DzlxkGUl.js";import"./Palette-CFaa6lnd.js";import"./User01-BbQpT999.js";import"./formatDistanceToNow-Cb2QZZJn.js";import"./use-registry-connections-BX2aMDCo.js";import"./useInfiniteQuery-DBOEwCdJ.js";import"./infiniteQueryObserver-Kusj8ovY.js";import"./collections-Djr3E20Q.js";import"./index-C2YTBPmn.js";import"./create-sse-subscription-CxkOgzKf.js";function H_(t,e){const s=Mt(e);return W_({filters:{...t,status:"pending"}},s).length}function jc(t,e){return t.findAll(e.filters).map(s=>e.select?e.select(s):s.state)}function W_(t={},e){const s=Mt(e).getMutationCache(),i=S.useRef(t),n=S.useRef(null);return n.current===null&&(n.current=jc(s,t)),S.useEffect(()=>{i.current=t}),S.useSyncExternalStore(S.useCallback(o=>s.subscribe(()=>{const a=Om(n.current,jc(s,i.current));n.current!==a&&(n.current=a,$m.schedule(o))}),[s]),()=>n.current,()=>n.current)}function U_(t,e){const s=B.c(37),{org:i,locator:n}=be();let o;s[0]!==i.id?(o={connectionId:Wt,orgId:i.id},s[0]=i.id,s[1]=o):o=s[1];const a=Me(o),l=Mt();let c;s[2]!==t||s[3]!==i.id?(c=lt.ensureTask(i.id,t),s[2]=t,s[3]=i.id,s[4]=c):c=s[4];let d;s[5]!==a||s[6]!==t?(d=async()=>(await a.callTool({name:"COLLECTION_THREADS_GET",arguments:{id:t}})).structuredContent?.item??null,s[5]=a,s[6]=t,s[7]=d):d=s[7];let u;s[8]!==c||s[9]!==d?(u={queryKey:c,queryFn:d,retry:!1,refetchOnWindowFocus:!1},s[8]=c,s[9]=d,s[10]=u):u=s[10];const h=Fi(u);let f;s[11]!==a||s[12]!==e?(f=async b=>{const y=await a.callTool({name:"COLLECTION_THREADS_CREATE",arguments:{data:{id:b,virtual_mcp_id:e}}});if(y.isError){const j=y.content,V=Array.isArray(j)&&j[0]&&typeof j[0]=="object"?j[0].text??"Create failed":"Create failed";throw new Error(V)}return y.structuredContent.item},s[11]=a,s[12]=e,s[13]=f):f=s[13];let m;s[14]!==n||s[15]!==i.id||s[16]!==h||s[17]!==l?(m=()=>{l.invalidateQueries({predicate:b=>b.queryKey[1]===i.id&&b.queryKey[3]==="collection"&&b.queryKey[4]==="THREADS"}),l.invalidateQueries({queryKey:lt.tasksPrefix(n)}),h.refetch()},s[14]=n,s[15]=i.id,s[16]=h,s[17]=l,s[18]=m):m=s[18];let p;s[19]!==f||s[20]!==m?(p={mutationFn:f,onSuccess:m},s[19]=f,s[20]=m,s[21]=p):p=s[21];const g=Br(p);let _,v;if(s[22]!==g||s[23]!==t||s[24]!==h.data||s[25]!==h.isSuccess?(_=()=>{!h.isSuccess||h.data||g.isPending||g.variables!==t&&g.mutate(t)},v=[t,h.isSuccess,h.data,g],s[22]=g,s[23]=t,s[24]=h.data,s[25]=h.isSuccess,s[26]=_,s[27]=v):(_=s[26],v=s[27]),S.useEffect(_,v),h.isLoading){let b;return s[28]===Symbol.for("react.memo_cache_sentinel")?(b={status:"loading"},s[28]=b):b=s[28],b}if(h.isError){const b=h.error;let y;return s[29]!==b?(y={status:"error",error:b},s[29]=b,s[30]=y):y=s[30],y}if(h.isSuccess&&h.data){let b;return s[31]!==h.data?(b={status:"ready",task:h.data},s[31]=h.data,s[32]=b):b=s[32],b}if(g.isPending||h.isSuccess&&!h.data){let b;return s[33]===Symbol.for("react.memo_cache_sentinel")?(b={status:"creating"},s[33]=b):b=s[33],b}if(g.isError){let b;return s[34]!==g.error?(b={status:"error",error:g.error},s[34]=g.error,s[35]=b):b=s[35],b}let x;return s[36]===Symbol.for("react.memo_cache_sentinel")?(x={status:"loading"},s[36]=x):x=s[36],x}function K_(t){const e={};for(const s of t.arguments??[])e[s.name]=s.required?Et().min(1,"Required"):Et();return Vs(e)}function q_(t){const e={};for(const s of t.arguments??[])e[s.name]="";return e}function Rl(t){const e=B.c(65),{prompt:s,setPrompt:i,onSubmit:n}=t,o=S.useId();let a;if(e[0]!==s){const D=s?K_(s):Vs({});a=Or(D),e[0]=s,e[1]=a}else a=e[1];const c=a;let d;e[2]!==s?(d=s?q_(s):{},e[2]=s,e[3]=d):d=e[3];let u;e[4]!==c||e[5]!==d?(u={resolver:c,defaultValues:d,mode:"onChange"},e[4]=c,e[5]=d,e[6]=u):u=e[6];const h=Hi(u);let f;e[7]!==s?.arguments?(f=s?.arguments??[],e[7]=s?.arguments,e[8]=f):f=e[8];const m=f;let p;e[9]!==h||e[10]!==n||e[11]!==i?(p=async D=>{await n(D),i(null),h.reset()},e[9]=h,e[10]=n,e[11]=i,e[12]=p):p=e[12];const g=p;let _;e[13]!==h||e[14]!==i?(_=D=>{D||(h.reset(),i(null))},e[13]=h,e[14]=i,e[15]=_):_=e[15];const v=_;if(!s)return null;let x;e[16]!==s._meta||e[17]!==s.name||e[18]!==s.title?(x=s.title||eo(s.name,si(s._meta)),e[16]=s._meta,e[17]=s.name,e[18]=s.title,e[19]=x):x=e[19];let b;e[20]!==x?(b=r.jsx(Ts,{children:r.jsx("span",{className:"capitalize",children:x})}),e[20]=x,e[21]=b):b=e[21];let y;e[22]!==s.description?(y=s.description&&r.jsx("p",{className:"text-sm text-muted-foreground",children:s.description}),e[22]=s.description,e[23]=y):y=e[23];let C;e[24]!==y||e[25]!==b?(C=r.jsxs(Ds,{children:[b,y]}),e[24]=y,e[25]=b,e[26]=C):C=e[26];let j;e[27]!==h||e[28]!==g?(j=D=>{D.stopPropagation(),h.handleSubmit(g)(D)},e[27]=h,e[28]=g,e[29]=j):j=e[29];let V;if(e[30]!==m||e[31]!==h.control||e[32]!==h.formState.isSubmitting){let D;e[34]!==h.control||e[35]!==h.formState.isSubmitting?(D=P=>r.jsx(It,{control:h.control,name:P.name,render:O=>{const{field:z}=O;return r.jsxs(Rt,{children:[r.jsxs(rs,{className:"text-xs",children:[P.name,P.required?null:r.jsxs("span",{className:"text-muted-foreground font-normal",children:[" ","(optional)"]})]}),r.jsx(Tt,{children:r.jsx(bt,{...z,value:z.value??"",required:P.required,placeholder:P.description??"",className:"h-9",disabled:h.formState.isSubmitting})}),r.jsx(Dt,{})]})}},P.name),e[34]=h.control,e[35]=h.formState.isSubmitting,e[36]=D):D=e[36],V=m.map(D),e[30]=m,e[31]=h.control,e[32]=h.formState.isSubmitting,e[33]=V}else V=e[33];let w;e[37]!==v?(w=()=>v(!1),e[37]=v,e[38]=w):w=e[38];let k;e[39]!==h.formState.isSubmitting||e[40]!==w?(k=r.jsx(ne,{type:"button",variant:"ghost",onClick:w,disabled:h.formState.isSubmitting,children:"Cancel"}),e[39]=h.formState.isSubmitting,e[40]=w,e[41]=k):k=e[41];const T=!h.formState.isValid||h.formState.isSubmitting;let I;e[42]!==h.formState.isSubmitting?(I=h.formState.isSubmitting?r.jsxs("span",{className:"flex items-center gap-2",children:[r.jsx(jr,{size:"xs"}),"Loading..."]}):"Use prompt",e[42]=h.formState.isSubmitting,e[43]=I):I=e[43];let A;e[44]!==o||e[45]!==T||e[46]!==I?(A=r.jsx(ne,{type:"submit",form:o,disabled:T,children:I}),e[44]=o,e[45]=T,e[46]=I,e[47]=A):A=e[47];let N;e[48]!==k||e[49]!==A?(N=r.jsxs(cl,{children:[k,A]}),e[48]=k,e[49]=A,e[50]=N):N=e[50];let E;e[51]!==o||e[52]!==j||e[53]!==V||e[54]!==N?(E=r.jsxs("form",{id:o,className:"space-y-4 py-4",autoComplete:"off",onSubmit:j,children:[V,N]}),e[51]=o,e[52]=j,e[53]=V,e[54]=N,e[55]=E):E=e[55];let R;e[56]!==h||e[57]!==E?(R=r.jsx(Pi,{...h,children:E}),e[56]=h,e[57]=E,e[58]=R):R=e[58];let M;e[59]!==C||e[60]!==R?(M=r.jsxs(ms,{className:"sm:max-w-lg max-h-[80vh] overflow-y-auto",children:[C,R]}),e[59]=C,e[60]=R,e[61]=M):M=e[61];let L;return e[62]!==v||e[63]!==M?(L=r.jsx(ps,{open:!0,onOpenChange:v,children:M}),e[62]=v,e[63]=M,e[64]=L):L=e[64],L}function G_(t){return!t||!t.content||t.content.length===0?!0:t.content.every(e=>e.type==="paragraph"?!e.content||e.content.length===0?!0:e.content.every(s=>s.type==="hardBreak"||s.type==="text"&&(!s.text||s.text.trim()==="")):!1)}function Y_(t,e){return{type:"doc",content:[...t?.content??[],e].filter(Boolean)}}const kc=3,Vu="inline-flex items-center gap-2 px-5 py-2.5 rounded-full bg-muted text-muted-foreground text-sm font-medium transition-colors cursor-pointer",X_="flex flex-col gap-1.5 p-4 rounded-xl bg-accent/40 text-sm leading-snug transition-colors cursor-pointer text-left";function Cu(t){const e=B.c(46),{item:s,onSelect:i,isLoading:n,isDisabled:o,variant:a}=t,l=a===void 0?"pill":a,{prompt:c}=s;let d;if(e[0]!==c._meta||e[1]!==c.name||e[2]!==c.title){const V=si(c._meta);d=c.title??eo(c.name,V),e[0]=c._meta,e[1]=c.name,e[2]=c.title,e[3]=d}else d=e[3];const u=d,h=c.description||null;if(l==="card"){let V;e[4]!==i||e[5]!==c?(V=()=>i(c),e[4]=i,e[5]=c,e[6]=V):V=e[6];const w=o||n,k=n&&"bg-accent/40",T=(o||n)&&"cursor-not-allowed opacity-50";let I;e[7]!==k||e[8]!==T?(I=X(X_,"hover:bg-accent/60 text-foreground",k,T),e[7]=k,e[8]=T,e[9]=I):I=e[9];let A;e[10]!==u?(A=r.jsx("span",{className:"font-medium truncate capitalize",children:u}),e[10]=u,e[11]=A):A=e[11];let N;e[12]!==n?(N=n&&r.jsx(jr,{size:"xs"}),e[12]=n,e[13]=N):N=e[13];let E;e[14]!==A||e[15]!==N?(E=r.jsxs("div",{className:"flex items-center justify-between gap-2",children:[A,N]}),e[14]=A,e[15]=N,e[16]=E):E=e[16];let R;e[17]!==h?(R=h&&r.jsx("span",{className:"text-xs text-muted-foreground line-clamp-2",children:h}),e[17]=h,e[18]=R):R=e[18];let M;return e[19]!==E||e[20]!==R||e[21]!==V||e[22]!==w||e[23]!==I?(M=r.jsxs("button",{type:"button",onClick:V,disabled:w,className:I,children:[E,R]}),e[19]=E,e[20]=R,e[21]=V,e[22]=w,e[23]=I,e[24]=M):M=e[24],M}let f;e[25]!==i||e[26]!==c?(f=()=>i(c),e[25]=i,e[26]=c,e[27]=f):f=e[27];const m=o||n,p=n&&"bg-muted/50",g=(o||n)&&"cursor-not-allowed opacity-50";let _;e[28]!==p||e[29]!==g?(_=X(Vu,"hover:bg-muted/70 hover:text-foreground",p,g),e[28]=p,e[29]=g,e[30]=_):_=e[30];let v;e[31]!==u?(v=r.jsx("span",{className:"capitalize",children:u}),e[31]=u,e[32]=v):v=e[32];let x;e[33]!==n?(x=n&&r.jsx(jr,{size:"xs"}),e[33]=n,e[34]=x):x=e[34];let b;e[35]!==f||e[36]!==m||e[37]!==_||e[38]!==v||e[39]!==x?(b=r.jsx(tt,{asChild:!0,children:r.jsxs("button",{type:"button",onClick:f,disabled:m,className:_,children:[v,x]})}),e[35]=f,e[36]=m,e[37]=_,e[38]=v,e[39]=x,e[40]=b):b=e[40];const y=h??u;let C;e[41]!==y?(C=r.jsx(st,{side:"top",className:"max-w-xs",children:r.jsx("p",{className:"text-xs",children:y})}),e[41]=y,e[42]=C):C=e[42];let j;return e[43]!==b||e[44]!==C?(j=r.jsxs(it,{delayDuration:400,children:[b,C]}),e[43]=b,e[44]=C,e[45]=j):j=e[45],j}function J_(t){const e=B.c(41),{items:s,open:i,onOpenChange:n,onSelect:o,loadingPrompt:a}=t,[l,c]=S.useState(""),d=!!a;let u;e[0]!==s||e[1]!==l?(u=l.trim()?s.filter(w=>{const k=l.toLowerCase();return w.prompt.name.toLowerCase().includes(k)||(w.prompt.title??"").toLowerCase().includes(k)||(w.prompt.description??"").toLowerCase().includes(k)}):s,e[0]=s,e[1]=l,e[2]=u):u=e[2];const h=u,f=Rs();let m;e[3]!==h.length||e[4]!==l?(m=h.length===0&&r.jsxs("p",{className:"col-span-4 text-sm text-muted-foreground text-center py-8",children:["No prompts match “",l,"”"]}),e[3]=h.length,e[4]=l,e[5]=m):m=e[5];let p;if(e[6]!==h||e[7]!==d||e[8]!==a?.name||e[9]!==n||e[10]!==o){let w;e[12]!==d||e[13]!==a?.name||e[14]!==n||e[15]!==o?(w=k=>r.jsx(Cu,{item:k,variant:"card",onSelect:T=>{n(!1),o(T)},isLoading:a?.name===k.prompt.name,isDisabled:d&&a?.name!==k.prompt.name},k.prompt.name),e[12]=d,e[13]=a?.name,e[14]=n,e[15]=o,e[16]=w):w=e[16],p=h.map(w),e[6]=h,e[7]=d,e[8]=a?.name,e[9]=n,e[10]=o,e[11]=p}else p=e[11];let g;e[17]!==m||e[18]!==p?(g=r.jsx("div",{className:"flex-1 overflow-y-auto [scrollbar-gutter:stable]",children:r.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-4 gap-3 p-5",children:[m,p]})}),e[17]=m,e[18]=p,e[19]=g):g=e[19];const _=g;let v;e[20]===Symbol.for("react.memo_cache_sentinel")?(v=w=>{w.key==="Escape"&&c("")},e[20]=v):v=e[20];let x;e[21]!==l?(x=r.jsx(Th,{value:l,onChange:c,placeholder:"Search prompts...",onKeyDown:v}),e[21]=l,e[22]=x):x=e[22];const b=x;if(f){let w;e[23]===Symbol.for("react.memo_cache_sentinel")?(w=r.jsx(so,{className:"sr-only",children:r.jsx(bi,{children:"All prompts"})}),e[23]=w):w=e[23];let k;e[24]===Symbol.for("react.memo_cache_sentinel")?(k=r.jsx("div",{className:"flex items-center h-12 border-b border-border px-4 shrink-0",children:r.jsx("span",{className:"text-sm font-medium text-foreground",children:"Prompts"})}),e[24]=k):k=e[24];let T;e[25]!==_||e[26]!==b?(T=r.jsxs(yi,{className:"h-[85vh] flex flex-col p-0 gap-0",children:[w,k,b,_]}),e[25]=_,e[26]=b,e[27]=T):T=e[27];let I;return e[28]!==n||e[29]!==i||e[30]!==T?(I=r.jsx(Mi,{delayDuration:400,children:r.jsx(Si,{open:i,onOpenChange:n,children:T})}),e[28]=n,e[29]=i,e[30]=T,e[31]=I):I=e[31],I}let y;e[32]===Symbol.for("react.memo_cache_sentinel")?(y=r.jsx(Ds,{className:"sr-only",children:r.jsx(Ts,{children:"All prompts"})}),e[32]=y):y=e[32];let C;e[33]===Symbol.for("react.memo_cache_sentinel")?(C=r.jsx("div",{className:"flex items-center h-12 border-b border-border px-4 shrink-0",children:r.jsx("span",{className:"text-sm font-medium text-foreground",children:"Prompts"})}),e[33]=C):C=e[33];let j;e[34]!==_||e[35]!==b?(j=r.jsxs(ms,{className:"sm:max-w-[1100px] h-[680px] p-0 gap-0 overflow-hidden flex flex-col",children:[y,C,b,_]}),e[34]=_,e[35]=b,e[36]=j):j=e[36];let V;return e[37]!==n||e[38]!==i||e[39]!==j?(V=r.jsx(Mi,{delayDuration:400,children:r.jsx(ps,{open:i,onOpenChange:n,children:j})}),e[37]=n,e[38]=i,e[39]=j,e[40]=V):V=e[40],V}function Q_(t){const e=B.c(29),{items:s,onSelect:i,loadingPrompt:n,className:o}=t,[a,l]=S.useState(!1);if(s.length===0)return null;let c,d,u;if(e[0]!==s||e[1]!==n||e[2]!==i){const v=s.slice(0,kc);let x;e[6]!==s?(x=s.slice(kc),e[6]=s,e[7]=x):x=e[7],c=x,d=!!n;let b;e[8]!==d||e[9]!==n?.name||e[10]!==i?(b=y=>r.jsx(Cu,{item:y,onSelect:i,isLoading:n?.name===y.prompt.name,isDisabled:d&&n?.name!==y.prompt.name},y.prompt.name),e[8]=d,e[9]=n?.name,e[10]=i,e[11]=b):b=e[11],u=v.map(b),e[0]=s,e[1]=n,e[2]=i,e[3]=c,e[4]=d,e[5]=u}else c=e[3],d=e[4],u=e[5];const h=u;let f;e[12]!==o?(f=X("w-full flex flex-wrap gap-2 justify-center",o),e[12]=o,e[13]=f):f=e[13];let m;e[14]!==c.length||e[15]!==d?(m=c.length>0&&r.jsxs("button",{type:"button",disabled:d,onClick:()=>l(!0),className:X(Vu,"hover:bg-muted/70 hover:text-foreground",d&&"opacity-50 cursor-not-allowed"),children:["+",c.length," more"]}),e[14]=c.length,e[15]=d,e[16]=m):m=e[16];let p;e[17]!==h||e[18]!==f||e[19]!==m?(p=r.jsxs("div",{className:f,children:[h,m]}),e[17]=h,e[18]=f,e[19]=m,e[20]=p):p=e[20];let g;e[21]!==s||e[22]!==n||e[23]!==a||e[24]!==i?(g=r.jsx(J_,{items:s,open:a,onOpenChange:l,onSelect:i,loadingPrompt:n}),e[21]=s,e[22]=n,e[23]=a,e[24]=i,e[25]=g):g=e[25];let _;return e[26]!==p||e[27]!==g?(_=r.jsxs(Mi,{delayDuration:400,children:[p,g]}),e[26]=p,e[27]=g,e[28]=_):_=e[28],_}function Z_(){return null}function ex(t,e){switch(e.type){case"SELECT_PROMPT":return!e.prompt.arguments||e.prompt.arguments.length===0?{stage:"loading",prompt:e.prompt}:{stage:"idle"};case"START_LOADING":return{stage:"loading",prompt:e.prompt,arguments:e.arguments};case"RESET":return{stage:"idle"};default:return t}}function tx(t){const e=B.c(30),{connectionId:s}=t,{sendMessage:i}=Ui(),{tiptapDocRef:n}=ni(),{org:o}=be();let a;e[0]!==s||e[1]!==o.id?(a={connectionId:s,orgId:o.id},e[0]=s,e[1]=o.id,e[2]=a):a=e[2];const l=Me(a);let c;e[3]!==l?(c={client:l,staleTime:6e4},e[3]=l,e[4]=c):c=e[4];const{data:d}=Dh(c);let u;e[5]!==d?.prompts?(u=d?.prompts??[],e[5]=d?.prompts,e[6]=u):u=e[6];const h=u;let f;e[7]!==h?(f=h.map(sx),e[7]=h,e[8]=f):f=e[8];const m=f;let p;e[9]===Symbol.for("react.memo_cache_sentinel")?(p={stage:"idle"},e[9]=p):p=e[9];const[g,_]=S.useReducer(ex,p),[v,x]=S.useState(null);let b;e[10]!==l||e[11]!==i||e[12]!==n?(b=async(E,R)=>{if(!l){pe.error("MCP client not available"),_({type:"RESET"});return}try{const M=await ul(l,E.name,R);_({type:"RESET"});const L=Y_(n.current,{type:"paragraph",content:[Rp({id:E.name,name:al(E.name,si(E._meta)),metadata:M.messages,char:"/"})]});await i(L)}catch(M){console.error("[ice-breakers] Failed to fetch prompt:",M),pe.error("Failed to load prompt. Please try again."),_({type:"RESET"})}},e[10]=l,e[11]=i,e[12]=n,e[13]=b):b=e[13];const y=b;let C;e[14]!==y?(C=async E=>{if(E.arguments&&E.arguments.length>0){_({type:"SELECT_PROMPT",prompt:E}),x(E);return}_({type:"START_LOADING",prompt:E}),await y(E)},e[14]=y,e[15]=C):C=e[15];const j=C;let V;e[16]!==v||e[17]!==y?(V=async E=>{v&&(_({type:"START_LOADING",prompt:v,arguments:E}),x(null),await y(v,E))},e[16]=v,e[17]=y,e[18]=V):V=e[18];const w=V;if(m.length===0)return null;const k=g.stage==="loading"?g.prompt:null;let T;e[19]!==j||e[20]!==m||e[21]!==k?(T=r.jsx(Q_,{items:m,onSelect:j,loadingPrompt:k}),e[19]=j,e[20]=m,e[21]=k,e[22]=T):T=e[22];let I;e[23]===Symbol.for("react.memo_cache_sentinel")?(I=()=>{x(null),_({type:"RESET"})},e[23]=I):I=e[23];let A;e[24]!==v||e[25]!==w?(A=r.jsx(Rl,{prompt:v,setPrompt:I,onSubmit:w}),e[24]=v,e[25]=w,e[26]=A):A=e[26];let N;return e[27]!==T||e[28]!==A?(N=r.jsxs(r.Fragment,{children:[T,A]}),e[27]=T,e[28]=A,e[29]=N):N=e[29],N}function sx(t){return{prompt:t}}function ix(t){const e=B.c(13),{className:s}=t,{selectedVirtualMcp:i}=ni(),{org:n}=be();let o;e[0]!==n.id?(o=io(n.id),e[0]=n.id,e[1]=o):o=e[1];const a=o.id,l=i?.id??a;let c;e[2]!==s?(c=X("w-full @container",s),e[2]=s,e[3]=c):c=e[3];const d=l??"default";let u;e[4]===Symbol.for("react.memo_cache_sentinel")?(u=r.jsx(Z_,{}),e[4]=u):u=e[4];let h;e[5]!==l?(h=r.jsx(tx,{connectionId:l}),e[5]=l,e[6]=h):h=e[6];let f;e[7]!==d||e[8]!==h?(f=r.jsx(Cs,{fallback:null,children:r.jsx(S.Suspense,{fallback:u,children:h},d)}),e[7]=d,e[8]=h,e[9]=f):f=e[9];let m;return e[10]!==c||e[11]!==f?(m=r.jsx("div",{className:c,children:f}),e[10]=c,e[11]=f,e[12]=m):m=e[12],m}function ju(t){const e=B.c(21),{current:s,total:i,onPrev:n,onNext:o}=t;if(i<=1)return null;const a=s===0,l=s===0?"opacity-30 cursor-not-allowed":"hover:text-foreground cursor-pointer";let c;e[0]!==l?(c=X("p-0.5 rounded transition-colors",l),e[0]=l,e[1]=c):c=e[1];let d;e[2]===Symbol.for("react.memo_cache_sentinel")?(d=r.jsx(xl,{size:14}),e[2]=d):d=e[2];let u;e[3]!==n||e[4]!==a||e[5]!==c?(u=r.jsx("button",{type:"button",onClick:n,disabled:a,className:c,"aria-label":"Previous question",children:d}),e[3]=n,e[4]=a,e[5]=c,e[6]=u):u=e[6];const h=s+1;let f;e[7]!==h||e[8]!==i?(f=r.jsxs("span",{className:"tabular-nums text-xs",children:[h," of ",i]}),e[7]=h,e[8]=i,e[9]=f):f=e[9];const m=s===i-1,p=s===i-1?"opacity-30 cursor-not-allowed":"hover:text-foreground cursor-pointer";let g;e[10]!==p?(g=X("p-0.5 rounded transition-colors",p),e[10]=p,e[11]=g):g=e[11];let _;e[12]===Symbol.for("react.memo_cache_sentinel")?(_=r.jsx(ro,{size:14}),e[12]=_):_=e[12];let v;e[13]!==o||e[14]!==g||e[15]!==m?(v=r.jsx("button",{type:"button",onClick:o,disabled:m,className:g,"aria-label":"Next question",children:_}),e[13]=o,e[14]=g,e[15]=m,e[16]=v):v=e[16];let x;return e[17]!==v||e[18]!==u||e[19]!==f?(x=r.jsxs("div",{className:"flex items-center gap-1 text-sm text-muted-foreground",children:[u,f,v]}),e[17]=v,e[18]=u,e[19]=f,e[20]=x):x=e[20],x}function On(t){const e=B.c(18),{title:s,children:i,footerLeft:n,footerRight:o,className:a}=t,l=a??"border-border";let c;e[0]!==l?(c=X("flex flex-col rounded-xl bg-background border shadow-md w-[calc(100%-16px)] max-w-[584px] mx-auto mb-[-16px]",l),e[0]=l,e[1]=c):c=e[1];let d;e[2]!==s?(d=r.jsx("div",{className:"flex items-center gap-2 p-4",children:r.jsx("p",{className:"flex-1 text-base font-medium text-foreground min-w-0",children:s})}),e[2]=s,e[3]=d):d=e[3];let u;e[4]!==i?(u=r.jsx("div",{className:"overflow-clip pb-4",children:i}),e[4]=i,e[5]=u):u=e[5];let h;e[6]!==n?(h=r.jsx("div",{children:n}),e[6]=n,e[7]=h):h=e[7];let f;e[8]!==o?(f=r.jsx("div",{className:"flex items-center gap-2",children:o}),e[8]=o,e[9]=f):f=e[9];let m;e[10]!==h||e[11]!==f?(m=r.jsx("div",{className:"border-t border-border px-3 py-3 pb-6",children:r.jsxs("div",{className:"flex items-center justify-between",children:[h,f]})}),e[10]=h,e[11]=f,e[12]=m):m=e[12];let p;return e[13]!==c||e[14]!==d||e[15]!==u||e[16]!==m?(p=r.jsxs("div",{className:c,children:[d,u,m]}),e[13]=c,e[14]=d,e[15]=u,e[16]=m,e[17]=p):p=e[17],p}const rx="User denied this tool call, give other alternatives.",nx=[{value:"readonly",label:"Ask before edit"},{value:"auto",label:"Auto approve"}];function ox(t){const e=B.c(9),{onYolo:s}=t,[i,n]=Wi();let o;e[0]!==s||e[1]!==i||e[2]!==n?(o=u=>{const h=u;n({...i,toolApprovalLevel:h}),h==="auto"&&s()},e[0]=s,e[1]=i,e[2]=n,e[3]=o):o=e[3];const a=o;let l;e[4]===Symbol.for("react.memo_cache_sentinel")?(l=r.jsx(Zs,{size:"xs",className:"text-xs text-muted-foreground border-border/60 bg-transparent hover:bg-accent/60 h-7 gap-1",onClick:lx,children:r.jsx(ei,{})}),e[4]=l):l=e[4];let c;e[5]===Symbol.for("react.memo_cache_sentinel")?(c=r.jsx(Js,{children:nx.map(ax)}),e[5]=c):c=e[5];let d;return e[6]!==a||e[7]!==i.toolApprovalLevel?(d=r.jsxs(Qs,{value:i.toolApprovalLevel,onValueChange:a,children:[l,c]}),e[6]=a,e[7]=i.toolApprovalLevel,e[8]=d):d=e[8],d}function ax(t){return r.jsx(Ht,{value:t.value,children:t.label},t.value)}function lx(t){return t.stopPropagation()}function cx(t){const e=B.c(5),{input:s}=t;if(s==null){let o;return e[0]===Symbol.for("react.memo_cache_sentinel")?(o=r.jsx("div",{className:"px-4 text-xs text-muted-foreground",children:"No input"}),e[0]=o):o=e[0],o}let i;try{let o;e[1]!==s?(o=JSON.stringify(s,null,2),e[1]=s,e[2]=o):o=e[2],i=o}catch{i=String(s)}let n;return e[3]!==i?(n=r.jsx("div",{className:"px-4",children:r.jsx("pre",{className:"text-xs font-mono text-muted-foreground/70 whitespace-pre-wrap wrap-break-word max-h-32 overflow-y-auto rounded-md bg-muted/30 px-3 py-2",children:i})}),e[3]=i,e[4]=n):n=e[4],n}function dx(t){const e=B.c(42),{approvals:s,onRespond:i}=t,[n,o]=S.useState(0),a=Math.min(n,s.length-1),l=s[a];if(!l)return null;let c;e[0]!==l.approvalId||e[1]!==i?(c=()=>{i(l.approvalId,!1,rx)},e[0]=l.approvalId,e[1]=i,e[2]=c):c=e[2];const d=c;let u;e[3]!==l.approvalId||e[4]!==i?(u=()=>{i(l.approvalId,!0)},e[3]=l.approvalId,e[4]=i,e[5]=u):u=e[5];const h=u;let f;e[6]!==s||e[7]!==i?(f=()=>{for(const N of s)i(N.approvalId,!0)},e[6]=s,e[7]=i,e[8]=f):f=e[8];const m=f;let p;e[9]!==a?(p=()=>{a>0&&o(a-1)},e[9]=a,e[10]=p):p=e[10];const g=p;let _;e[11]!==s.length||e[12]!==a?(_=()=>{a<s.length-1&&o(a+1)},e[11]=s.length,e[12]=a,e[13]=_):_=e[13];const v=_;let x;e[14]!==m?(x=r.jsx(ox,{onYolo:m}),e[14]=m,e[15]=x):x=e[15];let b;e[16]!==s.length||e[17]!==v||e[18]!==g||e[19]!==a?(b=r.jsx(ju,{current:a,total:s.length,onPrev:g,onNext:v}),e[16]=s.length,e[17]=v,e[18]=g,e[19]=a,e[20]=b):b=e[20];let y;e[21]!==x||e[22]!==b?(y=r.jsxs("div",{className:"flex items-center gap-2",children:[x,b]}),e[21]=x,e[22]=b,e[23]=y):y=e[23];const C=y;let j;e[24]!==d?(j=r.jsx(ne,{type:"button",variant:"ghost",size:"sm",className:"h-7 px-2.5 text-xs text-muted-foreground [@media(hover:hover)]:hover:text-foreground active:scale-[0.97] transition-transform",onClick:d,children:"Deny"}),e[24]=d,e[25]=j):j=e[25];let V;e[26]!==s.length||e[27]!==m?(V=s.length>1&&r.jsx(ne,{type:"button",variant:"outline",size:"sm",className:"h-7 px-2.5 text-xs active:scale-[0.97] transition-transform",onClick:m,children:"Accept All"}),e[26]=s.length,e[27]=m,e[28]=V):V=e[28];let w;e[29]!==h?(w=r.jsx(ne,{type:"button",size:"sm",className:"h-7 px-2.5 text-xs active:scale-[0.97] transition-transform",onClick:h,children:"Accept"}),e[29]=h,e[30]=w):w=e[30];let k;e[31]!==V||e[32]!==w||e[33]!==j?(k=r.jsxs(r.Fragment,{children:[j,V,w]}),e[31]=V,e[32]=w,e[33]=j,e[34]=k):k=e[34];const T=k;let I;e[35]!==l.input?(I=r.jsx(cx,{input:l.input}),e[35]=l.input,e[36]=I):I=e[36];let A;return e[37]!==l.friendlyName||e[38]!==C||e[39]!==T||e[40]!==I?(A=r.jsx(On,{title:l.friendlyName,footerLeft:C,footerRight:T,children:I}),e[37]=l.friendlyName,e[38]=C,e[39]=T,e[40]=I,e[41]=A):A=e[41],A}function hx(){const t=B.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=r.jsxs("div",{className:"flex items-center gap-2 p-4 border border-dashed rounded-lg bg-accent/50 w-[calc(100%-16px)] max-w-[584px] mx-auto mb-2",children:[r.jsx(ug,{className:"size-5 text-muted-foreground shimmer"}),r.jsx("span",{className:"text-sm text-muted-foreground shimmer",children:"Preparing approval request..."})]}),t[0]=e):e=t[0],e}function ux(t){const e=B.c(4),{approvals:s,isStreaming:i,onRespond:n}=t;if(i&&s.length===0){let a;return e[0]===Symbol.for("react.memo_cache_sentinel")?(a=r.jsx(hx,{}),e[0]=a):a=e[0],a}if(s.length===0)return null;let o;return e[1]!==s||e[2]!==n?(o=r.jsx(dx,{approvals:s,onRespond:n}),e[1]=s,e[2]=n,e[3]=o):o=e[3],o}function fx(t){const e=[];for(const s of t)if("state"in s&&s.state==="approval-requested"&&"approval"in s&&s.approval?.id&&"toolCallId"in s&&s.toolCallId){const i="toolName"in s&&typeof s.toolName=="string"?s.toolName:s.type.startsWith("tool-")?s.type.replace("tool-",""):"Tool";e.push({approvalId:s.approval.id,toolCallId:s.toolCallId,toolName:i,friendlyName:Tp(Dp(i)),input:s.input})}return e}function mx(t){const e=B.c(15),{plan:s,onApprove:i,onDismiss:n}=t;let o;e[0]!==i||e[1]!==s.plan?(o=()=>{i(s.plan)},e[0]=i,e[1]=s.plan,e[2]=o):o=e[2];const a=o;let l;e[3]!==n?(l=r.jsx(ne,{type:"button",variant:"ghost",size:"sm",className:"h-7 px-2.5 text-xs text-muted-foreground [@media(hover:hover)]:hover:text-foreground active:scale-[0.97] transition-transform",onClick:n,children:"Keep iterating"}),e[3]=n,e[4]=l):l=e[4];let c;e[5]!==a?(c=r.jsx(ne,{type:"button",size:"sm",className:"h-7 px-2.5 text-xs bg-purple-600 hover:bg-purple-700 text-white active:scale-[0.97] transition-transform",onClick:a,children:"Let's go"}),e[5]=a,e[6]=c):c=e[6];let d;e[7]!==l||e[8]!==c?(d=r.jsxs(r.Fragment,{children:[l,c]}),e[7]=l,e[8]=c,e[9]=d):d=e[9];const u=d;let h;e[10]!==s.plan?(h=r.jsx("div",{className:"px-4 max-h-64 overflow-y-auto",children:r.jsx("div",{className:"prose prose-sm max-w-none text-sm",children:r.jsx(Mp,{id:"plan-preview",part:{type:"text",text:s.plan}})})}),e[10]=s.plan,e[11]=h):h=e[11];let f;return e[12]!==u||e[13]!==h?(f=r.jsx(On,{title:"Implementation Plan",footerRight:u,className:"border-dashed border-purple-500",children:h}),e[12]=u,e[13]=h,e[14]=f):f=e[14],f}function px(){const t=B.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=r.jsxs("div",{className:"flex items-center gap-2 p-4 border border-dashed border-purple-500/30 rounded-lg bg-purple-500/5 w-[calc(100%-16px)] max-w-[584px] mx-auto mb-2",children:[r.jsx(Jt,{className:"size-5 text-purple-500 shimmer"}),r.jsx("span",{className:"text-sm text-muted-foreground shimmer",children:"Preparing plan..."})]}),t[0]=e):e=t[0],e}function gx(t){const e=B.c(7),{plans:s,isStreaming:i,onApprove:n,onDismiss:o}=t;if(i&&s.length===0){let d;return e[0]===Symbol.for("react.memo_cache_sentinel")?(d=r.jsx(px,{}),e[0]=d):d=e[0],d}let a;e[1]!==s?(a=s.at(-1),e[1]=s,e[2]=a):a=e[2];const l=a;if(!l)return null;let c;return e[3]!==l||e[4]!==n||e[5]!==o?(c=r.jsx(mx,{plan:l,onApprove:n,onDismiss:o}),e[3]=l,e[4]=n,e[5]=o,e[6]=c):c=e[6],c}function _x(t){const e=[];for(const s of t)if("type"in s&&s.type==="tool-propose_plan"&&"state"in s&&s.state==="input-available"&&"toolCallId"in s&&"input"in s){const i=s.input;e.push({toolCallId:s.toolCallId,plan:i.plan,state:s.state})}return e}const Nc=Vs({response:Et().min(1,"Response is required")}),xx=Vs({response:Et().min(1,"Please select or enter an option")}),vx=Vs({response:zm(["yes","no"])});function bx(t){switch(t.type){case"text":return Nc;case"choice":return xx;case"confirm":return vx;default:return Nc}}function yx(t){const e={};for(const s of t)e[s.toolCallId]=bx(s.input);return Vs(e)}function Sx(t){const e=B.c(6),{control:s,name:i,placeholder:n}=t;let o;e[0]!==n?(o=l=>{const{field:c}=l;return r.jsxs(Rt,{children:[r.jsx(Tt,{children:r.jsx("div",{className:"px-2",children:r.jsxs("div",{className:"flex items-center gap-3 px-2 py-3 rounded-lg bg-accent/50",children:[r.jsx("span",{className:"flex items-center justify-center size-6 rounded-md bg-muted shrink-0",children:r.jsx($h,{size:16,className:"text-muted-foreground"})}),r.jsx("input",{...c,type:"text",placeholder:n||"Type your response...",autoFocus:!0,"aria-label":"Text response input",className:"flex-1 text-sm bg-transparent outline-none placeholder:text-foreground/25 text-foreground min-w-0"})]})})}),r.jsx(Dt,{})]})},e[0]=n,e[1]=o):o=e[1];let a;return e[2]!==s||e[3]!==i||e[4]!==o?(a=r.jsx(It,{control:s,name:i,render:o}),e[2]=s,e[3]=i,e[4]=o,e[5]=a):a=e[5],a}function ku(t,e){const s=B.c(4);let i,n;s[0]!==t||s[1]!==e?(i=()=>{const o=a=>{const l=a.target.tagName;if(l==="INPUT"||l==="TEXTAREA"||a.metaKey||a.ctrlKey||a.altKey)return;const c=Number.parseInt(a.key,10);c>=1&&c<=t&&(a.preventDefault(),e(c-1))};return document.addEventListener("keydown",o),()=>document.removeEventListener("keydown",o)},n=[t,e],s[0]=t,s[1]=e,s[2]=i,s[3]=n):(i=s[2],n=s[3]),S.useEffect(i,n)}function wx(t){const e=B.c(9),{control:s,name:i,options:n}=t,[o,a]=S.useState(!1),l=S.useRef(null),c=S.useRef(null);let d;if(e[0]!==n?(d=f=>{c.current?.onChange(n[f]??""),a(!1)},e[0]=n,e[1]=d):d=e[1],ku(n.length,d),n.length===0)return null;let u;e[2]!==o||e[3]!==n?(u=f=>{const{field:m}=f;c.current=m;const p=o||!!m.value&&!n.includes(m.value);return r.jsxs(Rt,{children:[r.jsx(Tt,{children:r.jsxs("div",{className:"flex flex-col px-2",role:"group","aria-label":"Choice options",children:[n.map((g,_)=>{const v=m.value===g;return r.jsxs("button",{type:"button",onClick:()=>{m.onChange(g??""),a(!1)},className:X("flex items-center gap-3 px-2 py-3 rounded-lg text-left transition-colors w-full",v&&"bg-accent/50",!v&&"hover:bg-accent/30"),"aria-label":`Select ${g}`,children:[r.jsx("span",{className:X("flex items-center justify-center size-6 rounded-md text-sm shrink-0",v?"bg-chart-1 text-white":"bg-muted text-foreground"),children:_+1}),r.jsx("span",{className:"text-sm text-foreground truncate",children:g})]},`${_}-${g}`)}),r.jsxs("div",{className:X("flex items-center gap-3 px-2 py-3 rounded-lg transition-colors w-full cursor-text",p&&"bg-accent/50",!p&&"hover:bg-accent/30"),onClick:()=>{a(!0),n.includes(m.value)&&m.onChange(""),setTimeout(()=>l.current?.focus(),0)},children:[r.jsx("span",{className:"flex items-center justify-center size-6 rounded-md bg-muted shrink-0",children:r.jsx($h,{size:16,className:"text-muted-foreground"})}),p?r.jsx("input",{ref:l,type:"text",value:m.value,onChange:g=>m.onChange(g.target.value),placeholder:"Something else...",autoFocus:!0,"aria-label":"Custom choice input",className:"flex-1 text-sm bg-transparent outline-none placeholder:text-foreground/25 text-foreground min-w-0"}):r.jsx("span",{className:"text-sm text-foreground/25",children:"Something else..."})]})]})}),r.jsx(Dt,{})]})},e[2]=o,e[3]=n,e[4]=u):u=e[4];let h;return e[5]!==s||e[6]!==i||e[7]!==u?(h=r.jsx(It,{control:s,name:i,render:u}),e[5]=s,e[6]=i,e[7]=u,e[8]=h):h=e[8],h}function Vx(t){const e=B.c(6),{control:s,name:i}=t;let n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=["yes","no"],e[0]=n):n=e[0];const o=n,a=S.useRef(null);let l;e[1]===Symbol.for("react.memo_cache_sentinel")?(l=u=>{a.current?.onChange(o[u]??"")},e[1]=l):l=e[1],ku(o.length,l);let c;e[2]===Symbol.for("react.memo_cache_sentinel")?(c=u=>{const{field:h}=u;return a.current=h,r.jsxs(Rt,{children:[r.jsx(Tt,{children:r.jsx("div",{className:"flex gap-2 px-2",role:"group","aria-label":"Confirmation options",children:o.map(f=>{const m=h.value===f;return r.jsxs("button",{type:"button",onClick:()=>h.onChange(f),className:X("flex items-center gap-3 px-4 py-3 rounded-lg text-left transition-colors flex-1",m&&"bg-accent/50",!m&&"hover:bg-accent/30"),"aria-label":`Confirm ${f}`,children:[r.jsx("span",{className:X("flex items-center justify-center size-6 rounded-md text-sm shrink-0",m?"bg-chart-1 text-white":"bg-muted text-foreground"),children:f==="yes"?1:2}),r.jsx("span",{className:"text-sm text-foreground capitalize",children:f})]},f)})})}),r.jsx(Dt,{})]})},e[2]=c):c=e[2];let d;return e[3]!==s||e[4]!==i?(d=r.jsx(It,{control:s,name:i,render:c}),e[3]=s,e[4]=i,e[5]=d):d=e[5],d}function Ac(t){const e=B.c(13),{input:s,control:i,name:n}=t;switch(s.type){case"text":{let o;return e[0]!==i||e[1]!==s.default||e[2]!==n?(o=r.jsx(Sx,{control:i,name:n,placeholder:s.default}),e[0]=i,e[1]=s.default,e[2]=n,e[3]=o):o=e[3],o}case"choice":{let o;e[4]!==s.options?(o=s.options?.filter(Boolean)??[],e[4]=s.options,e[5]=o):o=e[5];const a=o;let l;return e[6]!==i||e[7]!==n||e[8]!==a?(l=r.jsx(wx,{control:i,name:n,options:a}),e[6]=i,e[7]=n,e[8]=a,e[9]=l):l=e[9],l}case"confirm":{let o;return e[10]!==i||e[11]!==n?(o=r.jsx(Vx,{control:i,name:n}),e[10]=i,e[11]=n,e[12]=o):o=e[12],o}default:return null}}function Cx({parts:t,onSubmit:e}){const[s,i]=S.useState(t[0]?.toolCallId??""),n=yx(t.map(x=>({toolCallId:x.toolCallId,input:x.input}))),o=Hi({resolver:Or(n),defaultValues:Object.fromEntries(t.map(x=>[x.toolCallId,{response:""}]))}),a=o.watch(),l=t.findIndex(x=>x.toolCallId===s),c=!!a[s]?.response,d=t.every(x=>!!a[x.toolCallId]?.response),u=x=>{for(const b of t){const y=x[b.toolCallId]?.response;y&&e(b,y)}},h=x=>t.find(b=>!x[b.toolCallId]?.response&&b.toolCallId!==s)??null,f=()=>{const x=o.getValues();if(t.every(y=>!!x[y.toolCallId]?.response))o.handleSubmit(u)();else{const y=h(x);y&&i(y.toolCallId)}},m=()=>{o.setValue(`${s}.response`,"user has skip this question"),f()},p=()=>{if(l>0){const x=t[l-1];x&&i(x.toolCallId)}},g=()=>{if(l<t.length-1){const x=t[l+1];x&&i(x.toolCallId)}},_=r.jsxs(r.Fragment,{children:[r.jsx(ne,{type:"button",variant:"outline",size:"sm",onClick:m,className:"h-7",children:"Skip"}),r.jsx(ne,{type:"button",size:"sm",disabled:!c,onClick:f,className:X("h-7",c?"":"opacity-50"),children:d?"Submit":"Next"})]}),v=r.jsx(ju,{current:l,total:t.length,onPrev:p,onNext:g});if(t.length===1){const x=t[0];return x?.input?r.jsx(Pi,{...o,children:r.jsx("form",{onSubmit:o.handleSubmit(u),autoComplete:"off",children:r.jsx(On,{title:x.input?.prompt??"Question",footerRight:_,children:r.jsx(Ac,{input:x.input,control:o.control,name:`${x.toolCallId}.response`})})})}):null}return r.jsx(Pi,{...o,children:r.jsx("form",{onSubmit:o.handleSubmit(u),autoComplete:"off",children:r.jsx(Mh,{value:s,onValueChange:i,children:t.map(x=>r.jsx(yn,{value:x.toolCallId,className:"mt-0",children:r.jsx(On,{title:x.input?.prompt??"Question",footerLeft:v,footerRight:_,children:r.jsx(Ac,{input:x.input,control:o.control,name:`${x.toolCallId}.response`})})},x.toolCallId))})})})}function jx(){const t=B.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=r.jsxs("div",{className:"flex items-center gap-2 p-4 border border-dashed rounded-lg bg-accent/50 w-[calc(100%-16px)] max-w-[584px] mx-auto mb-2",children:[r.jsx(Pg,{className:"size-5 text-muted-foreground shimmer"}),r.jsx("span",{className:"text-sm text-muted-foreground shimmer",children:"Preparing question..."})]}),t[0]=e):e=t[0],e}function Nu(t){const e=B.c(6),{userAskParts:s,isStreaming:i,onSubmit:n}=t;let o;e[0]!==s?(o=s.filter(kx),e[0]=s,e[1]=o):o=e[1];const a=o;if(i){let c;return e[2]===Symbol.for("react.memo_cache_sentinel")?(c=r.jsx(jx,{}),e[2]=c):c=e[2],c}if(a.length===0)return null;let l;return e[3]!==n||e[4]!==a?(l=r.jsx(Cx,{parts:a,onSubmit:n}),e[3]=n,e[4]=a,e[5]=l):l=e[5],l}function kx(t){return t.state==="input-available"}const Ec=new Map;function co(){const{org:t}=be(),e=Me({connectionId:Wt,orgId:t.id}),s=bl(),i=s.find(_=>_.providerId==="deco"),{data:n,isLoading:o,refetch:a,isFetching:l}=Fi({queryKey:lt.aiProviderCredits(t.id,"deco"),enabled:!!i,staleTime:6e4,queryFn:async()=>{const _=await e.callTool({name:"AI_PROVIDER_CREDITS",arguments:{providerId:"deco"}});return _?.isError?null:_.structuredContent??null}}),c=n?.balanceCents??null,d=c!=null?c/100:null,u=S.useRef(new Map);if(c!=null){const _=Ec.get(t.id);u.current.get(t.id)&&_!=null&&c>_&&se("credits_topped_up_detected",{organization_id:t.id,delta_cents:c-_,previous_balance_cents:_,new_balance_cents:c}),Ec.set(t.id,c),u.current.set(t.id,!0)}const h=!!i,f=c!=null&&c>0,m=c!=null&&c===0,p=c!=null&&c===200,g=s.length>0&&s.every(_=>_.providerId==="deco");return{hasDecoKey:h,decoKeyId:i?.id??null,balanceCents:c,balanceDollars:d,hasCredits:f,isZeroBalance:m,isInitialFreeCredit:p,hasOnlyDecoProvider:g,isLoading:o,isFetching:l,refetch:a}}function Nx(t){return t?t.message.startsWith("[CREDITS]"):!1}const Ax={usd:[{dollars:10,label:"Starter"},{dollars:20,label:"Popular"},{dollars:100,label:"Best value"}],brl:[{dollars:50,label:"Starter"},{dollars:100,label:"Popular"},{dollars:500,label:"Best value"}]},Ex=["Access to 100+ AI models","Unified API, no separate keys needed","Pay only for what you use"];function Au(t){const e=B.c(43),{onDismiss:s}=t,{org:i}=be(),n=Ke(),{decoKeyId:o}=co();let a;e[0]!==i.id?(a={connectionId:Wt,orgId:i.id},e[0]=i.id,e[1]=a):a=e[1];const l=Me(a),[c,d]=S.useState(""),[u,h]=S.useState(!1),[f,m]=S.useState("usd"),p=f==="brl"?"R$":"$";let g,_;e[2]!==i.id?(g=()=>{se("credits_exhausted_shown",{organization_id:i.id})},_=[i.id],e[2]=i.id,e[3]=g,e[4]=_):(g=e[3],_=e[4]),S.useEffect(g,_);let v;e[5]!==l||e[6]!==f?(v=async D=>{const P=await l.callTool({name:"AI_PROVIDER_TOPUP_URL",arguments:{providerId:"deco",amountCents:D,currency:f}});if(P?.isError)throw new Error(P.content?.[0]?.text??"Failed to get top-up URL");return P.structuredContent?.url},e[5]=l,e[6]=f,e[7]=v):v=e[7];let x;e[8]!==s?(x=D=>{D&&window.open(D,"_blank","noopener,noreferrer"),s?.()},e[8]=s,e[9]=x):x=e[9];let b;e[10]!==v||e[11]!==x?(b={mutationFn:v,onSuccess:x,onError:Tx},e[10]=v,e[11]=x,e[12]=b):b=e[12];const{mutate:y,isPending:C}=Br(b),j=parseFloat(c),V=!isNaN(j)&&j>=1;let w;e[13]!==s?(w=D=>!D&&s?.(),e[13]=s,e[14]=w):w=e[14];let k;e[15]===Symbol.for("react.memo_cache_sentinel")?(k=["radial-gradient(ellipse 40% 200% at -5% 100%, rgba(165,149,255,0.5) 0%, transparent 100%)","radial-gradient(ellipse 40% 200% at 105% -10%, rgba(208,236,26,0.45) 0%, transparent 100%)"],e[15]=k):k=e[15];let T;e[16]===Symbol.for("react.memo_cache_sentinel")?(T=r.jsx("div",{className:"absolute inset-x-0 top-0 h-36 pointer-events-none",style:{backgroundImage:k.join(", "),maskImage:"linear-gradient(to bottom, black 0%, transparent 100%)",WebkitMaskImage:"linear-gradient(to bottom, black 0%, transparent 100%)"}}),e[16]=T):T=e[16];let I;e[17]===Symbol.for("react.memo_cache_sentinel")?(I=r.jsxs("div",{className:"relative px-8 pt-8 pb-2 overflow-hidden",children:[T,r.jsxs(Ds,{className:"relative gap-4",children:[r.jsx("img",{src:"/logos/deco%20logo.svg",alt:"Deco AI Gateway",className:"size-9 rounded-lg object-contain dark:bg-white dark:p-0.5"}),r.jsxs("div",{children:[r.jsx(Ts,{className:"text-xl font-semibold tracking-tight",children:"Top up to keep building"}),r.jsx(dl,{className:"mt-1.5 text-sm leading-relaxed",children:"Your credits are used up. Add more to continue using AI across all your agents."})]})]})]}),e[17]=I):I=e[17];let A;e[18]!==f||e[19]!==p||e[20]!==c||e[21]!==j||e[22]!==o||e[23]!==V||e[24]!==C||e[25]!==u||e[26]!==y?(A=o&&r.jsxs("div",{className:"px-8 pt-5 pb-6",children:[r.jsx("div",{className:"mb-4",children:r.jsxs(eu,{type:"single",variant:"outline",size:"sm",value:f,onValueChange:D=>{D&&m(D)},children:[r.jsx(Ln,{value:"usd",className:"h-8 px-3 text-xs",children:"USD"}),r.jsx(Ln,{value:"brl",className:"h-8 px-3 text-xs",children:"BRL"})]})}),r.jsxs("div",{className:"rounded-xl border border-border p-5",children:[r.jsx("div",{className:"grid grid-cols-3 gap-2.5",children:Ax[f].map(D=>{const{dollars:P,label:O}=D;return r.jsxs("button",{type:"button",disabled:C,onClick:()=>{se("credits_topup_clicked",{amount_cents:P*100,currency:f,tier_label:O,source:"exhausted_banner"}),y(P*100)},className:X("relative flex flex-col items-center gap-1 py-5 rounded-xl border transition-all duration-150 cursor-pointer","disabled:opacity-50 disabled:cursor-wait","border-border hover:border-foreground/20 hover:bg-muted/30"),children:[r.jsxs("span",{className:"text-2xl font-semibold tabular-nums text-foreground",children:[p,P]}),r.jsx("span",{className:"text-xs text-muted-foreground",children:O})]},P)})}),u?r.jsxs("div",{className:"flex gap-2 mt-3",children:[r.jsxs("div",{className:"relative flex-1",children:[r.jsx("span",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-sm text-muted-foreground select-none",children:p}),r.jsx(bt,{type:"number",min:"1",step:"1",placeholder:"50",value:c,onChange:D=>d(D.target.value),className:"h-10 text-sm pl-7",autoFocus:!0})]}),r.jsx(ne,{className:"h-10",disabled:!V||C,onClick:()=>{se("credits_topup_clicked",{amount_cents:Math.round(j*100),currency:f,tier_label:"custom",source:"exhausted_banner"}),y(Math.round(j*100))},children:C?"Opening...":"Add"})]}):r.jsx("button",{type:"button",className:"w-full mt-3 text-xs text-muted-foreground hover:text-foreground transition-colors py-1",onClick:()=>h(!0),children:"Enter custom amount"})]}),r.jsx("div",{className:"mt-5 rounded-xl bg-muted/25 border border-border/50 p-4 space-y-3",children:Ex.map(Ix)})]}),e[18]=f,e[19]=p,e[20]=c,e[21]=j,e[22]=o,e[23]=V,e[24]=C,e[25]=u,e[26]=y,e[27]=A):A=e[27];let N;e[28]!==s?(N=r.jsx(ne,{variant:"ghost",size:"sm",onClick:s,children:"Dismiss"}),e[28]=s,e[29]=N):N=e[29];let E;e[30]!==n||e[31]!==s||e[32]!==i.slug?(E=r.jsx("button",{type:"button",className:"text-xs text-muted-foreground hover:text-foreground transition-colors",onClick:()=>{n({to:"/$org/settings/ai-providers",params:{org:i.slug}}),s?.()},children:"Manage providers"}),e[30]=n,e[31]=s,e[32]=i.slug,e[33]=E):E=e[33];let R;e[34]!==N||e[35]!==E?(R=r.jsxs("div",{className:"px-8 py-4 border-t border-border bg-muted/30 flex items-center justify-between",children:[N,E]}),e[34]=N,e[35]=E,e[36]=R):R=e[36];let M;e[37]!==A||e[38]!==R?(M=r.jsxs(ms,{className:"sm:max-w-[520px] gap-0 p-0 overflow-hidden",onOpenAutoFocus:Rx,children:[I,A,R]}),e[37]=A,e[38]=R,e[39]=M):M=e[39];let L;return e[40]!==M||e[41]!==w?(L=r.jsx(ps,{open:!0,onOpenChange:w,children:M}),e[40]=M,e[41]=w,e[42]=L):L=e[42],L}function Ix(t){return r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("div",{className:"flex items-center justify-center size-5 rounded-full bg-[hsl(var(--chart-1))]/15 shrink-0",children:r.jsx(Jt,{size:12,className:"text-[hsl(var(--chart-1))]"})}),r.jsx("span",{className:"text-sm text-foreground/80",children:t})]},t)}function Rx(t){return t.preventDefault()}function Tx(t){pe.error(`Top-up failed: ${t.message}`)}const Dx={length:"Response reached the model's output limit. Different models have different limits. Try switching models or asking it to continue.","content-filter":"Response was filtered due to content policy.","tool-calls":"Response paused after tool execution to prevent infinite loops and save costs. Click continue to keep working."};function $n(t){const e=B.c(32),{variant:s,onDismiss:i}=t,n=s==="error",o=n?"Error occurred":"Response incomplete",a=n?t.error.message:Dx[t.finishReason]??`Response stopped unexpectedly: ${t.finishReason}`,l=n?"border-destructive/30 bg-destructive/5":"border-amber-500/30 bg-amber-500/5",c=n?"text-destructive":"text-amber-600 dark:text-amber-500",d=n?ri:yh;let u;e[0]!==l?(u=X("flex items-start gap-2 px-3 py-2.5 rounded-lg border border-dashed text-sm w-full mb-2 shadow",l),e[0]=l,e[1]=u):u=e[1];let h;e[2]!==c?(h=X("mt-0.5 shrink-0",c),e[2]=c,e[3]=h):h=e[3];let f;e[4]!==d?(f=r.jsx(d,{size:16}),e[4]=d,e[5]=f):f=e[5];let m;e[6]!==h||e[7]!==f?(m=r.jsx("div",{className:h,children:f}),e[6]=h,e[7]=f,e[8]=m):m=e[8];let p;e[9]!==c?(p=X("text-xs mb-1 font-medium",c),e[9]=c,e[10]=p):p=e[10];let g;e[11]!==p||e[12]!==o?(g=r.jsx("div",{className:p,children:o}),e[11]=p,e[12]=o,e[13]=g):g=e[13];let _;e[14]!==a?(_=r.jsx("div",{className:"text-xs line-clamp-2 text-muted-foreground mb-2",children:a}),e[14]=a,e[15]=_):_=e[15];let v;e[16]!==n||e[17]!==t.onContinue||e[18]!==t.onFixInChat?(v=r.jsx("div",{className:"flex gap-2",children:n?r.jsxs(r.Fragment,{children:[r.jsx(ne,{size:"sm",variant:"outline",onClick:t.onFixInChat,className:"h-7 text-xs",children:"Fix in chat"}),r.jsx(ne,{size:"sm",variant:"outline",disabled:!0,className:"h-7 text-xs",children:"Report"})]}):r.jsx(ne,{size:"sm",variant:"outline",onClick:t.onContinue,className:"h-7 text-xs",children:"Continue"})}),e[16]=n,e[17]=t.onContinue,e[18]=t.onFixInChat,e[19]=v):v=e[19];let x;e[20]!==g||e[21]!==_||e[22]!==v?(x=r.jsxs("div",{className:"flex-1 min-w-0",children:[g,_,v]}),e[20]=g,e[21]=_,e[22]=v,e[23]=x):x=e[23];let b;e[24]===Symbol.for("react.memo_cache_sentinel")?(b=r.jsx(fi,{size:14}),e[24]=b):b=e[24];let y;e[25]!==i?(y=r.jsx("button",{type:"button",onClick:i,className:"text-muted-foreground hover:text-foreground transition-colors shrink-0",title:"Dismiss",children:b}),e[25]=i,e[26]=y):y=e[26];let C;return e[27]!==u||e[28]!==y||e[29]!==m||e[30]!==x?(C=r.jsx("div",{className:"px-0.5",children:r.jsxs("div",{className:u,children:[m,x,y]})}),e[27]=u,e[28]=y,e[29]=m,e[30]=x,e[31]=C):C=e[31],C}function ho(){const t=B.c(41),{error:e,clearError:s,finishReason:i,clearFinishReason:n,messages:o,isStreaming:a,isWaitingForApprovals:l,addToolOutput:c,addToolApprovalResponse:d,sendMessage:u}=Ui(),[h,f]=Wi(),{virtualMcpId:m,createTaskWithMessage:p}=es();let g,_,v,x;if(t[0]!==o){const R=o.at(-1);x=R?.role==="assistant"?R.parts.filter(Lx):null,g=x?.filter(Px)?.length,_=R?.role==="assistant"?_x(R.parts):[],v=R?.role==="assistant"?fx(R.parts):[],t[0]=o,t[1]=g,t[2]=_,t[3]=v,t[4]=x}else g=t[1],_=t[2],v=t[3],x=t[4];const b=v;let y;t[5]!==e||t[6]!==u?(y=()=>{if(e){const M={type:"doc",content:[{type:"paragraph",content:[{type:"text",text:`I encountered this error: ${e.message}. Can you help me fix it?`}]}]};u(M)}},t[5]=e,t[6]=u,t[7]=y):y=t[7];const C=y;let j;t[8]!==u?(j=()=>{u({type:"doc",content:[{type:"paragraph",content:[{type:"text",text:"Please continue."}]}]})},t[8]=u,t[9]=j):j=t[9];const V=j;let w;t[10]!==c?(w=(R,M)=>{c({tool:"user_ask",toolCallId:R.toolCallId,output:{response:M}})},t[10]=c,t[11]=w):w=t[11];const k=w;let T;t[12]!==p||t[13]!==h||t[14]!==f||t[15]!==m?(T=R=>{f({...h,toolApprovalLevel:"auto"}),p({virtualMcpId:m,message:{parts:[{type:"text",text:`Implement this plan:
3
3
 
4
4
  ${R}`}]}})},t[12]=p,t[13]=h,t[14]=f,t[15]=m,t[16]=T):T=t[16];const I=T,A=Mx;let N;t[17]!==d?(N=(R,M,L)=>{d({id:R,approved:M,...L?{reason:L}:{}})},t[17]=d,t[18]=N):N=t[18];const E=N;if(g){let R;return t[19]!==k||t[20]!==a||t[21]!==x?(R=r.jsx("div",{className:"absolute bottom-full left-0 right-0",children:r.jsx(Nu,{userAskParts:x,isStreaming:a,onSubmit:k})}),t[19]=k,t[20]=a,t[21]=x,t[22]=R):R=t[22],R}if(_.length>0){let R;return t[23]!==I||t[24]!==a||t[25]!==_?(R=r.jsx("div",{className:"absolute bottom-full left-0 right-0",children:r.jsx(gx,{plans:_,isStreaming:a,onApprove:I,onDismiss:A})}),t[23]=I,t[24]=a,t[25]=_,t[26]=R):R=t[26],R}if(b.length>0||a&&l){let R;return t[27]!==E||t[28]!==a||t[29]!==b?(R=r.jsx("div",{className:"absolute bottom-full left-0 right-0",children:r.jsx(ux,{approvals:b,isStreaming:a,onRespond:E})}),t[27]=E,t[28]=a,t[29]=b,t[30]=R):R=t[30],R}if(!a&&e){if(Nx(e)){let M;return t[31]!==s?(M=r.jsx(Au,{onDismiss:s}),t[31]=s,t[32]=M):M=t[32],M}let R;return t[33]!==s||t[34]!==e||t[35]!==C?(R=r.jsx("div",{className:"absolute bottom-full left-0 right-0 bg-background",children:r.jsx($n,{variant:"error",error:e,onDismiss:s,onFixInChat:C})}),t[33]=s,t[34]=e,t[35]=C,t[36]=R):R=t[36],R}if(!a&&i&&i!=="stop"&&!l){let R;return t[37]!==n||t[38]!==i||t[39]!==V?(R=r.jsx("div",{className:"absolute bottom-full left-0 right-0 bg-background",children:r.jsx($n,{variant:"warning",finishReason:i,onDismiss:n,onContinue:V})}),t[37]=n,t[38]=i,t[39]=V,t[40]=R):R=t[40],R}return null}function Mx(){document.querySelector("[data-chat-input]")?.focus()}function Px(t){return t.state!=="output-available"}function Lx(t){return t.type==="tool-user_ask"}ho.Error=function(e){return r.jsx($n,{variant:"error",error:e.error,onDismiss:e.onDismiss,onFixInChat:e.onFixInChat})};ho.Warning=function(e){return r.jsx($n,{variant:"warning",finishReason:e.finishReason,onDismiss:e.onDismiss,onContinue:e.onContinue})};ho.UserAskQuestion=Nu;async function Tl(t,e,s,i){if(!no(e)){pe.error("Selected model does not support file uploads");return}const n=s.type||"application/octet-stream";if(!Fg(n,e)){const a=su(e),l=e?.title??"This model";pe.error(`"${s.name}" can't be attached`,{description:`${l} accepts ${a}. PowerPoint, Word, and Excel files aren't supported yet.`});return}const o=10*1024*1024;if(s.size>o){pe.error(`File "${s.name}" exceeds 10MB limit`);return}try{const a=new FileReader,l=new Promise((u,h)=>{a.onload=()=>{const f=a.result;if(typeof f!="string"){h(new Error("Failed to read file as data URL"));return}const m=f.includes(",")?f.split(",")[1]??f:f;u(m)},a.onerror=h});a.readAsDataURL(s);const c=await l,d={id:crypto.randomUUID(),name:s.name,mimeType:s.type||"application/octet-stream",size:s.size,data:c};Pp(t,{from:i,to:i},d)}catch(a){console.error("Failed to process file:",a),pe.error(`Failed to load file "${s.name}"`)}}function Bx(t){const e=B.c(7),{editor:s,selectedModel:i}=t,n=S.useRef($x);let o,a;e[0]!==s||e[1]!==i?(o=()=>{n.current=async(d,u)=>{await Tl(s,i,d,u)}},a=[s,i],e[0]=s,e[1]=i,e[2]=o,e[3]=a):(o=e[2],a=e[3]),S.useEffect(o,a);let l,c;return e[4]!==s?(l=()=>{if(s?.isDestroyed)return;const d=new na("fileDropHandler");s.state.plugins.find(f=>f.spec.key===d)&&s.unregisterPlugin(d);const h=new Zp({key:d,props:{handleDrop:(f,m,p,g)=>{if(g)return!1;const _=m.dataTransfer?.files;if(!_||_.length===0)return!1;m.preventDefault();const v=f.posAtCoords({left:m.clientX,top:m.clientY});if(!v)return!1;const x=Array.from(_),b=v.pos;for(const y of x)n.current?.(y,b);return!0},handlePaste:(f,m)=>{const p=m.clipboardData?.items;if(!p)return!1;const g=Array.from(p).filter(Ox);if(g.length===0)return!1;m.preventDefault();const{from:_}=f.state.selection;for(const v of g){const x=v.getAsFile();x&&n.current?.(x,_)}return!0}}});return s.registerPlugin(h),()=>{s?.isDestroyed||s.unregisterPlugin(d)}},c=[s],e[4]=s,e[5]=l,e[6]=c):(l=e[5],c=e[6]),S.useEffect(l,c),null}function Ox(t){return t.kind==="file"}function $x(){return Promise.resolve()}function zx(t){const e=B.c(23),{selectedModel:s,isStreaming:i,icon:n}=t,{editor:o}=to(),a=S.useRef(null);let l;e[0]!==s?(l=no(s),e[0]=s,e[1]=l):l=e[1];const c=l;let d;e[2]!==o||e[3]!==s?(d=async y=>{const C=y.target.files;if(!C||C.length===0||!o)return;const j=Array.from(C),{from:V}=o.state.selection,w=V;for(const k of j)await Tl(o,s,k,w);a.current&&(a.current.value="")},e[2]=o,e[3]=s,e[4]=d):d=e[4];const u=d;if(!o||!c)return null;let h;e[5]!==s?(h=zg(s),e[5]=s,e[6]=h):h=e[6];let f;e[7]!==u||e[8]!==i||e[9]!==h?(f=r.jsx("input",{ref:a,type:"file",multiple:!0,accept:h,className:"hidden",onChange:u,disabled:i}),e[7]=u,e[8]=i,e[9]=h,e[10]=f):f=e[10];const m=i||!c;let p;e[11]===Symbol.for("react.memo_cache_sentinel")?(p=()=>a.current?.click(),e[11]=p):p=e[11];let g;e[12]!==n?(g=n??r.jsx(fg,{size:16}),e[12]=n,e[13]=g):g=e[13];let _;e[14]!==m||e[15]!==g?(_=r.jsx(tt,{asChild:!0,children:r.jsx(ne,{type:"button",variant:"ghost",size:"icon",className:"text-muted-foreground/75",disabled:m,onClick:p,children:g})}),e[14]=m,e[15]=g,e[16]=_):_=e[16];let v;e[17]===Symbol.for("react.memo_cache_sentinel")?(v=r.jsx(st,{side:"top",children:"Add file"}),e[17]=v):v=e[17];let x;e[18]!==_?(x=r.jsxs(it,{children:[_,v]}),e[18]=_,e[19]=x):x=e[19];let b;return e[20]!==x||e[21]!==f?(b=r.jsxs(r.Fragment,{children:[f,x]}),e[20]=x,e[21]=f,e[22]=b):b=e[22],b}var Fx=eg;var Hx=["input:not([inert]):not([inert] *)","select:not([inert]):not([inert] *)","textarea:not([inert]):not([inert] *)","a[href]:not([inert]):not([inert] *)","button:not([inert]):not([inert] *)","[tabindex]:not(slot):not([inert]):not([inert] *)","audio[controls]:not([inert]):not([inert] *)","video[controls]:not([inert]):not([inert] *)",'[contenteditable]:not([contenteditable="false"]):not([inert]):not([inert] *)',"details>summary:first-of-type:not([inert]):not([inert] *)","details:not([inert]):not([inert] *)"],ua=Hx.join(","),Eu=typeof Element>"u",Nr=Eu?function(){}:Element.prototype.matches||Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector,zn=!Eu&&Element.prototype.getRootNode?function(t){var e;return t==null||(e=t.getRootNode)===null||e===void 0?void 0:e.call(t)}:function(t){return t?.ownerDocument},Fn=function(e,s){var i;s===void 0&&(s=!0);var n=e==null||(i=e.getAttribute)===null||i===void 0?void 0:i.call(e,"inert"),o=n===""||n==="true",a=o||s&&e&&(typeof e.closest=="function"?e.closest("[inert]"):Fn(e.parentNode));return a},Wx=function(e){var s,i=e==null||(s=e.getAttribute)===null||s===void 0?void 0:s.call(e,"contenteditable");return i===""||i==="true"},Ux=function(e,s,i){if(Fn(e))return[];var n=Array.prototype.slice.apply(e.querySelectorAll(ua));return s&&Nr.call(e,ua)&&n.unshift(e),n=n.filter(i),n},fa=function(e,s,i){for(var n=[],o=Array.from(e);o.length;){var a=o.shift();if(!Fn(a,!1))if(a.tagName==="SLOT"){var l=a.assignedElements(),c=l.length?l:a.children,d=fa(c,!0,i);i.flatten?n.push.apply(n,d):n.push({scopeParent:a,candidates:d})}else{var u=Nr.call(a,ua);u&&i.filter(a)&&(s||!e.includes(a))&&n.push(a);var h=a.shadowRoot||typeof i.getShadowRoot=="function"&&i.getShadowRoot(a),f=!Fn(h,!1)&&(!i.shadowRootFilter||i.shadowRootFilter(a));if(h&&f){var m=fa(h===!0?a.children:h.children,!0,i);i.flatten?n.push.apply(n,m):n.push({scopeParent:a,candidates:m})}else o.unshift.apply(o,a.children)}}return n},Iu=function(e){return!isNaN(parseInt(e.getAttribute("tabindex"),10))},Ru=function(e){if(!e)throw new Error("No node provided");return e.tabIndex<0&&(/^(AUDIO|VIDEO|DETAILS)$/.test(e.tagName)||Wx(e))&&!Iu(e)?0:e.tabIndex},Kx=function(e,s){var i=Ru(e);return i<0&&s&&!Iu(e)?0:i},qx=function(e,s){return e.tabIndex===s.tabIndex?e.documentOrder-s.documentOrder:e.tabIndex-s.tabIndex},Tu=function(e){return e.tagName==="INPUT"},Gx=function(e){return Tu(e)&&e.type==="hidden"},Yx=function(e){var s=e.tagName==="DETAILS"&&Array.prototype.slice.apply(e.children).some(function(i){return i.tagName==="SUMMARY"});return s},Xx=function(e,s){for(var i=0;i<e.length;i++)if(e[i].checked&&e[i].form===s)return e[i]},Jx=function(e){if(!e.name)return!0;var s=e.form||zn(e),i=function(l){return s.querySelectorAll('input[type="radio"][name="'+l+'"]')},n;if(typeof window<"u"&&typeof window.CSS<"u"&&typeof window.CSS.escape=="function")n=i(window.CSS.escape(e.name));else try{n=i(e.name)}catch(a){return console.error("Looks like you have a radio button with a name attribute containing invalid CSS selector characters and need the CSS.escape polyfill: %s",a.message),!1}var o=Xx(n,e.form);return!o||o===e},Qx=function(e){return Tu(e)&&e.type==="radio"},Zx=function(e){return Qx(e)&&!Jx(e)},e1=function(e){var s,i=e&&zn(e),n=(s=i)===null||s===void 0?void 0:s.host,o=!1;if(i&&i!==e){var a,l,c;for(o=!!((a=n)!==null&&a!==void 0&&(l=a.ownerDocument)!==null&&l!==void 0&&l.contains(n)||e!=null&&(c=e.ownerDocument)!==null&&c!==void 0&&c.contains(e));!o&&n;){var d,u,h;i=zn(n),n=(d=i)===null||d===void 0?void 0:d.host,o=!!((u=n)!==null&&u!==void 0&&(h=u.ownerDocument)!==null&&h!==void 0&&h.contains(n))}}return o},Ic=function(e){var s=e.getBoundingClientRect(),i=s.width,n=s.height;return i===0&&n===0},t1=function(e,s){var i=s.displayCheck,n=s.getShadowRoot;if(i==="full-native"&&"checkVisibility"in e){var o=e.checkVisibility({checkOpacity:!1,opacityProperty:!1,contentVisibilityAuto:!0,visibilityProperty:!0,checkVisibilityCSS:!0});return!o}if(getComputedStyle(e).visibility==="hidden")return!0;var a=Nr.call(e,"details>summary:first-of-type"),l=a?e.parentElement:e;if(Nr.call(l,"details:not([open]) *"))return!0;if(!i||i==="full"||i==="full-native"||i==="legacy-full"){if(typeof n=="function"){for(var c=e;e;){var d=e.parentElement,u=zn(e);if(d&&!d.shadowRoot&&n(d)===!0)return Ic(e);e.assignedSlot?e=e.assignedSlot:!d&&u!==e.ownerDocument?e=u.host:e=d}e=c}if(e1(e))return!e.getClientRects().length;if(i!=="legacy-full")return!0}else if(i==="non-zero-area")return Ic(e);return!1},s1=function(e){if(/^(INPUT|BUTTON|SELECT|TEXTAREA)$/.test(e.tagName))for(var s=e.parentElement;s;){if(s.tagName==="FIELDSET"&&s.disabled){for(var i=0;i<s.children.length;i++){var n=s.children.item(i);if(n.tagName==="LEGEND")return Nr.call(s,"fieldset[disabled] *")?!0:!n.contains(e)}return!0}s=s.parentElement}return!1},i1=function(e,s){return!(s.disabled||Gx(s)||t1(s,e)||Yx(s)||s1(s))},Rc=function(e,s){return!(Zx(s)||Ru(s)<0||!i1(e,s))},r1=function(e){var s=parseInt(e.getAttribute("tabindex"),10);return!!(isNaN(s)||s>=0)},Du=function(e){var s=[],i=[];return e.forEach(function(n,o){var a=!!n.scopeParent,l=a?n.scopeParent:n,c=Kx(l,a),d=a?Du(n.candidates):l;c===0?a?s.push.apply(s,d):s.push(l):i.push({documentOrder:o,tabIndex:c,item:n,isScope:a,content:d})}),i.sort(qx).reduce(function(n,o){return o.isScope?n.push.apply(n,o.content):n.push(o.content),n},[]).concat(s)},Mu=function(e,s){s=s||{};var i;return s.getShadowRoot?i=fa([e],s.includeContainer,{filter:Rc.bind(null,s),flatten:!1,getShadowRoot:s.getShadowRoot,shadowRootFilter:r1}):i=Ux(e,s.includeContainer,Rc.bind(null,s)),Du(i)};function n1(){return/apple/i.test(navigator.vendor)}const Tc="data-floating-ui-focusable";function o1(t){let e=t.activeElement;for(;((s=e)==null||(s=s.shadowRoot)==null?void 0:s.activeElement)!=null;){var s;e=e.shadowRoot.activeElement}return e}function ma(t,e){if(!t||!e)return!1;const s=e.getRootNode==null?void 0:e.getRootNode();if(t.contains(e))return!0;if(s&&Fm(s)){let i=e;for(;i;){if(t===i)return!0;i=i.parentNode||i.host}}return!1}function er(t){return"composedPath"in t?t.composedPath()[0]:t.target}function No(t,e){if(e==null)return!1;if("composedPath"in t)return t.composedPath().includes(e);const s=t;return s.target!=null&&e.contains(s.target)}function a1(t){return t.matches("html,body")}function Ar(t){return t?.ownerDocument||document}function l1(t){return t?t.hasAttribute(Tc)?t:t.querySelector("["+Tc+"]")||t:null}function jn(t,e,s){return s===void 0&&(s=!0),t.filter(n=>{var o;return n.parentId===e&&(!s||((o=n.context)==null?void 0:o.open))}).flatMap(n=>[n,...jn(t,n.id,s)])}function c1(t){return"nativeEvent"in t}var d1=typeof document<"u",h1=function(){},pi=d1?S.useLayoutEffect:h1;const u1={...Sh},f1=u1.useInsertionEffect,m1=f1||(t=>t());function Ei(t){const e=S.useRef(()=>{});return m1(()=>{e.current=t}),S.useCallback(function(){for(var s=arguments.length,i=new Array(s),n=0;n<s;n++)i[n]=arguments[n];return e.current==null?void 0:e.current(...i)},[])}const Pu=()=>({getShadowRoot:!0,displayCheck:typeof ResizeObserver=="function"&&ResizeObserver.toString().includes("[native code]")?"full":"none"});function Lu(t,e){const s=Mu(t,Pu()),i=s.length;if(i===0)return;const n=o1(Ar(t)),o=s.indexOf(n),a=o===-1?e===1?0:i-1:o+e;return s[a]}function p1(t){return Lu(Ar(t).body,1)||t}function g1(t){return Lu(Ar(t).body,-1)||t}function Ao(t,e){const s=e||t.currentTarget,i=t.relatedTarget;return!i||!ma(s,i)}function _1(t){Mu(t,Pu()).forEach(s=>{s.dataset.tabindex=s.getAttribute("tabindex")||"",s.setAttribute("tabindex","-1")})}function Dc(t){t.querySelectorAll("[data-tabindex]").forEach(s=>{const i=s.dataset.tabindex;delete s.dataset.tabindex,i?s.setAttribute("tabindex",i):s.removeAttribute("tabindex")})}const x1="data-floating-ui-focusable",Mc="active",Pc="selected",v1={...Sh};let Lc=!1,b1=0;const Bc=()=>"floating-ui-"+Math.random().toString(36).slice(2,6)+b1++;function y1(){const[t,e]=S.useState(()=>Lc?Bc():void 0);return pi(()=>{t==null&&e(Bc())},[]),S.useEffect(()=>{Lc=!0},[]),t}const S1=v1.useId,Dl=S1||y1;function w1(){const t=new Map;return{emit(e,s){var i;(i=t.get(e))==null||i.forEach(n=>n(s))},on(e,s){t.has(e)||t.set(e,new Set),t.get(e).add(s)},off(e,s){var i;(i=t.get(e))==null||i.delete(s)}}}const V1=S.createContext(null),C1=S.createContext(null),Bu=()=>{var t;return((t=S.useContext(V1))==null?void 0:t.id)||null},Ou=()=>S.useContext(C1);function Ml(t){return"data-floating-ui-"+t}const j1={border:0,clip:"rect(0 0 0 0)",height:"1px",margin:"-1px",overflow:"hidden",padding:0,position:"fixed",whiteSpace:"nowrap",width:"1px",top:0,left:0},Oc=S.forwardRef(function(e,s){const[i,n]=S.useState();pi(()=>{n1()&&n("button")},[]);const o={ref:s,tabIndex:0,role:i,"aria-hidden":i?void 0:!0,[Ml("focus-guard")]:"",style:j1};return r.jsx("span",{...e,...o})}),k1={clipPath:"inset(50%)",position:"fixed",top:0,left:0},$u=S.createContext(null),$c=Ml("portal");function N1(t){t===void 0&&(t={});const{id:e,root:s}=t,i=Dl(),n=E1(),[o,a]=S.useState(null),l=S.useRef(null);return pi(()=>()=>{o?.remove(),queueMicrotask(()=>{l.current=null})},[o]),pi(()=>{if(!i||l.current)return;const c=e?document.getElementById(e):null;if(!c)return;const d=document.createElement("div");d.id=i,d.setAttribute($c,""),c.appendChild(d),l.current=d,a(d)},[e,i]),pi(()=>{if(s===null||!i||l.current)return;let c=s||n?.portalNode;c&&!Gm(c)&&(c=c.current),c=c||document.body;let d=null;e&&(d=document.createElement("div"),d.id=e,c.appendChild(d));const u=document.createElement("div");u.id=i,u.setAttribute($c,""),c=d||c,c.appendChild(u),l.current=u,a(u)},[e,s,i,n]),o}function A1(t){const{children:e,id:s,root:i,preserveTabOrder:n=!0}=t,o=N1({id:s,root:i}),[a,l]=S.useState(null),c=S.useRef(null),d=S.useRef(null),u=S.useRef(null),h=S.useRef(null),f=a?.modal,m=a?.open,p=!!a&&!a.modal&&a.open&&n&&!!(i||o);return S.useEffect(()=>{if(!o||!n||f)return;function g(_){o&&Ao(_)&&(_.type==="focusin"?Dc:_1)(o)}return o.addEventListener("focusin",g,!0),o.addEventListener("focusout",g,!0),()=>{o.removeEventListener("focusin",g,!0),o.removeEventListener("focusout",g,!0)}},[o,n,f]),S.useEffect(()=>{o&&(m||Dc(o))},[m,o]),r.jsxs($u.Provider,{value:S.useMemo(()=>({preserveTabOrder:n,beforeOutsideRef:c,afterOutsideRef:d,beforeInsideRef:u,afterInsideRef:h,portalNode:o,setFocusManagerState:l}),[n,o]),children:[p&&o&&r.jsx(Oc,{"data-type":"outside",ref:c,onFocus:g=>{if(Ao(g,o)){var _;(_=u.current)==null||_.focus()}else{const v=a?a.domReference:null,x=g1(v);x?.focus()}}}),p&&o&&r.jsx("span",{"aria-owns":o.id,style:k1}),o&&ds.createPortal(e,o),p&&o&&r.jsx(Oc,{"data-type":"outside",ref:d,onFocus:g=>{if(Ao(g,o)){var _;(_=h.current)==null||_.focus()}else{const v=a?a.domReference:null,x=p1(v);x?.focus(),a?.closeOnFocusOut&&a?.onOpenChange(!1,g.nativeEvent,"focus-out")}}})]})}const E1=()=>S.useContext($u),I1={pointerdown:"onPointerDown",mousedown:"onMouseDown",click:"onClick"},R1={pointerdown:"onPointerDownCapture",mousedown:"onMouseDownCapture",click:"onClickCapture"},zc=t=>{var e,s;return{escapeKey:typeof t=="boolean"?t:(e=t?.escapeKey)!=null?e:!1,outsidePress:typeof t=="boolean"?t:(s=t?.outsidePress)!=null?s:!0}};function T1(t,e){e===void 0&&(e={});const{open:s,onOpenChange:i,elements:n,dataRef:o}=t,{enabled:a=!0,escapeKey:l=!0,outsidePress:c=!0,outsidePressEvent:d="pointerdown",referencePress:u=!1,referencePressEvent:h="pointerdown",ancestorScroll:f=!1,bubbles:m,capture:p}=e,g=Ou(),_=Ei(typeof c=="function"?c:()=>!1),v=typeof c=="function"?_:c,x=S.useRef(!1),{escapeKey:b,outsidePress:y}=zc(m),{escapeKey:C,outsidePress:j}=zc(p),V=S.useRef(!1),w=Ei(E=>{var R;if(!s||!a||!l||E.key!=="Escape"||V.current)return;const M=(R=o.current.floatingContext)==null?void 0:R.nodeId,L=g?jn(g.nodesRef.current,M):[];if(!b&&(E.stopPropagation(),L.length>0)){let D=!0;if(L.forEach(P=>{var O;if((O=P.context)!=null&&O.open&&!P.context.dataRef.current.__escapeKeyBubbles){D=!1;return}}),!D)return}i(!1,c1(E)?E.nativeEvent:E,"escape-key")}),k=Ei(E=>{var R;const M=()=>{var L;w(E),(L=er(E))==null||L.removeEventListener("keydown",M)};(R=er(E))==null||R.addEventListener("keydown",M)}),T=Ei(E=>{var R;const M=o.current.insideReactTree;o.current.insideReactTree=!1;const L=x.current;if(x.current=!1,d==="click"&&L||M||typeof v=="function"&&!v(E))return;const D=er(E),P="["+Ml("inert")+"]",O=Ar(n.floating).querySelectorAll(P);let z=ys(D)?D:null;for(;z&&!wo(z);){const G=Um(z);if(wo(G)||!ys(G))break;z=G}if(O.length&&ys(D)&&!a1(D)&&!ma(D,n.floating)&&Array.from(O).every(G=>!ma(z,G)))return;if(Km(D)&&N){const G=wo(D),q=qm(D),H=/auto|scroll/,ee=G||H.test(q.overflowX),K=G||H.test(q.overflowY),U=ee&&D.clientWidth>0&&D.scrollWidth>D.clientWidth,te=K&&D.clientHeight>0&&D.scrollHeight>D.clientHeight,Y=q.direction==="rtl",J=te&&(Y?E.offsetX<=D.offsetWidth-D.clientWidth:E.offsetX>D.clientWidth),ie=U&&E.offsetY>D.clientHeight;if(J||ie)return}const $=(R=o.current.floatingContext)==null?void 0:R.nodeId,W=g&&jn(g.nodesRef.current,$).some(G=>{var q;return No(E,(q=G.context)==null?void 0:q.elements.floating)});if(No(E,n.floating)||No(E,n.domReference)||W)return;const F=g?jn(g.nodesRef.current,$):[];if(F.length>0){let G=!0;if(F.forEach(q=>{var H;if((H=q.context)!=null&&H.open&&!q.context.dataRef.current.__outsidePressBubbles){G=!1;return}}),!G)return}i(!1,E,"outside-press")}),I=Ei(E=>{var R;const M=()=>{var L;T(E),(L=er(E))==null||L.removeEventListener(d,M)};(R=er(E))==null||R.addEventListener(d,M)});S.useEffect(()=>{if(!s||!a)return;o.current.__escapeKeyBubbles=b,o.current.__outsidePressBubbles=y;let E=-1;function R(O){i(!1,O,"ancestor-scroll")}function M(){window.clearTimeout(E),V.current=!0}function L(){E=window.setTimeout(()=>{V.current=!1},Wm()?5:0)}const D=Ar(n.floating);l&&(D.addEventListener("keydown",C?k:w,C),D.addEventListener("compositionstart",M),D.addEventListener("compositionend",L)),v&&D.addEventListener(d,j?I:T,j);let P=[];return f&&(ys(n.domReference)&&(P=So(n.domReference)),ys(n.floating)&&(P=P.concat(So(n.floating))),!ys(n.reference)&&n.reference&&n.reference.contextElement&&(P=P.concat(So(n.reference.contextElement)))),P=P.filter(O=>{var z;return O!==((z=D.defaultView)==null?void 0:z.visualViewport)}),P.forEach(O=>{O.addEventListener("scroll",R,{passive:!0})}),()=>{l&&(D.removeEventListener("keydown",C?k:w,C),D.removeEventListener("compositionstart",M),D.removeEventListener("compositionend",L)),v&&D.removeEventListener(d,j?I:T,j),P.forEach(O=>{O.removeEventListener("scroll",R)}),window.clearTimeout(E)}},[o,n,l,v,d,s,i,f,a,b,y,w,C,k,T,j,I]),S.useEffect(()=>{o.current.insideReactTree=!1},[o,v,d]);const A=S.useMemo(()=>({onKeyDown:w,...u&&{[I1[h]]:E=>{i(!1,E.nativeEvent,"reference-press")},...h!=="click"&&{onClick(E){i(!1,E.nativeEvent,"reference-press")}}}}),[w,i,u,h]),N=S.useMemo(()=>{function E(R){R.button===0&&(x.current=!0)}return{onKeyDown:w,onMouseDown:E,onMouseUp:E,[R1[d]]:()=>{o.current.insideReactTree=!0}}},[w,d,o]);return S.useMemo(()=>a?{reference:A,floating:N}:{},[a,A,N])}function D1(t){const{open:e=!1,onOpenChange:s,elements:i}=t,n=Dl(),o=S.useRef({}),[a]=S.useState(()=>w1()),l=Bu()!=null,[c,d]=S.useState(i.reference),u=Ei((m,p,g)=>{o.current.openEvent=m?p:void 0,a.emit("openchange",{open:m,event:p,reason:g,nested:l}),s?.(m,p,g)}),h=S.useMemo(()=>({setPositionReference:d}),[]),f=S.useMemo(()=>({reference:c||i.reference||null,floating:i.floating||null,domReference:i.reference}),[c,i.reference,i.floating]);return S.useMemo(()=>({dataRef:o,open:e,onOpenChange:u,elements:f,events:a,floatingId:n,refs:h}),[e,u,f,a,n,h])}function M1(t){t===void 0&&(t={});const{nodeId:e}=t,s=D1({...t,elements:{reference:null,floating:null,...t.elements}}),i=t.rootContext||s,n=i.elements,[o,a]=S.useState(null),[l,c]=S.useState(null),u=n?.domReference||o,h=S.useRef(null),f=Ou();pi(()=>{u&&(h.current=u)},[u]);const m=Hm({...t,elements:{...n,...l&&{reference:l}}}),p=S.useCallback(b=>{const y=ys(b)?{getBoundingClientRect:()=>b.getBoundingClientRect(),getClientRects:()=>b.getClientRects(),contextElement:b}:b;c(y),m.refs.setReference(y)},[m.refs]),g=S.useCallback(b=>{(ys(b)||b===null)&&(h.current=b,a(b)),(ys(m.refs.reference.current)||m.refs.reference.current===null||b!==null&&!ys(b))&&m.refs.setReference(b)},[m.refs]),_=S.useMemo(()=>({...m.refs,setReference:g,setPositionReference:p,domReference:h}),[m.refs,g,p]),v=S.useMemo(()=>({...m.elements,domReference:u}),[m.elements,u]),x=S.useMemo(()=>({...m,...i,refs:_,elements:v,nodeId:e}),[m,_,v,e,i]);return pi(()=>{i.dataRef.current.floatingContext=x;const b=f?.nodesRef.current.find(y=>y.id===e);b&&(b.context=x)}),S.useMemo(()=>({...m,context:x,refs:_,elements:v}),[m,_,v,x])}function Eo(t,e,s){const i=new Map,n=s==="item";let o=t;if(n&&t){const{[Mc]:a,[Pc]:l,...c}=t;o=c}return{...s==="floating"&&{tabIndex:-1,[x1]:""},...o,...e.map(a=>{const l=a?a[s]:null;return typeof l=="function"?t?l(t):null:l}).concat(t).reduce((a,l)=>(l&&Object.entries(l).forEach(c=>{let[d,u]=c;if(!(n&&[Mc,Pc].includes(d)))if(d.indexOf("on")===0){if(i.has(d)||i.set(d,[]),typeof u=="function"){var h;(h=i.get(d))==null||h.push(u),a[d]=function(){for(var f,m=arguments.length,p=new Array(m),g=0;g<m;g++)p[g]=arguments[g];return(f=i.get(d))==null?void 0:f.map(_=>_(...p)).find(_=>_!==void 0)}}}else a[d]=u}),a),{})}}function P1(t){t===void 0&&(t=[]);const e=t.map(l=>l?.reference),s=t.map(l=>l?.floating),i=t.map(l=>l?.item),n=S.useCallback(l=>Eo(l,t,"reference"),e),o=S.useCallback(l=>Eo(l,t,"floating"),s),a=S.useCallback(l=>Eo(l,t,"item"),i);return S.useMemo(()=>({getReferenceProps:n,getFloatingProps:o,getItemProps:a}),[n,o,a])}const L1=new Map([["select","listbox"],["combobox","listbox"],["label",!1]]);function B1(t,e){var s,i;e===void 0&&(e={});const{open:n,elements:o,floatingId:a}=t,{enabled:l=!0,role:c="dialog"}=e,d=Dl(),u=((s=o.domReference)==null?void 0:s.id)||d,h=S.useMemo(()=>{var x;return((x=l1(o.floating))==null?void 0:x.id)||a},[o.floating,a]),f=(i=L1.get(c))!=null?i:c,p=Bu()!=null,g=S.useMemo(()=>f==="tooltip"||c==="label"?{["aria-"+(c==="label"?"labelledby":"describedby")]:n?h:void 0}:{"aria-expanded":n?"true":"false","aria-haspopup":f==="alertdialog"?"dialog":f,"aria-controls":n?h:void 0,...f==="listbox"&&{role:"combobox"},...f==="menu"&&{id:u},...f==="menu"&&p&&{role:"menuitem"},...c==="select"&&{"aria-autocomplete":"none"},...c==="combobox"&&{"aria-autocomplete":"list"}},[f,h,p,n,u,c]),_=S.useMemo(()=>{const x={id:h,...f&&{role:f}};return f==="tooltip"||c==="label"?x:{...x,...f==="menu"&&{"aria-labelledby":u}}},[f,h,u,c]),v=S.useCallback(x=>{let{active:b,selected:y}=x;const C={role:"option",...b&&{id:h+"-fui-option"}};switch(c){case"select":case"combobox":return{...C,"aria-selected":y}}return{}},[h,c]);return S.useMemo(()=>l?{reference:g,floating:_,item:v}:{},[l,g,_,v])}function O1(t){const e=B.c(26),{editor:s,query:i,items:n,onSelect:o,onClose:a}=t,[l,c]=S.useState(0),d=S.useRef(n),u=S.useRef(l),h=S.useRef(o),f=S.useRef(a),m=S.useDeferredValue(i);let p;e[0]===Symbol.for("react.memo_cache_sentinel")?(p=()=>{c(0)},e[0]=p):p=e[0];let g;e[1]!==m?(g=[m],e[1]=m,e[2]=g):g=e[2],S.useEffect(p,g);let _,v;e[3]!==n.length||e[4]!==l?(_=()=>{l>=n.length&&n.length>0&&c(0)},v=[n.length,l],e[3]=n.length,e[4]=l,e[5]=_,e[6]=v):(_=e[5],v=e[6]),S.useEffect(_,v);let x,b;e[7]!==n?(x=()=>{d.current=n},b=[n],e[7]=n,e[8]=x,e[9]=b):(x=e[8],b=e[9]),S.useEffect(x,b);let y,C;e[10]!==l?(y=()=>{u.current=l},C=[l],e[10]=l,e[11]=y,e[12]=C):(y=e[11],C=e[12]),S.useEffect(y,C);let j,V;e[13]!==o?(V=()=>{h.current=o},j=[o],e[13]=o,e[14]=j,e[15]=V):(j=e[14],V=e[15]),S.useEffect(V,j);let w,k;e[16]!==a?(w=()=>{f.current=a},k=[a],e[16]=a,e[17]=w,e[18]=k):(w=e[17],k=e[18]),S.useEffect(w,k);let T;e[19]!==s.isDestroyed||e[20]!==s.view.dom?(T=()=>{const E=s.view.dom;if(s?.isDestroyed||!E)return;const R=L=>{const D=d.current;if(!D.length)return!1;const P=()=>c(z=>(z+1)%D.length),O=()=>c(z=>(z-1+D.length)%D.length);switch(L.key){case"ArrowUp":return L.preventDefault(),O(),!0;case"ArrowDown":return L.preventDefault(),P(),!0;case"Tab":return L.preventDefault(),L.shiftKey?O():P(),!0;case"Home":return L.preventDefault(),c(0),!0;case"End":return L.preventDefault(),c(D.length-1),!0;case"Enter":{if(L.isComposing)return!1;L.preventDefault();const z=u.current;return z!==-1&&D[z]&&h.current?.(D[z],z),!0}case"Escape":return L.preventDefault(),f.current?.(),!0;default:return!1}},M=L=>{R(L)};return E.addEventListener("keydown",M,!0),()=>{E?.removeEventListener("keydown",M,!0)}},e[19]=s.isDestroyed,e[20]=s.view.dom,e[21]=T):T=e[21];let I;e[22]!==s?(I=[s],e[22]=s,e[23]=I):I=e[23],S.useEffect(T,I);const A=n.length?l:void 0;let N;return e[24]!==A?(N={selectedIndex:A,setSelectedIndex:c},e[24]=A,e[25]=N):N=e[25],N}function $1(t,e){switch(e.type){case"SET_SELECTED_ITEM":return{...t,selectedItem:e.payload};case"ON_START":return{...t,open:!0,selectedItem:null,element:e.payload.element,query:e.payload.query,range:e.payload.range};case"ON_UPDATE":return{...t,element:e.payload.element,query:e.payload.query,range:e.payload.range};case"ON_EXIT":return{open:!1,element:null,query:"",range:null,selectedItem:null};default:return t}}const zu=S.createContext(void 0);function Fu(){const t=S.useContext(zu);if(!t)throw new Error("useSuggestionContext must be used within a SuggestionContext.Provider");return t}function z1({editor:t,char:e,pluginKey:s,allow:i,onOpenChange:n}){const[o,a]=S.useReducer($1,{open:!1,element:null,query:"",range:null,selectedItem:null}),l=S.useRef(n);return l.current=n,S.useEffect(()=>{if(t?.isDestroyed)return;const c=s instanceof na?s:new na(s);t.state.plugins.find(h=>h.spec.key===c)&&t.unregisterPlugin(c);const u=Wg({pluginKey:c,editor:t,char:e,allow(h){const f=t.state.doc.resolve(h.range.from);for(let m=f.depth;m>0;m--)if(f.node(m).type.name==="image")return!1;return!(i&&!i(h))},command(){},render:()=>({onStart:h=>{a({type:"ON_START",payload:{element:h.decorationNode??null,query:h.query,range:h.range}}),l.current?.(!0)},onUpdate:h=>{a({type:"ON_UPDATE",payload:{element:h.decorationNode??null,query:h.query,range:h.range}})},onKeyDown:h=>h.event.key==="Escape"?(a({type:"ON_EXIT"}),!0):!1,onExit:()=>{a({type:"ON_EXIT"}),l.current?.(!1)}}),items:()=>[]});return t.registerPlugin(u),()=>{t?.isDestroyed||t.unregisterPlugin(c)}},[t,s,e,a,i]),{state:o,dispatch:a}}function F1({editor:t,queryKey:e,queryFn:s,onSelect:i}){const{state:n,dispatch:o}=Fu(),a=S.useDeferredValue(n.query),{data:l}=wh({queryKey:lt.suggestionItems(e,n.open,a),queryFn:()=>n.open?s({query:a}):[]}),c=()=>{o({type:"ON_EXIT"})},d=async(h,f)=>{if(!(n.selectedItem!==null||!n.range)){o({type:"SET_SELECTED_ITEM",payload:h});try{const{view:m}=t,g=m.state.selection.$to.nodeAfter?.text?.startsWith(" "),_=n.range?{...n.range}:{from:0,to:0};g&&n.range&&(_.to+=1),await i({range:_,item:h})===!1?o({type:"SET_SELECTED_ITEM",payload:null}):c()}catch{c()}}},{selectedIndex:u}=O1({editor:t,query:a,items:l,onSelect:d,onClose:c});return{selectedItem:n.selectedItem,items:l,selectedIndex:u,close:c,onSelect:d}}function H1({children:t}){const{state:e,dispatch:s}=Fu(),{open:i,element:n}=e,o=()=>{s({type:"ON_EXIT"})},{refs:a,floatingStyles:l,context:c}=M1({placement:"bottom-start",open:i,onOpenChange:f=>{f||o()},elements:{reference:n},middleware:[Ym(10),Xm(),Jm()],whileElementsMounted:Qm}),d=T1(c,{outsidePress:f=>!(f.target instanceof Element&&f.target.closest(".ProseMirror"))}),u=B1(c,{role:"listbox"}),{getFloatingProps:h}=P1([d,u]);return i?r.jsx(A1,{children:r.jsx("div",{ref:a.setFloating,style:l,...h(),className:"z-50 w-auto min-w-[360px] max-w-[520px] rounded-lg border bg-popover p-0 text-popover-foreground shadow-md outline-hidden overflow-hidden",children:t})}):null}const W1=t=>{const e=B.c(29),{item:s,isSelected:i,onSelect:n,isLoading:o,ref:a}=t;let l;if(e[0]!==s){const j=si(s._meta);l=s.title||eo(s.name,j),e[0]=s,e[1]=l}else l=e[1];const c=l,d=s.description||null,u=s.icon,h=i&&"bg-accent text-accent-foreground",f=o&&"pointer-events-none opacity-50";let m;e[2]!==h||e[3]!==f?(m=X("relative flex w-full cursor-pointer select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors","hover:bg-accent hover:text-accent-foreground","focus:bg-accent focus:text-accent-foreground",h,f),e[2]=h,e[3]=f,e[4]=m):m=e[4];let p;e[5]!==u||e[6]!==c?(p=u!==void 0&&r.jsx(zs,{icon:u,name:c,size:"xs",className:"mr-2"}),e[5]=u,e[6]=c,e[7]=p):p=e[7];let g;e[8]!==c?(g=r.jsx("span",{className:"font-medium flex items-center truncate capitalize",children:c}),e[8]=c,e[9]=g):g=e[9];let _;e[10]!==o?(_=o&&r.jsx(jr,{size:"xs"}),e[10]=o,e[11]=_):_=e[11];let v;e[12]!==g||e[13]!==_?(v=r.jsxs("div",{className:"flex items-center justify-between gap-2",children:[g,_]}),e[12]=g,e[13]=_,e[14]=v):v=e[14];let x;e[15]!==d?(x=d&&r.jsx("div",{className:"text-xs text-muted-foreground line-clamp-1",children:d}),e[15]=d,e[16]=x):x=e[16];let b;e[17]!==v||e[18]!==x?(b=r.jsxs("div",{className:"flex flex-col gap-0.5 flex-1 min-w-0",children:[v,x]}),e[17]=v,e[18]=x,e[19]=b):b=e[19];let y;e[20]!==s.drillable?(y=s.drillable&&r.jsx("kbd",{className:"shrink-0 ml-2 px-1.5 py-0.5 text-[10px] font-medium text-muted-foreground bg-muted border border-border rounded",children:"↵"}),e[20]=s.drillable,e[21]=y):y=e[21];let C;return e[22]!==n||e[23]!==a||e[24]!==b||e[25]!==y||e[26]!==m||e[27]!==p?(C=r.jsxs("div",{ref:a,onClick:n,className:m,children:[p,b,y]}),e[22]=n,e[23]=a,e[24]=b,e[25]=y,e[26]=m,e[27]=p,e[28]=C):C=e[28],C},U1=t=>{const e=B.c(18),{editor:s,queryKey:i,queryFn:n,onSelect:o}=t;let a;e[0]!==s||e[1]!==o||e[2]!==n||e[3]!==i?(a={editor:s,queryKey:i,queryFn:n,onSelect:o},e[0]=s,e[1]=o,e[2]=n,e[3]=i,e[4]=a):a=e[4];const{items:l,selectedIndex:c,onSelect:d,selectedItem:u}=F1(a);if(!l.length){let p;return e[5]===Symbol.for("react.memo_cache_sentinel")?(p=r.jsx("div",{className:"min-w-[360px] max-w-[520px] bg-popover text-popover-foreground rounded-md border shadow-md p-3 text-sm",children:"No items found"}),e[5]=p):p=e[5],p}let h;e[6]===Symbol.for("react.memo_cache_sentinel")?(h={maxHeight:"min(320px, var(--radix-popover-content-available-height, 320px))"},e[6]=h):h=e[6];let f;if(e[7]!==d||e[8]!==l||e[9]!==c||e[10]!==u?.name){let p;e[12]!==d||e[13]!==c||e[14]!==u?.name?(p=(g,_)=>r.jsx(W1,{item:g,isSelected:_===c,ref:_===c?G1:void 0,onSelect:()=>d(g,_),isLoading:u?.name===g.name},g.name),e[12]=d,e[13]=c,e[14]=u?.name,e[15]=p):p=e[15],f=l.map(p),e[7]=d,e[8]=l,e[9]=c,e[10]=u?.name,e[11]=f}else f=e[11];let m;return e[16]!==f?(m=r.jsx("div",{className:"min-w-[360px] max-w-[520px] bg-popover text-popover-foreground rounded-md overflow-y-auto",style:h,children:r.jsx("div",{className:"p-1",children:f})}),e[16]=f,e[17]=m):m=e[17],m};function K1(){const t=B.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=r.jsx("div",{className:"p-1",children:[...Array(3)].map(q1)}),t[0]=e):e=t[0],e}function q1(t,e){return r.jsxs("div",{className:"flex items-center gap-1.5 px-2 py-1.5 animate-pulse",children:[r.jsx("div",{className:"h-4 w-24 bg-muted rounded"}),r.jsx("div",{className:"h-3 w-32 bg-muted rounded"})]},e)}function Hu(t){const e=B.c(18),{editor:s,char:i,pluginKey:n,queryKey:o,queryFn:a,onSelect:l,allow:c,onOpenChange:d}=t;let u;e[0]!==c||e[1]!==i||e[2]!==s||e[3]!==d||e[4]!==n?(u={editor:s,char:i,pluginKey:n,allow:c,onOpenChange:d},e[0]=c,e[1]=i,e[2]=s,e[3]=d,e[4]=n,e[5]=u):u=e[5];const{state:h,dispatch:f}=z1(u);let m;e[6]!==f||e[7]!==h?(m={state:h,dispatch:f},e[6]=f,e[7]=h,e[8]=m):m=e[8];let p;e[9]===Symbol.for("react.memo_cache_sentinel")?(p=r.jsx(K1,{}),e[9]=p):p=e[9];let g;e[10]!==s||e[11]!==l||e[12]!==a||e[13]!==o?(g=r.jsx(H1,{children:r.jsx(S.Suspense,{fallback:p,children:r.jsx(U1,{editor:s,queryKey:o,queryFn:a,onSelect:l})})}),e[10]=s,e[11]=l,e[12]=a,e[13]=o,e[14]=g):g=e[14];let _;return e[15]!==m||e[16]!==g?(_=r.jsx(zu.Provider,{value:m,children:g}),e[15]=m,e[16]=g,e[17]=_):_=e[17],_}function G1(t){t&&t.scrollIntoView({block:"center",behavior:"smooth"})}const Y1=[{name:"agents",title:"Agents",description:"Mention an agent to hand off work",kind:"category",drillable:!0},{name:"resources",title:"Resources",description:"Attach a resource as context",kind:"category",drillable:!0}],X1=({editor:t,virtualMcpId:e})=>{const s=Mt(),{org:i}=be(),n=oo(),o=Me({connectionId:e,orgId:i.id}),a=lt.virtualMcpResources(e,i.id),[l,c]=S.useState("categories"),d=S.useRef(l);d.current=l;const u=S.useRef(null),h=S.useRef(!1),f=["at-mention",i.id,e??"default",l],m=async({item:_,range:v})=>{if(se("chat_picker_item_selected",{picker:"@",item_kind:_.kind,item_name:_.name}),_.kind!=="category"&&(h.current=!0),_.kind==="category")return c(_.name==="agents"?"agents":"resources"),!1;if(_.kind==="agent"&&_.agentId){Cr(t,v,{id:_.agentId,name:_.name,metadata:{agentId:_.agentId,title:_.name},char:"@"}),c("categories");return}if(_.kind==="resource"&&_.uri&&o){try{const x=await nu(o,_.uri);Cr(t,v,{id:_.uri,name:_.uri,metadata:x.contents,char:"@"})}catch(x){console.error("[at-mention] Failed to fetch resource:",x),pe.error("Failed to load resource. Please try again.")}c("categories");return}},p=async _=>{const{query:v}=_,x=d.current;if(x==="categories"){if(!v.trim())return Y1;const C=v.toLowerCase(),j=n.filter(w=>w.status==="active"&&(!w.id||!Mn(w.id))&&w.id!==e&&(w.title.toLowerCase().includes(C)||w.description?.toLowerCase().includes(C))).map(w=>({name:w.title,title:w.title,description:w.description??void 0,icon:w.icon??null,kind:"agent",agentId:w.id})),V=await(async()=>{if(!o)return[];let w=s.getQueryData(a);return w||(w=await s.fetchQuery({queryKey:a,queryFn:()=>xr(o),staleTime:6e4})),(w?.resources??[]).filter(k=>k.uri.toLowerCase().includes(C)||k.name?.toLowerCase().includes(C)||k.description?.toLowerCase().includes(C)).map(k=>({name:k.name??k.uri,title:k.name,description:k.description,kind:"resource",uri:k.uri}))})();return[...j,...V]}if(x==="agents"){let C=n.filter(j=>j.status==="active"&&(!j.id||!Mn(j.id))&&j.id!==e);if(v.trim()){const j=v.toLowerCase();C=C.filter(V=>V.title.toLowerCase().includes(j)||V.description?.toLowerCase().includes(j))}return C.map(j=>({name:j.title,title:j.title,description:j.description??void 0,icon:j.icon??null,kind:"agent",agentId:j.id}))}if(!o)return[];let b=s.getQueryData(a);b?s.fetchQuery({queryKey:a,queryFn:()=>xr(o),staleTime:6e4}).catch(()=>{}):b=await s.fetchQuery({queryKey:a,queryFn:()=>xr(o),staleTime:6e4});let y=b?.resources??[];if(v.trim()){const C=v.toLowerCase();y=y.filter(j=>j.uri.toLowerCase().includes(C)||j.name?.toLowerCase().includes(C)||j.description?.toLowerCase().includes(C))}return y.map(C=>({name:C.name??C.uri,title:C.name,description:C.description,kind:"resource",uri:C.uri}))},g=_=>{if(_)u.current=Date.now(),h.current=!1,se("chat_picker_opened",{picker:"@"});else{const v=u.current;se("chat_picker_closed",{picker:"@",outcome:h.current?"selected":"dismissed",duration_ms:v?Date.now()-v:null}),u.current=null,c("categories")}};return r.jsx(Hu,{editor:t,char:"@",pluginKey:"atDropdownMenu",queryKey:f,queryFn:p,onSelect:m,onOpenChange:g})};function J1(t,e){const s=ts(t),i=Wr(),n=new Map(i.map(c=>[c.id,c])),o=(s?.connections??[]).map(c=>c.connection_id),{data:a}=Fi({queryKey:lt.promptConnectionMap(e,o),queryFn:async()=>{const c={};return await Promise.all(o.map(async d=>{try{const u=await lg({connectionId:d,orgId:e}),h=await Pn(u);for(const f of h.prompts)f.name in c||(c[f.name]=d)}catch{}})),c},staleTime:6e4,enabled:o.length>0}),l=new Map;for(const[c,d]of Object.entries(a??{})){const u=n.get(d);u&&l.set(c,u)}return l}async function Fc(t,e,s,i,n,o){try{const a=await ul(s,i,o);Cr(t,e,{id:i,name:al(i,n),metadata:a.messages,char:"/"})}catch(a){console.error("[slash] Failed to fetch prompt:",a),pe.error("Failed to load prompt. Please try again.")}}async function Q1(t,e,s,i){try{const n=await nu(s,i);Cr(t,e,{id:i,name:i,metadata:n.contents,char:"/"})}catch(n){console.error("[slash] Failed to fetch resource:",n),pe.error("Failed to load resource. Please try again.")}}const Z1=({editor:t,virtualMcpId:e})=>{const s=Mt(),{org:i}=be(),n=Me({connectionId:e,orgId:i.id}),o=J1(e,i.id),a=S.useRef(o);a.current=o;const l=lt.virtualMcpPrompts(e,i.id),c=lt.virtualMcpResources(e,i.id),d=["slash-mention",i.id,e??"default"],[u,h]=S.useState(null),f=S.useRef(null),m=S.useRef(!1),p=async({item:x,range:b})=>{if(se("chat_picker_item_selected",{picker:"/",item_kind:x.kind,item_name:x.name}),m.current=!0,!!n)if(x.kind==="prompt"){if(x.arguments&&x.arguments.length>0){h({range:b,item:x});return}const y=si(x._meta);await Fc(t,b,n,x.name,y)}else x.uri&&await Q1(t,b,n,x.uri)},g=async x=>{if(!u||!n)return;const{range:b,item:y}=u,C=si(y._meta);await Fc(t,b,n,y.name,C,x),h(null)},_=async x=>{const{query:b}=x;if(!n)return[];const[y,C]=await Promise.all([ev(s,l,n),tv(s,c,n)]),j=b.trim().toLowerCase(),V=(y??[]).filter(k=>!j||k.name.toLowerCase().includes(j)||k.title?.toLowerCase().includes(j)||k.description?.toLowerCase().includes(j)).map(k=>({name:k.name,title:k.title,description:k.description,icon:a.current.get(k.name)?.icon??null,kind:"prompt",arguments:k.arguments,_meta:k._meta})),w=(C??[]).filter(k=>!j||k.uri.toLowerCase().includes(j)||k.name?.toLowerCase().includes(j)||k.description?.toLowerCase().includes(j)).map(k=>({name:k.name??k.uri,title:k.name,description:k.description,kind:"resource",uri:k.uri}));return[...V,...w]},v=u?.item.kind==="prompt"?{name:u.item.name,arguments:u.item.arguments,description:u.item.description}:null;return r.jsxs(r.Fragment,{children:[r.jsx(Hu,{editor:t,char:"/",pluginKey:"slashDropdownMenu",queryKey:d,queryFn:_,onSelect:p,onOpenChange:x=>{if(x)f.current=Date.now(),m.current=!1,se("chat_picker_opened",{picker:"/"});else{const b=f.current;se("chat_picker_closed",{picker:"/",outcome:m.current?"selected":"dismissed",duration_ms:b?Date.now()-b:null}),f.current=null}}}),r.jsx(Rl,{prompt:v,setPrompt:()=>h(null),onSubmit:g})]})};async function ev(t,e,s){let i=t.getQueryData(e);return i?t.fetchQuery({queryKey:e,queryFn:()=>Pn(s),staleTime:6e4}).catch(()=>{}):i=await t.fetchQuery({queryKey:e,queryFn:()=>Pn(s),staleTime:6e4}),i?.prompts??[]}async function tv(t,e,s){let i=t.getQueryData(e);return i?t.fetchQuery({queryKey:e,queryFn:()=>xr(s),staleTime:6e4}).catch(()=>{}):i=await t.fetchQuery({queryKey:e,queryFn:()=>xr(s),staleTime:6e4}),i?.resources??[]}function sv(t){return[ig.configure({heading:!1,blockquote:!1,codeBlock:!1,horizontalRule:!1,dropcursor:!1}),Fx.configure({placeholder:()=>t.current??"Ask anything, / for prompts, @ for agents & resources...",showOnlyWhenEditable:!1}),Lp,Bp]}function Wu({tiptapDoc:t,setTiptapDoc:e,disabled:s=!1,enterToSubmit:i=!1,placeholder:n,onSubmit:o,children:a}){const l=S.useRef(o),c=S.useRef(e),d=S.useRef(i),u=S.useRef(n),h=tg({extensions:sv(u),content:t||"",editorProps:{attributes:{"data-chat-input":"true",class:"prose prose-sm max-w-none focus:outline-none w-full h-full text-[15px] p-[18px]"},handleKeyDown:(f,m)=>m.key==="Enter"&&!m.shiftKey&&d.current?(m.preventDefault(),l.current?.(),!0):!1},onUpdate:({editor:f})=>{c.current(f?.getJSON())}});return S.useEffect(()=>{h?.setEditable(!s)},[h,s]),S.useEffect(()=>{l.current=o},[o]),S.useEffect(()=>{c.current=e},[e]),S.useEffect(()=>{d.current=i},[i]),S.useEffect(()=>{u.current=n},[n]),S.useEffect(()=>{if(h?.isDestroyed)return;const f=JSON.stringify(h?.getJSON()),m=JSON.stringify(t||{type:"doc",content:[]});f!==m&&h.commands.setContent(t||{type:"doc",content:[]})},[h,t]),r.jsx(sg.Provider,{value:{editor:h},children:a})}function Uu(t){const e=B.c(25),{disabled:s,virtualMcpId:i,showFileUploader:n,selectedModel:o,ref:a,className:l}=t,c=s===void 0?!1:s,d=n===void 0?!1:n,{editor:u}=to();let h,f;if(e[0]!==u?(h=()=>({focus:()=>{u?.commands.focus()},clear:()=>{u?.commands.clearContent(!0)},appendText:V=>{if(!u)return;const w=u.state.doc.textContent.trim()==="";u.commands.focus("end"),w||u.commands.insertContent(" "),u.commands.insertContent(V)},syncVoiceText:(V,w)=>{if(u&&(u.commands.setContent(V||{type:"doc",content:[]}),w)){u.commands.focus("end");const k=u.state.doc.textContent.trim().length>0;u.commands.insertContent(k?" "+w:w)}},restoreContent:V=>{u&&u.commands.setContent(V||{type:"doc",content:[]})}}),f=[u],e[0]=u,e[1]=h,e[2]=f):(h=e[1],f=e[2]),S.useImperativeHandle(a??null,h,f),!u)return null;const m=c&&"cursor-not-allowed opacity-70",p=c&&"[&_.ProseMirror]:cursor-not-allowed";let g;e[3]!==l||e[4]!==m||e[5]!==p?(g=X("overflow-y-auto relative flex-1 max-h-[164px] min-h-[20px] w-full flex flex-col",l,"[&_.ProseMirror]:outline-none [&_.ProseMirror]:min-h-[20px] [&_.ProseMirror]:flex-1","[&_.ProseMirror_p.is-editor-empty:first-child::before]:content-[attr(data-placeholder)]","[&_.ProseMirror_p.is-editor-empty:first-child::before]:text-muted-foreground","[&_.ProseMirror_p.is-editor-empty:first-child::before]:opacity-50","[&_.ProseMirror_p.is-editor-empty:first-child::before]:float-left","[&_.ProseMirror_p.is-editor-empty:first-child::before]:pointer-events-none","[&_.ProseMirror_p.is-editor-empty:first-child::before]:h-0",m,p),e[3]=l,e[4]=m,e[5]=p,e[6]=g):g=e[6];let _;e[7]!==u||e[8]!==g?(_=r.jsx(rg,{editor:u,className:g}),e[7]=u,e[8]=g,e[9]=_):_=e[9];const v=i??null;let x;e[10]!==u||e[11]!==v?(x=r.jsx(S.Suspense,{fallback:null,children:r.jsx(Z1,{editor:u,virtualMcpId:v})}),e[10]=u,e[11]=v,e[12]=x):x=e[12];const b=i??null;let y;e[13]!==u||e[14]!==b?(y=r.jsx(S.Suspense,{fallback:null,children:r.jsx(X1,{editor:u,virtualMcpId:b})}),e[13]=u,e[14]=b,e[15]=y):y=e[15];let C;e[16]!==u||e[17]!==o||e[18]!==d?(C=d&&o?r.jsx(Bx,{editor:u,selectedModel:o}):null,e[16]=u,e[17]=o,e[18]=d,e[19]=C):C=e[19];let j;return e[20]!==x||e[21]!==y||e[22]!==C||e[23]!==_?(j=r.jsxs(r.Fragment,{children:[_,x,y,C]}),e[20]=x,e[21]=y,e[22]=C,e[23]=_,e[24]=j):j=e[24],j}function pa(t){const e=B.c(3),[s]=Wi();let i;return e[0]!==s.enableSounds||e[1]!==t?(i=()=>{s.enableSounds&&Zg(t.dataUri).catch(o=>{console.warn(`[sound] ${t.name} playback failed:`,o)})},e[0]=s.enableSounds,e[1]=t,e[2]=i):i=e[2],i}const iv={name:"switch-005",dataUri:"data:audio/mpeg;base64,SUQzBAAAAAAAIlRTU0VAAAAOAAADTGF2ZjYyLjMuMTAwAAAAAAAAAAAAAAD/+1DAAAAAAAAAAAAAAAAAAAAAAABJbmZvAAAADwAAABkAABU4ABMTEx0dHR0nJycnMTExMTs7OztERERETk5OTlhYWFhiYmJibGxsbHZ2dnZ/f39/iYmJiZOTk5OdnZ2dp6enp7GxsbG7u7u7xMTExM7Ozs7Y2NjY4uLi4uzs7Oz29vb2/////wAAAABMYXZjNjIuMTEAAAAAAAAAAAAAAAAkBVYAAAAAAAAVOPCP8KUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA//tQxAAACEwDXvQRAAG8Ii93HtACUCAABAKCJwfaCEHwfeoEAQdEAYygIHBOCAIAgCAJh9QIOg+D5/ygPh/wfB8DuKAgCHyn9QPh/5SCDv+CEHAQdxOD4B27c39tbckkqYbBAYAN9bNJLB+aXAf5wQAKdzxfbmrVIRQ4xNx3HwnoDmLhfMhgJiiw/HREXNCHqjvHEPEG8QjBYlxQNepJAT0kC8ip6JzSWj1TasoG+iyycbf2Uil1ovf1f/oUtR1qP+s1WSBFKoAAU02BDjMhuP/7UsQEgws8bRpd8YABJYPeBf9wCGXTGxBYcw5AJFMFMAmQQAhGAxgLBgHIAMYAAALhgAchipbe/91aU1VV4zcZj1Vf1XgYCIMBNrsBAIGs9/Ue4i/xFPeqCqwViI9/UeLf///rOngdA3OPHFjmOBv+EQnGahgaZxVplmkAH5JadDTQlNCEuGNiWYbCCONWdUJg6HXNazFdu1T+VgaEpOP70exv7f2/4b/yH//2/4cqCX/zWRUrIw+IPNMNlDnjAXQas/I4AzmYifA0tMSCgQDF//tSxBCDSzzi3k/sQwEyCtjJ/rBZAk+Uqj1YhA5YMCAAMwgOUchTkK7OR7LbMl0W1H6SvzG0Q2ZzfKUhnmTobv9DNhS1v7P8h//8Gv8gTRt1jReZ7YEjmMQg9hhwwMycHooasFmZyjcZGBKJD+IwbMCQQLoi+IQXCcIoydKoilI2MWFS5uJdDEu2taRrYI2ZSqKY50pJLv2NfjUAAuQAMfqVQ/T3PDQgMJMeEZ45hJzY6MNoFMxqTj1zNGQKJjAxEsSCBgQJBSIL0mcKYQJfVAn/+1LEGwLKlEKrD3MiYcuMkVa/wABB8Vh6M1q1epbvXwWBURhkyEhWZ/////////////9gjZ/Wt4w+4MNMCpE4TBYQl4w1IHvMDdA2zBngBMwc8COMDhCpDAfgOAAgrBgNYU+YC0FBGAkAMpgWoSCYAGESGBGAKBgXgJOdiOJmMCmNwCYNDJhYRPykRCJhTBnEUzlsjv4UNLj/z97n3Mv/7z1nZqyitYAZIqErIwMwJAqEw0GAAMFptJMaqFwB8CQIWlhuhuDAwNjfuwrQFAYXCf/7UsQVAA+9PTP42gYRdiIu9zBwAPbFUCi0DAhgNcS+7cDwVgM05A9bUDeuQMyE/u3CygVISgZhpIau/9PhdQG2C9DpxZZJmn/dn/Psmt0EFm////l84ThUTopE4VD/9JkubOGasTvN30C20G21qgUCkVCoUCgPMywrPCGly27V5q5t24vl/8jSlSAPCxzNseNCw3oh3NGBu4BZJ5hv7DRSfR/+eWG7nA8IKh2Olv5iz3q5m3//Joxo3JqNyYkSuGt/k6D4DeoBOHmHdl0dkZYA//tSxAUAC4B1Z/2DADEcA17Z/uhI4Yoik/TrZo+ww7UtmpW4LDWu2IacoJKJJeTSM+ZmAYBEiU+ZnnAwCn1VVVV6JUJQVnioKhrgqdKgqGpUFeCp0sDR3ztQNREDRUFioKuxKCpYGQBlRIBk+aLwb8KblGQVDdphPYTUdBOGbVpAaTF6ZdjEV0iRUZRCYkA4oUQDx5zqDugtXvza/7fuNNvfZ+j9v+T/2f//J/4cAAOTpE5K4zksR9MfIB+TDcQTI4gNs1XKAzEFUrGkxABYEBb/+1LEEYNKrEjgT/TCwYYVmUX+mHoKgWhKU5Eiw9SFIRmppw+3fYo4siPhUFeexM8KgIO6wVuPDDy01qeRaVbw357//y3+o8M0pBNlNLCGBzGKwyYw2IIFOE1WNTjRM6x8MlA1AxDhUHTAkEiyKpnbWrLcaOBotBUKbk1pypcWDAIK00AhKLGkUco6q9VWvM53mcaq3tVa8zjTM/tX//EDP//////////XAAmrwAAPoKwcw0ShDCZD/BQlhzinxQdorsOuXTEIC01ZkJyu4k/qPP/7UsQUAEjkrrkvZaPBIRXUoe5QObfMhYKX9RVgTPqCSCaSCaSC0XVdV1f/////6IAlguuAJSiDRNloNBsZg+0+Ts8MMCn81WUTRAlIi+GHECD0y8AWDIqswYsxGOSKVV7MqOni8tkVOip0fZX/////9HrMCbAz2EHGS4GKAAiRAAAYAcDdKd4G6Z/nwYgJ0ZAIgZyC8aPAs/iPBhwMpWDQNARltNS5Y61v//9i8Yl4SkFkIGTkAc0UBrIYLPA4MYBEy+YLMRuY4nhTC3hZA68H//tSxCoAyQC6mY6CkWDJBIsBz/QUrgNmahSzcrYw0/HhfnMAZBojDsgTFkDR5MDkG/DZEbk2FCmowqdqv2TYABiJwqqYjaQRGZ1URZ1DhSsdiHX/GBu0QpzIBNSaLqZ0ARkwFARxMrpt/Eh47mbQAhhU6sisFUxBTUUzLjEwMFVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVX/+1LESoHHJCRaj/dmYAIAQAAQAARVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVTEFNRTMuMTAwVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVf/7UsSLg8AAAaQAAAAgAAA0gAAABFVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVTEFNRTMuMTAwVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV//tSxKGDwAABpAAAACAAADSAAAAEVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVMQU1FMy4xMDBVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV//tSxKGDwAABpAAAACAAADSAAAAEVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVMQU1FMy4xMDBVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV//tSxKGDwAABpAAAACAAADSAAAAEVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVMQU1FMy4xMDBVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVX/+1LEoYPAAAGkAAAAIAAANIAAAARVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVUxBTUUzLjEwMFVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVf/7UsShg8AAAaQAAAAgAAA0gAAABFVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVTEFNRTMuMTAwVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV//tSxKGDwAABpAAAACAAADSAAAAEVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVMQU1FMy4xMDBVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVX/+1LEoYPAAAGkAAAAIAAANIAAAARVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVUxBTUUzLjEwMFVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV//tSxKGDwAABpAAAACAAADSAAAAEVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVMQU1FMy4xMDBVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV//tSxKGDwAABpAAAACAAADSAAAAEVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVMQU1FMy4xMDBVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV//tSxKGDwAABpAAAACAAADSAAAAEVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVMQU1FMy4xMDBVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV//tSxKGDwAABpAAAACAAADSAAAAEVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVMQU1FMy4xMDBVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV//tSxKGDwAABpAAAACAAADSAAAAEVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVMQU1FMy4xMDBVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV",duration:.609,format:"mp3",license:"CC0",author:"Kenney"},rv=[{src:"/connections/gmail.png",name:"Gmail"},{src:"/connections/perplexity.png",name:"Perplexity"},{src:"/connections/github.png",name:"GitHub"}];function nv(){const t=B.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=r.jsx("div",{className:"flex items-center -space-x-1.5",children:rv.map(ov)}),t[0]=e):e=t[0],e}function ov(t){return r.jsx("img",{src:t.src,alt:t.name,className:"size-5 rounded-sm ring-1 ring-border object-cover bg-white"},t.name)}function av(t){const e=B.c(129),{disabled:s,onOpenConnections:i,virtualMcpId:n}=t,[o,a]=S.useState(!1),l=pa(iv),{org:c}=be(),{editor:d}=to();let u;e[0]!==c.id||e[1]!==n?(u={connectionId:n,orgId:c.id},e[0]=c.id,e[1]=n,e[2]=u):u=e[2];const h=Me(u);let f;e[3]!==c.id||e[4]!==n?(f=lt.virtualMcpPrompts(n,c.id),e[3]=c.id,e[4]=n,e[5]=f):f=e[5];const m=f;let p;e[6]!==h?(p=()=>Pn(h),e[6]=h,e[7]=p):p=e[7];const g=o&&!!h;let _;e[8]!==m||e[9]!==p||e[10]!==g?(_={queryKey:m,queryFn:p,staleTime:6e4,enabled:g},e[8]=m,e[9]=p,e[10]=g,e[11]=_):_=e[11];const{data:v,isLoading:x}=Fi(_);let b;e[12]!==v?.prompts?(b=v?.prompts??[],e[12]=v?.prompts,e[13]=b):b=e[13];const y=b,[C,j]=S.useState(null),{credentialId:V,imageModel:w,setImageModel:k,deepResearchModel:T,setDeepResearchModel:I,chatMode:A,setChatMode:N,simpleModeEnabled:E}=ni(),R=A==="plan",[M,L]=S.useState(!1),[D,P]=S.useState(!1),{models:O,isLoading:z}=tu(M||D?V??void 0:void 0);let $,W,F,G,q,H,ee,K,U,te,Y,J,ie;if(e[14]!==C||e[15]!==O||e[16]!==A||e[17]!==h||e[18]!==T||e[19]!==s||e[20]!==d||e[21]!==w||e[22]!==M||e[23]!==z||e[24]!==R||e[25]!==i||e[26]!==o||e[27]!==l||e[28]!==D||e[29]!==N||e[30]!==I||e[31]!==k||e[32]!==E){const Q=O.filter(cv),ae=O.filter(lv);let Se;e[46]!==A||e[47]!==R||e[48]!==l||e[49]!==N?(Se=()=>{l();const _e=R?"default":"plan";se("chat_mode_changed",{from_mode:A,to_mode:_e,source:"tools_popover"}),N(_e),a(!1)},e[46]=A,e[47]=R,e[48]=l,e[49]=N,e[50]=Se):Se=e[50];const Ne=Se;let Be;e[51]!==i?(Be=()=>{i(),a(!1)},e[51]=i,e[52]=Be):Be=e[52],F=Be;let Oe;e[53]!==h||e[54]!==d?(Oe=async(_e,Ot)=>{if(!d||!h)return;const $t=si(_e._meta),ls={from:d.state.selection.from,to:d.state.selection.to};try{const Qi=await ul(h,_e.name,Ot);Cr(d,ls,{id:_e.name,name:al(_e.name,$t),metadata:Qi.messages,char:"/"})}catch{pe.error("Failed to load prompt. Please try again.")}},e[53]=h,e[54]=d,e[55]=Oe):Oe=e[55];const He=Oe;let Je;e[56]!==He?(Je=async _e=>{a(!1);const Ot=!!(_e.arguments&&_e.arguments.length>0);if(se("chat_prompt_inserted",{prompt_name:_e.name,with_arguments:Ot}),Ot){j(_e);return}await He(_e)},e[56]=He,e[57]=Je):Je=e[57],q=Je;let dt;e[58]!==C||e[59]!==He?(dt=async _e=>{C&&(await He(C,_e),j(null))},e[58]=C,e[59]=He,e[60]=dt):dt=e[60],G=dt;let ge;e[61]!==l||e[62]!==k?(ge=_e=>{l(),se("chat_image_model_selected",{model_id:_e.modelId,model_title:_e.title,provider:_e.providerId??null}),k(_e),a(!1)},e[61]=l,e[62]=k,e[63]=ge):ge=e[63];const ke=ge;let Qe;e[64]!==l||e[65]!==I?(Qe=_e=>{l(),se("chat_search_model_selected",{model_id:_e.modelId,model_title:_e.title,provider:_e.providerId??null}),I(_e),a(!1)},e[64]=l,e[65]=I,e[66]=Qe):Qe=e[66];const Ct=Qe;let Pe;e[67]!==A||e[68]!==l||e[69]!==N?(Pe=()=>{l();const _e=A==="gen-image"?"default":"gen-image";se("chat_mode_changed",{from_mode:A,to_mode:_e,source:"tools_popover"}),N(_e),a(!1)},e[67]=A,e[68]=l,e[69]=N,e[70]=Pe):Pe=e[70];const Kt=Pe;let jt;e[71]!==A||e[72]!==l||e[73]!==N?(jt=()=>{l();const _e=A==="web-search"?"default":"web-search";se("chat_mode_changed",{from_mode:A,to_mode:_e,source:"tools_popover"}),N(_e),a(!1)},e[71]=A,e[72]=l,e[73]=N,e[74]=jt):jt=e[74];const Ae=jt,Ie=A==="gen-image",qe=A==="web-search";W=js,K=o,e[75]!==A||e[76]!==o?(U=_e=>{_e&&!o&&se("chat_tools_popover_opened",{chat_mode:A}),a(_e)},e[75]=A,e[76]=o,e[77]=U):U=e[77];let qt,_t;e[78]===Symbol.for("react.memo_cache_sentinel")?(qt=r.jsx(zh,{size:14}),_t=r.jsx("span",{className:"hidden sm:inline",children:"Tools"}),e[78]=qt,e[79]=_t):(qt=e[78],_t=e[79]),e[80]!==s?(te=r.jsx(ks,{asChild:!0,children:r.jsxs(ne,{type:"button",variant:"ghost",size:"default",disabled:s,className:"text-muted-foreground hover:text-foreground",children:[qt,_t]})}),e[80]=s,e[81]=te):te=e[81],$=Ns,Y="start",J="w-52 p-1.5";const xt=R&&"text-violet-600 dark:text-violet-400";let vt;e[82]!==xt?(vt=X(xt),e[82]=xt,e[83]=vt):vt=e[83];const _s=R&&"text-violet-500";let $e;e[84]!==_s?($e=X(_s),e[84]=_s,e[85]=$e):$e=e[85];let kt;e[86]!==$e?(kt=r.jsx(Xh,{size:16,className:$e}),e[86]=$e,e[87]=kt):kt=e[87];let Nt;e[88]===Symbol.for("react.memo_cache_sentinel")?(Nt=r.jsx("span",{className:"flex-1",children:"Plan mode"}),e[88]=Nt):Nt=e[88];let wt;e[89]!==R?(wt=R&&r.jsx("span",{className:"text-xs text-violet-500 font-medium",children:"On"}),e[89]=R,e[90]=wt):wt=e[90],e[91]!==Ne||e[92]!==vt||e[93]!==kt||e[94]!==wt?(ie=r.jsxs(ot,{onClick:Ne,className:vt,children:[kt,Nt,wt]}),e[91]=Ne,e[92]=vt,e[93]=kt,e[94]=wt,e[95]=ie):ie=e[95],H=E?r.jsxs(ot,{onClick:Kt,className:X(Ie&&"text-pink-600 dark:text-pink-400"),children:[r.jsx(la,{size:16,className:X(Ie&&"text-pink-500")}),r.jsx("span",{className:"flex-1",children:"Create image"}),Ie&&r.jsx("span",{className:"text-xs text-pink-500 font-medium",children:"On"})]}):r.jsxs(Sn,{open:M,onOpenChange:L,children:[r.jsxs("div",{className:"flex items-center rounded-lg",children:[r.jsxs(ot,{onClick:Kt,disabled:!w,className:X("flex-1 rounded-r-none pr-1",Ie&&"text-pink-600 dark:text-pink-400"),children:[r.jsx(la,{size:16,className:X(Ie&&"text-pink-500")}),r.jsx("span",{className:"flex-1",children:"Create image"}),Ie&&r.jsx("span",{className:"text-xs text-pink-500 font-medium",children:"On"})]}),r.jsx(lc,{className:X("flex items-center justify-center rounded-r-lg rounded-l-none px-1.5 py-1.5 text-muted-foreground outline-hidden select-none","hover:bg-accent hover:text-accent-foreground focus:bg-accent focus:text-accent-foreground","data-[state=open]:bg-accent data-[state=open]:text-accent-foreground"),children:r.jsx(kr,{size:14})})]}),r.jsx(wn,{className:"w-80 max-h-72 overflow-y-auto p-1.5",children:z?r.jsxs("div",{className:"flex items-center gap-2 px-2 py-3 text-sm text-muted-foreground",children:[r.jsx(Ee,{size:14,className:"animate-spin"}),"Loading models…"]}):Q.length===0?r.jsx("div",{className:"px-2 py-3 text-sm text-muted-foreground",children:"No image models available"}):Q.map(_e=>{const Ot=w?.modelId===_e.modelId,$t=xc(_e),ls=_e.title.includes(": ")?_e.title.split(": ").slice(1).join(": "):_e.title;return r.jsxs(ot,{onClick:()=>ke(_e),className:"flex items-center gap-2",children:[r.jsx("img",{src:$t,alt:"",className:"size-4 shrink-0 rounded-sm dark:bg-white dark:p-px"}),r.jsx("span",{className:"flex-1 text-sm truncate",children:ls}),Ot&&r.jsx(Jt,{size:14,className:"text-pink-500 shrink-0"})]},_e.modelId)})})]}),ee=E?r.jsxs(ot,{onClick:Ae,className:X(qe&&"text-blue-600 dark:text-blue-400"),children:[r.jsx(Ti,{size:16,className:X(qe&&"text-blue-500")}),r.jsx("span",{className:"flex-1",children:"Web search"}),qe&&r.jsx("span",{className:"text-xs text-blue-500 font-medium",children:"On"})]}):T&&r.jsxs(Sn,{open:D,onOpenChange:P,children:[r.jsxs("div",{className:"flex items-center rounded-lg",children:[r.jsxs(ot,{onClick:Ae,className:X("flex-1 rounded-r-none pr-1",qe&&"text-blue-600 dark:text-blue-400"),children:[r.jsx(Ti,{size:16,className:X(qe&&"text-blue-500")}),r.jsx("span",{className:"flex-1",children:"Web search"}),qe&&r.jsx("span",{className:"text-xs text-blue-500 font-medium",children:"On"})]}),r.jsx(lc,{className:X("flex items-center justify-center rounded-r-lg rounded-l-none px-1.5 py-1.5 text-muted-foreground outline-hidden select-none","hover:bg-accent hover:text-accent-foreground focus:bg-accent focus:text-accent-foreground","data-[state=open]:bg-accent data-[state=open]:text-accent-foreground"),children:r.jsx(kr,{size:14})})]}),r.jsx(wn,{className:"w-80 max-h-72 overflow-y-auto p-1.5",children:z?r.jsxs("div",{className:"flex items-center gap-2 px-2 py-3 text-sm text-muted-foreground",children:[r.jsx(Ee,{size:14,className:"animate-spin"}),"Loading models…"]}):ae.map(_e=>{const Ot=T?.modelId===_e.modelId,$t=xc(_e),ls=_e.title.includes(": ")?_e.title.split(": ").slice(1).join(": "):_e.title;return r.jsxs(ot,{onClick:()=>Ct(_e),className:"flex items-center gap-2",children:[r.jsx("img",{src:$t,alt:"",className:"size-4 shrink-0 rounded-sm dark:bg-white dark:p-px"}),r.jsx("span",{className:"flex-1 text-sm truncate",children:ls}),Ot&&r.jsx(Jt,{size:14,className:"text-blue-500 shrink-0"})]},_e.modelId)})})]}),e[14]=C,e[15]=O,e[16]=A,e[17]=h,e[18]=T,e[19]=s,e[20]=d,e[21]=w,e[22]=M,e[23]=z,e[24]=R,e[25]=i,e[26]=o,e[27]=l,e[28]=D,e[29]=N,e[30]=I,e[31]=k,e[32]=E,e[33]=$,e[34]=W,e[35]=F,e[36]=G,e[37]=q,e[38]=H,e[39]=ee,e[40]=K,e[41]=U,e[42]=te,e[43]=Y,e[44]=J,e[45]=ie}else $=e[33],W=e[34],F=e[35],G=e[36],q=e[37],H=e[38],ee=e[39],K=e[40],U=e[41],te=e[42],Y=e[43],J=e[44],ie=e[45];let ue;e[96]===Symbol.for("react.memo_cache_sentinel")?(ue=r.jsxs(Bh,{className:"gap-2",children:[r.jsx("span",{className:"flex size-4 items-center justify-center text-base font-medium text-muted-foreground",children:"/"}),r.jsx("span",{className:"flex-1",children:"Prompts"})]}),e[96]=ue):ue=e[96];let de;e[97]!==q||e[98]!==x||e[99]!==y?(de=x?r.jsxs("div",{className:"flex items-center gap-2 px-2 py-3 text-sm text-muted-foreground",children:[r.jsx(Ee,{size:14,className:"animate-spin"}),"Loading prompts…"]}):y.length===0?r.jsx("div",{className:"px-2 py-3 text-sm text-muted-foreground",children:"No prompts available"}):y.map(Q=>r.jsxs(ot,{onClick:()=>q(Q),className:"flex flex-col items-start gap-0.5",children:[r.jsx("span",{className:"font-medium text-sm capitalize",children:Q.title||eo(Q.name,si(Q._meta))}),Q.description&&r.jsx("span",{className:"text-xs text-muted-foreground line-clamp-2",children:Q.description})]},Q.name)),e[97]=q,e[98]=x,e[99]=y,e[100]=de):de=e[100];let xe;e[101]!==de?(xe=r.jsxs(Sn,{children:[ue,r.jsx(wn,{className:"w-80 max-h-72 overflow-y-auto p-1.5",children:de})]}),e[101]=de,e[102]=xe):xe=e[102];let oe,he;e[103]===Symbol.for("react.memo_cache_sentinel")?(oe=r.jsx(Lg,{size:16}),he=r.jsx("span",{className:"flex-1",children:"Connections"}),e[103]=oe,e[104]=he):(oe=e[103],he=e[104]);let me;e[105]===Symbol.for("react.memo_cache_sentinel")?(me=r.jsx(S.Suspense,{children:r.jsx(nv,{})}),e[105]=me):me=e[105];let fe;e[106]!==F?(fe=r.jsxs(ot,{onClick:F,children:[oe,he,me]}),e[106]=F,e[107]=fe):fe=e[107];let le;e[108]!==$||e[109]!==H||e[110]!==ee||e[111]!==xe||e[112]!==fe||e[113]!==Y||e[114]!==J||e[115]!==ie?(le=r.jsxs($,{align:Y,className:J,children:[ie,H,ee,xe,fe]}),e[108]=$,e[109]=H,e[110]=ee,e[111]=xe,e[112]=fe,e[113]=Y,e[114]=J,e[115]=ie,e[116]=le):le=e[116];let ve;e[117]!==W||e[118]!==K||e[119]!==U||e[120]!==te||e[121]!==le?(ve=r.jsxs(W,{open:K,onOpenChange:U,children:[te,le]}),e[117]=W,e[118]=K,e[119]=U,e[120]=te,e[121]=le,e[122]=ve):ve=e[122];let Ce;e[123]!==C||e[124]!==G?(Ce=r.jsx(Rl,{prompt:C,setPrompt:j,onSubmit:G}),e[123]=C,e[124]=G,e[125]=Ce):Ce=e[125];let Te;return e[126]!==ve||e[127]!==Ce?(Te=r.jsxs(r.Fragment,{children:[ve,Ce]}),e[126]=ve,e[127]=Ce,e[128]=Te):Te=e[128],Te}function lv(t){const e=t.modelId.toLowerCase().replace(/[^a-z0-9]/g,"");return e.includes("sonar")||e.includes("deepresearch")}function cv(t){return t.capabilities?.includes("image")}function dv({open:t,onOpenChange:e,onCreated:s}){const{org:i}=be(),{data:n}=St.useSession(),{stdioEnabled:o}=Zm(),a=Rs(),l=Sl(),c=lu(),u=cu(c,"").items,h=Hi({resolver:Or(t_),defaultValues:{title:"",description:null,icon:null,ui_type:"HTTP",connection_url:"",connection_token:null,npx_package:"",stdio_command:"",stdio_args:"",stdio_cwd:"",env_vars:[]}}),f=h.watch("ui_type"),m=h.watch("connection_url"),p=h.watch("npx_package"),g=on({uiType:f,connectionUrl:m??"",npxPackage:p??""})??vc({uiType:f,connectionUrl:m??"",registryItems:u}),_=V=>{const w=V.trim();if(!w)return;const k=!!h.formState.dirtyFields.title,T=!!h.formState.dirtyFields.description,I=!!h.formState.dirtyFields.env_vars,A=E=>{if(E&&(!k&&!h.getValues("title").trim()&&E.title&&h.setValue("title",E.title,{shouldDirty:!1}),!T&&!(h.getValues("description")??"").trim()&&E.description&&h.setValue("description",E.description,{shouldDirty:!1}),!I&&E.envVarKeys?.length)){const R=h.getValues("env_vars")??[],M=new Set(R.map(D=>D.key)),L=E.envVarKeys.filter(D=>!M.has(D));L.length>0&&h.setValue("env_vars",[...R,...L.map(D=>({key:D,value:""}))],{shouldDirty:!0})}},N=i_(w);if(N&&o){h.setValue("ui_type","NPX",{shouldDirty:!0}),h.setValue("npx_package",N.packageName,{shouldDirty:!0}),h.setValue("connection_url","",{shouldDirty:!0}),h.setValue("connection_token",null,{shouldDirty:!0}),A(on({uiType:"NPX",npxPackage:N.packageName}));return}if(w.startsWith("http://")||w.startsWith("https://")){const E=f==="HTTP"||f==="SSE"||f==="Websocket"?f:"HTTP";h.setValue("ui_type",E,{shouldDirty:!0}),h.setValue("connection_url",w,{shouldDirty:!0}),A(on({uiType:E,connectionUrl:w})??vc({uiType:E,connectionUrl:w,registryItems:u}));return}f==="NPX"&&A(on({uiType:"NPX",npxPackage:w}))},v=V=>{V||h.reset(),e(V)},x=async V=>{let w,k=null,T=null,I=null;V.ui_type==="NPX"?(w="STDIO",k="",I=r_(V.npx_package||"",V.env_vars||[])):V.ui_type==="STDIO"?(w="STDIO",k="",I=n_(V.stdio_command||"",V.stdio_args||"",V.stdio_cwd,V.env_vars||[])):(w=V.ui_type,k=V.connection_url||"",T=V.connection_token||null);const A=hu("conn");try{await l.create.mutateAsync({id:A,title:V.title,description:V.description||null,connection_type:w,connection_url:k,connection_token:T,created_at:new Date().toISOString(),updated_at:new Date().toISOString(),created_by:n?.user?.id||"system",organization_id:i.id,icon:V.icon??null,app_name:null,app_id:null,connection_headers:I,oauth_config:null,configuration_state:null,metadata:null,tools:null,bindings:null,status:"inactive"}),h.reset(),e(!1),s?.(A)}catch{pe.error("Failed to create connection")}},b="Create Connection",y="Create a custom connection in your organization. Fill in the details below.",C=h.formState.isSubmitting?"Saving...":"Create Connection",j=r.jsxs("div",{className:"grid gap-4",children:[r.jsx(It,{control:h.control,name:"ui_type",render:({field:V})=>r.jsxs(Rt,{children:[r.jsx(rs,{children:"Type *"}),r.jsxs(Qs,{value:V.value,onValueChange:V.onChange,children:[r.jsx(Tt,{children:r.jsx(Zs,{children:r.jsx(ei,{})})}),r.jsxs(Js,{children:[r.jsx(Ht,{value:"HTTP",children:r.jsxs("span",{className:"flex items-center gap-2",children:[r.jsx(Ti,{className:"w-4 h-4"}),"HTTP"]})}),r.jsx(Ht,{value:"SSE",children:r.jsxs("span",{className:"flex items-center gap-2",children:[r.jsx(Ti,{className:"w-4 h-4"}),"SSE"]})}),r.jsx(Ht,{value:"Websocket",children:r.jsxs("span",{className:"flex items-center gap-2",children:[r.jsx(Ti,{className:"w-4 h-4"}),"Websocket"]})}),o&&r.jsxs(r.Fragment,{children:[r.jsx(Ht,{value:"NPX",children:r.jsxs("span",{className:"flex items-center gap-2",children:[r.jsx(Vn,{className:"w-4 h-4"}),"NPX Package"]})}),r.jsx(Ht,{value:"STDIO",children:r.jsxs("span",{className:"flex items-center gap-2",children:[r.jsx(fl,{className:"w-4 h-4"}),"Custom Command"]})})]})]})]}),r.jsx(Dt,{})]})}),f==="NPX"&&r.jsx(It,{control:h.control,name:"npx_package",render:({field:V})=>r.jsxs(Rt,{children:[r.jsx(rs,{children:"NPM Package *"}),r.jsx(Tt,{children:r.jsx(bt,{placeholder:"@perplexity-ai/mcp-server",...V,value:V.value??"",onPaste:w=>{const k=w.clipboardData.getData("text");k&&(w.preventDefault(),h.setValue("npx_package",k.trim(),{shouldDirty:!0}),_(k))},onBlur:w=>{_(w.target.value),V.onBlur()}})}),r.jsx(Dt,{})]})}),f==="STDIO"&&r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"grid grid-cols-2 gap-4 items-start",children:[r.jsx(It,{control:h.control,name:"stdio_command",render:({field:V})=>r.jsxs(Rt,{children:[r.jsx(rs,{children:"Command *"}),r.jsx(Tt,{children:r.jsx(bt,{placeholder:"node, bun, python...",...V,value:V.value??""})}),r.jsx(Dt,{})]})}),r.jsx(It,{control:h.control,name:"stdio_args",render:({field:V})=>r.jsxs(Rt,{children:[r.jsx(rs,{children:"Arguments"}),r.jsx(Tt,{children:r.jsx(bt,{placeholder:"arg1 arg2 --flag value",...V,value:V.value??""})}),r.jsx(Dt,{})]})})]}),r.jsx(It,{control:h.control,name:"stdio_cwd",render:({field:V})=>r.jsxs(Rt,{children:[r.jsx(rs,{children:"Working Directory"}),r.jsx(Tt,{children:r.jsx(bt,{placeholder:"/path/to/project (optional)",...V,value:V.value??""})}),r.jsx("p",{className:"text-xs text-muted-foreground",children:"Directory where the command will be executed"}),r.jsx(Dt,{})]})})]}),(f==="NPX"||f==="STDIO")&&r.jsx(It,{control:h.control,name:"env_vars",render:({field:V})=>r.jsxs(Rt,{children:[r.jsx(rs,{children:"Environment Variables"}),r.jsx(Tt,{children:r.jsx(s_,{value:V.value??[],onChange:V.onChange})}),r.jsx(Dt,{})]})}),f!=="NPX"&&f!=="STDIO"&&r.jsxs(r.Fragment,{children:[r.jsx(It,{control:h.control,name:"connection_url",render:({field:V})=>r.jsxs(Rt,{children:[r.jsx(rs,{children:"URL *"}),r.jsx(Tt,{children:r.jsx(bt,{placeholder:"https://example.com/mcp",...V,value:V.value??"",onPaste:w=>{const k=w.clipboardData.getData("text");k&&(w.preventDefault(),h.setValue("connection_url",k.trim(),{shouldDirty:!0}),_(k))},onBlur:w=>{_(w.target.value),V.onBlur()}})}),r.jsx(Dt,{})]})}),r.jsx(It,{control:h.control,name:"connection_token",render:({field:V})=>r.jsxs(Rt,{children:[r.jsx(rs,{children:g?.token?.label??"Token (optional)"}),r.jsx(Tt,{children:r.jsx(bt,{type:"password",placeholder:g?.token?.placeholder??"Bearer token or API key",className:"ph-no-capture",...V,value:V.value??""})}),g?.token?.helperText&&r.jsxs("p",{className:"text-xs text-muted-foreground",children:[g.token.helperText,g.id==="github"&&r.jsxs(r.Fragment,{children:[" ","·"," ",r.jsx("a",{className:"text-foreground underline underline-offset-4 hover:text-foreground/80",href:"https://github.com/settings/personal-access-tokens",target:"_blank",rel:"noreferrer",children:"Open GitHub PAT settings"})]})]}),r.jsx(Dt,{})]})})]}),r.jsx(It,{control:h.control,name:"title",render:({field:V})=>r.jsxs(Rt,{children:[r.jsx(rs,{children:"Name *"}),r.jsx(Tt,{children:r.jsx(bt,{placeholder:"My Connection",...V})}),r.jsx(Dt,{})]})}),r.jsx(It,{control:h.control,name:"description",render:({field:V})=>r.jsxs(Rt,{children:[r.jsx(rs,{children:"Description"}),r.jsx(Tt,{children:r.jsx(ca,{placeholder:"A brief description of this connection",rows:3,...V,value:V.value??""})}),r.jsx(Dt,{})]})})]});return a?r.jsx(Si,{open:t,onOpenChange:v,children:r.jsxs(yi,{className:"max-h-[90vh]",children:[r.jsx(so,{className:"pb-2",children:r.jsxs("div",{className:"flex items-start justify-between gap-4",children:[r.jsxs("div",{className:"flex-1 text-left",children:[r.jsx(bi,{children:b}),r.jsx(ng,{className:"mt-1",children:y})]}),r.jsx(og,{asChild:!0,children:r.jsx(ne,{variant:"ghost",size:"icon",className:"shrink-0 -mt-1",children:r.jsx(ii,{size:16})})})]})}),r.jsx(Pi,{...h,children:r.jsxs("form",{onSubmit:h.handleSubmit(x),children:[r.jsx("div",{className:"overflow-y-auto px-4 pb-4",children:j}),r.jsx(ag,{children:r.jsx(ne,{type:"submit",disabled:h.formState.isSubmitting,className:"w-full",children:C})})]})})]})}):r.jsx(ps,{open:t,onOpenChange:v,children:r.jsxs(ms,{className:"sm:max-w-[525px]",children:[r.jsxs(Ds,{children:[r.jsx(Ts,{children:b}),r.jsx(dl,{children:y})]}),r.jsx(Pi,{...h,children:r.jsxs("form",{onSubmit:h.handleSubmit(x),children:[r.jsx("div",{className:"py-4",children:j}),r.jsxs(cl,{children:[r.jsx(ne,{type:"button",variant:"outline",onClick:()=>v(!1),children:"Cancel"}),r.jsx(ne,{type:"submit",disabled:h.formState.isSubmitting,className:"min-w-40",children:C})]})]})})]})})}function hv(t){const e=B.c(79),{mode:s,agentId:i,addedConnectionIds:n,onAdd:o,onCloneAndAdd:a,onConnectAndAdd:l,connectingItemId:c,search:d,onCreateConnection:u,onBrowseNavigate:h,defaultTab:f}=t,m=s===void 0?"add":s,p=f===void 0?"connected":f,{org:g}=be(),_=S.useDeferredValue(d),v=d!==_;let x;e[0]!==_?(x=_.toLowerCase(),e[0]=_,e[1]=x):x=e[1];const b=x;let y;e[2]!==p?(y=ge=>ge??p,e[2]=p,e[3]=y):y=e[3];const[C,j]=nl(ol.connectionsTab(g.slug)+(p==="all"?":home-modal":":agent-modal"),y);let V;e[4]!==C||e[5]!==j?(V=ge=>{ge!==C&&se("connections_dialog_tab_changed",{to_tab:ge}),j(ge)},e[4]=C,e[5]=j,e[6]=V):V=e[6];const w=V;let k;e[7]!==g.id?(k={connectionId:Wt,orgId:g.id},e[7]=g.id,e[8]=k):k=e[8];const T=Me(k);let I,A,N;if(e[9]!==T||e[10]!==_||e[11]!==g.id){N=_?.trim()?{operator:"or",conditions:[{field:["title"],operator:"contains",value:_.trim()},{field:["description"],operator:"contains",value:_.trim()}]}:void 0;const ge={...N&&{where:N},orderBy:[{field:["updated_at"],direction:"asc"}],limit:100,offset:0},ke=JSON.stringify(ge);A=o_,I=lt.collectionListInfinite(T,g.id,"","CONNECTIONS",ke),e[9]=T,e[10]=_,e[11]=g.id,e[12]=I,e[13]=A,e[14]=N}else I=e[12],A=e[13],N=e[14];let E;e[15]!==T||e[16]!==N?(E=async ge=>{const{pageParam:ke}=ge,Qe=ke===void 0?0:ke;return(await T.callTool({name:"COLLECTION_CONNECTIONS_LIST",arguments:{...N&&{where:N},orderBy:[{field:["updated_at"],direction:"asc"}],limit:100,offset:Qe}})).structuredContent},e[15]=T,e[16]=N,e[17]=E):E=e[17];let R;e[18]!==I||e[19]!==E?(R={queryKey:I,queryFn:E,initialPageParam:0,getNextPageParam:_v,staleTime:3e4},e[18]=I,e[19]=E,e[20]=R):R=e[20];const{data:M,fetchNextPage:L,hasNextPage:D,isFetchingNextPage:P}=A(R),O=M?.pages.flatMap(gv)??[],z=e_(O),$=new Set(O.filter(pv).map(mv)),W=lu(),F=cu(W,_),G=bc(F.loadMore,F.hasMore,F.isLoadingMore),q=bc(L,D??!1,P),H=C==="all"||!!b,ee=H?F.items.filter(ge=>{const ke=u_(ge);return!(ke&&$.has(ke))}):[],K=ee.filter(fv),U=ee.filter(uv);let te;e[21]!==n?(te=ge=>ge.some(ke=>n.has(ke.id)),e[21]=n,e[22]=te):te=e[22];const Y=te;let J;e[23]!==n||e[24]!==i||e[25]!==c||e[26]!==Y||e[27]!==m||e[28]!==o||e[29]!==h||e[30]!==a?(J=(ge,ke,Qe,Ct,Pe)=>{const Kt=Y(Pe),jt=Pe.find(Ie=>!n.has(Ie.id)),Ae=Pe[0];if(m==="browse"){const Ie=ou(Ae);return r.jsx(jo,{connection:{title:ke,icon:Qe,description:Pe.length>1?`${Pe.length} instances`:Ct??void 0},fallbackIcon:r.jsx(Vn,{}),headerActionsAlwaysVisible:!0,headerActions:r.jsxs(wc,{variant:"secondary",className:"text-xs gap-1 font-normal",children:[r.jsx(Jt,{size:11})," Connected"]}),onClick:()=>{se("connection_browse_clicked",{app_name:Ae.app_name??null,connection_id:Ae.id,instances_count:Pe.length}),h?.(Ie)}},ge)}return r.jsx(jo,{connection:{title:ke,icon:Qe,description:Ct},fallbackIcon:r.jsx(Vn,{}),headerActionsAlwaysVisible:!0,headerActions:r.jsxs("div",{className:"flex items-center gap-1.5",children:[Kt&&r.jsxs(wc,{variant:"secondary",className:"text-xs gap-1 font-normal",children:[r.jsx(Jt,{size:11})," Added"]}),r.jsx(ne,{variant:"outline",size:"sm",className:"h-7 px-3 text-xs font-medium",disabled:c!==null,onClick:Ie=>{Ie.stopPropagation(),jt?(se("connection_add_clicked",{action:"use_existing",app_name:Ae.app_name??null,connection_id:jt.id}),i&&se("agent_connection_attached",{agent_id:i,connection_id:jt.id,app_name:Ae.app_name??null,mode:"existing"}),o(jt.id)):(se("connection_add_clicked",{action:"clone",app_name:Ae.app_name??null,base_connection_id:Ae.id}),a(Ae))},children:"Add"})]})},ge)},e[23]=n,e[24]=i,e[25]=c,e[26]=Y,e[27]=m,e[28]=o,e[29]=h,e[30]=a,e[31]=J):J=e[31];const ie=J;let ue;e[32]!==c||e[33]!==m||e[34]!==l?(ue=ge=>{const ke=ge._meta?.["mcp.mesh"],Qe=ke?.friendlyName||ke?.friendly_name||ge.server?.title||ge.title||ge.server?.name||ge.name||ge.id||"",Ct=ge.server?.description||ge.description||null,Pe=ge.server?.icons?.[0]?.src||m_(ge.server?.repository)||null;return r.jsx(jo,{connection:{title:Qe,description:Ct,icon:Pe},fallbackIcon:r.jsx(Vn,{}),headerActionsAlwaysVisible:!0,headerActions:r.jsx(ne,{variant:"outline",size:"sm",className:"h-7 px-3 text-xs font-medium",disabled:c!==null,onClick:Kt=>{Kt.stopPropagation(),se("connection_add_clicked",{action:"connect_new",registry_item_id:ge.id,app_name:ge._meta?.["mcp.mesh"]?.friendlyName||ge.server?.name||ge.name||null}),l(ge)},children:c===ge.id?r.jsx(Ee,{size:14,className:"animate-spin"}):m==="browse"?"Connect":"Add"})},`catalog-${ge.id}`)},e[32]=c,e[33]=m,e[34]=l,e[35]=ue):ue=e[35];const de=ue;let xe;e[36]!==C||e[37]!==w||e[38]!==u||e[39]!==b?(xe=!b&&r.jsxs("div",{className:"flex items-center justify-between px-5 py-3 border-b border-border shrink-0",children:[r.jsx(du,{tabs:[{id:"all",label:"All"},{id:"connected",label:"Connected"}],activeTab:C,onTabChange:ge=>w(ge)}),r.jsxs(ne,{variant:"outline",size:"sm",className:"h-7 px-2 text-sm",onClick:()=>{se("connections_dialog_custom_clicked"),u()},children:[r.jsx(Qt,{size:12}),"Custom Connection"]})]}),e[36]=C,e[37]=w,e[38]=u,e[39]=b,e[40]=xe):xe=e[40];const oe=v&&"opacity-50 pointer-events-none";let he;e[41]!==oe?(he=X("flex-1 overflow-auto p-5 transition-opacity duration-150",oe),e[41]=oe,e[42]=he):he=e[42];const me="grid grid-cols-[repeat(auto-fill,minmax(260px,1fr))] gap-4";let fe;e[43]!==ie?(fe=ge=>{if(ge.type==="group")return ie(ge.key,ge.title,ge.icon,null,ge.connections);const ke=ge.connection;return ie(ke.id,ke.title,ke.icon,ke.description??null,[ke])},e[43]=ie,e[44]=fe):fe=e[44];const le=z.map(fe);let ve;e[45]!==q?(ve=r.jsx("div",{ref:q,className:"col-span-full h-1"}),e[45]=q,e[46]=ve):ve=e[46];let Ce;e[47]!==P?(Ce=P&&r.jsx("div",{className:"col-span-full flex justify-center py-6",children:r.jsx(Ee,{size:24,className:"animate-spin text-muted-foreground"})}),e[47]=P,e[48]=Ce):Ce=e[48];const Te=H&&K.length>0&&r.jsxs("div",{className:"col-span-full flex items-center gap-2 mt-2",children:[r.jsx(Bg,{size:13,className:"text-muted-foreground shrink-0"}),r.jsx("span",{className:"text-sm font-medium text-muted-foreground whitespace-nowrap",children:"Verified"}),r.jsx("div",{className:"flex-1 h-px bg-border"})]}),Q=H&&K.map(de),ae=H&&U.length>0&&r.jsxs("div",{className:"col-span-full flex items-center gap-2 mt-2",children:[r.jsx("span",{className:"text-sm font-medium text-muted-foreground whitespace-nowrap",children:"All connections"}),r.jsx("div",{className:"flex-1 h-px bg-border"})]}),Se=H&&U.map(de);let Ne;e[49]!==G||e[50]!==W||e[51]!==H?(Ne=H&&W.length>0&&r.jsx("div",{ref:G,className:"col-span-full h-1"}),e[49]=G,e[50]=W,e[51]=H,e[52]=Ne):Ne=e[52];let Be;e[53]!==F.isLoadingMore||e[54]!==H?(Be=H&&F.isLoadingMore&&r.jsx("div",{className:"col-span-full flex justify-center py-6",children:r.jsx(Ee,{size:24,className:"animate-spin text-muted-foreground"})}),e[53]=F.isLoadingMore,e[54]=H,e[55]=Be):Be=e[55];let Oe;e[56]!==le||e[57]!==ve||e[58]!==Ce||e[59]!==Te||e[60]!==Q||e[61]!==ae||e[62]!==Se||e[63]!==Ne||e[64]!==Be?(Oe=r.jsxs("div",{className:me,children:[le,ve,Ce,Te,Q,ae,Se,Ne,Be]}),e[56]=le,e[57]=ve,e[58]=Ce,e[59]=Te,e[60]=Q,e[61]=ae,e[62]=Se,e[63]=Ne,e[64]=Be,e[65]=Oe):Oe=e[65];let He;e[66]!==C||e[67]!==z.length||e[68]!==U||e[69]!==d||e[70]!==K?(He=z.length===0&&K.length===0&&U.length===0&&r.jsx("div",{className:"flex items-center justify-center h-48 text-sm text-muted-foreground",children:d?`No connections match "${d}"`:C==="connected"?"No connections yet":"No connections available"}),e[66]=C,e[67]=z.length,e[68]=U,e[69]=d,e[70]=K,e[71]=He):He=e[71];let Je;e[72]!==he||e[73]!==Oe||e[74]!==He?(Je=r.jsxs("div",{className:he,children:[Oe,He]}),e[72]=he,e[73]=Oe,e[74]=He,e[75]=Je):Je=e[75];let dt;return e[76]!==xe||e[77]!==Je?(dt=r.jsxs(r.Fragment,{children:[xe,Je]}),e[76]=xe,e[77]=Je,e[78]=dt):dt=e[78],dt}function uv(t){return!t.verified&&!t._meta?.["mcp.mesh"]?.verified&&!t.meta?.verified}function fv(t){return t.verified||t._meta?.["mcp.mesh"]?.verified||t.meta?.verified}function mv(t){return t.app_name}function pv(t){return t.app_name}function gv(t){return t?.items??[]}function _v(t,e){if(t?.hasMore)return e.reduce(xv,0)}function xv(t,e){return t+(e?.items?.length??0)}function Pl({open:t,onOpenChange:e,defaultTab:s,initialSearch:i="",...n}){const o=n.mode??"add",a="agentId"in n?n.agentId:void 0,l="addedConnectionIds"in n?n.addedConnectionIds??new Set:new Set,c="onAdd"in n&&n.onAdd?n.onAdd:w=>{},d=(w,k,T)=>{a&&se("agent_connection_attached",{agent_id:a,connection_id:w,app_name:k,mode:T})},[u,h]=S.useState(null),[f,m]=S.useState(i),[p,g]=S.useState(!1),{org:_}=be(),{data:v}=St.useSession(),x=Sl(),b=Mt(),y=Ke(),C=w=>{e(!1),y({to:"/$org/settings/connections/$appSlug",params:{org:_.slug,appSlug:w}})},j=async w=>{h(w.app_name??w.id);try{const T=`${w.title.replace(/\s*\(\d+\)\s*$/,"")} (${Date.now().toString(36).slice(-4)})`,A=(await x.create.mutateAsync({title:T,description:w.description??null,connection_type:w.connection_type,connection_url:w.connection_url??null,connection_token:null,icon:w.icon??null,app_name:w.app_name??null,app_id:w.app_id??null,connection_headers:w.connection_headers??null})).id,N=new URL(`/mcp/${A}`,window.location.origin),E=await pr({url:N.href,token:null});if(E.supportsOAuth&&!E.isAuthenticated){const{token:R,tokenInfo:M,error:L}=await vn({connectionId:A,scope:"offline_access"});if(L||!R){se("connection_oauth_failed",{connection_id:A,flow:"clone",error:L??"no_token"}),pe.error(`Authentication failed: ${L??"no token received"}`),await x.delete.mutateAsync(A);return}if(se("connection_oauth_succeeded",{connection_id:A,flow:"clone"}),M)try{(await fetch(`/api/connections/${A}/oauth-token`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({accessToken:M.accessToken,refreshToken:M.refreshToken,expiresIn:M.expiresIn,scope:M.scope,clientId:M.clientId,clientSecret:M.clientSecret,tokenEndpoint:M.tokenEndpoint})})).ok?await x.update.mutateAsync({id:A,data:{}}):await x.update.mutateAsync({id:A,data:{connection_token:R}})}catch{await x.update.mutateAsync({id:A,data:{connection_token:R}})}else await x.update.mutateAsync({id:A,data:{connection_token:R}});await b.invalidateQueries({queryKey:lt.isMCPAuthenticated(N.href,null)})}d(A,w.app_name??null,"clone"),c(A)}catch(k){console.error("Failed to add connection:",k),pe.error("Failed to add connection")}finally{h(null)}},V=async w=>{if(!(!_||!v?.user?.id)){h(w.id);try{const k=f_(w,_.id,v.user.id,{remoteIndex:0}),T=k.connection_type==="STDIO",I=!!k.connection_url,A=T&&k.connection_headers&&typeof k.connection_headers=="object"&&"command"in k.connection_headers;if(!I&&!A){pe.error("This MCP Server cannot be connected: no connection method available"),h(null);return}const{id:N}=await x.create.mutateAsync(k),E=new URL(`/mcp/${N}`,window.location.origin),R=await pr({url:E.href,token:null});if(R.supportsOAuth&&!R.isAuthenticated){const{token:M,tokenInfo:L,error:D}=await vn({connectionId:N,scope:"offline_access"});if(D||!M){se("connection_oauth_failed",{connection_id:N,flow:"connect_new",error:D??"no_token"}),pe.error(`Authentication failed: ${D??"no token received"}`),d(N,k.app_name??null,"new"),c(N);return}if(se("connection_oauth_succeeded",{connection_id:N,flow:"connect_new"}),L)try{(await fetch(`/api/connections/${N}/oauth-token`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({accessToken:L.accessToken,refreshToken:L.refreshToken,expiresIn:L.expiresIn,scope:L.scope,clientId:L.clientId,clientSecret:L.clientSecret,tokenEndpoint:L.tokenEndpoint})})).ok?await x.update.mutateAsync({id:N,data:{}}):await x.update.mutateAsync({id:N,data:{connection_token:M}})}catch{await x.update.mutateAsync({id:N,data:{connection_token:M}})}else await x.update.mutateAsync({id:N,data:{connection_token:M}});await b.invalidateQueries({queryKey:lt.isMCPAuthenticated(E.href,null)}),pe.success("Connected and authenticated")}else pe.success("Connected");d(N,k.app_name??null,"new"),c(N)}catch(k){console.error("Failed to connect:",k),pe.error("Failed to connect")}finally{h(null)}}};return r.jsxs(ps,{open:t,onOpenChange:e,children:[r.jsxs(ms,{className:"sm:max-w-5xl h-[85vh] max-h-[85vh] flex flex-col p-0 gap-0 overflow-hidden w-[95vw]",children:[r.jsx(Ds,{className:"px-6 pt-5 pb-0 shrink-0",children:r.jsx(Ts,{className:"text-base font-semibold",children:o==="browse"?"Connections":"Add Connection"})}),r.jsx("div",{className:"pt-3 shrink-0",children:r.jsx(Th,{value:f,onChange:m,placeholder:"Search connections..."})}),r.jsx(S.Suspense,{fallback:r.jsx("div",{className:"flex-1 flex items-center justify-center",children:r.jsx(Ee,{size:24,className:"animate-spin text-muted-foreground"})}),children:r.jsx(hv,{mode:o,agentId:a,addedConnectionIds:l,onAdd:c,onCloneAndAdd:j,onConnectAndAdd:V,connectingItemId:u,search:f,onCreateConnection:()=>g(!0),onBrowseNavigate:C,defaultTab:s})})]}),r.jsx(dv,{open:p,onOpenChange:g,onCreated:async w=>{g(!1);const k=new URL(`/mcp/${w}`,window.location.origin),T=await pr({url:k.href,token:null});if(T.supportsOAuth&&!T.isAuthenticated){const{token:I,tokenInfo:A,error:N}=await vn({connectionId:w,scope:"offline_access"});if(N||!I){se("connection_oauth_failed",{connection_id:w,flow:"custom_create",error:N??"no_token"}),pe.error(`Authentication failed: ${N??"no token received"}`),await x.delete.mutateAsync(w);return}if(se("connection_oauth_succeeded",{connection_id:w,flow:"custom_create"}),A)try{(await fetch(`/api/connections/${w}/oauth-token`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({accessToken:A.accessToken,refreshToken:A.refreshToken,expiresIn:A.expiresIn,scope:A.scope,clientId:A.clientId,clientSecret:A.clientSecret,tokenEndpoint:A.tokenEndpoint})})).ok?await x.update.mutateAsync({id:w,data:{}}):await x.update.mutateAsync({id:w,data:{connection_token:I}})}catch{await x.update.mutateAsync({id:w,data:{connection_token:I}})}else await x.update.mutateAsync({id:w,data:{connection_token:I}});await b.invalidateQueries({queryKey:lt.isMCPAuthenticated(k.href,null)})}d(w,null,"custom"),c(w),e(!1)}})]})}const vv=[{src:"/connections/github.png",name:"GitHub"},{src:"/connections/gmail.png",name:"Gmail"},{src:"/connections/linear.png",name:"Linear"},{src:"/connections/shopify.png",name:"Shopify"},{src:"/connections/firecrawl.png",name:"Firecrawl"},{src:"/connections/perplexity.png",name:"Perplexity"}];function bv(){const t=B.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=r.jsx("div",{className:"flex items-center -space-x-1",children:vv.map(yv)}),t[0]=e):e=t[0],e}function yv(t){return r.jsx("img",{src:t.src,alt:t.name,className:"size-5 rounded-sm ring-2 ring-muted object-cover bg-white"},t.name)}function Sv(t){const e=B.c(6),{onClick:s}=t;let i,n,o,a;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=X("group relative z-10 flex items-center gap-3 w-full px-4 py-3","rounded-b-2xl","cursor-pointer"),n=r.jsx("p",{className:"flex-1 text-xs text-muted-foreground truncate text-left",children:"Connect tools and get more done"}),o=r.jsx(bv,{}),a=r.jsx(Vl,{size:14,className:"shrink-0 text-muted-foreground/60 group-hover:text-muted-foreground transition-colors"}),e[0]=i,e[1]=n,e[2]=o,e[3]=a):(i=e[0],n=e[1],o=e[2],a=e[3]);let l;return e[4]!==s?(l=r.jsxs("button",{type:"button",onClick:s,className:i,children:[n,o,a]}),e[4]=s,e[5]=l):l=e[5],l}const cr=48;function wv(){const t=B.c(9),[e,s]=S.useState("idle"),[i,n]=S.useState(""),[o,a]=S.useState(""),[l,c]=S.useState(jv),d=S.useRef(null),u=S.useRef(null),h=S.useRef(null),f=S.useRef(null),m=S.useRef(0),p=S.useRef(!1),g=S.useRef(""),_=S.useRef(""),v=typeof window<"u"&&!!(window.SpeechRecognition||window.webkitSpeechRecognition);let x;t[0]===Symbol.for("react.memo_cache_sentinel")?(x=()=>{m.current&&(cancelAnimationFrame(m.current),m.current=0),u.current?.close().catch(Cv),f.current?.getTracks().forEach(Vv),h.current=null,u.current=null,f.current=null},t[0]=x):x=t[0];const b=x;let y;if(t[1]===Symbol.for("react.memo_cache_sentinel")){const I=A=>{f.current=A;const N=new AudioContext;u.current=N;const E=N.createMediaStreamSource(A),R=N.createAnalyser();R.fftSize=128,R.smoothingTimeConstant=.8,E.connect(R),h.current=R;const M=new Uint8Array(R.frequencyBinCount),L=()=>{if(!h.current)return;h.current.getByteFrequencyData(M);const D=[];for(let P=0;P<cr;P++){const O=Math.floor(P/cr*M.length);D.push(Math.max(.04,(M[O]??0)/255))}c(D),m.current=requestAnimationFrame(L)};L()};y=async()=>{const A=window.SpeechRecognition||window.webkitSpeechRecognition;if(!A){s("unsupported");return}let N;try{N=await navigator.mediaDevices.getUserMedia({audio:!0})}catch{s("permission-denied");return}n(""),a(""),_.current="",g.current="",p.current=!0,s("recording"),I(N);const E=new A;d.current=E,E.interimResults=!0,E.continuous=!0,E.lang=navigator.language||"en-US",E.onresult=R=>{let M="",L="";for(let D=R.resultIndex;D<R.results.length;D++){const P=R.results[D],O=P?.[0]?.transcript??"";P?.isFinal?L=L+O:M=M+O}L&&(g.current=g.current+L,n(g.current)),_.current=M,a(M)},E.onend=()=>{if(p.current)try{E.start()}catch{}};try{E.start()}catch{s("idle")}},t[1]=y}else y=t[1];const C=y;let j;t[2]===Symbol.for("react.memo_cache_sentinel")?(j=()=>{p.current=!1,d.current?.stop(),b(),s("idle"),c(Array(cr).fill(.05)),a("");const I=(g.current+(_.current?" "+_.current:"")).trim();return n(""),g.current="",_.current="",I},t[2]=j):j=t[2];const V=j;let w;t[3]===Symbol.for("react.memo_cache_sentinel")?(w=()=>{p.current=!1,d.current?.abort(),b(),s("idle"),n(""),a(""),c(Array(cr).fill(.05)),g.current="",_.current=""},t[3]=w):w=t[3];const k=w;let T;return t[4]!==o||t[5]!==e||t[6]!==i||t[7]!==l?(T={status:e,transcript:i,interimTranscript:o,waveformData:l,isSupported:v,startRecording:C,stopRecording:V,cancelRecording:k},t[4]=o,t[5]=e,t[6]=i,t[7]=l,t[8]=T):T=t[8],T}function Vv(t){return t.stop()}function Cv(){}function jv(){return Array(cr).fill(.05)}function kv(t){const e=B.c(4),{data:s}=t;let i;e[0]!==s?(i=s.map(Nv),e[0]=s,e[1]=i):i=e[1];let n;return e[2]!==i?(n=r.jsx("div",{className:"flex items-center justify-center gap-[2px] h-10 overflow-hidden","aria-hidden":"true",children:i}),e[2]=i,e[3]=n):n=e[3],n}function Nv(t,e){return r.jsx("div",{className:"w-[2px] shrink-0 rounded-full bg-chart-2 transition-[height] duration-75 ease-out",style:{height:`${Math.max(4,Math.round(t*40))}px`}},e)}const Io=[{value:"fast",label:"Fast",Icon:Hh,description:"Quicker responses"},{value:"smart",label:"Smart",Icon:_l,description:"Balanced quality"},{value:"thinking",label:"Thinking",Icon:gg,description:"Deeper reasoning"}];function Av(t){const e=B.c(17),{tier:s,onSelect:i}=t;let n;e[0]!==s?(n=Io.find(m=>m.value===s)??Io[1],e[0]=s,e[1]=n):n=e[1];const o=n,a=o.Icon;let l;e[2]!==a?(l=r.jsx(a,{size:14}),e[2]=a,e[3]=l):l=e[3];let c;e[4]!==o.label?(c=r.jsx("span",{className:"hidden sm:inline",children:o.label}),e[4]=o.label,e[5]=c):c=e[5];let d;e[6]!==l||e[7]!==c?(d=r.jsx(ks,{asChild:!0,children:r.jsxs(ne,{type:"button",variant:"ghost",size:"default",className:"text-muted-foreground hover:text-foreground",children:[l,c]})}),e[6]=l,e[7]=c,e[8]=d):d=e[8];let u;e[9]!==i||e[10]!==s?(u=Io.map(m=>{const{value:p,label:g,Icon:_,description:v}=m;return r.jsxs(ot,{onSelect:()=>i(p),children:[r.jsx(_,{size:16,className:"text-muted-foreground"}),r.jsxs("div",{className:"flex flex-col gap-0.5 flex-1",children:[r.jsx("span",{children:g}),r.jsx("span",{className:"text-xs text-muted-foreground font-normal",children:v})]}),s===p&&r.jsx("span",{className:"text-xs text-muted-foreground font-medium",children:"On"})]},p)}),e[9]=i,e[10]=s,e[11]=u):u=e[11];let h;e[12]!==u?(h=r.jsx(Ns,{align:"end",className:"w-52 p-1.5",children:u}),e[12]=u,e[13]=h):h=e[13];let f;return e[14]!==d||e[15]!==h?(f=r.jsxs(js,{children:[d,h]}),e[14]=d,e[15]=h,e[16]=f):f=e[16],f}function Ev(t){const e=B.c(4),{editor:s}=to(),[i,n]=S.useState(!1),o=S.useRef(0);let a,l;return e[0]!==s||e[1]!==t?(a=()=>{const c=f=>{f.dataTransfer?.types.includes("Files")&&(f.preventDefault(),o.current=o.current+1,n(!0))},d=f=>{f.preventDefault(),o.current=Math.max(0,o.current-1),o.current===0&&n(!1)},u=Iv,h=f=>{if(f.preventDefault(),o.current=0,n(!1),!s||!t||!no(t))return;const m=f.dataTransfer?.files;if(!m||m.length===0)return;const{from:p}=s.state.selection;for(const g of Array.from(m))Tl(s,t,g,p)};return window.addEventListener("dragenter",c),window.addEventListener("dragleave",d),window.addEventListener("dragover",u),window.addEventListener("drop",h),()=>{window.removeEventListener("dragenter",c),window.removeEventListener("dragleave",d),window.removeEventListener("dragover",u),window.removeEventListener("drop",h)}},l=[s,t],e[0]=s,e[1]=t,e[2]=a,e[3]=l):(a=e[2],l=e[3]),S.useEffect(a,l),i}function Iv(t){t.dataTransfer?.types.includes("Files")&&t.preventDefault()}function Rv(t){const e=B.c(11),{selectedModel:s}=t,i=Ev(s);let n;e[0]!==s?(n=no(s),e[0]=s,e[1]=n):n=e[1];const o=n,a=i?"opacity-100":"opacity-0 pointer-events-none",l=o?"border-primary/40 text-primary/70":"border-destructive/30 text-destructive/70";let c;e[2]!==a||e[3]!==l?(c=X("absolute inset-0 z-20 rounded-xl flex flex-col items-center justify-center gap-2 bg-muted border-2 border-dashed transition-opacity",a,l),e[2]=a,e[3]=l,e[4]=c):c=e[4];let d;e[5]!==s||e[6]!==o?(d=o?r.jsxs(r.Fragment,{children:[r.jsx(Qh,{size:24}),r.jsxs("span",{className:"text-sm font-medium",children:["Drop ",su(s)," here"]})]}):r.jsxs(r.Fragment,{children:[r.jsx(Jh,{size:24}),r.jsx("span",{className:"text-sm font-medium",children:"This model can't read attachments — switch to one with vision or file support"})]}),e[5]=s,e[6]=o,e[7]=d):d=e[7];let u;return e[8]!==c||e[9]!==d?(u=r.jsx("div",{className:c,children:d}),e[8]=c,e[9]=d,e[10]=u):u=e[10],u}function Tv({onOpenContextPanel:t,showConnectionsBanner:e=!1}){const{messages:s,isStreaming:i,isRunInProgress:n,sendMessage:o,stop:a}=Ui(),{taskId:l,tasks:c}=es(),{selectedModel:d,selectedVirtualMcp:u,isModelsLoading:h,tiptapDocRef:f,imageModel:m,deepResearchModel:p,chatMode:g,setChatMode:_,simpleModeEnabled:v,simpleModeTier:x,setSimpleModeTier:b}=ni(),{data:y}=St.useSession(),C=y?.user?.id,{org:j}=be(),V=io(j.id).id,w=pa(_c),[k,T]=S.useState(!1),I=wv(),A=S.useRef(void 0),N=async()=>{A.current=L,await I.startRecording();const Y=I.status==="recording"?"started":I.status==="unsupported"?"unsupported":I.status==="permission-denied"?"permission_denied":"unknown";se("chat_voice_started",{thread_id:l,outcome:Y})},E=()=>{se("chat_voice_confirmed",{thread_id:l});const Y=I.stopRecording();W.current?.syncVoiceText(A.current,Y),W.current?.focus()},R=()=>{se("chat_voice_cancelled",{thread_id:l}),I.cancelRecording(),W.current?.restoreContent(A.current)};S.useEffect(()=>{if(I.status!=="recording")return;const Y=(I.transcript+(I.interimTranscript?" "+I.interimTranscript:"")).trim();W.current?.syncVoiceText(A.current,Y)},[I.transcript,I.interimTranscript,I.status]);const M=c.find(Y=>Y.id===l),[L,D]=S.useState(void 0),P=Y=>{D(Y),f.current=Y},O=S.useRef(l);O.current!==l&&(O.current=l,D(void 0),f.current=void 0);const $=[...s].reverse().find(Y=>Y.role==="assistant")?.metadata?.modelLimits?.contextWindow??d?.limits?.contextWindow,W=S.useRef(null),F=g==="plan";S.useEffect(()=>{const Y=J=>{Ph(J)&&J.code==="KeyL"&&(J.preventDefault(),J.shiftKey&&_(g==="plan"?"default":"plan"),W.current?.focus())};return document.addEventListener("keydown",Y),()=>document.removeEventListener("keydown",Y)},[g,_]);const G=Eh(s),q=[...s].reverse().find(Y=>Y.role==="assistant"&&Y.metadata?.usage)?.metadata?.usage,H=q?.contextTokens??(q?.totalTokens??0)-(q?.reasoningTokens??0),ee=pa(_c),K=!i&&!!d&&!h&&!G_(L),U=i||n,te=Y=>{Y?.preventDefault(),i?(se("chat_message_stopped",{thread_id:l}),a()):n?(se("chat_message_stopped",{thread_id:l}),a()):K&&L&&(se("chat_message_sent",{thread_id:l,mode:g,model_id:d?.modelId??null,model_provider:d?.providerId??null,virtual_mcp_id:u?.id??null,submission:Y?"button_or_enter":"programmatic"}),ee(),o(L),P(void 0))};return C&&M?.created_by&&M.created_by!==C?r.jsxs("div",{className:"flex w-full items-center gap-2 px-3 py-2.5 rounded-xl border border-border bg-muted/40 text-muted-foreground",children:[r.jsx(Jh,{size:14,className:"shrink-0"}),r.jsx("span",{className:"text-sm",children:"Read only — you're viewing someone else's thread"})]}):r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"flex flex-col w-full justify-end",children:r.jsxs("div",{className:"relative rounded-2xl w-full flex flex-col",children:[e&&r.jsx("div",{className:"absolute inset-0 rounded-2xl pointer-events-none bg-muted/50"}),r.jsx(ho,{}),r.jsx(Wu,{tiptapDoc:L,setTiptapDoc:P,disabled:i||!d,enterToSubmit:!0,onSubmit:te,children:r.jsxs("form",{onSubmit:te,className:X("w-full relative rounded-2xl min-h-[110px] md:min-h-[130px] flex flex-col bg-background dark:bg-muted card-shadow"),children:[r.jsx(Rv,{selectedModel:d}),r.jsx("div",{className:"group/input relative flex flex-col gap-2 flex-1",children:r.jsx(Uu,{ref:W,disabled:i||!d||I.status==="recording",virtualMcpId:u?.id??V,showFileUploader:!0,selectedModel:d})}),r.jsx("div",{className:"flex items-center justify-between p-2.5 gap-1",children:I.status==="recording"?r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"flex-1"}),r.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[r.jsx(kv,{data:I.waveformData.slice(0,28)}),r.jsx("button",{type:"button",onClick:R,className:"flex items-center justify-center size-8 rounded-lg hover:bg-muted text-muted-foreground hover:text-foreground transition-colors","aria-label":"Cancel recording",children:r.jsx(fi,{size:16})}),r.jsx("button",{type:"button",onClick:E,className:"flex items-center justify-center size-8 rounded-lg bg-foreground text-background hover:opacity-80 transition-opacity","aria-label":"Use transcription",children:r.jsx(Jt,{size:16})})]})]}):r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"flex items-center gap-1.5 min-w-0 shrink-0",children:[r.jsx(zx,{selectedModel:d,isStreaming:i,icon:r.jsx(Qt,{size:16})}),r.jsx(av,{disabled:i,onOpenConnections:()=>{se("connections_dialog_opened",{source:"tools_popover",mode:"add"}),T(!0)},virtualMcpId:u?.id??V}),F&&r.jsxs("button",{type:"button",onClick:()=>{w(),se("chat_mode_changed",{from_mode:"plan",to_mode:"default",source:"pill_dismiss"}),_("default")},className:"flex items-center gap-1.5 h-8 rounded-lg px-2.5 text-sm font-medium text-violet-600 dark:text-violet-400 hover:bg-violet-500/10 group whitespace-nowrap animate-in fade-in duration-200",children:[r.jsx(Xh,{size:14,className:"shrink-0"}),"Plan mode",r.jsx(fi,{size:14,className:"shrink-0 hidden group-hover:block"})]}),g==="gen-image"&&m&&r.jsxs("button",{type:"button",onClick:()=>{w(),se("chat_mode_changed",{from_mode:"gen-image",to_mode:"default",source:"pill_dismiss"}),_("default")},className:"flex items-center gap-1.5 h-8 rounded-lg px-2.5 text-sm font-medium text-pink-600 dark:text-pink-400 hover:bg-pink-500/10 group whitespace-nowrap animate-in fade-in duration-200",children:[r.jsx(la,{size:14,className:"shrink-0"}),r.jsx("span",{className:"max-w-[120px] truncate",children:v?"Create image":m.title.includes(": ")?m.title.split(": ").slice(1).join(": "):m.title}),r.jsx(fi,{size:14,className:"shrink-0 hidden group-hover:block"})]}),g==="web-search"&&p&&r.jsxs("button",{type:"button",onClick:()=>{w(),se("chat_mode_changed",{from_mode:"web-search",to_mode:"default",source:"pill_dismiss"}),_("default")},className:"flex items-center gap-1.5 h-8 rounded-lg px-2.5 text-sm font-medium text-blue-600 dark:text-blue-400 hover:bg-blue-500/10 group whitespace-nowrap animate-in fade-in duration-200",children:[r.jsx(Ti,{size:14,className:"shrink-0"}),r.jsx("span",{className:"max-w-[120px] truncate",children:v?"Web search":p.title.includes(": ")?p.title.split(": ").slice(1).join(": "):p.title}),r.jsx(fi,{size:14,className:"shrink-0 hidden group-hover:block"})]}),$&&H>0&&r.jsx(Op,{usage:G,totalTokens:H,contextWindow:$,onOpenContextPanel:t})]}),r.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[v?r.jsx(Av,{tier:x,onSelect:b}):r.jsx(iu,{placeholder:"Model",variant:"borderless",className:"h-8 text-sm py-2 min-w-0"}),I.isSupported&&!i&&!n&&r.jsx(ne,{type:"button",onClick:N,variant:"ghost",size:"icon",className:X("size-8 rounded-lg transition-colors",I.status==="permission-denied"?"text-destructive hover:text-destructive hover:bg-destructive/10":"text-muted-foreground hover:text-foreground"),title:I.status==="permission-denied"?"Microphone access denied — click to try again":"Voice input",children:r.jsx(mg,{size:18})}),r.jsx(ne,{type:U?"button":"submit",onClick:Y=>{U&&(Y.preventDefault(),Y.stopPropagation(),a())},variant:K||U?"default":"ghost",size:"icon",disabled:!K&&!U,className:X("size-8 rounded-lg transition-all",!K&&!U&&"bg-muted text-muted-foreground hover:bg-muted hover:text-muted-foreground cursor-not-allowed"),title:i?"Stop generating":n?"Cancel run":"Send message (Enter)",children:U?r.jsx(pg,{size:20}):r.jsx(Fh,{size:20})})]})]})})]})},l),e&&r.jsx(Sv,{onClick:()=>{se("connections_banner_clicked",{source:"home_chat_input"}),se("connections_dialog_opened",{source:"home_banner",mode:"add"}),T(!0)}})]})}),r.jsx(Pl,{mode:"browse",open:k,onOpenChange:T,defaultTab:"all"})]})}const Dv={usd:[{dollars:10,label:"Starter"},{dollars:20,label:"Popular"},{dollars:100,label:"Best value"}],brl:[{dollars:50,label:"Starter"},{dollars:100,label:"Popular"},{dollars:500,label:"Best value"}]};function Ku(t){return`deco-credits-empty-dismissed:${t}`}function Mv(t){try{return localStorage.getItem(Ku(t))==="1"}catch{return!1}}function Pv(){const t=B.c(49),{org:e}=be(),s=Ke(),{decoKeyId:i}=co();let n;t[0]!==e.id?(n={connectionId:Wt,orgId:e.id},t[0]=e.id,t[1]=n):n=t[1];const o=Me(n),[a,l]=S.useState(!0),[c,d]=S.useState(""),[u,h]=S.useState(!1),[f,m]=S.useState("usd"),p=f==="brl"?"R$":"$";let g;t[2]!==e.id?(g=()=>{se("credits_empty_state_dismissed",{organization_id:e.id}),l(!1);try{localStorage.setItem(Ku(e.id),"1")}catch{}},t[2]=e.id,t[3]=g):g=t[3];const _=g;let v,x;t[4]!==a||t[5]!==e.id?(v=()=>{a&&se("credits_empty_state_shown",{organization_id:e.id})},x=[a,e.id],t[4]=a,t[5]=e.id,t[6]=v,t[7]=x):(v=t[6],x=t[7]),S.useEffect(v,x);let b;t[8]!==o||t[9]!==f?(b=async $=>{const W=await o.callTool({name:"AI_PROVIDER_TOPUP_URL",arguments:{providerId:"deco",amountCents:$,currency:f}});if(W?.isError)throw new Error(W.content?.[0]?.text??"Failed to get top-up URL");return W.structuredContent?.url},t[8]=o,t[9]=f,t[10]=b):b=t[10];let y;t[11]!==_?(y=$=>{$&&window.open($,"_blank","noopener,noreferrer"),_()},t[11]=_,t[12]=y):y=t[12];let C;t[13]!==b||t[14]!==y?(C={mutationFn:b,onSuccess:y,onError:Bv},t[13]=b,t[14]=y,t[15]=C):C=t[15];const{mutate:j,isPending:V}=Br(C),w=parseFloat(c),k=!isNaN(w)&&w>=1;if(!a)return null;let T;t[16]!==_?(T=$=>!$&&_(),t[16]=_,t[17]=T):T=t[17];let I;t[18]===Symbol.for("react.memo_cache_sentinel")?(I=r.jsx("div",{className:"absolute inset-x-0 top-0 h-24 bg-gradient-to-b from-amber-500/8 to-transparent pointer-events-none rounded-t-lg"}),t[18]=I):I=t[18];let A;t[19]===Symbol.for("react.memo_cache_sentinel")?(A=r.jsx("div",{className:"flex items-center justify-center size-11 rounded-full bg-amber-100 dark:bg-amber-900/40 border border-amber-200/60 dark:border-amber-800/40 mx-auto",children:r.jsx(ml,{size:20,className:"text-amber-600 dark:text-amber-400"})}),t[19]=A):A=t[19];let N;t[20]===Symbol.for("react.memo_cache_sentinel")?(N=r.jsxs("div",{className:"relative px-6 pt-7 pb-5",children:[I,r.jsxs(Ds,{className:"relative gap-3",children:[A,r.jsxs("div",{className:"text-center",children:[r.jsx(Ts,{className:"text-lg font-semibold",children:"This workspace has no credits"}),r.jsx(dl,{className:"mt-2 text-[13px] leading-relaxed max-w-[320px] mx-auto",children:"Your free credits were used in another workspace. Add credits to use AI here."})]})]})]}),t[20]=N):N=t[20];let E;t[21]!==f||t[22]!==p||t[23]!==c||t[24]!==w||t[25]!==i||t[26]!==k||t[27]!==V||t[28]!==u||t[29]!==j?(E=i&&r.jsxs("div",{className:"px-6 pb-5",children:[r.jsx("div",{className:"mb-4",children:r.jsxs(eu,{type:"single",variant:"outline",size:"sm",value:f,onValueChange:$=>{$&&m($)},children:[r.jsx(Ln,{value:"usd",className:"h-8 px-3 text-xs",children:"USD"}),r.jsx(Ln,{value:"brl",className:"h-8 px-3 text-xs",children:"BRL"})]})}),r.jsx("div",{className:"grid grid-cols-3 gap-2.5",children:Dv[f].map($=>{const{dollars:W,label:F}=$;return r.jsxs("button",{type:"button",disabled:V,onClick:()=>{se("credits_topup_clicked",{amount_cents:W*100,currency:f,tier_label:F,source:"empty_state"}),j(W*100)},className:X("relative flex flex-col items-center gap-1 py-6 rounded-xl border transition-all duration-150 cursor-pointer","disabled:opacity-50 disabled:cursor-wait","border-border hover:border-foreground/20 hover:bg-muted/30"),children:[r.jsxs("span",{className:"text-2xl font-semibold tabular-nums text-foreground",children:[p,W]}),r.jsx("span",{className:"text-xs text-muted-foreground",children:F})]},W)})}),u?r.jsxs("div",{className:"flex gap-2 mt-3",children:[r.jsxs("div",{className:"relative flex-1",children:[r.jsx("span",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-sm text-muted-foreground select-none",children:p}),r.jsx(bt,{type:"number",min:"1",step:"1",placeholder:"50",value:c,onChange:$=>d($.target.value),className:"h-10 text-sm pl-7",autoFocus:!0})]}),r.jsx(ne,{className:"h-10",disabled:!k||V,onClick:()=>{se("credits_topup_clicked",{amount_cents:Math.round(w*100),currency:f,tier_label:"custom",source:"empty_state"}),j(Math.round(w*100))},children:V?"Opening...":"Add"})]}):r.jsx("button",{type:"button",className:"w-full mt-2.5 text-xs text-muted-foreground hover:text-foreground transition-colors py-1",onClick:()=>h(!0),children:"Enter custom amount"})]}),t[21]=f,t[22]=p,t[23]=c,t[24]=w,t[25]=i,t[26]=k,t[27]=V,t[28]=u,t[29]=j,t[30]=E):E=t[30];let R;t[31]!==_||t[32]!==s||t[33]!==e.slug?(R=()=>{s({to:"/$org/settings/ai-providers",params:{org:e.slug}}),_()},t[31]=_,t[32]=s,t[33]=e.slug,t[34]=R):R=t[34];let M;t[35]===Symbol.for("react.memo_cache_sentinel")?(M=r.jsx(ro,{size:12,className:"transition-transform duration-150 group-hover:translate-x-0.5"}),t[35]=M):M=t[35];let L;t[36]!==R?(L=r.jsxs("button",{type:"button",className:"group flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors",onClick:R,children:["Use your own provider",M]}),t[36]=R,t[37]=L):L=t[37];let D;t[38]!==_?(D=r.jsx(ne,{variant:"ghost",size:"sm",className:"text-xs text-muted-foreground",onClick:_,children:"Skip for now"}),t[38]=_,t[39]=D):D=t[39];let P;t[40]!==L||t[41]!==D?(P=r.jsxs("div",{className:"px-6 py-3.5 border-t border-border bg-muted/30 flex items-center justify-between",children:[L,D]}),t[40]=L,t[41]=D,t[42]=P):P=t[42];let O;t[43]!==E||t[44]!==P?(O=r.jsxs(ms,{className:"sm:max-w-[500px] gap-0 p-0 overflow-hidden",onOpenAutoFocus:Lv,children:[N,E,P]}),t[43]=E,t[44]=P,t[45]=O):O=t[45];let z;return t[46]!==O||t[47]!==T?(z=r.jsx(ps,{open:!0,onOpenChange:T,children:O}),t[46]=O,t[47]=T,t[48]=z):z=t[48],z}function Lv(t){return t.preventDefault()}function Bv(t){pe.error(`Top-up failed: ${t.message}`)}function Ov(t){const e=B.c(6),{balanceDollars:s}=t;let i;e[0]!==s?(i=s.toFixed(2),e[0]=s,e[1]=i):i=e[1];const n=i;let o,a;e[2]===Symbol.for("react.memo_cache_sentinel")?(o=X("inline-flex items-center gap-1.5 px-3 py-1 rounded-full","bg-emerald-50 dark:bg-emerald-950/30","border border-emerald-200/60 dark:border-emerald-800/40","animate-in fade-in-0 slide-in-from-bottom-2 duration-300"),a=r.jsx(ml,{size:13,className:"text-emerald-600 dark:text-emerald-400"}),e[2]=o,e[3]=a):(o=e[2],a=e[3]);let l;return e[4]!==n?(l=r.jsxs("div",{className:o,children:[a,r.jsxs("span",{className:"text-xs font-medium text-emerald-700 dark:text-emerald-300 tabular-nums",children:["$",n," in credits to get started"]})]}),e[4]=n,e[5]=l):l=e[5],l}function $v(){const t=B.c(8),{org:e}=be(),s=Ke();let i;t[0]!==s||t[1]!==e.slug?(i=()=>s({to:"/$org/settings/ai-providers",params:{org:e.slug}}),t[0]=s,t[1]=e.slug,t[2]=i):i=t[2];let n,o,a;t[3]===Symbol.for("react.memo_cache_sentinel")?(n=X("inline-flex items-center gap-1.5 px-3 py-1 rounded-full cursor-pointer","bg-amber-50 dark:bg-amber-950/30","border border-amber-200/60 dark:border-amber-800/40","hover:bg-amber-100/60 dark:hover:bg-amber-900/30","transition-colors duration-150","animate-in fade-in-0 slide-in-from-bottom-2 duration-300"),o=r.jsx(ri,{size:13,className:"text-amber-600 dark:text-amber-400"}),a=r.jsx("span",{className:"text-xs font-medium text-amber-700 dark:text-amber-300",children:"No credits remaining · Add more"}),t[3]=n,t[4]=o,t[5]=a):(n=t[3],o=t[4],a=t[5]);let l;return t[6]!==i?(l=r.jsxs("button",{type:"button",onClick:i,className:n,children:[o,a]}),t[6]=i,t[7]=l):l=t[7],l}function zv(t){const e=B.c(11),{className:s}=t;let i;e[0]!==s?(i=X("flex h-full w-full flex-col bg-background",s),e[0]=s,e[1]=i):i=e[1];let n;e[2]===Symbol.for("react.memo_cache_sentinel")?(n=r.jsx("div",{className:"size-6 rounded-lg bg-muted animate-pulse"}),e[2]=n):n=e[2];let o;e[3]===Symbol.for("react.memo_cache_sentinel")?(o=r.jsxs("div",{className:"flex items-center gap-3",children:[n,r.jsxs("div",{className:"flex flex-col gap-2",children:[r.jsx("div",{className:"h-3.5 w-28 rounded bg-muted animate-pulse"}),r.jsx("div",{className:"h-3 w-40 rounded bg-muted/60 animate-pulse"})]})]}),e[3]=o):o=e[3];let a;e[4]===Symbol.for("react.memo_cache_sentinel")?(a=r.jsx("div",{className:"flex items-center h-12 flex-none border-b border-border/80 px-4",children:r.jsxs("div",{className:"flex items-center justify-between gap-3 w-full",children:[o,r.jsxs("div",{className:"flex items-end gap-2",children:[r.jsx("div",{className:"h-6 w-6 rounded-full bg-muted animate-pulse"}),r.jsx("div",{className:"h-6 w-6 rounded-lg bg-muted animate-pulse"})]})]})}),e[4]=a):a=e[4];let l;e[5]===Symbol.for("react.memo_cache_sentinel")?(l=r.jsx("div",{className:"flex-1 overflow-hidden px-4 py-4",children:r.jsxs("div",{className:"mx-auto flex w-full max-w-2xl flex-col gap-4",children:[r.jsx(an,{align:"right",width:"w-3/4"}),r.jsx(an,{align:"left",width:"w-full",lines:3}),r.jsx(an,{align:"right",width:"w-2/3"}),r.jsx(an,{align:"left",width:"w-5/6",lines:2})]})}),e[5]=l):l=e[5];let c;e[6]===Symbol.for("react.memo_cache_sentinel")?(c=r.jsx("div",{className:"relative flex flex-1 flex-col gap-2 p-2.5",children:r.jsx("div",{className:"relative flex-1",children:r.jsxs("div",{className:"space-y-2 p-2",children:[r.jsx("div",{className:"h-3 w-full rounded bg-muted/40 animate-pulse"}),r.jsx("div",{className:"h-3 w-4/5 rounded bg-muted/40 animate-pulse"})]})})}),e[6]=c):c=e[6];let d;e[7]===Symbol.for("react.memo_cache_sentinel")?(d=r.jsx("div",{className:"flex items-center gap-1",children:r.jsx("div",{className:"size-8 rounded-full bg-muted/60 animate-pulse"})}),e[7]=d):d=e[7];let u;e[8]===Symbol.for("react.memo_cache_sentinel")?(u=r.jsx("div",{className:"px-4 py-4",children:r.jsx("div",{className:"mx-auto w-full max-w-2xl",children:r.jsxs("div",{className:"relative flex min-h-[130px] flex-col rounded-xl bg-background card-shadow",children:[c,r.jsxs("div",{className:"flex items-center justify-between px-2.5 pb-2.5",children:[d,r.jsxs("div",{className:"flex items-center gap-1",children:[r.jsx("div",{className:"h-8 w-32 rounded-lg bg-muted/60 animate-pulse"}),r.jsx("div",{className:"size-8 rounded-full bg-muted animate-pulse"})]})]})]})})}),e[8]=u):u=e[8];let h;return e[9]!==i?(h=r.jsxs("div",{className:i,children:[a,l,u]}),e[9]=i,e[10]=h):h=e[10],h}function an(t){const e=B.c(22),{align:s,width:i,lines:n}=t,o=i===void 0?"w-full":i,a=n===void 0?1:n,l=s==="right"?"flex-row-reverse":"flex-row";let c;e[0]!==l?(c=X("flex w-full gap-4 px-4 py-2",l),e[0]=l,e[1]=c):c=e[1];const d=s==="right"?"ml-auto max-w-3/4 items-end":"w-full items-start";let u;e[2]!==d?(u=X("flex min-w-0 flex-col gap-2",d),e[2]=d,e[3]=u):u=e[3];let h;e[4]===Symbol.for("react.memo_cache_sentinel")?(h=r.jsx("div",{className:"h-3 w-16 rounded bg-muted/40 animate-pulse"}),e[4]=h):h=e[4];const f=s==="right"?"bg-muted":"bg-transparent border border-border/40";let m;e[5]!==f||e[6]!==o?(m=X("min-w-0 rounded-2xl p-4",f,o),e[5]=f,e[6]=o,e[7]=m):m=e[7];let p;e[8]!==a?(p=Array.from({length:a}),e[8]=a,e[9]=p):p=e[9];let g;e[10]!==a||e[11]!==p?(g=r.jsx("div",{className:"space-y-2",children:p.map((b,y)=>r.jsx("div",{className:X("h-3 rounded bg-muted-foreground/20 animate-pulse",y===a-1?"w-3/4":"w-full"),style:{animationDelay:`${y*.1}s`}},y))}),e[10]=a,e[11]=p,e[12]=g):g=e[12];let _;e[13]!==g||e[14]!==m?(_=r.jsx("div",{className:m,children:g}),e[13]=g,e[14]=m,e[15]=_):_=e[15];let v;e[16]!==_||e[17]!==u?(v=r.jsxs("div",{className:u,children:[h,_]}),e[16]=_,e[17]=u,e[18]=v):v=e[18];let x;return e[19]!==v||e[20]!==c?(x=r.jsx("div",{className:c,children:v}),e[19]=v,e[20]=c,e[21]=x):x=e[21],x}function Fv(t){const e=B.c(5),{className:s,children:i}=t;let n;e[0]!==s?(n=X("flex flex-col h-full w-full bg-background transform-[translateZ(0)]",s),e[0]=s,e[1]=n):n=e[1];let o;return e[2]!==i||e[3]!==n?(o=r.jsx("div",{className:n,children:i}),e[2]=i,e[3]=n,e[4]=o):o=e[4],o}function Hv(t){const e=B.c(5),{children:s,className:i}=t;let n;e[0]!==i?(n=X("flex-1 min-h-0 overflow-y-auto isolate",i),e[0]=i,e[1]=n):n=e[1];let o;return e[2]!==s||e[3]!==n?(o=r.jsx("div",{className:n,children:s}),e[2]=s,e[3]=n,e[4]=o):o=e[4],o}function Wv(t){const e=B.c(2),{children:s}=t;let i;return e[0]!==s?(i=r.jsx("div",{className:"h-full w-full flex items-center justify-center max-w-2xl mx-auto",children:s}),e[0]=s,e[1]=i):i=e[1],i}function Uv(){const t=B.c(16),{messages:e,status:s}=Ui(),i=$p(e);let n;t[0]!==i?(n=i.at(-1),t[0]=i,t[1]=n):n=t[1];const o=n,a=s==="submitted"||s==="streaming";let l;if(t[2]!==a||t[3]!==o||t[4]!==i||t[5]!==e||t[6]!==s){const c=e.at(-1),d=!a&&c?.role==="assistant"&&c.parts.filter(Gv).some(qv),u=!a&&c?.role==="assistant"&&c.parts.some(Kv);let h;if(t[8]!==i||t[9]!==s){let m;t[11]!==i.length||t[12]!==s?(m=(p,g)=>r.jsx(dc,{pair:p,isLastPair:!1,status:g===i.length-1?s:void 0},`pair-${p.user.id}`),t[11]=i.length,t[12]=s,t[13]=m):m=t[13],h=i.slice(0,-1).map(m),t[8]=i,t[9]=s,t[10]=h}else h=t[10];let f;t[14]!==h?(f=r.jsx("div",{className:"flex flex-col min-w-0 max-w-2xl mx-auto w-full",children:h}),t[14]=h,t[15]=f):f=t[15],l=r.jsxs("div",{className:"w-full min-w-0 max-w-full overflow-y-auto h-full overflow-x-hidden",children:[f,o&&r.jsx("div",{className:X("min-h-full min-w-0 max-w-2xl mx-auto w-full",(d||u)&&"pb-60"),children:r.jsx(dc,{pair:o,isLastPair:!0,status:s},`pair-${o?.user.id}`)})]}),t[2]=a,t[3]=o,t[4]=i,t[5]=e,t[6]=s,t[7]=l}else l=t[7];return l}function Kv(t){return"state"in t&&t.state==="approval-requested"}function qv(t){return t.state==="input-available"}function Gv(t){return t.type==="tool-user_ask"}function Yv(t){const e=B.c(5),{children:s,className:i}=t;let n;e[0]!==i?(n=X("flex-none w-full mx-auto p-2 pt-0","max-w-2xl min-w-0",i),e[0]=i,e[1]=n):n=e[1];let o;return e[2]!==s||e[3]!==n?(o=r.jsx("div",{className:n,children:s}),e[2]=s,e[3]=n,e[4]=o):o=e[4],o}const De=Object.assign(Fv,{Main:Hv,Messages:Uv,EmptyState:Wv,Footer:Yv,Input:Tv,Provider:Ap,ActiveTaskProvider:Np,Skeleton:zv,IceBreakers:ix,NoAiProviderEmptyState:Hg,CreditsEmptyState:Pv,CreditsEyebrow:Ov,NoCreditsEyebrow:$v,CreditsExhaustedBanner:Au}),Xv=`You are an image generator agent. Every request of the user is somewhat related to creating, editing or varying an image. You have access to image generation tools
5
5
 
@@ -256,7 +256,7 @@ When given a research question or topic:
256
256
  - Identify sources, patterns, gaps, and contradictions
257
257
  - Deliver findings as clear, structured summaries with actionable insights
258
258
 
259
- Approach every request with rigor and intellectual honesty. Always surface what is uncertain or debated, not just what is known.`,tb=["Break any topic into key sub-questions and define scope","Synthesize information from multiple angles and sources","Distinguish facts, expert consensus, and contested claims","Identify gaps, contradictions, and emerging patterns","Deliver structured summaries with actionable insights"];function Wc(t){const e=B.c(7),{onRecruit:s,isRecruiting:i}=t;let n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=r.jsx("p",{className:"text-sm text-muted-foreground",children:"Add a Web Researcher agent that conducts thorough, rigorous research on any topic and delivers structured, actionable insights."}),e[0]=n):n=e[0];let o;e[1]===Symbol.for("react.memo_cache_sentinel")?(o=r.jsx("p",{className:"text-sm font-medium text-foreground",children:"Capabilities"}),e[1]=o):o=e[1];let a;e[2]===Symbol.for("react.memo_cache_sentinel")?(a=r.jsxs("div",{className:"space-y-2",children:[o,r.jsx("ul",{className:"space-y-1.5",children:tb.map(sb)})]}),e[2]=a):a=e[2];const l=i?"Setting up...":"Add Web Researcher";let c;return e[3]!==i||e[4]!==s||e[5]!==l?(c=r.jsxs("div",{className:"flex flex-col gap-6",children:[n,a,r.jsx(ne,{onClick:s,disabled:i,className:"w-full cursor-pointer",children:l})]}),e[3]=i,e[4]=s,e[5]=l,e[6]=c):c=e[6],c}function sb(t){return r.jsxs("li",{className:"text-sm text-muted-foreground flex items-start gap-2",children:[r.jsx("span",{className:"text-amber-500 mt-0.5 shrink-0",children:"+"}),t]},t)}function ib({open:t,onOpenChange:e,existingAgent:s}){const i=Rs(),n=lo(),o=yl(),[a,l]=S.useState(!1),c=Os.find(f=>f.id==="ai-research"),d=r.jsx(Ms,{icon:c.icon,name:c.title,size:"sm"}),u=async()=>{if(s){e(!1),n(s.id);return}l(!0);try{const f=await o.create.mutateAsync({title:c.title,description:"Systematic research and information synthesis assistant",icon:c.icon,status:"active",connections:[],metadata:{type:"ai-research",instructions:eb}});se("agent_recruit_confirmed",{template_id:"ai-research",agent_id:f.id}),e(!1),n(f.id)}catch(f){se("agent_recruit_failed",{template_id:"ai-research",error:f instanceof Error?f.message:String(f)}),console.error("Failed to create Researcher agent:",f)}finally{l(!1)}},h=`Add ${c.title}`;return i?r.jsx(Si,{open:t,onOpenChange:e,children:r.jsxs(yi,{className:"h-[70dvh]",children:[r.jsx(so,{className:"px-4 pt-4 pb-4 shrink-0",children:r.jsxs("div",{className:"flex items-center gap-3",children:[d,r.jsx(bi,{className:"text-xl font-semibold",children:h})]})}),r.jsx("div",{className:"flex flex-col flex-1 min-h-0 px-4 pb-8",children:r.jsx(Wc,{onRecruit:u,isRecruiting:a})})]})}):r.jsx(ps,{open:t,onOpenChange:e,children:r.jsxs(ms,{className:"sm:max-w-[500px] p-8",children:[r.jsx(Ds,{className:"mb-4",children:r.jsxs("div",{className:"flex items-center gap-3",children:[d,r.jsx(Ts,{className:"text-xl font-semibold",children:h})]})}),r.jsx(Wc,{onRecruit:u,isRecruiting:a})]})})}function rb(t){try{const e=localStorage.getItem(`mesh:chat:recent-agents:${t}`);return e?JSON.parse(e):[]}catch{return[]}}function tr(t){const e=B.c(21),{agent:s,onSpecialClick:i,tracking:n}=t,{org:o}=be(),a=Ke();let l;e[0]!==s.id||e[1]!==s.title||e[2]!==a||e[3]!==i||e[4]!==o||e[5]!==n.action||e[6]!==n.template_id||e[7]!==n.tile_kind?(l=()=>{if(se("home_agent_tile_clicked",{template_id:n.template_id,agent_id:s.id,agent_title:s.title,tile_kind:n.tile_kind,action:n.action}),i)i();else{const g=crypto.randomUUID();a({to:"/$org/$taskId",params:{org:o.slug,taskId:g},search:{virtualmcpid:s.id}})}},e[0]=s.id,e[1]=s.title,e[2]=a,e[3]=i,e[4]=o,e[5]=n.action,e[6]=n.template_id,e[7]=n.tile_kind,e[8]=l):l=e[8];const c=l;let d;e[9]===Symbol.for("react.memo_cache_sentinel")?(d=X("flex flex-col items-center gap-3 p-2 rounded-lg","transition-colors","cursor-pointer","w-[100px] shrink-0","group"),e[9]=d):d=e[9];const u=`Select agent ${s.title}`;let h;e[10]===Symbol.for("react.memo_cache_sentinel")?(h=r.jsx(ao,{size:24}),e[10]=h):h=e[10];let f;e[11]!==s.icon||e[12]!==s.title?(f=r.jsx(Ms,{icon:s.icon,name:s.title,size:"md",fallbackIcon:h,className:"transition-transform group-hover:scale-110"}),e[11]=s.icon,e[12]=s.title,e[13]=f):f=e[13];let m;e[14]!==s.title?(m=r.jsx("p",{className:"text-xs sm:text-sm text-foreground text-center leading-tight line-clamp-2 break-words w-full",children:s.title}),e[14]=s.title,e[15]=m):m=e[15];let p;return e[16]!==c||e[17]!==u||e[18]!==f||e[19]!==m?(p=r.jsxs("button",{type:"button",onClick:c,className:d,"aria-label":u,children:[f,m]}),e[16]=c,e[17]=u,e[18]=f,e[19]=m,e[20]=p):p=e[20],p}function nb(){const t=B.c(8),e=Ke(),{org:s}=be();let i;t[0]===Symbol.for("react.memo_cache_sentinel")?(i=X("flex flex-col items-center gap-3 p-2 rounded-lg","transition-colors","cursor-pointer","w-[100px] shrink-0","group"),t[0]=i):i=t[0];let n;t[1]!==e||t[2]!==s.slug?(n=()=>{se("home_see_all_agents_clicked"),e({to:"/$org/settings/agents",params:{org:s.slug}})},t[1]=e,t[2]=s.slug,t[3]=n):n=t[3];let o,a;t[4]===Symbol.for("react.memo_cache_sentinel")?(o=r.jsx("div",{className:"size-12 rounded-xl bg-accent flex items-center justify-center shrink-0 transition-transform group-hover:scale-110",children:r.jsx(Vl,{size:20,className:"text-foreground"})}),a=r.jsx("p",{className:"text-xs sm:text-sm text-foreground text-center leading-tight",children:"See all"}),t[4]=o,t[5]=a):(o=t[4],a=t[5]);let l;return t[6]!==n?(l=r.jsxs("button",{type:"button",className:i,"aria-label":"See all agents",onClick:n,children:[o,a]}),t[6]=n,t[7]=l):l=t[7],l}function ob(){const t=B.c(9);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e={navigateOnCreate:!0},t[0]=e):e=t[0];const{createVirtualMCP:s,isCreating:i}=pu(e);let n;t[1]!==s?(n=()=>{se("home_create_agent_clicked"),s()},t[1]=s,t[2]=n):n=t[2];let o;t[3]===Symbol.for("react.memo_cache_sentinel")?(o=X("flex flex-col items-center gap-3 p-2 rounded-lg","transition-colors","cursor-pointer","w-[100px] shrink-0","group","disabled:opacity-50 disabled:cursor-not-allowed"),t[3]=o):o=t[3];let a,l;t[4]===Symbol.for("react.memo_cache_sentinel")?(a=r.jsx("div",{className:"size-12 rounded-xl bg-background border-2 border-dashed border-border flex items-center justify-center shrink-0 transition-transform group-hover:scale-110",children:r.jsx(Qt,{size:20,className:"text-muted-foreground"})}),l=r.jsx("p",{className:"text-xs sm:text-sm text-foreground text-center leading-tight",children:"Create agent"}),t[4]=a,t[5]=l):(a=t[4],l=t[5]);let c;return t[6]!==i||t[7]!==n?(c=r.jsxs("button",{type:"button",onClick:n,disabled:i,className:o,"aria-label":"Create agent",children:[a,l]}),t[6]=i,t[7]=n,t[8]=c):c=t[8],c}function ab(){const t=B.c(95),e=oo(),{locator:s}=be(),[i,n]=S.useState(!1),[o,a]=S.useState(!1),[l,c]=S.useState(!1),[d,u]=S.useState(!1),h=lo();let f;t[0]===Symbol.for("react.memo_cache_sentinel")?(f=Os.find(ub),t[0]=f):f=t[0];const m=f;let p;t[1]===Symbol.for("react.memo_cache_sentinel")?(p=Os.find(hb),t[1]=p):p=t[1];const g=p;let _;t[2]===Symbol.for("react.memo_cache_sentinel")?(_=Os.find(db),t[2]=_):_=t[2];const v=_;let x;t[3]===Symbol.for("react.memo_cache_sentinel")?(x=Os.find(cb),t[3]=x):x=t[3];const b=x;let y,C,j,V,w,k,T,I,A,N,E;if(t[4]!==s||t[5]!==h||t[6]!==e){const F=rb(s),G=e.filter(lb).sort((Q,ae)=>{const Se=F.indexOf(Q.id),Ne=F.indexOf(ae.id);return Se!==-1&&Ne!==-1?Se-Ne:Se!==-1?-1:Ne!==-1?1:new Date(ae.updated_at).getTime()-new Date(Q.updated_at).getTime()}).slice(0,4);let q;if(t[18]!==e){let Q;t[20]===Symbol.for("react.memo_cache_sentinel")?(Q=ae=>ae.id!==null&&(ae.metadata?.type===g.id||ae.title===g.title),t[20]=Q):Q=t[20],q=e.find(Q),t[18]=e,t[19]=q}else q=t[19];j=q;let H;if(t[21]!==e){let Q;t[23]===Symbol.for("react.memo_cache_sentinel")?(Q=ae=>ae.id!==null&&(ae.metadata?.type===v.id||ae.title===v.title),t[23]=Q):Q=t[23],H=e.find(Q),t[21]=e,t[22]=H}else H=t[22];y=H;let ee;if(t[24]!==e){let Q;t[26]===Symbol.for("react.memo_cache_sentinel")?(Q=ae=>ae.id!==null&&(ae.metadata?.type===b.id||ae.title===b.title),t[26]=Q):Q=t[26],ee=e.find(Q),t[24]=e,t[25]=ee}else ee=t[25];C=ee,V=G.length>0,w="w-full max-md:overflow-x-auto max-md:[scrollbar-width:none] max-md:[&::-webkit-scrollbar]:hidden",k="flex flex-wrap justify-center gap-1.5 max-md:flex-nowrap max-md:justify-start md:max-h-52 md:overflow-hidden",t[27]===Symbol.for("react.memo_cache_sentinel")?(T=r.jsx(tr,{agent:m,onSpecialClick:()=>n(!0),tracking:{template_id:m.id,tile_kind:"template",action:"open_modal"}},m.id),t[27]=T):T=t[27];const K=j??g;let U;t[28]!==j||t[29]!==h?(U=j?()=>h(j.id):()=>a(!0),t[28]=j,t[29]=h,t[30]=U):U=t[30];const te=j?"existing":"template",Y=j?"navigate":"open_modal";let J;t[31]!==te||t[32]!==Y?(J={template_id:g.id,tile_kind:te,action:Y},t[31]=te,t[32]=Y,t[33]=J):J=t[33],t[34]!==K||t[35]!==U||t[36]!==J?(I=r.jsx(tr,{agent:K,onSpecialClick:U,tracking:J},g.id),t[34]=K,t[35]=U,t[36]=J,t[37]=I):I=t[37];const ie=y??v;let ue;t[38]!==y||t[39]!==h?(ue=y?()=>h(y.id):()=>c(!0),t[38]=y,t[39]=h,t[40]=ue):ue=t[40];const de=y?"existing":"template",xe=y?"navigate":"open_modal";let oe;t[41]!==de||t[42]!==xe?(oe={template_id:v.id,tile_kind:de,action:xe},t[41]=de,t[42]=xe,t[43]=oe):oe=t[43],t[44]!==ie||t[45]!==ue||t[46]!==oe?(A=r.jsx(tr,{agent:ie,onSpecialClick:ue,tracking:oe},v.id),t[44]=ie,t[45]=ue,t[46]=oe,t[47]=A):A=t[47];const he=C??b;let me;t[48]!==C||t[49]!==h?(me=C?()=>h(C.id):()=>u(!0),t[48]=C,t[49]=h,t[50]=me):me=t[50];const fe=C?"existing":"template",le=C?"navigate":"open_modal";let ve;t[51]!==fe||t[52]!==le?(ve={template_id:b.id,tile_kind:fe,action:le},t[51]=fe,t[52]=le,t[53]=ve):ve=t[53],t[54]!==he||t[55]!==me||t[56]!==ve?(N=r.jsx(tr,{agent:he,onSpecialClick:me,tracking:ve},b.id),t[54]=he,t[55]=me,t[56]=ve,t[57]=N):N=t[57];let Ce;t[58]!==y?.id||t[59]!==C?.id||t[60]!==j?.id?(Ce=Q=>Q.id!==j?.id&&Q.id!==y?.id&&Q.id!==C?.id,t[58]=y?.id,t[59]=C?.id,t[60]=j?.id,t[61]=Ce):Ce=t[61];let Te;t[62]!==h?(Te=Q=>r.jsx(tr,{agent:Q,onSpecialClick:()=>h(Q.id),tracking:{template_id:null,tile_kind:"recent",action:"navigate"}},Q.id??"default"),t[62]=h,t[63]=Te):Te=t[63],E=G.filter(Ce).map(Te),t[4]=s,t[5]=h,t[6]=e,t[7]=y,t[8]=C,t[9]=j,t[10]=V,t[11]=w,t[12]=k,t[13]=T,t[14]=I,t[15]=A,t[16]=N,t[17]=E}else y=t[7],C=t[8],j=t[9],V=t[10],w=t[11],k=t[12],T=t[13],I=t[14],A=t[15],N=t[16],E=t[17];let R;t[64]===Symbol.for("react.memo_cache_sentinel")?(R=r.jsx(ob,{}),t[64]=R):R=t[64];let M;t[65]!==V?(M=V&&r.jsx(nb,{}),t[65]=V,t[66]=M):M=t[66];let L;t[67]!==M||t[68]!==k||t[69]!==T||t[70]!==I||t[71]!==A||t[72]!==N||t[73]!==E?(L=r.jsxs("div",{className:k,children:[T,I,A,N,E,R,M]}),t[67]=M,t[68]=k,t[69]=T,t[70]=I,t[71]=A,t[72]=N,t[73]=E,t[74]=L):L=t[74];let D;t[75]!==w||t[76]!==L?(D=r.jsx("div",{className:w,children:L}),t[75]=w,t[76]=L,t[77]=D):D=t[77];let P;t[78]!==i?(P=r.jsx(Bn,{open:i,onOpenChange:n}),t[78]=i,t[79]=P):P=t[79];let O;t[80]!==o||t[81]!==j?(O=r.jsx(uu,{open:o,onOpenChange:a,existingAgent:j}),t[80]=o,t[81]=j,t[82]=O):O=t[82];let z;t[83]!==l||t[84]!==y?(z=r.jsx(Zv,{open:l,onOpenChange:c,existingAgent:y}),t[83]=l,t[84]=y,t[85]=z):z=t[85];let $;t[86]!==d||t[87]!==C?($=r.jsx(ib,{open:d,onOpenChange:u,existingAgent:C}),t[86]=d,t[87]=C,t[88]=$):$=t[88];let W;return t[89]!==D||t[90]!==P||t[91]!==O||t[92]!==z||t[93]!==$?(W=r.jsxs(r.Fragment,{children:[D,P,O,z,$]}),t[89]=D,t[90]=P,t[91]=O,t[92]=z,t[93]=$,t[94]=W):W=t[94],W}function lb(t){return t.id!==null&&!Mn(t.id)}function cb(t){return t.id==="ai-research"}function db(t){return t.id==="ai-image"}function hb(t){return t.id==="site-diagnostics"}function ub(t){return t.id==="site-editor"}function fb(){const t=B.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=r.jsx("div",{className:"w-full max-md:overflow-x-auto max-md:[scrollbar-width:none] max-md:[&::-webkit-scrollbar]:hidden",children:r.jsx("div",{className:"flex flex-wrap justify-center gap-1.5 max-md:flex-nowrap max-md:justify-start md:max-h-52 md:overflow-hidden",children:Array.from({length:7}).map(mb)})}),t[0]=e):e=t[0],e}function mb(t,e){return r.jsxs("div",{className:"flex flex-col items-center gap-3 p-2 w-[100px] shrink-0",children:[r.jsx(Bi,{className:"size-12 rounded-xl shrink-0"}),r.jsx(Bi,{className:"h-3 sm:h-4 w-full"})]},e)}function Uc(){const t=B.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=r.jsx(S.Suspense,{fallback:r.jsx(fb,{}),children:r.jsx(ab,{})}),t[0]=e):e=t[0],e}function sr(t){return t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}k`:String(t)}function Kc(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 pb(t){return t?t.replace(/-\d{8}(?:-[a-z0-9]+)*$/i,"").replace(/-/g," "):"—"}function gb(t){const e=B.c(4),{items:s}=t;let i;e[0]!==s?(i=s.map(_b),e[0]=s,e[1]=i):i=e[1];let n;return e[2]!==i?(n=r.jsx("div",{className:"grid grid-cols-2 gap-x-8 gap-y-6",children:i}),e[2]=i,e[3]=n):n=e[3],n}function _b(t){return r.jsxs("div",{className:"flex flex-col gap-1 min-w-0",children:[r.jsx("span",{className:"text-xs text-muted-foreground truncate",children:t.label}),r.jsx("span",{className:"text-sm text-foreground tabular-nums truncate",children:t.value})]},t.label)}function xb(t){const e=B.c(30),{userTokens:s,assistantTokens:i,otherTokens:n}=t,o=s+i+n,a=o>0?s/o*100:0,l=o>0?i/o*100:0,c=o>0?n/o*100:0;let d;e[0]!==a?(d=a>0&&r.jsx("div",{className:"h-full bg-chart-1",style:{width:`${a}%`}}),e[0]=a,e[1]=d):d=e[1];let u;e[2]!==l?(u=l>0&&r.jsx("div",{className:"h-full bg-chart-2",style:{width:`${l}%`}}),e[2]=l,e[3]=u):u=e[3];let h;e[4]!==c?(h=c>0&&r.jsx("div",{className:"h-full bg-muted-foreground/30",style:{width:`${c}%`}}),e[4]=c,e[5]=h):h=e[5];let f;e[6]!==d||e[7]!==u||e[8]!==h?(f=r.jsxs("div",{className:"flex h-2 w-full overflow-hidden rounded-full bg-muted",children:[d,u,h]}),e[6]=d,e[7]=u,e[8]=h,e[9]=f):f=e[9];let m;e[10]===Symbol.for("react.memo_cache_sentinel")?(m=r.jsx("span",{className:"inline-block h-2 w-2 rounded-sm bg-chart-1 shrink-0"}),e[10]=m):m=e[10];let p;e[11]!==a?(p=a.toFixed(1),e[11]=a,e[12]=p):p=e[12];let g;e[13]!==p?(g=r.jsxs("div",{className:"flex items-center gap-1.5",children:[m,r.jsxs("span",{className:"text-xs text-muted-foreground",children:["User ",p,"%"]})]}),e[13]=p,e[14]=g):g=e[14];let _;e[15]===Symbol.for("react.memo_cache_sentinel")?(_=r.jsx("span",{className:"inline-block h-2 w-2 rounded-sm bg-chart-2 shrink-0"}),e[15]=_):_=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=r.jsxs("div",{className:"flex items-center gap-1.5",children:[_,r.jsxs("span",{className:"text-xs text-muted-foreground",children:["Assistant ",v,"%"]})]}),e[18]=v,e[19]=x):x=e[19];let b;e[20]!==c||e[21]!==n?(b=n>0&&r.jsxs("div",{className:"flex items-center gap-1.5",children:[r.jsx("span",{className:"inline-block h-2 w-2 rounded-sm bg-muted-foreground/30 shrink-0"}),r.jsxs("span",{className:"text-xs text-muted-foreground",children:["Other ",c.toFixed(1),"%"]})]}),e[20]=c,e[21]=n,e[22]=b):b=e[22];let y;e[23]!==x||e[24]!==b||e[25]!==g?(y=r.jsxs("div",{className:"flex flex-wrap gap-x-3 gap-y-1",children:[g,x,b]}),e[23]=x,e[24]=b,e[25]=g,e[26]=y):y=e[26];let C;return e[27]!==y||e[28]!==f?(C=r.jsxs("div",{className:"flex flex-col gap-2",children:[f,y]}),e[27]=y,e[28]=f,e[29]=C):C=e[29],C}function vb(t){const e=B.c(19),{part:s}=t,i=s.input?.agent_id,n=ts(i),o=n?.title??"Subtask",a=n?.icon??null,l=s.state==="input-streaming"||s.state==="input-available"||s.state==="output-available"&&s.preliminary===!0,c=s.state==="output-error",d=s.state==="approval-requested";let u;e[0]!==a||e[1]!==o?(u=r.jsx(Ms,{icon:a,name:o,size:"xs",className:"size-6 rounded-md shrink-0"}),e[0]=a,e[1]=o,e[2]=u):u=e[2];const h=c?"text-destructive":"text-foreground";let f;e[3]!==h?(f=X("shrink-0 font-medium",h),e[3]=h,e[4]=f):f=e[4];let m;e[5]!==o||e[6]!==f?(m=r.jsx("span",{className:f,children:o}),e[5]=o,e[6]=f,e[7]=m):m=e[7];let p;e[8]!==s.input?(p=s.input?.prompt&&r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"text-muted-foreground/50",children:"·"}),r.jsx("span",{className:"truncate text-muted-foreground",children:s.input.prompt})]}),e[8]=s.input,e[9]=p):p=e[9];let g;e[10]!==d||e[11]!==c||e[12]!==l?(g=r.jsx("span",{className:"ml-auto shrink-0",children:l?r.jsx(Ee,{size:12,className:"animate-spin text-muted-foreground"}):c?r.jsx(Og,{size:12,className:"text-destructive"}):d?r.jsx(ri,{size:12,className:"text-warning"}):r.jsx(x_,{size:12,className:"text-emerald-500"})}),e[10]=d,e[11]=c,e[12]=l,e[13]=g):g=e[13];let _;return e[14]!==u||e[15]!==m||e[16]!==p||e[17]!==g?(_=r.jsxs("div",{className:"flex items-center gap-2 text-xs min-w-0",children:[u,m,p,g]}),e[14]=u,e[15]=m,e[16]=p,e[17]=g,e[18]=_):_=e[18],_}function bb(t){const e=B.c(58),{onClose:s,back:i,className:n}=t,[o,a]=S.useState(null),{messages:l}=Ui(),{tasks:c,taskId:d}=es(),{selectedModel:u,selectedVirtualMcp:h}=ni();let f,m,p,g,_,v,x,b;if(e[0]!==i||e[1]!==n||e[2]!==l||e[3]!==s||e[4]!==o?.id||e[5]!==u||e[6]!==h?.title||e[7]!==d||e[8]!==c){b=Symbol.for("react.early_return_sentinel");e:{let j;e[17]!==d?(j=J=>J.id===d,e[17]=d,e[18]=j):j=e[18];const V=c.find(j),w=Eh(l),k=[...l].reverse().find(Ab),T=k?.metadata?.usage,I=k?.metadata?.modelLimits?.contextWindow??u?.limits?.contextWindow??null,A=T?.contextTokens??T?.totalTokens??0,N=I&&I>0?(A/I*100).toFixed(1):null,E=l;let R;e[19]!==E?(R=E.filter(Nb).reduce(kb,0),e[19]=E,e[20]=R):R=e[20];const M=R,L=l;let D;e[21]!==L?(D=L.filter(jb).reduce(Cb,0),e[21]=L,e[22]=D):D=e[22];const P=D,O=Math.max(0,w.totalTokens-M-P),z=l[0],$=l.at(-1),W=z?.metadata?.created_at??V?.created_at,F=$?.metadata?.created_at??V?.updated_at,G=l.filter(Vb),q=l.flatMap(Sb),H=u?.modelId?pb(u.modelId):"—",ee=h?.title??"Decopilot",K=[{label:"Session",value:V?.title??"New chat"},{label:"Messages",value:G.length},{label:"Agent",value:ee},{label:"Model",value:H},{label:"Context Limit",value:I?sr(I):"—"},{label:"Session Tokens (billed)",value:w.totalTokens>0?sr(w.totalTokens):"0"},{label:"Usage",value:N!==null?`${N}%`:"—"},{label:"Input Tokens",value:w.inputTokens>0?sr(w.inputTokens):"0"},{label:"Output Tokens",value:w.outputTokens>0?sr(w.outputTokens):"0"},{label:"Reasoning Tokens",value:w.reasoningTokens>0?sr(w.reasoningTokens):"0"},{label:"Cost",value:w.cost>0?`$${w.cost<.001?w.cost.toFixed(6):w.cost.toFixed(4)}`:"$0.00"},{label:"Session Created",value:Kc(W)},{label:"Last Activity",value:Kc(F)}];if(!V&&G.length===0){let J;e[23]!==n?(J=X("flex flex-col h-full w-full border-l border-border bg-background",n),e[23]=n,e[24]=J):J=e[24];let ie;e[25]===Symbol.for("react.memo_cache_sentinel")?(ie=r.jsx("span",{className:"text-sm font-medium text-foreground",children:"Context"}),e[25]=ie):ie=e[25];let ue;e[26]!==i?(ue=i?r.jsx(aa,{size:14,className:"text-muted-foreground"}):r.jsx(ii,{size:14,className:"text-muted-foreground"}),e[26]=i,e[27]=ue):ue=e[27];let de;e[28]!==s||e[29]!==ue?(de=r.jsxs("div",{className:"h-11 px-4 flex items-center justify-between shrink-0 border-b border-border/50",children:[ie,r.jsx("button",{type:"button",onClick:s,className:"flex size-6 items-center justify-center rounded hover:bg-accent transition-colors",children:ue})]}),e[28]=s,e[29]=ue,e[30]=de):de=e[30];let xe;e[31]===Symbol.for("react.memo_cache_sentinel")?(xe=r.jsx("div",{className:"flex-1 flex items-center justify-center px-4 text-center",children:r.jsx("p",{className:"text-xs text-muted-foreground",children:"Start a conversation to see context"})}),e[31]=xe):xe=e[31];let oe;e[32]!==J||e[33]!==de?(oe=r.jsxs("div",{className:J,children:[de,xe]}),e[32]=J,e[33]=de,e[34]=oe):oe=e[34],b=oe;break e}e[35]!==n?(v=X("flex flex-col h-full w-full border-l border-border bg-background overflow-y-auto",n),e[35]=n,e[36]=v):v=e[36];let U;e[37]===Symbol.for("react.memo_cache_sentinel")?(U=r.jsx("span",{className:"text-sm font-medium text-foreground",children:"Context"}),e[37]=U):U=e[37];let te;e[38]!==i?(te=i?r.jsx(aa,{size:14}):r.jsx(ii,{size:14}),e[38]=i,e[39]=te):te=e[39],e[40]!==s||e[41]!==te?(x=r.jsxs("div",{className:"flex h-11 shrink-0 items-center justify-between border-b border-border/50 px-4",children:[U,r.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:te})]}),e[40]=s,e[41]=te,e[42]=x):x=e[42],f="flex flex-col gap-8 p-6",m=q.length>0&&r.jsxs("div",{className:"flex flex-col gap-3",children:[r.jsx("span",{className:"text-xs text-muted-foreground",children:"Subtasks"}),r.jsx("div",{className:"flex flex-col gap-1",children:q.map(yb)})]}),p=r.jsx(gb,{items:K});let Y;e[43]===Symbol.for("react.memo_cache_sentinel")?(Y=r.jsx("span",{className:"text-xs text-muted-foreground",children:"Context Breakdown"}),e[43]=Y):Y=e[43],e[44]!==P||e[45]!==O||e[46]!==M?(g=r.jsxs("div",{className:"flex flex-col gap-3",children:[Y,r.jsx(xb,{userTokens:M,assistantTokens:P,otherTokens:O})]}),e[44]=P,e[45]=O,e[46]=M,e[47]=g):g=e[47],_=G.length>0&&r.jsxs("div",{className:"flex flex-col gap-3",children:[r.jsx("span",{className:"text-xs text-muted-foreground",children:"Raw messages"}),r.jsx("div",{className:"flex flex-col gap-1",children:G.map(J=>{const ie=J.metadata?.created_at,ue=o?.id===J.id;return r.jsxs("div",{className:"rounded-md border border-border/50 overflow-hidden",children:[r.jsxs("button",{type:"button",onClick:()=>a(ue?null:J),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:[r.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[r.jsx("span",{className:X("shrink-0 font-medium",J.role==="user"?"text-chart-1":"text-chart-2"),children:J.role}),r.jsx("span",{className:"text-muted-foreground",children:"•"}),r.jsx("span",{className:"truncate text-muted-foreground font-mono",children:J.id})]}),ie&&r.jsx("span",{className:"shrink-0 text-muted-foreground tabular-nums",children:new Date(ie).toLocaleString("en-US",{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit"})})]}),ue&&r.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(J,null,2)})]},J.id)})})]})}e[0]=i,e[1]=n,e[2]=l,e[3]=s,e[4]=o?.id,e[5]=u,e[6]=h?.title,e[7]=d,e[8]=c,e[9]=f,e[10]=m,e[11]=p,e[12]=g,e[13]=_,e[14]=v,e[15]=x,e[16]=b}else f=e[9],m=e[10],p=e[11],g=e[12],_=e[13],v=e[14],x=e[15],b=e[16];if(b!==Symbol.for("react.early_return_sentinel"))return b;let y;e[48]!==f||e[49]!==m||e[50]!==p||e[51]!==g||e[52]!==_?(y=r.jsxs("div",{className:f,children:[m,p,g,_]}),e[48]=f,e[49]=m,e[50]=p,e[51]=g,e[52]=_,e[53]=y):y=e[53];let C;return e[54]!==v||e[55]!==x||e[56]!==y?(C=r.jsxs("div",{className:v,children:[x,y]}),e[54]=v,e[55]=x,e[56]=y,e[57]=C):C=e[57],C}function yb(t,e){return r.jsx(vb,{part:t},e)}function Sb(t){return(t.parts??[]).filter(wb)}function wb(t){return t.type==="tool-subtask"}function Vb(t){return t.role!=="system"}function Cb(t,e){const s=e.metadata?.usage;return t+(s?.outputTokens??0)}function jb(t){return t.role==="assistant"}function kb(t,e){const s=e.metadata?.usage;return t+(s?.inputTokens??0)}function Nb(t){return t.role==="user"}function Ab(t){return t.role==="assistant"&&t.metadata?.usage}function Eb(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 Ib(t){const e=B.c(25),{orgId:s,userId:i,connectionId:n,vmMap:o,owner:a,repo:l,enabled:c}=t,d=c===void 0?!0:c,u=n??null;let h;e[0]!==s||e[1]!==u?(h={connectionId:u,orgId:s},e[0]=s,e[1]=u,e[2]=h):h=e[2];const f=Me(h);let m;e[3]!==a||e[4]!==l?(m={owner:a,repo:l},e[3]=a,e[4]=l,e[5]=m):m=e[5];const p=d&&!!n&&!!a&&!!l;let g;e[6]!==f||e[7]!==m||e[8]!==p?(g={client:f,toolName:"list_branches",toolArguments:m,enabled:p,staleTime:3e4,select:Mb},e[6]=f,e[7]=m,e[8]=p,e[9]=g):g=e[9];const{data:_,isLoading:v,isError:x}=wi(g);let b,y;e[10]!==i||e[11]!==o?(y=new Set(Object.keys(o?.[i]??{})),b=[...y].sort().map(Db),e[10]=i,e[11]=o,e[12]=b,e[13]=y):(b=e[12],y=e[13]);const C=b;let j;if(e[14]!==_||e[15]!==y){const T=Array.isArray(_)?_:_?.branches??[];let I;e[17]!==y?(I=A=>!y.has(A.name),e[17]=y,e[18]=I):I=e[18],j=T.filter(Tb).filter(I).map(Rb),e[14]=_,e[15]=y,e[16]=j}else j=e[16];const V=j,w=Array.isArray(_)?null:_?.default_branch??null;let k;return e[19]!==w||e[20]!==x||e[21]!==v||e[22]!==V||e[23]!==C?(k={yours:C,others:V,defaultBase:w,isLoading:v,isError:x},e[19]=w,e[20]=x,e[21]=v,e[22]=V,e[23]=C,e[24]=k):k=e[24],k}function Rb(t){return{name:t.name,source:"other",author:typeof t.commit?.author=="string"?t.commit.author:t.commit?.author?.login??null}}function Tb(t){return typeof t.name=="string"}function Db(t){return{name:t,source:"yours"}}function Mb(t){return Eb(t)}function Pb(t){const e=B.c(36),{orgId:s,userId:i,connectionId:n,owner:o,repo:a,vmMap:l,value:c,onChange:d}=t,[u,h]=S.useState(!1);let f;e[0]!==n||e[1]!==u||e[2]!==s||e[3]!==o||e[4]!==a||e[5]!==i||e[6]!==l?(f={orgId:s,userId:i,connectionId:n,vmMap:l,owner:o,repo:a,enabled:u},e[0]=n,e[1]=u,e[2]=s,e[3]=o,e[4]=a,e[5]=i,e[6]=l,e[7]=f):f=e[7];const{yours:m,others:p,isLoading:g,isError:_}=Ib(f);let v;e[8]!==d?(v=N=>{d(N),h(!1)},e[8]=d,e[9]=v):v=e[9];const x=v,b=c??"Select branch…";let y;e[10]===Symbol.for("react.memo_cache_sentinel")?(y=r.jsx(gr,{className:"h-3.5 w-3.5"}),e[10]=y):y=e[10];let C;e[11]!==b?(C=r.jsx(oi,{asChild:!0,children:r.jsxs(ne,{variant:"outline",size:"sm",className:"h-7 gap-1.5 px-2 font-mono text-xs",children:[y,r.jsx("span",{className:"max-w-[200px] truncate",children:b})]})}),e[11]=b,e[12]=C):C=e[12];let j;e[13]===Symbol.for("react.memo_cache_sentinel")?(j=r.jsx(c_,{placeholder:"Search branches…"}),e[13]=j):j=e[13];let V;e[14]!==_?(V=_&&r.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[14]=_,e[15]=V):V=e[15];let w;e[16]!==_||e[17]!==g||e[18]!==p.length||e[19]!==m.length?(w=!_&&!g&&m.length===0&&p.length===0&&r.jsx(a_,{children:"No branches found."}),e[16]=_,e[17]=g,e[18]=p.length,e[19]=m.length,e[20]=w):w=e[20];let k;e[21]!==x||e[22]!==m?(k=m.length>0&&r.jsx(yc,{heading:"Your branches",children:m.map(N=>r.jsxs(Sc,{value:N.name,onSelect:()=>x(N.name),children:[r.jsx(gr,{className:"mr-2 h-4 w-4"}),r.jsx("span",{className:"flex-1 truncate",children:N.name})]},N.name))}),e[21]=x,e[22]=m,e[23]=k):k=e[23];let T;e[24]!==p||e[25]!==x?(T=p.length>0&&r.jsxs(r.Fragment,{children:[r.jsx(l_,{}),r.jsx(yc,{heading:"Other branches in repo",children:p.map(N=>r.jsxs(Sc,{value:N.name,onSelect:()=>x(N.name),children:[r.jsx(gr,{className:"mr-2 h-4 w-4"}),r.jsx("span",{className:"flex-1 truncate",children:N.name}),N.author&&r.jsxs("span",{className:"text-xs text-muted-foreground",children:["@",N.author]})]},N.name))})]}),e[24]=p,e[25]=x,e[26]=T):T=e[26];let I;e[27]!==V||e[28]!==w||e[29]!==k||e[30]!==T?(I=r.jsx(ai,{className:"w-[min(420px,calc(100vw-2rem))] p-0",align:"start",children:r.jsxs(d_,{children:[j,r.jsxs(h_,{children:[V,w,k,T]})]})}),e[27]=V,e[28]=w,e[29]=k,e[30]=T,e[31]=I):I=e[31];let A;return e[32]!==u||e[33]!==I||e[34]!==C?(A=r.jsxs(li,{open:u,onOpenChange:h,children:[C,I]}),e[32]=u,e[33]=I,e[34]=C,e[35]=A):A=e[35],A}const Lb=["radial-gradient(ellipse 25% 220% at -5% 120%, rgba(165,149,255,0.35) 0%, transparent 100%)","radial-gradient(ellipse 25% 220% at 105% -20%, rgba(208,236,26,0.32) 0%, transparent 100%)"].join(", "),Bb="/decotexture.svg";function qc(t){const e=B.c(7),{onClick:s}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i={backgroundImage:Lb},e[0]=i):i=e[0];let n,o;e[1]===Symbol.for("react.memo_cache_sentinel")?(n=r.jsx("div",{className:"relative shrink-0 p-1.5 bg-[var(--brand-green-light)] rounded-lg border border-border",children:r.jsx(Ms,{icon:"/logos/deco%20logo.svg",name:"deco.cx",size:"xs",className:"border-0 rounded-none bg-transparent"})}),o=r.jsx("p",{className:"flex-1 relative text-sm font-medium text-foreground leading-none whitespace-nowrap",children:"Import your deco.cx site"}),e[1]=n,e[2]=o):(n=e[1],o=e[2]);let a;e[3]===Symbol.for("react.memo_cache_sentinel")?(a=r.jsx("img",{src:Bb,alt:"","aria-hidden":!0,className:"absolute pointer-events-none",style:{width:"274.5px",height:"272.25px",left:"calc(50% + 145.5px)",top:"calc(50% + 40px)",transform:"translate(-50%, -50%)"}}),e[3]=a):a=e[3];let l;e[4]===Symbol.for("react.memo_cache_sentinel")?(l=r.jsx("div",{className:"relative bg-background flex items-center justify-center size-8 rounded-md shrink-0",children:r.jsx(ro,{size:16,className:"text-foreground transition-transform group-hover:translate-x-0.5"})}),e[4]=l):l=e[4];let c;return e[5]!==s?(c=r.jsxs("button",{type:"button",onClick:s,className:"w-full relative flex items-center gap-4 px-4 py-4 rounded-lg border border-border bg-background overflow-hidden transition-colors text-left cursor-pointer group",style:i,children:[n,o,a,l]}),e[5]=s,e[6]=c):c=e[6],c}function Ob(){const t=B.c(5),{data:e}=St.useSession();let s;t[0]!==e?.user?.email?(s=lt.decoProfile(e?.user?.email),t[0]=e?.user?.email,t[1]=s):s=t[1];const i=!!e?.user?.email;let n;t[2]!==s||t[3]!==i?(n={queryKey:s,queryFn:$b,enabled:i,staleTime:3e5},t[2]=s,t[3]=i,t[4]=n):n=t[4];const{data:o}=Fi(n);return o?.isDecoUser??!1}async function $b(){const t=await fetch("/api/deco-sites/profile");return t.ok?t.json():{isDecoUser:!1}}function zb(t){const e=B.c(56),{onOpenContextPanel:s}=t,{data:i}=St.useSession(),[n,o]=S.useState(!1),a=Ob(),l=Rs(),{hasDecoKey:c,isZeroBalance:d,isInitialFreeCredit:u,balanceDollars:h,hasOnlyDecoProvider:f}=co();let m;e[0]!==i?.user?.name?(m=i?.user?.name?.split(" ")[0]||"there",e[0]=i?.user?.name,e[1]=m):m=e[1];const p=m,g=c&&u&&h!=null,_=c&&d&&f;if(l){let N;e[2]!==h||e[3]!==g?(N=g&&r.jsx("div",{className:"mb-4",children:r.jsx(De.CreditsEyebrow,{balanceDollars:h})}),e[2]=h,e[3]=g,e[4]=N):N=e[4];let E;e[5]!==_?(E=_&&r.jsx("div",{className:"mb-4",children:r.jsx(De.NoCreditsEyebrow,{})}),e[5]=_,e[6]=E):E=e[6];let R;e[7]!==p?(R=r.jsxs("p",{className:"text-3xl font-medium text-foreground text-center max-w-[280px]",children:["What's on your mind, ",p,"?"]}),e[7]=p,e[8]=R):R=e[8];let M;e[9]!==N||e[10]!==E||e[11]!==R?(M=r.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center w-full",children:[N,E,R]}),e[9]=N,e[10]=E,e[11]=R,e[12]=M):M=e[12];let L;e[13]===Symbol.for("react.memo_cache_sentinel")?(L=r.jsx(Uc,{}),e[13]=L):L=e[13];let D;e[14]!==s?(D=r.jsxs("div",{className:"w-full flex flex-col gap-4 pb-4",children:[L,r.jsx(De.Input,{onOpenContextPanel:s,showConnectionsBanner:!0})]}),e[14]=s,e[15]=D):D=e[15];let P;e[16]!==a?(P=a&&r.jsx("div",{className:"w-full",children:r.jsx(qc,{onClick:()=>o(!0)})}),e[16]=a,e[17]=P):P=e[17];let O;e[18]!==M||e[19]!==D||e[20]!==P?(O=r.jsxs("div",{className:"flex-1 relative flex flex-col items-center px-4",children:[M,D,P]}),e[18]=M,e[19]=D,e[20]=P,e[21]=O):O=e[21];let z;e[22]!==n?(z=r.jsx(Bn,{open:n,onOpenChange:o}),e[22]=n,e[23]=z):z=e[23];let $;return e[24]!==z||e[25]!==O?($=r.jsxs(r.Fragment,{children:[O,z]}),e[24]=z,e[25]=O,e[26]=$):$=e[26],$}let v;e[27]!==h||e[28]!==g?(v=g&&r.jsx("div",{className:"mb-4",children:r.jsx(De.CreditsEyebrow,{balanceDollars:h})}),e[27]=h,e[28]=g,e[29]=v):v=e[29];let x;e[30]!==_?(x=_&&r.jsx("div",{className:"mb-4",children:r.jsx(De.NoCreditsEyebrow,{})}),e[30]=_,e[31]=x):x=e[31];let b;e[32]!==p?(b=r.jsxs("p",{className:"text-3xl font-medium text-foreground",children:["What's on your mind, ",p,"?"]}),e[32]=p,e[33]=b):b=e[33];let y;e[34]!==v||e[35]!==x||e[36]!==b?(y=r.jsxs("div",{className:"text-center mb-10",children:[v,x,b]}),e[34]=v,e[35]=x,e[36]=b,e[37]=y):y=e[37];let C;e[38]!==s?(C=r.jsx("div",{className:"w-full",children:r.jsx(De.Input,{onOpenContextPanel:s,showConnectionsBanner:!0})}),e[38]=s,e[39]=C):C=e[39];let j;e[40]!==y||e[41]!==C?(j=r.jsxs("div",{className:"flex flex-col items-center w-full max-w-[672px]",children:[y,C]}),e[40]=y,e[41]=C,e[42]=j):j=e[42];let V;e[43]===Symbol.for("react.memo_cache_sentinel")?(V=r.jsx("div",{className:"w-full mt-10 mx-auto",children:r.jsx(Uc,{})}),e[43]=V):V=e[43];let w;e[44]!==j?(w=r.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center w-full",children:[j,V]}),e[44]=j,e[45]=w):w=e[45];let k;e[46]!==a?(k=a&&r.jsx("div",{className:"absolute bottom-6 left-0 right-0 px-10",children:r.jsx("div",{className:"w-full max-w-[500px] mx-auto",children:r.jsx(qc,{onClick:()=>o(!0)})})}),e[46]=a,e[47]=k):k=e[47];let T;e[48]!==k||e[49]!==w?(T=r.jsxs("div",{className:"flex-1 relative flex flex-col items-center px-10",children:[w,k]}),e[48]=k,e[49]=w,e[50]=T):T=e[50];let I;e[51]!==n?(I=r.jsx(Bn,{open:n,onOpenChange:o}),e[51]=n,e[52]=I):I=e[52];let A;return e[53]!==T||e[54]!==I?(A=r.jsxs(r.Fragment,{children:[T,I]}),e[53]=T,e[54]=I,e[55]=A):A=e[55],A}function Fb(){const t=B.c(26),{org:e}=be(),{selectedVirtualMcp:s}=ni(),{data:i}=St.useSession(),{currentBranch:n,setCurrentTaskBranch:o}=es();let a;t[0]!==e.id?(a=io(e.id),t[0]=e.id,t[1]=a):a=t[1];const c=s??a,d=ts(c.id),u=i?.user?.id??"",h=d?.metadata?.githubRepo??null,f=!!h?.connectionId&&!!u;let m;t[2]===Symbol.for("react.memo_cache_sentinel")?(m=r.jsx(ao,{size:32}),t[2]=m):m=t[2];let p;t[3]!==c.icon||t[4]!==c.title?(p=r.jsx(Ms,{icon:c.icon,name:c.title,size:"lg",fallbackIcon:m,className:"size-10 min-w-10 md:size-[60px]! md:min-w-[60px] rounded-xl md:rounded-[18px]!"}),t[3]=c.icon,t[4]=c.title,t[5]=p):p=t[5];let g;t[6]!==c.title?(g=r.jsx("h3",{className:"text-base md:text-xl font-medium text-foreground",children:c.title}),t[6]=c.title,t[7]=g):g=t[7];const _=c.description??"Ask anything about configuring model providers or using MCP Mesh.";let v;t[8]!==_?(v=r.jsx("div",{className:"text-muted-foreground text-center text-base max-w-md line-clamp-2",children:_}),t[8]=_,t[9]=v):v=t[9];let x;t[10]!==n||t[11]!==d?.metadata?.vmMap||t[12]!==h||t[13]!==e.id||t[14]!==o||t[15]!==f||t[16]!==u?(x=f&&r.jsx("div",{className:"mt-2",children:r.jsx(Pb,{orgId:e.id,userId:u,connectionId:h.connectionId,owner:h.owner,repo:h.name,vmMap:d?.metadata?.vmMap,value:n??void 0,onChange:o})}),t[10]=n,t[11]=d?.metadata?.vmMap,t[12]=h,t[13]=e.id,t[14]=o,t[15]=f,t[16]=u,t[17]=x):x=t[17];let b;t[18]!==p||t[19]!==g||t[20]!==v||t[21]!==x?(b=r.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 md:gap-4 text-center",children:[p,g,v,x]}),t[18]=p,t[19]=g,t[20]=v,t[21]=x,t[22]=b):b=t[22];let y;t[23]===Symbol.for("react.memo_cache_sentinel")?(y=r.jsx("div",{className:"w-full max-w-3xl mx-auto",children:r.jsx(De.IceBreakers,{})}),t[23]=y):y=t[23];let C;return t[24]!==b?(C=r.jsxs("div",{className:"h-full w-full flex flex-col items-center justify-center gap-6 px-4",children:[b,y]}),t[24]=b,t[25]=C):C=t[25],C}function Hb(t){const e=B.c(27),{variant:s}=t,{org:i}=be(),n=bl(),{isChatEmpty:o}=Ui(),[a,l]=S.useState("chat"),c=co();if(n.length===0){let C;return e[0]===Symbol.for("react.memo_cache_sentinel")?(C=r.jsx(De,{className:"animate-in fade-in-0 duration-200",children:r.jsx(De.Main,{className:"flex flex-col items-center",children:r.jsx(De.EmptyState,{children:r.jsx(De.NoAiProviderEmptyState,{})})})}),e[0]=C):C=e[0],C}let d;e[1]!==c.hasDecoKey||e[2]!==c.hasOnlyDecoProvider||e[3]!==c.isLoading||e[4]!==c.isZeroBalance||e[5]!==o||e[6]!==i?(d=c.hasDecoKey&&c.isZeroBalance&&c.hasOnlyDecoProvider&&!c.isLoading&&o&&!Mv(i.id),e[1]=c.hasDecoKey,e[2]=c.hasOnlyDecoProvider,e[3]=c.isLoading,e[4]=c.isZeroBalance,e[5]=o,e[6]=i,e[7]=d):d=e[7];const u=d;let h;e[8]!==u?(h=u&&r.jsx(De.CreditsEmptyState,{}),e[8]=u,e[9]=h):h=e[9];const f=a!=="chat"?"opacity-0 pointer-events-none":"opacity-100";let m;e[10]!==f?(m=X("absolute inset-0 flex flex-col transition-opacity duration-100 ease-out",f),e[10]=f,e[11]=m):m=e[11];let p;e[12]!==o||e[13]!==s?(p=o?s==="home"?r.jsx(zb,{onOpenContextPanel:()=>l("context")}):r.jsxs(r.Fragment,{children:[r.jsx(De.Main,{children:r.jsx(Fb,{})}),r.jsx(De.Footer,{children:r.jsx(De.Input,{onOpenContextPanel:()=>l("context")})})]}):r.jsxs(r.Fragment,{children:[r.jsx(De.Main,{children:r.jsx(De.Messages,{})}),r.jsx(De.Footer,{children:r.jsx(De.Input,{onOpenContextPanel:()=>l("context")})})]}),e[12]=o,e[13]=s,e[14]=p):p=e[14];let g;e[15]!==m||e[16]!==p?(g=r.jsx("div",{className:m,children:p}),e[15]=m,e[16]=p,e[17]=g):g=e[17];const _=a==="context"?"opacity-100":"opacity-0 pointer-events-none";let v;e[18]!==_?(v=X("absolute inset-0 flex flex-col transition-opacity duration-100 ease-out",_),e[18]=_,e[19]=v):v=e[19];let x;e[20]===Symbol.for("react.memo_cache_sentinel")?(x=r.jsx(bb,{back:!0,onClose:()=>l("chat")}),e[20]=x):x=e[20];let b;e[21]!==v?(b=r.jsx("div",{className:v,children:x}),e[21]=v,e[22]=b):b=e[22];let y;return e[23]!==b||e[24]!==h||e[25]!==g?(y=r.jsxs(De,{className:"relative overflow-hidden animate-in fade-in-0 duration-200",children:[h,g,b]}),e[23]=b,e[24]=h,e[25]=g,e[26]=y):y=e[26],y}function qu(t){const e=B.c(4),{variant:s}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx(De.Skeleton,{}),e[0]=i):i=e[0];let n;e[1]===Symbol.for("react.memo_cache_sentinel")?(n=r.jsx(De.Skeleton,{}),e[1]=n):n=e[1];let o;return e[2]!==s?(o=r.jsx(Cs,{fallback:i,children:r.jsx(S.Suspense,{fallback:n,children:r.jsx(Hb,{variant:s})})}),e[2]=s,e[3]=o):o=e[3],o}function Wb(){const t=B.c(6),{org:e,locator:s}=be(),i=Mt();let n;t[0]!==s||t[1]!==i?(n=()=>{i.invalidateQueries({queryKey:lt.tasksPrefix(s)})},t[0]=s,t[1]=i,t[2]=n):n=t[2];let o;t[3]!==e.id||t[4]!==n?(o={orgId:e.id,onTaskStatus:n},t[3]=e.id,t[4]=n,t[5]=o):o=t[5],b_(o)}function Ub(t){const e=B.c(8),{virtualMcpId:s,size:i,showAutomationBadge:n}=t,o=i===void 0?"sm":i;let a;e[0]!==o||e[1]!==s?(a=s?r.jsx(Kb,{virtualMcpId:s,size:o}):r.jsx(zs,{icon:null,name:"?",size:o}),e[0]=o,e[1]=s,e[2]=a):a=e[2];let l;e[3]!==n?(l=n&&r.jsx("span",{"aria-label":"Automation-triggered",className:"absolute -bottom-0.5 -right-0.5 flex size-4 items-center justify-center rounded-full bg-blue-500 border border-blue-600 text-white",children:r.jsx($i,{size:10,className:"text-white"})}),e[3]=n,e[4]=l):l=e[4];let c;return e[5]!==a||e[6]!==l?(c=r.jsxs("div",{className:"relative shrink-0",children:[a,l]}),e[5]=a,e[6]=l,e[7]=c):c=e[7],c}function Kb(t){const e=B.c(6),{virtualMcpId:s,size:i}=t,n=ts(s);if(!n){let l;return e[0]!==i?(l=r.jsx(zs,{icon:null,name:"?",size:i}),e[0]=i,e[1]=l):l=e[1],l}const o=n.icon??null;let a;return e[2]!==n.title||e[3]!==i||e[4]!==o?(a=r.jsx(zs,{icon:o,name:n.title,size:i}),e[2]=n.title,e[3]=i,e[4]=o,e[5]=a):a=e[5],a}function Fs(t){const e=t?.metadata?.githubRepo;return e?.connectionId&&t?.connections?.some(i=>i.connection_id===e.connectionId)?e:null}function qb(t){const e=B.c(42),{task:s,isActive:i,onClick:n,onArchive:o,showAutomationBadge:a}=t,l=zp(s.status),c=l.icon,d=ts(s.virtual_mcp_id);let u;e[0]!==d?(u=Fs(d),e[0]=d,e[1]=u):u=e[1];const h=u,f="button",m=0;let p;e[2]!==n?(p=O=>{O.target===O.currentTarget&&(O.key==="Enter"||O.key===" ")&&(O.preventDefault(),n())},e[2]=n,e[3]=p):p=e[3];const g=i?"bg-accent":"hover:bg-accent/60";let _;e[4]!==g?(_=X("group/row flex items-center gap-3 px-2 py-1.5 rounded-md cursor-pointer transition-colors",g),e[4]=g,e[5]=_):_=e[5];let v;e[6]!==a||e[7]!==s.virtual_mcp_id?(v=r.jsx(Ub,{virtualMcpId:s.virtual_mcp_id,size:"sm",showAutomationBadge:a}),e[6]=a,e[7]=s.virtual_mcp_id,e[8]=v):v=e[8];const x=s.title||"Untitled task";let b;e[9]!==x?(b=r.jsx("div",{className:"text-sm text-foreground truncate",children:x}),e[9]=x,e[10]=b):b=e[10];let y;e[11]!==h||e[12]!==s.branch||e[13]!==s.updated_at?(y=s.updated_at&&r.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground min-w-0",children:[s.branch?r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"truncate font-mono",children:s.branch}),r.jsx("span",{className:"shrink-0",children:"·"})]}):h?r.jsxs(r.Fragment,{children:[r.jsxs("span",{className:"truncate",children:[h.owner,"/",h.name]}),r.jsx("span",{className:"shrink-0",children:"·"})]}):null,r.jsx("span",{className:"shrink-0",children:Fp(new Date(s.updated_at))})]}),e[11]=h,e[12]=s.branch,e[13]=s.updated_at,e[14]=y):y=e[14];let C;e[15]!==y||e[16]!==b?(C=r.jsxs("div",{className:"flex-1 min-w-0",children:[b,y]}),e[15]=y,e[16]=b,e[17]=C):C=e[17];const j="shrink-0 grid [grid-template-areas:'slot'] items-center justify-items-center",V="[grid-area:slot] flex size-7 items-center justify-center group-hover/row:invisible",w=l.label,k=14,T=X(l.iconClassName,s.status==="in_progress"&&"animate-spin");let I;e[18]!==c||e[19]!==T?(I=r.jsx(c,{size:k,className:T}),e[18]=c,e[19]=T,e[20]=I):I=e[20];let A;e[21]!==l||e[22]!==I?(A=r.jsx("span",{className:V,"aria-label":w,children:I}),e[21]=l,e[22]=I,e[23]=A):A=e[23];let N;e[24]!==o?(N=O=>{O.stopPropagation(),o()},e[24]=o,e[25]=N):N=e[25];let E;e[26]===Symbol.for("react.memo_cache_sentinel")?(E=r.jsx(_g,{size:14}),e[26]=E):E=e[26];let R;e[27]!==N?(R=r.jsx(tt,{asChild:!0,children:r.jsx("button",{type:"button","aria-label":"Archive task",onClick:N,className:"[grid-area:slot] invisible group-hover/row:visible flex size-7 items-center justify-center rounded-md text-muted-foreground hover:text-foreground hover:bg-muted",children:E})}),e[27]=N,e[28]=R):R=e[28];let M;e[29]===Symbol.for("react.memo_cache_sentinel")?(M=r.jsx(st,{side:"right",children:"Archive"}),e[29]=M):M=e[29];let L;e[30]!==R?(L=r.jsxs(it,{children:[R,M]}),e[30]=R,e[31]=L):L=e[31];let D;e[32]!==A||e[33]!==L?(D=r.jsxs("div",{className:j,children:[A,L]}),e[32]=A,e[33]=L,e[34]=D):D=e[34];let P;return e[35]!==n||e[36]!==C||e[37]!==D||e[38]!==p||e[39]!==_||e[40]!==v?(P=r.jsxs("div",{role:f,tabIndex:m,onClick:n,onKeyDown:p,className:_,children:[v,C,D]}),e[35]=n,e[36]=C,e[37]=D,e[38]=p,e[39]=_,e[40]=v,e[41]=P):P=e[41],P}const Gu={all:"All tasks",manual:"Chats",automation:"Automation"},Yu={all:"All members",mine:"Mine only"};function Gb(t){const e=B.c(57),{title:s,tasks:i,activeTaskId:n,onSelect:o,onArchive:a,onNew:l,showNewButton:c,showAutomationBadge:d,emptyLabel:u,currentUserId:h}=t,[f,m]=S.useState("all"),[p,g]=S.useState("mine");let _;e[0]!==h||e[1]!==p||e[2]!==i?(_=p==="mine"&&h?i.filter(G=>G.created_by===h):i,e[0]=h,e[1]=p,e[2]=i,e[3]=_):_=e[3];const v=_;let x;e[4]!==f||e[5]!==v?(x=f==="automation"?v.filter(Qb):f==="manual"?v.filter(Jb):v,e[4]=f,e[5]=v,e[6]=x):x=e[6];const b=x;let y;e[7]!==s?(y=r.jsx("span",{children:s}),e[7]=s,e[8]=y):y=e[8];let C;e[9]!==p?(C=r.jsx(ks,{asChild:!0,children:r.jsx("button",{type:"button","aria-label":"Filter by member",className:"flex size-8 items-center justify-center rounded-md hover:bg-muted hover:text-foreground",children:p==="mine"?r.jsx(xg,{size:16}):r.jsx(ao,{size:16})})}),e[9]=p,e[10]=C):C=e[10];let j;e[11]!==p?(j=G=>{const q=G;q!==p&&se("tasks_panel_member_filter_changed",{to_value:q}),g(q)},e[11]=p,e[12]=j):j=e[12];let V;e[13]===Symbol.for("react.memo_cache_sentinel")?(V=Object.keys(Yu),e[13]=V):V=e[13];let w;e[14]===Symbol.for("react.memo_cache_sentinel")?(w=V.map(Xb),e[14]=w):w=e[14];let k;e[15]!==p||e[16]!==j?(k=r.jsx(Ns,{align:"end",children:r.jsx(hc,{value:p,onValueChange:j,children:w})}),e[15]=p,e[16]=j,e[17]=k):k=e[17];let T;e[18]!==C||e[19]!==k?(T=r.jsxs(js,{children:[C,k]}),e[18]=C,e[19]=k,e[20]=T):T=e[20];const I=f!=="all"&&"text-purple-500";let A;e[21]!==I?(A=X("flex size-8 items-center justify-center rounded-md hover:bg-muted hover:text-foreground",I),e[21]=I,e[22]=A):A=e[22];let N;e[23]===Symbol.for("react.memo_cache_sentinel")?(N=r.jsx($g,{size:16}),e[23]=N):N=e[23];let E;e[24]!==A?(E=r.jsx(ks,{asChild:!0,children:r.jsx("button",{type:"button","aria-label":"Filter tasks",className:A,children:N})}),e[24]=A,e[25]=E):E=e[25];let R;e[26]!==f?(R=G=>{const q=G;q!==f&&se("tasks_panel_filter_changed",{to_value:q}),m(q)},e[26]=f,e[27]=R):R=e[27];let M;e[28]===Symbol.for("react.memo_cache_sentinel")?(M=Object.keys(Gu),e[28]=M):M=e[28];let L;e[29]===Symbol.for("react.memo_cache_sentinel")?(L=M.map(Yb),e[29]=L):L=e[29];let D;e[30]!==f||e[31]!==R?(D=r.jsx(Ns,{align:"end",children:r.jsx(hc,{value:f,onValueChange:R,children:L})}),e[30]=f,e[31]=R,e[32]=D):D=e[32];let P;e[33]!==E||e[34]!==D?(P=r.jsxs(js,{children:[E,D]}),e[33]=E,e[34]=D,e[35]=P):P=e[35];let O;e[36]!==l||e[37]!==c||e[38]!==s?(O=c&&l&&r.jsx("button",{type:"button",onClick:()=>{se("tasks_panel_new_clicked"),l()},"aria-label":`New ${s.toLowerCase()}`,className:"flex size-8 items-center justify-center rounded-md hover:bg-muted hover:text-foreground",children:r.jsx(pl,{size:16})}),e[36]=l,e[37]=c,e[38]=s,e[39]=O):O=e[39];let z;e[40]!==P||e[41]!==O||e[42]!==T?(z=r.jsxs("div",{className:"flex items-center gap-0.5",children:[T,P,O]}),e[40]=P,e[41]=O,e[42]=T,e[43]=z):z=e[43];let $;e[44]!==z||e[45]!==y?($=r.jsxs("div",{className:"pl-2 pr-1.5 h-7 flex items-center justify-between text-xs font-medium text-muted-foreground mb-1",children:[y,z]}),e[44]=z,e[45]=y,e[46]=$):$=e[46];let W;e[47]!==n||e[48]!==u||e[49]!==a||e[50]!==o||e[51]!==d||e[52]!==b?(W=b.length===0&&u?r.jsx("div",{className:"px-2 py-1.5 text-xs text-muted-foreground/70",children:u}):b.map(G=>r.jsx(qb,{task:G,isActive:n===G.id,onClick:()=>{n!==G.id&&se("tasks_panel_task_clicked",{thread_id:G.id,virtual_mcp_id:G.virtual_mcp_id??null,from_automation:!!G.fromAutomation}),o(G)},onArchive:()=>{se("tasks_panel_task_archived",{thread_id:G.id,virtual_mcp_id:G.virtual_mcp_id??null}),a(G)},showAutomationBadge:d||G.fromAutomation},G.id)),e[47]=n,e[48]=u,e[49]=a,e[50]=o,e[51]=d,e[52]=b,e[53]=W):W=e[53];let F;return e[54]!==$||e[55]!==W?(F=r.jsxs("div",{className:"flex flex-col gap-0.5 mt-1",children:[$,W]}),e[54]=$,e[55]=W,e[56]=F):F=e[56],F}function Yb(t){return r.jsx(Oh,{value:t,children:Gu[t]},t)}function Xb(t){return r.jsx(Oh,{value:t,children:Yu[t]},t)}function Jb(t){return!t.fromAutomation}function Qb(t){return t.fromAutomation}function Zb(){const t=B.c(22);Wb();const{data:e}=St.useSession(),s=e?.user?.id;let i;t[0]===Symbol.for("react.memo_cache_sentinel")?(i={owner:"me",status:"open",hasTrigger:!1},t[0]=i):i=t[0];const{tasks:n}=ia(i);let o;t[1]===Symbol.for("react.memo_cache_sentinel")?(o={owner:"all",status:"open",hasTrigger:!0},t[1]=o):o=t[1];const{tasks:a}=ia(o),{setTaskId:l,createNewTask:c}=zr();let d;t[2]===Symbol.for("react.memo_cache_sentinel")?(d={strict:!1},t[2]=d):d=t[2];const u=$r(d),{locator:h,org:f}=be(),m=Mt();let p;t[3]!==f.id?(p={connectionId:Wt,orgId:f.id},t[3]=f.id,t[4]=p):p=t[4];const g=Me(p),_=u.taskId??null;let v;t[5]!==a||t[6]!==n?(v=[...n,...a.map(t0)].sort(e0),t[5]=a,t[6]=n,t[7]=v):v=t[7];const x=v;let b;t[8]!==g||t[9]!==h||t[10]!==m?(b=async V=>{try{await Ep(g,V.id,{hidden:!0}),m.invalidateQueries({queryKey:lt.tasksPrefix(h)})}catch(w){const T=w;pe.error(`Failed to archive task: ${T.message}`)}},t[8]=g,t[9]=h,t[10]=m,t[11]=b):b=t[11];const y=b;if(x.length===0){let V;return t[12]===Symbol.for("react.memo_cache_sentinel")?(V=r.jsx("div",{className:"h-full flex items-center justify-center p-4",children:r.jsx(Oi,{image:r.jsx(vg,{size:48,className:"text-muted-foreground"}),title:"No tasks yet",description:"Start a conversation to create your first task."})}),t[12]=V):V=t[12],V}let C;t[13]!==l?(C=V=>l(V.id,V.virtual_mcp_id),t[13]=l,t[14]=C):C=t[14];let j;return t[15]!==_||t[16]!==x||t[17]!==c||t[18]!==s||t[19]!==y||t[20]!==C?(j=r.jsx("div",{className:"flex flex-col h-full min-h-0 overflow-y-auto p-2 gap-3",children:r.jsx(Gb,{title:"Tasks",tasks:x,activeTaskId:_,onSelect:C,onArchive:y,onNew:c,showNewButton:!0,currentUserId:s})}),t[15]=_,t[16]=x,t[17]=c,t[18]=s,t[19]=y,t[20]=C,t[21]=j):j=t[21],j}function e0(t,e){return(e.updated_at??"").localeCompare(t.updated_at??"")}function t0(t){return{...t,fromAutomation:!0}}function s0(){const t=B.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=r.jsx("div",{className:"flex flex-col h-full p-2 gap-1.5",children:Array.from({length:6}).map(i0)}),t[0]=e):e=t[0],e}function i0(t,e){return r.jsx("div",{className:"h-10 rounded-md bg-muted/60 animate-pulse"},e)}function Xu(){const t=B.c(2);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=r.jsx(De.Skeleton,{}),t[0]=e):e=t[0];let s;return t[1]===Symbol.for("react.memo_cache_sentinel")?(s=r.jsx(Cs,{fallback:e,children:r.jsx(S.Suspense,{fallback:r.jsx(s0,{}),children:r.jsx(Zb,{})})}),t[1]=s):s=t[1],s}function Ju(){const t=B.c(77),{org:e}=be(),s=Ke(),i=Vh(),{setTasksOpen:n,openTab:o}=zr(),a=e.slug,l=be().project;let c;t[0]===Symbol.for("react.memo_cache_sentinel")?(c={strict:!1},t[0]=c):c=t[0];const d=$r(c);let u;t[1]===Symbol.for("react.memo_cache_sentinel")?(u={strict:!1},t[1]=u):u=t[1];const h=vi(u),f=i.location.pathname;let m;t[2]!==l.enabledPlugins?(m=l.enabledPlugins??[],t[2]=l.enabledPlugins,t[3]=m):m=t[3];const p=m;let g;t[4]!==l.ui?(g=l.ui?.pinnedViews??[],t[4]=l.ui,t[5]=g):g=t[5];const _=g;let v,x,b,y;if(t[6]!==l.id||t[7]!==p||t[8]!==s||t[9]!==a||t[10]!==d.pluginId||t[11]!==d.taskId||t[12]!==h.virtualmcpid){let q;t[17]!==p?(q=ie=>p.includes(ie.pluginId),t[17]=p,t[18]=q):q=t[18];const H=ep.filter(q),ee=h.virtualmcpid??l.id;x=!!h.virtualmcpid;const K=d.taskId??"",U=d.pluginId;let te;t[19]!==U?(te=ie=>U===ie,t[19]=U,t[20]=te):te=t[20],v=te;let Y;t[21]!==K||t[22]!==s||t[23]!==a||t[24]!==ee?(Y=ie=>{const ue=K||crypto.randomUUID();s({to:"/$org/$taskId/$pluginId",params:{org:a,taskId:ue,pluginId:ie},search:de=>({...de,virtualmcpid:ee})})},t[21]=K,t[22]=s,t[23]=a,t[24]=ee,t[25]=Y):Y=t[25],b=Y;let J;t[26]!==v||t[27]!==b?(J=ie=>({key:ie.pluginId,label:ie.label,icon:ie.icon,isActive:v(ie.pluginId),onClick:()=>b(ie.pluginId)}),t[26]=v,t[27]=b,t[28]=J):J=t[28],y=H.map(J),t[6]=l.id,t[7]=p,t[8]=s,t[9]=a,t[10]=d.pluginId,t[11]=d.taskId,t[12]=h.virtualmcpid,t[13]=v,t[14]=x,t[15]=b,t[16]=y}else v=t[13],x=t[14],b=t[15],y=t[16];const C=y;let j;if(t[29]!==p||t[30]!==v||t[31]!==b){let q;t[33]!==p?(q=K=>p.includes(K.pluginId),t[33]=p,t[34]=q):q=t[34];const H=tp.filter(q);let ee;t[35]!==v||t[36]!==b?(ee=K=>({type:"group",group:{id:`${K.pluginId}-${K.id}`,label:K.label,items:K.items.map((U,te)=>({key:`${K.pluginId}-${K.id}-${te}`,label:U.label,icon:U.icon,isActive:v(K.pluginId),onClick:()=>b(K.pluginId)})),defaultExpanded:K.defaultExpanded??!0}}),t[35]=v,t[36]=b,t[37]=ee):ee=t[37],j=H.map(ee),t[29]=p,t[30]=v,t[31]=b,t[32]=j}else j=t[32];const V=j;let w;if(t[38]!==o||t[39]!==_){let q;t[41]!==o?(q=H=>{const ee=Fr(H.icon),K=ee.type==="icon"?Hr(ee.name):null;return{key:`app-${H.connectionId}-${H.toolName}`,label:H.label||H.toolName,icon:K?r.jsx(K,{size:16,className:"text-muted-foreground"}):ee.type==="url"?r.jsx("img",{src:ee.url,alt:"",className:"size-4 rounded"}):r.jsx(gu,{size:16,className:"text-muted-foreground"}),isActive:!1,onClick:()=>o(ra(H.connectionId,H.toolName))}},t[41]=o,t[42]=q):q=t[42],w=_.map(q),t[38]=o,t[39]=_,t[40]=w}else w=t[40];const k=w;let T;t[43]!==k?(T=k.length>0?{type:"group",group:{id:"apps",label:"Apps",items:k,defaultExpanded:!0}}:null,t[43]=k,t[44]=T):T=t[44];const I=T;let A;t[45]===Symbol.for("react.memo_cache_sentinel")?(A=r.jsx(bg,{className:"size-4!"}),t[45]=A):A=t[45];const N=f===`/${a}`||f===`/${a}/`;let E;t[46]!==s||t[47]!==a||t[48]!==n?(E=()=>{n(!1),s({to:"/$org",params:{org:a}})},t[46]=s,t[47]=a,t[48]=n,t[49]=E):E=t[49];let R;t[50]!==E||t[51]!==N?(R={key:"home",label:"Home",icon:A,isActive:N,onClick:E},t[50]=E,t[51]=N,t[52]=R):R=t[52];const M=R;let L;t[53]!==p?(L=p.includes(sp),t[53]=p,t[54]=L):L=t[54];const D=L;let P;t[55]===Symbol.for("react.memo_cache_sentinel")?(P=r.jsx(ip,{className:"size-4!"}),t[55]=P):P=t[55];let O;t[56]!==a||t[57]!==f?(O=f.startsWith(`/${a}/settings/workflows`),t[56]=a,t[57]=f,t[58]=O):O=t[58];let z;t[59]!==s||t[60]!==a?(z=()=>s({to:"/$org/settings/workflows",params:{org:a}}),t[59]=s,t[60]=a,t[61]=z):z=t[61];let $;t[62]!==O||t[63]!==z?($={key:"workflows",label:"Workflows",icon:P,isActive:O,onClick:z},t[62]=O,t[63]=z,t[64]=$):$=t[64];const W=$;let F;if(t[65]!==M||t[66]!==x||t[67]!==D||t[68]!==W){const q=[M];x&&D&&q.push(W),F={type:"items",items:q},t[65]=M,t[66]=x,t[67]=D,t[68]=W,t[69]=F}else F=t[69];let G;if(t[70]!==I||t[71]!==V||t[72]!==C||t[73]!==F){if(G=[F],C.length>0){let q;t[75]!==C?(q={type:"items",items:C},t[75]=C,t[76]=q):q=t[76],G.push(q)}V.length>0&&G.push(...V),I&&G.push(I),t[70]=I,t[71]=V,t[72]=C,t[73]=F,t[74]=G}else G=t[74];return G}function Qu(t){const e=B.c(3),{children:s}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx("div",{className:"flex h-6 items-center",children:r.jsx("div",{className:"h-0.5 w-16 rounded-full bg-sidebar-foreground/15"})}),e[0]=i):i=e[0];let n;return e[1]!==s?(n=r.jsxs(Ur,{className:"pt-0 pr-0 pb-2 pl-0 mt-2",children:[i,r.jsx(Kr,{children:r.jsx(gs,{className:"gap-0.5",children:s})})]}),e[1]=s,e[2]=n):n=e[2],n}function r0(){const t=B.c(7),s=Ch().logo??jh,i=typeof s=="string"?s:s.light,n=typeof s=="string"?s:s.dark;let o;t[0]!==i?(o=r.jsx("img",{src:i,alt:"Logo",className:"size-6 object-contain dark:hidden"}),t[0]=i,t[1]=o):o=t[1];let a;t[2]!==n?(a=r.jsx("img",{src:n,alt:"Logo",className:"size-6 object-contain hidden dark:block"}),t[2]=n,t[3]=a):a=t[3];let l;return t[4]!==o||t[5]!==a?(l=r.jsx(vu,{className:"flex items-center justify-center shrink-0 px-2 pb-0",children:r.jsxs("div",{className:"flex w-full aspect-square items-center justify-center",children:[o,a]})}),t[4]=o,t[5]=a,t[6]=l):l=t[6],l}function Zu(t){const e=B.c(15),{item:s}=t,{isMobile:i,setOpenMobile:n}=qr();let o;e[0]!==i||e[1]!==s||e[2]!==n?(o=()=>{se("nav_item_clicked",{nav_key:s.key,nav_label:s.label,is_active:!!s.isActive,is_mobile:i}),s.onClick?.(),i&&n(!1)},e[0]=i,e[1]=s,e[2]=n,e[3]=o):o=e[3];const a=o,l=s.key,c=s.isActive&&"z-10";let d;e[4]!==c?(d=X(c),e[4]=c,e[5]=d):d=e[5];let u;e[6]!==a||e[7]!==s.icon||e[8]!==s.isActive||e[9]!==s.label?(u=r.jsx(us,{onClick:a,isActive:s.isActive,tooltip:s.label,className:"bg-muted/75",children:s.icon}),e[6]=a,e[7]=s.icon,e[8]=s.isActive,e[9]=s.label,e[10]=u):u=e[10];let h;return e[11]!==s.key||e[12]!==d||e[13]!==u?(h=r.jsx(Zt,{className:d,children:u},l),e[11]=s.key,e[12]=d,e[13]=u,e[14]=h):h=e[14],h}function n0(t){const e=B.c(12),{section:s}=t;switch(s.type){case"divider":{let i;return e[0]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx(_u,{className:"my-2"}),e[0]=i):i=e[0],i}case"spacer":{let i;return e[1]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx("div",{className:"flex-1"}),e[1]=i):i=e[1],i}case"group":{const i=s.group.label,n=s.group.defaultExpanded;let o;e[2]!==s.group.items?(o=s.group.items.map(a0),e[2]=s.group.items,e[3]=o):o=e[3];let a;return e[4]!==s.group.defaultExpanded||e[5]!==s.group.label||e[6]!==o?(a=r.jsx(Qu,{label:i,defaultExpanded:n,children:o}),e[4]=s.group.defaultExpanded,e[5]=s.group.label,e[6]=o,e[7]=a):a=e[7],a}case"items":{let i;e[8]!==s.items?(i=s.items.map(o0),e[8]=s.items,e[9]=i):i=e[9];let n;return e[10]!==i?(n=r.jsx(Ur,{className:"pt-0 pr-0 pb-0 pl-0",children:r.jsx(Kr,{children:r.jsx(gs,{className:"gap-1.5",children:i})})}),e[10]=i,e[11]=n):n=e[11],n}}}function o0(t){return r.jsx(Zu,{item:t},t.key)}function a0(t){return r.jsx(Zu,{item:t},t.key)}function l0(t){const e=B.c(14),{sections:s,header:i,footer:n,additionalContent:o,variant:a,contentClassName:l}=t,c=a===void 0?"sidebar":a;let d;e[0]===Symbol.for("react.memo_cache_sentinel")?(d=r.jsx(S.Suspense,{fallback:r.jsx("div",{className:"h-10 shrink-0"}),children:r.jsx(r0,{})}),e[0]=d):d=e[0];let u;e[1]!==l?(u=X("flex flex-col flex-1 px-2 py-2 gap-0",l),e[1]=l,e[2]=u):u=e[2];let h;e[3]!==s?(h=s.map(c0),e[3]=s,e[4]=h):h=e[4];let f;e[5]!==o||e[6]!==u||e[7]!==h?(f=r.jsxs(xu,{className:u,children:[h,o]}),e[5]=o,e[6]=u,e[7]=h,e[8]=f):f=e[8];let m;return e[9]!==n||e[10]!==i||e[11]!==f||e[12]!==c?(m=r.jsxs(y_,{variant:c,children:[d,i,f,n]}),e[9]=n,e[10]=i,e[11]=f,e[12]=c,e[13]=m):m=e[13],m}function c0(t,e){return r.jsx(n0,{section:t},e)}function ef(t){const e=B.c(2);let s;return e[0]!==t?(s=r.jsx(l0,{...t}),e[0]=t,e[1]=s):s=e[1],s}ef.Skeleton=function(){return r.jsx("div",{className:"flex flex-col gap-0.5",children:Array.from({length:8}).map((e,s)=>r.jsx("div",{className:"w-full h-8",children:r.jsx(Bi,{className:"h-full bg-sidebar-accent rounded-md"})},s))})};function d0(){const t=B.c(7),s=Ch().logo??jh,i=typeof s=="string"?s:s.light,n=typeof s=="string"?s:s.dark;let o;t[0]!==i?(o=r.jsx("img",{src:i,alt:"Logo",className:"size-6 object-contain dark:hidden"}),t[0]=i,t[1]=o):o=t[1];let a;t[2]!==n?(a=r.jsx("img",{src:n,alt:"Logo",className:"size-6 object-contain hidden dark:block"}),t[2]=n,t[3]=a):a=t[3];let l;return t[4]!==o||t[5]!==a?(l=r.jsx(vu,{className:"flex items-center justify-center shrink-0 px-2 pb-0",children:r.jsxs("div",{className:"flex w-full aspect-square items-center justify-center",children:[o,a]})}),t[4]=o,t[5]=a,t[6]=l):l=t[6],l}function Gc(t){const e=B.c(15),{item:s,onClose:i}=t,n=s.isActive&&"z-10";let o;e[0]!==n?(o=X(n),e[0]=n,e[1]=o):o=e[1];let a;e[2]!==s||e[3]!==i?(a=()=>{s.onClick?.(),i()},e[2]=s,e[3]=i,e[4]=a):a=e[4];let l;e[5]!==s.icon?(l=r.jsx("span",{className:"[&>svg]:size-8",children:s.icon}),e[5]=s.icon,e[6]=l):l=e[6];let c;e[7]!==s.isActive||e[8]!==s.label||e[9]!==a||e[10]!==l?(c=r.jsx(us,{onClick:a,isActive:s.isActive,tooltip:s.label,className:"bg-muted/75",children:l}),e[7]=s.isActive,e[8]=s.label,e[9]=a,e[10]=l,e[11]=c):c=e[11];let d;return e[12]!==o||e[13]!==c?(d=r.jsx(Zt,{className:o,children:c}),e[12]=o,e[13]=c,e[14]=d):d=e[14],d}function h0(t){const e=B.c(18),{section:s,onClose:i}=t;switch(s.type){case"divider":{let n;return e[0]===Symbol.for("react.memo_cache_sentinel")?(n=r.jsx(_u,{className:"my-2"}),e[0]=n):n=e[0],n}case"spacer":{let n;return e[1]===Symbol.for("react.memo_cache_sentinel")?(n=r.jsx("div",{className:"flex-1"}),e[1]=n):n=e[1],n}case"group":{const n=s.group.label,o=s.group.defaultExpanded;let a;if(e[2]!==i||e[3]!==s.group.items){let c;e[5]!==i?(c=d=>r.jsx(Gc,{item:d,onClose:i},d.key),e[5]=i,e[6]=c):c=e[6],a=s.group.items.map(c),e[2]=i,e[3]=s.group.items,e[4]=a}else a=e[4];let l;return e[7]!==s.group.defaultExpanded||e[8]!==s.group.label||e[9]!==a?(l=r.jsx(Qu,{label:n,defaultExpanded:o,children:a}),e[7]=s.group.defaultExpanded,e[8]=s.group.label,e[9]=a,e[10]=l):l=e[10],l}case"items":{let n;if(e[11]!==i||e[12]!==s.items){let a;e[14]!==i?(a=l=>r.jsx(Gc,{item:l,onClose:i},l.key),e[14]=i,e[15]=a):a=e[15],n=s.items.map(a),e[11]=i,e[12]=s.items,e[13]=n}else n=e[13];let o;return e[16]!==n?(o=r.jsx(Ur,{className:"pt-0 pr-0 pb-0 pl-0",children:r.jsx(Kr,{children:r.jsx(gs,{className:"gap-1.5",children:n})})}),e[16]=n,e[17]=o):o=e[17],o}}}function u0(t){const e=B.c(12),{sections:s,onClose:i,footer:n,additionalContent:o}=t;let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=r.jsx(S.Suspense,{fallback:r.jsx("div",{className:"h-10 shrink-0"}),children:r.jsx(d0,{})}),e[0]=a):a=e[0];let l;if(e[1]!==i||e[2]!==s){let u;e[4]!==i?(u=(h,f)=>r.jsx(h0,{section:h,onClose:i},f),e[4]=i,e[5]=u):u=e[5],l=s.map(u),e[1]=i,e[2]=s,e[3]=l}else l=e[3];let c;e[6]!==o||e[7]!==l?(c=r.jsxs(xu,{className:"flex flex-col flex-1 px-2 py-2 gap-0",children:[l,o]}),e[6]=o,e[7]=l,e[8]=c):c=e[8];let d;return e[9]!==n||e[10]!==c?(d=r.jsxs("div",{className:"bg-sidebar flex h-full w-full flex-col","data-sidebar":"sidebar",children:[a,c,n]}),e[9]=n,e[10]=c,e[11]=d):d=e[11],d}function tf(t){return t.toLowerCase().trim().replace(/[^a-z0-9\s_-]+/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const f0=Vs({name:Et().min(2,"Organization name is required")});function m0(t){const e=B.c(41),{open:s,onOpenChange:i}=t;let n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n={resolver:Or(f0),defaultValues:{name:""}},e[0]=n):n=e[0];const o=Hi(n);let a;e[1]===Symbol.for("react.memo_cache_sentinel")?(a={mutationFn:g0,onSuccess:p0},e[1]=a):a=e[1];const l=Br(a),c=l.error instanceof Error?l.error.message:l.error?"Failed to create organization.":null;let d;e[2]===Symbol.for("react.memo_cache_sentinel")?(d=r.jsxs(kl,{children:[r.jsx(Nl,{children:"Create a new organization"}),r.jsx(Al,{children:"Set up a new organization to collaborate with others."})]}),e[2]=d):d=e[2];let u;if(e[3]!==l||e[4]!==o){let V;e[6]!==l?(V=w=>l.mutateAsync(w),e[6]=l,e[7]=V):V=e[7],u=o.handleSubmit(V),e[3]=l,e[4]=o,e[5]=u}else u=e[5];let h;e[8]!==o.formState.isSubmitting?(h=V=>{const{field:w}=V;return r.jsxs(Rt,{children:[r.jsx(rs,{children:"Organization Name"}),r.jsx(Tt,{children:r.jsx(bt,{...w,placeholder:"Acme Inc.",disabled:o.formState.isSubmitting})}),r.jsx(hg,{children:"The name of your company or organization"}),w.value&&r.jsxs("div",{className:"text-xs text-muted-foreground mt-1",children:["Organization URL:"," ",r.jsxs("span",{className:"font-mono",children:[typeof window<"u"?globalThis.location.origin:"","/",tf(w.value)]})]}),r.jsx(Dt,{})]})},e[8]=o.formState.isSubmitting,e[9]=h):h=e[9];let f;e[10]!==o.control||e[11]!==h?(f=r.jsx(It,{control:o.control,name:"name",render:h}),e[10]=o.control,e[11]=h,e[12]=f):f=e[12];let m;e[13]!==c?(m=c&&r.jsx("div",{className:"text-destructive text-sm mt-2",children:c}),e[13]=c,e[14]=m):m=e[14];let p;e[15]!==l||e[16]!==o?(p=()=>{l.reset(),o.reset()},e[15]=l,e[16]=o,e[17]=p):p=e[17];let g;e[18]!==o.formState.isSubmitting||e[19]!==p?(g=r.jsx(Cl,{disabled:o.formState.isSubmitting,onClick:p,children:"Cancel"}),e[18]=o.formState.isSubmitting,e[19]=p,e[20]=g):g=e[20];const _=!o.formState.isValid||o.formState.isSubmitting;let v;e[21]!==o.formState.isSubmitting?(v=o.formState.isSubmitting?r.jsxs("span",{className:"flex items-center gap-2",children:[r.jsx(jr,{size:"xs"})," Creating..."]}):"Create Organization",e[21]=o.formState.isSubmitting,e[22]=v):v=e[22];let x;e[23]!==_||e[24]!==v?(x=r.jsx(ne,{type:"submit",variant:"default",disabled:_,children:v}),e[23]=_,e[24]=v,e[25]=x):x=e[25];let b;e[26]!==x||e[27]!==g?(b=r.jsxs(El,{children:[g,x]}),e[26]=x,e[27]=g,e[28]=b):b=e[28];let y;e[29]!==b||e[30]!==u||e[31]!==f||e[32]!==m?(y=r.jsxs("form",{className:"space-y-6",onSubmit:u,autoComplete:"off",children:[f,m,b]}),e[29]=b,e[30]=u,e[31]=f,e[32]=m,e[33]=y):y=e[33];let C;e[34]!==o||e[35]!==y?(C=r.jsxs(jl,{children:[d,r.jsx(Pi,{...o,children:y})]}),e[34]=o,e[35]=y,e[36]=C):C=e[36];let j;return e[37]!==i||e[38]!==s||e[39]!==C?(j=r.jsx(Il,{open:s,onOpenChange:i,children:C}),e[37]=i,e[38]=s,e[39]=C,e[40]=j):j=e[40],j}function p0(t){const{orgSlug:e}=t;window.location.href=`/${e}`}async function g0(t){const e=tf(t.name);if(!e)throw new Error("Organization slug is invalid");const s=await St.organization.create({name:t.name,slug:e});if(s?.error)throw new Error(s.error.message||"Failed to create organization");const i=s?.data?.slug??e;if(!i)throw new Error("Failed to create organization");return{orgSlug:i}}function ga(t){let e=0;for(let i=0;i<t.length;i++)e=t.charCodeAt(i)+((e<<5)-e);const s=Math.abs(e)%360;return{backgroundColor:`hsl(${s} 55% 70%)`,color:`hsl(${s} 55% 20%)`}}function _0(t){const e=B.c(13),{org:s,size:i}=t,n=i===void 0?"sm":i,o=n==="xs"?"size-5":"size-6",a=n==="xs"?"text-[9px]":"text-xs";let l;e[0]!==o?(l=X(o,"shrink-0 rounded-md flex items-center justify-center border border-border/50 overflow-hidden"),e[0]=o,e[1]=l):l=e[1];let c;e[2]!==s.logo||e[3]!==s.name?(c=s.logo?void 0:ga(s.name),e[2]=s.logo,e[3]=s.name,e[4]=c):c=e[4];let d;e[5]!==s.logo||e[6]!==s.name||e[7]!==a?(d=s.logo?r.jsx("img",{src:s.logo,alt:"",className:"size-full object-cover"}):r.jsx("span",{className:X("font-semibold leading-none",a),children:s.name.slice(0,2).toUpperCase()}),e[5]=s.logo,e[6]=s.name,e[7]=a,e[8]=d):d=e[8];let u;return e[9]!==l||e[10]!==c||e[11]!==d?(u=r.jsx("div",{className:l,style:c,children:d}),e[9]=l,e[10]=c,e[11]=d,e[12]=u):u=e[12],u}function ln(t){const e=B.c(22),{item:s,onClose:i}=t;if(s.href){const c=s.external?"_blank":void 0,d=s.external?"noopener noreferrer":void 0;let u;e[0]!==s.icon?(u=r.jsx("span",{className:"shrink-0 text-muted-foreground",children:s.icon}),e[0]=s.icon,e[1]=u):u=e[1];let h;e[2]!==s.label?(h=r.jsx("span",{className:"flex-1",children:s.label}),e[2]=s.label,e[3]=h):h=e[3];let f;return e[4]!==s.href||e[5]!==i||e[6]!==c||e[7]!==d||e[8]!==u||e[9]!==h?(f=r.jsxs("a",{href:s.href,target:c,rel:d,className:"flex items-center gap-2.5 px-3 py-2 rounded-md text-sm text-left w-full transition-colors text-foreground/80 hover:bg-sidebar-accent hover:text-foreground",onClick:i,children:[u,h]}),e[4]=s.href,e[5]=i,e[6]=c,e[7]=d,e[8]=u,e[9]=h,e[10]=f):f=e[10],f}let n;e[11]!==s||e[12]!==i?(n=()=>{s.onClick?.(),i()},e[11]=s,e[12]=i,e[13]=n):n=e[13];let o;e[14]!==s.icon?(o=r.jsx("span",{className:"shrink-0 text-muted-foreground",children:s.icon}),e[14]=s.icon,e[15]=o):o=e[15];let a;e[16]!==s.label?(a=r.jsx("span",{className:"flex-1",children:s.label}),e[16]=s.label,e[17]=a):a=e[17];let l;return e[18]!==n||e[19]!==o||e[20]!==a?(l=r.jsxs("button",{type:"button",onClick:n,className:"flex items-center gap-2.5 px-3 py-2 rounded-md text-sm text-left w-full transition-colors text-foreground/80 hover:bg-sidebar-accent hover:text-foreground",children:[o,a]}),e[18]=n,e[19]=o,e[20]=a,e[21]=l):l=e[21],l}function Yc(t){const e=B.c(16),{sortedOrgs:s,orgParam:i,onSelectOrg:n,onCreateOrg:o}=t;let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=r.jsx("span",{className:"text-sm font-medium text-muted-foreground/60",children:"Your Organizations"}),e[0]=a):a=e[0];let l;e[1]===Symbol.for("react.memo_cache_sentinel")?(l=r.jsx(Qt,{size:16}),e[1]=l):l=e[1];let c;e[2]!==o?(c=r.jsxs("div",{className:"flex items-center justify-between px-4 py-3",children:[a,r.jsx("button",{type:"button",onClick:o,className:"flex items-center justify-center size-7 rounded-md text-muted-foreground hover:bg-accent/50 hover:text-foreground transition-colors",children:l})]}),e[2]=o,e[3]=c):c=e[3];let d;if(e[4]!==n||e[5]!==i||e[6]!==s){let f;e[8]!==n||e[9]!==i?(f=m=>r.jsxs("button",{type:"button",onClick:()=>n(m.slug),className:X("flex items-center gap-3 px-3 py-2.5 rounded-md text-sm text-left w-full transition-colors",m.slug===i?"bg-accent text-accent-foreground":"text-foreground hover:bg-accent/50"),children:[r.jsx(_0,{org:m,size:"sm"}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("p",{className:"text-sm font-medium truncate",children:m.name}),r.jsx("p",{className:"text-xs text-muted-foreground truncate",children:m.slug})]}),m.slug===i&&r.jsx(Jt,{size:14,className:"ml-auto text-muted-foreground shrink-0"})]},m.id),e[8]=n,e[9]=i,e[10]=f):f=e[10],d=s.map(f),e[4]=n,e[5]=i,e[6]=s,e[7]=d}else d=e[7];let u;e[11]!==d?(u=r.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto p-1.5 flex flex-col gap-1",children:d}),e[11]=d,e[12]=u):u=e[12];let h;return e[13]!==c||e[14]!==u?(h=r.jsxs(r.Fragment,{children:[c,u]}),e[13]=c,e[14]=u,e[15]=h):h=e[15],h}function Xc(t){const e=B.c(142),{user:s,userImage:i,menuItems:n,signOutItem:o,themeOptions:a,preferences:l,setPreferences:c,sortedOrgs:d,orgParam:u,onSelectOrg:h,onCreateOrg:f,close:m,isMobile:p}=t;if(p){const K=s?.name??"U";let U;e[0]!==K||e[1]!==i?(U=r.jsx(Vc,{url:i,fallback:K,shape:"circle",size:"sm",className:"shrink-0"}),e[0]=K,e[1]=i,e[2]=U):U=e[2];const te=s?.name??"User";let Y;e[3]!==te?(Y=r.jsx("p",{className:"text-sm font-medium truncate",children:te}),e[3]=te,e[4]=Y):Y=e[4];const J=s?.email;let ie;e[5]!==J?(ie=r.jsx("p",{className:"text-xs text-muted-foreground truncate",children:J}),e[5]=J,e[6]=ie):ie=e[6];let ue;e[7]!==Y||e[8]!==ie?(ue=r.jsxs("div",{className:"flex-1 min-w-0",children:[Y,ie]}),e[7]=Y,e[8]=ie,e[9]=ue):ue=e[9];let de;e[10]!==s?(de=()=>{s?.id&&navigator.clipboard.writeText(s.id).then(y0)},e[10]=s,e[11]=de):de=e[11];let xe;e[12]===Symbol.for("react.memo_cache_sentinel")?(xe=r.jsx(Li,{size:14}),e[12]=xe):xe=e[12];let oe;e[13]!==de?(oe=r.jsx(tt,{asChild:!0,children:r.jsx("button",{type:"button",tabIndex:-1,onClick:de,className:"shrink-0 text-muted-foreground hover:text-foreground transition-colors",children:xe})}),e[13]=de,e[14]=oe):oe=e[14];let he;e[15]===Symbol.for("react.memo_cache_sentinel")?(he=r.jsx(st,{side:"right",children:r.jsx("p",{className:"text-xs",children:"Copy user ID"})}),e[15]=he):he=e[15];let me;e[16]!==oe?(me=r.jsx(Mi,{delayDuration:300,children:r.jsxs(it,{children:[oe,he]})}),e[16]=oe,e[17]=me):me=e[17];let fe;e[18]!==me||e[19]!==U||e[20]!==ue?(fe=r.jsxs("div",{className:"flex items-center gap-3 px-4 py-4 border-b border-border",children:[U,ue,me]}),e[18]=me,e[19]=U,e[20]=ue,e[21]=fe):fe=e[21];let le;e[22]!==f||e[23]!==h||e[24]!==u||e[25]!==d?(le=r.jsx("div",{className:"border-b border-border pb-2",children:r.jsx(Yc,{sortedOrgs:d,orgParam:u,onSelectOrg:h,onCreateOrg:f})}),e[22]=f,e[23]=h,e[24]=u,e[25]=d,e[26]=le):le=e[26];let ve;if(e[27]!==m||e[28]!==n){let Pe;e[30]!==m?(Pe=Kt=>r.jsx(ln,{item:Kt,onClose:m},Kt.key),e[30]=m,e[31]=Pe):Pe=e[31],ve=n.map(Pe),e[27]=m,e[28]=n,e[29]=ve}else ve=e[29];let Ce;e[32]!==m||e[33]!==o?(Ce=r.jsx(ln,{item:o,onClose:m}),e[32]=m,e[33]=o,e[34]=Ce):Ce=e[34];let Te;e[35]!==ve||e[36]!==Ce?(Te=r.jsxs("nav",{className:"flex flex-col px-2 pt-2 pb-2 gap-0.5",children:[ve,Ce]}),e[35]=ve,e[36]=Ce,e[37]=Te):Te=e[37];let Q;e[38]!==le||e[39]!==Te?(Q=r.jsxs("div",{className:"flex-1 min-h-0 overflow-y-auto",children:[le,Te]}),e[38]=le,e[39]=Te,e[40]=Q):Q=e[40];let ae;if(e[41]!==l.theme||e[42]!==c||e[43]!==a){let Pe;e[45]!==l.theme||e[46]!==c?(Pe=Kt=>{const{value:jt,icon:Ae,label:Ie}=Kt;return r.jsx("button",{type:"button","aria-label":Ie,onClick:()=>c(qe=>({...qe,theme:jt})),className:X("size-8 rounded-md flex items-center justify-center transition-colors",l.theme===jt?"bg-sidebar-accent text-foreground":"text-muted-foreground hover:bg-sidebar-accent/50 hover:text-foreground"),children:Ae},jt)},e[45]=l.theme,e[46]=c,e[47]=Pe):Pe=e[47],ae=a.map(Pe),e[41]=l.theme,e[42]=c,e[43]=a,e[44]=ae}else ae=e[44];let Se;e[48]!==ae?(Se=r.jsx("div",{className:"flex items-center gap-0.5",children:ae}),e[48]=ae,e[49]=Se):Se=e[49];const Ne=l.enableSounds?"Disable sounds":"Enable sounds";let Be;e[50]!==c?(Be=()=>c(b0),e[50]=c,e[51]=Be):Be=e[51];const Oe=l.enableSounds?"text-foreground hover:bg-sidebar-accent/50":"text-muted-foreground hover:bg-sidebar-accent/50 hover:text-foreground";let He;e[52]!==Oe?(He=X("size-8 rounded-md flex items-center justify-center transition-colors",Oe),e[52]=Oe,e[53]=He):He=e[53];let Je;e[54]!==l.enableSounds?(Je=l.enableSounds?r.jsx(uc,{size:14}):r.jsx(fc,{size:14}),e[54]=l.enableSounds,e[55]=Je):Je=e[55];let dt;e[56]!==Ne||e[57]!==Be||e[58]!==He||e[59]!==Je?(dt=r.jsx("button",{type:"button","aria-label":Ne,onClick:Be,className:He,children:Je}),e[56]=Ne,e[57]=Be,e[58]=He,e[59]=Je,e[60]=dt):dt=e[60];let ge;e[61]===Symbol.for("react.memo_cache_sentinel")?(ge=r.jsxs("span",{className:"text-xs text-muted-foreground/60",children:["v","2.278.0"]}),e[61]=ge):ge=e[61];let ke;e[62]!==dt?(ke=r.jsxs("div",{className:"flex items-center gap-2",children:[dt,ge]}),e[62]=dt,e[63]=ke):ke=e[63];let Qe;e[64]!==Se||e[65]!==ke?(Qe=r.jsxs("div",{className:"flex items-center justify-between px-3 py-3 border-t border-border/50",children:[Se,ke]}),e[64]=Se,e[65]=ke,e[66]=Qe):Qe=e[66];let Ct;return e[67]!==fe||e[68]!==Q||e[69]!==Qe?(Ct=r.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[fe,Q,Qe]}),e[67]=fe,e[68]=Q,e[69]=Qe,e[70]=Ct):Ct=e[70],Ct}const g=s?.name??"U";let _;e[71]!==g||e[72]!==i?(_=r.jsx(Vc,{url:i,fallback:g,shape:"circle",size:"sm",className:"shrink-0"}),e[71]=g,e[72]=i,e[73]=_):_=e[73];const v=s?.name??"User";let x;e[74]!==v?(x=r.jsx("p",{className:"text-sm font-medium truncate",children:v}),e[74]=v,e[75]=x):x=e[75];const b=s?.email;let y;e[76]!==b?(y=r.jsx("p",{className:"text-xs text-muted-foreground truncate",children:b}),e[76]=b,e[77]=y):y=e[77];let C;e[78]!==x||e[79]!==y?(C=r.jsxs("div",{className:"flex-1 min-w-0",children:[x,y]}),e[78]=x,e[79]=y,e[80]=C):C=e[80];let j;e[81]!==s?(j=()=>{s?.id&&navigator.clipboard.writeText(s.id).then(v0)},e[81]=s,e[82]=j):j=e[82];let V;e[83]===Symbol.for("react.memo_cache_sentinel")?(V=r.jsx(Li,{size:14}),e[83]=V):V=e[83];let w;e[84]!==j?(w=r.jsx(tt,{asChild:!0,children:r.jsx("button",{type:"button",tabIndex:-1,onClick:j,className:"shrink-0 text-muted-foreground hover:text-foreground transition-colors",children:V})}),e[84]=j,e[85]=w):w=e[85];let k;e[86]===Symbol.for("react.memo_cache_sentinel")?(k=r.jsx(st,{side:"right",children:r.jsx("p",{className:"text-xs",children:"Copy user ID"})}),e[86]=k):k=e[86];let T;e[87]!==w?(T=r.jsx(Mi,{delayDuration:300,children:r.jsxs(it,{children:[w,k]})}),e[87]=w,e[88]=T):T=e[88];let I;e[89]!==T||e[90]!==_||e[91]!==C?(I=r.jsxs("div",{className:"flex items-center gap-3 px-4 py-3 mx-1 mt-1",children:[_,C,T]}),e[89]=T,e[90]=_,e[91]=C,e[92]=I):I=e[92];let A;if(e[93]!==m||e[94]!==n){let K;e[96]!==m?(K=U=>r.jsx(ln,{item:U,onClose:m},U.key),e[96]=m,e[97]=K):K=e[97],A=n.map(K),e[93]=m,e[94]=n,e[95]=A}else A=e[95];let N;e[98]!==m||e[99]!==o?(N=r.jsx(ln,{item:o,onClose:m}),e[98]=m,e[99]=o,e[100]=N):N=e[100];let E;e[101]!==A||e[102]!==N?(E=r.jsxs("nav",{className:"flex-1 flex flex-col px-2 pt-1 overflow-y-auto",children:[A,N]}),e[101]=A,e[102]=N,e[103]=E):E=e[103];let R;if(e[104]!==l.theme||e[105]!==c||e[106]!==a){let K;e[108]!==l.theme||e[109]!==c?(K=U=>{const{value:te,icon:Y,label:J}=U;return r.jsx("button",{type:"button","aria-label":J,onClick:()=>c(ie=>({...ie,theme:te})),className:X("size-7 rounded-md flex items-center justify-center transition-colors",l.theme===te?"bg-sidebar-accent text-foreground":"text-muted-foreground hover:bg-sidebar-accent/50 hover:text-foreground"),children:Y},te)},e[108]=l.theme,e[109]=c,e[110]=K):K=e[110],R=a.map(K),e[104]=l.theme,e[105]=c,e[106]=a,e[107]=R}else R=e[107];let M;e[111]!==R?(M=r.jsx("div",{className:"flex items-center gap-0.5",children:R}),e[111]=R,e[112]=M):M=e[112];const L=l.enableSounds?"Disable sounds":"Enable sounds";let D;e[113]!==c?(D=()=>c(x0),e[113]=c,e[114]=D):D=e[114];const P=l.enableSounds?"text-foreground hover:bg-sidebar-accent/50":"text-muted-foreground hover:bg-sidebar-accent/50 hover:text-foreground";let O;e[115]!==P?(O=X("size-7 rounded-md flex items-center justify-center transition-colors",P),e[115]=P,e[116]=O):O=e[116];let z;e[117]!==l.enableSounds?(z=l.enableSounds?r.jsx(uc,{size:14}):r.jsx(fc,{size:14}),e[117]=l.enableSounds,e[118]=z):z=e[118];let $;e[119]!==L||e[120]!==D||e[121]!==O||e[122]!==z?($=r.jsx("button",{type:"button","aria-label":L,onClick:D,className:O,children:z}),e[119]=L,e[120]=D,e[121]=O,e[122]=z,e[123]=$):$=e[123];let W;e[124]===Symbol.for("react.memo_cache_sentinel")?(W=r.jsxs("span",{className:"text-xs text-muted-foreground/60",children:["v","2.278.0"]}),e[124]=W):W=e[124];let F;e[125]!==$?(F=r.jsxs("div",{className:"flex items-center gap-2",children:[$,W]}),e[125]=$,e[126]=F):F=e[126];let G;e[127]!==M||e[128]!==F?(G=r.jsxs("div",{className:"flex items-center justify-between px-2 py-1.5 border-t border-border/50",children:[M,F]}),e[127]=M,e[128]=F,e[129]=G):G=e[129];let q;e[130]!==I||e[131]!==E||e[132]!==G?(q=r.jsxs("div",{className:"w-60 shrink-0 flex flex-col border-r border-border bg-sidebar/75",children:[I,E,G]}),e[130]=I,e[131]=E,e[132]=G,e[133]=q):q=e[133];let H;e[134]!==f||e[135]!==h||e[136]!==u||e[137]!==d?(H=r.jsx("div",{className:"flex-1 flex flex-col min-w-0 min-h-0 overflow-hidden",children:r.jsx(Yc,{sortedOrgs:d,orgParam:u,onSelectOrg:h,onCreateOrg:f})}),e[134]=f,e[135]=h,e[136]=u,e[137]=d,e[138]=H):H=e[138];let ee;return e[139]!==q||e[140]!==H?(ee=r.jsxs("div",{className:"flex min-h-[380px] w-full overflow-hidden",children:[q,H]}),e[139]=q,e[140]=H,e[141]=ee):ee=e[141],ee}function x0(t){return{...t,enableSounds:!t.enableSounds}}function v0(){pe.success("User ID copied")}function b0(t){return{...t,enableSounds:!t.enableSounds}}function y0(){pe.success("User ID copied")}function sf(){const t=B.c(50),{data:e}=St.useSession(),{data:s}=St.useListOrganizations(),i=Ke();let n;t[0]===Symbol.for("react.memo_cache_sentinel")?(n={from:"/shell/$org",shouldThrow:!1},t[0]=n):n=t[0];const a=rp(n)?.params.org,[l,c]=Wi(),d=Rs(),[u,h]=S.useState(!1),[f,m]=S.useState(!1),p=e?.user,g=p?.image;let _;if(t[1]!==d||t[2]!==i||t[3]!==u||t[4]!==a||t[5]!==s||t[6]!==l||t[7]!==c||t[8]!==p||t[9]!==g){const b=s?.find(ee=>ee.slug===a);let y;if(t[11]!==a||t[12]!==s){let ee;t[14]!==a?(ee=(K,U)=>K.slug===a?-1:U.slug===a?1:K.name.localeCompare(U.name),t[14]=a,t[15]=ee):ee=t[15],y=[...s??[]].sort(ee),t[11]=a,t[12]=s,t[13]=y}else y=t[13];const C=y;let j;t[16]!==i?(j=ee=>{h(!1),i({to:"/$org",params:{org:ee}})},t[16]=i,t[17]=j):j=t[17];const V=j;let w;t[18]===Symbol.for("react.memo_cache_sentinel")?(w=()=>h(!1),t[18]=w):w=t[18];const k=w;let T;t[19]===Symbol.for("react.memo_cache_sentinel")?(T=r.jsx(Gr,{size:16}),t[19]=T):T=t[19];let I;t[20]!==i||t[21]!==a?(I={key:"preferences",label:"Preferences",icon:T,onClick:()=>{i({to:"/$org/settings/profile",params:{org:a??""}})}},t[20]=i,t[21]=a,t[22]=I):I=t[22];let A;t[23]===Symbol.for("react.memo_cache_sentinel")?(A={key:"terms",label:"Terms of Use",icon:r.jsx(yg,{size:16}),href:"https://www.decocms.com/terms-of-use",external:!0},t[23]=A):A=t[23];let N;t[24]===Symbol.for("react.memo_cache_sentinel")?(N={key:"privacy",label:"Privacy Policy",icon:r.jsx(Sg,{size:16}),href:"https://www.decocms.com/privacy-policy",external:!0},t[24]=N):N=t[24];let E;t[25]===Symbol.for("react.memo_cache_sentinel")?(E={key:"github",label:"decocms/studio",icon:r.jsx(np,{className:"w-4 h-4"}),href:"https://github.com/decocms/studio",external:!0},t[25]=E):E=t[25];let R;t[26]===Symbol.for("react.memo_cache_sentinel")?(R={key:"community",label:"Community",icon:r.jsx(ao,{size:16}),href:"https://decocms.com/discord",external:!0},t[26]=R):R=t[26];let M;t[27]===Symbol.for("react.memo_cache_sentinel")?(M={key:"homepage",label:"Homepage",icon:r.jsx(Zh,{size:16}),href:"https://decocms.com",external:!0},t[27]=M):M=t[27];let L;t[28]!==I?(L=[I,A,N,E,R,M],t[28]=I,t[29]=L):L=t[29];const D=L;let P;t[30]===Symbol.for("react.memo_cache_sentinel")?(P={key:"logout",label:"Sign out",icon:r.jsx(Rg,{size:16}),onClick:w0},t[30]=P):P=t[30];const O=P;let z;t[31]===Symbol.for("react.memo_cache_sentinel")?(z={value:"light",icon:r.jsx(N_,{size:14}),label:"Light theme"},t[31]=z):z=t[31];let $;t[32]===Symbol.for("react.memo_cache_sentinel")?($={value:"dark",icon:r.jsx(A_,{size:14}),label:"Dark theme"},t[32]=$):$=t[32];let W;t[33]===Symbol.for("react.memo_cache_sentinel")?(W=[z,$,{value:"system",icon:r.jsx(E_,{size:14}),label:"System theme"}],t[33]=W):W=t[33];const F=W;let G;t[34]===Symbol.for("react.memo_cache_sentinel")?(G=()=>{h(!1),m(!0)},t[34]=G):G=t[34];let q;t[35]!==V||t[36]!==d||t[37]!==D||t[38]!==a||t[39]!==l||t[40]!==c||t[41]!==C||t[42]!==p||t[43]!==g?(q={user:p,userImage:g,menuItems:D,signOutItem:O,themeOptions:F,preferences:l,setPreferences:c,sortedOrgs:C,orgParam:a,onSelectOrg:V,onCreateOrg:G,close:k,isMobile:d},t[35]=V,t[36]=d,t[37]=D,t[38]=a,t[39]=l,t[40]=c,t[41]=C,t[42]=p,t[43]=g,t[44]=q):q=t[44];const H=q;_=d?r.jsxs(Si,{open:u,onOpenChange:h,direction:"bottom",children:[r.jsxs("button",{type:"button",onClick:()=>h(!0),className:"flex items-center gap-3 w-full px-3 py-2.5 rounded-lg transition-colors text-sm text-sidebar-foreground/70 hover:bg-sidebar-accent hover:text-sidebar-foreground",children:[r.jsx("div",{className:"shrink-0 size-5 rounded-md flex items-center justify-center border border-border/50 overflow-hidden",style:b?.logo?void 0:ga(b?.name??""),children:b?.logo?r.jsx("img",{src:b.logo,alt:"",className:"size-full object-cover"}):r.jsx("span",{className:"font-semibold leading-none text-[8px]",children:(b?.name??"?").slice(0,2).toUpperCase()})}),r.jsx("span",{className:"truncate",children:b?.name??"Account"})]}),r.jsxs(yi,{className:"h-[80dvh] p-0",children:[r.jsx(bi,{className:"sr-only",children:"Account"}),r.jsx(Xc,{...H})]})]}):r.jsxs(li,{open:u,onOpenChange:h,children:[r.jsx(oi,{asChild:!0,children:r.jsx(us,{tooltip:b?.name??"Account",className:"rounded-md",children:r.jsx("div",{className:"shrink-0 size-6 rounded-md flex items-center justify-center border border-border/50 overflow-hidden",style:b?.logo?void 0:ga(b?.name??""),children:b?.logo?r.jsx("img",{src:b.logo,alt:"",className:"size-full object-cover"}):r.jsx("span",{className:"font-semibold leading-none text-[9px]",children:(b?.name??"?").slice(0,2).toUpperCase()})})})}),r.jsx(ai,{side:"right",align:"end",sideOffset:18,collisionPadding:16,className:"w-[520px] p-0 flex max-h-[520px]",onCloseAutoFocus:S0,children:r.jsx(Xc,{...H})})]}),t[1]=d,t[2]=i,t[3]=u,t[4]=a,t[5]=s,t[6]=l,t[7]=c,t[8]=p,t[9]=g,t[10]=_}else _=t[10];let v;t[45]!==f?(v=r.jsx(m0,{open:f,onOpenChange:m}),t[45]=f,t[46]=v):v=t[46];let x;return t[47]!==_||t[48]!==v?(x=r.jsxs(r.Fragment,{children:[_,v]}),t[47]=_,t[48]=v,t[49]=x):x=t[49],x}function S0(t){return t.preventDefault()}function w0(){se("signed_out",{source:"account_popover"}),St.signOut()}function V0({invitation:t}){const[e,s]=S.useState(!1),[i,n]=S.useState(!1),o=Mt(),a=async()=>{s(!0);try{const c=await St.organization.acceptInvitation({invitationId:t.id});if(c.error)pe.error(c.error.message),s(!1);else{const d=await St.organization.setActive({organizationId:t.organizationId});pe.success("Invitation accepted!");const u=d?.data?.slug;window.location.href=u?`/${u}`:"/"}}catch{pe.error("Failed to accept invitation"),s(!1)}},l=async()=>{n(!0);try{const c=await St.organization.rejectInvitation({invitationId:t.id});c.error?(pe.error(c.error.message),n(!1)):(pe.success("Invitation declined"),o.invalidateQueries())}catch{pe.error("Failed to decline invitation"),n(!1)}};return r.jsxs("div",{className:"flex items-center gap-3 px-5 py-4 border-b border-border last:border-0 hover:bg-muted/25 transition-colors",children:[r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("p",{className:"text-xs text-muted-foreground",children:"You've been invited to join"}),r.jsx("p",{className:"text-sm font-medium truncate",children:t.organizationName??"Unknown organization"})]}),r.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[r.jsx(ne,{size:"icon",variant:"ghost",className:"size-7 text-green-600 hover:text-green-700 hover:bg-green-50 dark:hover:bg-green-950",onClick:a,disabled:e||i,"aria-label":"Accept invitation",children:r.jsx(Jt,{size:14})}),r.jsx(ne,{size:"icon",variant:"ghost",className:"size-7 text-muted-foreground hover:text-destructive hover:bg-destructive/10",onClick:l,disabled:e||i,"aria-label":"Decline invitation",children:r.jsx(ii,{size:14})})]})]})}function C0(){const t=S.useContext(op),{data:e}=t.hooks.useListUserInvitations();return(e??[]).filter(i=>i.status==="pending"&&new Date(i.expiresAt)>new Date)}class j0 extends S.Component{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(e,s){}render(){return this.state.hasError?null:this.props.children}}function k0(t){return t<=1?"text-destructive":t<=5?"text-amber-500 dark:text-amber-400":"text-foreground/70"}function N0(){const t=B.c(19),e=Ke(),{org:s}=be();let i;t[0]!==s.id?(i={connectionId:Wt,orgId:s.id},t[0]=s.id,t[1]=i):i=t[1];const n=Me(i);let o;t[2]===Symbol.for("react.memo_cache_sentinel")?(o={providerId:"deco"},t[2]=o):o=t[2];let a;t[3]!==n?(a={client:n,toolName:"AI_PROVIDER_CREDITS",toolArguments:o,staleTime:6e4,select:A0},t[3]=n,t[4]=a):a=t[4];const{data:l,isPending:c,isError:d}=wi(a),u=l?.balanceCents!=null?l.balanceCents/100:null;let h;t[5]!==u||t[6]!==d||t[7]!==c?(h=c||d||u==null?"Credits":`Credits: $${u.toFixed(2)}`,t[5]=u,t[6]=d,t[7]=c,t[8]=h):h=t[8];const f=h;let m;t[9]!==u?(m=X(u!=null&&k0(u)),t[9]=u,t[10]=m):m=t[10];let p;t[11]!==e||t[12]!==s.slug?(p=()=>e({to:"/$org/settings/ai-providers",params:{org:s.slug}}),t[11]=e,t[12]=s.slug,t[13]=p):p=t[13];let g;t[14]===Symbol.for("react.memo_cache_sentinel")?(g=r.jsx(ml,{size:24}),t[14]=g):g=t[14];let _;return t[15]!==m||t[16]!==p||t[17]!==f?(_=r.jsx(gs,{children:r.jsx(Zt,{children:r.jsx(us,{tooltip:f,className:m,onClick:p,children:g})})}),t[15]=m,t[16]=p,t[17]=f,t[18]=_):_=t[18],_}function A0(t){return t.structuredContent}function E0(){const t=B.c(1);if(!bl().some(I0))return null;let i;return t[0]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx(N0,{}),t[0]=i):i=t[0],i}function I0(t){return t.providerId==="deco"}function R0(){const t=B.c(3),[e,s]=S.useState(!1);let i;t[0]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx(gs,{children:r.jsx(Zt,{children:r.jsx(us,{tooltip:"Connections",onClick:()=>{se("connections_dialog_opened",{source:"sidebar_footer",mode:"browse"}),s(!0)},children:r.jsx(Tg,{size:24})})})}),t[0]=i):i=t[0];let n;return t[1]!==e?(n=r.jsxs(r.Fragment,{children:[i,r.jsx(Pl,{mode:"browse",open:e,onOpenChange:s,defaultTab:"all"})]}),t[1]=e,t[2]=n):n=t[2],n}function T0(){const t=B.c(11),e=C0();let s;t[0]===Symbol.for("react.memo_cache_sentinel")?(s=r.jsx(mc,{size:24}),t[0]=s):s=t[0];let i;t[1]!==e.length?(i=e.length>0&&r.jsx("span",{className:"absolute top-1 right-1 size-2 rounded-full bg-red-500 pointer-events-none"}),t[1]=e.length,t[2]=i):i=t[2];let n;t[3]!==i?(n=r.jsx(gs,{children:r.jsx(Zt,{children:r.jsx(oi,{asChild:!0,children:r.jsxs(us,{tooltip:"Inbox",className:"relative",children:[s,i]})})})}),t[3]=i,t[4]=n):n=t[4];let o;t[5]===Symbol.for("react.memo_cache_sentinel")?(o=r.jsx("div",{className:"px-4 py-3 border-b border-border shrink-0",children:r.jsx("h3",{className:"text-sm font-medium",children:"Inbox"})}),t[5]=o):o=t[5];let a;t[6]!==e?(a=r.jsxs(ai,{side:"right",align:"start",sideOffset:16,collisionPadding:16,className:"w-[min(400px,calc(100vw-2rem))] p-0 h-[min(650px,calc(100dvh-4rem))] flex flex-col",children:[o,e.length===0?r.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-2 px-6 text-center",children:[r.jsx(mc,{size:24,className:"text-muted-foreground/50"}),r.jsx("p",{className:"text-sm font-medium text-foreground",children:"No invites pending"}),r.jsx("p",{className:"text-xs text-muted-foreground",children:"Organization invitations will appear here"})]}):r.jsx("div",{className:"overflow-y-auto flex-1",children:e.map(D0)})]}),t[6]=e,t[7]=a):a=t[7];let l;return t[8]!==n||t[9]!==a?(l=r.jsxs(li,{children:[n,a]}),t[8]=n,t[9]=a,t[10]=l):l=t[10],l}function D0(t){return r.jsx(V0,{invitation:t},t.id)}function M0(){const t=B.c(6),e=Ke(),{org:s}=be();let i;t[0]!==e||t[1]!==s.slug?(i=()=>e({to:"/$org/settings",params:{org:s.slug}}),t[0]=e,t[1]=s.slug,t[2]=i):i=t[2];let n;t[3]===Symbol.for("react.memo_cache_sentinel")?(n=r.jsx(Gr,{size:24}),t[3]=n):n=t[3];let o;return t[4]!==i?(o=r.jsx(gs,{children:r.jsx(Zt,{children:r.jsx(us,{tooltip:"Settings",onClick:i,children:n})})}),t[4]=i,t[5]=o):o=t[5],o}function P0(){const t=B.c(5);let e,s,i,n;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=r.jsx(j0,{children:r.jsx(S.Suspense,{fallback:null,children:r.jsx(E0,{})})}),s=r.jsx(R0,{}),i=r.jsx(T0,{}),n=r.jsx(M0,{}),t[0]=e,t[1]=s,t[2]=i,t[3]=n):(e=t[0],s=t[1],i=t[2],n=t[3]);let o;return t[4]===Symbol.for("react.memo_cache_sentinel")?(o=r.jsxs(bu,{className:"px-2 pb-3 gap-1",children:[e,s,i,n,r.jsx(gs,{children:r.jsx(Zt,{children:r.jsx(sf,{})})})]}),t[4]=o):o=t[4],o}function L0(){const t=B.c(10),e=Ke(),{org:s}=be(),{setOpenMobile:i}=qr();let n;t[0]!==e||t[1]!==s.slug||t[2]!==i?(n=()=>{e({to:"/$org/settings",params:{org:s.slug}}),i(!1)},t[0]=e,t[1]=s.slug,t[2]=i,t[3]=n):n=t[3];let o;t[4]===Symbol.for("react.memo_cache_sentinel")?(o=r.jsx(Gr,{}),t[4]=o):o=t[4];let a;t[5]!==n?(a=r.jsx(Zt,{children:r.jsx(us,{tooltip:"Settings",onClick:n,children:o})}),t[5]=n,t[6]=a):a=t[6];let l;t[7]===Symbol.for("react.memo_cache_sentinel")?(l=r.jsx(Zt,{children:r.jsx(sf,{})}),t[7]=l):l=t[7];let c;return t[8]!==a?(c=r.jsx(bu,{children:r.jsxs(gs,{children:[a,l]})}),t[8]=a,t[9]=c):c=t[9],c}function B0(){for(var t=arguments.length,e=new Array(t),s=0;s<t;s++)e[s]=arguments[s];return S.useMemo(()=>i=>{e.forEach(n=>n(i))},e)}const uo=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Ki(t){const e=Object.prototype.toString.call(t);return e==="[object Window]"||e==="[object global]"}function Ll(t){return"nodeType"in t}function Ut(t){var e,s;return t?Ki(t)?t:Ll(t)&&(e=(s=t.ownerDocument)==null?void 0:s.defaultView)!=null?e:window:window}function Bl(t){const{Document:e}=Ut(t);return t instanceof e}function Xr(t){return Ki(t)?!1:t instanceof Ut(t).HTMLElement}function rf(t){return t instanceof Ut(t).SVGElement}function qi(t){return t?Ki(t)?t.document:Ll(t)?Bl(t)?t:Xr(t)||rf(t)?t.ownerDocument:document:document:document}const Es=uo?S.useLayoutEffect:S.useEffect;function Ol(t){const e=S.useRef(t);return Es(()=>{e.current=t}),S.useCallback(function(){for(var s=arguments.length,i=new Array(s),n=0;n<s;n++)i[n]=arguments[n];return e.current==null?void 0:e.current(...i)},[])}function O0(){const t=S.useRef(null),e=S.useCallback((i,n)=>{t.current=setInterval(i,n)},[]),s=S.useCallback(()=>{t.current!==null&&(clearInterval(t.current),t.current=null)},[]);return[e,s]}function Er(t,e){e===void 0&&(e=[t]);const s=S.useRef(t);return Es(()=>{s.current!==t&&(s.current=t)},e),s}function Jr(t,e){const s=S.useRef();return S.useMemo(()=>{const i=t(s.current);return s.current=i,i},[...e])}function Hn(t){const e=Ol(t),s=S.useRef(null),i=S.useCallback(n=>{n!==s.current&&e?.(n,s.current),s.current=n},[]);return[s,i]}function _a(t){const e=S.useRef();return S.useEffect(()=>{e.current=t},[t]),e.current}let Ro={};function Qr(t,e){return S.useMemo(()=>{if(e)return e;const s=Ro[t]==null?0:Ro[t]+1;return Ro[t]=s,t+"-"+s},[t,e])}function nf(t){return function(e){for(var s=arguments.length,i=new Array(s>1?s-1:0),n=1;n<s;n++)i[n-1]=arguments[n];return i.reduce((o,a)=>{const l=Object.entries(a);for(const[c,d]of l){const u=o[c];u!=null&&(o[c]=u+t*d)}return o},{...e})}}const Di=nf(1),Ir=nf(-1);function $0(t){return"clientX"in t&&"clientY"in t}function $l(t){if(!t)return!1;const{KeyboardEvent:e}=Ut(t.target);return e&&t instanceof e}function z0(t){if(!t)return!1;const{TouchEvent:e}=Ut(t.target);return e&&t instanceof e}function xa(t){if(z0(t)){if(t.touches&&t.touches.length){const{clientX:e,clientY:s}=t.touches[0];return{x:e,y:s}}else if(t.changedTouches&&t.changedTouches.length){const{clientX:e,clientY:s}=t.changedTouches[0];return{x:e,y:s}}}return $0(t)?{x:t.clientX,y:t.clientY}:null}const Rr=Object.freeze({Translate:{toString(t){if(!t)return;const{x:e,y:s}=t;return"translate3d("+(e?Math.round(e):0)+"px, "+(s?Math.round(s):0)+"px, 0)"}},Scale:{toString(t){if(!t)return;const{scaleX:e,scaleY:s}=t;return"scaleX("+e+") scaleY("+s+")"}},Transform:{toString(t){if(t)return[Rr.Translate.toString(t),Rr.Scale.toString(t)].join(" ")}},Transition:{toString(t){let{property:e,duration:s,easing:i}=t;return e+" "+s+"ms "+i}}}),Jc="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function F0(t){return t.matches(Jc)?t:t.querySelector(Jc)}const H0={display:"none"};function W0(t){let{id:e,value:s}=t;return Ft.createElement("div",{id:e,style:H0},s)}function U0(t){let{id:e,announcement:s,ariaLiveType:i="assertive"}=t;const n={position:"fixed",top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(100%)",whiteSpace:"nowrap"};return Ft.createElement("div",{id:e,style:n,role:"status","aria-live":i,"aria-atomic":!0},s)}function K0(){const[t,e]=S.useState("");return{announce:S.useCallback(i=>{i!=null&&e(i)},[]),announcement:t}}const of=S.createContext(null);function q0(t){const e=S.useContext(of);S.useEffect(()=>{if(!e)throw new Error("useDndMonitor must be used within a children of <DndContext>");return e(t)},[t,e])}function G0(){const[t]=S.useState(()=>new Set),e=S.useCallback(i=>(t.add(i),()=>t.delete(i)),[t]);return[S.useCallback(i=>{let{type:n,event:o}=i;t.forEach(a=>{var l;return(l=a[n])==null?void 0:l.call(a,o)})},[t]),e]}const Y0={draggable:`
259
+ Approach every request with rigor and intellectual honesty. Always surface what is uncertain or debated, not just what is known.`,tb=["Break any topic into key sub-questions and define scope","Synthesize information from multiple angles and sources","Distinguish facts, expert consensus, and contested claims","Identify gaps, contradictions, and emerging patterns","Deliver structured summaries with actionable insights"];function Wc(t){const e=B.c(7),{onRecruit:s,isRecruiting:i}=t;let n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=r.jsx("p",{className:"text-sm text-muted-foreground",children:"Add a Web Researcher agent that conducts thorough, rigorous research on any topic and delivers structured, actionable insights."}),e[0]=n):n=e[0];let o;e[1]===Symbol.for("react.memo_cache_sentinel")?(o=r.jsx("p",{className:"text-sm font-medium text-foreground",children:"Capabilities"}),e[1]=o):o=e[1];let a;e[2]===Symbol.for("react.memo_cache_sentinel")?(a=r.jsxs("div",{className:"space-y-2",children:[o,r.jsx("ul",{className:"space-y-1.5",children:tb.map(sb)})]}),e[2]=a):a=e[2];const l=i?"Setting up...":"Add Web Researcher";let c;return e[3]!==i||e[4]!==s||e[5]!==l?(c=r.jsxs("div",{className:"flex flex-col gap-6",children:[n,a,r.jsx(ne,{onClick:s,disabled:i,className:"w-full cursor-pointer",children:l})]}),e[3]=i,e[4]=s,e[5]=l,e[6]=c):c=e[6],c}function sb(t){return r.jsxs("li",{className:"text-sm text-muted-foreground flex items-start gap-2",children:[r.jsx("span",{className:"text-amber-500 mt-0.5 shrink-0",children:"+"}),t]},t)}function ib({open:t,onOpenChange:e,existingAgent:s}){const i=Rs(),n=lo(),o=yl(),[a,l]=S.useState(!1),c=Os.find(f=>f.id==="ai-research"),d=r.jsx(Ms,{icon:c.icon,name:c.title,size:"sm"}),u=async()=>{if(s){e(!1),n(s.id);return}l(!0);try{const f=await o.create.mutateAsync({title:c.title,description:"Systematic research and information synthesis assistant",icon:c.icon,status:"active",connections:[],metadata:{type:"ai-research",instructions:eb}});se("agent_recruit_confirmed",{template_id:"ai-research",agent_id:f.id}),e(!1),n(f.id)}catch(f){se("agent_recruit_failed",{template_id:"ai-research",error:f instanceof Error?f.message:String(f)}),console.error("Failed to create Researcher agent:",f)}finally{l(!1)}},h=`Add ${c.title}`;return i?r.jsx(Si,{open:t,onOpenChange:e,children:r.jsxs(yi,{className:"h-[70dvh]",children:[r.jsx(so,{className:"px-4 pt-4 pb-4 shrink-0",children:r.jsxs("div",{className:"flex items-center gap-3",children:[d,r.jsx(bi,{className:"text-xl font-semibold",children:h})]})}),r.jsx("div",{className:"flex flex-col flex-1 min-h-0 px-4 pb-8",children:r.jsx(Wc,{onRecruit:u,isRecruiting:a})})]})}):r.jsx(ps,{open:t,onOpenChange:e,children:r.jsxs(ms,{className:"sm:max-w-[500px] p-8",children:[r.jsx(Ds,{className:"mb-4",children:r.jsxs("div",{className:"flex items-center gap-3",children:[d,r.jsx(Ts,{className:"text-xl font-semibold",children:h})]})}),r.jsx(Wc,{onRecruit:u,isRecruiting:a})]})})}function rb(t){try{const e=localStorage.getItem(`mesh:chat:recent-agents:${t}`);return e?JSON.parse(e):[]}catch{return[]}}function tr(t){const e=B.c(21),{agent:s,onSpecialClick:i,tracking:n}=t,{org:o}=be(),a=Ke();let l;e[0]!==s.id||e[1]!==s.title||e[2]!==a||e[3]!==i||e[4]!==o||e[5]!==n.action||e[6]!==n.template_id||e[7]!==n.tile_kind?(l=()=>{if(se("home_agent_tile_clicked",{template_id:n.template_id,agent_id:s.id,agent_title:s.title,tile_kind:n.tile_kind,action:n.action}),i)i();else{const g=crypto.randomUUID();a({to:"/$org/$taskId",params:{org:o.slug,taskId:g},search:{virtualmcpid:s.id}})}},e[0]=s.id,e[1]=s.title,e[2]=a,e[3]=i,e[4]=o,e[5]=n.action,e[6]=n.template_id,e[7]=n.tile_kind,e[8]=l):l=e[8];const c=l;let d;e[9]===Symbol.for("react.memo_cache_sentinel")?(d=X("flex flex-col items-center gap-3 p-2 rounded-lg","transition-colors","cursor-pointer","w-[100px] shrink-0","group"),e[9]=d):d=e[9];const u=`Select agent ${s.title}`;let h;e[10]===Symbol.for("react.memo_cache_sentinel")?(h=r.jsx(ao,{size:24}),e[10]=h):h=e[10];let f;e[11]!==s.icon||e[12]!==s.title?(f=r.jsx(Ms,{icon:s.icon,name:s.title,size:"md",fallbackIcon:h,className:"transition-transform group-hover:scale-110"}),e[11]=s.icon,e[12]=s.title,e[13]=f):f=e[13];let m;e[14]!==s.title?(m=r.jsx("p",{className:"text-xs sm:text-sm text-foreground text-center leading-tight line-clamp-2 break-words w-full",children:s.title}),e[14]=s.title,e[15]=m):m=e[15];let p;return e[16]!==c||e[17]!==u||e[18]!==f||e[19]!==m?(p=r.jsxs("button",{type:"button",onClick:c,className:d,"aria-label":u,children:[f,m]}),e[16]=c,e[17]=u,e[18]=f,e[19]=m,e[20]=p):p=e[20],p}function nb(){const t=B.c(8),e=Ke(),{org:s}=be();let i;t[0]===Symbol.for("react.memo_cache_sentinel")?(i=X("flex flex-col items-center gap-3 p-2 rounded-lg","transition-colors","cursor-pointer","w-[100px] shrink-0","group"),t[0]=i):i=t[0];let n;t[1]!==e||t[2]!==s.slug?(n=()=>{se("home_see_all_agents_clicked"),e({to:"/$org/settings/agents",params:{org:s.slug}})},t[1]=e,t[2]=s.slug,t[3]=n):n=t[3];let o,a;t[4]===Symbol.for("react.memo_cache_sentinel")?(o=r.jsx("div",{className:"size-12 rounded-xl bg-accent flex items-center justify-center shrink-0 transition-transform group-hover:scale-110",children:r.jsx(Vl,{size:20,className:"text-foreground"})}),a=r.jsx("p",{className:"text-xs sm:text-sm text-foreground text-center leading-tight",children:"See all"}),t[4]=o,t[5]=a):(o=t[4],a=t[5]);let l;return t[6]!==n?(l=r.jsxs("button",{type:"button",className:i,"aria-label":"See all agents",onClick:n,children:[o,a]}),t[6]=n,t[7]=l):l=t[7],l}function ob(){const t=B.c(9);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e={navigateOnCreate:!0},t[0]=e):e=t[0];const{createVirtualMCP:s,isCreating:i}=pu(e);let n;t[1]!==s?(n=()=>{se("home_create_agent_clicked"),s()},t[1]=s,t[2]=n):n=t[2];let o;t[3]===Symbol.for("react.memo_cache_sentinel")?(o=X("flex flex-col items-center gap-3 p-2 rounded-lg","transition-colors","cursor-pointer","w-[100px] shrink-0","group","disabled:opacity-50 disabled:cursor-not-allowed"),t[3]=o):o=t[3];let a,l;t[4]===Symbol.for("react.memo_cache_sentinel")?(a=r.jsx("div",{className:"size-12 rounded-xl bg-background border-2 border-dashed border-border flex items-center justify-center shrink-0 transition-transform group-hover:scale-110",children:r.jsx(Qt,{size:20,className:"text-muted-foreground"})}),l=r.jsx("p",{className:"text-xs sm:text-sm text-foreground text-center leading-tight",children:"Create agent"}),t[4]=a,t[5]=l):(a=t[4],l=t[5]);let c;return t[6]!==i||t[7]!==n?(c=r.jsxs("button",{type:"button",onClick:n,disabled:i,className:o,"aria-label":"Create agent",children:[a,l]}),t[6]=i,t[7]=n,t[8]=c):c=t[8],c}function ab(){const t=B.c(95),e=oo(),{locator:s}=be(),[i,n]=S.useState(!1),[o,a]=S.useState(!1),[l,c]=S.useState(!1),[d,u]=S.useState(!1),h=lo();let f;t[0]===Symbol.for("react.memo_cache_sentinel")?(f=Os.find(ub),t[0]=f):f=t[0];const m=f;let p;t[1]===Symbol.for("react.memo_cache_sentinel")?(p=Os.find(hb),t[1]=p):p=t[1];const g=p;let _;t[2]===Symbol.for("react.memo_cache_sentinel")?(_=Os.find(db),t[2]=_):_=t[2];const v=_;let x;t[3]===Symbol.for("react.memo_cache_sentinel")?(x=Os.find(cb),t[3]=x):x=t[3];const b=x;let y,C,j,V,w,k,T,I,A,N,E;if(t[4]!==s||t[5]!==h||t[6]!==e){const F=rb(s),G=e.filter(lb).sort((Q,ae)=>{const Se=F.indexOf(Q.id),Ne=F.indexOf(ae.id);return Se!==-1&&Ne!==-1?Se-Ne:Se!==-1?-1:Ne!==-1?1:new Date(ae.updated_at).getTime()-new Date(Q.updated_at).getTime()}).slice(0,4);let q;if(t[18]!==e){let Q;t[20]===Symbol.for("react.memo_cache_sentinel")?(Q=ae=>ae.id!==null&&(ae.metadata?.type===g.id||ae.title===g.title),t[20]=Q):Q=t[20],q=e.find(Q),t[18]=e,t[19]=q}else q=t[19];j=q;let H;if(t[21]!==e){let Q;t[23]===Symbol.for("react.memo_cache_sentinel")?(Q=ae=>ae.id!==null&&(ae.metadata?.type===v.id||ae.title===v.title),t[23]=Q):Q=t[23],H=e.find(Q),t[21]=e,t[22]=H}else H=t[22];y=H;let ee;if(t[24]!==e){let Q;t[26]===Symbol.for("react.memo_cache_sentinel")?(Q=ae=>ae.id!==null&&(ae.metadata?.type===b.id||ae.title===b.title),t[26]=Q):Q=t[26],ee=e.find(Q),t[24]=e,t[25]=ee}else ee=t[25];C=ee,V=G.length>0,w="w-full max-md:overflow-x-auto max-md:[scrollbar-width:none] max-md:[&::-webkit-scrollbar]:hidden",k="flex flex-wrap justify-center gap-1.5 max-md:flex-nowrap max-md:justify-start md:max-h-52 md:overflow-hidden",t[27]===Symbol.for("react.memo_cache_sentinel")?(T=r.jsx(tr,{agent:m,onSpecialClick:()=>n(!0),tracking:{template_id:m.id,tile_kind:"template",action:"open_modal"}},m.id),t[27]=T):T=t[27];const K=j??g;let U;t[28]!==j||t[29]!==h?(U=j?()=>h(j.id):()=>a(!0),t[28]=j,t[29]=h,t[30]=U):U=t[30];const te=j?"existing":"template",Y=j?"navigate":"open_modal";let J;t[31]!==te||t[32]!==Y?(J={template_id:g.id,tile_kind:te,action:Y},t[31]=te,t[32]=Y,t[33]=J):J=t[33],t[34]!==K||t[35]!==U||t[36]!==J?(I=r.jsx(tr,{agent:K,onSpecialClick:U,tracking:J},g.id),t[34]=K,t[35]=U,t[36]=J,t[37]=I):I=t[37];const ie=y??v;let ue;t[38]!==y||t[39]!==h?(ue=y?()=>h(y.id):()=>c(!0),t[38]=y,t[39]=h,t[40]=ue):ue=t[40];const de=y?"existing":"template",xe=y?"navigate":"open_modal";let oe;t[41]!==de||t[42]!==xe?(oe={template_id:v.id,tile_kind:de,action:xe},t[41]=de,t[42]=xe,t[43]=oe):oe=t[43],t[44]!==ie||t[45]!==ue||t[46]!==oe?(A=r.jsx(tr,{agent:ie,onSpecialClick:ue,tracking:oe},v.id),t[44]=ie,t[45]=ue,t[46]=oe,t[47]=A):A=t[47];const he=C??b;let me;t[48]!==C||t[49]!==h?(me=C?()=>h(C.id):()=>u(!0),t[48]=C,t[49]=h,t[50]=me):me=t[50];const fe=C?"existing":"template",le=C?"navigate":"open_modal";let ve;t[51]!==fe||t[52]!==le?(ve={template_id:b.id,tile_kind:fe,action:le},t[51]=fe,t[52]=le,t[53]=ve):ve=t[53],t[54]!==he||t[55]!==me||t[56]!==ve?(N=r.jsx(tr,{agent:he,onSpecialClick:me,tracking:ve},b.id),t[54]=he,t[55]=me,t[56]=ve,t[57]=N):N=t[57];let Ce;t[58]!==y?.id||t[59]!==C?.id||t[60]!==j?.id?(Ce=Q=>Q.id!==j?.id&&Q.id!==y?.id&&Q.id!==C?.id,t[58]=y?.id,t[59]=C?.id,t[60]=j?.id,t[61]=Ce):Ce=t[61];let Te;t[62]!==h?(Te=Q=>r.jsx(tr,{agent:Q,onSpecialClick:()=>h(Q.id),tracking:{template_id:null,tile_kind:"recent",action:"navigate"}},Q.id??"default"),t[62]=h,t[63]=Te):Te=t[63],E=G.filter(Ce).map(Te),t[4]=s,t[5]=h,t[6]=e,t[7]=y,t[8]=C,t[9]=j,t[10]=V,t[11]=w,t[12]=k,t[13]=T,t[14]=I,t[15]=A,t[16]=N,t[17]=E}else y=t[7],C=t[8],j=t[9],V=t[10],w=t[11],k=t[12],T=t[13],I=t[14],A=t[15],N=t[16],E=t[17];let R;t[64]===Symbol.for("react.memo_cache_sentinel")?(R=r.jsx(ob,{}),t[64]=R):R=t[64];let M;t[65]!==V?(M=V&&r.jsx(nb,{}),t[65]=V,t[66]=M):M=t[66];let L;t[67]!==M||t[68]!==k||t[69]!==T||t[70]!==I||t[71]!==A||t[72]!==N||t[73]!==E?(L=r.jsxs("div",{className:k,children:[T,I,A,N,E,R,M]}),t[67]=M,t[68]=k,t[69]=T,t[70]=I,t[71]=A,t[72]=N,t[73]=E,t[74]=L):L=t[74];let D;t[75]!==w||t[76]!==L?(D=r.jsx("div",{className:w,children:L}),t[75]=w,t[76]=L,t[77]=D):D=t[77];let P;t[78]!==i?(P=r.jsx(Bn,{open:i,onOpenChange:n}),t[78]=i,t[79]=P):P=t[79];let O;t[80]!==o||t[81]!==j?(O=r.jsx(uu,{open:o,onOpenChange:a,existingAgent:j}),t[80]=o,t[81]=j,t[82]=O):O=t[82];let z;t[83]!==l||t[84]!==y?(z=r.jsx(Zv,{open:l,onOpenChange:c,existingAgent:y}),t[83]=l,t[84]=y,t[85]=z):z=t[85];let $;t[86]!==d||t[87]!==C?($=r.jsx(ib,{open:d,onOpenChange:u,existingAgent:C}),t[86]=d,t[87]=C,t[88]=$):$=t[88];let W;return t[89]!==D||t[90]!==P||t[91]!==O||t[92]!==z||t[93]!==$?(W=r.jsxs(r.Fragment,{children:[D,P,O,z,$]}),t[89]=D,t[90]=P,t[91]=O,t[92]=z,t[93]=$,t[94]=W):W=t[94],W}function lb(t){return t.id!==null&&!Mn(t.id)}function cb(t){return t.id==="ai-research"}function db(t){return t.id==="ai-image"}function hb(t){return t.id==="site-diagnostics"}function ub(t){return t.id==="site-editor"}function fb(){const t=B.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=r.jsx("div",{className:"w-full max-md:overflow-x-auto max-md:[scrollbar-width:none] max-md:[&::-webkit-scrollbar]:hidden",children:r.jsx("div",{className:"flex flex-wrap justify-center gap-1.5 max-md:flex-nowrap max-md:justify-start md:max-h-52 md:overflow-hidden",children:Array.from({length:7}).map(mb)})}),t[0]=e):e=t[0],e}function mb(t,e){return r.jsxs("div",{className:"flex flex-col items-center gap-3 p-2 w-[100px] shrink-0",children:[r.jsx(Bi,{className:"size-12 rounded-xl shrink-0"}),r.jsx(Bi,{className:"h-3 sm:h-4 w-full"})]},e)}function Uc(){const t=B.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=r.jsx(S.Suspense,{fallback:r.jsx(fb,{}),children:r.jsx(ab,{})}),t[0]=e):e=t[0],e}function sr(t){return t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}k`:String(t)}function Kc(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 pb(t){return t?t.replace(/-\d{8}(?:-[a-z0-9]+)*$/i,"").replace(/-/g," "):"—"}function gb(t){const e=B.c(4),{items:s}=t;let i;e[0]!==s?(i=s.map(_b),e[0]=s,e[1]=i):i=e[1];let n;return e[2]!==i?(n=r.jsx("div",{className:"grid grid-cols-2 gap-x-8 gap-y-6",children:i}),e[2]=i,e[3]=n):n=e[3],n}function _b(t){return r.jsxs("div",{className:"flex flex-col gap-1 min-w-0",children:[r.jsx("span",{className:"text-xs text-muted-foreground truncate",children:t.label}),r.jsx("span",{className:"text-sm text-foreground tabular-nums truncate",children:t.value})]},t.label)}function xb(t){const e=B.c(30),{userTokens:s,assistantTokens:i,otherTokens:n}=t,o=s+i+n,a=o>0?s/o*100:0,l=o>0?i/o*100:0,c=o>0?n/o*100:0;let d;e[0]!==a?(d=a>0&&r.jsx("div",{className:"h-full bg-chart-1",style:{width:`${a}%`}}),e[0]=a,e[1]=d):d=e[1];let u;e[2]!==l?(u=l>0&&r.jsx("div",{className:"h-full bg-chart-2",style:{width:`${l}%`}}),e[2]=l,e[3]=u):u=e[3];let h;e[4]!==c?(h=c>0&&r.jsx("div",{className:"h-full bg-muted-foreground/30",style:{width:`${c}%`}}),e[4]=c,e[5]=h):h=e[5];let f;e[6]!==d||e[7]!==u||e[8]!==h?(f=r.jsxs("div",{className:"flex h-2 w-full overflow-hidden rounded-full bg-muted",children:[d,u,h]}),e[6]=d,e[7]=u,e[8]=h,e[9]=f):f=e[9];let m;e[10]===Symbol.for("react.memo_cache_sentinel")?(m=r.jsx("span",{className:"inline-block h-2 w-2 rounded-sm bg-chart-1 shrink-0"}),e[10]=m):m=e[10];let p;e[11]!==a?(p=a.toFixed(1),e[11]=a,e[12]=p):p=e[12];let g;e[13]!==p?(g=r.jsxs("div",{className:"flex items-center gap-1.5",children:[m,r.jsxs("span",{className:"text-xs text-muted-foreground",children:["User ",p,"%"]})]}),e[13]=p,e[14]=g):g=e[14];let _;e[15]===Symbol.for("react.memo_cache_sentinel")?(_=r.jsx("span",{className:"inline-block h-2 w-2 rounded-sm bg-chart-2 shrink-0"}),e[15]=_):_=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=r.jsxs("div",{className:"flex items-center gap-1.5",children:[_,r.jsxs("span",{className:"text-xs text-muted-foreground",children:["Assistant ",v,"%"]})]}),e[18]=v,e[19]=x):x=e[19];let b;e[20]!==c||e[21]!==n?(b=n>0&&r.jsxs("div",{className:"flex items-center gap-1.5",children:[r.jsx("span",{className:"inline-block h-2 w-2 rounded-sm bg-muted-foreground/30 shrink-0"}),r.jsxs("span",{className:"text-xs text-muted-foreground",children:["Other ",c.toFixed(1),"%"]})]}),e[20]=c,e[21]=n,e[22]=b):b=e[22];let y;e[23]!==x||e[24]!==b||e[25]!==g?(y=r.jsxs("div",{className:"flex flex-wrap gap-x-3 gap-y-1",children:[g,x,b]}),e[23]=x,e[24]=b,e[25]=g,e[26]=y):y=e[26];let C;return e[27]!==y||e[28]!==f?(C=r.jsxs("div",{className:"flex flex-col gap-2",children:[f,y]}),e[27]=y,e[28]=f,e[29]=C):C=e[29],C}function vb(t){const e=B.c(19),{part:s}=t,i=s.input?.agent_id,n=ts(i),o=n?.title??"Subtask",a=n?.icon??null,l=s.state==="input-streaming"||s.state==="input-available"||s.state==="output-available"&&s.preliminary===!0,c=s.state==="output-error",d=s.state==="approval-requested";let u;e[0]!==a||e[1]!==o?(u=r.jsx(Ms,{icon:a,name:o,size:"xs",className:"size-6 rounded-md shrink-0"}),e[0]=a,e[1]=o,e[2]=u):u=e[2];const h=c?"text-destructive":"text-foreground";let f;e[3]!==h?(f=X("shrink-0 font-medium",h),e[3]=h,e[4]=f):f=e[4];let m;e[5]!==o||e[6]!==f?(m=r.jsx("span",{className:f,children:o}),e[5]=o,e[6]=f,e[7]=m):m=e[7];let p;e[8]!==s.input?(p=s.input?.prompt&&r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"text-muted-foreground/50",children:"·"}),r.jsx("span",{className:"truncate text-muted-foreground",children:s.input.prompt})]}),e[8]=s.input,e[9]=p):p=e[9];let g;e[10]!==d||e[11]!==c||e[12]!==l?(g=r.jsx("span",{className:"ml-auto shrink-0",children:l?r.jsx(Ee,{size:12,className:"animate-spin text-muted-foreground"}):c?r.jsx(Og,{size:12,className:"text-destructive"}):d?r.jsx(ri,{size:12,className:"text-warning"}):r.jsx(x_,{size:12,className:"text-emerald-500"})}),e[10]=d,e[11]=c,e[12]=l,e[13]=g):g=e[13];let _;return e[14]!==u||e[15]!==m||e[16]!==p||e[17]!==g?(_=r.jsxs("div",{className:"flex items-center gap-2 text-xs min-w-0",children:[u,m,p,g]}),e[14]=u,e[15]=m,e[16]=p,e[17]=g,e[18]=_):_=e[18],_}function bb(t){const e=B.c(58),{onClose:s,back:i,className:n}=t,[o,a]=S.useState(null),{messages:l}=Ui(),{tasks:c,taskId:d}=es(),{selectedModel:u,selectedVirtualMcp:h}=ni();let f,m,p,g,_,v,x,b;if(e[0]!==i||e[1]!==n||e[2]!==l||e[3]!==s||e[4]!==o?.id||e[5]!==u||e[6]!==h?.title||e[7]!==d||e[8]!==c){b=Symbol.for("react.early_return_sentinel");e:{let j;e[17]!==d?(j=J=>J.id===d,e[17]=d,e[18]=j):j=e[18];const V=c.find(j),w=Eh(l),k=[...l].reverse().find(Ab),T=k?.metadata?.usage,I=k?.metadata?.modelLimits?.contextWindow??u?.limits?.contextWindow??null,A=T?.contextTokens??T?.totalTokens??0,N=I&&I>0?(A/I*100).toFixed(1):null,E=l;let R;e[19]!==E?(R=E.filter(Nb).reduce(kb,0),e[19]=E,e[20]=R):R=e[20];const M=R,L=l;let D;e[21]!==L?(D=L.filter(jb).reduce(Cb,0),e[21]=L,e[22]=D):D=e[22];const P=D,O=Math.max(0,w.totalTokens-M-P),z=l[0],$=l.at(-1),W=z?.metadata?.created_at??V?.created_at,F=$?.metadata?.created_at??V?.updated_at,G=l.filter(Vb),q=l.flatMap(Sb),H=u?.modelId?pb(u.modelId):"—",ee=h?.title??"Decopilot",K=[{label:"Session",value:V?.title??"New chat"},{label:"Messages",value:G.length},{label:"Agent",value:ee},{label:"Model",value:H},{label:"Context Limit",value:I?sr(I):"—"},{label:"Session Tokens (billed)",value:w.totalTokens>0?sr(w.totalTokens):"0"},{label:"Usage",value:N!==null?`${N}%`:"—"},{label:"Input Tokens",value:w.inputTokens>0?sr(w.inputTokens):"0"},{label:"Output Tokens",value:w.outputTokens>0?sr(w.outputTokens):"0"},{label:"Reasoning Tokens",value:w.reasoningTokens>0?sr(w.reasoningTokens):"0"},{label:"Cost",value:w.cost>0?`$${w.cost<.001?w.cost.toFixed(6):w.cost.toFixed(4)}`:"$0.00"},{label:"Session Created",value:Kc(W)},{label:"Last Activity",value:Kc(F)}];if(!V&&G.length===0){let J;e[23]!==n?(J=X("flex flex-col h-full w-full border-l border-border bg-background",n),e[23]=n,e[24]=J):J=e[24];let ie;e[25]===Symbol.for("react.memo_cache_sentinel")?(ie=r.jsx("span",{className:"text-sm font-medium text-foreground",children:"Context"}),e[25]=ie):ie=e[25];let ue;e[26]!==i?(ue=i?r.jsx(aa,{size:14,className:"text-muted-foreground"}):r.jsx(ii,{size:14,className:"text-muted-foreground"}),e[26]=i,e[27]=ue):ue=e[27];let de;e[28]!==s||e[29]!==ue?(de=r.jsxs("div",{className:"h-11 px-4 flex items-center justify-between shrink-0 border-b border-border/50",children:[ie,r.jsx("button",{type:"button",onClick:s,className:"flex size-6 items-center justify-center rounded hover:bg-accent transition-colors",children:ue})]}),e[28]=s,e[29]=ue,e[30]=de):de=e[30];let xe;e[31]===Symbol.for("react.memo_cache_sentinel")?(xe=r.jsx("div",{className:"flex-1 flex items-center justify-center px-4 text-center",children:r.jsx("p",{className:"text-xs text-muted-foreground",children:"Start a conversation to see context"})}),e[31]=xe):xe=e[31];let oe;e[32]!==J||e[33]!==de?(oe=r.jsxs("div",{className:J,children:[de,xe]}),e[32]=J,e[33]=de,e[34]=oe):oe=e[34],b=oe;break e}e[35]!==n?(v=X("flex flex-col h-full w-full border-l border-border bg-background overflow-y-auto",n),e[35]=n,e[36]=v):v=e[36];let U;e[37]===Symbol.for("react.memo_cache_sentinel")?(U=r.jsx("span",{className:"text-sm font-medium text-foreground",children:"Context"}),e[37]=U):U=e[37];let te;e[38]!==i?(te=i?r.jsx(aa,{size:14}):r.jsx(ii,{size:14}),e[38]=i,e[39]=te):te=e[39],e[40]!==s||e[41]!==te?(x=r.jsxs("div",{className:"flex h-11 shrink-0 items-center justify-between border-b border-border/50 px-4",children:[U,r.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:te})]}),e[40]=s,e[41]=te,e[42]=x):x=e[42],f="flex flex-col gap-8 p-6",m=q.length>0&&r.jsxs("div",{className:"flex flex-col gap-3",children:[r.jsx("span",{className:"text-xs text-muted-foreground",children:"Subtasks"}),r.jsx("div",{className:"flex flex-col gap-1",children:q.map(yb)})]}),p=r.jsx(gb,{items:K});let Y;e[43]===Symbol.for("react.memo_cache_sentinel")?(Y=r.jsx("span",{className:"text-xs text-muted-foreground",children:"Context Breakdown"}),e[43]=Y):Y=e[43],e[44]!==P||e[45]!==O||e[46]!==M?(g=r.jsxs("div",{className:"flex flex-col gap-3",children:[Y,r.jsx(xb,{userTokens:M,assistantTokens:P,otherTokens:O})]}),e[44]=P,e[45]=O,e[46]=M,e[47]=g):g=e[47],_=G.length>0&&r.jsxs("div",{className:"flex flex-col gap-3",children:[r.jsx("span",{className:"text-xs text-muted-foreground",children:"Raw messages"}),r.jsx("div",{className:"flex flex-col gap-1",children:G.map(J=>{const ie=J.metadata?.created_at,ue=o?.id===J.id;return r.jsxs("div",{className:"rounded-md border border-border/50 overflow-hidden",children:[r.jsxs("button",{type:"button",onClick:()=>a(ue?null:J),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:[r.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[r.jsx("span",{className:X("shrink-0 font-medium",J.role==="user"?"text-chart-1":"text-chart-2"),children:J.role}),r.jsx("span",{className:"text-muted-foreground",children:"•"}),r.jsx("span",{className:"truncate text-muted-foreground font-mono",children:J.id})]}),ie&&r.jsx("span",{className:"shrink-0 text-muted-foreground tabular-nums",children:new Date(ie).toLocaleString("en-US",{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit"})})]}),ue&&r.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(J,null,2)})]},J.id)})})]})}e[0]=i,e[1]=n,e[2]=l,e[3]=s,e[4]=o?.id,e[5]=u,e[6]=h?.title,e[7]=d,e[8]=c,e[9]=f,e[10]=m,e[11]=p,e[12]=g,e[13]=_,e[14]=v,e[15]=x,e[16]=b}else f=e[9],m=e[10],p=e[11],g=e[12],_=e[13],v=e[14],x=e[15],b=e[16];if(b!==Symbol.for("react.early_return_sentinel"))return b;let y;e[48]!==f||e[49]!==m||e[50]!==p||e[51]!==g||e[52]!==_?(y=r.jsxs("div",{className:f,children:[m,p,g,_]}),e[48]=f,e[49]=m,e[50]=p,e[51]=g,e[52]=_,e[53]=y):y=e[53];let C;return e[54]!==v||e[55]!==x||e[56]!==y?(C=r.jsxs("div",{className:v,children:[x,y]}),e[54]=v,e[55]=x,e[56]=y,e[57]=C):C=e[57],C}function yb(t,e){return r.jsx(vb,{part:t},e)}function Sb(t){return(t.parts??[]).filter(wb)}function wb(t){return t.type==="tool-subtask"}function Vb(t){return t.role!=="system"}function Cb(t,e){const s=e.metadata?.usage;return t+(s?.outputTokens??0)}function jb(t){return t.role==="assistant"}function kb(t,e){const s=e.metadata?.usage;return t+(s?.inputTokens??0)}function Nb(t){return t.role==="user"}function Ab(t){return t.role==="assistant"&&t.metadata?.usage}function Eb(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 Ib(t){const e=B.c(25),{orgId:s,userId:i,connectionId:n,vmMap:o,owner:a,repo:l,enabled:c}=t,d=c===void 0?!0:c,u=n??null;let h;e[0]!==s||e[1]!==u?(h={connectionId:u,orgId:s},e[0]=s,e[1]=u,e[2]=h):h=e[2];const f=Me(h);let m;e[3]!==a||e[4]!==l?(m={owner:a,repo:l},e[3]=a,e[4]=l,e[5]=m):m=e[5];const p=d&&!!n&&!!a&&!!l;let g;e[6]!==f||e[7]!==m||e[8]!==p?(g={client:f,toolName:"list_branches",toolArguments:m,enabled:p,staleTime:3e4,select:Mb},e[6]=f,e[7]=m,e[8]=p,e[9]=g):g=e[9];const{data:_,isLoading:v,isError:x}=wi(g);let b,y;e[10]!==i||e[11]!==o?(y=new Set(Object.keys(o?.[i]??{})),b=[...y].sort().map(Db),e[10]=i,e[11]=o,e[12]=b,e[13]=y):(b=e[12],y=e[13]);const C=b;let j;if(e[14]!==_||e[15]!==y){const T=Array.isArray(_)?_:_?.branches??[];let I;e[17]!==y?(I=A=>!y.has(A.name),e[17]=y,e[18]=I):I=e[18],j=T.filter(Tb).filter(I).map(Rb),e[14]=_,e[15]=y,e[16]=j}else j=e[16];const V=j,w=Array.isArray(_)?null:_?.default_branch??null;let k;return e[19]!==w||e[20]!==x||e[21]!==v||e[22]!==V||e[23]!==C?(k={yours:C,others:V,defaultBase:w,isLoading:v,isError:x},e[19]=w,e[20]=x,e[21]=v,e[22]=V,e[23]=C,e[24]=k):k=e[24],k}function Rb(t){return{name:t.name,source:"other",author:typeof t.commit?.author=="string"?t.commit.author:t.commit?.author?.login??null}}function Tb(t){return typeof t.name=="string"}function Db(t){return{name:t,source:"yours"}}function Mb(t){return Eb(t)}function Pb(t){const e=B.c(36),{orgId:s,userId:i,connectionId:n,owner:o,repo:a,vmMap:l,value:c,onChange:d}=t,[u,h]=S.useState(!1);let f;e[0]!==n||e[1]!==u||e[2]!==s||e[3]!==o||e[4]!==a||e[5]!==i||e[6]!==l?(f={orgId:s,userId:i,connectionId:n,vmMap:l,owner:o,repo:a,enabled:u},e[0]=n,e[1]=u,e[2]=s,e[3]=o,e[4]=a,e[5]=i,e[6]=l,e[7]=f):f=e[7];const{yours:m,others:p,isLoading:g,isError:_}=Ib(f);let v;e[8]!==d?(v=N=>{d(N),h(!1)},e[8]=d,e[9]=v):v=e[9];const x=v,b=c??"Select branch…";let y;e[10]===Symbol.for("react.memo_cache_sentinel")?(y=r.jsx(gr,{className:"h-3.5 w-3.5"}),e[10]=y):y=e[10];let C;e[11]!==b?(C=r.jsx(oi,{asChild:!0,children:r.jsxs(ne,{variant:"outline",size:"sm",className:"h-7 gap-1.5 px-2 font-mono text-xs",children:[y,r.jsx("span",{className:"max-w-[200px] truncate",children:b})]})}),e[11]=b,e[12]=C):C=e[12];let j;e[13]===Symbol.for("react.memo_cache_sentinel")?(j=r.jsx(c_,{placeholder:"Search branches…"}),e[13]=j):j=e[13];let V;e[14]!==_?(V=_&&r.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[14]=_,e[15]=V):V=e[15];let w;e[16]!==_||e[17]!==g||e[18]!==p.length||e[19]!==m.length?(w=!_&&!g&&m.length===0&&p.length===0&&r.jsx(a_,{children:"No branches found."}),e[16]=_,e[17]=g,e[18]=p.length,e[19]=m.length,e[20]=w):w=e[20];let k;e[21]!==x||e[22]!==m?(k=m.length>0&&r.jsx(yc,{heading:"Your branches",children:m.map(N=>r.jsxs(Sc,{value:N.name,onSelect:()=>x(N.name),children:[r.jsx(gr,{className:"mr-2 h-4 w-4"}),r.jsx("span",{className:"flex-1 truncate",children:N.name})]},N.name))}),e[21]=x,e[22]=m,e[23]=k):k=e[23];let T;e[24]!==p||e[25]!==x?(T=p.length>0&&r.jsxs(r.Fragment,{children:[r.jsx(l_,{}),r.jsx(yc,{heading:"Other branches in repo",children:p.map(N=>r.jsxs(Sc,{value:N.name,onSelect:()=>x(N.name),children:[r.jsx(gr,{className:"mr-2 h-4 w-4"}),r.jsx("span",{className:"flex-1 truncate",children:N.name}),N.author&&r.jsxs("span",{className:"text-xs text-muted-foreground",children:["@",N.author]})]},N.name))})]}),e[24]=p,e[25]=x,e[26]=T):T=e[26];let I;e[27]!==V||e[28]!==w||e[29]!==k||e[30]!==T?(I=r.jsx(ai,{className:"w-[min(420px,calc(100vw-2rem))] p-0",align:"start",children:r.jsxs(d_,{children:[j,r.jsxs(h_,{children:[V,w,k,T]})]})}),e[27]=V,e[28]=w,e[29]=k,e[30]=T,e[31]=I):I=e[31];let A;return e[32]!==u||e[33]!==I||e[34]!==C?(A=r.jsxs(li,{open:u,onOpenChange:h,children:[C,I]}),e[32]=u,e[33]=I,e[34]=C,e[35]=A):A=e[35],A}const Lb=["radial-gradient(ellipse 25% 220% at -5% 120%, rgba(165,149,255,0.35) 0%, transparent 100%)","radial-gradient(ellipse 25% 220% at 105% -20%, rgba(208,236,26,0.32) 0%, transparent 100%)"].join(", "),Bb="/decotexture.svg";function qc(t){const e=B.c(7),{onClick:s}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i={backgroundImage:Lb},e[0]=i):i=e[0];let n,o;e[1]===Symbol.for("react.memo_cache_sentinel")?(n=r.jsx("div",{className:"relative shrink-0 p-1.5 bg-[var(--brand-green-light)] rounded-lg border border-border",children:r.jsx(Ms,{icon:"/logos/deco%20logo.svg",name:"deco.cx",size:"xs",className:"border-0 rounded-none bg-transparent"})}),o=r.jsx("p",{className:"flex-1 relative text-sm font-medium text-foreground leading-none whitespace-nowrap",children:"Import your deco.cx site"}),e[1]=n,e[2]=o):(n=e[1],o=e[2]);let a;e[3]===Symbol.for("react.memo_cache_sentinel")?(a=r.jsx("img",{src:Bb,alt:"","aria-hidden":!0,className:"absolute pointer-events-none",style:{width:"274.5px",height:"272.25px",left:"calc(50% + 145.5px)",top:"calc(50% + 40px)",transform:"translate(-50%, -50%)"}}),e[3]=a):a=e[3];let l;e[4]===Symbol.for("react.memo_cache_sentinel")?(l=r.jsx("div",{className:"relative bg-background flex items-center justify-center size-8 rounded-md shrink-0",children:r.jsx(ro,{size:16,className:"text-foreground transition-transform group-hover:translate-x-0.5"})}),e[4]=l):l=e[4];let c;return e[5]!==s?(c=r.jsxs("button",{type:"button",onClick:s,className:"w-full relative flex items-center gap-4 px-4 py-4 rounded-lg border border-border bg-background overflow-hidden transition-colors text-left cursor-pointer group",style:i,children:[n,o,a,l]}),e[5]=s,e[6]=c):c=e[6],c}function Ob(){const t=B.c(5),{data:e}=St.useSession();let s;t[0]!==e?.user?.email?(s=lt.decoProfile(e?.user?.email),t[0]=e?.user?.email,t[1]=s):s=t[1];const i=!!e?.user?.email;let n;t[2]!==s||t[3]!==i?(n={queryKey:s,queryFn:$b,enabled:i,staleTime:3e5},t[2]=s,t[3]=i,t[4]=n):n=t[4];const{data:o}=Fi(n);return o?.isDecoUser??!1}async function $b(){const t=await fetch("/api/deco-sites/profile");return t.ok?t.json():{isDecoUser:!1}}function zb(t){const e=B.c(56),{onOpenContextPanel:s}=t,{data:i}=St.useSession(),[n,o]=S.useState(!1),a=Ob(),l=Rs(),{hasDecoKey:c,isZeroBalance:d,isInitialFreeCredit:u,balanceDollars:h,hasOnlyDecoProvider:f}=co();let m;e[0]!==i?.user?.name?(m=i?.user?.name?.split(" ")[0]||"there",e[0]=i?.user?.name,e[1]=m):m=e[1];const p=m,g=c&&u&&h!=null,_=c&&d&&f;if(l){let N;e[2]!==h||e[3]!==g?(N=g&&r.jsx("div",{className:"mb-4",children:r.jsx(De.CreditsEyebrow,{balanceDollars:h})}),e[2]=h,e[3]=g,e[4]=N):N=e[4];let E;e[5]!==_?(E=_&&r.jsx("div",{className:"mb-4",children:r.jsx(De.NoCreditsEyebrow,{})}),e[5]=_,e[6]=E):E=e[6];let R;e[7]!==p?(R=r.jsxs("p",{className:"text-3xl font-medium text-foreground text-center max-w-[280px]",children:["What's on your mind, ",p,"?"]}),e[7]=p,e[8]=R):R=e[8];let M;e[9]!==N||e[10]!==E||e[11]!==R?(M=r.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center w-full",children:[N,E,R]}),e[9]=N,e[10]=E,e[11]=R,e[12]=M):M=e[12];let L;e[13]===Symbol.for("react.memo_cache_sentinel")?(L=r.jsx(Uc,{}),e[13]=L):L=e[13];let D;e[14]!==s?(D=r.jsxs("div",{className:"w-full flex flex-col gap-4 pb-4",children:[L,r.jsx(De.Input,{onOpenContextPanel:s,showConnectionsBanner:!0})]}),e[14]=s,e[15]=D):D=e[15];let P;e[16]!==a?(P=a&&r.jsx("div",{className:"w-full",children:r.jsx(qc,{onClick:()=>o(!0)})}),e[16]=a,e[17]=P):P=e[17];let O;e[18]!==M||e[19]!==D||e[20]!==P?(O=r.jsxs("div",{className:"flex-1 relative flex flex-col items-center px-4",children:[M,D,P]}),e[18]=M,e[19]=D,e[20]=P,e[21]=O):O=e[21];let z;e[22]!==n?(z=r.jsx(Bn,{open:n,onOpenChange:o}),e[22]=n,e[23]=z):z=e[23];let $;return e[24]!==z||e[25]!==O?($=r.jsxs(r.Fragment,{children:[O,z]}),e[24]=z,e[25]=O,e[26]=$):$=e[26],$}let v;e[27]!==h||e[28]!==g?(v=g&&r.jsx("div",{className:"mb-4",children:r.jsx(De.CreditsEyebrow,{balanceDollars:h})}),e[27]=h,e[28]=g,e[29]=v):v=e[29];let x;e[30]!==_?(x=_&&r.jsx("div",{className:"mb-4",children:r.jsx(De.NoCreditsEyebrow,{})}),e[30]=_,e[31]=x):x=e[31];let b;e[32]!==p?(b=r.jsxs("p",{className:"text-3xl font-medium text-foreground",children:["What's on your mind, ",p,"?"]}),e[32]=p,e[33]=b):b=e[33];let y;e[34]!==v||e[35]!==x||e[36]!==b?(y=r.jsxs("div",{className:"text-center mb-10",children:[v,x,b]}),e[34]=v,e[35]=x,e[36]=b,e[37]=y):y=e[37];let C;e[38]!==s?(C=r.jsx("div",{className:"w-full",children:r.jsx(De.Input,{onOpenContextPanel:s,showConnectionsBanner:!0})}),e[38]=s,e[39]=C):C=e[39];let j;e[40]!==y||e[41]!==C?(j=r.jsxs("div",{className:"flex flex-col items-center w-full max-w-[672px]",children:[y,C]}),e[40]=y,e[41]=C,e[42]=j):j=e[42];let V;e[43]===Symbol.for("react.memo_cache_sentinel")?(V=r.jsx("div",{className:"w-full mt-10 mx-auto",children:r.jsx(Uc,{})}),e[43]=V):V=e[43];let w;e[44]!==j?(w=r.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center w-full",children:[j,V]}),e[44]=j,e[45]=w):w=e[45];let k;e[46]!==a?(k=a&&r.jsx("div",{className:"absolute bottom-6 left-0 right-0 px-10",children:r.jsx("div",{className:"w-full max-w-[500px] mx-auto",children:r.jsx(qc,{onClick:()=>o(!0)})})}),e[46]=a,e[47]=k):k=e[47];let T;e[48]!==k||e[49]!==w?(T=r.jsxs("div",{className:"flex-1 relative flex flex-col items-center px-10",children:[w,k]}),e[48]=k,e[49]=w,e[50]=T):T=e[50];let I;e[51]!==n?(I=r.jsx(Bn,{open:n,onOpenChange:o}),e[51]=n,e[52]=I):I=e[52];let A;return e[53]!==T||e[54]!==I?(A=r.jsxs(r.Fragment,{children:[T,I]}),e[53]=T,e[54]=I,e[55]=A):A=e[55],A}function Fb(){const t=B.c(26),{org:e}=be(),{selectedVirtualMcp:s}=ni(),{data:i}=St.useSession(),{currentBranch:n,setCurrentTaskBranch:o}=es();let a;t[0]!==e.id?(a=io(e.id),t[0]=e.id,t[1]=a):a=t[1];const c=s??a,d=ts(c.id),u=i?.user?.id??"",h=d?.metadata?.githubRepo??null,f=!!h?.connectionId&&!!u;let m;t[2]===Symbol.for("react.memo_cache_sentinel")?(m=r.jsx(ao,{size:32}),t[2]=m):m=t[2];let p;t[3]!==c.icon||t[4]!==c.title?(p=r.jsx(Ms,{icon:c.icon,name:c.title,size:"lg",fallbackIcon:m,className:"size-10 min-w-10 md:size-[60px]! md:min-w-[60px] rounded-xl md:rounded-[18px]!"}),t[3]=c.icon,t[4]=c.title,t[5]=p):p=t[5];let g;t[6]!==c.title?(g=r.jsx("h3",{className:"text-base md:text-xl font-medium text-foreground",children:c.title}),t[6]=c.title,t[7]=g):g=t[7];const _=c.description??"Ask anything about configuring model providers or using MCP Mesh.";let v;t[8]!==_?(v=r.jsx("div",{className:"text-muted-foreground text-center text-base max-w-md line-clamp-2",children:_}),t[8]=_,t[9]=v):v=t[9];let x;t[10]!==n||t[11]!==d?.metadata?.vmMap||t[12]!==h||t[13]!==e.id||t[14]!==o||t[15]!==f||t[16]!==u?(x=f&&r.jsx("div",{className:"mt-2",children:r.jsx(Pb,{orgId:e.id,userId:u,connectionId:h.connectionId,owner:h.owner,repo:h.name,vmMap:d?.metadata?.vmMap,value:n??void 0,onChange:o})}),t[10]=n,t[11]=d?.metadata?.vmMap,t[12]=h,t[13]=e.id,t[14]=o,t[15]=f,t[16]=u,t[17]=x):x=t[17];let b;t[18]!==p||t[19]!==g||t[20]!==v||t[21]!==x?(b=r.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 md:gap-4 text-center",children:[p,g,v,x]}),t[18]=p,t[19]=g,t[20]=v,t[21]=x,t[22]=b):b=t[22];let y;t[23]===Symbol.for("react.memo_cache_sentinel")?(y=r.jsx("div",{className:"w-full max-w-3xl mx-auto",children:r.jsx(De.IceBreakers,{})}),t[23]=y):y=t[23];let C;return t[24]!==b?(C=r.jsxs("div",{className:"h-full w-full flex flex-col items-center justify-center gap-6 px-4",children:[b,y]}),t[24]=b,t[25]=C):C=t[25],C}function Hb(t){const e=B.c(27),{variant:s}=t,{org:i}=be(),n=bl(),{isChatEmpty:o}=Ui(),[a,l]=S.useState("chat"),c=co();if(n.length===0){let C;return e[0]===Symbol.for("react.memo_cache_sentinel")?(C=r.jsx(De,{className:"animate-in fade-in-0 duration-200",children:r.jsx(De.Main,{className:"flex flex-col items-center",children:r.jsx(De.EmptyState,{children:r.jsx(De.NoAiProviderEmptyState,{})})})}),e[0]=C):C=e[0],C}let d;e[1]!==c.hasDecoKey||e[2]!==c.hasOnlyDecoProvider||e[3]!==c.isLoading||e[4]!==c.isZeroBalance||e[5]!==o||e[6]!==i?(d=c.hasDecoKey&&c.isZeroBalance&&c.hasOnlyDecoProvider&&!c.isLoading&&o&&!Mv(i.id),e[1]=c.hasDecoKey,e[2]=c.hasOnlyDecoProvider,e[3]=c.isLoading,e[4]=c.isZeroBalance,e[5]=o,e[6]=i,e[7]=d):d=e[7];const u=d;let h;e[8]!==u?(h=u&&r.jsx(De.CreditsEmptyState,{}),e[8]=u,e[9]=h):h=e[9];const f=a!=="chat"?"opacity-0 pointer-events-none":"opacity-100";let m;e[10]!==f?(m=X("absolute inset-0 flex flex-col transition-opacity duration-100 ease-out",f),e[10]=f,e[11]=m):m=e[11];let p;e[12]!==o||e[13]!==s?(p=o?s==="home"?r.jsx(zb,{onOpenContextPanel:()=>l("context")}):r.jsxs(r.Fragment,{children:[r.jsx(De.Main,{children:r.jsx(Fb,{})}),r.jsx(De.Footer,{children:r.jsx(De.Input,{onOpenContextPanel:()=>l("context")})})]}):r.jsxs(r.Fragment,{children:[r.jsx(De.Main,{children:r.jsx(De.Messages,{})}),r.jsx(De.Footer,{children:r.jsx(De.Input,{onOpenContextPanel:()=>l("context")})})]}),e[12]=o,e[13]=s,e[14]=p):p=e[14];let g;e[15]!==m||e[16]!==p?(g=r.jsx("div",{className:m,children:p}),e[15]=m,e[16]=p,e[17]=g):g=e[17];const _=a==="context"?"opacity-100":"opacity-0 pointer-events-none";let v;e[18]!==_?(v=X("absolute inset-0 flex flex-col transition-opacity duration-100 ease-out",_),e[18]=_,e[19]=v):v=e[19];let x;e[20]===Symbol.for("react.memo_cache_sentinel")?(x=r.jsx(bb,{back:!0,onClose:()=>l("chat")}),e[20]=x):x=e[20];let b;e[21]!==v?(b=r.jsx("div",{className:v,children:x}),e[21]=v,e[22]=b):b=e[22];let y;return e[23]!==b||e[24]!==h||e[25]!==g?(y=r.jsxs(De,{className:"relative overflow-hidden animate-in fade-in-0 duration-200",children:[h,g,b]}),e[23]=b,e[24]=h,e[25]=g,e[26]=y):y=e[26],y}function qu(t){const e=B.c(4),{variant:s}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx(De.Skeleton,{}),e[0]=i):i=e[0];let n;e[1]===Symbol.for("react.memo_cache_sentinel")?(n=r.jsx(De.Skeleton,{}),e[1]=n):n=e[1];let o;return e[2]!==s?(o=r.jsx(Cs,{fallback:i,children:r.jsx(S.Suspense,{fallback:n,children:r.jsx(Hb,{variant:s})})}),e[2]=s,e[3]=o):o=e[3],o}function Wb(){const t=B.c(6),{org:e,locator:s}=be(),i=Mt();let n;t[0]!==s||t[1]!==i?(n=()=>{i.invalidateQueries({queryKey:lt.tasksPrefix(s)})},t[0]=s,t[1]=i,t[2]=n):n=t[2];let o;t[3]!==e.id||t[4]!==n?(o={orgId:e.id,onTaskStatus:n},t[3]=e.id,t[4]=n,t[5]=o):o=t[5],b_(o)}function Ub(t){const e=B.c(8),{virtualMcpId:s,size:i,showAutomationBadge:n}=t,o=i===void 0?"sm":i;let a;e[0]!==o||e[1]!==s?(a=s?r.jsx(Kb,{virtualMcpId:s,size:o}):r.jsx(zs,{icon:null,name:"?",size:o}),e[0]=o,e[1]=s,e[2]=a):a=e[2];let l;e[3]!==n?(l=n&&r.jsx("span",{"aria-label":"Automation-triggered",className:"absolute -bottom-0.5 -right-0.5 flex size-4 items-center justify-center rounded-full bg-blue-500 border border-blue-600 text-white",children:r.jsx($i,{size:10,className:"text-white"})}),e[3]=n,e[4]=l):l=e[4];let c;return e[5]!==a||e[6]!==l?(c=r.jsxs("div",{className:"relative shrink-0",children:[a,l]}),e[5]=a,e[6]=l,e[7]=c):c=e[7],c}function Kb(t){const e=B.c(6),{virtualMcpId:s,size:i}=t,n=ts(s);if(!n){let l;return e[0]!==i?(l=r.jsx(zs,{icon:null,name:"?",size:i}),e[0]=i,e[1]=l):l=e[1],l}const o=n.icon??null;let a;return e[2]!==n.title||e[3]!==i||e[4]!==o?(a=r.jsx(zs,{icon:o,name:n.title,size:i}),e[2]=n.title,e[3]=i,e[4]=o,e[5]=a):a=e[5],a}function Fs(t){const e=t?.metadata?.githubRepo;return e?.connectionId&&t?.connections?.some(i=>i.connection_id===e.connectionId)?e:null}function qb(t){const e=B.c(42),{task:s,isActive:i,onClick:n,onArchive:o,showAutomationBadge:a}=t,l=zp(s.status),c=l.icon,d=ts(s.virtual_mcp_id);let u;e[0]!==d?(u=Fs(d),e[0]=d,e[1]=u):u=e[1];const h=u,f="button",m=0;let p;e[2]!==n?(p=O=>{O.target===O.currentTarget&&(O.key==="Enter"||O.key===" ")&&(O.preventDefault(),n())},e[2]=n,e[3]=p):p=e[3];const g=i?"bg-accent":"hover:bg-accent/60";let _;e[4]!==g?(_=X("group/row flex items-center gap-3 px-2 py-1.5 rounded-md cursor-pointer transition-colors",g),e[4]=g,e[5]=_):_=e[5];let v;e[6]!==a||e[7]!==s.virtual_mcp_id?(v=r.jsx(Ub,{virtualMcpId:s.virtual_mcp_id,size:"sm",showAutomationBadge:a}),e[6]=a,e[7]=s.virtual_mcp_id,e[8]=v):v=e[8];const x=s.title||"Untitled task";let b;e[9]!==x?(b=r.jsx("div",{className:"text-sm text-foreground truncate",children:x}),e[9]=x,e[10]=b):b=e[10];let y;e[11]!==h||e[12]!==s.branch||e[13]!==s.updated_at?(y=s.updated_at&&r.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground min-w-0",children:[s.branch?r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"truncate font-mono",children:s.branch}),r.jsx("span",{className:"shrink-0",children:"·"})]}):h?r.jsxs(r.Fragment,{children:[r.jsxs("span",{className:"truncate",children:[h.owner,"/",h.name]}),r.jsx("span",{className:"shrink-0",children:"·"})]}):null,r.jsx("span",{className:"shrink-0",children:Fp(new Date(s.updated_at))})]}),e[11]=h,e[12]=s.branch,e[13]=s.updated_at,e[14]=y):y=e[14];let C;e[15]!==y||e[16]!==b?(C=r.jsxs("div",{className:"flex-1 min-w-0",children:[b,y]}),e[15]=y,e[16]=b,e[17]=C):C=e[17];const j="shrink-0 grid [grid-template-areas:'slot'] items-center justify-items-center",V="[grid-area:slot] flex size-7 items-center justify-center group-hover/row:invisible",w=l.label,k=14,T=X(l.iconClassName,s.status==="in_progress"&&"animate-spin");let I;e[18]!==c||e[19]!==T?(I=r.jsx(c,{size:k,className:T}),e[18]=c,e[19]=T,e[20]=I):I=e[20];let A;e[21]!==l||e[22]!==I?(A=r.jsx("span",{className:V,"aria-label":w,children:I}),e[21]=l,e[22]=I,e[23]=A):A=e[23];let N;e[24]!==o?(N=O=>{O.stopPropagation(),o()},e[24]=o,e[25]=N):N=e[25];let E;e[26]===Symbol.for("react.memo_cache_sentinel")?(E=r.jsx(_g,{size:14}),e[26]=E):E=e[26];let R;e[27]!==N?(R=r.jsx(tt,{asChild:!0,children:r.jsx("button",{type:"button","aria-label":"Archive task",onClick:N,className:"[grid-area:slot] invisible group-hover/row:visible flex size-7 items-center justify-center rounded-md text-muted-foreground hover:text-foreground hover:bg-muted",children:E})}),e[27]=N,e[28]=R):R=e[28];let M;e[29]===Symbol.for("react.memo_cache_sentinel")?(M=r.jsx(st,{side:"right",children:"Archive"}),e[29]=M):M=e[29];let L;e[30]!==R?(L=r.jsxs(it,{children:[R,M]}),e[30]=R,e[31]=L):L=e[31];let D;e[32]!==A||e[33]!==L?(D=r.jsxs("div",{className:j,children:[A,L]}),e[32]=A,e[33]=L,e[34]=D):D=e[34];let P;return e[35]!==n||e[36]!==C||e[37]!==D||e[38]!==p||e[39]!==_||e[40]!==v?(P=r.jsxs("div",{role:f,tabIndex:m,onClick:n,onKeyDown:p,className:_,children:[v,C,D]}),e[35]=n,e[36]=C,e[37]=D,e[38]=p,e[39]=_,e[40]=v,e[41]=P):P=e[41],P}const Gu={all:"All tasks",manual:"Chats",automation:"Automation"},Yu={all:"All members",mine:"Mine only"};function Gb(t){const e=B.c(57),{title:s,tasks:i,activeTaskId:n,onSelect:o,onArchive:a,onNew:l,showNewButton:c,showAutomationBadge:d,emptyLabel:u,currentUserId:h}=t,[f,m]=S.useState("all"),[p,g]=S.useState("mine");let _;e[0]!==h||e[1]!==p||e[2]!==i?(_=p==="mine"&&h?i.filter(G=>G.created_by===h):i,e[0]=h,e[1]=p,e[2]=i,e[3]=_):_=e[3];const v=_;let x;e[4]!==f||e[5]!==v?(x=f==="automation"?v.filter(Qb):f==="manual"?v.filter(Jb):v,e[4]=f,e[5]=v,e[6]=x):x=e[6];const b=x;let y;e[7]!==s?(y=r.jsx("span",{children:s}),e[7]=s,e[8]=y):y=e[8];let C;e[9]!==p?(C=r.jsx(ks,{asChild:!0,children:r.jsx("button",{type:"button","aria-label":"Filter by member",className:"flex size-8 items-center justify-center rounded-md hover:bg-muted hover:text-foreground",children:p==="mine"?r.jsx(xg,{size:16}):r.jsx(ao,{size:16})})}),e[9]=p,e[10]=C):C=e[10];let j;e[11]!==p?(j=G=>{const q=G;q!==p&&se("tasks_panel_member_filter_changed",{to_value:q}),g(q)},e[11]=p,e[12]=j):j=e[12];let V;e[13]===Symbol.for("react.memo_cache_sentinel")?(V=Object.keys(Yu),e[13]=V):V=e[13];let w;e[14]===Symbol.for("react.memo_cache_sentinel")?(w=V.map(Xb),e[14]=w):w=e[14];let k;e[15]!==p||e[16]!==j?(k=r.jsx(Ns,{align:"end",children:r.jsx(hc,{value:p,onValueChange:j,children:w})}),e[15]=p,e[16]=j,e[17]=k):k=e[17];let T;e[18]!==C||e[19]!==k?(T=r.jsxs(js,{children:[C,k]}),e[18]=C,e[19]=k,e[20]=T):T=e[20];const I=f!=="all"&&"text-purple-500";let A;e[21]!==I?(A=X("flex size-8 items-center justify-center rounded-md hover:bg-muted hover:text-foreground",I),e[21]=I,e[22]=A):A=e[22];let N;e[23]===Symbol.for("react.memo_cache_sentinel")?(N=r.jsx($g,{size:16}),e[23]=N):N=e[23];let E;e[24]!==A?(E=r.jsx(ks,{asChild:!0,children:r.jsx("button",{type:"button","aria-label":"Filter tasks",className:A,children:N})}),e[24]=A,e[25]=E):E=e[25];let R;e[26]!==f?(R=G=>{const q=G;q!==f&&se("tasks_panel_filter_changed",{to_value:q}),m(q)},e[26]=f,e[27]=R):R=e[27];let M;e[28]===Symbol.for("react.memo_cache_sentinel")?(M=Object.keys(Gu),e[28]=M):M=e[28];let L;e[29]===Symbol.for("react.memo_cache_sentinel")?(L=M.map(Yb),e[29]=L):L=e[29];let D;e[30]!==f||e[31]!==R?(D=r.jsx(Ns,{align:"end",children:r.jsx(hc,{value:f,onValueChange:R,children:L})}),e[30]=f,e[31]=R,e[32]=D):D=e[32];let P;e[33]!==E||e[34]!==D?(P=r.jsxs(js,{children:[E,D]}),e[33]=E,e[34]=D,e[35]=P):P=e[35];let O;e[36]!==l||e[37]!==c||e[38]!==s?(O=c&&l&&r.jsx("button",{type:"button",onClick:()=>{se("tasks_panel_new_clicked"),l()},"aria-label":`New ${s.toLowerCase()}`,className:"flex size-8 items-center justify-center rounded-md hover:bg-muted hover:text-foreground",children:r.jsx(pl,{size:16})}),e[36]=l,e[37]=c,e[38]=s,e[39]=O):O=e[39];let z;e[40]!==P||e[41]!==O||e[42]!==T?(z=r.jsxs("div",{className:"flex items-center gap-0.5",children:[T,P,O]}),e[40]=P,e[41]=O,e[42]=T,e[43]=z):z=e[43];let $;e[44]!==z||e[45]!==y?($=r.jsxs("div",{className:"pl-2 pr-1.5 h-7 flex items-center justify-between text-xs font-medium text-muted-foreground mb-1",children:[y,z]}),e[44]=z,e[45]=y,e[46]=$):$=e[46];let W;e[47]!==n||e[48]!==u||e[49]!==a||e[50]!==o||e[51]!==d||e[52]!==b?(W=b.length===0&&u?r.jsx("div",{className:"px-2 py-1.5 text-xs text-muted-foreground/70",children:u}):b.map(G=>r.jsx(qb,{task:G,isActive:n===G.id,onClick:()=>{n!==G.id&&se("tasks_panel_task_clicked",{thread_id:G.id,virtual_mcp_id:G.virtual_mcp_id??null,from_automation:!!G.fromAutomation}),o(G)},onArchive:()=>{se("tasks_panel_task_archived",{thread_id:G.id,virtual_mcp_id:G.virtual_mcp_id??null}),a(G)},showAutomationBadge:d||G.fromAutomation},G.id)),e[47]=n,e[48]=u,e[49]=a,e[50]=o,e[51]=d,e[52]=b,e[53]=W):W=e[53];let F;return e[54]!==$||e[55]!==W?(F=r.jsxs("div",{className:"flex flex-col gap-0.5 mt-1",children:[$,W]}),e[54]=$,e[55]=W,e[56]=F):F=e[56],F}function Yb(t){return r.jsx(Oh,{value:t,children:Gu[t]},t)}function Xb(t){return r.jsx(Oh,{value:t,children:Yu[t]},t)}function Jb(t){return!t.fromAutomation}function Qb(t){return t.fromAutomation}function Zb(){const t=B.c(22);Wb();const{data:e}=St.useSession(),s=e?.user?.id;let i;t[0]===Symbol.for("react.memo_cache_sentinel")?(i={owner:"me",status:"open",hasTrigger:!1},t[0]=i):i=t[0];const{tasks:n}=ia(i);let o;t[1]===Symbol.for("react.memo_cache_sentinel")?(o={owner:"all",status:"open",hasTrigger:!0},t[1]=o):o=t[1];const{tasks:a}=ia(o),{setTaskId:l,createNewTask:c}=zr();let d;t[2]===Symbol.for("react.memo_cache_sentinel")?(d={strict:!1},t[2]=d):d=t[2];const u=$r(d),{locator:h,org:f}=be(),m=Mt();let p;t[3]!==f.id?(p={connectionId:Wt,orgId:f.id},t[3]=f.id,t[4]=p):p=t[4];const g=Me(p),_=u.taskId??null;let v;t[5]!==a||t[6]!==n?(v=[...n,...a.map(t0)].sort(e0),t[5]=a,t[6]=n,t[7]=v):v=t[7];const x=v;let b;t[8]!==g||t[9]!==h||t[10]!==m?(b=async V=>{try{await Ep(g,V.id,{hidden:!0}),m.invalidateQueries({queryKey:lt.tasksPrefix(h)})}catch(w){const T=w;pe.error(`Failed to archive task: ${T.message}`)}},t[8]=g,t[9]=h,t[10]=m,t[11]=b):b=t[11];const y=b;if(x.length===0){let V;return t[12]===Symbol.for("react.memo_cache_sentinel")?(V=r.jsx("div",{className:"h-full flex items-center justify-center p-4",children:r.jsx(Oi,{image:r.jsx(vg,{size:48,className:"text-muted-foreground"}),title:"No tasks yet",description:"Start a conversation to create your first task."})}),t[12]=V):V=t[12],V}let C;t[13]!==l?(C=V=>l(V.id,V.virtual_mcp_id),t[13]=l,t[14]=C):C=t[14];let j;return t[15]!==_||t[16]!==x||t[17]!==c||t[18]!==s||t[19]!==y||t[20]!==C?(j=r.jsx("div",{className:"flex flex-col h-full min-h-0 overflow-y-auto p-2 gap-3",children:r.jsx(Gb,{title:"Tasks",tasks:x,activeTaskId:_,onSelect:C,onArchive:y,onNew:c,showNewButton:!0,currentUserId:s})}),t[15]=_,t[16]=x,t[17]=c,t[18]=s,t[19]=y,t[20]=C,t[21]=j):j=t[21],j}function e0(t,e){return(e.updated_at??"").localeCompare(t.updated_at??"")}function t0(t){return{...t,fromAutomation:!0}}function s0(){const t=B.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=r.jsx("div",{className:"flex flex-col h-full p-2 gap-1.5",children:Array.from({length:6}).map(i0)}),t[0]=e):e=t[0],e}function i0(t,e){return r.jsx("div",{className:"h-10 rounded-md bg-muted/60 animate-pulse"},e)}function Xu(){const t=B.c(2);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=r.jsx(De.Skeleton,{}),t[0]=e):e=t[0];let s;return t[1]===Symbol.for("react.memo_cache_sentinel")?(s=r.jsx(Cs,{fallback:e,children:r.jsx(S.Suspense,{fallback:r.jsx(s0,{}),children:r.jsx(Zb,{})})}),t[1]=s):s=t[1],s}function Ju(){const t=B.c(77),{org:e}=be(),s=Ke(),i=Vh(),{setTasksOpen:n,openTab:o}=zr(),a=e.slug,l=be().project;let c;t[0]===Symbol.for("react.memo_cache_sentinel")?(c={strict:!1},t[0]=c):c=t[0];const d=$r(c);let u;t[1]===Symbol.for("react.memo_cache_sentinel")?(u={strict:!1},t[1]=u):u=t[1];const h=vi(u),f=i.location.pathname;let m;t[2]!==l.enabledPlugins?(m=l.enabledPlugins??[],t[2]=l.enabledPlugins,t[3]=m):m=t[3];const p=m;let g;t[4]!==l.ui?(g=l.ui?.pinnedViews??[],t[4]=l.ui,t[5]=g):g=t[5];const _=g;let v,x,b,y;if(t[6]!==l.id||t[7]!==p||t[8]!==s||t[9]!==a||t[10]!==d.pluginId||t[11]!==d.taskId||t[12]!==h.virtualmcpid){let q;t[17]!==p?(q=ie=>p.includes(ie.pluginId),t[17]=p,t[18]=q):q=t[18];const H=ep.filter(q),ee=h.virtualmcpid??l.id;x=!!h.virtualmcpid;const K=d.taskId??"",U=d.pluginId;let te;t[19]!==U?(te=ie=>U===ie,t[19]=U,t[20]=te):te=t[20],v=te;let Y;t[21]!==K||t[22]!==s||t[23]!==a||t[24]!==ee?(Y=ie=>{const ue=K||crypto.randomUUID();s({to:"/$org/$taskId/$pluginId",params:{org:a,taskId:ue,pluginId:ie},search:de=>({...de,virtualmcpid:ee})})},t[21]=K,t[22]=s,t[23]=a,t[24]=ee,t[25]=Y):Y=t[25],b=Y;let J;t[26]!==v||t[27]!==b?(J=ie=>({key:ie.pluginId,label:ie.label,icon:ie.icon,isActive:v(ie.pluginId),onClick:()=>b(ie.pluginId)}),t[26]=v,t[27]=b,t[28]=J):J=t[28],y=H.map(J),t[6]=l.id,t[7]=p,t[8]=s,t[9]=a,t[10]=d.pluginId,t[11]=d.taskId,t[12]=h.virtualmcpid,t[13]=v,t[14]=x,t[15]=b,t[16]=y}else v=t[13],x=t[14],b=t[15],y=t[16];const C=y;let j;if(t[29]!==p||t[30]!==v||t[31]!==b){let q;t[33]!==p?(q=K=>p.includes(K.pluginId),t[33]=p,t[34]=q):q=t[34];const H=tp.filter(q);let ee;t[35]!==v||t[36]!==b?(ee=K=>({type:"group",group:{id:`${K.pluginId}-${K.id}`,label:K.label,items:K.items.map((U,te)=>({key:`${K.pluginId}-${K.id}-${te}`,label:U.label,icon:U.icon,isActive:v(K.pluginId),onClick:()=>b(K.pluginId)})),defaultExpanded:K.defaultExpanded??!0}}),t[35]=v,t[36]=b,t[37]=ee):ee=t[37],j=H.map(ee),t[29]=p,t[30]=v,t[31]=b,t[32]=j}else j=t[32];const V=j;let w;if(t[38]!==o||t[39]!==_){let q;t[41]!==o?(q=H=>{const ee=Fr(H.icon),K=ee.type==="icon"?Hr(ee.name):null;return{key:`app-${H.connectionId}-${H.toolName}`,label:H.label||H.toolName,icon:K?r.jsx(K,{size:16,className:"text-muted-foreground"}):ee.type==="url"?r.jsx("img",{src:ee.url,alt:"",className:"size-4 rounded"}):r.jsx(gu,{size:16,className:"text-muted-foreground"}),isActive:!1,onClick:()=>o(ra(H.connectionId,H.toolName))}},t[41]=o,t[42]=q):q=t[42],w=_.map(q),t[38]=o,t[39]=_,t[40]=w}else w=t[40];const k=w;let T;t[43]!==k?(T=k.length>0?{type:"group",group:{id:"apps",label:"Apps",items:k,defaultExpanded:!0}}:null,t[43]=k,t[44]=T):T=t[44];const I=T;let A;t[45]===Symbol.for("react.memo_cache_sentinel")?(A=r.jsx(bg,{className:"size-4!"}),t[45]=A):A=t[45];const N=f===`/${a}`||f===`/${a}/`;let E;t[46]!==s||t[47]!==a||t[48]!==n?(E=()=>{n(!1),s({to:"/$org",params:{org:a}})},t[46]=s,t[47]=a,t[48]=n,t[49]=E):E=t[49];let R;t[50]!==E||t[51]!==N?(R={key:"home",label:"Home",icon:A,isActive:N,onClick:E},t[50]=E,t[51]=N,t[52]=R):R=t[52];const M=R;let L;t[53]!==p?(L=p.includes(sp),t[53]=p,t[54]=L):L=t[54];const D=L;let P;t[55]===Symbol.for("react.memo_cache_sentinel")?(P=r.jsx(ip,{className:"size-4!"}),t[55]=P):P=t[55];let O;t[56]!==a||t[57]!==f?(O=f.startsWith(`/${a}/settings/workflows`),t[56]=a,t[57]=f,t[58]=O):O=t[58];let z;t[59]!==s||t[60]!==a?(z=()=>s({to:"/$org/settings/workflows",params:{org:a}}),t[59]=s,t[60]=a,t[61]=z):z=t[61];let $;t[62]!==O||t[63]!==z?($={key:"workflows",label:"Workflows",icon:P,isActive:O,onClick:z},t[62]=O,t[63]=z,t[64]=$):$=t[64];const W=$;let F;if(t[65]!==M||t[66]!==x||t[67]!==D||t[68]!==W){const q=[M];x&&D&&q.push(W),F={type:"items",items:q},t[65]=M,t[66]=x,t[67]=D,t[68]=W,t[69]=F}else F=t[69];let G;if(t[70]!==I||t[71]!==V||t[72]!==C||t[73]!==F){if(G=[F],C.length>0){let q;t[75]!==C?(q={type:"items",items:C},t[75]=C,t[76]=q):q=t[76],G.push(q)}V.length>0&&G.push(...V),I&&G.push(I),t[70]=I,t[71]=V,t[72]=C,t[73]=F,t[74]=G}else G=t[74];return G}function Qu(t){const e=B.c(3),{children:s}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx("div",{className:"flex h-6 items-center",children:r.jsx("div",{className:"h-0.5 w-16 rounded-full bg-sidebar-foreground/15"})}),e[0]=i):i=e[0];let n;return e[1]!==s?(n=r.jsxs(Ur,{className:"pt-0 pr-0 pb-2 pl-0 mt-2",children:[i,r.jsx(Kr,{children:r.jsx(gs,{className:"gap-0.5",children:s})})]}),e[1]=s,e[2]=n):n=e[2],n}function r0(){const t=B.c(7),s=Ch().logo??jh,i=typeof s=="string"?s:s.light,n=typeof s=="string"?s:s.dark;let o;t[0]!==i?(o=r.jsx("img",{src:i,alt:"Logo",className:"size-6 object-contain dark:hidden"}),t[0]=i,t[1]=o):o=t[1];let a;t[2]!==n?(a=r.jsx("img",{src:n,alt:"Logo",className:"size-6 object-contain hidden dark:block"}),t[2]=n,t[3]=a):a=t[3];let l;return t[4]!==o||t[5]!==a?(l=r.jsx(vu,{className:"flex items-center justify-center shrink-0 px-2 pb-0",children:r.jsxs("div",{className:"flex w-full aspect-square items-center justify-center",children:[o,a]})}),t[4]=o,t[5]=a,t[6]=l):l=t[6],l}function Zu(t){const e=B.c(15),{item:s}=t,{isMobile:i,setOpenMobile:n}=qr();let o;e[0]!==i||e[1]!==s||e[2]!==n?(o=()=>{se("nav_item_clicked",{nav_key:s.key,nav_label:s.label,is_active:!!s.isActive,is_mobile:i}),s.onClick?.(),i&&n(!1)},e[0]=i,e[1]=s,e[2]=n,e[3]=o):o=e[3];const a=o,l=s.key,c=s.isActive&&"z-10";let d;e[4]!==c?(d=X(c),e[4]=c,e[5]=d):d=e[5];let u;e[6]!==a||e[7]!==s.icon||e[8]!==s.isActive||e[9]!==s.label?(u=r.jsx(us,{onClick:a,isActive:s.isActive,tooltip:s.label,className:"bg-muted/75",children:s.icon}),e[6]=a,e[7]=s.icon,e[8]=s.isActive,e[9]=s.label,e[10]=u):u=e[10];let h;return e[11]!==s.key||e[12]!==d||e[13]!==u?(h=r.jsx(Zt,{className:d,children:u},l),e[11]=s.key,e[12]=d,e[13]=u,e[14]=h):h=e[14],h}function n0(t){const e=B.c(12),{section:s}=t;switch(s.type){case"divider":{let i;return e[0]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx(_u,{className:"my-2"}),e[0]=i):i=e[0],i}case"spacer":{let i;return e[1]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx("div",{className:"flex-1"}),e[1]=i):i=e[1],i}case"group":{const i=s.group.label,n=s.group.defaultExpanded;let o;e[2]!==s.group.items?(o=s.group.items.map(a0),e[2]=s.group.items,e[3]=o):o=e[3];let a;return e[4]!==s.group.defaultExpanded||e[5]!==s.group.label||e[6]!==o?(a=r.jsx(Qu,{label:i,defaultExpanded:n,children:o}),e[4]=s.group.defaultExpanded,e[5]=s.group.label,e[6]=o,e[7]=a):a=e[7],a}case"items":{let i;e[8]!==s.items?(i=s.items.map(o0),e[8]=s.items,e[9]=i):i=e[9];let n;return e[10]!==i?(n=r.jsx(Ur,{className:"pt-0 pr-0 pb-0 pl-0",children:r.jsx(Kr,{children:r.jsx(gs,{className:"gap-1.5",children:i})})}),e[10]=i,e[11]=n):n=e[11],n}}}function o0(t){return r.jsx(Zu,{item:t},t.key)}function a0(t){return r.jsx(Zu,{item:t},t.key)}function l0(t){const e=B.c(14),{sections:s,header:i,footer:n,additionalContent:o,variant:a,contentClassName:l}=t,c=a===void 0?"sidebar":a;let d;e[0]===Symbol.for("react.memo_cache_sentinel")?(d=r.jsx(S.Suspense,{fallback:r.jsx("div",{className:"h-10 shrink-0"}),children:r.jsx(r0,{})}),e[0]=d):d=e[0];let u;e[1]!==l?(u=X("flex flex-col flex-1 px-2 py-2 gap-0",l),e[1]=l,e[2]=u):u=e[2];let h;e[3]!==s?(h=s.map(c0),e[3]=s,e[4]=h):h=e[4];let f;e[5]!==o||e[6]!==u||e[7]!==h?(f=r.jsxs(xu,{className:u,children:[h,o]}),e[5]=o,e[6]=u,e[7]=h,e[8]=f):f=e[8];let m;return e[9]!==n||e[10]!==i||e[11]!==f||e[12]!==c?(m=r.jsxs(y_,{variant:c,children:[d,i,f,n]}),e[9]=n,e[10]=i,e[11]=f,e[12]=c,e[13]=m):m=e[13],m}function c0(t,e){return r.jsx(n0,{section:t},e)}function ef(t){const e=B.c(2);let s;return e[0]!==t?(s=r.jsx(l0,{...t}),e[0]=t,e[1]=s):s=e[1],s}ef.Skeleton=function(){return r.jsx("div",{className:"flex flex-col gap-0.5",children:Array.from({length:8}).map((e,s)=>r.jsx("div",{className:"w-full h-8",children:r.jsx(Bi,{className:"h-full bg-sidebar-accent rounded-md"})},s))})};function d0(){const t=B.c(7),s=Ch().logo??jh,i=typeof s=="string"?s:s.light,n=typeof s=="string"?s:s.dark;let o;t[0]!==i?(o=r.jsx("img",{src:i,alt:"Logo",className:"size-6 object-contain dark:hidden"}),t[0]=i,t[1]=o):o=t[1];let a;t[2]!==n?(a=r.jsx("img",{src:n,alt:"Logo",className:"size-6 object-contain hidden dark:block"}),t[2]=n,t[3]=a):a=t[3];let l;return t[4]!==o||t[5]!==a?(l=r.jsx(vu,{className:"flex items-center justify-center shrink-0 px-2 pb-0",children:r.jsxs("div",{className:"flex w-full aspect-square items-center justify-center",children:[o,a]})}),t[4]=o,t[5]=a,t[6]=l):l=t[6],l}function Gc(t){const e=B.c(15),{item:s,onClose:i}=t,n=s.isActive&&"z-10";let o;e[0]!==n?(o=X(n),e[0]=n,e[1]=o):o=e[1];let a;e[2]!==s||e[3]!==i?(a=()=>{s.onClick?.(),i()},e[2]=s,e[3]=i,e[4]=a):a=e[4];let l;e[5]!==s.icon?(l=r.jsx("span",{className:"[&>svg]:size-8",children:s.icon}),e[5]=s.icon,e[6]=l):l=e[6];let c;e[7]!==s.isActive||e[8]!==s.label||e[9]!==a||e[10]!==l?(c=r.jsx(us,{onClick:a,isActive:s.isActive,tooltip:s.label,className:"bg-muted/75",children:l}),e[7]=s.isActive,e[8]=s.label,e[9]=a,e[10]=l,e[11]=c):c=e[11];let d;return e[12]!==o||e[13]!==c?(d=r.jsx(Zt,{className:o,children:c}),e[12]=o,e[13]=c,e[14]=d):d=e[14],d}function h0(t){const e=B.c(18),{section:s,onClose:i}=t;switch(s.type){case"divider":{let n;return e[0]===Symbol.for("react.memo_cache_sentinel")?(n=r.jsx(_u,{className:"my-2"}),e[0]=n):n=e[0],n}case"spacer":{let n;return e[1]===Symbol.for("react.memo_cache_sentinel")?(n=r.jsx("div",{className:"flex-1"}),e[1]=n):n=e[1],n}case"group":{const n=s.group.label,o=s.group.defaultExpanded;let a;if(e[2]!==i||e[3]!==s.group.items){let c;e[5]!==i?(c=d=>r.jsx(Gc,{item:d,onClose:i},d.key),e[5]=i,e[6]=c):c=e[6],a=s.group.items.map(c),e[2]=i,e[3]=s.group.items,e[4]=a}else a=e[4];let l;return e[7]!==s.group.defaultExpanded||e[8]!==s.group.label||e[9]!==a?(l=r.jsx(Qu,{label:n,defaultExpanded:o,children:a}),e[7]=s.group.defaultExpanded,e[8]=s.group.label,e[9]=a,e[10]=l):l=e[10],l}case"items":{let n;if(e[11]!==i||e[12]!==s.items){let a;e[14]!==i?(a=l=>r.jsx(Gc,{item:l,onClose:i},l.key),e[14]=i,e[15]=a):a=e[15],n=s.items.map(a),e[11]=i,e[12]=s.items,e[13]=n}else n=e[13];let o;return e[16]!==n?(o=r.jsx(Ur,{className:"pt-0 pr-0 pb-0 pl-0",children:r.jsx(Kr,{children:r.jsx(gs,{className:"gap-1.5",children:n})})}),e[16]=n,e[17]=o):o=e[17],o}}}function u0(t){const e=B.c(12),{sections:s,onClose:i,footer:n,additionalContent:o}=t;let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=r.jsx(S.Suspense,{fallback:r.jsx("div",{className:"h-10 shrink-0"}),children:r.jsx(d0,{})}),e[0]=a):a=e[0];let l;if(e[1]!==i||e[2]!==s){let u;e[4]!==i?(u=(h,f)=>r.jsx(h0,{section:h,onClose:i},f),e[4]=i,e[5]=u):u=e[5],l=s.map(u),e[1]=i,e[2]=s,e[3]=l}else l=e[3];let c;e[6]!==o||e[7]!==l?(c=r.jsxs(xu,{className:"flex flex-col flex-1 px-2 py-2 gap-0",children:[l,o]}),e[6]=o,e[7]=l,e[8]=c):c=e[8];let d;return e[9]!==n||e[10]!==c?(d=r.jsxs("div",{className:"bg-sidebar flex h-full w-full flex-col","data-sidebar":"sidebar",children:[a,c,n]}),e[9]=n,e[10]=c,e[11]=d):d=e[11],d}function tf(t){return t.toLowerCase().trim().replace(/[^a-z0-9\s_-]+/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const f0=Vs({name:Et().min(2,"Organization name is required")});function m0(t){const e=B.c(41),{open:s,onOpenChange:i}=t;let n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n={resolver:Or(f0),defaultValues:{name:""}},e[0]=n):n=e[0];const o=Hi(n);let a;e[1]===Symbol.for("react.memo_cache_sentinel")?(a={mutationFn:g0,onSuccess:p0},e[1]=a):a=e[1];const l=Br(a),c=l.error instanceof Error?l.error.message:l.error?"Failed to create organization.":null;let d;e[2]===Symbol.for("react.memo_cache_sentinel")?(d=r.jsxs(kl,{children:[r.jsx(Nl,{children:"Create a new organization"}),r.jsx(Al,{children:"Set up a new organization to collaborate with others."})]}),e[2]=d):d=e[2];let u;if(e[3]!==l||e[4]!==o){let V;e[6]!==l?(V=w=>l.mutateAsync(w),e[6]=l,e[7]=V):V=e[7],u=o.handleSubmit(V),e[3]=l,e[4]=o,e[5]=u}else u=e[5];let h;e[8]!==o.formState.isSubmitting?(h=V=>{const{field:w}=V;return r.jsxs(Rt,{children:[r.jsx(rs,{children:"Organization Name"}),r.jsx(Tt,{children:r.jsx(bt,{...w,placeholder:"Acme Inc.",disabled:o.formState.isSubmitting})}),r.jsx(hg,{children:"The name of your company or organization"}),w.value&&r.jsxs("div",{className:"text-xs text-muted-foreground mt-1",children:["Organization URL:"," ",r.jsxs("span",{className:"font-mono",children:[typeof window<"u"?globalThis.location.origin:"","/",tf(w.value)]})]}),r.jsx(Dt,{})]})},e[8]=o.formState.isSubmitting,e[9]=h):h=e[9];let f;e[10]!==o.control||e[11]!==h?(f=r.jsx(It,{control:o.control,name:"name",render:h}),e[10]=o.control,e[11]=h,e[12]=f):f=e[12];let m;e[13]!==c?(m=c&&r.jsx("div",{className:"text-destructive text-sm mt-2",children:c}),e[13]=c,e[14]=m):m=e[14];let p;e[15]!==l||e[16]!==o?(p=()=>{l.reset(),o.reset()},e[15]=l,e[16]=o,e[17]=p):p=e[17];let g;e[18]!==o.formState.isSubmitting||e[19]!==p?(g=r.jsx(Cl,{disabled:o.formState.isSubmitting,onClick:p,children:"Cancel"}),e[18]=o.formState.isSubmitting,e[19]=p,e[20]=g):g=e[20];const _=!o.formState.isValid||o.formState.isSubmitting;let v;e[21]!==o.formState.isSubmitting?(v=o.formState.isSubmitting?r.jsxs("span",{className:"flex items-center gap-2",children:[r.jsx(jr,{size:"xs"})," Creating..."]}):"Create Organization",e[21]=o.formState.isSubmitting,e[22]=v):v=e[22];let x;e[23]!==_||e[24]!==v?(x=r.jsx(ne,{type:"submit",variant:"default",disabled:_,children:v}),e[23]=_,e[24]=v,e[25]=x):x=e[25];let b;e[26]!==x||e[27]!==g?(b=r.jsxs(El,{children:[g,x]}),e[26]=x,e[27]=g,e[28]=b):b=e[28];let y;e[29]!==b||e[30]!==u||e[31]!==f||e[32]!==m?(y=r.jsxs("form",{className:"space-y-6",onSubmit:u,autoComplete:"off",children:[f,m,b]}),e[29]=b,e[30]=u,e[31]=f,e[32]=m,e[33]=y):y=e[33];let C;e[34]!==o||e[35]!==y?(C=r.jsxs(jl,{children:[d,r.jsx(Pi,{...o,children:y})]}),e[34]=o,e[35]=y,e[36]=C):C=e[36];let j;return e[37]!==i||e[38]!==s||e[39]!==C?(j=r.jsx(Il,{open:s,onOpenChange:i,children:C}),e[37]=i,e[38]=s,e[39]=C,e[40]=j):j=e[40],j}function p0(t){const{orgSlug:e}=t;window.location.href=`/${e}`}async function g0(t){const e=tf(t.name);if(!e)throw new Error("Organization slug is invalid");const s=await St.organization.create({name:t.name,slug:e});if(s?.error)throw new Error(s.error.message||"Failed to create organization");const i=s?.data?.slug??e;if(!i)throw new Error("Failed to create organization");return{orgSlug:i}}function ga(t){let e=0;for(let i=0;i<t.length;i++)e=t.charCodeAt(i)+((e<<5)-e);const s=Math.abs(e)%360;return{backgroundColor:`hsl(${s} 55% 70%)`,color:`hsl(${s} 55% 20%)`}}function _0(t){const e=B.c(13),{org:s,size:i}=t,n=i===void 0?"sm":i,o=n==="xs"?"size-5":"size-6",a=n==="xs"?"text-[9px]":"text-xs";let l;e[0]!==o?(l=X(o,"shrink-0 rounded-md flex items-center justify-center border border-border/50 overflow-hidden"),e[0]=o,e[1]=l):l=e[1];let c;e[2]!==s.logo||e[3]!==s.name?(c=s.logo?void 0:ga(s.name),e[2]=s.logo,e[3]=s.name,e[4]=c):c=e[4];let d;e[5]!==s.logo||e[6]!==s.name||e[7]!==a?(d=s.logo?r.jsx("img",{src:s.logo,alt:"",className:"size-full object-cover"}):r.jsx("span",{className:X("font-semibold leading-none",a),children:s.name.slice(0,2).toUpperCase()}),e[5]=s.logo,e[6]=s.name,e[7]=a,e[8]=d):d=e[8];let u;return e[9]!==l||e[10]!==c||e[11]!==d?(u=r.jsx("div",{className:l,style:c,children:d}),e[9]=l,e[10]=c,e[11]=d,e[12]=u):u=e[12],u}function ln(t){const e=B.c(22),{item:s,onClose:i}=t;if(s.href){const c=s.external?"_blank":void 0,d=s.external?"noopener noreferrer":void 0;let u;e[0]!==s.icon?(u=r.jsx("span",{className:"shrink-0 text-muted-foreground",children:s.icon}),e[0]=s.icon,e[1]=u):u=e[1];let h;e[2]!==s.label?(h=r.jsx("span",{className:"flex-1",children:s.label}),e[2]=s.label,e[3]=h):h=e[3];let f;return e[4]!==s.href||e[5]!==i||e[6]!==c||e[7]!==d||e[8]!==u||e[9]!==h?(f=r.jsxs("a",{href:s.href,target:c,rel:d,className:"flex items-center gap-2.5 px-3 py-2 rounded-md text-sm text-left w-full transition-colors text-foreground/80 hover:bg-sidebar-accent hover:text-foreground",onClick:i,children:[u,h]}),e[4]=s.href,e[5]=i,e[6]=c,e[7]=d,e[8]=u,e[9]=h,e[10]=f):f=e[10],f}let n;e[11]!==s||e[12]!==i?(n=()=>{s.onClick?.(),i()},e[11]=s,e[12]=i,e[13]=n):n=e[13];let o;e[14]!==s.icon?(o=r.jsx("span",{className:"shrink-0 text-muted-foreground",children:s.icon}),e[14]=s.icon,e[15]=o):o=e[15];let a;e[16]!==s.label?(a=r.jsx("span",{className:"flex-1",children:s.label}),e[16]=s.label,e[17]=a):a=e[17];let l;return e[18]!==n||e[19]!==o||e[20]!==a?(l=r.jsxs("button",{type:"button",onClick:n,className:"flex items-center gap-2.5 px-3 py-2 rounded-md text-sm text-left w-full transition-colors text-foreground/80 hover:bg-sidebar-accent hover:text-foreground",children:[o,a]}),e[18]=n,e[19]=o,e[20]=a,e[21]=l):l=e[21],l}function Yc(t){const e=B.c(16),{sortedOrgs:s,orgParam:i,onSelectOrg:n,onCreateOrg:o}=t;let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=r.jsx("span",{className:"text-sm font-medium text-muted-foreground/60",children:"Your Organizations"}),e[0]=a):a=e[0];let l;e[1]===Symbol.for("react.memo_cache_sentinel")?(l=r.jsx(Qt,{size:16}),e[1]=l):l=e[1];let c;e[2]!==o?(c=r.jsxs("div",{className:"flex items-center justify-between px-4 py-3",children:[a,r.jsx("button",{type:"button",onClick:o,className:"flex items-center justify-center size-7 rounded-md text-muted-foreground hover:bg-accent/50 hover:text-foreground transition-colors",children:l})]}),e[2]=o,e[3]=c):c=e[3];let d;if(e[4]!==n||e[5]!==i||e[6]!==s){let f;e[8]!==n||e[9]!==i?(f=m=>r.jsxs("button",{type:"button",onClick:()=>n(m.slug),className:X("flex items-center gap-3 px-3 py-2.5 rounded-md text-sm text-left w-full transition-colors",m.slug===i?"bg-accent text-accent-foreground":"text-foreground hover:bg-accent/50"),children:[r.jsx(_0,{org:m,size:"sm"}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("p",{className:"text-sm font-medium truncate",children:m.name}),r.jsx("p",{className:"text-xs text-muted-foreground truncate",children:m.slug})]}),m.slug===i&&r.jsx(Jt,{size:14,className:"ml-auto text-muted-foreground shrink-0"})]},m.id),e[8]=n,e[9]=i,e[10]=f):f=e[10],d=s.map(f),e[4]=n,e[5]=i,e[6]=s,e[7]=d}else d=e[7];let u;e[11]!==d?(u=r.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto p-1.5 flex flex-col gap-1",children:d}),e[11]=d,e[12]=u):u=e[12];let h;return e[13]!==c||e[14]!==u?(h=r.jsxs(r.Fragment,{children:[c,u]}),e[13]=c,e[14]=u,e[15]=h):h=e[15],h}function Xc(t){const e=B.c(142),{user:s,userImage:i,menuItems:n,signOutItem:o,themeOptions:a,preferences:l,setPreferences:c,sortedOrgs:d,orgParam:u,onSelectOrg:h,onCreateOrg:f,close:m,isMobile:p}=t;if(p){const K=s?.name??"U";let U;e[0]!==K||e[1]!==i?(U=r.jsx(Vc,{url:i,fallback:K,shape:"circle",size:"sm",className:"shrink-0"}),e[0]=K,e[1]=i,e[2]=U):U=e[2];const te=s?.name??"User";let Y;e[3]!==te?(Y=r.jsx("p",{className:"text-sm font-medium truncate",children:te}),e[3]=te,e[4]=Y):Y=e[4];const J=s?.email;let ie;e[5]!==J?(ie=r.jsx("p",{className:"text-xs text-muted-foreground truncate",children:J}),e[5]=J,e[6]=ie):ie=e[6];let ue;e[7]!==Y||e[8]!==ie?(ue=r.jsxs("div",{className:"flex-1 min-w-0",children:[Y,ie]}),e[7]=Y,e[8]=ie,e[9]=ue):ue=e[9];let de;e[10]!==s?(de=()=>{s?.id&&navigator.clipboard.writeText(s.id).then(y0)},e[10]=s,e[11]=de):de=e[11];let xe;e[12]===Symbol.for("react.memo_cache_sentinel")?(xe=r.jsx(Li,{size:14}),e[12]=xe):xe=e[12];let oe;e[13]!==de?(oe=r.jsx(tt,{asChild:!0,children:r.jsx("button",{type:"button",tabIndex:-1,onClick:de,className:"shrink-0 text-muted-foreground hover:text-foreground transition-colors",children:xe})}),e[13]=de,e[14]=oe):oe=e[14];let he;e[15]===Symbol.for("react.memo_cache_sentinel")?(he=r.jsx(st,{side:"right",children:r.jsx("p",{className:"text-xs",children:"Copy user ID"})}),e[15]=he):he=e[15];let me;e[16]!==oe?(me=r.jsx(Mi,{delayDuration:300,children:r.jsxs(it,{children:[oe,he]})}),e[16]=oe,e[17]=me):me=e[17];let fe;e[18]!==me||e[19]!==U||e[20]!==ue?(fe=r.jsxs("div",{className:"flex items-center gap-3 px-4 py-4 border-b border-border",children:[U,ue,me]}),e[18]=me,e[19]=U,e[20]=ue,e[21]=fe):fe=e[21];let le;e[22]!==f||e[23]!==h||e[24]!==u||e[25]!==d?(le=r.jsx("div",{className:"border-b border-border pb-2",children:r.jsx(Yc,{sortedOrgs:d,orgParam:u,onSelectOrg:h,onCreateOrg:f})}),e[22]=f,e[23]=h,e[24]=u,e[25]=d,e[26]=le):le=e[26];let ve;if(e[27]!==m||e[28]!==n){let Pe;e[30]!==m?(Pe=Kt=>r.jsx(ln,{item:Kt,onClose:m},Kt.key),e[30]=m,e[31]=Pe):Pe=e[31],ve=n.map(Pe),e[27]=m,e[28]=n,e[29]=ve}else ve=e[29];let Ce;e[32]!==m||e[33]!==o?(Ce=r.jsx(ln,{item:o,onClose:m}),e[32]=m,e[33]=o,e[34]=Ce):Ce=e[34];let Te;e[35]!==ve||e[36]!==Ce?(Te=r.jsxs("nav",{className:"flex flex-col px-2 pt-2 pb-2 gap-0.5",children:[ve,Ce]}),e[35]=ve,e[36]=Ce,e[37]=Te):Te=e[37];let Q;e[38]!==le||e[39]!==Te?(Q=r.jsxs("div",{className:"flex-1 min-h-0 overflow-y-auto",children:[le,Te]}),e[38]=le,e[39]=Te,e[40]=Q):Q=e[40];let ae;if(e[41]!==l.theme||e[42]!==c||e[43]!==a){let Pe;e[45]!==l.theme||e[46]!==c?(Pe=Kt=>{const{value:jt,icon:Ae,label:Ie}=Kt;return r.jsx("button",{type:"button","aria-label":Ie,onClick:()=>c(qe=>({...qe,theme:jt})),className:X("size-8 rounded-md flex items-center justify-center transition-colors",l.theme===jt?"bg-sidebar-accent text-foreground":"text-muted-foreground hover:bg-sidebar-accent/50 hover:text-foreground"),children:Ae},jt)},e[45]=l.theme,e[46]=c,e[47]=Pe):Pe=e[47],ae=a.map(Pe),e[41]=l.theme,e[42]=c,e[43]=a,e[44]=ae}else ae=e[44];let Se;e[48]!==ae?(Se=r.jsx("div",{className:"flex items-center gap-0.5",children:ae}),e[48]=ae,e[49]=Se):Se=e[49];const Ne=l.enableSounds?"Disable sounds":"Enable sounds";let Be;e[50]!==c?(Be=()=>c(b0),e[50]=c,e[51]=Be):Be=e[51];const Oe=l.enableSounds?"text-foreground hover:bg-sidebar-accent/50":"text-muted-foreground hover:bg-sidebar-accent/50 hover:text-foreground";let He;e[52]!==Oe?(He=X("size-8 rounded-md flex items-center justify-center transition-colors",Oe),e[52]=Oe,e[53]=He):He=e[53];let Je;e[54]!==l.enableSounds?(Je=l.enableSounds?r.jsx(uc,{size:14}):r.jsx(fc,{size:14}),e[54]=l.enableSounds,e[55]=Je):Je=e[55];let dt;e[56]!==Ne||e[57]!==Be||e[58]!==He||e[59]!==Je?(dt=r.jsx("button",{type:"button","aria-label":Ne,onClick:Be,className:He,children:Je}),e[56]=Ne,e[57]=Be,e[58]=He,e[59]=Je,e[60]=dt):dt=e[60];let ge;e[61]===Symbol.for("react.memo_cache_sentinel")?(ge=r.jsxs("span",{className:"text-xs text-muted-foreground/60",children:["v","2.278.1"]}),e[61]=ge):ge=e[61];let ke;e[62]!==dt?(ke=r.jsxs("div",{className:"flex items-center gap-2",children:[dt,ge]}),e[62]=dt,e[63]=ke):ke=e[63];let Qe;e[64]!==Se||e[65]!==ke?(Qe=r.jsxs("div",{className:"flex items-center justify-between px-3 py-3 border-t border-border/50",children:[Se,ke]}),e[64]=Se,e[65]=ke,e[66]=Qe):Qe=e[66];let Ct;return e[67]!==fe||e[68]!==Q||e[69]!==Qe?(Ct=r.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[fe,Q,Qe]}),e[67]=fe,e[68]=Q,e[69]=Qe,e[70]=Ct):Ct=e[70],Ct}const g=s?.name??"U";let _;e[71]!==g||e[72]!==i?(_=r.jsx(Vc,{url:i,fallback:g,shape:"circle",size:"sm",className:"shrink-0"}),e[71]=g,e[72]=i,e[73]=_):_=e[73];const v=s?.name??"User";let x;e[74]!==v?(x=r.jsx("p",{className:"text-sm font-medium truncate",children:v}),e[74]=v,e[75]=x):x=e[75];const b=s?.email;let y;e[76]!==b?(y=r.jsx("p",{className:"text-xs text-muted-foreground truncate",children:b}),e[76]=b,e[77]=y):y=e[77];let C;e[78]!==x||e[79]!==y?(C=r.jsxs("div",{className:"flex-1 min-w-0",children:[x,y]}),e[78]=x,e[79]=y,e[80]=C):C=e[80];let j;e[81]!==s?(j=()=>{s?.id&&navigator.clipboard.writeText(s.id).then(v0)},e[81]=s,e[82]=j):j=e[82];let V;e[83]===Symbol.for("react.memo_cache_sentinel")?(V=r.jsx(Li,{size:14}),e[83]=V):V=e[83];let w;e[84]!==j?(w=r.jsx(tt,{asChild:!0,children:r.jsx("button",{type:"button",tabIndex:-1,onClick:j,className:"shrink-0 text-muted-foreground hover:text-foreground transition-colors",children:V})}),e[84]=j,e[85]=w):w=e[85];let k;e[86]===Symbol.for("react.memo_cache_sentinel")?(k=r.jsx(st,{side:"right",children:r.jsx("p",{className:"text-xs",children:"Copy user ID"})}),e[86]=k):k=e[86];let T;e[87]!==w?(T=r.jsx(Mi,{delayDuration:300,children:r.jsxs(it,{children:[w,k]})}),e[87]=w,e[88]=T):T=e[88];let I;e[89]!==T||e[90]!==_||e[91]!==C?(I=r.jsxs("div",{className:"flex items-center gap-3 px-4 py-3 mx-1 mt-1",children:[_,C,T]}),e[89]=T,e[90]=_,e[91]=C,e[92]=I):I=e[92];let A;if(e[93]!==m||e[94]!==n){let K;e[96]!==m?(K=U=>r.jsx(ln,{item:U,onClose:m},U.key),e[96]=m,e[97]=K):K=e[97],A=n.map(K),e[93]=m,e[94]=n,e[95]=A}else A=e[95];let N;e[98]!==m||e[99]!==o?(N=r.jsx(ln,{item:o,onClose:m}),e[98]=m,e[99]=o,e[100]=N):N=e[100];let E;e[101]!==A||e[102]!==N?(E=r.jsxs("nav",{className:"flex-1 flex flex-col px-2 pt-1 overflow-y-auto",children:[A,N]}),e[101]=A,e[102]=N,e[103]=E):E=e[103];let R;if(e[104]!==l.theme||e[105]!==c||e[106]!==a){let K;e[108]!==l.theme||e[109]!==c?(K=U=>{const{value:te,icon:Y,label:J}=U;return r.jsx("button",{type:"button","aria-label":J,onClick:()=>c(ie=>({...ie,theme:te})),className:X("size-7 rounded-md flex items-center justify-center transition-colors",l.theme===te?"bg-sidebar-accent text-foreground":"text-muted-foreground hover:bg-sidebar-accent/50 hover:text-foreground"),children:Y},te)},e[108]=l.theme,e[109]=c,e[110]=K):K=e[110],R=a.map(K),e[104]=l.theme,e[105]=c,e[106]=a,e[107]=R}else R=e[107];let M;e[111]!==R?(M=r.jsx("div",{className:"flex items-center gap-0.5",children:R}),e[111]=R,e[112]=M):M=e[112];const L=l.enableSounds?"Disable sounds":"Enable sounds";let D;e[113]!==c?(D=()=>c(x0),e[113]=c,e[114]=D):D=e[114];const P=l.enableSounds?"text-foreground hover:bg-sidebar-accent/50":"text-muted-foreground hover:bg-sidebar-accent/50 hover:text-foreground";let O;e[115]!==P?(O=X("size-7 rounded-md flex items-center justify-center transition-colors",P),e[115]=P,e[116]=O):O=e[116];let z;e[117]!==l.enableSounds?(z=l.enableSounds?r.jsx(uc,{size:14}):r.jsx(fc,{size:14}),e[117]=l.enableSounds,e[118]=z):z=e[118];let $;e[119]!==L||e[120]!==D||e[121]!==O||e[122]!==z?($=r.jsx("button",{type:"button","aria-label":L,onClick:D,className:O,children:z}),e[119]=L,e[120]=D,e[121]=O,e[122]=z,e[123]=$):$=e[123];let W;e[124]===Symbol.for("react.memo_cache_sentinel")?(W=r.jsxs("span",{className:"text-xs text-muted-foreground/60",children:["v","2.278.1"]}),e[124]=W):W=e[124];let F;e[125]!==$?(F=r.jsxs("div",{className:"flex items-center gap-2",children:[$,W]}),e[125]=$,e[126]=F):F=e[126];let G;e[127]!==M||e[128]!==F?(G=r.jsxs("div",{className:"flex items-center justify-between px-2 py-1.5 border-t border-border/50",children:[M,F]}),e[127]=M,e[128]=F,e[129]=G):G=e[129];let q;e[130]!==I||e[131]!==E||e[132]!==G?(q=r.jsxs("div",{className:"w-60 shrink-0 flex flex-col border-r border-border bg-sidebar/75",children:[I,E,G]}),e[130]=I,e[131]=E,e[132]=G,e[133]=q):q=e[133];let H;e[134]!==f||e[135]!==h||e[136]!==u||e[137]!==d?(H=r.jsx("div",{className:"flex-1 flex flex-col min-w-0 min-h-0 overflow-hidden",children:r.jsx(Yc,{sortedOrgs:d,orgParam:u,onSelectOrg:h,onCreateOrg:f})}),e[134]=f,e[135]=h,e[136]=u,e[137]=d,e[138]=H):H=e[138];let ee;return e[139]!==q||e[140]!==H?(ee=r.jsxs("div",{className:"flex min-h-[380px] w-full overflow-hidden",children:[q,H]}),e[139]=q,e[140]=H,e[141]=ee):ee=e[141],ee}function x0(t){return{...t,enableSounds:!t.enableSounds}}function v0(){pe.success("User ID copied")}function b0(t){return{...t,enableSounds:!t.enableSounds}}function y0(){pe.success("User ID copied")}function sf(){const t=B.c(50),{data:e}=St.useSession(),{data:s}=St.useListOrganizations(),i=Ke();let n;t[0]===Symbol.for("react.memo_cache_sentinel")?(n={from:"/shell/$org",shouldThrow:!1},t[0]=n):n=t[0];const a=rp(n)?.params.org,[l,c]=Wi(),d=Rs(),[u,h]=S.useState(!1),[f,m]=S.useState(!1),p=e?.user,g=p?.image;let _;if(t[1]!==d||t[2]!==i||t[3]!==u||t[4]!==a||t[5]!==s||t[6]!==l||t[7]!==c||t[8]!==p||t[9]!==g){const b=s?.find(ee=>ee.slug===a);let y;if(t[11]!==a||t[12]!==s){let ee;t[14]!==a?(ee=(K,U)=>K.slug===a?-1:U.slug===a?1:K.name.localeCompare(U.name),t[14]=a,t[15]=ee):ee=t[15],y=[...s??[]].sort(ee),t[11]=a,t[12]=s,t[13]=y}else y=t[13];const C=y;let j;t[16]!==i?(j=ee=>{h(!1),i({to:"/$org",params:{org:ee}})},t[16]=i,t[17]=j):j=t[17];const V=j;let w;t[18]===Symbol.for("react.memo_cache_sentinel")?(w=()=>h(!1),t[18]=w):w=t[18];const k=w;let T;t[19]===Symbol.for("react.memo_cache_sentinel")?(T=r.jsx(Gr,{size:16}),t[19]=T):T=t[19];let I;t[20]!==i||t[21]!==a?(I={key:"preferences",label:"Preferences",icon:T,onClick:()=>{i({to:"/$org/settings/profile",params:{org:a??""}})}},t[20]=i,t[21]=a,t[22]=I):I=t[22];let A;t[23]===Symbol.for("react.memo_cache_sentinel")?(A={key:"terms",label:"Terms of Use",icon:r.jsx(yg,{size:16}),href:"https://www.decocms.com/terms-of-use",external:!0},t[23]=A):A=t[23];let N;t[24]===Symbol.for("react.memo_cache_sentinel")?(N={key:"privacy",label:"Privacy Policy",icon:r.jsx(Sg,{size:16}),href:"https://www.decocms.com/privacy-policy",external:!0},t[24]=N):N=t[24];let E;t[25]===Symbol.for("react.memo_cache_sentinel")?(E={key:"github",label:"decocms/studio",icon:r.jsx(np,{className:"w-4 h-4"}),href:"https://github.com/decocms/studio",external:!0},t[25]=E):E=t[25];let R;t[26]===Symbol.for("react.memo_cache_sentinel")?(R={key:"community",label:"Community",icon:r.jsx(ao,{size:16}),href:"https://decocms.com/discord",external:!0},t[26]=R):R=t[26];let M;t[27]===Symbol.for("react.memo_cache_sentinel")?(M={key:"homepage",label:"Homepage",icon:r.jsx(Zh,{size:16}),href:"https://decocms.com",external:!0},t[27]=M):M=t[27];let L;t[28]!==I?(L=[I,A,N,E,R,M],t[28]=I,t[29]=L):L=t[29];const D=L;let P;t[30]===Symbol.for("react.memo_cache_sentinel")?(P={key:"logout",label:"Sign out",icon:r.jsx(Rg,{size:16}),onClick:w0},t[30]=P):P=t[30];const O=P;let z;t[31]===Symbol.for("react.memo_cache_sentinel")?(z={value:"light",icon:r.jsx(N_,{size:14}),label:"Light theme"},t[31]=z):z=t[31];let $;t[32]===Symbol.for("react.memo_cache_sentinel")?($={value:"dark",icon:r.jsx(A_,{size:14}),label:"Dark theme"},t[32]=$):$=t[32];let W;t[33]===Symbol.for("react.memo_cache_sentinel")?(W=[z,$,{value:"system",icon:r.jsx(E_,{size:14}),label:"System theme"}],t[33]=W):W=t[33];const F=W;let G;t[34]===Symbol.for("react.memo_cache_sentinel")?(G=()=>{h(!1),m(!0)},t[34]=G):G=t[34];let q;t[35]!==V||t[36]!==d||t[37]!==D||t[38]!==a||t[39]!==l||t[40]!==c||t[41]!==C||t[42]!==p||t[43]!==g?(q={user:p,userImage:g,menuItems:D,signOutItem:O,themeOptions:F,preferences:l,setPreferences:c,sortedOrgs:C,orgParam:a,onSelectOrg:V,onCreateOrg:G,close:k,isMobile:d},t[35]=V,t[36]=d,t[37]=D,t[38]=a,t[39]=l,t[40]=c,t[41]=C,t[42]=p,t[43]=g,t[44]=q):q=t[44];const H=q;_=d?r.jsxs(Si,{open:u,onOpenChange:h,direction:"bottom",children:[r.jsxs("button",{type:"button",onClick:()=>h(!0),className:"flex items-center gap-3 w-full px-3 py-2.5 rounded-lg transition-colors text-sm text-sidebar-foreground/70 hover:bg-sidebar-accent hover:text-sidebar-foreground",children:[r.jsx("div",{className:"shrink-0 size-5 rounded-md flex items-center justify-center border border-border/50 overflow-hidden",style:b?.logo?void 0:ga(b?.name??""),children:b?.logo?r.jsx("img",{src:b.logo,alt:"",className:"size-full object-cover"}):r.jsx("span",{className:"font-semibold leading-none text-[8px]",children:(b?.name??"?").slice(0,2).toUpperCase()})}),r.jsx("span",{className:"truncate",children:b?.name??"Account"})]}),r.jsxs(yi,{className:"h-[80dvh] p-0",children:[r.jsx(bi,{className:"sr-only",children:"Account"}),r.jsx(Xc,{...H})]})]}):r.jsxs(li,{open:u,onOpenChange:h,children:[r.jsx(oi,{asChild:!0,children:r.jsx(us,{tooltip:b?.name??"Account",className:"rounded-md",children:r.jsx("div",{className:"shrink-0 size-6 rounded-md flex items-center justify-center border border-border/50 overflow-hidden",style:b?.logo?void 0:ga(b?.name??""),children:b?.logo?r.jsx("img",{src:b.logo,alt:"",className:"size-full object-cover"}):r.jsx("span",{className:"font-semibold leading-none text-[9px]",children:(b?.name??"?").slice(0,2).toUpperCase()})})})}),r.jsx(ai,{side:"right",align:"end",sideOffset:18,collisionPadding:16,className:"w-[520px] p-0 flex max-h-[520px]",onCloseAutoFocus:S0,children:r.jsx(Xc,{...H})})]}),t[1]=d,t[2]=i,t[3]=u,t[4]=a,t[5]=s,t[6]=l,t[7]=c,t[8]=p,t[9]=g,t[10]=_}else _=t[10];let v;t[45]!==f?(v=r.jsx(m0,{open:f,onOpenChange:m}),t[45]=f,t[46]=v):v=t[46];let x;return t[47]!==_||t[48]!==v?(x=r.jsxs(r.Fragment,{children:[_,v]}),t[47]=_,t[48]=v,t[49]=x):x=t[49],x}function S0(t){return t.preventDefault()}function w0(){se("signed_out",{source:"account_popover"}),St.signOut()}function V0({invitation:t}){const[e,s]=S.useState(!1),[i,n]=S.useState(!1),o=Mt(),a=async()=>{s(!0);try{const c=await St.organization.acceptInvitation({invitationId:t.id});if(c.error)pe.error(c.error.message),s(!1);else{const d=await St.organization.setActive({organizationId:t.organizationId});pe.success("Invitation accepted!");const u=d?.data?.slug;window.location.href=u?`/${u}`:"/"}}catch{pe.error("Failed to accept invitation"),s(!1)}},l=async()=>{n(!0);try{const c=await St.organization.rejectInvitation({invitationId:t.id});c.error?(pe.error(c.error.message),n(!1)):(pe.success("Invitation declined"),o.invalidateQueries())}catch{pe.error("Failed to decline invitation"),n(!1)}};return r.jsxs("div",{className:"flex items-center gap-3 px-5 py-4 border-b border-border last:border-0 hover:bg-muted/25 transition-colors",children:[r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("p",{className:"text-xs text-muted-foreground",children:"You've been invited to join"}),r.jsx("p",{className:"text-sm font-medium truncate",children:t.organizationName??"Unknown organization"})]}),r.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[r.jsx(ne,{size:"icon",variant:"ghost",className:"size-7 text-green-600 hover:text-green-700 hover:bg-green-50 dark:hover:bg-green-950",onClick:a,disabled:e||i,"aria-label":"Accept invitation",children:r.jsx(Jt,{size:14})}),r.jsx(ne,{size:"icon",variant:"ghost",className:"size-7 text-muted-foreground hover:text-destructive hover:bg-destructive/10",onClick:l,disabled:e||i,"aria-label":"Decline invitation",children:r.jsx(ii,{size:14})})]})]})}function C0(){const t=S.useContext(op),{data:e}=t.hooks.useListUserInvitations();return(e??[]).filter(i=>i.status==="pending"&&new Date(i.expiresAt)>new Date)}class j0 extends S.Component{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(e,s){}render(){return this.state.hasError?null:this.props.children}}function k0(t){return t<=1?"text-destructive":t<=5?"text-amber-500 dark:text-amber-400":"text-foreground/70"}function N0(){const t=B.c(19),e=Ke(),{org:s}=be();let i;t[0]!==s.id?(i={connectionId:Wt,orgId:s.id},t[0]=s.id,t[1]=i):i=t[1];const n=Me(i);let o;t[2]===Symbol.for("react.memo_cache_sentinel")?(o={providerId:"deco"},t[2]=o):o=t[2];let a;t[3]!==n?(a={client:n,toolName:"AI_PROVIDER_CREDITS",toolArguments:o,staleTime:6e4,select:A0},t[3]=n,t[4]=a):a=t[4];const{data:l,isPending:c,isError:d}=wi(a),u=l?.balanceCents!=null?l.balanceCents/100:null;let h;t[5]!==u||t[6]!==d||t[7]!==c?(h=c||d||u==null?"Credits":`Credits: $${u.toFixed(2)}`,t[5]=u,t[6]=d,t[7]=c,t[8]=h):h=t[8];const f=h;let m;t[9]!==u?(m=X(u!=null&&k0(u)),t[9]=u,t[10]=m):m=t[10];let p;t[11]!==e||t[12]!==s.slug?(p=()=>e({to:"/$org/settings/ai-providers",params:{org:s.slug}}),t[11]=e,t[12]=s.slug,t[13]=p):p=t[13];let g;t[14]===Symbol.for("react.memo_cache_sentinel")?(g=r.jsx(ml,{size:24}),t[14]=g):g=t[14];let _;return t[15]!==m||t[16]!==p||t[17]!==f?(_=r.jsx(gs,{children:r.jsx(Zt,{children:r.jsx(us,{tooltip:f,className:m,onClick:p,children:g})})}),t[15]=m,t[16]=p,t[17]=f,t[18]=_):_=t[18],_}function A0(t){return t.structuredContent}function E0(){const t=B.c(1);if(!bl().some(I0))return null;let i;return t[0]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx(N0,{}),t[0]=i):i=t[0],i}function I0(t){return t.providerId==="deco"}function R0(){const t=B.c(3),[e,s]=S.useState(!1);let i;t[0]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx(gs,{children:r.jsx(Zt,{children:r.jsx(us,{tooltip:"Connections",onClick:()=>{se("connections_dialog_opened",{source:"sidebar_footer",mode:"browse"}),s(!0)},children:r.jsx(Tg,{size:24})})})}),t[0]=i):i=t[0];let n;return t[1]!==e?(n=r.jsxs(r.Fragment,{children:[i,r.jsx(Pl,{mode:"browse",open:e,onOpenChange:s,defaultTab:"all"})]}),t[1]=e,t[2]=n):n=t[2],n}function T0(){const t=B.c(11),e=C0();let s;t[0]===Symbol.for("react.memo_cache_sentinel")?(s=r.jsx(mc,{size:24}),t[0]=s):s=t[0];let i;t[1]!==e.length?(i=e.length>0&&r.jsx("span",{className:"absolute top-1 right-1 size-2 rounded-full bg-red-500 pointer-events-none"}),t[1]=e.length,t[2]=i):i=t[2];let n;t[3]!==i?(n=r.jsx(gs,{children:r.jsx(Zt,{children:r.jsx(oi,{asChild:!0,children:r.jsxs(us,{tooltip:"Inbox",className:"relative",children:[s,i]})})})}),t[3]=i,t[4]=n):n=t[4];let o;t[5]===Symbol.for("react.memo_cache_sentinel")?(o=r.jsx("div",{className:"px-4 py-3 border-b border-border shrink-0",children:r.jsx("h3",{className:"text-sm font-medium",children:"Inbox"})}),t[5]=o):o=t[5];let a;t[6]!==e?(a=r.jsxs(ai,{side:"right",align:"start",sideOffset:16,collisionPadding:16,className:"w-[min(400px,calc(100vw-2rem))] p-0 h-[min(650px,calc(100dvh-4rem))] flex flex-col",children:[o,e.length===0?r.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-2 px-6 text-center",children:[r.jsx(mc,{size:24,className:"text-muted-foreground/50"}),r.jsx("p",{className:"text-sm font-medium text-foreground",children:"No invites pending"}),r.jsx("p",{className:"text-xs text-muted-foreground",children:"Organization invitations will appear here"})]}):r.jsx("div",{className:"overflow-y-auto flex-1",children:e.map(D0)})]}),t[6]=e,t[7]=a):a=t[7];let l;return t[8]!==n||t[9]!==a?(l=r.jsxs(li,{children:[n,a]}),t[8]=n,t[9]=a,t[10]=l):l=t[10],l}function D0(t){return r.jsx(V0,{invitation:t},t.id)}function M0(){const t=B.c(6),e=Ke(),{org:s}=be();let i;t[0]!==e||t[1]!==s.slug?(i=()=>e({to:"/$org/settings",params:{org:s.slug}}),t[0]=e,t[1]=s.slug,t[2]=i):i=t[2];let n;t[3]===Symbol.for("react.memo_cache_sentinel")?(n=r.jsx(Gr,{size:24}),t[3]=n):n=t[3];let o;return t[4]!==i?(o=r.jsx(gs,{children:r.jsx(Zt,{children:r.jsx(us,{tooltip:"Settings",onClick:i,children:n})})}),t[4]=i,t[5]=o):o=t[5],o}function P0(){const t=B.c(5);let e,s,i,n;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=r.jsx(j0,{children:r.jsx(S.Suspense,{fallback:null,children:r.jsx(E0,{})})}),s=r.jsx(R0,{}),i=r.jsx(T0,{}),n=r.jsx(M0,{}),t[0]=e,t[1]=s,t[2]=i,t[3]=n):(e=t[0],s=t[1],i=t[2],n=t[3]);let o;return t[4]===Symbol.for("react.memo_cache_sentinel")?(o=r.jsxs(bu,{className:"px-2 pb-3 gap-1",children:[e,s,i,n,r.jsx(gs,{children:r.jsx(Zt,{children:r.jsx(sf,{})})})]}),t[4]=o):o=t[4],o}function L0(){const t=B.c(10),e=Ke(),{org:s}=be(),{setOpenMobile:i}=qr();let n;t[0]!==e||t[1]!==s.slug||t[2]!==i?(n=()=>{e({to:"/$org/settings",params:{org:s.slug}}),i(!1)},t[0]=e,t[1]=s.slug,t[2]=i,t[3]=n):n=t[3];let o;t[4]===Symbol.for("react.memo_cache_sentinel")?(o=r.jsx(Gr,{}),t[4]=o):o=t[4];let a;t[5]!==n?(a=r.jsx(Zt,{children:r.jsx(us,{tooltip:"Settings",onClick:n,children:o})}),t[5]=n,t[6]=a):a=t[6];let l;t[7]===Symbol.for("react.memo_cache_sentinel")?(l=r.jsx(Zt,{children:r.jsx(sf,{})}),t[7]=l):l=t[7];let c;return t[8]!==a?(c=r.jsx(bu,{children:r.jsxs(gs,{children:[a,l]})}),t[8]=a,t[9]=c):c=t[9],c}function B0(){for(var t=arguments.length,e=new Array(t),s=0;s<t;s++)e[s]=arguments[s];return S.useMemo(()=>i=>{e.forEach(n=>n(i))},e)}const uo=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Ki(t){const e=Object.prototype.toString.call(t);return e==="[object Window]"||e==="[object global]"}function Ll(t){return"nodeType"in t}function Ut(t){var e,s;return t?Ki(t)?t:Ll(t)&&(e=(s=t.ownerDocument)==null?void 0:s.defaultView)!=null?e:window:window}function Bl(t){const{Document:e}=Ut(t);return t instanceof e}function Xr(t){return Ki(t)?!1:t instanceof Ut(t).HTMLElement}function rf(t){return t instanceof Ut(t).SVGElement}function qi(t){return t?Ki(t)?t.document:Ll(t)?Bl(t)?t:Xr(t)||rf(t)?t.ownerDocument:document:document:document}const Es=uo?S.useLayoutEffect:S.useEffect;function Ol(t){const e=S.useRef(t);return Es(()=>{e.current=t}),S.useCallback(function(){for(var s=arguments.length,i=new Array(s),n=0;n<s;n++)i[n]=arguments[n];return e.current==null?void 0:e.current(...i)},[])}function O0(){const t=S.useRef(null),e=S.useCallback((i,n)=>{t.current=setInterval(i,n)},[]),s=S.useCallback(()=>{t.current!==null&&(clearInterval(t.current),t.current=null)},[]);return[e,s]}function Er(t,e){e===void 0&&(e=[t]);const s=S.useRef(t);return Es(()=>{s.current!==t&&(s.current=t)},e),s}function Jr(t,e){const s=S.useRef();return S.useMemo(()=>{const i=t(s.current);return s.current=i,i},[...e])}function Hn(t){const e=Ol(t),s=S.useRef(null),i=S.useCallback(n=>{n!==s.current&&e?.(n,s.current),s.current=n},[]);return[s,i]}function _a(t){const e=S.useRef();return S.useEffect(()=>{e.current=t},[t]),e.current}let Ro={};function Qr(t,e){return S.useMemo(()=>{if(e)return e;const s=Ro[t]==null?0:Ro[t]+1;return Ro[t]=s,t+"-"+s},[t,e])}function nf(t){return function(e){for(var s=arguments.length,i=new Array(s>1?s-1:0),n=1;n<s;n++)i[n-1]=arguments[n];return i.reduce((o,a)=>{const l=Object.entries(a);for(const[c,d]of l){const u=o[c];u!=null&&(o[c]=u+t*d)}return o},{...e})}}const Di=nf(1),Ir=nf(-1);function $0(t){return"clientX"in t&&"clientY"in t}function $l(t){if(!t)return!1;const{KeyboardEvent:e}=Ut(t.target);return e&&t instanceof e}function z0(t){if(!t)return!1;const{TouchEvent:e}=Ut(t.target);return e&&t instanceof e}function xa(t){if(z0(t)){if(t.touches&&t.touches.length){const{clientX:e,clientY:s}=t.touches[0];return{x:e,y:s}}else if(t.changedTouches&&t.changedTouches.length){const{clientX:e,clientY:s}=t.changedTouches[0];return{x:e,y:s}}}return $0(t)?{x:t.clientX,y:t.clientY}:null}const Rr=Object.freeze({Translate:{toString(t){if(!t)return;const{x:e,y:s}=t;return"translate3d("+(e?Math.round(e):0)+"px, "+(s?Math.round(s):0)+"px, 0)"}},Scale:{toString(t){if(!t)return;const{scaleX:e,scaleY:s}=t;return"scaleX("+e+") scaleY("+s+")"}},Transform:{toString(t){if(t)return[Rr.Translate.toString(t),Rr.Scale.toString(t)].join(" ")}},Transition:{toString(t){let{property:e,duration:s,easing:i}=t;return e+" "+s+"ms "+i}}}),Jc="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function F0(t){return t.matches(Jc)?t:t.querySelector(Jc)}const H0={display:"none"};function W0(t){let{id:e,value:s}=t;return Ft.createElement("div",{id:e,style:H0},s)}function U0(t){let{id:e,announcement:s,ariaLiveType:i="assertive"}=t;const n={position:"fixed",top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(100%)",whiteSpace:"nowrap"};return Ft.createElement("div",{id:e,style:n,role:"status","aria-live":i,"aria-atomic":!0},s)}function K0(){const[t,e]=S.useState("");return{announce:S.useCallback(i=>{i!=null&&e(i)},[]),announcement:t}}const of=S.createContext(null);function q0(t){const e=S.useContext(of);S.useEffect(()=>{if(!e)throw new Error("useDndMonitor must be used within a children of <DndContext>");return e(t)},[t,e])}function G0(){const[t]=S.useState(()=>new Set),e=S.useCallback(i=>(t.add(i),()=>t.delete(i)),[t]);return[S.useCallback(i=>{let{type:n,event:o}=i;t.forEach(a=>{var l;return(l=a[n])==null?void 0:l.call(a,o)})},[t]),e]}const Y0={draggable:`
260
260
  To pick up a draggable item, press the space bar.
261
261
  While dragging, use the arrow keys to move the item.
262
262
  Press space again to drop the item in its new position, or press escape to cancel.
@@ -447,4 +447,4 @@ ${Q}
447
447
 
448
448
  <message>
449
449
  ${he}
450
- </message>`}]}}))},L=e.models?.credentialId||m||"",D=e.models?.thinking?.id||p?.modelId||"",P=Hi({defaultValues:{name:e.name,active:e.active,credential_id:L,model_id:D}}),O=P.watch("active"),z=P.watch("credential_id"),$=P.watch("model_id"),{models:W,isLoading:F}=tu(z||void 0),G=W.find(oe=>oe.modelId===$)??null,q=S.useRef(null),H=S.useRef(new Set),ee=S.useRef(0),K=S.useRef(null),U=3e4,te=()=>{K.current&&(clearTimeout(K.current),K.current=null),q.current!==null&&(se("automation_updated",{automation_id:t,agent_id:o,fields:Array.from(H.current),save_count:ee.current,edit_duration_ms:Date.now()-q.current}),q.current=null,H.current=new Set,ee.current=0)},Y=async()=>{if(!(Object.keys(P.formState.dirtyFields).length>0)&&!R.current)return!0;const he=Object.keys(P.formState.dirtyFields),me=R.current;R.current=!1;const fe=P.getValues();try{const le=fe.credential_id&&fe.model_id?fe.credential_id:"",ve=fe.credential_id&&fe.model_id?fe.model_id:"",Ce={id:t,name:fe.name,active:fe.active,agent:{id:o},models:{credentialId:le,thinking:{id:ve}},messages:Ip(b),temperature:0};await l.mutateAsync(Ce),q.current===null&&(q.current=Date.now());for(const Te of he)H.current.add(Te);return me&&H.current.add("messages"),ee.current+=1,K.current&&clearTimeout(K.current),K.current=setTimeout(te,U),P.reset({...fe,credential_id:le,model_id:ve}),!0}catch{return R.current=!0,!1}},J=()=>{E.current&&clearTimeout(E.current),E.current=setTimeout(()=>{Y()},1e3)},ie=async()=>(E.current&&clearTimeout(E.current),Y()),ue=oe=>{if(y(oe),!N.current){N.current=!0;return}R.current=!0,J()},de=S.useRef(!1);de.current||(de.current=!0,P.watch(()=>{J()}));const xe=async()=>{se("automation_test_clicked",{automation_id:t,agent_id:o});const oe=await ie();if(te(),!oe)return;if(!b){pe.error("No instructions configured for this automation");return}G&&z&&f({...G,keyId:z}),v({..._,toolApprovalLevel:"auto"});const he=cc(b);h({message:{tiptapDoc:b,parts:he},virtualMcpId:o||void 0})};return r.jsxs(r.Fragment,{children:[i&&r.jsx("div",{className:"flex items-center pb-4 shrink-0",children:r.jsxs(ne,{variant:"ghost",size:"sm",onClick:i,children:[r.jsx(xl,{size:14}),"Back to list"]})}),r.jsxs("div",{className:"flex flex-col gap-8",children:[r.jsxs("div",{className:"flex flex-col gap-1.5",children:[r.jsxs("div",{className:"flex items-center justify-between gap-4",children:[r.jsx(bt,{...P.register("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"}}),n&&r.jsx(ne,{variant:"ghost",size:"icon",className:"text-muted-foreground hover:text-destructive shrink-0",onClick:n,children:r.jsx(ha,{size:14})})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(Ai,{control:P.control,name:"active",render:({field:oe})=>r.jsx(da,{checked:oe.value,onCheckedChange:he=>{oe.onChange(he),setTimeout(()=>ie(),0)},className:"cursor-pointer"})}),r.jsx("span",{className:"text-sm text-muted-foreground",children:O?"Active":"Inactive"}),r.jsx("span",{className:"text-muted-foreground/50 text-sm",children:"·"}),r.jsx(P_,{id:e.created_by,size:"2xs",className:"text-sm text-muted-foreground"})]})]}),r.jsxs("div",{className:"flex flex-col gap-2.5",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("span",{className:"text-xs font-semibold text-muted-foreground/60",children:"Starter"}),r.jsx(_5,{automationId:t,open:C,onOpenChange:j,onCustomSelect:()=>{w(!0),A(!1),T("")},onEventSelect:()=>{A(!0),w(!1)}})]}),e.triggers.length===0&&!V?r.jsx("div",{className:"rounded-lg border border-dashed border-border px-4 py-6 text-center",children:r.jsxs("p",{className:"text-sm text-muted-foreground",children:["When should this automation run?"," ",r.jsx("button",{type:"button",className:"text-foreground underline underline-offset-2 cursor-pointer hover:text-foreground/80 transition-colors",onClick:()=>j(!0),children:"Add a starter"})," ","to get going."]})}):r.jsx("div",{className:"flex flex-col gap-2",children:e.triggers.map(oe=>r.jsx(x5,{trigger:oe,automationId:t,connectionName:oe.connection_id?u.get(oe.connection_id):void 0},oe.id))}),V&&r.jsxs("div",{className:"flex items-center gap-2.5 px-3 py-2.5 rounded-lg border border-border bg-background group",children:[r.jsx(_r,{size:14,className:"text-muted-foreground shrink-0"}),r.jsx("input",{type:"text",value:k,onChange:oe=>T(oe.target.value),onBlur:async()=>{const oe=k.trim();if(!(!oe||!Vr(oe)))try{await c.mutateAsync({automation_id:t,type:"cron",cron_expression:oe}),se("automation_trigger_added",{automation_id:t,trigger_type:"cron"}),pe.success("Starter added"),w(!1),T("")}catch{pe.error("Failed to add starter")}},onKeyDown:async oe=>{const he=k.trim();oe.key==="Enter"&&he&&Vr(he)&&oe.target.blur(),oe.key==="Escape"&&(w(!1),T(""))},placeholder:"0 9 * * 1-5",className:"flex-1 text-sm font-mono bg-transparent outline-none placeholder:text-muted-foreground/40",autoFocus:!0}),k&&!Vr(k)&&r.jsx("span",{className:"text-xs text-muted-foreground/60 shrink-0",children:"invalid"}),c.isPending&&r.jsx(Ee,{size:13,className:"animate-spin text-muted-foreground shrink-0"}),r.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:()=>{w(!1),T("")},children:r.jsx(ii,{size:13})})]}),I&&r.jsx(S.Suspense,{fallback:r.jsxs("div",{className:"flex items-center gap-2 px-3 py-3 rounded-lg border border-border bg-background",children:[r.jsx(Ee,{size:13,className:"animate-spin text-muted-foreground"}),r.jsx("span",{className:"text-sm text-muted-foreground",children:"Loading connections..."})]}),children:r.jsx(b5,{automationId:t,onDone:()=>A(!1)})})]}),r.jsxs("div",{className:"flex flex-col gap-2.5",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("span",{className:"text-xs font-semibold text-muted-foreground/60",children:"Instructions"}),r.jsxs(ne,{variant:"outline",size:"sm",className:"h-7 gap-1.5 px-2 text-xs",disabled:!b,onClick:M,children:[r.jsx(_l,{size:13}),"Improve"]})]}),r.jsx(Wu,{tiptapDoc:b,setTiptapDoc:ue,placeholder:"What should this automation do?",children:r.jsxs("div",{className:"rounded-xl border border-border min-h-[120px] flex flex-col",children:[r.jsx(Uu,{virtualMcpId:o||null,className:"max-h-[45vh]"}),r.jsxs("div",{className:"flex items-center justify-end gap-1.5 p-2.5",children:[r.jsx(iu,{model:G,isLoading:F,credentialId:z||null,onCredentialChange:oe=>{P.setValue("credential_id",oe??"",{shouldDirty:!0}),P.setValue("model_id","",{shouldDirty:!0})},onModelChange:oe=>P.setValue("model_id",oe.modelId,{shouldDirty:!0}),placeholder:"Model"}),r.jsxs(it,{children:[r.jsx(tt,{asChild:!0,children:r.jsxs(ne,{type:"button",variant:"default",className:"h-8 gap-1.5 rounded-md px-3 text-sm font-medium",onClick:xe,disabled:!o,children:[r.jsx(Fh,{size:16}),"Test"]})}),r.jsx(st,{children:"Test Automation"})]})]})]})})]})]})]})}function C5(t){const e=B.c(6),{tabId:s,virtualMcpId:i}=t;let n;e[0]!==s?(n=Ih(s),e[0]=s,e[1]=n):n=e[1];const o=n;if(!o)return null;let a;e[2]===Symbol.for("react.memo_cache_sentinel")?(a=r.jsx("div",{className:"flex-1 flex items-center justify-center",children:r.jsx(Ee,{size:20,className:"animate-spin text-muted-foreground"})}),e[2]=a):a=e[2];let l;return e[3]!==o.id||e[4]!==i?(l=r.jsx(hs,{children:r.jsx(hs.Content,{children:r.jsx(hs.Body,{children:r.jsx(S.Suspense,{fallback:a,children:r.jsx(j5,{id:o.id,virtualMcpId:i})})})})}),e[3]=o.id,e[4]=i,e[5]=l):l=e[5],l}function j5(t){const e=B.c(9),{id:s,virtualMcpId:i}=t,n=Ke(),{data:o,isLoading:a}=B_(s);let l;e[0]!==n?(l=()=>n({to:".",search:k5,replace:!0}),e[0]=n,e[1]=l):l=e[1];const c=l;if(a){let u;return e[2]===Symbol.for("react.memo_cache_sentinel")?(u=r.jsx("div",{className:"flex-1 flex items-center justify-center",children:r.jsx(Ee,{size:20,className:"animate-spin text-muted-foreground"})}),e[2]=u):u=e[2],u}if(!o){let u;return e[3]===Symbol.for("react.memo_cache_sentinel")?(u=r.jsx("div",{className:"flex-1 flex items-center justify-center text-sm text-muted-foreground",children:"Automation not found"}),e[3]=u):u=e[3],u}let d;return e[4]!==o||e[5]!==s||e[6]!==c||e[7]!==i?(d=r.jsx(V5,{automationId:s,automation:o,virtualMcpId:i,onBack:c}),e[4]=o,e[5]=s,e[6]=c,e[7]=i,e[8]=d):d=e[8],d}function k5(t){return{...t,main:"automations"}}function N5(t){const e=B.c(19),{virtualMcpId:s}=t,i=Ke(),{data:n}=O_(s),o=n===void 0?[]:n,{create:a}=Yr(),[l,c]=S.useState(""),d=l.toLowerCase(),u=o.filter(k=>k.name.toLowerCase().includes(d));let h;e[0]!==i?(h=k=>i({to:".",search:T=>({...T,main:"automation:"+k}),replace:!0}),e[0]=i,e[1]=h):h=e[1];const f=h,m=async()=>{if(a.isPending)return;se("automation_new_clicked",{virtual_mcp_id:s,existing_count:o.length});const k=await a.mutateAsync(z_(s));f(k.id)},p=hs,g=hs,_=hs;let v;e[2]===Symbol.for("react.memo_cache_sentinel")?(v=r.jsx(Qt,{size:14}),e[2]=v):v=e[2];let x;e[3]!==a.isPending||e[4]!==m?(x=r.jsx(hs.Title,{actions:r.jsxs(ne,{size:"sm",onClick:m,disabled:a.isPending,children:[v,"New automation"]}),children:"Automations"}),e[3]=a.isPending,e[4]=m,e[5]=x):x=e[5];const b=o.length>0&&r.jsx(F_,{value:l,onChange:c,placeholder:"Search automations...",className:"w-full md:w-[375px]"});let y;e[6]!==x||e[7]!==b?(y=r.jsxs("div",{className:"flex flex-col gap-6",children:[x,b]}),e[6]=x,e[7]=b,e[8]=y):y=e[8];const C=o.length===0?r.jsx("div",{className:"flex items-center justify-center py-20",children:r.jsx(Oi,{image:r.jsx($i,{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:r.jsxs(ne,{size:"sm",onClick:m,disabled:a.isPending,children:[r.jsx(Qt,{size:14}),"New automation"]})})}):u.length===0?r.jsx("div",{className:"flex items-center justify-center py-20",children:r.jsx(Oi,{image:r.jsx($i,{size:48,className:"text-muted-foreground"}),title:"No automations found",description:`No automations match "${l}"`})}):r.jsx("div",{className:"mt-6 rounded-xl border border-border overflow-hidden",children:u.map(k=>r.jsx($_,{automation:k,onClick:()=>f(k.id)},k.id))});let j;e[9]!==_.Body||e[10]!==y||e[11]!==C?(j=r.jsxs(_.Body,{children:[y,C]}),e[9]=_.Body,e[10]=y,e[11]=C,e[12]=j):j=e[12];let V;e[13]!==j||e[14]!==g.Content?(V=r.jsx(g.Content,{children:j}),e[13]=j,e[14]=g.Content,e[15]=V):V=e[15];let w;return e[16]!==p||e[17]!==V?(w=r.jsx(p,{children:V}),e[16]=p,e[17]=V,e[18]=w):w=e[18],w}function A5(t){const e=B.c(3),{virtualMcpId:s}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx("div",{className:"flex-1 flex items-center justify-center",children:r.jsx(Ee,{size:20,className:"animate-spin text-muted-foreground"})}),e[0]=i):i=e[0];let n;return e[1]!==s?(n=r.jsx(S.Suspense,{fallback:i,children:r.jsx(N5,{virtualMcpId:s})}),e[1]=s,e[2]=n):n=e[2],n}const mh=S.lazy(()=>jp(()=>import("./project-app-view-CpeukqHC.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])).then(t=>({default:t.AppViewContent})));function E5(t){const e=B.c(35),{taskId:s,virtualMcpId:i}=t;let n;e[0]!==s||e[1]!==i?(n={virtualMcpId:i,taskId:s},e[0]=s,e[1]=i,e[2]=n):n=e[2];const{activeTab:o,layoutTabs:a,automationTabParsed:l}=zf(n);if(Yp(o)){let m;return e[3]!==i?(m=r.jsx(_d,{virtualMcpId:i}),e[3]=i,e[4]=m):m=e[4],m}if(o==="git"){let m;return e[5]!==i?(m=r.jsx(gV,{virtualMcpId:i}),e[5]=i,e[6]=m):m=e[6],m}if(o==="automations"){let m;return e[7]!==i?(m=r.jsx(A5,{virtualMcpId:i}),e[7]=i,e[8]=m):m=e[8],m}if(o==="env"){let m;return e[9]!==i?(m=r.jsx(h5,{virtualMcpId:i}),e[9]=i,e[10]=m):m=e[10],m}if(o==="preview"){let m;return e[11]!==i?(m=r.jsx(qV,{virtualMcpId:i}),e[11]=i,e[12]=m):m=e[12],m}if(l){let m;return e[13]!==o||e[14]!==i?(m=r.jsx(C5,{tabId:o,virtualMcpId:i}),e[13]=o,e[14]=i,e[15]=m):m=e[15],m}let c;e[16]!==o?(c=Xp(o),e[16]=o,e[17]=c):c=e[17];const d=c;if(d){let m;e[18]===Symbol.for("react.memo_cache_sentinel")?(m=r.jsx("div",{className:"h-full w-full flex items-center justify-center",children:r.jsx(Ee,{size:20,className:"animate-spin text-muted-foreground"})}),e[18]=m):m=e[18];let p;return e[19]!==o||e[20]!==d.connectionId||e[21]!==d.toolName?(p=r.jsx(S.Suspense,{fallback:m,children:r.jsx(mh,{connectionId:d.connectionId,toolName:d.toolName},o)}),e[19]=o,e[20]=d.connectionId,e[21]=d.toolName,e[22]=p):p=e[22],p}let u;if(e[23]!==o||e[24]!==a){let m;e[26]!==o?(m=p=>p.id===o,e[26]=o,e[27]=m):m=e[27],u=a.find(m),e[23]=o,e[24]=a,e[25]=u}else u=e[25];const h=u;if(h){let m;e[28]===Symbol.for("react.memo_cache_sentinel")?(m=r.jsx("div",{className:"h-full w-full flex items-center justify-center",children:r.jsx(Ee,{size:20,className:"animate-spin text-muted-foreground"})}),e[28]=m):m=e[28];let p;return e[29]!==o||e[30]!==h.id||e[31]!==h.view.appId?(p=r.jsx(S.Suspense,{fallback:m,children:r.jsx(mh,{connectionId:h.view.appId,toolName:h.id},o)}),e[29]=o,e[30]=h.id,e[31]=h.view.appId,e[32]=p):p=e[32],p}let f;return e[33]!==i?(f=r.jsx(_d,{virtualMcpId:i}),e[33]=i,e[34]=f):f=e[34],f}function I5(t){const e=B.c(7),{children:s,defaultSize:i}=t,[,n]=S.useTransition();let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=ol.decoChatPanelWidth(),e[0]=o):o=e[0];const[a,l]=nl(o,45),c=i>0&&i<100?a:i;let d;e[1]!==l?(d=f=>n(()=>{f>0&&f<100&&l(f)}),e[1]=l,e[2]=d):d=e[2];const u=d;let h;return e[3]!==s||e[4]!==c||e[5]!==u?(h=r.jsx(ru,{defaultSize:c,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]=c,e[5]=u,e[6]=h):h=e[6],h}function R5(t){const e=B.c(31),{virtualMcpId:s,taskId:i,chatOpen:n,mainOpen:o,variant:a,chatContent:l}=t;let c;e[0]!==n||e[1]!==o?(c=ud(n,o),e[0]=n,e[1]=o,e[2]=c):c=e[2];const d=c;let u;e[3]===Symbol.for("react.memo_cache_sentinel")?(u=ol.decoChatPanelWidth(),e[3]=u):u=e[3];const[h]=nl(u,45),f=S.useRef(null);let m,p;e[4]!==n||e[5]!==o||e[6]!==h?(m=()=>{const I=f.current;if(!I)return;const A=ud(n,o),N=A.chat>0&&A.chat<100?h:A.chat,E=A.chat>0&&A.chat<100?100-h:A.main;I.setLayout([N,E])},p=[n,o,h],e[4]=n,e[5]=o,e[6]=h,e[7]=m,e[8]=p):(m=e[7],p=e[8]),S.useEffect(m,p);const g=`${s}-${i}`;let _;e[9]===Symbol.for("react.memo_cache_sentinel")?(_={overflow:"visible"},e[9]=_):_=e[9];let v;e[10]!==l||e[11]!==a?(v=l??r.jsx(qu,{variant:a}),e[10]=l,e[11]=a,e[12]=v):v=e[12];let x;e[13]!==v?(x=r.jsx("div",{className:"h-full p-0.5 pt-0.25",children:r.jsx("div",{className:"h-full bg-background rounded-[0.75rem] overflow-hidden card-shadow",children:v})}),e[13]=v,e[14]=x):x=e[14];let b;e[15]!==d.chat||e[16]!==x?(b=r.jsx(I5,{defaultSize:d.chat,children:x}),e[15]=d.chat,e[16]=x,e[17]=b):b=e[17];let y;e[18]===Symbol.for("react.memo_cache_sentinel")?(y=r.jsx(Yg,{className:"bg-sidebar"}),e[18]=y):y=e[18];const C=d.main;let j;e[19]===Symbol.for("react.memo_cache_sentinel")?(j={overflow:"visible"},e[19]=j):j=e[19];let V;e[20]===Symbol.for("react.memo_cache_sentinel")?(V=X("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[20]=V):V=e[20];let w;e[21]!==i||e[22]!==s?(w=r.jsx("div",{className:"h-full p-0.5 pt-0.25",children:r.jsx("div",{className:V,children:r.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:r.jsx(E5,{taskId:i,virtualMcpId:s})})})}),e[21]=i,e[22]=s,e[23]=w):w=e[23];let k;e[24]!==d.main||e[25]!==w?(k=r.jsx(ru,{className:"min-w-0 flex flex-col",order:2,defaultSize:C,style:j,collapsible:!0,collapsedSize:0,minSize:20,children:w}),e[24]=d.main,e[25]=w,e[26]=k):k=e[26];let T;return e[27]!==k||e[28]!==g||e[29]!==b?(T=r.jsxs(Xg,{ref:f,direction:"horizontal",className:"flex-1 min-h-0 pb-1 pr-1 pl-0 pt-0",style:_,children:[b,y,k]},g),e[27]=k,e[28]=g,e[29]=b,e[30]=T):T=e[30],T}const ta="flex size-7 shrink-0 items-center justify-center rounded-md transition-colors",ph="bg-sidebar-accent text-sidebar-foreground",sa="text-sidebar-foreground/60 hover:bg-sidebar-accent hover:text-sidebar-foreground";function T5(t){const e=B.c(38),{isDecopilot:s,chatOpen:i,toggleChat:n,onNewTask:o}=t,{tasksOpen:a,toggleTasks:l}=Of(),c=!!o;let d;e[0]!==a||e[1]!==l?(d=()=>{se("agent_toolbar_toggled",{button:"tasks",next_state:a?"closed":"open"}),l()},e[0]=a,e[1]=l,e[2]=d):d=e[2];const u=a?ph:sa;let h;e[3]!==u?(h=X(ta,u),e[3]=u,e[4]=h):h=e[4];let f;e[5]===Symbol.for("react.memo_cache_sentinel")?(f=r.jsx(Ig,{size:16}),e[5]=f):f=e[5];let m;e[6]!==d||e[7]!==h||e[8]!==a?(m=r.jsx(tt,{asChild:!0,children:r.jsx("button",{type:"button",onClick:d,"aria-pressed":a,className:h,children:f})}),e[6]=d,e[7]=h,e[8]=a,e[9]=m):m=e[9];let p;e[10]===Symbol.for("react.memo_cache_sentinel")?(p=r.jsx(st,{side:"bottom",children:"Tasks"}),e[10]=p):p=e[10];let g;e[11]!==m?(g=r.jsxs(it,{delayDuration:300,children:[m,p]}),e[11]=m,e[12]=g):g=e[12];let _;e[13]!==i||e[14]!==s||e[15]!==n?(_=!s&&r.jsxs(it,{delayDuration:300,children:[r.jsx(tt,{asChild:!0,children:r.jsx("button",{type:"button",onClick:()=>{se("agent_toolbar_toggled",{button:"chat",next_state:i?"closed":"open"}),n()},"aria-pressed":i,className:X(ta,i?ph:sa),children:r.jsx(Eg,{size:16})})}),r.jsx(st,{side:"bottom",children:"Chat"})]}),e[13]=i,e[14]=s,e[15]=n,e[16]=_):_=e[16];const v=c?"grid-cols-[1fr]":"grid-cols-[0fr]";let x;e[17]!==v?(x=X("grid transition-[grid-template-columns] duration-200 ease-[var(--ease-out-quart)]",v),e[17]=v,e[18]=x):x=e[18];const b=!c,y=c?0:-1,C=!c,j=c?"translate-x-0 opacity-100":"-translate-x-2 opacity-0";let V;e[19]!==j?(V=X(ta,sa,"transition-[transform,opacity] duration-200 ease-[var(--ease-out-quart)] will-change-transform",j),e[19]=j,e[20]=V):V=e[20];let w;e[21]===Symbol.for("react.memo_cache_sentinel")?(w=r.jsx(pl,{size:16}),e[21]=w):w=e[21];let k;e[22]!==o||e[23]!==b||e[24]!==y||e[25]!==C||e[26]!==V?(k=r.jsx(tt,{asChild:!0,children:r.jsx("button",{type:"button",onClick:o,disabled:b,tabIndex:y,"aria-hidden":C,className:V,children:w})}),e[22]=o,e[23]=b,e[24]=y,e[25]=C,e[26]=V,e[27]=k):k=e[27];let T;e[28]===Symbol.for("react.memo_cache_sentinel")?(T=r.jsx(st,{side:"bottom",children:"New task"}),e[28]=T):T=e[28];let I;e[29]!==k?(I=r.jsx("div",{className:"overflow-hidden",children:r.jsxs(it,{delayDuration:300,children:[k,T]})}),e[29]=k,e[30]=I):I=e[30];let A;e[31]!==x||e[32]!==I?(A=r.jsx("div",{className:x,children:I}),e[31]=x,e[32]=I,e[33]=A):A=e[33];let N;return e[34]!==A||e[35]!==g||e[36]!==_?(N=r.jsxs(r.Fragment,{children:[g,_,A]}),e[34]=A,e[35]=g,e[36]=_,e[37]=N):N=e[37],N}function D5(t,e,s){if(t.length<=s)return{visible:t,overflow:[]};const i=t.slice(0,s),n=t.slice(s);if(e==null)return{visible:i,overflow:n};if(i.some(h=>h.id===e))return{visible:i,overflow:n};const a=n.findIndex(h=>h.id===e);if(a===-1)return{visible:i,overflow:n};const l=i[i.length-1],c=n[a],d=[...i.slice(0,-1),c],u=[l,...n.slice(0,a),...n.slice(a+1)];return{visible:d,overflow:u}}function M5(t){const e=B.c(13),{title:s,icon:i,active:n,onClick:o}=t,a=n?"bg-sidebar-accent text-sidebar-foreground":"text-sidebar-foreground/60 hover:bg-sidebar-accent hover:text-sidebar-foreground";let l;e[0]!==a?(l=X("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 c;e[2]!==i?(c=r.jsx("span",{className:"flex size-5 items-center justify-center shrink-0",children:r.jsx(P5,{icon:i})}),e[2]=i,e[3]=c):c=e[3];let d;e[4]!==s?(d=r.jsx("span",{className:"whitespace-nowrap text-sm font-medium leading-none",children:s}),e[4]=s,e[5]=d):d=e[5];let u;return e[6]!==n||e[7]!==o||e[8]!==l||e[9]!==c||e[10]!==d||e[11]!==s?(u=r.jsxs("button",{type:"button",onClick:o,"aria-pressed":n,"aria-label":s,className:l,children:[c,d]}),e[6]=n,e[7]=o,e[8]=l,e[9]=c,e[10]=d,e[11]=s,e[12]=u):u=e[12],u}function P5(t){const e=B.c(5),{icon:s}=t;if(s.kind==="component"){const{Component:n}=s;let o;return e[0]!==n?(o=r.jsx(n,{className:"size-4"}),e[0]=n,e[1]=o):o=e[1],o}if(s.kind==="url"){let n;return e[2]!==s.src?(n=r.jsx("img",{src:s.src,alt:"",className:"size-4 rounded-sm object-cover"}),e[2]=s.src,e[3]=n):n=e[3],n}let i;return e[4]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx(Yh,{className:"size-4"}),e[4]=i):i=e[4],i}function L5(t){const e=B.c(13),{overflow:s,onSelect:i}=t,[n,o]=S.useState(!1);let a;e[0]!==i?(a=f=>{o(!1),i(f)},e[0]=i,e[1]=a):a=e[1];const l=a;let c;e[2]===Symbol.for("react.memo_cache_sentinel")?(c=r.jsx(oi,{asChild:!0,children:r.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:r.jsx(Kh,{className:"size-4"})})}),e[2]=c):c=e[2];let d;if(e[3]!==l||e[4]!==s){let f;e[6]!==l?(f=m=>r.jsx("li",{children:r.jsxs("button",{type:"button",onClick:()=>l(m.id),className:"w-full flex items-center gap-2 px-3 py-2 rounded-md hover:bg-accent text-sm text-foreground",children:[r.jsx("span",{className:"flex size-5 items-center justify-center shrink-0",children:r.jsx(B5,{icon:m.icon})}),r.jsx("span",{className:"truncate",children:m.title})]})},m.id),e[6]=l,e[7]=f):f=e[7],d=s.map(f),e[3]=l,e[4]=s,e[5]=d}else d=e[5];let u;e[8]!==d?(u=r.jsx(ai,{align:"end",className:"w-56 p-1",children:r.jsx("ul",{className:"flex flex-col",children:d})}),e[8]=d,e[9]=u):u=e[9];let h;return e[10]!==n||e[11]!==u?(h=r.jsxs(li,{open:n,onOpenChange:o,children:[c,u]}),e[10]=n,e[11]=u,e[12]=h):h=e[12],h}function B5(t){const e=B.c(5),{icon:s}=t;if(s.kind==="component"){const{Component:n}=s;let o;return e[0]!==n?(o=r.jsx(n,{className:"size-4"}),e[0]=n,e[1]=o):o=e[1],o}if(s.kind==="url"){let n;return e[2]!==s.src?(n=r.jsx("img",{src:s.src,alt:"",className:"size-4 rounded-sm object-cover"}),e[2]=s.src,e[3]=n):n=e[3],n}let i;return e[4]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx(Yh,{className:"size-4"}),e[4]=i):i=e[4],i}const O5=6;function $5(t){const e=B.c(20),{virtualMcpId:s,taskId:i}=t,n=Ke();let o;e[0]!==i||e[1]!==s?(o={virtualMcpId:s,taskId:i},e[0]=i,e[1]=s,e[2]=o):o=e[2];const{tabs:a,activeTab:l,mainOpen:c,setActiveTab:d}=zf(o);let u,h,f,m;if(e[3]!==l||e[4]!==c||e[5]!==n||e[6]!==d||e[7]!==a||e[8]!==s){const _=Jp({activeTab:l,mainOpen:c}),v=j=>j.id==="automations"?_:c&&j.id===l,b=a.find(j=>v(j))?.id??null,{visible:y,overflow:C}=D5(a,b,O5);h=C,u=j=>{const V=a.find(k=>k.id===j),w=b===j&&c;if(se("main_panel_tab_clicked",{virtual_mcp_id:s,tab_id:j,tab_kind:V?.kind??null,was_active:w}),j==="automations"){const k=Qp({activeTab:l,mainOpen:c});n({to:".",search:T=>({...T,main:k}),replace:!0});return}d(j)},f="flex items-center min-w-0 ml-auto gap-0.5",m=y.map(j=>r.jsx(M5,{title:j.title,icon:j.icon,active:v(j),onClick:()=>u(j.id)},j.id)),e[3]=l,e[4]=c,e[5]=n,e[6]=d,e[7]=a,e[8]=s,e[9]=u,e[10]=h,e[11]=f,e[12]=m}else u=e[9],h=e[10],f=e[11],m=e[12];let p;e[13]!==u||e[14]!==h?(p=h.length>0&&r.jsx(L5,{overflow:h,onSelect:u}),e[13]=u,e[14]=h,e[15]=p):p=e[15];let g;return e[16]!==f||e[17]!==m||e[18]!==p?(g=r.jsxs("div",{className:f,children:[m,p]}),e[16]=f,e[17]=m,e[18]=p,e[19]=g):g=e[19],g}function z5(t){const e=B.c(12);let s,i,n,o;e[0]!==t?({className:s,orientation:n,decorative:o,...i}=t,e[0]=t,e[1]=s,e[2]=i,e[3]=n,e[4]=o):(s=e[1],i=e[2],n=e[3],o=e[4]);const a=n===void 0?"horizontal":n,l=o===void 0?!0:o;let c;e[5]!==s?(c=X("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]=c):c=e[6];let d;return e[7]!==l||e[8]!==a||e[9]!==i||e[10]!==c?(d=r.jsx(kp,{"data-slot":"separator-root",decorative:l,orientation:a,className:c,...i}),e[7]=l,e[8]=a,e[9]=i,e[10]=c,e[11]=d):d=e[11],d}function F5(t){const e=B.c(20),{prNumber:s,disabled:i,send:n}=t;let o;e[0]!==s||e[1]!==n?(o=()=>n(nV({prNumber:s})),e[0]=s,e[1]=n,e[2]=o):o=e[2];const a=o;let l;e[3]!==s||e[4]!==n?(l=()=>n(rV({prNumber:s})),e[3]=s,e[4]=n,e[5]=l):l=e[5];const c=l;let d;e[6]!==i||e[7]!==a?(d=r.jsx(ne,{size:"sm",className:"rounded-r-none border-r border-primary-foreground/20",disabled:i,onClick:a,children:"Publish"}),e[6]=i,e[7]=a,e[8]=d):d=e[8];let u;e[9]===Symbol.for("react.memo_cache_sentinel")?(u=r.jsx(kr,{className:"h-3.5 w-3.5"}),e[9]=u):u=e[9];let h;e[10]!==i?(h=r.jsx(ks,{asChild:!0,children:r.jsx(ne,{size:"sm",className:"rounded-l-none px-2",disabled:i,"aria-label":"More actions",children:u})}),e[10]=i,e[11]=h):h=e[11];let f;e[12]!==c?(f=r.jsx(Ns,{align:"end",children:r.jsx(ot,{onClick:c,children:"Review"})}),e[12]=c,e[13]=f):f=e[13];let m;e[14]!==h||e[15]!==f?(m=r.jsxs(js,{children:[h,f]}),e[14]=h,e[15]=f,e[16]=m):m=e[16];let p;return e[17]!==d||e[18]!==m?(p=r.jsxs("div",{className:"inline-flex items-stretch rounded-md",children:[d,m]}),e[17]=d,e[18]=m,e[19]=p):p=e[19],p}const H5=new Set(["failure","timed_out","cancelled","action_required"]);function W5(t){return t.status==="completed"&&H5.has(t.conclusion)}function U5(t){return t.status==="queued"||t.status==="in_progress"}function K5(t){const{branchStatus:e,pr:s,checks:i,reviews:n}=t;if(!e)return null;if(e.workingTreeDirty||e.unpushed>0)return{label:"Save changes",action:"commit-and-push"};if(s?.merged)return!!e.headSha&&!!s.headSha&&e.headSha!==s.headSha?{label:"Submit for review",action:"create-pr"}:null;if(e.aheadOfBase>0){if(s&&s.state==="closed"&&!s.merged)return{label:"Reopen",action:"reopen"};if(!s)return{label:"Submit for review",action:"create-pr"};if((n?.mergeableState??"unknown")==="dirty")return{label:`Sync with ${s.base}`,action:"rebase"};const l=i.filter(W5).map(c=>c.name);return l.length>0?{label:"Fix tests",action:"fix-checks",meta:{failingChecks:l}}:i.some(U5)?{label:"Running tests…",disabled:!0}:n?.draft?{label:"Mark ready",action:"mark-ready"}:(n?.unresolvedConversations??0)>0?{label:"Address feedback",action:"resolve-comments"}:n?.missingRequiredApprovals?{label:"Awaiting review",disabled:!0}:{label:"Publish",action:"merge-split"}}return null}function q5(){return Yi().branchStatus}const G5=6e4,Y5=3e4;function X5(t){const e=B.c(11);let s;e[0]!==t.connectionId||e[1]!==t.orgId?(s={connectionId:t.connectionId,orgId:t.orgId},e[0]=t.connectionId,e[1]=t.orgId,e[2]=s):s=e[2];const i=Me(s),n=t.prNumber??0;let o;e[3]!==t.owner||e[4]!==t.repo||e[5]!==n?(o={method:"get",owner:t.owner,repo:t.repo,pullNumber:n},e[3]=t.owner,e[4]=t.repo,e[5]=n,e[6]=o):o=e[6];const a=!!t.prNumber;let l;return e[7]!==i||e[8]!==o||e[9]!==a?(l={client:i,toolName:"pull_request_read",toolArguments:o,enabled:a,refetchInterval:G5,refetchIntervalInBackground:!1,staleTime:Y5,select:J5},e[7]=i,e[8]=o,e[9]=a,e[10]=l):l=e[10],wi(l)}function J5(t){const e=Zr(t);if(!e)return null;const s=e.mergeable_state??"unknown",i=!!(e.draft??!1),n=Number(e.review_comments??0),o=s==="blocked"&&n>0?n:0;return{draft:i,mergeableState:s,unresolvedConversations:o,missingRequiredApprovals:s==="blocked"&&o===0}}function Q5(t){const e=B.c(38),{virtualMcpId:s}=t,{org:i}=be(),n=ts(s),{currentBranch:o}=es(),a=Zn(),l=n?.metadata?.githubRepo??null,c=q5(),d=l?.connectionId??"",u=l?.owner??"",h=l?.name??"",f=o??null;let m;e[0]!==i.id||e[1]!==d||e[2]!==u||e[3]!==h||e[4]!==f?(m={orgId:i.id,connectionId:d,owner:u,repo:h,branch:f},e[0]=i.id,e[1]=d,e[2]=u,e[3]=h,e[4]=f,e[5]=m):m=e[5];const g=Hf(m).data??null,_=l?.connectionId??"",v=l?.owner??"",x=l?.name??"",b=g&&g.state==="open"?g.number:null;let y;e[6]!==i.id||e[7]!==_||e[8]!==v||e[9]!==x||e[10]!==b?(y={orgId:i.id,connectionId:_,owner:v,repo:x,prNumber:b},e[6]=i.id,e[7]=_,e[8]=v,e[9]=x,e[10]=b,e[11]=y):y=e[11];const C=Uf(y),j=l?.connectionId??"",V=l?.owner??"",w=l?.name??"",k=g&&g.state==="open"?g.number:null;let T;e[12]!==i.id||e[13]!==j||e[14]!==V||e[15]!==w||e[16]!==k?(T={orgId:i.id,connectionId:j,owner:V,repo:w,prNumber:k},e[12]=i.id,e[13]=j,e[14]=V,e[15]=w,e[16]=k,e[17]=T):T=e[17];const I=X5(T);if(!l?.connectionId||!o)return null;let A;e[18]!==c||e[19]!==C.data||e[20]!==g||e[21]!==I.data?(A=K5({branchStatus:c,pr:g,checks:C.data??[],reviews:I.data??null}),e[18]=c,e[19]=C.data,e[20]=g,e[21]=I.data,e[22]=A):A=e[22];const N=A;if(!N)return null;let E;e[23]!==a?(E=$=>a.sendMessage({parts:[{type:"text",text:$}]}),e[23]=a,e[24]=E):E=e[24];const R=E,M=a.isStreaming;let L;e[25]!==o||e[26]!==N||e[27]!==M||e[28]!==g||e[29]!==R?(L=$=>{if(!M)switch($){case"commit-and-push":{R(Xw({branch:o}));return}case"create-pr":{R(Jw({branch:o}));return}case"reopen":{g&&R(Qw({prNumber:g.number}));return}case"rebase":{R(Zw({branch:o}));return}case"fix-checks":{g&&R(tV({prNumber:g.number,failingChecks:N.meta?.failingChecks??[]}));return}case"mark-ready":{g&&R(sV({prNumber:g.number}));return}case"resolve-comments":{g&&R(iV({prNumber:g.number}));return}case"merge-split":return}},e[25]=o,e[26]=N,e[27]=M,e[28]=g,e[29]=R,e[30]=L):L=e[30];const D=L;let P;e[31]===Symbol.for("react.memo_cache_sentinel")?(P=r.jsx(z5,{orientation:"vertical",className:"mx-2 data-[orientation=vertical]:h-5"}),e[31]=P):P=e[31];const O=g?.number;let z;return e[32]!==N||e[33]!==M||e[34]!==D||e[35]!==R||e[36]!==O?(z=r.jsxs(r.Fragment,{children:[P,r.jsx(Z5,{button:N,isStreaming:M,onActivate:D,prNumber:O,send:R})]}),e[32]=N,e[33]=M,e[34]=D,e[35]=R,e[36]=O,e[37]=z):z=e[37],z}function Z5(t){const e=B.c(18),{button:s,isStreaming:i}=t,n=!!s.disabled||i,o=i?"Chat is running":null;if(s.action==="merge-split"&&t.prNumber!=null){let u;e[0]!==n||e[1]!==t.prNumber||e[2]!==t.send?(u=r.jsx(F5,{prNumber:t.prNumber,disabled:n,send:t.send}),e[0]=n,e[1]=t.prNumber,e[2]=t.send,e[3]=u):u=e[3];let h;return e[4]!==u||e[5]!==o?(h=r.jsx(gh,{label:o,children:u}),e[4]=u,e[5]=o,e[6]=h):h=e[6],h}const a=s.disabled?"outline":"default";let l;e[7]!==s.action||e[8]!==t?(l=()=>t.onActivate(s.action),e[7]=s.action,e[8]=t,e[9]=l):l=e[9];let c;e[10]!==s.label||e[11]!==n||e[12]!==a||e[13]!==l?(c=r.jsx(ne,{size:"sm",variant:a,disabled:n,onClick:l,children:s.label}),e[10]=s.label,e[11]=n,e[12]=a,e[13]=l,e[14]=c):c=e[14];let d;return e[15]!==c||e[16]!==o?(d=r.jsx(gh,{label:o,children:c}),e[15]=c,e[16]=o,e[17]=d):d=e[17],d}function gh(t){const e=B.c(9),{label:s,children:i}=t;if(!s){let l;return e[0]!==i?(l=r.jsx(r.Fragment,{children:i}),e[0]=i,e[1]=l):l=e[1],l}let n;e[2]!==i?(n=r.jsx(tt,{asChild:!0,children:r.jsx("span",{children:i})}),e[2]=i,e[3]=n):n=e[3];let o;e[4]!==s?(o=r.jsx(st,{children:s}),e[4]=s,e[5]=o):o=e[5];let a;return e[6]!==n||e[7]!==o?(a=r.jsx(Mi,{children:r.jsxs(it,{children:[n,o]})}),e[6]=n,e[7]=o,e[8]=a):a=e[8],a}function ek(t){const e=B.c(2),{virtualMcp:s}=t;if(!!!(s.metadata?.githubRepo??null)?.connectionId)return null;let o;return e[0]!==s.id?(o=r.jsx(ze.Right,{children:r.jsx(Q5,{virtualMcpId:s.id})}),e[0]=s.id,e[1]=o):o=e[1],o}const Ii=S.createContext(null);function ac(){return S.use(Ii)}function _h(t){const e=B.c(8),{children:s,variant:i}=t,{taskId:n}=es();let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=r.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]=o):o=e[0];let a;e[1]===Symbol.for("react.memo_cache_sentinel")?(a=r.jsx(De.Skeleton,{}),e[1]=a):a=e[1];let l;e[2]!==s||e[3]!==i?(l=s??r.jsx(qu,{variant:i}),e[2]=s,e[3]=i,e[4]=l):l=e[4];let c;return e[5]!==l||e[6]!==n?(c=r.jsx(Cs,{fallback:o,children:r.jsx(S.Suspense,{fallback:a,children:r.jsx(De.ActiveTaskProvider,{taskId:n,children:l})})}),e[5]=l,e[6]=n,e[7]=c):c=e[7],c}function xh(t){const e=B.c(3),{onNewTaskRef:s,createNewTask:i}=t;let n;return e[0]!==i||e[1]!==s?(n=()=>(s.current=i,()=>{s.current=null}),e[0]=i,e[1]=s,e[2]=n):n=e[2],S.useLayoutEffect(n),null}function tk(t){const e=B.c(3),{onOpenSidebar:s}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx(Dg,{size:20}),e[0]=i):i=e[0];let n;return e[1]!==s?(n=r.jsx("div",{className:"shrink-0 flex items-center justify-between px-3 h-12 bg-background border-b border-border",children:r.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]=n):n=e[2],n}function vh(t){const e=B.c(16),{virtualMcpId:s,hasActiveGithubRepo:i,vmMap:n,children:o}=t,{org:a}=be(),{currentBranch:l}=es(),{data:c}=St.useSession(),d=c?.user?.id,u=d&&l?n?.[d]?.[l]??null:null;let h;e[0]!==u?(h=u?.previewUrl?u.previewUrl.replace(/\/$/,""):null,e[0]=u,e[1]=h):h=e[1];const f=h;let m;e[2]!==a.id?(m={connectionId:Wt,orgId:a.id},e[2]=a.id,e[3]=m):m=e[3];const p=Me(m),{mutate:g}=ql(p);let _;e[4]===Symbol.for("react.memo_cache_sentinel")?(_=new Set,e[4]=_):_=e[4];const v=S.useRef(_);let x,b;e[5]!==l||e[6]!==i||e[7]!==g||e[8]!==d||e[9]!==s||e[10]!==n?(x=()=>{i&&d&&l&&(n?.[d]?.[l]||v.current.has(l)||(v.current.add(l),g({virtualMcpId:s,branch:l},{onError:sk})))},b=[i,d,l,n,s,g],e[5]=l,e[6]=i,e[7]=g,e[8]=d,e[9]=s,e[10]=n,e[11]=x,e[12]=b):(x=e[11],b=e[12]),S.useEffect(x,b);let y;return e[13]!==o||e[14]!==f?(y=r.jsx(IV,{daemonBaseUrl:f,children:o}),e[13]=o,e[14]=f,e[15]=y):y=e[15],y}function sk(t){console.error("[auto-start-vm] failed:",t)}function bh(){const t=B.c(106),e=Rs(),s=Ke(),{org:i}=be(),n=RS()?.tasksOpen??!1;I_(i.id);let o;t[0]===Symbol.for("react.memo_cache_sentinel")?(o={strict:!1},t[0]=o):o=t[0];const a=$r(o),l=a.org??"";let c;t[1]===Symbol.for("react.memo_cache_sentinel")?(c={strict:!1},t[1]=c):c=t[1];const d=vi(c);let u;t[2]!==i.id||t[3]!==d.virtualmcpid?(u=d.virtualmcpid??io(i.id).id,t[2]=i.id,t[3]=d.virtualmcpid,t[4]=u):u=t[4];const h=u;let f;t[5]!==i.id?(f=hl(i.id),t[5]=i.id,t[6]=f):f=t[6];const m=h===f,p=!m,g=U_(a.taskId??"",h),_=ts(h),v=_?.metadata?.ui?.layout??null;let x;t[7]!==v?(x=v?{defaultMainView:v.defaultMainView??null,chatDefaultOpen:v.chatDefaultOpen??null}:null,t[7]=v,t[8]=x):x=t[8];const b=x;let y;t[9]!==_?(y=_&&Fs(_),t[9]=_,t[10]=y):y=t[10];const C=!!y;let j;t[11]!==p||t[12]!==l||t[13]!==h?(j={virtualMcpId:h,orgSlug:l,isAgentRoute:p},t[11]=p,t[12]=l,t[13]=h,t[14]=j):j=t[14];const V=AS(b,j),{setOpenMobile:w,openMobile:k}=qr(),T=w,I=S.useRef(null);let A,N;t[15]===Symbol.for("react.memo_cache_sentinel")?(A=()=>{const K=U=>{Ph(U)&&U.shiftKey&&U.code==="KeyS"&&!U.repeat&&(U.preventDefault(),I.current?.())};return document.addEventListener("keydown",K),()=>document.removeEventListener("keydown",K)},N=[],t[15]=A,t[16]=N):(A=t[15],N=t[16]),S.useEffect(A,N);const E=h;let R;t[17]!==_||t[18]!==h?(R={virtualMcpId:h,entity:_},t[17]=_,t[18]=h,t[19]=R):R=t[19];const M=R;if(g.status==="creating"||g.status==="loading"){let K;t[20]===Symbol.for("react.memo_cache_sentinel")?(K=r.jsx("div",{className:"flex-1 min-h-0 pr-1.5 pb-1.5 overflow-hidden",children:r.jsxs("div",{className:"flex h-full items-center justify-center bg-background card-shadow rounded-[0.75rem] text-sm text-muted-foreground",children:[r.jsx(Ee,{className:"size-4 animate-spin mr-2"}),"Creating task…"]})}),t[20]=K):K=t[20];let U;return t[21]!==M?(U=r.jsx(Ii,{value:M,children:K}),t[21]=M,t[22]=U):U=t[22],U}if(g.status==="error"){let K;t[23]===Symbol.for("react.memo_cache_sentinel")?(K=r.jsx("div",{className:"font-medium",children:"Task unavailable"}),t[23]=K):K=t[23];let U;t[24]!==g.error.message?(U=r.jsx("div",{className:"flex-1 min-h-0 pr-1.5 pb-1.5 overflow-hidden",children:r.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:[K,r.jsx("div",{className:"text-muted-foreground",children:g.error.message})]})}),t[24]=g.error.message,t[25]=U):U=t[25];let te;return t[26]!==M||t[27]!==U?(te=r.jsx(Ii,{value:M,children:U}),t[26]=M,t[27]=U,t[28]=te):te=t[28],te}if(!_){let K;t[29]===Symbol.for("react.memo_cache_sentinel")?(K=r.jsx(ri,{size:48,className:"text-muted-foreground"}),t[29]=K):K=t[29];const U=`The agent "${h}" does not exist in this organization.`;let te;t[30]!==s||t[31]!==l?(te=r.jsx(ne,{variant:"outline",onClick:()=>s({to:"/$org",params:{org:l}}),children:"Go to organization home"}),t[30]=s,t[31]=l,t[32]=te):te=t[32];let Y;t[33]!==U||t[34]!==te?(Y=r.jsx("div",{className:"flex-1 min-h-0 pr-1.5 pb-1.5 overflow-hidden",children:r.jsx("div",{className:"flex flex-col h-full bg-background overflow-hidden card-shadow rounded-[0.75rem]",children:r.jsx(Oi,{image:K,title:"Agent not found",description:U,actions:te})})}),t[33]=U,t[34]=te,t[35]=Y):Y=t[35];let J;return t[36]!==M||t[37]!==Y?(J=r.jsx(Ii,{value:M,children:Y}),t[36]=M,t[37]=Y,t[38]=J):J=t[38],J}if(e){let K;t[39]===Symbol.for("react.memo_cache_sentinel")?(K=r.jsx(C_,{className:"sr-only",children:"Navigation"}),t[39]=K):K=t[39];let U;t[40]!==T?(U=r.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:r.jsx(SS,{onClose:()=>T(!1)})}),t[40]=T,t[41]=U):U=t[41];let te;t[42]===Symbol.for("react.memo_cache_sentinel")?(te=r.jsx("div",{className:"flex-1 min-w-0 overflow-hidden",children:r.jsx(Xu,{})}),t[42]=te):te=t[42];let Y;t[43]!==U?(Y=r.jsxs(j_,{side:"left",hideCloseButton:!0,className:"w-[calc(100vw-3rem)] sm:max-w-md! p-0",children:[K,r.jsxs("div",{className:"flex h-full",children:[U,te]})]}),t[43]=U,t[44]=Y):Y=t[44];let J;t[45]!==k||t[46]!==T||t[47]!==Y?(J=r.jsx(k_,{open:k,onOpenChange:T,children:Y}),t[45]=k,t[46]=T,t[47]=Y,t[48]=J):J=t[48];const ie=J,ue=_?.metadata?.vmMap;let de;t[49]!==V.createNewTask?(de=r.jsx(xh,{onNewTaskRef:I,createNewTask:V.createNewTask}),t[49]=V.createNewTask,t[50]=de):de=t[50];let xe;t[51]!==T?(xe=r.jsx(tk,{onOpenSidebar:()=>T(!0)}),t[51]=T,t[52]=xe):xe=t[52];const oe=m?"home":void 0;let he;t[53]!==oe?(he=r.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:r.jsx(_h,{variant:oe})}),t[53]=oe,t[54]=he):he=t[54];let me;t[55]!==C||t[56]!==ie||t[57]!==ue||t[58]!==de||t[59]!==xe||t[60]!==he||t[61]!==h?(me=r.jsxs(vh,{virtualMcpId:h,hasActiveGithubRepo:C,vmMap:ue,children:[de,xe,he,ie]}),t[55]=C,t[56]=ie,t[57]=ue,t[58]=de,t[59]=xe,t[60]=he,t[61]=h,t[62]=me):me=t[62];let fe;t[63]!==E||t[64]!==me?(fe=r.jsx("div",{className:"flex flex-col flex-1 bg-background min-h-0",children:r.jsx(De.Provider,{virtualMcpId:E,children:me},E)}),t[63]=E,t[64]=me,t[65]=fe):fe=t[65];let le;return t[66]!==M||t[67]!==fe?(le=r.jsx(Ii,{value:M,children:fe}),t[66]=M,t[67]=fe,t[68]=le):le=t[68],le}const L=n?void 0:V.createNewTask;let D;t[69]!==m||t[70]!==V.chatOpen||t[71]!==V.toggleChat||t[72]!==L?(D=r.jsx(ze.Toggles,{children:r.jsx(T5,{isDecopilot:m,chatOpen:V.chatOpen,toggleChat:V.toggleChat,onNewTask:L})}),t[69]=m,t[70]=V.chatOpen,t[71]=V.toggleChat,t[72]=L,t[73]=D):D=t[73];let P;t[74]!==m||t[75]!==V.taskId||t[76]!==h?(P=!m&&r.jsx(ze.Tabs,{children:r.jsx($5,{virtualMcpId:h,taskId:V.taskId})}),t[74]=m,t[75]=V.taskId,t[76]=h,t[77]=P):P=t[77];const O=_?.metadata?.vmMap;let z;t[78]!==_||t[79]!==m?(z=!m&&r.jsx(ek,{virtualMcp:_}),t[78]=_,t[79]=m,t[80]=z):z=t[80];let $;t[81]!==V.createNewTask?($=r.jsx(xh,{onNewTaskRef:I,createNewTask:V.createNewTask}),t[81]=V.createNewTask,t[82]=$):$=t[82];const W=m?"home":void 0;let F;t[83]!==W?(F=r.jsx(_h,{variant:W}),t[83]=W,t[84]=F):F=t[84];let G;t[85]!==V.chatOpen||t[86]!==V.mainOpen||t[87]!==V.taskId||t[88]!==F||t[89]!==h?(G=r.jsx(R5,{virtualMcpId:h,taskId:V.taskId,chatOpen:V.chatOpen,mainOpen:V.mainOpen,chatContent:F}),t[85]=V.chatOpen,t[86]=V.mainOpen,t[87]=V.taskId,t[88]=F,t[89]=h,t[90]=G):G=t[90];let q;t[91]!==C||t[92]!==O||t[93]!==z||t[94]!==$||t[95]!==G||t[96]!==h?(q=r.jsxs(vh,{virtualMcpId:h,hasActiveGithubRepo:C,vmMap:O,children:[z,$,G]}),t[91]=C,t[92]=O,t[93]=z,t[94]=$,t[95]=G,t[96]=h,t[97]=q):q=t[97];let H;t[98]!==E||t[99]!==P||t[100]!==q?(H=r.jsxs(De.Provider,{virtualMcpId:E,children:[P,q]},E),t[98]=E,t[99]=P,t[100]=q,t[101]=H):H=t[101];let ee;return t[102]!==M||t[103]!==D||t[104]!==H?(ee=r.jsxs(Ii,{value:M,children:[D,H]}),t[102]=M,t[103]=D,t[104]=H,t[105]=ee):ee=t[105],ee}function X4(){const t=B.c(5),e=Rs();let s;t[0]===Symbol.for("react.memo_cache_sentinel")?(s={"--sidebar-width-icon":"3.5rem"},t[0]=s):s=t[0];let i;t[1]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx(yS,{}),t[1]=i):i=t[1];let n;t[2]===Symbol.for("react.memo_cache_sentinel")?(n={background:"transparent",containerType:"inline-size"},t[2]=n):n=t[2];let o;return t[3]!==e?(o=r.jsx(S_,{defaultOpen:!1,children:r.jsx("div",{className:"flex flex-col h-dvh overflow-hidden",children:r.jsxs(w_,{className:"flex-1 bg-sidebar",style:s,children:[i,r.jsx(V_,{className:"flex flex-col",style:n,children:e?r.jsx(S.Suspense,{fallback:r.jsx("div",{className:"flex-1 flex items-center justify-center",children:r.jsx(Ee,{size:20,className:"animate-spin text-muted-foreground"})}),children:r.jsx(bh,{})}):r.jsx(S.Suspense,{fallback:r.jsx("div",{className:"flex-1 flex items-center justify-center",children:r.jsx(Ee,{size:20,className:"animate-spin text-muted-foreground"})}),children:r.jsx(ES,{children:r.jsxs(ze,{children:[r.jsxs(ze.Header,{children:[r.jsxs(ze.LeftColumn,{children:[r.jsx(ze.Nav,{}),r.jsx(ze.TogglesSlot,{})]}),r.jsx(ze.CenterSlot,{}),r.jsxs(ze.RightColumn,{children:[r.jsx(ze.TabsSlot,{}),r.jsx(ze.RightSlot,{})]})]}),r.jsxs("div",{className:"flex-1 min-h-0 flex flex-row",children:[r.jsx(YS,{}),r.jsx("div",{className:"flex-1 min-w-0 flex flex-col",children:r.jsx(S.Suspense,{fallback:r.jsx("div",{className:"flex-1 flex items-center justify-center",children:r.jsx(Ee,{size:20,className:"animate-spin text-muted-foreground"})}),children:r.jsx(bh,{})})})]})]})})})})]})})}),t[3]=e,t[4]=o):o=t[4],o}export{X4 as default,ac as useInsetContext};
450
+ </message>`}]}}))},L=e.models?.credentialId||m||"",D=e.models?.thinking?.id||p?.modelId||"",P=Hi({defaultValues:{name:e.name,active:e.active,credential_id:L,model_id:D}}),O=P.watch("active"),z=P.watch("credential_id"),$=P.watch("model_id"),{models:W,isLoading:F}=tu(z||void 0),G=W.find(oe=>oe.modelId===$)??null,q=S.useRef(null),H=S.useRef(new Set),ee=S.useRef(0),K=S.useRef(null),U=3e4,te=()=>{K.current&&(clearTimeout(K.current),K.current=null),q.current!==null&&(se("automation_updated",{automation_id:t,agent_id:o,fields:Array.from(H.current),save_count:ee.current,edit_duration_ms:Date.now()-q.current}),q.current=null,H.current=new Set,ee.current=0)},Y=async()=>{if(!(Object.keys(P.formState.dirtyFields).length>0)&&!R.current)return!0;const he=Object.keys(P.formState.dirtyFields),me=R.current;R.current=!1;const fe=P.getValues();try{const le=fe.credential_id&&fe.model_id?fe.credential_id:"",ve=fe.credential_id&&fe.model_id?fe.model_id:"",Ce={id:t,name:fe.name,active:fe.active,agent:{id:o},models:{credentialId:le,thinking:{id:ve}},messages:Ip(b),temperature:0};await l.mutateAsync(Ce),q.current===null&&(q.current=Date.now());for(const Te of he)H.current.add(Te);return me&&H.current.add("messages"),ee.current+=1,K.current&&clearTimeout(K.current),K.current=setTimeout(te,U),P.reset({...fe,credential_id:le,model_id:ve}),!0}catch{return R.current=!0,!1}},J=()=>{E.current&&clearTimeout(E.current),E.current=setTimeout(()=>{Y()},1e3)},ie=async()=>(E.current&&clearTimeout(E.current),Y()),ue=oe=>{if(y(oe),!N.current){N.current=!0;return}R.current=!0,J()},de=S.useRef(!1);de.current||(de.current=!0,P.watch(()=>{J()}));const xe=async()=>{se("automation_test_clicked",{automation_id:t,agent_id:o});const oe=await ie();if(te(),!oe)return;if(!b){pe.error("No instructions configured for this automation");return}G&&z&&f({...G,keyId:z}),v({..._,toolApprovalLevel:"auto"});const he=cc(b);h({message:{tiptapDoc:b,parts:he},virtualMcpId:o||void 0})};return r.jsxs(r.Fragment,{children:[i&&r.jsx("div",{className:"flex items-center pb-4 shrink-0",children:r.jsxs(ne,{variant:"ghost",size:"sm",onClick:i,children:[r.jsx(xl,{size:14}),"Back to list"]})}),r.jsxs("div",{className:"flex flex-col gap-8",children:[r.jsxs("div",{className:"flex flex-col gap-1.5",children:[r.jsxs("div",{className:"flex items-center justify-between gap-4",children:[r.jsx(bt,{...P.register("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"}}),n&&r.jsx(ne,{variant:"ghost",size:"icon",className:"text-muted-foreground hover:text-destructive shrink-0",onClick:n,children:r.jsx(ha,{size:14})})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(Ai,{control:P.control,name:"active",render:({field:oe})=>r.jsx(da,{checked:oe.value,onCheckedChange:he=>{oe.onChange(he),setTimeout(()=>ie(),0)},className:"cursor-pointer"})}),r.jsx("span",{className:"text-sm text-muted-foreground",children:O?"Active":"Inactive"}),r.jsx("span",{className:"text-muted-foreground/50 text-sm",children:"·"}),r.jsx(P_,{id:e.created_by,size:"2xs",className:"text-sm text-muted-foreground"})]})]}),r.jsxs("div",{className:"flex flex-col gap-2.5",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("span",{className:"text-xs font-semibold text-muted-foreground/60",children:"Starter"}),r.jsx(_5,{automationId:t,open:C,onOpenChange:j,onCustomSelect:()=>{w(!0),A(!1),T("")},onEventSelect:()=>{A(!0),w(!1)}})]}),e.triggers.length===0&&!V?r.jsx("div",{className:"rounded-lg border border-dashed border-border px-4 py-6 text-center",children:r.jsxs("p",{className:"text-sm text-muted-foreground",children:["When should this automation run?"," ",r.jsx("button",{type:"button",className:"text-foreground underline underline-offset-2 cursor-pointer hover:text-foreground/80 transition-colors",onClick:()=>j(!0),children:"Add a starter"})," ","to get going."]})}):r.jsx("div",{className:"flex flex-col gap-2",children:e.triggers.map(oe=>r.jsx(x5,{trigger:oe,automationId:t,connectionName:oe.connection_id?u.get(oe.connection_id):void 0},oe.id))}),V&&r.jsxs("div",{className:"flex items-center gap-2.5 px-3 py-2.5 rounded-lg border border-border bg-background group",children:[r.jsx(_r,{size:14,className:"text-muted-foreground shrink-0"}),r.jsx("input",{type:"text",value:k,onChange:oe=>T(oe.target.value),onBlur:async()=>{const oe=k.trim();if(!(!oe||!Vr(oe)))try{await c.mutateAsync({automation_id:t,type:"cron",cron_expression:oe}),se("automation_trigger_added",{automation_id:t,trigger_type:"cron"}),pe.success("Starter added"),w(!1),T("")}catch{pe.error("Failed to add starter")}},onKeyDown:async oe=>{const he=k.trim();oe.key==="Enter"&&he&&Vr(he)&&oe.target.blur(),oe.key==="Escape"&&(w(!1),T(""))},placeholder:"0 9 * * 1-5",className:"flex-1 text-sm font-mono bg-transparent outline-none placeholder:text-muted-foreground/40",autoFocus:!0}),k&&!Vr(k)&&r.jsx("span",{className:"text-xs text-muted-foreground/60 shrink-0",children:"invalid"}),c.isPending&&r.jsx(Ee,{size:13,className:"animate-spin text-muted-foreground shrink-0"}),r.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:()=>{w(!1),T("")},children:r.jsx(ii,{size:13})})]}),I&&r.jsx(S.Suspense,{fallback:r.jsxs("div",{className:"flex items-center gap-2 px-3 py-3 rounded-lg border border-border bg-background",children:[r.jsx(Ee,{size:13,className:"animate-spin text-muted-foreground"}),r.jsx("span",{className:"text-sm text-muted-foreground",children:"Loading connections..."})]}),children:r.jsx(b5,{automationId:t,onDone:()=>A(!1)})})]}),r.jsxs("div",{className:"flex flex-col gap-2.5",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("span",{className:"text-xs font-semibold text-muted-foreground/60",children:"Instructions"}),r.jsxs(ne,{variant:"outline",size:"sm",className:"h-7 gap-1.5 px-2 text-xs",disabled:!b,onClick:M,children:[r.jsx(_l,{size:13}),"Improve"]})]}),r.jsx(Wu,{tiptapDoc:b,setTiptapDoc:ue,placeholder:"What should this automation do?",children:r.jsxs("div",{className:"rounded-xl border border-border min-h-[120px] flex flex-col",children:[r.jsx(Uu,{virtualMcpId:o||null,className:"max-h-[45vh]"}),r.jsxs("div",{className:"flex items-center justify-end gap-1.5 p-2.5",children:[r.jsx(iu,{model:G,isLoading:F,credentialId:z||null,onCredentialChange:oe=>{P.setValue("credential_id",oe??"",{shouldDirty:!0}),P.setValue("model_id","",{shouldDirty:!0})},onModelChange:oe=>P.setValue("model_id",oe.modelId,{shouldDirty:!0}),placeholder:"Model"}),r.jsxs(it,{children:[r.jsx(tt,{asChild:!0,children:r.jsxs(ne,{type:"button",variant:"default",className:"h-8 gap-1.5 rounded-md px-3 text-sm font-medium",onClick:xe,disabled:!o,children:[r.jsx(Fh,{size:16}),"Test"]})}),r.jsx(st,{children:"Test Automation"})]})]})]})})]})]})]})}function C5(t){const e=B.c(6),{tabId:s,virtualMcpId:i}=t;let n;e[0]!==s?(n=Ih(s),e[0]=s,e[1]=n):n=e[1];const o=n;if(!o)return null;let a;e[2]===Symbol.for("react.memo_cache_sentinel")?(a=r.jsx("div",{className:"flex-1 flex items-center justify-center",children:r.jsx(Ee,{size:20,className:"animate-spin text-muted-foreground"})}),e[2]=a):a=e[2];let l;return e[3]!==o.id||e[4]!==i?(l=r.jsx(hs,{children:r.jsx(hs.Content,{children:r.jsx(hs.Body,{children:r.jsx(S.Suspense,{fallback:a,children:r.jsx(j5,{id:o.id,virtualMcpId:i})})})})}),e[3]=o.id,e[4]=i,e[5]=l):l=e[5],l}function j5(t){const e=B.c(9),{id:s,virtualMcpId:i}=t,n=Ke(),{data:o,isLoading:a}=B_(s);let l;e[0]!==n?(l=()=>n({to:".",search:k5,replace:!0}),e[0]=n,e[1]=l):l=e[1];const c=l;if(a){let u;return e[2]===Symbol.for("react.memo_cache_sentinel")?(u=r.jsx("div",{className:"flex-1 flex items-center justify-center",children:r.jsx(Ee,{size:20,className:"animate-spin text-muted-foreground"})}),e[2]=u):u=e[2],u}if(!o){let u;return e[3]===Symbol.for("react.memo_cache_sentinel")?(u=r.jsx("div",{className:"flex-1 flex items-center justify-center text-sm text-muted-foreground",children:"Automation not found"}),e[3]=u):u=e[3],u}let d;return e[4]!==o||e[5]!==s||e[6]!==c||e[7]!==i?(d=r.jsx(V5,{automationId:s,automation:o,virtualMcpId:i,onBack:c}),e[4]=o,e[5]=s,e[6]=c,e[7]=i,e[8]=d):d=e[8],d}function k5(t){return{...t,main:"automations"}}function N5(t){const e=B.c(19),{virtualMcpId:s}=t,i=Ke(),{data:n}=O_(s),o=n===void 0?[]:n,{create:a}=Yr(),[l,c]=S.useState(""),d=l.toLowerCase(),u=o.filter(k=>k.name.toLowerCase().includes(d));let h;e[0]!==i?(h=k=>i({to:".",search:T=>({...T,main:"automation:"+k}),replace:!0}),e[0]=i,e[1]=h):h=e[1];const f=h,m=async()=>{if(a.isPending)return;se("automation_new_clicked",{virtual_mcp_id:s,existing_count:o.length});const k=await a.mutateAsync(z_(s));f(k.id)},p=hs,g=hs,_=hs;let v;e[2]===Symbol.for("react.memo_cache_sentinel")?(v=r.jsx(Qt,{size:14}),e[2]=v):v=e[2];let x;e[3]!==a.isPending||e[4]!==m?(x=r.jsx(hs.Title,{actions:r.jsxs(ne,{size:"sm",onClick:m,disabled:a.isPending,children:[v,"New automation"]}),children:"Automations"}),e[3]=a.isPending,e[4]=m,e[5]=x):x=e[5];const b=o.length>0&&r.jsx(F_,{value:l,onChange:c,placeholder:"Search automations...",className:"w-full md:w-[375px]"});let y;e[6]!==x||e[7]!==b?(y=r.jsxs("div",{className:"flex flex-col gap-6",children:[x,b]}),e[6]=x,e[7]=b,e[8]=y):y=e[8];const C=o.length===0?r.jsx("div",{className:"flex items-center justify-center py-20",children:r.jsx(Oi,{image:r.jsx($i,{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:r.jsxs(ne,{size:"sm",onClick:m,disabled:a.isPending,children:[r.jsx(Qt,{size:14}),"New automation"]})})}):u.length===0?r.jsx("div",{className:"flex items-center justify-center py-20",children:r.jsx(Oi,{image:r.jsx($i,{size:48,className:"text-muted-foreground"}),title:"No automations found",description:`No automations match "${l}"`})}):r.jsx("div",{className:"mt-6 rounded-xl border border-border overflow-hidden",children:u.map(k=>r.jsx($_,{automation:k,onClick:()=>f(k.id)},k.id))});let j;e[9]!==_.Body||e[10]!==y||e[11]!==C?(j=r.jsxs(_.Body,{children:[y,C]}),e[9]=_.Body,e[10]=y,e[11]=C,e[12]=j):j=e[12];let V;e[13]!==j||e[14]!==g.Content?(V=r.jsx(g.Content,{children:j}),e[13]=j,e[14]=g.Content,e[15]=V):V=e[15];let w;return e[16]!==p||e[17]!==V?(w=r.jsx(p,{children:V}),e[16]=p,e[17]=V,e[18]=w):w=e[18],w}function A5(t){const e=B.c(3),{virtualMcpId:s}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx("div",{className:"flex-1 flex items-center justify-center",children:r.jsx(Ee,{size:20,className:"animate-spin text-muted-foreground"})}),e[0]=i):i=e[0];let n;return e[1]!==s?(n=r.jsx(S.Suspense,{fallback:i,children:r.jsx(N5,{virtualMcpId:s})}),e[1]=s,e[2]=n):n=e[2],n}const mh=S.lazy(()=>jp(()=>import("./project-app-view-Cgxq8Z9m.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])).then(t=>({default:t.AppViewContent})));function E5(t){const e=B.c(35),{taskId:s,virtualMcpId:i}=t;let n;e[0]!==s||e[1]!==i?(n={virtualMcpId:i,taskId:s},e[0]=s,e[1]=i,e[2]=n):n=e[2];const{activeTab:o,layoutTabs:a,automationTabParsed:l}=zf(n);if(Yp(o)){let m;return e[3]!==i?(m=r.jsx(_d,{virtualMcpId:i}),e[3]=i,e[4]=m):m=e[4],m}if(o==="git"){let m;return e[5]!==i?(m=r.jsx(gV,{virtualMcpId:i}),e[5]=i,e[6]=m):m=e[6],m}if(o==="automations"){let m;return e[7]!==i?(m=r.jsx(A5,{virtualMcpId:i}),e[7]=i,e[8]=m):m=e[8],m}if(o==="env"){let m;return e[9]!==i?(m=r.jsx(h5,{virtualMcpId:i}),e[9]=i,e[10]=m):m=e[10],m}if(o==="preview"){let m;return e[11]!==i?(m=r.jsx(qV,{virtualMcpId:i}),e[11]=i,e[12]=m):m=e[12],m}if(l){let m;return e[13]!==o||e[14]!==i?(m=r.jsx(C5,{tabId:o,virtualMcpId:i}),e[13]=o,e[14]=i,e[15]=m):m=e[15],m}let c;e[16]!==o?(c=Xp(o),e[16]=o,e[17]=c):c=e[17];const d=c;if(d){let m;e[18]===Symbol.for("react.memo_cache_sentinel")?(m=r.jsx("div",{className:"h-full w-full flex items-center justify-center",children:r.jsx(Ee,{size:20,className:"animate-spin text-muted-foreground"})}),e[18]=m):m=e[18];let p;return e[19]!==o||e[20]!==d.connectionId||e[21]!==d.toolName?(p=r.jsx(S.Suspense,{fallback:m,children:r.jsx(mh,{connectionId:d.connectionId,toolName:d.toolName},o)}),e[19]=o,e[20]=d.connectionId,e[21]=d.toolName,e[22]=p):p=e[22],p}let u;if(e[23]!==o||e[24]!==a){let m;e[26]!==o?(m=p=>p.id===o,e[26]=o,e[27]=m):m=e[27],u=a.find(m),e[23]=o,e[24]=a,e[25]=u}else u=e[25];const h=u;if(h){let m;e[28]===Symbol.for("react.memo_cache_sentinel")?(m=r.jsx("div",{className:"h-full w-full flex items-center justify-center",children:r.jsx(Ee,{size:20,className:"animate-spin text-muted-foreground"})}),e[28]=m):m=e[28];let p;return e[29]!==o||e[30]!==h.id||e[31]!==h.view.appId?(p=r.jsx(S.Suspense,{fallback:m,children:r.jsx(mh,{connectionId:h.view.appId,toolName:h.id},o)}),e[29]=o,e[30]=h.id,e[31]=h.view.appId,e[32]=p):p=e[32],p}let f;return e[33]!==i?(f=r.jsx(_d,{virtualMcpId:i}),e[33]=i,e[34]=f):f=e[34],f}function I5(t){const e=B.c(7),{children:s,defaultSize:i}=t,[,n]=S.useTransition();let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=ol.decoChatPanelWidth(),e[0]=o):o=e[0];const[a,l]=nl(o,45),c=i>0&&i<100?a:i;let d;e[1]!==l?(d=f=>n(()=>{f>0&&f<100&&l(f)}),e[1]=l,e[2]=d):d=e[2];const u=d;let h;return e[3]!==s||e[4]!==c||e[5]!==u?(h=r.jsx(ru,{defaultSize:c,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]=c,e[5]=u,e[6]=h):h=e[6],h}function R5(t){const e=B.c(31),{virtualMcpId:s,taskId:i,chatOpen:n,mainOpen:o,variant:a,chatContent:l}=t;let c;e[0]!==n||e[1]!==o?(c=ud(n,o),e[0]=n,e[1]=o,e[2]=c):c=e[2];const d=c;let u;e[3]===Symbol.for("react.memo_cache_sentinel")?(u=ol.decoChatPanelWidth(),e[3]=u):u=e[3];const[h]=nl(u,45),f=S.useRef(null);let m,p;e[4]!==n||e[5]!==o||e[6]!==h?(m=()=>{const I=f.current;if(!I)return;const A=ud(n,o),N=A.chat>0&&A.chat<100?h:A.chat,E=A.chat>0&&A.chat<100?100-h:A.main;I.setLayout([N,E])},p=[n,o,h],e[4]=n,e[5]=o,e[6]=h,e[7]=m,e[8]=p):(m=e[7],p=e[8]),S.useEffect(m,p);const g=`${s}-${i}`;let _;e[9]===Symbol.for("react.memo_cache_sentinel")?(_={overflow:"visible"},e[9]=_):_=e[9];let v;e[10]!==l||e[11]!==a?(v=l??r.jsx(qu,{variant:a}),e[10]=l,e[11]=a,e[12]=v):v=e[12];let x;e[13]!==v?(x=r.jsx("div",{className:"h-full p-0.5 pt-0.25",children:r.jsx("div",{className:"h-full bg-background rounded-[0.75rem] overflow-hidden card-shadow",children:v})}),e[13]=v,e[14]=x):x=e[14];let b;e[15]!==d.chat||e[16]!==x?(b=r.jsx(I5,{defaultSize:d.chat,children:x}),e[15]=d.chat,e[16]=x,e[17]=b):b=e[17];let y;e[18]===Symbol.for("react.memo_cache_sentinel")?(y=r.jsx(Yg,{className:"bg-sidebar"}),e[18]=y):y=e[18];const C=d.main;let j;e[19]===Symbol.for("react.memo_cache_sentinel")?(j={overflow:"visible"},e[19]=j):j=e[19];let V;e[20]===Symbol.for("react.memo_cache_sentinel")?(V=X("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[20]=V):V=e[20];let w;e[21]!==i||e[22]!==s?(w=r.jsx("div",{className:"h-full p-0.5 pt-0.25",children:r.jsx("div",{className:V,children:r.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:r.jsx(E5,{taskId:i,virtualMcpId:s})})})}),e[21]=i,e[22]=s,e[23]=w):w=e[23];let k;e[24]!==d.main||e[25]!==w?(k=r.jsx(ru,{className:"min-w-0 flex flex-col",order:2,defaultSize:C,style:j,collapsible:!0,collapsedSize:0,minSize:20,children:w}),e[24]=d.main,e[25]=w,e[26]=k):k=e[26];let T;return e[27]!==k||e[28]!==g||e[29]!==b?(T=r.jsxs(Xg,{ref:f,direction:"horizontal",className:"flex-1 min-h-0 pb-1 pr-1 pl-0 pt-0",style:_,children:[b,y,k]},g),e[27]=k,e[28]=g,e[29]=b,e[30]=T):T=e[30],T}const ta="flex size-7 shrink-0 items-center justify-center rounded-md transition-colors",ph="bg-sidebar-accent text-sidebar-foreground",sa="text-sidebar-foreground/60 hover:bg-sidebar-accent hover:text-sidebar-foreground";function T5(t){const e=B.c(38),{isDecopilot:s,chatOpen:i,toggleChat:n,onNewTask:o}=t,{tasksOpen:a,toggleTasks:l}=Of(),c=!!o;let d;e[0]!==a||e[1]!==l?(d=()=>{se("agent_toolbar_toggled",{button:"tasks",next_state:a?"closed":"open"}),l()},e[0]=a,e[1]=l,e[2]=d):d=e[2];const u=a?ph:sa;let h;e[3]!==u?(h=X(ta,u),e[3]=u,e[4]=h):h=e[4];let f;e[5]===Symbol.for("react.memo_cache_sentinel")?(f=r.jsx(Ig,{size:16}),e[5]=f):f=e[5];let m;e[6]!==d||e[7]!==h||e[8]!==a?(m=r.jsx(tt,{asChild:!0,children:r.jsx("button",{type:"button",onClick:d,"aria-pressed":a,className:h,children:f})}),e[6]=d,e[7]=h,e[8]=a,e[9]=m):m=e[9];let p;e[10]===Symbol.for("react.memo_cache_sentinel")?(p=r.jsx(st,{side:"bottom",children:"Tasks"}),e[10]=p):p=e[10];let g;e[11]!==m?(g=r.jsxs(it,{delayDuration:300,children:[m,p]}),e[11]=m,e[12]=g):g=e[12];let _;e[13]!==i||e[14]!==s||e[15]!==n?(_=!s&&r.jsxs(it,{delayDuration:300,children:[r.jsx(tt,{asChild:!0,children:r.jsx("button",{type:"button",onClick:()=>{se("agent_toolbar_toggled",{button:"chat",next_state:i?"closed":"open"}),n()},"aria-pressed":i,className:X(ta,i?ph:sa),children:r.jsx(Eg,{size:16})})}),r.jsx(st,{side:"bottom",children:"Chat"})]}),e[13]=i,e[14]=s,e[15]=n,e[16]=_):_=e[16];const v=c?"grid-cols-[1fr]":"grid-cols-[0fr]";let x;e[17]!==v?(x=X("grid transition-[grid-template-columns] duration-200 ease-[var(--ease-out-quart)]",v),e[17]=v,e[18]=x):x=e[18];const b=!c,y=c?0:-1,C=!c,j=c?"translate-x-0 opacity-100":"-translate-x-2 opacity-0";let V;e[19]!==j?(V=X(ta,sa,"transition-[transform,opacity] duration-200 ease-[var(--ease-out-quart)] will-change-transform",j),e[19]=j,e[20]=V):V=e[20];let w;e[21]===Symbol.for("react.memo_cache_sentinel")?(w=r.jsx(pl,{size:16}),e[21]=w):w=e[21];let k;e[22]!==o||e[23]!==b||e[24]!==y||e[25]!==C||e[26]!==V?(k=r.jsx(tt,{asChild:!0,children:r.jsx("button",{type:"button",onClick:o,disabled:b,tabIndex:y,"aria-hidden":C,className:V,children:w})}),e[22]=o,e[23]=b,e[24]=y,e[25]=C,e[26]=V,e[27]=k):k=e[27];let T;e[28]===Symbol.for("react.memo_cache_sentinel")?(T=r.jsx(st,{side:"bottom",children:"New task"}),e[28]=T):T=e[28];let I;e[29]!==k?(I=r.jsx("div",{className:"overflow-hidden",children:r.jsxs(it,{delayDuration:300,children:[k,T]})}),e[29]=k,e[30]=I):I=e[30];let A;e[31]!==x||e[32]!==I?(A=r.jsx("div",{className:x,children:I}),e[31]=x,e[32]=I,e[33]=A):A=e[33];let N;return e[34]!==A||e[35]!==g||e[36]!==_?(N=r.jsxs(r.Fragment,{children:[g,_,A]}),e[34]=A,e[35]=g,e[36]=_,e[37]=N):N=e[37],N}function D5(t,e,s){if(t.length<=s)return{visible:t,overflow:[]};const i=t.slice(0,s),n=t.slice(s);if(e==null)return{visible:i,overflow:n};if(i.some(h=>h.id===e))return{visible:i,overflow:n};const a=n.findIndex(h=>h.id===e);if(a===-1)return{visible:i,overflow:n};const l=i[i.length-1],c=n[a],d=[...i.slice(0,-1),c],u=[l,...n.slice(0,a),...n.slice(a+1)];return{visible:d,overflow:u}}function M5(t){const e=B.c(13),{title:s,icon:i,active:n,onClick:o}=t,a=n?"bg-sidebar-accent text-sidebar-foreground":"text-sidebar-foreground/60 hover:bg-sidebar-accent hover:text-sidebar-foreground";let l;e[0]!==a?(l=X("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 c;e[2]!==i?(c=r.jsx("span",{className:"flex size-5 items-center justify-center shrink-0",children:r.jsx(P5,{icon:i})}),e[2]=i,e[3]=c):c=e[3];let d;e[4]!==s?(d=r.jsx("span",{className:"whitespace-nowrap text-sm font-medium leading-none",children:s}),e[4]=s,e[5]=d):d=e[5];let u;return e[6]!==n||e[7]!==o||e[8]!==l||e[9]!==c||e[10]!==d||e[11]!==s?(u=r.jsxs("button",{type:"button",onClick:o,"aria-pressed":n,"aria-label":s,className:l,children:[c,d]}),e[6]=n,e[7]=o,e[8]=l,e[9]=c,e[10]=d,e[11]=s,e[12]=u):u=e[12],u}function P5(t){const e=B.c(5),{icon:s}=t;if(s.kind==="component"){const{Component:n}=s;let o;return e[0]!==n?(o=r.jsx(n,{className:"size-4"}),e[0]=n,e[1]=o):o=e[1],o}if(s.kind==="url"){let n;return e[2]!==s.src?(n=r.jsx("img",{src:s.src,alt:"",className:"size-4 rounded-sm object-cover"}),e[2]=s.src,e[3]=n):n=e[3],n}let i;return e[4]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx(Yh,{className:"size-4"}),e[4]=i):i=e[4],i}function L5(t){const e=B.c(13),{overflow:s,onSelect:i}=t,[n,o]=S.useState(!1);let a;e[0]!==i?(a=f=>{o(!1),i(f)},e[0]=i,e[1]=a):a=e[1];const l=a;let c;e[2]===Symbol.for("react.memo_cache_sentinel")?(c=r.jsx(oi,{asChild:!0,children:r.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:r.jsx(Kh,{className:"size-4"})})}),e[2]=c):c=e[2];let d;if(e[3]!==l||e[4]!==s){let f;e[6]!==l?(f=m=>r.jsx("li",{children:r.jsxs("button",{type:"button",onClick:()=>l(m.id),className:"w-full flex items-center gap-2 px-3 py-2 rounded-md hover:bg-accent text-sm text-foreground",children:[r.jsx("span",{className:"flex size-5 items-center justify-center shrink-0",children:r.jsx(B5,{icon:m.icon})}),r.jsx("span",{className:"truncate",children:m.title})]})},m.id),e[6]=l,e[7]=f):f=e[7],d=s.map(f),e[3]=l,e[4]=s,e[5]=d}else d=e[5];let u;e[8]!==d?(u=r.jsx(ai,{align:"end",className:"w-56 p-1",children:r.jsx("ul",{className:"flex flex-col",children:d})}),e[8]=d,e[9]=u):u=e[9];let h;return e[10]!==n||e[11]!==u?(h=r.jsxs(li,{open:n,onOpenChange:o,children:[c,u]}),e[10]=n,e[11]=u,e[12]=h):h=e[12],h}function B5(t){const e=B.c(5),{icon:s}=t;if(s.kind==="component"){const{Component:n}=s;let o;return e[0]!==n?(o=r.jsx(n,{className:"size-4"}),e[0]=n,e[1]=o):o=e[1],o}if(s.kind==="url"){let n;return e[2]!==s.src?(n=r.jsx("img",{src:s.src,alt:"",className:"size-4 rounded-sm object-cover"}),e[2]=s.src,e[3]=n):n=e[3],n}let i;return e[4]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx(Yh,{className:"size-4"}),e[4]=i):i=e[4],i}const O5=6;function $5(t){const e=B.c(20),{virtualMcpId:s,taskId:i}=t,n=Ke();let o;e[0]!==i||e[1]!==s?(o={virtualMcpId:s,taskId:i},e[0]=i,e[1]=s,e[2]=o):o=e[2];const{tabs:a,activeTab:l,mainOpen:c,setActiveTab:d}=zf(o);let u,h,f,m;if(e[3]!==l||e[4]!==c||e[5]!==n||e[6]!==d||e[7]!==a||e[8]!==s){const _=Jp({activeTab:l,mainOpen:c}),v=j=>j.id==="automations"?_:c&&j.id===l,b=a.find(j=>v(j))?.id??null,{visible:y,overflow:C}=D5(a,b,O5);h=C,u=j=>{const V=a.find(k=>k.id===j),w=b===j&&c;if(se("main_panel_tab_clicked",{virtual_mcp_id:s,tab_id:j,tab_kind:V?.kind??null,was_active:w}),j==="automations"){const k=Qp({activeTab:l,mainOpen:c});n({to:".",search:T=>({...T,main:k}),replace:!0});return}d(j)},f="flex items-center min-w-0 ml-auto gap-0.5",m=y.map(j=>r.jsx(M5,{title:j.title,icon:j.icon,active:v(j),onClick:()=>u(j.id)},j.id)),e[3]=l,e[4]=c,e[5]=n,e[6]=d,e[7]=a,e[8]=s,e[9]=u,e[10]=h,e[11]=f,e[12]=m}else u=e[9],h=e[10],f=e[11],m=e[12];let p;e[13]!==u||e[14]!==h?(p=h.length>0&&r.jsx(L5,{overflow:h,onSelect:u}),e[13]=u,e[14]=h,e[15]=p):p=e[15];let g;return e[16]!==f||e[17]!==m||e[18]!==p?(g=r.jsxs("div",{className:f,children:[m,p]}),e[16]=f,e[17]=m,e[18]=p,e[19]=g):g=e[19],g}function z5(t){const e=B.c(12);let s,i,n,o;e[0]!==t?({className:s,orientation:n,decorative:o,...i}=t,e[0]=t,e[1]=s,e[2]=i,e[3]=n,e[4]=o):(s=e[1],i=e[2],n=e[3],o=e[4]);const a=n===void 0?"horizontal":n,l=o===void 0?!0:o;let c;e[5]!==s?(c=X("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]=c):c=e[6];let d;return e[7]!==l||e[8]!==a||e[9]!==i||e[10]!==c?(d=r.jsx(kp,{"data-slot":"separator-root",decorative:l,orientation:a,className:c,...i}),e[7]=l,e[8]=a,e[9]=i,e[10]=c,e[11]=d):d=e[11],d}function F5(t){const e=B.c(20),{prNumber:s,disabled:i,send:n}=t;let o;e[0]!==s||e[1]!==n?(o=()=>n(nV({prNumber:s})),e[0]=s,e[1]=n,e[2]=o):o=e[2];const a=o;let l;e[3]!==s||e[4]!==n?(l=()=>n(rV({prNumber:s})),e[3]=s,e[4]=n,e[5]=l):l=e[5];const c=l;let d;e[6]!==i||e[7]!==a?(d=r.jsx(ne,{size:"sm",className:"rounded-r-none border-r border-primary-foreground/20",disabled:i,onClick:a,children:"Publish"}),e[6]=i,e[7]=a,e[8]=d):d=e[8];let u;e[9]===Symbol.for("react.memo_cache_sentinel")?(u=r.jsx(kr,{className:"h-3.5 w-3.5"}),e[9]=u):u=e[9];let h;e[10]!==i?(h=r.jsx(ks,{asChild:!0,children:r.jsx(ne,{size:"sm",className:"rounded-l-none px-2",disabled:i,"aria-label":"More actions",children:u})}),e[10]=i,e[11]=h):h=e[11];let f;e[12]!==c?(f=r.jsx(Ns,{align:"end",children:r.jsx(ot,{onClick:c,children:"Review"})}),e[12]=c,e[13]=f):f=e[13];let m;e[14]!==h||e[15]!==f?(m=r.jsxs(js,{children:[h,f]}),e[14]=h,e[15]=f,e[16]=m):m=e[16];let p;return e[17]!==d||e[18]!==m?(p=r.jsxs("div",{className:"inline-flex items-stretch rounded-md",children:[d,m]}),e[17]=d,e[18]=m,e[19]=p):p=e[19],p}const H5=new Set(["failure","timed_out","cancelled","action_required"]);function W5(t){return t.status==="completed"&&H5.has(t.conclusion)}function U5(t){return t.status==="queued"||t.status==="in_progress"}function K5(t){const{branchStatus:e,pr:s,checks:i,reviews:n}=t;if(!e)return null;if(e.workingTreeDirty||e.unpushed>0)return{label:"Save changes",action:"commit-and-push"};if(s?.merged)return!!e.headSha&&!!s.headSha&&e.headSha!==s.headSha?{label:"Submit for review",action:"create-pr"}:null;if(e.aheadOfBase>0){if(s&&s.state==="closed"&&!s.merged)return{label:"Reopen",action:"reopen"};if(!s)return{label:"Submit for review",action:"create-pr"};if((n?.mergeableState??"unknown")==="dirty")return{label:`Sync with ${s.base}`,action:"rebase"};const l=i.filter(W5).map(c=>c.name);return l.length>0?{label:"Fix tests",action:"fix-checks",meta:{failingChecks:l}}:i.some(U5)?{label:"Running tests…",disabled:!0}:n?.draft?{label:"Mark ready",action:"mark-ready"}:(n?.unresolvedConversations??0)>0?{label:"Address feedback",action:"resolve-comments"}:n?.missingRequiredApprovals?{label:"Awaiting review",disabled:!0}:{label:"Publish",action:"merge-split"}}return null}function q5(){return Yi().branchStatus}const G5=6e4,Y5=3e4;function X5(t){const e=B.c(11);let s;e[0]!==t.connectionId||e[1]!==t.orgId?(s={connectionId:t.connectionId,orgId:t.orgId},e[0]=t.connectionId,e[1]=t.orgId,e[2]=s):s=e[2];const i=Me(s),n=t.prNumber??0;let o;e[3]!==t.owner||e[4]!==t.repo||e[5]!==n?(o={method:"get",owner:t.owner,repo:t.repo,pullNumber:n},e[3]=t.owner,e[4]=t.repo,e[5]=n,e[6]=o):o=e[6];const a=!!t.prNumber;let l;return e[7]!==i||e[8]!==o||e[9]!==a?(l={client:i,toolName:"pull_request_read",toolArguments:o,enabled:a,refetchInterval:G5,refetchIntervalInBackground:!1,staleTime:Y5,select:J5},e[7]=i,e[8]=o,e[9]=a,e[10]=l):l=e[10],wi(l)}function J5(t){const e=Zr(t);if(!e)return null;const s=e.mergeable_state??"unknown",i=!!(e.draft??!1),n=Number(e.review_comments??0),o=s==="blocked"&&n>0?n:0;return{draft:i,mergeableState:s,unresolvedConversations:o,missingRequiredApprovals:s==="blocked"&&o===0}}function Q5(t){const e=B.c(38),{virtualMcpId:s}=t,{org:i}=be(),n=ts(s),{currentBranch:o}=es(),a=Zn(),l=n?.metadata?.githubRepo??null,c=q5(),d=l?.connectionId??"",u=l?.owner??"",h=l?.name??"",f=o??null;let m;e[0]!==i.id||e[1]!==d||e[2]!==u||e[3]!==h||e[4]!==f?(m={orgId:i.id,connectionId:d,owner:u,repo:h,branch:f},e[0]=i.id,e[1]=d,e[2]=u,e[3]=h,e[4]=f,e[5]=m):m=e[5];const g=Hf(m).data??null,_=l?.connectionId??"",v=l?.owner??"",x=l?.name??"",b=g&&g.state==="open"?g.number:null;let y;e[6]!==i.id||e[7]!==_||e[8]!==v||e[9]!==x||e[10]!==b?(y={orgId:i.id,connectionId:_,owner:v,repo:x,prNumber:b},e[6]=i.id,e[7]=_,e[8]=v,e[9]=x,e[10]=b,e[11]=y):y=e[11];const C=Uf(y),j=l?.connectionId??"",V=l?.owner??"",w=l?.name??"",k=g&&g.state==="open"?g.number:null;let T;e[12]!==i.id||e[13]!==j||e[14]!==V||e[15]!==w||e[16]!==k?(T={orgId:i.id,connectionId:j,owner:V,repo:w,prNumber:k},e[12]=i.id,e[13]=j,e[14]=V,e[15]=w,e[16]=k,e[17]=T):T=e[17];const I=X5(T);if(!l?.connectionId||!o)return null;let A;e[18]!==c||e[19]!==C.data||e[20]!==g||e[21]!==I.data?(A=K5({branchStatus:c,pr:g,checks:C.data??[],reviews:I.data??null}),e[18]=c,e[19]=C.data,e[20]=g,e[21]=I.data,e[22]=A):A=e[22];const N=A;if(!N)return null;let E;e[23]!==a?(E=$=>a.sendMessage({parts:[{type:"text",text:$}]}),e[23]=a,e[24]=E):E=e[24];const R=E,M=a.isStreaming;let L;e[25]!==o||e[26]!==N||e[27]!==M||e[28]!==g||e[29]!==R?(L=$=>{if(!M)switch($){case"commit-and-push":{R(Xw({branch:o}));return}case"create-pr":{R(Jw({branch:o}));return}case"reopen":{g&&R(Qw({prNumber:g.number}));return}case"rebase":{R(Zw({branch:o}));return}case"fix-checks":{g&&R(tV({prNumber:g.number,failingChecks:N.meta?.failingChecks??[]}));return}case"mark-ready":{g&&R(sV({prNumber:g.number}));return}case"resolve-comments":{g&&R(iV({prNumber:g.number}));return}case"merge-split":return}},e[25]=o,e[26]=N,e[27]=M,e[28]=g,e[29]=R,e[30]=L):L=e[30];const D=L;let P;e[31]===Symbol.for("react.memo_cache_sentinel")?(P=r.jsx(z5,{orientation:"vertical",className:"mx-2 data-[orientation=vertical]:h-5"}),e[31]=P):P=e[31];const O=g?.number;let z;return e[32]!==N||e[33]!==M||e[34]!==D||e[35]!==R||e[36]!==O?(z=r.jsxs(r.Fragment,{children:[P,r.jsx(Z5,{button:N,isStreaming:M,onActivate:D,prNumber:O,send:R})]}),e[32]=N,e[33]=M,e[34]=D,e[35]=R,e[36]=O,e[37]=z):z=e[37],z}function Z5(t){const e=B.c(18),{button:s,isStreaming:i}=t,n=!!s.disabled||i,o=i?"Chat is running":null;if(s.action==="merge-split"&&t.prNumber!=null){let u;e[0]!==n||e[1]!==t.prNumber||e[2]!==t.send?(u=r.jsx(F5,{prNumber:t.prNumber,disabled:n,send:t.send}),e[0]=n,e[1]=t.prNumber,e[2]=t.send,e[3]=u):u=e[3];let h;return e[4]!==u||e[5]!==o?(h=r.jsx(gh,{label:o,children:u}),e[4]=u,e[5]=o,e[6]=h):h=e[6],h}const a=s.disabled?"outline":"default";let l;e[7]!==s.action||e[8]!==t?(l=()=>t.onActivate(s.action),e[7]=s.action,e[8]=t,e[9]=l):l=e[9];let c;e[10]!==s.label||e[11]!==n||e[12]!==a||e[13]!==l?(c=r.jsx(ne,{size:"sm",variant:a,disabled:n,onClick:l,children:s.label}),e[10]=s.label,e[11]=n,e[12]=a,e[13]=l,e[14]=c):c=e[14];let d;return e[15]!==c||e[16]!==o?(d=r.jsx(gh,{label:o,children:c}),e[15]=c,e[16]=o,e[17]=d):d=e[17],d}function gh(t){const e=B.c(9),{label:s,children:i}=t;if(!s){let l;return e[0]!==i?(l=r.jsx(r.Fragment,{children:i}),e[0]=i,e[1]=l):l=e[1],l}let n;e[2]!==i?(n=r.jsx(tt,{asChild:!0,children:r.jsx("span",{children:i})}),e[2]=i,e[3]=n):n=e[3];let o;e[4]!==s?(o=r.jsx(st,{children:s}),e[4]=s,e[5]=o):o=e[5];let a;return e[6]!==n||e[7]!==o?(a=r.jsx(Mi,{children:r.jsxs(it,{children:[n,o]})}),e[6]=n,e[7]=o,e[8]=a):a=e[8],a}function ek(t){const e=B.c(2),{virtualMcp:s}=t;if(!!!(s.metadata?.githubRepo??null)?.connectionId)return null;let o;return e[0]!==s.id?(o=r.jsx(ze.Right,{children:r.jsx(Q5,{virtualMcpId:s.id})}),e[0]=s.id,e[1]=o):o=e[1],o}const Ii=S.createContext(null);function ac(){return S.use(Ii)}function _h(t){const e=B.c(8),{children:s,variant:i}=t,{taskId:n}=es();let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=r.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]=o):o=e[0];let a;e[1]===Symbol.for("react.memo_cache_sentinel")?(a=r.jsx(De.Skeleton,{}),e[1]=a):a=e[1];let l;e[2]!==s||e[3]!==i?(l=s??r.jsx(qu,{variant:i}),e[2]=s,e[3]=i,e[4]=l):l=e[4];let c;return e[5]!==l||e[6]!==n?(c=r.jsx(Cs,{fallback:o,children:r.jsx(S.Suspense,{fallback:a,children:r.jsx(De.ActiveTaskProvider,{taskId:n,children:l})})}),e[5]=l,e[6]=n,e[7]=c):c=e[7],c}function xh(t){const e=B.c(3),{onNewTaskRef:s,createNewTask:i}=t;let n;return e[0]!==i||e[1]!==s?(n=()=>(s.current=i,()=>{s.current=null}),e[0]=i,e[1]=s,e[2]=n):n=e[2],S.useLayoutEffect(n),null}function tk(t){const e=B.c(3),{onOpenSidebar:s}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx(Dg,{size:20}),e[0]=i):i=e[0];let n;return e[1]!==s?(n=r.jsx("div",{className:"shrink-0 flex items-center justify-between px-3 h-12 bg-background border-b border-border",children:r.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]=n):n=e[2],n}function vh(t){const e=B.c(16),{virtualMcpId:s,hasActiveGithubRepo:i,vmMap:n,children:o}=t,{org:a}=be(),{currentBranch:l}=es(),{data:c}=St.useSession(),d=c?.user?.id,u=d&&l?n?.[d]?.[l]??null:null;let h;e[0]!==u?(h=u?.previewUrl?u.previewUrl.replace(/\/$/,""):null,e[0]=u,e[1]=h):h=e[1];const f=h;let m;e[2]!==a.id?(m={connectionId:Wt,orgId:a.id},e[2]=a.id,e[3]=m):m=e[3];const p=Me(m),{mutate:g}=ql(p);let _;e[4]===Symbol.for("react.memo_cache_sentinel")?(_=new Set,e[4]=_):_=e[4];const v=S.useRef(_);let x,b;e[5]!==l||e[6]!==i||e[7]!==g||e[8]!==d||e[9]!==s||e[10]!==n?(x=()=>{i&&d&&l&&(n?.[d]?.[l]||v.current.has(l)||(v.current.add(l),g({virtualMcpId:s,branch:l},{onError:sk})))},b=[i,d,l,n,s,g],e[5]=l,e[6]=i,e[7]=g,e[8]=d,e[9]=s,e[10]=n,e[11]=x,e[12]=b):(x=e[11],b=e[12]),S.useEffect(x,b);let y;return e[13]!==o||e[14]!==f?(y=r.jsx(IV,{daemonBaseUrl:f,children:o}),e[13]=o,e[14]=f,e[15]=y):y=e[15],y}function sk(t){console.error("[auto-start-vm] failed:",t)}function bh(){const t=B.c(106),e=Rs(),s=Ke(),{org:i}=be(),n=RS()?.tasksOpen??!1;I_(i.id);let o;t[0]===Symbol.for("react.memo_cache_sentinel")?(o={strict:!1},t[0]=o):o=t[0];const a=$r(o),l=a.org??"";let c;t[1]===Symbol.for("react.memo_cache_sentinel")?(c={strict:!1},t[1]=c):c=t[1];const d=vi(c);let u;t[2]!==i.id||t[3]!==d.virtualmcpid?(u=d.virtualmcpid??io(i.id).id,t[2]=i.id,t[3]=d.virtualmcpid,t[4]=u):u=t[4];const h=u;let f;t[5]!==i.id?(f=hl(i.id),t[5]=i.id,t[6]=f):f=t[6];const m=h===f,p=!m,g=U_(a.taskId??"",h),_=ts(h),v=_?.metadata?.ui?.layout??null;let x;t[7]!==v?(x=v?{defaultMainView:v.defaultMainView??null,chatDefaultOpen:v.chatDefaultOpen??null}:null,t[7]=v,t[8]=x):x=t[8];const b=x;let y;t[9]!==_?(y=_&&Fs(_),t[9]=_,t[10]=y):y=t[10];const C=!!y;let j;t[11]!==p||t[12]!==l||t[13]!==h?(j={virtualMcpId:h,orgSlug:l,isAgentRoute:p},t[11]=p,t[12]=l,t[13]=h,t[14]=j):j=t[14];const V=AS(b,j),{setOpenMobile:w,openMobile:k}=qr(),T=w,I=S.useRef(null);let A,N;t[15]===Symbol.for("react.memo_cache_sentinel")?(A=()=>{const K=U=>{Ph(U)&&U.shiftKey&&U.code==="KeyS"&&!U.repeat&&(U.preventDefault(),I.current?.())};return document.addEventListener("keydown",K),()=>document.removeEventListener("keydown",K)},N=[],t[15]=A,t[16]=N):(A=t[15],N=t[16]),S.useEffect(A,N);const E=h;let R;t[17]!==_||t[18]!==h?(R={virtualMcpId:h,entity:_},t[17]=_,t[18]=h,t[19]=R):R=t[19];const M=R;if(g.status==="creating"||g.status==="loading"){let K;t[20]===Symbol.for("react.memo_cache_sentinel")?(K=r.jsx("div",{className:"flex-1 min-h-0 pr-1.5 pb-1.5 overflow-hidden",children:r.jsxs("div",{className:"flex h-full items-center justify-center bg-background card-shadow rounded-[0.75rem] text-sm text-muted-foreground",children:[r.jsx(Ee,{className:"size-4 animate-spin mr-2"}),"Creating task…"]})}),t[20]=K):K=t[20];let U;return t[21]!==M?(U=r.jsx(Ii,{value:M,children:K}),t[21]=M,t[22]=U):U=t[22],U}if(g.status==="error"){let K;t[23]===Symbol.for("react.memo_cache_sentinel")?(K=r.jsx("div",{className:"font-medium",children:"Task unavailable"}),t[23]=K):K=t[23];let U;t[24]!==g.error.message?(U=r.jsx("div",{className:"flex-1 min-h-0 pr-1.5 pb-1.5 overflow-hidden",children:r.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:[K,r.jsx("div",{className:"text-muted-foreground",children:g.error.message})]})}),t[24]=g.error.message,t[25]=U):U=t[25];let te;return t[26]!==M||t[27]!==U?(te=r.jsx(Ii,{value:M,children:U}),t[26]=M,t[27]=U,t[28]=te):te=t[28],te}if(!_){let K;t[29]===Symbol.for("react.memo_cache_sentinel")?(K=r.jsx(ri,{size:48,className:"text-muted-foreground"}),t[29]=K):K=t[29];const U=`The agent "${h}" does not exist in this organization.`;let te;t[30]!==s||t[31]!==l?(te=r.jsx(ne,{variant:"outline",onClick:()=>s({to:"/$org",params:{org:l}}),children:"Go to organization home"}),t[30]=s,t[31]=l,t[32]=te):te=t[32];let Y;t[33]!==U||t[34]!==te?(Y=r.jsx("div",{className:"flex-1 min-h-0 pr-1.5 pb-1.5 overflow-hidden",children:r.jsx("div",{className:"flex flex-col h-full bg-background overflow-hidden card-shadow rounded-[0.75rem]",children:r.jsx(Oi,{image:K,title:"Agent not found",description:U,actions:te})})}),t[33]=U,t[34]=te,t[35]=Y):Y=t[35];let J;return t[36]!==M||t[37]!==Y?(J=r.jsx(Ii,{value:M,children:Y}),t[36]=M,t[37]=Y,t[38]=J):J=t[38],J}if(e){let K;t[39]===Symbol.for("react.memo_cache_sentinel")?(K=r.jsx(C_,{className:"sr-only",children:"Navigation"}),t[39]=K):K=t[39];let U;t[40]!==T?(U=r.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:r.jsx(SS,{onClose:()=>T(!1)})}),t[40]=T,t[41]=U):U=t[41];let te;t[42]===Symbol.for("react.memo_cache_sentinel")?(te=r.jsx("div",{className:"flex-1 min-w-0 overflow-hidden",children:r.jsx(Xu,{})}),t[42]=te):te=t[42];let Y;t[43]!==U?(Y=r.jsxs(j_,{side:"left",hideCloseButton:!0,className:"w-[calc(100vw-3rem)] sm:max-w-md! p-0",children:[K,r.jsxs("div",{className:"flex h-full",children:[U,te]})]}),t[43]=U,t[44]=Y):Y=t[44];let J;t[45]!==k||t[46]!==T||t[47]!==Y?(J=r.jsx(k_,{open:k,onOpenChange:T,children:Y}),t[45]=k,t[46]=T,t[47]=Y,t[48]=J):J=t[48];const ie=J,ue=_?.metadata?.vmMap;let de;t[49]!==V.createNewTask?(de=r.jsx(xh,{onNewTaskRef:I,createNewTask:V.createNewTask}),t[49]=V.createNewTask,t[50]=de):de=t[50];let xe;t[51]!==T?(xe=r.jsx(tk,{onOpenSidebar:()=>T(!0)}),t[51]=T,t[52]=xe):xe=t[52];const oe=m?"home":void 0;let he;t[53]!==oe?(he=r.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:r.jsx(_h,{variant:oe})}),t[53]=oe,t[54]=he):he=t[54];let me;t[55]!==C||t[56]!==ie||t[57]!==ue||t[58]!==de||t[59]!==xe||t[60]!==he||t[61]!==h?(me=r.jsxs(vh,{virtualMcpId:h,hasActiveGithubRepo:C,vmMap:ue,children:[de,xe,he,ie]}),t[55]=C,t[56]=ie,t[57]=ue,t[58]=de,t[59]=xe,t[60]=he,t[61]=h,t[62]=me):me=t[62];let fe;t[63]!==E||t[64]!==me?(fe=r.jsx("div",{className:"flex flex-col flex-1 bg-background min-h-0",children:r.jsx(De.Provider,{virtualMcpId:E,children:me},E)}),t[63]=E,t[64]=me,t[65]=fe):fe=t[65];let le;return t[66]!==M||t[67]!==fe?(le=r.jsx(Ii,{value:M,children:fe}),t[66]=M,t[67]=fe,t[68]=le):le=t[68],le}const L=n?void 0:V.createNewTask;let D;t[69]!==m||t[70]!==V.chatOpen||t[71]!==V.toggleChat||t[72]!==L?(D=r.jsx(ze.Toggles,{children:r.jsx(T5,{isDecopilot:m,chatOpen:V.chatOpen,toggleChat:V.toggleChat,onNewTask:L})}),t[69]=m,t[70]=V.chatOpen,t[71]=V.toggleChat,t[72]=L,t[73]=D):D=t[73];let P;t[74]!==m||t[75]!==V.taskId||t[76]!==h?(P=!m&&r.jsx(ze.Tabs,{children:r.jsx($5,{virtualMcpId:h,taskId:V.taskId})}),t[74]=m,t[75]=V.taskId,t[76]=h,t[77]=P):P=t[77];const O=_?.metadata?.vmMap;let z;t[78]!==_||t[79]!==m?(z=!m&&r.jsx(ek,{virtualMcp:_}),t[78]=_,t[79]=m,t[80]=z):z=t[80];let $;t[81]!==V.createNewTask?($=r.jsx(xh,{onNewTaskRef:I,createNewTask:V.createNewTask}),t[81]=V.createNewTask,t[82]=$):$=t[82];const W=m?"home":void 0;let F;t[83]!==W?(F=r.jsx(_h,{variant:W}),t[83]=W,t[84]=F):F=t[84];let G;t[85]!==V.chatOpen||t[86]!==V.mainOpen||t[87]!==V.taskId||t[88]!==F||t[89]!==h?(G=r.jsx(R5,{virtualMcpId:h,taskId:V.taskId,chatOpen:V.chatOpen,mainOpen:V.mainOpen,chatContent:F}),t[85]=V.chatOpen,t[86]=V.mainOpen,t[87]=V.taskId,t[88]=F,t[89]=h,t[90]=G):G=t[90];let q;t[91]!==C||t[92]!==O||t[93]!==z||t[94]!==$||t[95]!==G||t[96]!==h?(q=r.jsxs(vh,{virtualMcpId:h,hasActiveGithubRepo:C,vmMap:O,children:[z,$,G]}),t[91]=C,t[92]=O,t[93]=z,t[94]=$,t[95]=G,t[96]=h,t[97]=q):q=t[97];let H;t[98]!==E||t[99]!==P||t[100]!==q?(H=r.jsxs(De.Provider,{virtualMcpId:E,children:[P,q]},E),t[98]=E,t[99]=P,t[100]=q,t[101]=H):H=t[101];let ee;return t[102]!==M||t[103]!==D||t[104]!==H?(ee=r.jsxs(Ii,{value:M,children:[D,H]}),t[102]=M,t[103]=D,t[104]=H,t[105]=ee):ee=t[105],ee}function X4(){const t=B.c(5),e=Rs();let s;t[0]===Symbol.for("react.memo_cache_sentinel")?(s={"--sidebar-width-icon":"3.5rem"},t[0]=s):s=t[0];let i;t[1]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx(yS,{}),t[1]=i):i=t[1];let n;t[2]===Symbol.for("react.memo_cache_sentinel")?(n={background:"transparent",containerType:"inline-size"},t[2]=n):n=t[2];let o;return t[3]!==e?(o=r.jsx(S_,{defaultOpen:!1,children:r.jsx("div",{className:"flex flex-col h-dvh overflow-hidden",children:r.jsxs(w_,{className:"flex-1 bg-sidebar",style:s,children:[i,r.jsx(V_,{className:"flex flex-col",style:n,children:e?r.jsx(S.Suspense,{fallback:r.jsx("div",{className:"flex-1 flex items-center justify-center",children:r.jsx(Ee,{size:20,className:"animate-spin text-muted-foreground"})}),children:r.jsx(bh,{})}):r.jsx(S.Suspense,{fallback:r.jsx("div",{className:"flex-1 flex items-center justify-center",children:r.jsx(Ee,{size:20,className:"animate-spin text-muted-foreground"})}),children:r.jsx(ES,{children:r.jsxs(ze,{children:[r.jsxs(ze.Header,{children:[r.jsxs(ze.LeftColumn,{children:[r.jsx(ze.Nav,{}),r.jsx(ze.TogglesSlot,{})]}),r.jsx(ze.CenterSlot,{}),r.jsxs(ze.RightColumn,{children:[r.jsx(ze.TabsSlot,{}),r.jsx(ze.RightSlot,{})]})]}),r.jsxs("div",{className:"flex-1 min-h-0 flex flex-row",children:[r.jsx(YS,{}),r.jsx("div",{className:"flex-1 min-w-0 flex flex-col",children:r.jsx(S.Suspense,{fallback:r.jsx("div",{className:"flex-1 flex items-center justify-center",children:r.jsx(Ee,{size:20,className:"animate-spin text-muted-foreground"})}),children:r.jsx(bh,{})})})]})]})})})})]})})}),t[3]=e,t[4]=o):o=t[4],o}export{X4 as default,ac as useInsetContext};