decocms 4.22.2 → 4.22.3

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 (223) hide show
  1. package/dist/client/assets/{AlertCircle-BWfyWgiw.js → AlertCircle-CS_9RDbg.js} +1 -1
  2. package/dist/client/assets/{ArrowUpRight-h5-lNOU3.js → ArrowUpRight-DvbKSlUB.js} +1 -1
  3. package/dist/client/assets/{Check-B2t3_u8j.js → Check-CUUu6fuS.js} +1 -1
  4. package/dist/client/assets/{CheckCircle-Cd9sCPj_.js → CheckCircle-2nPR7mAJ.js} +1 -1
  5. package/dist/client/assets/{ChevronDown-CJGVvA9G.js → ChevronDown-SbVNxwJa.js} +1 -1
  6. package/dist/client/assets/{ChevronRight-SxNLyRA0.js → ChevronRight-CcT_Yai8.js} +1 -1
  7. package/dist/client/assets/{ChevronUp-Cfv8kwOP.js → ChevronUp-DvAb8S9K.js} +1 -1
  8. package/dist/client/assets/{Circle-CmWJQsR2.js → Circle-Bk2OeGHv.js} +1 -1
  9. package/dist/client/assets/{Copy01-C_1mrR9P.js → Copy01-DvnmgpBw.js} +1 -1
  10. package/dist/client/assets/{DotsVertical-DQ-r-KXk.js → DotsVertical-BdQp-tpJ.js} +1 -1
  11. package/dist/client/assets/{Eye-Jd91Hda4.js → Eye-_b_nmYda.js} +1 -1
  12. package/dist/client/assets/{FilterLines-C7Zdp7-q.js → FilterLines-Dgm9Ju0X.js} +1 -1
  13. package/dist/client/assets/{Globe01-4bI1LBPk.js → Globe01-BWEVPBr8.js} +1 -1
  14. package/dist/client/assets/{Globe04-CPnbhr3e.js → Globe04-wcXsSWcH.js} +1 -1
  15. package/dist/client/assets/{HardDrive-WT4IA8YF.js → HardDrive-CCq9xvHa.js} +1 -1
  16. package/dist/client/assets/{Key01-_0kmrESm.js → Key01-BXrc6Emy.js} +1 -1
  17. package/dist/client/assets/{LayoutLeft-D_5UU_fl.js → LayoutLeft-BStzo30s.js} +1 -1
  18. package/dist/client/assets/{LinkExternal01-CYx_LjKe.js → LinkExternal01-BuzymGhb.js} +1 -1
  19. package/dist/client/assets/{List-5nWMXvgZ.js → List-BFtSkA22.js} +1 -1
  20. package/dist/client/assets/{Loading02-D5Q9o2ML.js → Loading02-Cc_XPeVS.js} +1 -1
  21. package/dist/client/assets/{Monitor01-EVfMwGgl.js → Monitor01-BJSW7YEH.js} +1 -1
  22. package/dist/client/assets/{Palette-Cg2Il5Mo.js → Palette-BudWH9og.js} +1 -1
  23. package/dist/client/assets/{Play-C4pBBuTc.js → Play-tpQoZZ7-.js} +1 -1
  24. package/dist/client/assets/{Plus-Cj9kK9tN.js → Plus-6nUvzb_a.js} +1 -1
  25. package/dist/client/assets/{SearchLg-JSkDDvk4.js → SearchLg-uOXEhZpb.js} +1 -1
  26. package/dist/client/assets/{SearchMd-CP9WApAb.js → SearchMd-CxCfJ-k7.js} +1 -1
  27. package/dist/client/assets/{Settings02-Bs74lw7T.js → Settings02-C4te5XIh.js} +1 -1
  28. package/dist/client/assets/{Shield01-DMFwBOtF.js → Shield01-DL0nLXwm.js} +1 -1
  29. package/dist/client/assets/{Star01-CC3gyOop.js → Star01-BMo746nc.js} +1 -1
  30. package/dist/client/assets/{Stars01-DKD-uu49.js → Stars01-CeLaUJek.js} +1 -1
  31. package/dist/client/assets/{Stars02-DGriyPK-.js → Stars02-CbNiaecd.js} +1 -1
  32. package/dist/client/assets/{Sun-DszeKWvN.js → Sun-DdZgJrCs.js} +1 -1
  33. package/dist/client/assets/{SwitchHorizontal01-a_i15cCW.js → SwitchHorizontal01-BmduH4aR.js} +1 -1
  34. package/dist/client/assets/{Tool01-iIXzQIf6.js → Tool01-TTGB3OaR.js} +1 -1
  35. package/dist/client/assets/{Trash01-D_xTnQtW.js → Trash01-D7DoI-Sm.js} +1 -1
  36. package/dist/client/assets/{Upload01-COCQSA6j.js → Upload01-DK0nNkQH.js} +1 -1
  37. package/dist/client/assets/{User01-DBHhpCM7.js → User01-zyFcbX02.js} +1 -1
  38. package/dist/client/assets/{Users01-BymojQtX.js → Users01-DD6y7ZFy.js} +1 -1
  39. package/dist/client/assets/{Users03-Dnn-6pZq.js → Users03-CbmB3ag4.js} +1 -1
  40. package/dist/client/assets/{X-DY9hR308.js → X-qcmmBu7s.js} +1 -1
  41. package/dist/client/assets/{XCircle-DofnF94J.js → XCircle-Bn7fkWKh.js} +1 -1
  42. package/dist/client/assets/{XClose-CmiCfuv_.js → XClose-aB151tNh.js} +1 -1
  43. package/dist/client/assets/{Zap-BwbZR_TW.js → Zap-CKOdamGS.js} +1 -1
  44. package/dist/client/assets/{ZapSquare-B7pUKk1h.js → ZapSquare-BWJNUjCu.js} +1 -1
  45. package/dist/client/assets/{ZoomOut-B3kimgA9.js → ZoomOut-TFjut-PL.js} +1 -1
  46. package/dist/client/assets/{access-gate-BOS773UI.js → access-gate-BrC4x4bH.js} +1 -1
  47. package/dist/client/assets/{add-section-modal-Z7yIxDfk.js → add-section-modal-CMgGjfQy.js} +1 -1
  48. package/dist/client/assets/{agent-capabilities-DRUNyKs6.js → agent-capabilities-B_99zpHP.js} +1 -1
  49. package/dist/client/assets/{agent-icon-K57A0DzY.js → agent-icon-CPQk4YwJ.js} +1 -1
  50. package/dist/client/assets/{agents-list-DdfrpJA4.js → agents-list-nbmqgS_E.js} +1 -1
  51. package/dist/client/assets/{ai-providers-ZlX0S41Y.js → ai-providers-D0wJFLuS.js} +1 -1
  52. package/dist/client/assets/{alert-D12iE_jh.js → alert-CIXXRGUS.js} +1 -1
  53. package/dist/client/assets/{alert-dialog-BuY0O9iQ.js → alert-dialog-DmHjxQGj.js} +1 -1
  54. package/dist/client/assets/{app-editor-B6oORsVZ.js → app-editor-BsolX872.js} +1 -1
  55. package/dist/client/assets/{auth-D1xUzxIp.js → auth-D0kIsFu2.js} +1 -1
  56. package/dist/client/assets/{auth-catchall-BTjXPhNI.js → auth-catchall-DqYoQiw7.js} +1 -1
  57. package/dist/client/assets/{auth-entry-Bg2Xb6tT.js → auth-entry-D3jHJu3A.js} +1 -1
  58. package/dist/client/assets/{auth-split-layout-CzHLXrwa.js → auth-split-layout-CX7sxZli.js} +1 -1
  59. package/dist/client/assets/{authenticate-and-persist-oauth-CbQ04gTK.js → authenticate-and-persist-oauth-DkNbTtTB.js} +1 -1
  60. package/dist/client/assets/{automation-list-row-3xTUT0sz.js → automation-list-row-F_XkFIpJ.js} +1 -1
  61. package/dist/client/assets/{automation-runs-B5QugYRM.js → automation-runs-fA1ChIGW.js} +1 -1
  62. package/dist/client/assets/{automations-DpLONqEv.js → automations-mTaCH83G.js} +1 -1
  63. package/dist/client/assets/{avatar-b6IKYKQs.js → avatar-B8x-LJ3L.js} +1 -1
  64. package/dist/client/assets/{badge-DGFEVFje.js → badge-Du0UNTzb.js} +1 -1
  65. package/dist/client/assets/{block-document-CLPFDPat.js → block-document-iNfCDN2P.js} +1 -1
  66. package/dist/client/assets/{brand-context-Ba-On5d-.js → brand-context-E2Z3Pmiz.js} +1 -1
  67. package/dist/client/assets/{breadcrumb-8G_CoEun.js → breadcrumb-BShjlVDr.js} +1 -1
  68. package/dist/client/assets/{buckets-pXaevYUV.js → buckets-BT1sWv9w.js} +1 -1
  69. package/dist/client/assets/{bulk-category-panel-OTFFglhS.js → bulk-category-panel-CXG1IXf-.js} +1 -1
  70. package/dist/client/assets/{capability-load-error-CEmXpgFG.js → capability-load-error-DsHvqjTt.js} +1 -1
  71. package/dist/client/assets/{card-dPxA0RCs.js → card-CYX_RwBA.js} +1 -1
  72. package/dist/client/assets/{category-editor-B2KWZmpg.js → category-editor-DjMzIFH_.js} +1 -1
  73. package/dist/client/assets/{chat-context-COllONR2.js → chat-context-Cemyx-UZ.js} +1 -1
  74. package/dist/client/assets/{checkbox-5y5TSI8u.js → checkbox-DZJkrzus.js} +1 -1
  75. package/dist/client/assets/{cli-auth-success-DY-Hf-b0.js → cli-auth-success-DOW9HsKN.js} +1 -1
  76. package/dist/client/assets/{collection-detail-bmPgPvem.js → collection-detail-BMZKhngT.js} +1 -1
  77. package/dist/client/assets/{collection-display-button-B4kpKs3o.js → collection-display-button-BuAgDHrw.js} +1 -1
  78. package/dist/client/assets/{collection-search-SaKzAiAF.js → collection-search-DfgQYgyj.js} +1 -1
  79. package/dist/client/assets/{collection-table-wrapper-CJ-K0eS_.js → collection-table-wrapper-hkqvebTU.js} +1 -1
  80. package/dist/client/assets/{collection-tabs-CZb_AY94.js → collection-tabs-D3XeP_yy.js} +1 -1
  81. package/dist/client/assets/{command-DDwBnk4S.js → command-DN00KTSb.js} +1 -1
  82. package/dist/client/assets/{commerce-onboarding-Cj6KuavN.js → commerce-onboarding-yWSM0PQD.js} +1 -1
  83. package/dist/client/assets/{connect-desktop-dialog-uu1uNLI_.js → connect-desktop-dialog-DnC2R2Wo.js} +1 -1
  84. package/dist/client/assets/{connection-card-BsaY572f.js → connection-card-BoKNDsqu.js} +1 -1
  85. package/dist/client/assets/{connection-detail-CVTulNyz.js → connection-detail-C_252exw.js} +1 -1
  86. package/dist/client/assets/{connection-form-helpers-CHdocTpm.js → connection-form-helpers-DgmmJwTY.js} +1 -1
  87. package/dist/client/assets/{connections-JYGKhfuk.js → connections-BMIC4hHM.js} +1 -1
  88. package/dist/client/assets/{decopilot-B6qg2Op3.js → decopilot-CETHa21a.js} +1 -1
  89. package/dist/client/assets/{decopilot-sse-pool-D8tR3MTD.js → decopilot-sse-pool-C82Ujbm_.js} +1 -1
  90. package/dist/client/assets/{dialog-RRPWwqaQ.js → dialog-CEOLT1ZZ.js} +1 -1
  91. package/dist/client/assets/{domain-settings-CtXa1jf3.js → domain-settings-BSIbwctC.js} +1 -1
  92. package/dist/client/assets/{drawer-DJfZ0VmD.js → drawer-B-rufaJn.js} +1 -1
  93. package/dist/client/assets/{dropdown-menu-DDhytuEd.js → dropdown-menu-CeNfEKAu.js} +1 -1
  94. package/dist/client/assets/{empty-state-CtsFp5nF.js → empty-state-BXO7rHQu.js} +1 -1
  95. package/dist/client/assets/{extract-connection-data-DI_Hy6px.js → extract-connection-data-Db76guDM.js} +1 -1
  96. package/dist/client/assets/{file-explorer-D1P9uacX.js → file-explorer-CLuX6xBf.js} +1 -1
  97. package/dist/client/assets/{file-type-icon-CBM2EyFd.js → file-type-icon-CxAOgcI2.js} +1 -1
  98. package/dist/client/assets/{files-DdTksaS8.js → files-BjIbXeVM.js} +1 -1
  99. package/dist/client/assets/{form-BylSC3lX.js → form-DtFQ7vfL.js} +1 -1
  100. package/dist/client/assets/{general-DGX6oTcl.js → general-DHyqePel.js} +1 -1
  101. package/dist/client/assets/{github-repo-picker-J64_EPEa.js → github-repo-picker-DXC0Oul4.js} +1 -1
  102. package/dist/client/assets/{hooks-B4JA5-D1.js → hooks-DLOVOtDp.js} +1 -1
  103. package/dist/client/assets/{index-DTx-RDv5.js → index-914V2fcS.js} +1 -1
  104. package/dist/client/assets/{index-DEenRZAo.js → index-9ntojBLk.js} +1 -1
  105. package/dist/client/assets/{index-DKXcf6uO.js → index-B1FK7wQH.js} +1 -1
  106. package/dist/client/assets/{index-CZfoQE-0.js → index-BNz3lima.js} +1 -1
  107. package/dist/client/assets/{index-B3JJ62uP.js → index-Blor2-rz.js} +1 -1
  108. package/dist/client/assets/{index-Bxu03H5X.js → index-BlyuLoWx.js} +1 -1
  109. package/dist/client/assets/{index-FLLcVjP1.js → index-Cs6NaxUB.js} +25 -25
  110. package/dist/client/assets/{index-8heN4TLW.js → index-Cwr5cOYK.js} +1 -1
  111. package/dist/client/assets/{index-CC3_vx1n.js → index-D5RT2LDt.js} +1 -1
  112. package/dist/client/assets/{index-jUZDCPpZ.js → index-Ds2zXC-C.js} +1 -1
  113. package/dist/client/assets/{index-DACIolxc.js → index-Um2y51Zg.js} +1 -1
  114. package/dist/client/assets/{index-DHu9eqr8.js → index-g1gbVRQq.js} +1 -1
  115. package/dist/client/assets/{index-redirect-KOsw3DwK.js → index-redirect-D63CT2D1.js} +1 -1
  116. package/dist/client/assets/{index-5AaNNafz.js → index-wvMNjAV0.js} +3 -3
  117. package/dist/client/assets/{index-C7SCPFX7.js → index-yCHQGXJ7.js} +1 -1
  118. package/dist/client/assets/{input-BAz505sI.js → input-CtNQHwPy.js} +1 -1
  119. package/dist/client/assets/{integration-icon-DtLxCtgy.js → integration-icon-DvFXK2MU.js} +1 -1
  120. package/dist/client/assets/{invite-member-dialog-BDVAAQIu.js → invite-member-dialog-CrMqsXT4.js} +1 -1
  121. package/dist/client/assets/{label-BALEyZ3d.js → label-B8KM3R_q.js} +1 -1
  122. package/dist/client/assets/{library-tab-Ds5fpIQF.js → library-tab-DFX3AeS3.js} +1 -1
  123. package/dist/client/assets/{login-DPGDZC34.js → login-DxUhmOqI.js} +1 -1
  124. package/dist/client/assets/{mcp-oauth-CXxRaWx9.js → mcp-oauth-DzrEuQr5.js} +1 -1
  125. package/dist/client/assets/{members-Bape-XGh.js → members-CPkTTkE0.js} +1 -1
  126. package/dist/client/assets/{monaco-editor-qr3YxpgD.js → monaco-editor-BgI79QTg.js} +1 -1
  127. package/dist/client/assets/{monitoring-stats-row-DHs40KAy.js → monitoring-stats-row-CUczTxeX.js} +1 -1
  128. package/dist/client/assets/{oauth-callback-DAEXXBSA.js → oauth-callback-DIyFvghE.js} +1 -1
  129. package/dist/client/assets/{oauth-callback-ai-provider-DGzIC1E3.js → oauth-callback-ai-provider-IS3SsI0k.js} +1 -1
  130. package/dist/client/assets/{onboarding-BQNZ1j24.js → onboarding-KfqNRkYy.js} +1 -1
  131. package/dist/client/assets/{org-install-cdxFoHPK.js → org-install-CxT0tsIO.js} +1 -1
  132. package/dist/client/assets/{org-layout-MlmaWu50.js → org-layout-BQzjU6XX.js} +1 -1
  133. package/dist/client/assets/{organization-choice-CCNhBIVu.js → organization-choice-BI1DZkDU.js} +1 -1
  134. package/dist/client/assets/{page-seo-form-B9WRtqtD.js → page-seo-form-D7JF4DTh.js} +1 -1
  135. package/dist/client/assets/page-seo-sheet-BzOt7DdS.js +1 -0
  136. package/dist/client/assets/{popover-QpTPPo-c.js → popover-Cvv98a2C.js} +1 -1
  137. package/dist/client/assets/{post-editor-DrsCS-yJ.js → post-editor-6_kkiUtL.js} +1 -1
  138. package/dist/client/assets/{primitives-BjlgEPjn.js → primitives-Bxk9aYw4.js} +1 -1
  139. package/dist/client/assets/{profile-BJ8vtOlo.js → profile-CZas9jg2.js} +1 -1
  140. package/dist/client/assets/project-app-view-xDz9FH-v.js +1 -0
  141. package/dist/client/assets/record-editor-C33gYIwT.js +1 -0
  142. package/dist/client/assets/registry-D8itHQYS.js +2 -0
  143. package/dist/client/assets/{registry-layout-ksLcOWzv.js → registry-layout-8sIvvJ4I.js} +1 -1
  144. package/dist/client/assets/{require-capability-C2pr3gWk.js → require-capability-CSyEuadx.js} +1 -1
  145. package/dist/client/assets/{required-auth-layout-BIsgDBTS.js → required-auth-layout-CH2SPOr0.js} +1 -1
  146. package/dist/client/assets/{reset-password-5xoBMew1.js → reset-password-CftvJ30J.js} +1 -1
  147. package/dist/client/assets/{roles-CTVYbrPK.js → roles-b4IJFdUQ.js} +1 -1
  148. package/dist/client/assets/{scroll-area-B7g9A0xO.js → scroll-area-CbuKwozG.js} +1 -1
  149. package/dist/client/assets/{search-input-Cn-k-Sr0.js → search-input-BJJrtkoD.js} +1 -1
  150. package/dist/client/assets/{secrets-01-N-EoG.js → secrets-xEL3iU0h.js} +1 -1
  151. package/dist/client/assets/{sections-editor-FTn-qJ5h.js → sections-editor-I7PrxFXt.js} +1 -1
  152. package/dist/client/assets/{select-DMOL9nTa.js → select-DF6YoK_r.js} +1 -1
  153. package/dist/client/assets/{select-model-DJ7qLHls.js → select-model-nui66-pH.js} +1 -1
  154. package/dist/client/assets/{seo-editor-CJg20m-v.js → seo-editor-BJAI05hX.js} +1 -1
  155. package/dist/client/assets/{settings-layout-C-lnHpnd.js → settings-layout-urJbxzRN.js} +1 -1
  156. package/dist/client/assets/{settings-section-knuBYiSB.js → settings-section-CngINngb.js} +1 -1
  157. package/dist/client/assets/{sheet-B1hdeTXZ.js → sheet-DMc7DeSX.js} +1 -1
  158. package/dist/client/assets/{shell-controls-DGQEgSmu.js → shell-controls-Bkd5dBPA.js} +1 -1
  159. package/dist/client/assets/{shell-layout-BzrEGgvG.js → shell-layout-CoG2R-A7.js} +1 -1
  160. package/dist/client/assets/{sidebar-BZHqZbJ1.js → sidebar-yJWB-4vB.js} +1 -1
  161. package/dist/client/assets/{skeleton-C1g3sLzc.js → skeleton-CEKyj6Ku.js} +1 -1
  162. package/dist/client/assets/{sso-BRP47dTR.js → sso-C_CoNDtw.js} +1 -1
  163. package/dist/client/assets/{store-COqKQ01f.js → store-B3cr8RRQ.js} +1 -1
  164. package/dist/client/assets/store-registry-0mo75fzc.js +2 -0
  165. package/dist/client/assets/{studio-tools-CK3O9apC.js → studio-tools-CEhEjTYq.js} +1 -1
  166. package/dist/client/assets/{switch-CTqoacsA.js → switch-CDv7wzZp.js} +1 -1
  167. package/dist/client/assets/{table-D9O3xZPm.js → table-_yINUqfn.js} +1 -1
  168. package/dist/client/assets/{tabs-OKKf4LAY.js → tabs-Cf3RVJ3Q.js} +1 -1
  169. package/dist/client/assets/{task-row-mk4G9x-_.js → task-row-BVs0CmAg.js} +1 -1
  170. package/dist/client/assets/{task-status-gvDe4NpG.js → task-status-VysJG0vN.js} +1 -1
  171. package/dist/client/assets/{textarea-BwMDBTqD.js → textarea-CDy5MusJ.js} +1 -1
  172. package/dist/client/assets/{toggle-group-CqoGi-AW.js → toggle-group-Dtf2CWD1.js} +1 -1
  173. package/dist/client/assets/{toolbar-Do7hu99P.js → toolbar-DeO3vJmm.js} +1 -1
  174. package/dist/client/assets/{toolbar-icon-button-D8xZWaZ4.js → toolbar-icon-button-C4_ADEJH.js} +1 -1
  175. package/dist/client/assets/{tools-list-D7bHk7AU.js → tools-list-Cn_EK2iQ.js} +1 -1
  176. package/dist/client/assets/{tooltip-jwNiafJz.js → tooltip-DlUY886I.js} +1 -1
  177. package/dist/client/assets/{types-Z9nbiCM2.js → types-CvzpcJR1.js} +1 -1
  178. package/dist/client/assets/{use-ai-providers-CaFOP2gL.js → use-ai-providers-BJKmj4My.js} +1 -1
  179. package/dist/client/assets/{use-automations-BYB1tBxg.js → use-automations-BFGNyCFk.js} +1 -1
  180. package/dist/client/assets/{use-capability-BJgOQ1dM.js → use-capability-DgzJJHkU.js} +1 -1
  181. package/dist/client/assets/{use-clock-tick-DiuTRa3m.js → use-clock-tick-BEBincp5.js} +1 -1
  182. package/dist/client/assets/{use-collections-D9VCe-RD.js → use-collections-CjkVI8cV.js} +1 -1
  183. package/dist/client/assets/{use-connection-BsHhz007.js → use-connection-ChjsmWTh.js} +1 -1
  184. package/dist/client/assets/{use-copy-BhkveYAE.js → use-copy-I4FalMZb.js} +1 -1
  185. package/dist/client/assets/{use-create-virtual-mcp-DL7SpS9p.js → use-create-virtual-mcp-BmL59nAp.js} +1 -1
  186. package/dist/client/assets/{use-debounced-autosave-CP4G_DMm.js → use-debounced-autosave-DhGwNW9j.js} +1 -1
  187. package/dist/client/assets/{use-debounced-value-qurf1YAB.js → use-debounced-value-CLg8LNax.js} +1 -1
  188. package/dist/client/assets/{use-decopilot-events-89JO9cLA.js → use-decopilot-events-uhlm9ZSC.js} +1 -1
  189. package/dist/client/assets/{use-delete-connection-CPcnCL2Y.js → use-delete-connection-CZmgFI8O.js} +1 -1
  190. package/dist/client/assets/{use-file-configs-C37Mzz_w.js → use-file-configs-aZ5m3Qj2.js} +1 -1
  191. package/dist/client/assets/{use-infinite-scroll-Dzaxo4bN.js → use-infinite-scroll-DI0qAEco.js} +1 -1
  192. package/dist/client/assets/{use-join-requests-CPgcKwb5.js → use-join-requests-CIrAIT4T.js} +1 -1
  193. package/dist/client/assets/{use-mcp-client-DAdRU1cY.js → use-mcp-client-dBNHEL6c.js} +1 -1
  194. package/dist/client/assets/{use-mcp-prompts-DbP7dBZf.js → use-mcp-prompts-D2VFS_7Z.js} +1 -1
  195. package/dist/client/assets/{use-mcp-tools-s0H1m2Ok.js → use-mcp-tools-DX5g41Xz.js} +1 -1
  196. package/dist/client/assets/{use-members-BT2wuks0.js → use-members-BeAV3T2H.js} +1 -1
  197. package/dist/client/assets/{use-mobile-CCjACM_-.js → use-mobile-7niVKoti.js} +1 -1
  198. package/dist/client/assets/{use-navigate-to-agent-CMFaBfX6.js → use-navigate-to-agent-C1tFWD13.js} +1 -1
  199. package/dist/client/assets/{use-org-auth-client-BSqoqb51.js → use-org-auth-client-CwSEkcA-.js} +1 -1
  200. package/dist/client/assets/{use-org-sso-CZi5R7ze.js → use-org-sso-CXSE3hAV.js} +1 -1
  201. package/dist/client/assets/{use-organization-roles-amhmG5-6.js → use-organization-roles-C8hy4d4V.js} +1 -1
  202. package/dist/client/assets/{use-organization-settings-DJLfSIHV.js → use-organization-settings-OjpRHnBI.js} +1 -1
  203. package/dist/client/assets/{use-registry-connections-DPtEZCsY.js → use-registry-connections-BiMSB_yO.js} +1 -1
  204. package/dist/client/assets/{use-secrets-CTWIslZA.js → use-secrets-sNifGUNT.js} +1 -1
  205. package/dist/client/assets/{use-status-sounds-Du5pinlF.js → use-status-sounds-BjM7PTwu.js} +1 -1
  206. package/dist/client/assets/{use-view-mode-C9H3mYaP.js → use-view-mode-C6xNmVYR.js} +1 -1
  207. package/dist/client/assets/{use-virtual-mcp-B0Bq3-Jt.js → use-virtual-mcp-Cy-jA6Qm.js} +1 -1
  208. package/dist/client/assets/useInfiniteQuery-CcA0p7if.js +1 -0
  209. package/dist/client/assets/useSuspenseInfiniteQuery-DXVqJ8aq.js +1 -0
  210. package/dist/client/assets/{useSuspenseQueries-BQ3vTQtS.js → useSuspenseQueries-Dg30S2DW.js} +1 -1
  211. package/dist/client/assets/{variant-calendar-DKaaO6xE.js → variant-calendar-DoCnqvSc.js} +1 -1
  212. package/dist/client/assets/{view-mode-toggle-B6q9qYR8.js → view-mode-toggle-BMDNQ_Ex.js} +1 -1
  213. package/dist/client/index.html +1 -1
  214. package/dist/server/cli.js +1 -1
  215. package/dist/server/server.js +1 -1
  216. package/package.json +1 -1
  217. package/dist/client/assets/page-seo-sheet-Da6XfVR0.js +0 -1
  218. package/dist/client/assets/project-app-view-DseQWbDi.js +0 -1
  219. package/dist/client/assets/record-editor-DbGexVfp.js +0 -1
  220. package/dist/client/assets/registry-DeMcmcPG.js +0 -2
  221. package/dist/client/assets/store-registry-DkYzijdd.js +0 -2
  222. package/dist/client/assets/useInfiniteQuery-C7fx2naq.js +0 -1
  223. package/dist/client/assets/useSuspenseInfiniteQuery-DpHAMt5e.js +0 -1
@@ -1,4 +1,4 @@
1
- import{m as It,r as g,ak as ia,ai as la,c as F,D as Se,l as K,j as a,E as ca,t as fe,o as Je,aw as ua,s as at,ax as Hn,L as da,B as ae,p as fa,n as Va,ay as ma,az as pa,I as lt,a1 as ha,aA as vt,aB as xs,b as ct,d as Wn,v as re,aC as ga,W as dr,P as xa,F as ba,aD as va,a as fr,aE as ya,aF as Vr,aG as wa,aH as De,aI as Cn,ae as st,aJ as Aa,aK as jn,aL as Sa,aM as Ca,aN as ja,aO as Na,q as Ra,K as rt,aP as ka,aQ as Ea,aR as Ia,aS as Da,aT as mr,aU as wt,k as Ta,i as _a,a2 as pr,a3 as le}from"./index-5AaNNafz.js";import{i as hr,n as Ma}from"./SwitchHorizontal01-a_i15cCW.js";import{b as Ye,u as ut,S as On,c as rn,a as gr,f as xr,s as Pa,g as Oa,h as La,i as Fa,j as br,A as $a,k as za,l as Ba}from"./chat-context-COllONR2.js";import{j as vr,s as on,g as Ke,P as qt,k as Gn,t as Ua,l as Ka,M as qa,m as Ya,n as Yt,o as yr,p as Qa,D as Ha,q as Wa,r as Ga,v as it,w as Xa,d as Ja,x as Za,y as Xn,z as ei,F as ti,i as ni,E as si,c as ri,A as oi,B as ai,H as ii,I as li,J as bs}from"./scroll-area-B7g9A0xO.js";import{c as Ln,a as Qe,b as He,T as We}from"./tooltip-jwNiafJz.js";import{c as an,a as ln,d as cn,e as un,b as Jn}from"./dialog-RRPWwqaQ.js";import{c as ci,b as ui,a as di,D as fi}from"./drawer-DJfZ0VmD.js";import{C as Vi}from"./collection-search-SaKzAiAF.js";import{u as mi}from"./use-mobile-CCjACM_-.js";import{u as dt}from"./use-mcp-client-DAdRU1cY.js";import{a as dn,S as pi,i as vs}from"./constants-C8_Swa4x.js";import{u as hi,g as fn,l as Fn}from"./use-mcp-prompts-DbP7dBZf.js";import{t as Vn}from"./ChevronDown-CJGVvA9G.js";import{i as tt}from"./X-DY9hR308.js";import{t as gi,z as xi,b as bi,w as vi,A as yi}from"./hooks-B4JA5-D1.js";import{K as wi,i as Ai}from"./shell-layout-BzrEGgvG.js";import{u as Si,a as Ci}from"./use-virtual-mcp-B0Bq3-Jt.js";import{n as wr}from"./ZapSquare-B7pUKk1h.js";import{i as Dt}from"./Check-B2t3_u8j.js";import{s as Ar}from"./Star01-CC3gyOop.js";import{a as Sr}from"./Tool01-iIXzQIf6.js";import{af as mn,B as ji,a7 as Cr,ag as Ni,A as jr,g as zt,k as Ri,a9 as ki,ah as Ei,F as Ii,ai as Nr,aj as Di,ak as Ti,c as Rr}from"./agent-icon-K57A0DzY.js";import{i as _i}from"./Upload01-COCQSA6j.js";import{i as kr}from"./AlertCircle-BWfyWgiw.js";import{a as Mi}from"./Copy01-C_1mrR9P.js";import{a as $n,b as Zn,d as es,e as ts,F as Er}from"./form-BylSC3lX.js";import{b as Pi,d as Oi,c as Li,S as Fi,a as $i}from"./select-DMOL9nTa.js";import{b as zi}from"./Settings02-Bs74lw7T.js";import{i as Ir,t as zn,b as Bi}from"./XCircle-DofnF94J.js";import{b as Ui,c as Ki}from"./tabs-OKKf4LAY.js";import{a as Dr,T as Qt}from"./toggle-group-CqoGi-AW.js";import{I as Tr}from"./input-BAz505sI.js";import{u as _r,a as qi,g as Yi,A as Qi}from"./agent-capabilities-DRUNyKs6.js";import{u as Mr}from"./studio-tools-CK3O9apC.js";import{i as ns}from"./Monitor01-EVfMwGgl.js";import{u as Pr,C as Hi,a as Or,b as Lr}from"./connect-desktop-dialog-uu1uNLI_.js";import{s as Wi}from"./XClose-CmiCfuv_.js";import{m as pn,i as Gi,g as Fr,a as Xi,N as Ji}from"./decopilot-B6qg2Op3.js";import{P as ss,a as rs,b as os}from"./popover-QpTPPo-c.js";import{e as ys,a as ws,g as Zi,b as el,C as tl,c as nl,d as sl}from"./command-DDwBnk4S.js";import{u as rl}from"./useInfiniteQuery-C7fx2naq.js";import{t as ol}from"./Stars01-DKD-uu49.js";import{q as al,r as il,s as ll,t as cl,S as ul,B as dl}from"./index-CZfoQE-0.js";import{a as fl,b as Vl,D as ml,c as Be,e as As,f as Ss,g as Cs,j as pl,i as hl}from"./dropdown-menu-DDhytuEd.js";import{s as js}from"./Plus-Cj9kK9tN.js";import{p as gl,q as xl}from"./question-004-sINsf4GQ.js";import{i as bl}from"./ChevronRight-SxNLyRA0.js";import{m as vl}from"./tab-id-CLpu897Q.js";function yl(t,e){const n=It(e);return wl({filters:{...t,status:"pending"}},n).length}function Ns(t,e){return t.findAll(e.filters).map(n=>e.select?e.select(n):n.state)}function wl(t={},e){const n=It(e).getMutationCache(),s=g.useRef(t),r=g.useRef(null);return r.current===null&&(r.current=Ns(n,t)),g.useEffect(()=>{s.current=t}),g.useSyncExternalStore(g.useCallback(o=>n.subscribe(()=>{const i=ia(r.current,Ns(n,s.current));r.current!==i&&(r.current=i,la.schedule(o))}),[n]),()=>r.current,()=>r.current)}const Rs=3,$r="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",Al="flex flex-col gap-1.5 p-4 rounded-xl bg-accent/40 text-sm leading-snug transition-colors cursor-pointer text-left";function zr(t){const e=F.c(46),{item:n,onSelect:s,isLoading:r,isDisabled:o,variant:i}=t,l=i===void 0?"pill":i,{prompt:u}=n;let d;if(e[0]!==u._meta||e[1]!==u.name||e[2]!==u.title){const w=Ke(u._meta);d=u.title??Gn(u.name,w),e[0]=u._meta,e[1]=u.name,e[2]=u.title,e[3]=d}else d=e[3];const f=d,c=u.description||null;if(l==="card"){let w;e[4]!==s||e[5]!==u?(w=()=>s(u),e[4]=s,e[5]=u,e[6]=w):w=e[6];const S=o||r,N=r&&"bg-accent/40",E=(o||r)&&"cursor-not-allowed opacity-50";let k;e[7]!==N||e[8]!==E?(k=K(Al,"hover:bg-accent/60 text-foreground",N,E),e[7]=N,e[8]=E,e[9]=k):k=e[9];let _;e[10]!==f?(_=a.jsx("span",{className:"font-medium truncate capitalize",children:f}),e[10]=f,e[11]=_):_=e[11];let D;e[12]!==r?(D=r&&a.jsx(On,{size:"xs"}),e[12]=r,e[13]=D):D=e[13];let R;e[14]!==_||e[15]!==D?(R=a.jsxs("div",{className:"flex items-center justify-between gap-2",children:[_,D]}),e[14]=_,e[15]=D,e[16]=R):R=e[16];let P;e[17]!==c?(P=c&&a.jsx("span",{className:"text-xs text-muted-foreground line-clamp-2",children:c}),e[17]=c,e[18]=P):P=e[18];let I;return e[19]!==R||e[20]!==P||e[21]!==w||e[22]!==S||e[23]!==k?(I=a.jsxs("button",{type:"button",onClick:w,disabled:S,className:k,children:[R,P]}),e[19]=R,e[20]=P,e[21]=w,e[22]=S,e[23]=k,e[24]=I):I=e[24],I}let m;e[25]!==s||e[26]!==u?(m=()=>s(u),e[25]=s,e[26]=u,e[27]=m):m=e[27];const V=o||r,x=r&&"bg-muted/50",p=(o||r)&&"cursor-not-allowed opacity-50";let h;e[28]!==x||e[29]!==p?(h=K($r,"hover:bg-muted/70 hover:text-foreground",x,p),e[28]=x,e[29]=p,e[30]=h):h=e[30];let v;e[31]!==f?(v=a.jsx("span",{className:"capitalize",children:f}),e[31]=f,e[32]=v):v=e[32];let b;e[33]!==r?(b=r&&a.jsx(On,{size:"xs"}),e[33]=r,e[34]=b):b=e[34];let y;e[35]!==m||e[36]!==V||e[37]!==h||e[38]!==v||e[39]!==b?(y=a.jsx(Qe,{asChild:!0,children:a.jsxs("button",{type:"button",onClick:m,disabled:V,className:h,children:[v,b]})}),e[35]=m,e[36]=V,e[37]=h,e[38]=v,e[39]=b,e[40]=y):y=e[40];const C=c??f;let j;e[41]!==C?(j=a.jsx(He,{side:"top",className:"max-w-xs",children:a.jsx("p",{className:"text-xs",children:C})}),e[41]=C,e[42]=j):j=e[42];let A;return e[43]!==y||e[44]!==j?(A=a.jsxs(We,{delayDuration:400,children:[y,j]}),e[43]=y,e[44]=j,e[45]=A):A=e[45],A}function Sl(t){const e=F.c(41),{items:n,open:s,onOpenChange:r,onSelect:o,loadingPrompt:i}=t,[l,u]=g.useState(""),d=!!i;let f;e[0]!==n||e[1]!==l?(f=l.trim()?n.filter(S=>{const N=l.toLowerCase();return S.prompt.name.toLowerCase().includes(N)||(S.prompt.title??"").toLowerCase().includes(N)||(S.prompt.description??"").toLowerCase().includes(N)}):n,e[0]=n,e[1]=l,e[2]=f):f=e[2];const c=f,m=mi();let V;e[3]!==c.length||e[4]!==l?(V=c.length===0&&a.jsxs("p",{className:"col-span-4 text-sm text-muted-foreground text-center py-8",children:["No prompts match “",l,"”"]}),e[3]=c.length,e[4]=l,e[5]=V):V=e[5];let x;if(e[6]!==c||e[7]!==d||e[8]!==i?.name||e[9]!==r||e[10]!==o){let S;e[12]!==d||e[13]!==i?.name||e[14]!==r||e[15]!==o?(S=N=>a.jsx(zr,{item:N,variant:"card",onSelect:E=>{r(!1),o(E)},isLoading:i?.name===N.prompt.name,isDisabled:d&&i?.name!==N.prompt.name},N.prompt.name),e[12]=d,e[13]=i?.name,e[14]=r,e[15]=o,e[16]=S):S=e[16],x=c.map(S),e[6]=c,e[7]=d,e[8]=i?.name,e[9]=r,e[10]=o,e[11]=x}else x=e[11];let p;e[17]!==V||e[18]!==x?(p=a.jsx("div",{className:"flex-1 overflow-y-auto [scrollbar-gutter:stable]",children:a.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-4 gap-3 p-5",children:[V,x]})}),e[17]=V,e[18]=x,e[19]=p):p=e[19];const h=p;let v;e[20]===Symbol.for("react.memo_cache_sentinel")?(v=S=>{S.key==="Escape"&&u("")},e[20]=v):v=e[20];let b;e[21]!==l?(b=a.jsx(Vi,{value:l,onChange:u,placeholder:"Search prompts...",onKeyDown:v}),e[21]=l,e[22]=b):b=e[22];const y=b;if(m){let S;e[23]===Symbol.for("react.memo_cache_sentinel")?(S=a.jsx(ci,{className:"sr-only",children:a.jsx(ui,{children:"All prompts"})}),e[23]=S):S=e[23];let N;e[24]===Symbol.for("react.memo_cache_sentinel")?(N=a.jsx("div",{className:"flex items-center h-12 border-b border-border px-4 shrink-0",children:a.jsx("span",{className:"text-sm font-medium text-foreground",children:"Prompts"})}),e[24]=N):N=e[24];let E;e[25]!==h||e[26]!==y?(E=a.jsxs(di,{className:"h-[85vh] flex flex-col p-0 gap-0",children:[S,N,y,h]}),e[25]=h,e[26]=y,e[27]=E):E=e[27];let k;return e[28]!==r||e[29]!==s||e[30]!==E?(k=a.jsx(Ln,{delayDuration:400,children:a.jsx(fi,{open:s,onOpenChange:r,children:E})}),e[28]=r,e[29]=s,e[30]=E,e[31]=k):k=e[31],k}let C;e[32]===Symbol.for("react.memo_cache_sentinel")?(C=a.jsx(an,{className:"sr-only",children:a.jsx(ln,{children:"All prompts"})}),e[32]=C):C=e[32];let j;e[33]===Symbol.for("react.memo_cache_sentinel")?(j=a.jsx("div",{className:"flex items-center h-12 border-b border-border px-4 shrink-0",children:a.jsx("span",{className:"text-sm font-medium text-foreground",children:"Prompts"})}),e[33]=j):j=e[33];let A;e[34]!==h||e[35]!==y?(A=a.jsxs(cn,{className:"sm:max-w-[1100px] h-[680px] p-0 gap-0 overflow-hidden flex flex-col",children:[C,j,y,h]}),e[34]=h,e[35]=y,e[36]=A):A=e[36];let w;return e[37]!==r||e[38]!==s||e[39]!==A?(w=a.jsx(Ln,{delayDuration:400,children:a.jsx(un,{open:s,onOpenChange:r,children:A})}),e[37]=r,e[38]=s,e[39]=A,e[40]=w):w=e[40],w}function Cl(t){const e=F.c(29),{items:n,onSelect:s,loadingPrompt:r,className:o}=t,[i,l]=g.useState(!1);if(n.length===0)return null;let u,d,f;if(e[0]!==n||e[1]!==r||e[2]!==s){const v=n.slice(0,Rs);let b;e[6]!==n?(b=n.slice(Rs),e[6]=n,e[7]=b):b=e[7],u=b,d=!!r;let y;e[8]!==d||e[9]!==r?.name||e[10]!==s?(y=C=>a.jsx(zr,{item:C,onSelect:s,isLoading:r?.name===C.prompt.name,isDisabled:d&&r?.name!==C.prompt.name},C.prompt.name),e[8]=d,e[9]=r?.name,e[10]=s,e[11]=y):y=e[11],f=v.map(y),e[0]=n,e[1]=r,e[2]=s,e[3]=u,e[4]=d,e[5]=f}else u=e[3],d=e[4],f=e[5];const c=f;let m;e[12]!==o?(m=K("w-full flex flex-wrap gap-2 justify-center",o),e[12]=o,e[13]=m):m=e[13];let V;e[14]!==u.length||e[15]!==d?(V=u.length>0&&a.jsxs("button",{type:"button",disabled:d,onClick:()=>l(!0),className:K($r,"hover:bg-muted/70 hover:text-foreground",d&&"opacity-50 cursor-not-allowed"),children:["+",u.length," more"]}),e[14]=u.length,e[15]=d,e[16]=V):V=e[16];let x;e[17]!==c||e[18]!==m||e[19]!==V?(x=a.jsxs("div",{className:m,children:[c,V]}),e[17]=c,e[18]=m,e[19]=V,e[20]=x):x=e[20];let p;e[21]!==n||e[22]!==r||e[23]!==i||e[24]!==s?(p=a.jsx(Sl,{items:n,open:i,onOpenChange:l,onSelect:s,loadingPrompt:r}),e[21]=n,e[22]=r,e[23]=i,e[24]=s,e[25]=p):p=e[25];let h;return e[26]!==x||e[27]!==p?(h=a.jsxs(Ln,{delayDuration:400,children:[x,p]}),e[26]=x,e[27]=p,e[28]=h):h=e[28],h}function jl(){return null}function Nl(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 Rl(t){const e=F.c(30),{connectionId:n}=t,{sendMessage:s}=ut(),{org:r}=Se();let o;e[0]!==n||e[1]!==r.id||e[2]!==r.slug?(o={connectionId:n,orgId:r.id,orgSlug:r.slug},e[0]=n,e[1]=r.id,e[2]=r.slug,e[3]=o):o=e[3];const i=dt(o);let l;e[4]!==i?(l={client:i,staleTime:6e4},e[4]=i,e[5]=l):l=e[5];const{data:u}=hi(l);let d;e[6]!==u?.prompts?(d=u?.prompts??[],e[6]=u?.prompts,e[7]=d):d=e[7];const f=d;let c;e[8]!==f?(c=f.map(kl),e[8]=f,e[9]=c):c=e[9];const m=c;let V;e[10]===Symbol.for("react.memo_cache_sentinel")?(V={stage:"idle"},e[10]=V):V=e[10];const[x,p]=g.useReducer(Nl,V),[h,v]=g.useState(null);let b;e[11]!==i||e[12]!==s?(b=async(D,R)=>{if(!i){fe.error("MCP client not available"),p({type:"RESET"});return}try{const P=await fn(i,D.name,R);p({type:"RESET"});const I={type:"doc",content:[{type:"paragraph",content:[vr({id:D.name,name:on(D.name,Ke(D._meta)),metadata:P.messages,char:"/",kind:"prompt",args:R}),{type:"text",text:" "}]}]};await s(I)}catch(P){console.error("[ice-breakers] Failed to fetch prompt:",P),fe.error("Failed to load prompt. Please try again."),p({type:"RESET"})}},e[11]=i,e[12]=s,e[13]=b):b=e[13];const y=b;let C;e[14]!==y?(C=async D=>{if(D.arguments&&D.arguments.length>0){p({type:"SELECT_PROMPT",prompt:D}),v(D);return}p({type:"START_LOADING",prompt:D}),await y(D)},e[14]=y,e[15]=C):C=e[15];const j=C;let A;e[16]!==h||e[17]!==y?(A=async D=>{h&&(p({type:"START_LOADING",prompt:h,arguments:D}),v(null),await y(h,D))},e[16]=h,e[17]=y,e[18]=A):A=e[18];const w=A;if(m.length===0)return null;const S=x.stage==="loading"?x.prompt:null;let N;e[19]!==j||e[20]!==m||e[21]!==S?(N=a.jsx(Cl,{items:m,onSelect:j,loadingPrompt:S}),e[19]=j,e[20]=m,e[21]=S,e[22]=N):N=e[22];let E;e[23]===Symbol.for("react.memo_cache_sentinel")?(E=()=>{v(null),p({type:"RESET"})},e[23]=E):E=e[23];let k;e[24]!==h||e[25]!==w?(k=a.jsx(qt,{prompt:h,setPrompt:E,onSubmit:w}),e[24]=h,e[25]=w,e[26]=k):k=e[26];let _;return e[27]!==N||e[28]!==k?(_=a.jsxs(a.Fragment,{children:[N,k]}),e[27]=N,e[28]=k,e[29]=_):_=e[29],_}function kl(t){return{prompt:t}}function El(t){const e=F.c(13),{className:n}=t,{selectedVirtualMcp:s}=Ye(),{org:r}=Se();let o;e[0]!==r.id?(o=dn(r.id),e[0]=r.id,e[1]=o):o=e[1];const i=o.id,l=s?.id??i;let u;e[2]!==n?(u=K("w-full @container",n),e[2]=n,e[3]=u):u=e[3];const d=l??"default";let f;e[4]===Symbol.for("react.memo_cache_sentinel")?(f=a.jsx(jl,{}),e[4]=f):f=e[4];let c;e[5]!==l?(c=a.jsx(Rl,{connectionId:l}),e[5]=l,e[6]=c):c=e[6];let m;e[7]!==d||e[8]!==c?(m=a.jsx(ca,{fallback:null,children:a.jsx(g.Suspense,{fallback:f,children:c},d)}),e[7]=d,e[8]=c,e[9]=m):m=e[9];let V;return e[10]!==u||e[11]!==m?(V=a.jsx("div",{className:u,children:m}),e[10]=u,e[11]=m,e[12]=V):V=e[12],V}const Nn="cubic-bezier(0.645, 0.045, 0.355, 1)",Il=44,Dl={default:"",error:"isolate after:content-[''] after:absolute after:inset-0 after:rounded-xl after:bg-destructive/5 after:pointer-events-none after:-z-10",warning:"isolate after:content-[''] after:absolute after:inset-0 after:rounded-xl after:bg-amber-500/5 after:pointer-events-none after:-z-10"},Tl={default:"border-border",error:"border-destructive/30",warning:"border-amber-500/30"},_l={default:"text-muted-foreground",error:"text-destructive",warning:"text-amber-600 dark:text-amber-500"};function qe(t){const e=F.c(61),{icon:n,label:s,count:r,title:o,footerLeft:i,footerRight:l,children:u,defaultExpanded:d,variant:f,onClose:c}=t,m=f===void 0?"default":f,[V,x]=g.useState(d),[p,h]=g.useState(!1);let v;e[0]!==c?(v=()=>{h(!0),c?.()},e[0]=c,e[1]=v):v=e[1];const b=v;if(p)return null;const y=Tl[m],C=Dl[m];let j;e[2]!==y||e[3]!==C?(j=K("relative flex flex-col rounded-xl bg-background border shadow-md","w-[calc(100%-16px)] max-w-[640px] mx-auto mb-2",y,C),e[2]=y,e[3]=C,e[4]=j):j=e[4];let A;e[5]===Symbol.for("react.memo_cache_sentinel")?(A=()=>x(Ml),e[5]=A):A=e[5];const w=V&&"rounded-b-none",S=!V&&"rounded-b-xl";let N;e[6]!==w||e[7]!==S?(N=K("flex items-center gap-2 w-full px-3 py-2 text-sm text-left","hover:bg-accent/50 transition-colors rounded-t-xl",w,S),e[6]=w,e[7]=S,e[8]=N):N=e[8];const E=_l[m];let k;e[9]!==E?(k=K("shrink-0",E),e[9]=E,e[10]=k):k=e[10];let _;e[11]!==n||e[12]!==k?(_=a.jsx("span",{className:k,children:n}),e[11]=n,e[12]=k,e[13]=_):_=e[13];let D;e[14]!==s?(D=a.jsx("span",{className:"flex-1 min-w-0 truncate",children:s}),e[14]=s,e[15]=D):D=e[15];let R;e[16]!==r?(R=r?a.jsx("span",{className:"text-xs text-muted-foreground shrink-0",children:r}):null,e[16]=r,e[17]=R):R=e[17];const P=V?"rotate(180deg)":"rotate(0deg)";let I;e[18]!==P?(I=a.jsx("span",{"aria-hidden":"true",className:"text-muted-foreground shrink-0 flex items-center justify-center",children:a.jsx(Vn,{size:16,style:{transform:P,transition:`transform 180ms ${Nn}`}})}),e[18]=P,e[19]=I):I=e[19];let T,M;e[20]!==b?(T=ne=>{ne.stopPropagation(),b()},M=ne=>{(ne.key==="Enter"||ne.key===" ")&&(ne.preventDefault(),ne.stopPropagation(),b())},e[20]=b,e[21]=T,e[22]=M):(T=e[21],M=e[22]);let L;e[23]===Symbol.for("react.memo_cache_sentinel")?(L=a.jsx(tt,{size:16}),e[23]=L):L=e[23];let U;e[24]!==T||e[25]!==M?(U=a.jsx("span",{role:"button",tabIndex:0,"data-testid":"collapsible-highlight-close","aria-label":"Close",title:"Close",onClick:T,onKeyDown:M,className:"text-muted-foreground hover:text-foreground transition-colors shrink-0 flex items-center justify-center -mr-1 ml-1 p-1 rounded-md hover:bg-accent",children:L}),e[24]=T,e[25]=M,e[26]=U):U=e[26];let $;e[27]!==V||e[28]!==_||e[29]!==D||e[30]!==R||e[31]!==I||e[32]!==U||e[33]!==N?($=a.jsxs("button",{type:"button","data-testid":"collapsible-highlight-chip","aria-expanded":V,onClick:A,className:N,children:[_,D,R,I,U]}),e[27]=V,e[28]=_,e[29]=D,e[30]=R,e[31]=I,e[32]=U,e[33]=N,e[34]=$):$=e[34];const B=V?"1fr":"0fr";let q;e[35]!==B?(q={display:"grid",gridTemplateRows:B,transition:`grid-template-rows 180ms ${Nn}`},e[35]=B,e[36]=q):q=e[36];let Q;e[37]===Symbol.for("react.memo_cache_sentinel")?(Q={overflow:"hidden",minHeight:0},e[37]=Q):Q=e[37];const O=V?1:0;let z;e[38]!==O?(z={opacity:O,transition:`opacity 120ms ${Nn}`},e[38]=O,e[39]=z):z=e[39];let W;e[40]!==o?(W=o?a.jsx("div",{className:"flex items-start gap-2 px-4 pt-4 pb-5 border-t border-dashed border-border/60",children:a.jsx("p",{className:"flex-1 text-base font-medium text-foreground min-w-0",children:o})}):a.jsx("div",{className:"border-t border-dashed border-border/60"}),e[40]=o,e[41]=W):W=e[41];let H;e[42]!==u||e[43]!==o?(H=u?a.jsx("div",{className:K("overflow-clip pb-4",!o&&"pt-4"),children:u}):null,e[42]=u,e[43]=o,e[44]=H):H=e[44];let X;e[45]!==i||e[46]!==l?(X=i||l?a.jsx("div",{className:"border-t border-border px-3 py-3 pb-6",children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("div",{children:i}),a.jsx("div",{className:"flex items-center gap-2",children:l})]})}):null,e[45]=i,e[46]=l,e[47]=X):X=e[47];let Y;e[48]!==z||e[49]!==W||e[50]!==H||e[51]!==X?(Y=a.jsx("div",{style:Q,children:a.jsxs("div",{style:z,children:[W,H,X]})}),e[48]=z,e[49]=W,e[50]=H,e[51]=X,e[52]=Y):Y=e[52];let te;e[53]!==q||e[54]!==Y?(te=a.jsx("div",{"data-testid":"collapsible-highlight-body",style:q,children:Y}),e[53]=q,e[54]=Y,e[55]=te):te=e[55];let J;return e[56]!==$||e[57]!==te||e[58]!==j||e[59]!==m?(J=a.jsxs("div",{"data-testid":"collapsible-highlight","data-variant":m,className:j,children:[$,te]}),e[56]=$,e[57]=te,e[58]=j,e[59]=m,e[60]=J):J=e[60],J}function Ml(t){return!t}const Pl=Je({content:at().min(1).describe("Imperative form, e.g. 'Implement the login flow'"),status:Hn(["pending","in_progress","completed"]),activeForm:at().min(1).describe("Present-continuous form shown in the UI while the todo is in progress, e.g. 'Implementing the login flow'")}),Br=Je({todos:ua(Pl)}),Ol="Plan and track multi-step work. Call with the FULL todo list every time — this replaces the prior list. Call at the start of every multi-step request. Skip only for true one-shots (a single tool call or a direct answer). Mark exactly one todo `in_progress` at a time. Flip a todo to `in_progress` before starting it and to `completed` the moment it finishes — do not batch completions. Your prior tool-call inputs are your current state — read your last call to see where you are.";gi({description:Ol,inputSchema:xi(Br),execute:async({todos:t})=>({ok:!0,count:t.length})});const Ll="tool-todo_write",Fl=new Set(["input-available","output-available"]);function Ur(t){for(let e=t.length-1;e>=0;e--){const n=t[e];if(n.role!=="assistant")continue;const s=n.parts;if(Array.isArray(s))for(let r=s.length-1;r>=0;r--){const o=s[r];if(o.type!==Ll||typeof o.state!="string"||!Fl.has(o.state))continue;const i=Br.safeParse(o.input);if(i.success)return i.data.todos}}return[]}function Kr(t){const e=[];for(const n of t)if("state"in n&&n.state==="approval-requested"&&"approval"in n&&n.approval?.id&&"toolCallId"in n&&n.toolCallId){const s="toolName"in n&&typeof n.toolName=="string"?n.toolName:n.type.startsWith("tool-")?n.type.replace("tool-",""):"Tool";e.push({approvalId:n.approval.id,toolCallId:n.toolCallId,toolName:s,friendlyName:Ua(Ka(s)),input:n.input})}return e}function qr(t){const e=[];for(const n of t)if("type"in n&&n.type==="tool-propose_plan"&&"state"in n&&n.state==="input-available"&&"toolCallId"in n&&"input"in n){const s=n.input;e.push({toolCallId:n.toolCallId,plan:s.plan,state:n.state})}return e}function $l(t){return t?t.message.startsWith("[CREDITS]"):!1}const zl={isCreditExhausted:!1,hasTodos:!1,showError:!1,showWarning:!1,hasApprovals:!1,hasPlans:!1,isWaitingForUserInput:!1};function Bl(t){const{messages:e,error:n,finishReason:s,isStreaming:r,isWaitingForApprovals:o}=t;if(!r&&n&&$l(n))return{...zl,isCreditExhausted:!0};const i=e.at(-1),l=i?.role==="assistant"?i.parts:[],u=l,f=!!u.filter(y=>y.type==="tool-user_ask").filter(y=>y.state!=="output-available").length,c=qr(l),m=Kr(u),V=Ur(e),x=!r&&!!n,p=m.length>0||r&&o,h=c.length>0,b=!r&&!!s&&s!=="stop"&&!(s==="tool-calls"&&(f||p||h))&&!x;return{isCreditExhausted:!1,hasTodos:V.length>0,showError:x,showWarning:b,hasApprovals:p,hasPlans:h,isWaitingForUserInput:f}}function Yr(){const t=F.c(6),{messages:e,error:n,finishReason:s,isStreaming:r,isWaitingForApprovals:o}=ut(),i=n??null,l=s??null;let u;return t[0]!==r||t[1]!==o||t[2]!==e||t[3]!==i||t[4]!==l?(u=Bl({messages:e,error:i,finishReason:l,isStreaming:r,isWaitingForApprovals:o}),t[0]=r,t[1]=o,t[2]=e,t[3]=i,t[4]=l,t[5]=u):u=t[5],u}function Ul(){const t=Yr();return t.isCreditExhausted?0:Number(t.hasTodos)+Number(t.showError)+Number(t.showWarning)+Number(t.hasApprovals)+Number(t.hasPlans)+Number(t.isWaitingForUserInput)}function Qr(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(n=>n.type==="hardBreak"||n.type==="text"&&(!n.text||n.text.trim()==="")):!1)}const Kl="__home__";function as(t,e){return da.chatDraft(t,e)}function ql(t){if(!t)return null;let e;try{e=JSON.parse(t)}catch{return null}if(!e||typeof e!="object"||typeof e.updatedAt!="number")return null;const n=e.tiptapDoc;return!n||typeof n!="object"||n.type!=="doc"||!Array.isArray(n.content)?null:n}function Yl(t,e,n,s,r){const o=as(e,n);if(Qr(s)){t.removeItem(o);return}const i={tiptapDoc:s,updatedAt:Date.now()},l=JSON.stringify(i);try{t.setItem(o,l)}catch(u){if(Hl(u)){const d=new TextEncoder().encode(l).byteLength;r?.onQuotaExceeded?.({docSizeBytes:d});return}throw u}}function ks(t,e,n){const s=as(e,n),r=t.getItem(s),o=ql(r);return r!==null&&o===null&&t.removeItem(s),o}function Ql(t,e,n){t.removeItem(as(e,n))}function Hl(t){if(!t||typeof t!="object")return!1;const e=t.name;return e==="QuotaExceededError"||e==="NS_ERROR_DOM_QUOTA_REACHED"}function Wl(t){const e=F.c(21),{current:n,total:s,onPrev:r,onNext:o}=t;if(s<=1)return null;const i=n===0,l=n===0?"opacity-30 cursor-not-allowed":"hover:text-foreground cursor-pointer";let u;e[0]!==l?(u=K("p-0.5 rounded transition-colors",l),e[0]=l,e[1]=u):u=e[1];let d;e[2]===Symbol.for("react.memo_cache_sentinel")?(d=a.jsx(zi,{size:14}),e[2]=d):d=e[2];let f;e[3]!==r||e[4]!==i||e[5]!==u?(f=a.jsx("button",{type:"button",onClick:r,disabled:i,className:u,"aria-label":"Previous question",children:d}),e[3]=r,e[4]=i,e[5]=u,e[6]=f):f=e[6];const c=n+1;let m;e[7]!==c||e[8]!==s?(m=a.jsxs("span",{className:"tabular-nums text-xs",children:[c," of ",s]}),e[7]=c,e[8]=s,e[9]=m):m=e[9];const V=n===s-1,x=n===s-1?"opacity-30 cursor-not-allowed":"hover:text-foreground cursor-pointer";let p;e[10]!==x?(p=K("p-0.5 rounded transition-colors",x),e[10]=x,e[11]=p):p=e[11];let h;e[12]===Symbol.for("react.memo_cache_sentinel")?(h=a.jsx(Ir,{size:14}),e[12]=h):h=e[12];let v;e[13]!==o||e[14]!==p||e[15]!==V?(v=a.jsx("button",{type:"button",onClick:o,disabled:V,className:p,"aria-label":"Next question",children:h}),e[13]=o,e[14]=p,e[15]=V,e[16]=v):v=e[16];let b;return e[17]!==v||e[18]!==f||e[19]!==m?(b=a.jsxs("div",{className:"flex items-center gap-1 text-sm text-muted-foreground",children:[f,m,v]}),e[17]=v,e[18]=f,e[19]=m,e[20]=b):b=e[20],b}function Hr(t){const e=F.c(8),{currentIndex:n,total:s,onPrev:r,onNext:o,extraLeft:i}=t;let l;e[0]!==n||e[1]!==o||e[2]!==r||e[3]!==s?(l=a.jsx(Wl,{current:n,total:s,onPrev:r,onNext:o}),e[0]=n,e[1]=o,e[2]=r,e[3]=s,e[4]=l):l=e[4];let u;return e[5]!==i||e[6]!==l?(u=a.jsxs("div",{className:"flex items-center gap-2",children:[l,i]}),e[5]=i,e[6]=l,e[7]=u):u=e[7],u}function Gl(t){const e=F.c(17),{isStreaming:n,isAllAnswered:s,isCurrentAnswered:r,onAdvanceOrSubmit:o,submitLabel:i,nextLabel:l}=t,f=s?i===void 0?"Submit":i:l===void 0?"Next":l,c=s?n:!r,m=c?s?"Waiting for the assistant to finish…":"Answer this item to continue":null;let V;e[0]!==c||e[1]!==o?(V=()=>{c||o()},e[0]=c,e[1]=o,e[2]=V):V=e[2];const x=c&&"opacity-50 cursor-not-allowed";let p;e[3]!==x?(p=K("h-7 px-2.5 text-xs",x),e[3]=x,e[4]=p):p=e[4];let h;e[5]!==c||e[6]!==f||e[7]!==V||e[8]!==p?(h=a.jsx(ae,{type:"button",size:"sm","aria-disabled":c,onClick:V,className:p,children:f}),e[5]=c,e[6]=f,e[7]=V,e[8]=p,e[9]=h):h=e[9];const v=h;if(!m)return v;let b;e[10]!==v?(b=a.jsx(Qe,{asChild:!0,children:v}),e[10]=v,e[11]=b):b=e[11];let y;e[12]!==m?(y=a.jsx(He,{children:m}),e[12]=m,e[13]=y):y=e[13];let C;return e[14]!==b||e[15]!==y?(C=a.jsxs(We,{children:[b,y]}),e[14]=b,e[15]=y,e[16]=C):C=e[16],C}function Wr(t,e,n){return t.findIndex(s=>e(s)===n)}function Es(t,e,n,s){return t.length===0?!1:t.every(r=>s(n[e(r)]))}function Is(t,e,n,s,r){if(t.length===0)return null;const o=Wr(t,e,r);for(let i=1;i<=t.length;i++){const l=t[(o+i)%t.length];if(!l)continue;const u=e(l);if(u!==r&&!s(n[u]))return u}return null}function Xl(t){return!t.isStreaming&&t.allAnswered}function Gr(t){const{parts:e,partKey:n,schema:s,defaultValues:r,isStreaming:o,hasAnswer:i,onSubmit:l}=t,u=e[0]?n(e[0]):"",[d,f]=g.useState(u),[c,m]=g.useState(!1),V=fa({resolver:Va(s),defaultValues:r}),x=V.watch(),p=Wr(e,n,d),h=p>=0?e[p]:void 0,v=i(x[d]),b=Es(e,n,x,i),y=Xl({isStreaming:o,allAnswered:b}),C=()=>{if(p>0){const k=e[p-1];k&&f(n(k))}},j=()=>{if(p>=0&&p<e.length-1){const k=e[p+1];k&&f(n(k))}},A=()=>{const k=V.getValues(),_=Is(e,n,k,i,d);_&&f(_)},w=()=>{V.handleSubmit(k=>{const _=k;for(const D of e)l(D,_[n(D)])})()},S=g.useRef(w);S.current=w;const N=()=>{y&&(m(!1),S.current())},E=()=>{const k=V.getValues();if(Es(e,n,k,i)){if(o){m(!0);return}m(!1),S.current()}else{const _=Is(e,n,k,i,d);_&&f(_)}};return g.useEffect(()=>{if(c&&!o){if(!b){m(!1);return}m(!1),S.current()}},[c,o,b]),{form:V,activeKey:d,setActiveKey:f,currentIndex:p,currentPart:h,isCurrentAnswered:v,isAllAnswered:b,canSubmit:y,goPrev:C,goNext:j,advanceToNextUnanswered:A,submit:N,submitOrAdvance:E}}const Xr="User denied this tool call, give other alternatives.";function Jr(t){const e=F.c(9),{onYolo:n}=t,[s,r]=lt();let o;e[0]!==n||e[1]!==s||e[2]!==r?(o=f=>{const c=f,m=s.toolApprovalLevel??"readonly";r({...s,toolApprovalLevel:c}),c==="auto"&&n(m)},e[0]=n,e[1]=s,e[2]=r,e[3]=o):o=e[3];const i=o;let l;e[4]===Symbol.for("react.memo_cache_sentinel")?(l=a.jsx(Fi,{size:"xs",className:"text-xs text-muted-foreground border-border/60 bg-transparent hover:bg-accent/60 h-7 gap-1",onClick:Zl,children:a.jsx($i,{})}),e[4]=l):l=e[4];let u;e[5]===Symbol.for("react.memo_cache_sentinel")?(u=a.jsx(Pi,{children:vt.map(Jl)}),e[5]=u):u=e[5];let d;return e[6]!==i||e[7]!==s.toolApprovalLevel?(d=a.jsxs(Oi,{value:s.toolApprovalLevel,onValueChange:i,children:[l,u]}),e[6]=i,e[7]=s.toolApprovalLevel,e[8]=d):d=e[8],d}function Jl(t){return a.jsx(Li,{value:t.value,children:t.label},t.value)}function Zl(t){return t.stopPropagation()}function Zr(t){const e=F.c(5),{input:n}=t;if(n==null){let o;return e[0]===Symbol.for("react.memo_cache_sentinel")?(o=a.jsx("div",{className:"px-4 text-xs text-muted-foreground",children:"No input"}),e[0]=o):o=e[0],o}let s;try{let o;e[1]!==n?(o=JSON.stringify(n,null,2),e[1]=n,e[2]=o):o=e[2],s=o}catch{s=String(n)}let r;return e[3]!==s?(r=a.jsx("div",{className:"px-4",children:a.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:s})}),e[3]=s,e[4]=r):r=e[4],r}function ec(t){const e=F.c(28),{approval:n,onRespond:s}=t,[r]=lt(),o=r.toolApprovalLevel??"readonly";let i;e[0]!==n.approvalId||e[1]!==o||e[2]!==s?(i=()=>s(n.approvalId,!1,Xr,o),e[0]=n.approvalId,e[1]=o,e[2]=s,e[3]=i):i=e[3];const l=i;let u;e[4]!==n.approvalId||e[5]!==o||e[6]!==s?(u=()=>s(n.approvalId,!0,void 0,o),e[4]=n.approvalId,e[5]=o,e[6]=s,e[7]=u):u=e[7];const d=u;let f;e[8]!==n.approvalId||e[9]!==s?(f=j=>s(n.approvalId,!0,void 0,j),e[8]=n.approvalId,e[9]=s,e[10]=f):f=e[10];const c=f;let m;e[11]!==c?(m=a.jsx("div",{className:"flex items-center gap-2",children:a.jsx(Jr,{onYolo:c})}),e[11]=c,e[12]=m):m=e[12];const V=m;let x;e[13]!==l?(x=a.jsx(ae,{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:l,children:"Deny"}),e[13]=l,e[14]=x):x=e[14];let p;e[15]!==d?(p=a.jsx(ae,{type:"button",size:"sm",className:"h-7 px-2.5 text-xs active:scale-[0.97] transition-transform",onClick:d,children:"Accept"}),e[15]=d,e[16]=p):p=e[16];let h;e[17]!==x||e[18]!==p?(h=a.jsxs(a.Fragment,{children:[x,p]}),e[17]=x,e[18]=p,e[19]=h):h=e[19];const v=h;let b;e[20]===Symbol.for("react.memo_cache_sentinel")?(b=a.jsx(mn,{size:14}),e[20]=b):b=e[20];let y;e[21]!==n.input?(y=a.jsx(Zr,{input:n.input}),e[21]=n.input,e[22]=y):y=e[22];let C;return e[23]!==n.friendlyName||e[24]!==V||e[25]!==v||e[26]!==y?(C=a.jsx(qe,{icon:b,label:"Approval needed",title:n.friendlyName,defaultExpanded:!0,footerLeft:V,footerRight:v,children:y}),e[23]=n.friendlyName,e[24]=V,e[25]=v,e[26]=y,e[27]=C):C=e[27],C}const tc=ma(at(),Je({approved:pa().optional(),levelOverride:Hn(["auto","readonly"]).optional()}));function nc(t){const e=F.c(42),{approvals:n,isStreaming:s,onRespond:r}=t,[o]=lt(),i=o.toolApprovalLevel??"readonly";let l;e[0]!==n?(l=Object.fromEntries(n.map(oc)),e[0]=n,e[1]=l):l=e[1];const u=l;let d;e[2]!==i||e[3]!==r?(d=(E,k)=>{const _=k;typeof _?.approved=="boolean"&&r(E.approvalId,_.approved,_.approved===!1?Xr:void 0,_.levelOverride??i)},e[2]=i,e[3]=r,e[4]=d):d=e[4];let f;e[5]!==n||e[6]!==u||e[7]!==s||e[8]!==d?(f={parts:n,partKey:rc,schema:tc,defaultValues:u,isStreaming:s,hasAnswer:sc,onSubmit:d},e[5]=n,e[6]=u,e[7]=s,e[8]=d,e[9]=f):f=e[9];const c=Gr(f);let m;e[10]!==n||e[11]!==c?(m=E=>{c.form.reset(Object.fromEntries(n.map(k=>[k.approvalId,{approved:!0,levelOverride:E}]))),c.submitOrAdvance()},e[10]=n,e[11]=c,e[12]=m):m=e[12];const V=m,x=c.currentPart;let p;e[13]!==c?(p=E=>{E.preventDefault(),c.submit()},e[13]=c,e[14]=p):p=e[14];let h;e[15]===Symbol.for("react.memo_cache_sentinel")?(h=a.jsx(mn,{size:14}),e[15]=h):h=e[15];const v=`${n.length} approvals pending`,b=x?.friendlyName??"";let y;e[16]!==V?(y=a.jsx(Jr,{onYolo:V}),e[16]=V,e[17]=y):y=e[17];let C;e[18]!==n.length||e[19]!==c.currentIndex||e[20]!==c.goNext||e[21]!==c.goPrev||e[22]!==y?(C=a.jsx(Hr,{currentIndex:c.currentIndex,total:n.length,onPrev:c.goPrev,onNext:c.goNext,extraLeft:y}),e[18]=n.length,e[19]=c.currentIndex,e[20]=c.goNext,e[21]=c.goPrev,e[22]=y,e[23]=C):C=e[23];let j;e[24]!==x||e[25]!==c.form.control||e[26]!==c.submitOrAdvance?(j=x?a.jsx(ac,{approvalId:x.approvalId,control:c.form.control,onChange:c.submitOrAdvance}):null,e[24]=x,e[25]=c.form.control,e[26]=c.submitOrAdvance,e[27]=j):j=e[27];let A;e[28]!==x?(A=x?a.jsx(Zr,{input:x.input}):null,e[28]=x,e[29]=A):A=e[29];let w;e[30]!==C||e[31]!==j||e[32]!==A||e[33]!==v||e[34]!==b?(w=a.jsx(qe,{icon:h,label:v,title:b,defaultExpanded:!0,footerLeft:C,footerRight:j,children:A}),e[30]=C,e[31]=j,e[32]=A,e[33]=v,e[34]=b,e[35]=w):w=e[35];let S;e[36]!==w||e[37]!==p?(S=a.jsx("form",{onSubmit:p,children:w}),e[36]=w,e[37]=p,e[38]=S):S=e[38];let N;return e[39]!==c.form||e[40]!==S?(N=a.jsx($n,{...c.form,children:S}),e[39]=c.form,e[40]=S,e[41]=N):N=e[41],N}function sc(t){return typeof t?.approved=="boolean"}function rc(t){return t.approvalId}function oc(t){return[t.approvalId,{approved:void 0}]}function ac(t){const e=F.c(6),{approvalId:n,control:s,onChange:r}=t,o=`${n}.approved`;let i;e[0]!==r?(i=u=>{const{field:d}=u,f=d.value===!0,c=d.value===!1;return a.jsxs(a.Fragment,{children:[a.jsx(ae,{type:"button",variant:c?"secondary":"ghost",size:"sm",className:"h-7 px-2.5 text-xs",onClick:()=>{d.onChange(!1),r()},"aria-pressed":c,children:"Deny"}),a.jsx(ae,{type:"button",variant:f?"default":"outline",size:"sm",className:"h-7 px-2.5 text-xs",onClick:()=>{d.onChange(!0),r()},"aria-pressed":f,children:"Accept"})]})},e[0]=r,e[1]=i):i=e[1];let l;return e[2]!==s||e[3]!==o||e[4]!==i?(l=a.jsx(ha,{control:s,name:o,render:i}),e[2]=s,e[3]=o,e[4]=i,e[5]=l):l=e[5],l}function ic(){const t=F.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=a.jsxs("div",{className:"flex items-center gap-2 p-4 border border-dashed rounded-lg bg-accent/50 w-[calc(100%-16px)] max-w-[640px] mx-auto mb-2",children:[a.jsx(mn,{className:"size-5 text-muted-foreground shimmer"}),a.jsx("span",{className:"text-sm text-muted-foreground shimmer",children:"Preparing approval request..."})]}),t[0]=e):e=t[0],e}function lc(t){const e=F.c(8),{approvals:n,isStreaming:s,onRespond:r}=t;if(s&&n.length===0){let i;return e[0]===Symbol.for("react.memo_cache_sentinel")?(i=a.jsx(ic,{}),e[0]=i):i=e[0],i}if(n.length===0)return null;if(n.length===1){const i=n[0];if(!i)return null;let l;return e[1]!==r||e[2]!==i?(l=a.jsx(ec,{approval:i,onRespond:r}),e[1]=r,e[2]=i,e[3]=l):l=e[3],l}let o;return e[4]!==n||e[5]!==s||e[6]!==r?(o=a.jsx(nc,{approvals:n,isStreaming:s,onRespond:r}),e[4]=n,e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function cc(t){const e=F.c(16),{plan:n,onApprove:s,onDismiss:r}=t;let o;e[0]!==s||e[1]!==n.plan?(o=()=>{s(n.plan)},e[0]=s,e[1]=n.plan,e[2]=o):o=e[2];const i=o;let l;e[3]!==r?(l=a.jsx(ae,{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:r,children:"Keep iterating"}),e[3]=r,e[4]=l):l=e[4];let u;e[5]!==i?(u=a.jsx(ae,{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:i,children:"Let's go"}),e[5]=i,e[6]=u):u=e[6];let d;e[7]!==l||e[8]!==u?(d=a.jsxs(a.Fragment,{children:[l,u]}),e[7]=l,e[8]=u,e[9]=d):d=e[9];const f=d;let c;e[10]===Symbol.for("react.memo_cache_sentinel")?(c=a.jsx(ji,{size:14}),e[10]=c):c=e[10];let m;e[11]!==n.plan?(m=a.jsx("div",{className:"px-4 max-h-64 overflow-y-auto",children:a.jsx("div",{className:"prose prose-sm max-w-none text-sm",children:a.jsx(qa,{id:"plan-preview",part:{type:"text",text:n.plan}})})}),e[11]=n.plan,e[12]=m):m=e[12];let V;return e[13]!==f||e[14]!==m?(V=a.jsx(qe,{icon:c,label:"Plan ready",title:"Implementation Plan",defaultExpanded:!0,footerRight:f,children:m}),e[13]=f,e[14]=m,e[15]=V):V=e[15],V}function uc(){const t=F.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=a.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-[640px] mx-auto mb-2",children:[a.jsx(Dt,{className:"size-5 text-purple-500 shimmer"}),a.jsx("span",{className:"text-sm text-muted-foreground shimmer",children:"Preparing plan..."})]}),t[0]=e):e=t[0],e}function dc(t){const e=F.c(7),{plans:n,isStreaming:s,onApprove:r,onDismiss:o}=t;if(s&&n.length===0){let d;return e[0]===Symbol.for("react.memo_cache_sentinel")?(d=a.jsx(uc,{}),e[0]=d):d=e[0],d}let i;e[1]!==n?(i=n.at(-1),e[1]=n,e[2]=i):i=e[2];const l=i;if(!l)return null;let u;return e[3]!==l||e[4]!==r||e[5]!==o?(u=a.jsx(cc,{plan:l,onApprove:r,onDismiss:o}),e[3]=l,e[4]=r,e[5]=o,e[6]=u):u=e[6],u}function eo(t){return t?"response"in t?t.response:t.option??t.draft:""}const Ds=Je({response:at().min(1,"Response is required")}),fc=Je({option:at().nullable(),draft:at()}).refine(t=>(t.option??t.draft).length>0,{message:"Please select or enter an option"}),Vc=Je({response:Hn(["yes","no"])});function mc(t){switch(t.type){case"text":return Ds;case"choice":return fc;case"confirm":return Vc;default:return Ds}}function pc(t){const e={};for(const n of t)e[n.toolCallId]=mc(n.input);return Je(e)}function hc(t){const e=F.c(6),{control:n,name:s,placeholder:r}=t;let o;e[0]!==r?(o=l=>{const{field:u}=l,d=u.value??"";return a.jsxs(Zn,{children:[a.jsx(es,{children:a.jsx("div",{className:"px-2",children:a.jsxs("div",{className:"flex items-center gap-3 px-2 py-3 rounded-lg bg-accent/50",children:[a.jsx("span",{className:"flex items-center justify-center size-6 rounded-md bg-muted shrink-0",children:a.jsx(Cr,{size:16,className:"text-muted-foreground"})}),a.jsx("input",{...u,value:d,type:"text",placeholder:r||"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"})]})})}),a.jsx(ts,{})]})},e[0]=r,e[1]=o):o=e[1];let i;return e[2]!==n||e[3]!==s||e[4]!==o?(i=a.jsx(Er,{control:n,name:s,render:o}),e[2]=n,e[3]=s,e[4]=o,e[5]=i):i=e[5],i}function to(t,e){const n=F.c(4);let s,r;n[0]!==t||n[1]!==e?(s=()=>{const o=i=>{const l=i.target.tagName;if(l==="INPUT"||l==="TEXTAREA"||i.metaKey||i.ctrlKey||i.altKey)return;const u=Number.parseInt(i.key,10);u>=1&&u<=t&&(i.preventDefault(),e(u-1))};return document.addEventListener("keydown",o),()=>document.removeEventListener("keydown",o)},r=[t,e],n[0]=t,n[1]=e,n[2]=s,n[3]=r):(s=n[2],r=n[3]),g.useEffect(s,r)}function gc(t){const e=F.c(40),{control:n,name:s,options:r}=t,o=`${s}.option`;let i;e[0]!==n||e[1]!==o?(i={control:n,name:o,defaultValue:null},e[0]=n,e[1]=o,e[2]=i):i=e[2];const{field:l}=xs(i),u=`${s}.draft`;let d;e[3]!==n||e[4]!==u?(d={control:n,name:u,defaultValue:""},e[3]=n,e[4]=u,e[5]=d):d=e[5];const{field:f}=xs(d),c=l.value,m=f.value??"";let V;if(e[6]!==l||e[7]!==r?(V=_=>{const D=r[_];D!=null&&l.onChange(D)},e[6]=l,e[7]=r,e[8]=V):V=e[8],to(r.length,V),r.length===0)return null;const x=c===null;let p;if(e[9]!==l||e[10]!==c||e[11]!==r){let _;e[13]!==l||e[14]!==c?(_=(D,R)=>{const P=c===D;return a.jsxs("button",{type:"button",onClick:()=>l.onChange(D),className:K("flex items-center gap-3 px-2 py-3 rounded-lg text-left transition-colors w-full",P&&"bg-accent/50",!P&&"hover:bg-accent/30"),"aria-label":`Select ${D}`,children:[a.jsx("span",{className:K("flex items-center justify-center size-6 rounded-md text-sm shrink-0",P?"bg-chart-1 text-white":"bg-muted text-foreground"),children:R+1}),a.jsx("span",{className:"text-sm text-foreground truncate",children:D})]},`${R}-${D}`)},e[13]=l,e[14]=c,e[15]=_):_=e[15],p=r.map(_),e[9]=l,e[10]=c,e[11]=r,e[12]=p}else p=e[12];const h=x&&"bg-accent/50",v=!x&&"hover:bg-accent/30";let b;e[16]!==h||e[17]!==v?(b=K("flex items-center gap-3 px-2 py-3 rounded-lg transition-colors w-full cursor-text",h,v),e[16]=h,e[17]=v,e[18]=b):b=e[18];let y;e[19]===Symbol.for("react.memo_cache_sentinel")?(y=a.jsx("span",{className:"flex items-center justify-center size-6 rounded-md bg-muted shrink-0",children:a.jsx(Cr,{size:16,className:"text-muted-foreground"})}),e[19]=y):y=e[19];const C=x?m:"";let j;e[20]!==f||e[21]!==l||e[22]!==c?(j=_=>{f.onChange(_.target.value),c!==null&&l.onChange(null)},e[20]=f,e[21]=l,e[22]=c,e[23]=j):j=e[23];let A;e[24]!==l||e[25]!==c?(A=()=>{c!==null&&l.onChange(null)},e[24]=l,e[25]=c,e[26]=A):A=e[26];let w;e[27]!==C||e[28]!==j||e[29]!==A?(w=a.jsx("input",{type:"text",value:C,onChange:j,onFocus:A,placeholder:"Something else...","aria-label":"Custom choice input",className:"flex-1 text-sm bg-transparent outline-none placeholder:text-foreground/25 text-foreground min-w-0"}),e[27]=C,e[28]=j,e[29]=A,e[30]=w):w=e[30];let S;e[31]!==w||e[32]!==b?(S=a.jsxs("label",{className:b,children:[y,w]}),e[31]=w,e[32]=b,e[33]=S):S=e[33];let N;e[34]!==S||e[35]!==p?(N=a.jsx(es,{children:a.jsxs("div",{className:"flex flex-col px-2",role:"group","aria-label":"Choice options",children:[p,S]})}),e[34]=S,e[35]=p,e[36]=N):N=e[36];let E;e[37]===Symbol.for("react.memo_cache_sentinel")?(E=a.jsx(ts,{}),e[37]=E):E=e[37];let k;return e[38]!==N?(k=a.jsxs(Zn,{children:[N,E]}),e[38]=N,e[39]=k):k=e[39],k}function xc(t){const e=F.c(6),{control:n,name:s}=t;let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=["yes","no"],e[0]=r):r=e[0];const o=r,i=g.useRef(null);let l;e[1]===Symbol.for("react.memo_cache_sentinel")?(l=f=>{i.current?.onChange(o[f]??"")},e[1]=l):l=e[1],to(o.length,l);let u;e[2]===Symbol.for("react.memo_cache_sentinel")?(u=f=>{const{field:c}=f;return i.current=c,a.jsxs(Zn,{children:[a.jsx(es,{children:a.jsx("div",{className:"flex gap-2 px-2",role:"group","aria-label":"Confirmation options",children:o.map(m=>{const V=c.value===m;return a.jsxs("button",{type:"button",onClick:()=>c.onChange(m),className:K("flex items-center gap-3 px-4 py-3 rounded-lg text-left transition-colors flex-1",V&&"bg-accent/50",!V&&"hover:bg-accent/30"),"aria-label":`Confirm ${m}`,children:[a.jsx("span",{className:K("flex items-center justify-center size-6 rounded-md text-sm shrink-0",V?"bg-chart-1 text-white":"bg-muted text-foreground"),children:m==="yes"?1:2}),a.jsx("span",{className:"text-sm text-foreground capitalize",children:m})]},m)})})}),a.jsx(ts,{})]})},e[2]=u):u=e[2];let d;return e[3]!==n||e[4]!==s?(d=a.jsx(Er,{control:n,name:s,render:u}),e[3]=n,e[4]=s,e[5]=d):d=e[5],d}function Ts(t){const e=F.c(13),{input:n,control:s,toolCallId:r}=t;switch(n.type){case"text":{const o=`${r}.response`;let i;return e[0]!==s||e[1]!==n.default||e[2]!==o?(i=a.jsx(hc,{control:s,name:o,placeholder:n.default}),e[0]=s,e[1]=n.default,e[2]=o,e[3]=i):i=e[3],i}case"choice":{let o;e[4]!==n.options?(o=n.options?.filter(Boolean)??[],e[4]=n.options,e[5]=o):o=e[5];const i=o;let l;return e[6]!==s||e[7]!==i||e[8]!==r?(l=a.jsx(gc,{control:s,name:r,options:i}),e[6]=s,e[7]=i,e[8]=r,e[9]=l):l=e[9],l}case"confirm":{const o=`${r}.response`;let i;return e[10]!==s||e[11]!==o?(i=a.jsx(xc,{control:s,name:o}),e[10]=s,e[11]=o,e[12]=i):i=e[12],i}default:return null}}function bc(t){const e=F.c(71),{parts:n,isStreaming:s,onSubmit:r}=t;let o;e[0]!==n?(o=pc(n.map(Ac)),e[0]=n,e[1]=o):o=e[1];const i=o;let l;e[2]!==n?(l=Object.fromEntries(n.map(wc)),e[2]=n,e[3]=l):l=e[3];const u=l;let d;e[4]!==r?(d=(T,M)=>{const L=eo(M);L&&r(T,L)},e[4]=r,e[5]=d):d=e[5];let f;e[6]!==u||e[7]!==s||e[8]!==n||e[9]!==i||e[10]!==d?(f={parts:n,partKey:yc,schema:i,defaultValues:u,isStreaming:s,hasAnswer:vc,onSubmit:d},e[6]=u,e[7]=s,e[8]=n,e[9]=i,e[10]=d,e[11]=f):f=e[11];const c=Gr(f),m=c.currentPart;let V;e[12]!==m||e[13]!==c?(V=()=>{const T=m;if(!T)return;const M=T.toolCallId;T.input?.type==="choice"?(c.form.setValue(`${M}.option`,null),c.form.setValue(`${M}.draft`,"user has skip this question")):c.form.setValue(`${M}.response`,"user has skip this question"),c.advanceToNextUnanswered()},e[12]=m,e[13]=c,e[14]=V):V=e[14];const x=V;let p;e[15]!==c.currentIndex||e[16]!==c.goNext||e[17]!==c.goPrev||e[18]!==n.length?(p=a.jsx(Hr,{currentIndex:c.currentIndex,total:n.length,onPrev:c.goPrev,onNext:c.goNext}),e[15]=c.currentIndex,e[16]=c.goNext,e[17]=c.goPrev,e[18]=n.length,e[19]=p):p=e[19];const h=p;let v;e[20]!==x?(v=a.jsx(ae,{type:"button",variant:"outline",size:"sm",onClick:x,className:"h-7",children:"Skip"}),e[20]=x,e[21]=v):v=e[21];let b;e[22]!==c.isAllAnswered||e[23]!==c.isCurrentAnswered||e[24]!==c.submitOrAdvance||e[25]!==s?(b=a.jsx(Gl,{isStreaming:s,isAllAnswered:c.isAllAnswered,isCurrentAnswered:c.isCurrentAnswered,onAdvanceOrSubmit:c.submitOrAdvance}),e[22]=c.isAllAnswered,e[23]=c.isCurrentAnswered,e[24]=c.submitOrAdvance,e[25]=s,e[26]=b):b=e[26];let y;e[27]!==v||e[28]!==b?(y=a.jsxs(a.Fragment,{children:[v,b]}),e[27]=v,e[28]=b,e[29]=y):y=e[29];const C=y;if(n.length===1){const T=n[0];if(!T?.input)return null;let M;e[30]!==c?(M=z=>{z.preventDefault(),c.submit()},e[30]=c,e[31]=M):M=e[31];let L;e[32]===Symbol.for("react.memo_cache_sentinel")?(L=a.jsx(zn,{size:14}),e[32]=L):L=e[32];const U=T.input?.prompt??"Question",$=T.input;let B;e[33]!==c.form.control||e[34]!==T.toolCallId||e[35]!==$?(B=a.jsx(Ts,{input:$,control:c.form.control,toolCallId:T.toolCallId}),e[33]=c.form.control,e[34]=T.toolCallId,e[35]=$,e[36]=B):B=e[36];let q;e[37]!==C||e[38]!==U||e[39]!==B?(q=a.jsx(qe,{icon:L,label:"Question pending",title:U,defaultExpanded:!0,footerRight:C,children:B}),e[37]=C,e[38]=U,e[39]=B,e[40]=q):q=e[40];let Q;e[41]!==M||e[42]!==q?(Q=a.jsx("form",{onSubmit:M,autoComplete:"off",children:q}),e[41]=M,e[42]=q,e[43]=Q):Q=e[43];let O;return e[44]!==c.form||e[45]!==Q?(O=a.jsx($n,{...c.form,children:Q}),e[44]=c.form,e[45]=Q,e[46]=O):O=e[46],O}const j=c.form;let A;e[47]!==c?(A=T=>{T.preventDefault(),c.submit()},e[47]=c,e[48]=A):A=e[48];let w;e[49]===Symbol.for("react.memo_cache_sentinel")?(w=a.jsx(zn,{size:14}),e[49]=w):w=e[49];const S=`${c.currentIndex+1} of ${n.length}`,N=m?.input?.prompt??"Question",E=c.activeKey,k=c.setActiveKey;let _;if(e[50]!==c.form||e[51]!==n){let T;e[53]!==c.form?(T=M=>a.jsx(Ui,{value:M.toolCallId,className:"mt-0",children:a.jsx(Ts,{input:M.input,control:c.form.control,toolCallId:M.toolCallId})},M.toolCallId),e[53]=c.form,e[54]=T):T=e[54],_=n.map(T),e[50]=c.form,e[51]=n,e[52]=_}else _=e[52];let D;e[55]!==c.activeKey||e[56]!==c.setActiveKey||e[57]!==_?(D=a.jsx(Ki,{value:E,onValueChange:k,children:_}),e[55]=c.activeKey,e[56]=c.setActiveKey,e[57]=_,e[58]=D):D=e[58];let R;e[59]!==h||e[60]!==C||e[61]!==S||e[62]!==N||e[63]!==D?(R=a.jsx(qe,{icon:w,label:"Question pending",count:S,title:N,defaultExpanded:!0,footerLeft:h,footerRight:C,children:D}),e[59]=h,e[60]=C,e[61]=S,e[62]=N,e[63]=D,e[64]=R):R=e[64];let P;e[65]!==A||e[66]!==R?(P=a.jsx("form",{onSubmit:A,autoComplete:"off",children:R}),e[65]=A,e[66]=R,e[67]=P):P=e[67];let I;return e[68]!==c.form||e[69]!==P?(I=a.jsx($n,{...j,children:P}),e[68]=c.form,e[69]=P,e[70]=I):I=e[70],I}function vc(t){return!!eo(t)}function yc(t){return t.toolCallId}function wc(t){return t.input?.type==="choice"?[t.toolCallId,{option:null,draft:""}]:[t.toolCallId,{response:""}]}function Ac(t){return{toolCallId:t.toolCallId,input:t.input}}function Sc(){const t=F.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=a.jsxs("div",{className:"flex items-center gap-2 p-4 border border-dashed rounded-lg bg-accent/50 w-[calc(100%-16px)] max-w-[640px] mx-auto mb-2",children:[a.jsx(zn,{className:"size-5 text-muted-foreground shimmer"}),a.jsx("span",{className:"text-sm text-muted-foreground shimmer",children:"Preparing question..."})]}),t[0]=e):e=t[0],e}function no(t){const e=F.c(7),{userAskParts:n,isStreaming:s,onSubmit:r}=t;let o;e[0]!==n?(o=n.filter(Cc),e[0]=n,e[1]=o):o=e[1];const i=o;if(i.length===0){if(s){let u;return e[2]===Symbol.for("react.memo_cache_sentinel")?(u=a.jsx(Sc,{}),e[2]=u):u=e[2],u}return null}let l;return e[3]!==s||e[4]!==r||e[5]!==i?(l=a.jsx(bc,{parts:i,isStreaming:s,onSubmit:r}),e[3]=s,e[4]=r,e[5]=i,e[6]=l):l=e[6],l}function Cc(t){return t.state==="input-available"}function jc(t){const e=t.filter(o=>o.status==="in_progress"),n=t.filter(o=>o.status==="completed").length,s=t.length;if(s>0&&n===s)return{icon:"completed",activity:"All done",progress:`${s}/${s}`};const[r]=e;return r&&e.length===1?{icon:"in_progress",activity:r.activeForm,progress:`${n}/${s} done`}:e.length>1?{icon:"in_progress",activity:`${e.length} in progress`,progress:`${n}/${s} done`}:n>0?{icon:"pending",activity:`${s-n} pending`,progress:`${n}/${s} done`}:{icon:"pending",activity:`${s} todos`,progress:"not started"}}function Nc(){const t=F.c(21),{messages:e}=ut();let n,s,r,o,i,l,u,d,f;if(t[0]!==e){f=Symbol.for("react.early_return_sentinel");e:{const V=Ur(e);if(V.length===0){f=null;break e}const x=jc(V);n=qe,i=a.jsx(Ic,{status:x.icon}),l=x.activity,u=x.progress,d=!1,s="todos-list",r="flex flex-col px-2 max-h-[40vh] overflow-y-auto",o=V.map(Rc)}t[0]=e,t[1]=n,t[2]=s,t[3]=r,t[4]=o,t[5]=i,t[6]=l,t[7]=u,t[8]=d,t[9]=f}else n=t[1],s=t[2],r=t[3],o=t[4],i=t[5],l=t[6],u=t[7],d=t[8],f=t[9];if(f!==Symbol.for("react.early_return_sentinel"))return f;let c;t[10]!==s||t[11]!==r||t[12]!==o?(c=a.jsx("ul",{"data-testid":s,className:r,children:o}),t[10]=s,t[11]=r,t[12]=o,t[13]=c):c=t[13];let m;return t[14]!==n||t[15]!==i||t[16]!==l||t[17]!==u||t[18]!==d||t[19]!==c?(m=a.jsx(n,{icon:i,label:l,count:u,defaultExpanded:d,children:c}),t[14]=n,t[15]=i,t[16]=l,t[17]=u,t[18]=d,t[19]=c,t[20]=m):m=t[20],m}function Rc(t,e){return a.jsx(kc,{todo:t},e)}function kc(t){const e=F.c(14),{todo:n}=t,s=n.status==="completed",o=n.status==="in_progress"?n.activeForm:n.content;let i;e[0]!==n.status?(i=a.jsx(Ec,{status:n.status}),e[0]=n.status,e[1]=i):i=e[1];const l=s&&"text-muted-foreground";let u;e[2]!==l?(u=K("relative text-sm leading-snug pt-px select-none",l),e[2]=l,e[3]=u):u=e[3];const d=s?"100%":"0%",f=s?"width 300ms ease 200ms":"width 150ms ease";let c;e[4]!==d||e[5]!==f?(c=a.jsx("span",{"aria-hidden":"true",style:{position:"absolute",left:0,top:"50%",height:"1px",background:"currentColor",width:d,transition:f}}),e[4]=d,e[5]=f,e[6]=c):c=e[6];let m;e[7]!==o||e[8]!==u||e[9]!==c?(m=a.jsxs("span",{className:u,children:[o,c]}),e[7]=o,e[8]=u,e[9]=c,e[10]=m):m=e[10];let V;return e[11]!==i||e[12]!==m?(V=a.jsxs("li",{className:"flex items-start gap-2.5 px-2 py-1.5 rounded-lg hover:bg-accent/50 transition-colors",children:[i,m]}),e[11]=i,e[12]=m,e[13]=V):V=e[13],V}function Ec(t){const e=F.c(4),{status:n}=t,s=n==="completed"?"true":void 0,r=n==="in_progress"?"true":void 0;let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=a.jsx("svg",{viewBox:"0 0 21 21",children:a.jsx("path",{d:"M5,10.75 L8.5,14.25 L19.4,2.3 C18.8333333,1.43333333 18.0333333,1 17,1 L4,1 C2.35,1 1,2.35 1,4 L1,17 C1,18.65 2.35,20 4,20 L17,20 C18.65,20 20,18.65 20,17 L20,7.99769186"})}),e[0]=o):o=e[0];let i;return e[1]!==s||e[2]!==r?(i=a.jsx("div",{className:"todo-cb mt-0.5","data-checked":s,"data-progress":r,"aria-hidden":"true",children:o}),e[1]=s,e[2]=r,e[3]=i):i=e[3],i}function Ic(t){const e=F.c(3),{status:n}=t;if(n==="completed"){let r;return e[0]===Symbol.for("react.memo_cache_sentinel")?(r=a.jsx("span",{"aria-label":"completed",className:"inline-flex items-center justify-center w-3.5 h-3.5 rounded-sm bg-primary",children:a.jsx("svg",{viewBox:"0 0 10 8",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",className:"w-2 h-2 text-primary-foreground",style:{strokeWidth:2},children:a.jsx("path",{d:"M1 4l2.5 2.5L9 1"})})}),e[0]=r):r=e[0],r}if(n==="in_progress"){let r;return e[1]===Symbol.for("react.memo_cache_sentinel")?(r=a.jsx("span",{"aria-label":"in progress",className:"inline-block w-2 h-2 rounded-full bg-primary animate-pulse shrink-0"}),e[1]=r):r=e[1],r}let s;return e[2]===Symbol.for("react.memo_cache_sentinel")?(s=a.jsx("span",{"aria-label":"pending",className:"inline-block w-3.5 h-3.5 rounded-sm border-[1.5px] border-muted-foreground/50 shrink-0"}),e[2]=s):s=e[2],s}const Dc={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"}]},Tc=["Access to 100+ AI models","Unified API, no separate keys needed","Pay only for what you use"];function so(t){const e=F.c(41),{onDismiss:n}=t,{org:s}=Se(),r=ct(),{decoKeyId:o}=_r(),i=Mr(),[l,u]=g.useState(""),[d,f]=g.useState(!1),[c,m]=g.useState("usd"),V=c==="brl"?"R$":"$";let x,p;e[0]!==s.id?(x=()=>{re("credits_exhausted_shown",{organization_id:s.id})},p=[s.id],e[0]=s.id,e[1]=x,e[2]=p):(x=e[1],p=e[2]),g.useEffect(x,p);let h;e[3]!==c||e[4]!==i?(h=async T=>{const{url:M}=await i.call("AI_PROVIDER_TOPUP_URL",{providerId:"deco",amountCents:T,currency:c});return M},e[3]=c,e[4]=i,e[5]=h):h=e[5];let v;e[6]!==n?(v=T=>{T&&window.open(T,"_blank","noopener,noreferrer"),n?.()},e[6]=n,e[7]=v):v=e[7];let b;e[8]!==h||e[9]!==v?(b={mutationFn:h,onSuccess:v,onError:Pc},e[8]=h,e[9]=v,e[10]=b):b=e[10];const{mutate:y,isPending:C}=Wn(b),j=parseFloat(l),A=!isNaN(j)&&j>=1;let w;e[11]!==n?(w=T=>!T&&n?.(),e[11]=n,e[12]=w):w=e[12];let S;e[13]===Symbol.for("react.memo_cache_sentinel")?(S=["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[13]=S):S=e[13];let N;e[14]===Symbol.for("react.memo_cache_sentinel")?(N=a.jsx("div",{className:"absolute inset-x-0 top-0 h-36 pointer-events-none",style:{backgroundImage:S.join(", "),maskImage:"linear-gradient(to bottom, black 0%, transparent 100%)",WebkitMaskImage:"linear-gradient(to bottom, black 0%, transparent 100%)"}}),e[14]=N):N=e[14];let E;e[15]===Symbol.for("react.memo_cache_sentinel")?(E=a.jsxs("div",{className:"relative px-8 pt-8 pb-2 overflow-hidden",children:[N,a.jsxs(an,{className:"relative gap-4",children:[a.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"}),a.jsxs("div",{children:[a.jsx(ln,{className:"text-xl font-semibold tracking-tight",children:"Top up to keep building"}),a.jsx(Jn,{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[15]=E):E=e[15];let k;e[16]!==c||e[17]!==V||e[18]!==l||e[19]!==j||e[20]!==o||e[21]!==A||e[22]!==C||e[23]!==d||e[24]!==y?(k=o&&a.jsxs("div",{className:"px-8 pt-5 pb-6",children:[a.jsx("div",{className:"mb-4",children:a.jsxs(Dr,{type:"single",variant:"outline",size:"sm",value:c,onValueChange:T=>{T&&m(T)},children:[a.jsx(Qt,{value:"usd",className:"h-8 px-3 text-xs",children:"USD"}),a.jsx(Qt,{value:"brl",className:"h-8 px-3 text-xs",children:"BRL"})]})}),a.jsxs("div",{className:"rounded-xl border border-border p-5",children:[a.jsx("div",{className:"grid grid-cols-3 gap-2.5",children:Dc[c].map(T=>{const{dollars:M,label:L}=T;return a.jsxs("button",{type:"button",disabled:C,onClick:()=>{re("credits_topup_clicked",{amount_cents:M*100,currency:c,tier_label:L,source:"exhausted_banner"}),y(M*100)},className:K("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:[a.jsxs("span",{className:"text-2xl font-semibold tabular-nums text-foreground",children:[V,M]}),a.jsx("span",{className:"text-xs text-muted-foreground",children:L})]},M)})}),d?a.jsxs("div",{className:"flex gap-2 mt-3",children:[a.jsxs("div",{className:"relative flex-1",children:[a.jsx("span",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-sm text-muted-foreground select-none",children:V}),a.jsx(Tr,{type:"number",min:"1",step:"1",placeholder:"50",value:l,onChange:T=>u(T.target.value),className:"h-10 text-sm pl-7",autoFocus:!0})]}),a.jsx(ae,{className:"h-10",disabled:!A||C,onClick:()=>{re("credits_topup_clicked",{amount_cents:Math.round(j*100),currency:c,tier_label:"custom",source:"exhausted_banner"}),y(Math.round(j*100))},children:C?"Opening...":"Add"})]}):a.jsx("button",{type:"button",className:"w-full mt-3 text-xs text-muted-foreground hover:text-foreground transition-colors py-1",onClick:()=>f(!0),children:"Enter custom amount"})]}),a.jsx("div",{className:"mt-5 rounded-xl bg-muted/25 border border-border/50 p-4 space-y-3",children:Tc.map(_c)})]}),e[16]=c,e[17]=V,e[18]=l,e[19]=j,e[20]=o,e[21]=A,e[22]=C,e[23]=d,e[24]=y,e[25]=k):k=e[25];let _;e[26]!==n?(_=a.jsx(ae,{variant:"ghost",size:"sm",onClick:n,children:"Dismiss"}),e[26]=n,e[27]=_):_=e[27];let D;e[28]!==r||e[29]!==n||e[30]!==s.slug?(D=a.jsx("button",{type:"button",className:"text-xs text-muted-foreground hover:text-foreground transition-colors",onClick:()=>{r({to:"/$org/settings/ai-providers",params:{org:s.slug}}),n?.()},children:"Manage providers"}),e[28]=r,e[29]=n,e[30]=s.slug,e[31]=D):D=e[31];let R;e[32]!==_||e[33]!==D?(R=a.jsxs("div",{className:"px-8 py-4 border-t border-border bg-muted/30 flex items-center justify-between",children:[_,D]}),e[32]=_,e[33]=D,e[34]=R):R=e[34];let P;e[35]!==k||e[36]!==R?(P=a.jsxs(cn,{className:"sm:max-w-[520px] gap-0 p-0 overflow-hidden",onOpenAutoFocus:Mc,children:[E,k,R]}),e[35]=k,e[36]=R,e[37]=P):P=e[37];let I;return e[38]!==P||e[39]!==w?(I=a.jsx(un,{open:!0,onOpenChange:w,children:P}),e[38]=P,e[39]=w,e[40]=I):I=e[40],I}function _c(t){return a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"flex items-center justify-center size-5 rounded-full bg-[hsl(var(--chart-1))]/15 shrink-0",children:a.jsx(Dt,{size:12,className:"text-[hsl(var(--chart-1))]"})}),a.jsx("span",{className:"text-sm text-foreground/80",children:t})]},t)}function Mc(t){return t.preventDefault()}function Pc(t){fe.error(`Top-up failed: ${t.message}`)}function Oc(){const t=F.c(5),e=rn(),n=Pr(),[s,r]=g.useState(!1);if(!(e?.lockedSandbox==="user-desktop")||!n.ready||n.online)return null;let i;t[0]===Symbol.for("react.memo_cache_sentinel")?(i=a.jsx(ns,{size:14}),t[0]=i):i=t[0];let l;t[1]===Symbol.for("react.memo_cache_sentinel")?(l=a.jsx(ae,{size:"sm",variant:"outline",className:"h-7 text-xs",onClick:()=>r(!0),children:"Reconnect desktop"}),t[1]=l):l=t[1];let u;t[2]===Symbol.for("react.memo_cache_sentinel")?(u=a.jsx(qe,{icon:i,label:"Your desktop is offline",title:"This chat runs on your desktop, which isn't connected right now.",defaultExpanded:!0,variant:"warning",footerRight:l,children:a.jsxs("p",{className:"mx-4 text-xs text-muted-foreground",children:["Run ",a.jsx("code",{className:"font-mono",children:"bunx decocms@latest link"})," in a terminal on that machine to bring it back. Messages you send while it's offline will fail."]})}),t[2]=u):u=t[2];let d;return t[3]!==s?(d=a.jsxs(a.Fragment,{children:[u,a.jsx(Hi,{open:s,onOpenChange:r})]}),t[3]=s,t[4]=d):d=t[4],d}function Lc(t){const e=t.trim(),n=e.startsWith("<")&&/<[a-z][\s\S]*>/i.test(e),s=/cloudflare|cf-[a-z-]+|error[\s_-]?code[\s_-]?5\d\d/i.test(e),r=/failed to fetch|networkerror|load failed|offline/i.test(e),o=/timeout|timed out|aborted|deadline/i.test(e),i=e.length>240,l=/sandbox failed to start(?::\s*(.+))?/is.exec(e);if(l){const u=l[1]?.trim().replace(/\.$/,"");return{summary:u?`Your sandbox didn't finish starting up (${u}). Try again.`:"Your sandbox didn't finish starting up. Try again.",rawDetails:t}}return/link_unavailable|user_desktop_link_/i.test(e)?/user_desktop_link_capability_missing/i.test(e)?{summary:"Your desktop is connected, but the CLI this chat uses wasn't detected there. Install it and sign in on your desktop, then try again.",rawDetails:t}:{summary:"Your desktop is offline. Run `bunx decocms@latest link` in a terminal on it, then try again.",rawDetails:t}:s||n&&i?{summary:"Our servers are having a moment. Try sending again in a few seconds.",rawDetails:t}:r?{summary:"Lost connection. Check your network and try again.",rawDetails:t}:o?{summary:"That took longer than expected. Try again.",rawDetails:t}:n||i?{summary:"Something unexpected came back from the server. Try again.",rawDetails:t}:{summary:t,rawDetails:null}}const Fc={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 Ht(t){const e=F.c(19),{variant:n,onDismiss:s}=t,r=n==="error",o=r?"Error occurred":"Response incomplete",i=r?kr:dr,l=r?t.error.message:Fc[t.finishReason]??`Response stopped unexpectedly: ${t.finishReason}`;let u;e[0]!==r||e[1]!==l?(u=r?Lc(l):{summary:l,rawDetails:null},e[0]=r,e[1]=l,e[2]=u):u=e[2];const{summary:d,rawDetails:f}=u;let c;e[3]!==i?(c=a.jsx(i,{size:14}),e[3]=i,e[4]=c):c=e[4];let m;e[5]!==r||e[6]!==t.onContinue||e[7]!==t.onFixInChat?(m=r?a.jsx(ae,{size:"sm",variant:"outline",onClick:t.onFixInChat,className:"h-7 text-xs",children:"Fix in chat"}):a.jsx(ae,{size:"sm",variant:"outline",onClick:t.onContinue,className:"h-7 text-xs",children:"Continue"}),e[5]=r,e[6]=t.onContinue,e[7]=t.onFixInChat,e[8]=m):m=e[8];let V;e[9]!==f?(V=f?a.jsxs("details",{className:"group mx-4",children:[a.jsxs("summary",{className:"flex cursor-pointer list-none items-center gap-1.5 text-xs text-muted-foreground transition-colors hover:text-foreground [&::-webkit-details-marker]:hidden",children:[a.jsx("svg",{"aria-hidden":"true",className:"size-3 transition-transform group-open:rotate-90",viewBox:"0 0 12 12",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:a.jsx("path",{d:"m4.5 3 3 3-3 3"})}),a.jsx("span",{className:"group-open:hidden",children:"Show technical details"}),a.jsx("span",{className:"hidden group-open:inline",children:"Hide technical details"})]}),a.jsxs("div",{className:"relative mt-2",children:[a.jsx("button",{type:"button",onClick:()=>{navigator.clipboard.writeText(f).then(zc).catch($c)},"aria-label":"Copy error details",title:"Copy",className:"absolute right-1.5 top-1.5 z-10 flex h-6 w-6 items-center justify-center rounded-md bg-background/80 text-muted-foreground backdrop-blur-sm transition-colors hover:bg-background hover:text-foreground",children:a.jsx(Mi,{className:"size-3.5"})}),a.jsx("pre",{className:"max-h-40 overflow-auto rounded-md border border-border/60 bg-background px-3 py-2 pr-8 font-mono text-xs text-foreground/80 whitespace-pre-wrap break-all",children:f})]})]}):null,e[9]=f,e[10]=V):V=e[10];let x;return e[11]!==o||e[12]!==s||e[13]!==d||e[14]!==c||e[15]!==m||e[16]!==V||e[17]!==n?(x=a.jsx(qe,{icon:c,label:o,title:d,defaultExpanded:!0,variant:n,onClose:s,footerRight:m,children:V}),e[11]=o,e[12]=s,e[13]=d,e[14]=c,e[15]=m,e[16]=V,e[17]=n,e[18]=x):x=e[18],x}function $c(){return fe.error("Could not copy")}function zc(){return fe.success("Copied to clipboard")}function hn(){const t=F.c(62),{error:e,clearError:n,finishReason:s,clearFinishReason:r,messages:o,isStreaming:i,submit:l,sendMessage:u}=ut(),[d,f]=lt(),{virtualMcpId:c,createTaskWithMessage:m}=gr(),{chatMode:V,simpleModeTier:x}=Ye();let p;t[0]!==V||t[1]!==x||t[2]!==c?(p=G=>({tier:x,mode:V,toolApprovalLevel:G,agent:c?{id:c}:void 0}),t[0]=V,t[1]=x,t[2]=c,t[3]=p):p=t[3];const h=p;let v;t[4]!==d.toolApprovalLevel?(v=d.toolApprovalLevel??ga(),t[4]=d.toolApprovalLevel,t[5]=v):v=t[5];const b=v,y=o.at(-1),C=y?.role==="assistant"?y.parts:[],j=C.filter(qc),A=qr(C),w=Kr(C);let S;t[6]!==e||t[7]!==u?(S=()=>{if(e){const oe={type:"doc",content:[{type:"paragraph",content:[{type:"text",text:`I encountered this error: ${e.message}. Can you help me fix it?`}]}]};u(oe)}},t[6]=e,t[7]=u,t[8]=S):S=t[8];const N=S;let E;t[9]!==u?(E=()=>{u({type:"doc",content:[{type:"paragraph",content:[{type:"text",text:"Please continue."}]}]})},t[9]=u,t[10]=E):E=t[10];const k=E;let _;t[11]!==h||t[12]!==b||t[13]!==l?(_=(G,oe)=>{l({kind:"toolOutput",toolCallId:G.toolCallId,output:{response:oe}},h(b))},t[11]=h,t[12]=b,t[13]=l,t[14]=_):_=t[14];const D=_;let R;t[15]!==m||t[16]!==d||t[17]!==f||t[18]!==c?(R=G=>{f({...d,toolApprovalLevel:"auto"}),m({virtualMcpId:c,message:{parts:[{type:"text",text:`Implement this plan:
1
+ import{m as It,r as g,ak as ia,ai as la,c as F,D as Se,l as K,j as a,E as ca,t as fe,o as Je,aw as ua,s as at,ax as Hn,L as da,B as ae,p as fa,n as Va,ay as ma,az as pa,I as lt,a1 as ha,aA as vt,aB as xs,b as ct,d as Wn,v as re,aC as ga,W as dr,P as xa,F as ba,aD as va,a as fr,aE as ya,aF as Vr,aG as wa,aH as De,aI as Cn,ae as st,aJ as Aa,aK as jn,aL as Sa,aM as Ca,aN as ja,aO as Na,q as Ra,K as rt,aP as ka,aQ as Ea,aR as Ia,aS as Da,aT as mr,aU as wt,k as Ta,i as _a,a2 as pr,a3 as le}from"./index-wvMNjAV0.js";import{i as hr,n as Ma}from"./SwitchHorizontal01-BmduH4aR.js";import{b as Ye,u as ut,S as On,c as rn,a as gr,f as xr,s as Pa,g as Oa,h as La,i as Fa,j as br,A as $a,k as za,l as Ba}from"./chat-context-Cemyx-UZ.js";import{j as vr,s as on,g as Ke,P as qt,k as Gn,t as Ua,l as Ka,M as qa,m as Ya,n as Yt,o as yr,p as Qa,D as Ha,q as Wa,r as Ga,v as it,w as Xa,d as Ja,x as Za,y as Xn,z as ei,F as ti,i as ni,E as si,c as ri,A as oi,B as ai,H as ii,I as li,J as bs}from"./scroll-area-CbuKwozG.js";import{c as Ln,a as Qe,b as He,T as We}from"./tooltip-DlUY886I.js";import{c as an,a as ln,d as cn,e as un,b as Jn}from"./dialog-CEOLT1ZZ.js";import{c as ci,b as ui,a as di,D as fi}from"./drawer-B-rufaJn.js";import{C as Vi}from"./collection-search-DfgQYgyj.js";import{u as mi}from"./use-mobile-7niVKoti.js";import{u as dt}from"./use-mcp-client-dBNHEL6c.js";import{a as dn,S as pi,i as vs}from"./constants-C8_Swa4x.js";import{u as hi,g as fn,l as Fn}from"./use-mcp-prompts-D2VFS_7Z.js";import{t as Vn}from"./ChevronDown-SbVNxwJa.js";import{i as tt}from"./X-qcmmBu7s.js";import{t as gi,z as xi,b as bi,w as vi,A as yi}from"./hooks-DLOVOtDp.js";import{K as wi,i as Ai}from"./shell-layout-CoG2R-A7.js";import{u as Si,a as Ci}from"./use-virtual-mcp-Cy-jA6Qm.js";import{n as wr}from"./ZapSquare-BWJNUjCu.js";import{i as Dt}from"./Check-CUUu6fuS.js";import{s as Ar}from"./Star01-BMo746nc.js";import{a as Sr}from"./Tool01-TTGB3OaR.js";import{af as mn,B as ji,a7 as Cr,ag as Ni,A as jr,g as zt,k as Ri,a9 as ki,ah as Ei,F as Ii,ai as Nr,aj as Di,ak as Ti,c as Rr}from"./agent-icon-CPQk4YwJ.js";import{i as _i}from"./Upload01-DK0nNkQH.js";import{i as kr}from"./AlertCircle-CS_9RDbg.js";import{a as Mi}from"./Copy01-DvnmgpBw.js";import{a as $n,b as Zn,d as es,e as ts,F as Er}from"./form-DtFQ7vfL.js";import{b as Pi,d as Oi,c as Li,S as Fi,a as $i}from"./select-DF6YoK_r.js";import{b as zi}from"./Settings02-C4te5XIh.js";import{i as Ir,t as zn,b as Bi}from"./XCircle-Bn7fkWKh.js";import{b as Ui,c as Ki}from"./tabs-Cf3RVJ3Q.js";import{a as Dr,T as Qt}from"./toggle-group-Dtf2CWD1.js";import{I as Tr}from"./input-CtNQHwPy.js";import{u as _r,a as qi,g as Yi,A as Qi}from"./agent-capabilities-B_99zpHP.js";import{u as Mr}from"./studio-tools-CEhEjTYq.js";import{i as ns}from"./Monitor01-BJSW7YEH.js";import{u as Pr,C as Hi,a as Or,b as Lr}from"./connect-desktop-dialog-DnC2R2Wo.js";import{s as Wi}from"./XClose-aB151tNh.js";import{m as pn,i as Gi,g as Fr,a as Xi,N as Ji}from"./decopilot-CETHa21a.js";import{P as ss,a as rs,b as os}from"./popover-Cvv98a2C.js";import{e as ys,a as ws,g as Zi,b as el,C as tl,c as nl,d as sl}from"./command-DN00KTSb.js";import{u as rl}from"./useInfiniteQuery-CcA0p7if.js";import{t as ol}from"./Stars01-CeLaUJek.js";import{q as al,r as il,s as ll,t as cl,S as ul,B as dl}from"./index-BNz3lima.js";import{a as fl,b as Vl,D as ml,c as Be,e as As,f as Ss,g as Cs,j as pl,i as hl}from"./dropdown-menu-CeNfEKAu.js";import{s as js}from"./Plus-6nUvzb_a.js";import{p as gl,q as xl}from"./question-004-sINsf4GQ.js";import{i as bl}from"./ChevronRight-CcT_Yai8.js";import{m as vl}from"./tab-id-CLpu897Q.js";function yl(t,e){const n=It(e);return wl({filters:{...t,status:"pending"}},n).length}function Ns(t,e){return t.findAll(e.filters).map(n=>e.select?e.select(n):n.state)}function wl(t={},e){const n=It(e).getMutationCache(),s=g.useRef(t),r=g.useRef(null);return r.current===null&&(r.current=Ns(n,t)),g.useEffect(()=>{s.current=t}),g.useSyncExternalStore(g.useCallback(o=>n.subscribe(()=>{const i=ia(r.current,Ns(n,s.current));r.current!==i&&(r.current=i,la.schedule(o))}),[n]),()=>r.current,()=>r.current)}const Rs=3,$r="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",Al="flex flex-col gap-1.5 p-4 rounded-xl bg-accent/40 text-sm leading-snug transition-colors cursor-pointer text-left";function zr(t){const e=F.c(46),{item:n,onSelect:s,isLoading:r,isDisabled:o,variant:i}=t,l=i===void 0?"pill":i,{prompt:u}=n;let d;if(e[0]!==u._meta||e[1]!==u.name||e[2]!==u.title){const w=Ke(u._meta);d=u.title??Gn(u.name,w),e[0]=u._meta,e[1]=u.name,e[2]=u.title,e[3]=d}else d=e[3];const f=d,c=u.description||null;if(l==="card"){let w;e[4]!==s||e[5]!==u?(w=()=>s(u),e[4]=s,e[5]=u,e[6]=w):w=e[6];const S=o||r,N=r&&"bg-accent/40",E=(o||r)&&"cursor-not-allowed opacity-50";let k;e[7]!==N||e[8]!==E?(k=K(Al,"hover:bg-accent/60 text-foreground",N,E),e[7]=N,e[8]=E,e[9]=k):k=e[9];let _;e[10]!==f?(_=a.jsx("span",{className:"font-medium truncate capitalize",children:f}),e[10]=f,e[11]=_):_=e[11];let D;e[12]!==r?(D=r&&a.jsx(On,{size:"xs"}),e[12]=r,e[13]=D):D=e[13];let R;e[14]!==_||e[15]!==D?(R=a.jsxs("div",{className:"flex items-center justify-between gap-2",children:[_,D]}),e[14]=_,e[15]=D,e[16]=R):R=e[16];let P;e[17]!==c?(P=c&&a.jsx("span",{className:"text-xs text-muted-foreground line-clamp-2",children:c}),e[17]=c,e[18]=P):P=e[18];let I;return e[19]!==R||e[20]!==P||e[21]!==w||e[22]!==S||e[23]!==k?(I=a.jsxs("button",{type:"button",onClick:w,disabled:S,className:k,children:[R,P]}),e[19]=R,e[20]=P,e[21]=w,e[22]=S,e[23]=k,e[24]=I):I=e[24],I}let m;e[25]!==s||e[26]!==u?(m=()=>s(u),e[25]=s,e[26]=u,e[27]=m):m=e[27];const V=o||r,x=r&&"bg-muted/50",p=(o||r)&&"cursor-not-allowed opacity-50";let h;e[28]!==x||e[29]!==p?(h=K($r,"hover:bg-muted/70 hover:text-foreground",x,p),e[28]=x,e[29]=p,e[30]=h):h=e[30];let v;e[31]!==f?(v=a.jsx("span",{className:"capitalize",children:f}),e[31]=f,e[32]=v):v=e[32];let b;e[33]!==r?(b=r&&a.jsx(On,{size:"xs"}),e[33]=r,e[34]=b):b=e[34];let y;e[35]!==m||e[36]!==V||e[37]!==h||e[38]!==v||e[39]!==b?(y=a.jsx(Qe,{asChild:!0,children:a.jsxs("button",{type:"button",onClick:m,disabled:V,className:h,children:[v,b]})}),e[35]=m,e[36]=V,e[37]=h,e[38]=v,e[39]=b,e[40]=y):y=e[40];const C=c??f;let j;e[41]!==C?(j=a.jsx(He,{side:"top",className:"max-w-xs",children:a.jsx("p",{className:"text-xs",children:C})}),e[41]=C,e[42]=j):j=e[42];let A;return e[43]!==y||e[44]!==j?(A=a.jsxs(We,{delayDuration:400,children:[y,j]}),e[43]=y,e[44]=j,e[45]=A):A=e[45],A}function Sl(t){const e=F.c(41),{items:n,open:s,onOpenChange:r,onSelect:o,loadingPrompt:i}=t,[l,u]=g.useState(""),d=!!i;let f;e[0]!==n||e[1]!==l?(f=l.trim()?n.filter(S=>{const N=l.toLowerCase();return S.prompt.name.toLowerCase().includes(N)||(S.prompt.title??"").toLowerCase().includes(N)||(S.prompt.description??"").toLowerCase().includes(N)}):n,e[0]=n,e[1]=l,e[2]=f):f=e[2];const c=f,m=mi();let V;e[3]!==c.length||e[4]!==l?(V=c.length===0&&a.jsxs("p",{className:"col-span-4 text-sm text-muted-foreground text-center py-8",children:["No prompts match “",l,"”"]}),e[3]=c.length,e[4]=l,e[5]=V):V=e[5];let x;if(e[6]!==c||e[7]!==d||e[8]!==i?.name||e[9]!==r||e[10]!==o){let S;e[12]!==d||e[13]!==i?.name||e[14]!==r||e[15]!==o?(S=N=>a.jsx(zr,{item:N,variant:"card",onSelect:E=>{r(!1),o(E)},isLoading:i?.name===N.prompt.name,isDisabled:d&&i?.name!==N.prompt.name},N.prompt.name),e[12]=d,e[13]=i?.name,e[14]=r,e[15]=o,e[16]=S):S=e[16],x=c.map(S),e[6]=c,e[7]=d,e[8]=i?.name,e[9]=r,e[10]=o,e[11]=x}else x=e[11];let p;e[17]!==V||e[18]!==x?(p=a.jsx("div",{className:"flex-1 overflow-y-auto [scrollbar-gutter:stable]",children:a.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-4 gap-3 p-5",children:[V,x]})}),e[17]=V,e[18]=x,e[19]=p):p=e[19];const h=p;let v;e[20]===Symbol.for("react.memo_cache_sentinel")?(v=S=>{S.key==="Escape"&&u("")},e[20]=v):v=e[20];let b;e[21]!==l?(b=a.jsx(Vi,{value:l,onChange:u,placeholder:"Search prompts...",onKeyDown:v}),e[21]=l,e[22]=b):b=e[22];const y=b;if(m){let S;e[23]===Symbol.for("react.memo_cache_sentinel")?(S=a.jsx(ci,{className:"sr-only",children:a.jsx(ui,{children:"All prompts"})}),e[23]=S):S=e[23];let N;e[24]===Symbol.for("react.memo_cache_sentinel")?(N=a.jsx("div",{className:"flex items-center h-12 border-b border-border px-4 shrink-0",children:a.jsx("span",{className:"text-sm font-medium text-foreground",children:"Prompts"})}),e[24]=N):N=e[24];let E;e[25]!==h||e[26]!==y?(E=a.jsxs(di,{className:"h-[85vh] flex flex-col p-0 gap-0",children:[S,N,y,h]}),e[25]=h,e[26]=y,e[27]=E):E=e[27];let k;return e[28]!==r||e[29]!==s||e[30]!==E?(k=a.jsx(Ln,{delayDuration:400,children:a.jsx(fi,{open:s,onOpenChange:r,children:E})}),e[28]=r,e[29]=s,e[30]=E,e[31]=k):k=e[31],k}let C;e[32]===Symbol.for("react.memo_cache_sentinel")?(C=a.jsx(an,{className:"sr-only",children:a.jsx(ln,{children:"All prompts"})}),e[32]=C):C=e[32];let j;e[33]===Symbol.for("react.memo_cache_sentinel")?(j=a.jsx("div",{className:"flex items-center h-12 border-b border-border px-4 shrink-0",children:a.jsx("span",{className:"text-sm font-medium text-foreground",children:"Prompts"})}),e[33]=j):j=e[33];let A;e[34]!==h||e[35]!==y?(A=a.jsxs(cn,{className:"sm:max-w-[1100px] h-[680px] p-0 gap-0 overflow-hidden flex flex-col",children:[C,j,y,h]}),e[34]=h,e[35]=y,e[36]=A):A=e[36];let w;return e[37]!==r||e[38]!==s||e[39]!==A?(w=a.jsx(Ln,{delayDuration:400,children:a.jsx(un,{open:s,onOpenChange:r,children:A})}),e[37]=r,e[38]=s,e[39]=A,e[40]=w):w=e[40],w}function Cl(t){const e=F.c(29),{items:n,onSelect:s,loadingPrompt:r,className:o}=t,[i,l]=g.useState(!1);if(n.length===0)return null;let u,d,f;if(e[0]!==n||e[1]!==r||e[2]!==s){const v=n.slice(0,Rs);let b;e[6]!==n?(b=n.slice(Rs),e[6]=n,e[7]=b):b=e[7],u=b,d=!!r;let y;e[8]!==d||e[9]!==r?.name||e[10]!==s?(y=C=>a.jsx(zr,{item:C,onSelect:s,isLoading:r?.name===C.prompt.name,isDisabled:d&&r?.name!==C.prompt.name},C.prompt.name),e[8]=d,e[9]=r?.name,e[10]=s,e[11]=y):y=e[11],f=v.map(y),e[0]=n,e[1]=r,e[2]=s,e[3]=u,e[4]=d,e[5]=f}else u=e[3],d=e[4],f=e[5];const c=f;let m;e[12]!==o?(m=K("w-full flex flex-wrap gap-2 justify-center",o),e[12]=o,e[13]=m):m=e[13];let V;e[14]!==u.length||e[15]!==d?(V=u.length>0&&a.jsxs("button",{type:"button",disabled:d,onClick:()=>l(!0),className:K($r,"hover:bg-muted/70 hover:text-foreground",d&&"opacity-50 cursor-not-allowed"),children:["+",u.length," more"]}),e[14]=u.length,e[15]=d,e[16]=V):V=e[16];let x;e[17]!==c||e[18]!==m||e[19]!==V?(x=a.jsxs("div",{className:m,children:[c,V]}),e[17]=c,e[18]=m,e[19]=V,e[20]=x):x=e[20];let p;e[21]!==n||e[22]!==r||e[23]!==i||e[24]!==s?(p=a.jsx(Sl,{items:n,open:i,onOpenChange:l,onSelect:s,loadingPrompt:r}),e[21]=n,e[22]=r,e[23]=i,e[24]=s,e[25]=p):p=e[25];let h;return e[26]!==x||e[27]!==p?(h=a.jsxs(Ln,{delayDuration:400,children:[x,p]}),e[26]=x,e[27]=p,e[28]=h):h=e[28],h}function jl(){return null}function Nl(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 Rl(t){const e=F.c(30),{connectionId:n}=t,{sendMessage:s}=ut(),{org:r}=Se();let o;e[0]!==n||e[1]!==r.id||e[2]!==r.slug?(o={connectionId:n,orgId:r.id,orgSlug:r.slug},e[0]=n,e[1]=r.id,e[2]=r.slug,e[3]=o):o=e[3];const i=dt(o);let l;e[4]!==i?(l={client:i,staleTime:6e4},e[4]=i,e[5]=l):l=e[5];const{data:u}=hi(l);let d;e[6]!==u?.prompts?(d=u?.prompts??[],e[6]=u?.prompts,e[7]=d):d=e[7];const f=d;let c;e[8]!==f?(c=f.map(kl),e[8]=f,e[9]=c):c=e[9];const m=c;let V;e[10]===Symbol.for("react.memo_cache_sentinel")?(V={stage:"idle"},e[10]=V):V=e[10];const[x,p]=g.useReducer(Nl,V),[h,v]=g.useState(null);let b;e[11]!==i||e[12]!==s?(b=async(D,R)=>{if(!i){fe.error("MCP client not available"),p({type:"RESET"});return}try{const P=await fn(i,D.name,R);p({type:"RESET"});const I={type:"doc",content:[{type:"paragraph",content:[vr({id:D.name,name:on(D.name,Ke(D._meta)),metadata:P.messages,char:"/",kind:"prompt",args:R}),{type:"text",text:" "}]}]};await s(I)}catch(P){console.error("[ice-breakers] Failed to fetch prompt:",P),fe.error("Failed to load prompt. Please try again."),p({type:"RESET"})}},e[11]=i,e[12]=s,e[13]=b):b=e[13];const y=b;let C;e[14]!==y?(C=async D=>{if(D.arguments&&D.arguments.length>0){p({type:"SELECT_PROMPT",prompt:D}),v(D);return}p({type:"START_LOADING",prompt:D}),await y(D)},e[14]=y,e[15]=C):C=e[15];const j=C;let A;e[16]!==h||e[17]!==y?(A=async D=>{h&&(p({type:"START_LOADING",prompt:h,arguments:D}),v(null),await y(h,D))},e[16]=h,e[17]=y,e[18]=A):A=e[18];const w=A;if(m.length===0)return null;const S=x.stage==="loading"?x.prompt:null;let N;e[19]!==j||e[20]!==m||e[21]!==S?(N=a.jsx(Cl,{items:m,onSelect:j,loadingPrompt:S}),e[19]=j,e[20]=m,e[21]=S,e[22]=N):N=e[22];let E;e[23]===Symbol.for("react.memo_cache_sentinel")?(E=()=>{v(null),p({type:"RESET"})},e[23]=E):E=e[23];let k;e[24]!==h||e[25]!==w?(k=a.jsx(qt,{prompt:h,setPrompt:E,onSubmit:w}),e[24]=h,e[25]=w,e[26]=k):k=e[26];let _;return e[27]!==N||e[28]!==k?(_=a.jsxs(a.Fragment,{children:[N,k]}),e[27]=N,e[28]=k,e[29]=_):_=e[29],_}function kl(t){return{prompt:t}}function El(t){const e=F.c(13),{className:n}=t,{selectedVirtualMcp:s}=Ye(),{org:r}=Se();let o;e[0]!==r.id?(o=dn(r.id),e[0]=r.id,e[1]=o):o=e[1];const i=o.id,l=s?.id??i;let u;e[2]!==n?(u=K("w-full @container",n),e[2]=n,e[3]=u):u=e[3];const d=l??"default";let f;e[4]===Symbol.for("react.memo_cache_sentinel")?(f=a.jsx(jl,{}),e[4]=f):f=e[4];let c;e[5]!==l?(c=a.jsx(Rl,{connectionId:l}),e[5]=l,e[6]=c):c=e[6];let m;e[7]!==d||e[8]!==c?(m=a.jsx(ca,{fallback:null,children:a.jsx(g.Suspense,{fallback:f,children:c},d)}),e[7]=d,e[8]=c,e[9]=m):m=e[9];let V;return e[10]!==u||e[11]!==m?(V=a.jsx("div",{className:u,children:m}),e[10]=u,e[11]=m,e[12]=V):V=e[12],V}const Nn="cubic-bezier(0.645, 0.045, 0.355, 1)",Il=44,Dl={default:"",error:"isolate after:content-[''] after:absolute after:inset-0 after:rounded-xl after:bg-destructive/5 after:pointer-events-none after:-z-10",warning:"isolate after:content-[''] after:absolute after:inset-0 after:rounded-xl after:bg-amber-500/5 after:pointer-events-none after:-z-10"},Tl={default:"border-border",error:"border-destructive/30",warning:"border-amber-500/30"},_l={default:"text-muted-foreground",error:"text-destructive",warning:"text-amber-600 dark:text-amber-500"};function qe(t){const e=F.c(61),{icon:n,label:s,count:r,title:o,footerLeft:i,footerRight:l,children:u,defaultExpanded:d,variant:f,onClose:c}=t,m=f===void 0?"default":f,[V,x]=g.useState(d),[p,h]=g.useState(!1);let v;e[0]!==c?(v=()=>{h(!0),c?.()},e[0]=c,e[1]=v):v=e[1];const b=v;if(p)return null;const y=Tl[m],C=Dl[m];let j;e[2]!==y||e[3]!==C?(j=K("relative flex flex-col rounded-xl bg-background border shadow-md","w-[calc(100%-16px)] max-w-[640px] mx-auto mb-2",y,C),e[2]=y,e[3]=C,e[4]=j):j=e[4];let A;e[5]===Symbol.for("react.memo_cache_sentinel")?(A=()=>x(Ml),e[5]=A):A=e[5];const w=V&&"rounded-b-none",S=!V&&"rounded-b-xl";let N;e[6]!==w||e[7]!==S?(N=K("flex items-center gap-2 w-full px-3 py-2 text-sm text-left","hover:bg-accent/50 transition-colors rounded-t-xl",w,S),e[6]=w,e[7]=S,e[8]=N):N=e[8];const E=_l[m];let k;e[9]!==E?(k=K("shrink-0",E),e[9]=E,e[10]=k):k=e[10];let _;e[11]!==n||e[12]!==k?(_=a.jsx("span",{className:k,children:n}),e[11]=n,e[12]=k,e[13]=_):_=e[13];let D;e[14]!==s?(D=a.jsx("span",{className:"flex-1 min-w-0 truncate",children:s}),e[14]=s,e[15]=D):D=e[15];let R;e[16]!==r?(R=r?a.jsx("span",{className:"text-xs text-muted-foreground shrink-0",children:r}):null,e[16]=r,e[17]=R):R=e[17];const P=V?"rotate(180deg)":"rotate(0deg)";let I;e[18]!==P?(I=a.jsx("span",{"aria-hidden":"true",className:"text-muted-foreground shrink-0 flex items-center justify-center",children:a.jsx(Vn,{size:16,style:{transform:P,transition:`transform 180ms ${Nn}`}})}),e[18]=P,e[19]=I):I=e[19];let T,M;e[20]!==b?(T=ne=>{ne.stopPropagation(),b()},M=ne=>{(ne.key==="Enter"||ne.key===" ")&&(ne.preventDefault(),ne.stopPropagation(),b())},e[20]=b,e[21]=T,e[22]=M):(T=e[21],M=e[22]);let L;e[23]===Symbol.for("react.memo_cache_sentinel")?(L=a.jsx(tt,{size:16}),e[23]=L):L=e[23];let U;e[24]!==T||e[25]!==M?(U=a.jsx("span",{role:"button",tabIndex:0,"data-testid":"collapsible-highlight-close","aria-label":"Close",title:"Close",onClick:T,onKeyDown:M,className:"text-muted-foreground hover:text-foreground transition-colors shrink-0 flex items-center justify-center -mr-1 ml-1 p-1 rounded-md hover:bg-accent",children:L}),e[24]=T,e[25]=M,e[26]=U):U=e[26];let $;e[27]!==V||e[28]!==_||e[29]!==D||e[30]!==R||e[31]!==I||e[32]!==U||e[33]!==N?($=a.jsxs("button",{type:"button","data-testid":"collapsible-highlight-chip","aria-expanded":V,onClick:A,className:N,children:[_,D,R,I,U]}),e[27]=V,e[28]=_,e[29]=D,e[30]=R,e[31]=I,e[32]=U,e[33]=N,e[34]=$):$=e[34];const B=V?"1fr":"0fr";let q;e[35]!==B?(q={display:"grid",gridTemplateRows:B,transition:`grid-template-rows 180ms ${Nn}`},e[35]=B,e[36]=q):q=e[36];let Q;e[37]===Symbol.for("react.memo_cache_sentinel")?(Q={overflow:"hidden",minHeight:0},e[37]=Q):Q=e[37];const O=V?1:0;let z;e[38]!==O?(z={opacity:O,transition:`opacity 120ms ${Nn}`},e[38]=O,e[39]=z):z=e[39];let W;e[40]!==o?(W=o?a.jsx("div",{className:"flex items-start gap-2 px-4 pt-4 pb-5 border-t border-dashed border-border/60",children:a.jsx("p",{className:"flex-1 text-base font-medium text-foreground min-w-0",children:o})}):a.jsx("div",{className:"border-t border-dashed border-border/60"}),e[40]=o,e[41]=W):W=e[41];let H;e[42]!==u||e[43]!==o?(H=u?a.jsx("div",{className:K("overflow-clip pb-4",!o&&"pt-4"),children:u}):null,e[42]=u,e[43]=o,e[44]=H):H=e[44];let X;e[45]!==i||e[46]!==l?(X=i||l?a.jsx("div",{className:"border-t border-border px-3 py-3 pb-6",children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("div",{children:i}),a.jsx("div",{className:"flex items-center gap-2",children:l})]})}):null,e[45]=i,e[46]=l,e[47]=X):X=e[47];let Y;e[48]!==z||e[49]!==W||e[50]!==H||e[51]!==X?(Y=a.jsx("div",{style:Q,children:a.jsxs("div",{style:z,children:[W,H,X]})}),e[48]=z,e[49]=W,e[50]=H,e[51]=X,e[52]=Y):Y=e[52];let te;e[53]!==q||e[54]!==Y?(te=a.jsx("div",{"data-testid":"collapsible-highlight-body",style:q,children:Y}),e[53]=q,e[54]=Y,e[55]=te):te=e[55];let J;return e[56]!==$||e[57]!==te||e[58]!==j||e[59]!==m?(J=a.jsxs("div",{"data-testid":"collapsible-highlight","data-variant":m,className:j,children:[$,te]}),e[56]=$,e[57]=te,e[58]=j,e[59]=m,e[60]=J):J=e[60],J}function Ml(t){return!t}const Pl=Je({content:at().min(1).describe("Imperative form, e.g. 'Implement the login flow'"),status:Hn(["pending","in_progress","completed"]),activeForm:at().min(1).describe("Present-continuous form shown in the UI while the todo is in progress, e.g. 'Implementing the login flow'")}),Br=Je({todos:ua(Pl)}),Ol="Plan and track multi-step work. Call with the FULL todo list every time — this replaces the prior list. Call at the start of every multi-step request. Skip only for true one-shots (a single tool call or a direct answer). Mark exactly one todo `in_progress` at a time. Flip a todo to `in_progress` before starting it and to `completed` the moment it finishes — do not batch completions. Your prior tool-call inputs are your current state — read your last call to see where you are.";gi({description:Ol,inputSchema:xi(Br),execute:async({todos:t})=>({ok:!0,count:t.length})});const Ll="tool-todo_write",Fl=new Set(["input-available","output-available"]);function Ur(t){for(let e=t.length-1;e>=0;e--){const n=t[e];if(n.role!=="assistant")continue;const s=n.parts;if(Array.isArray(s))for(let r=s.length-1;r>=0;r--){const o=s[r];if(o.type!==Ll||typeof o.state!="string"||!Fl.has(o.state))continue;const i=Br.safeParse(o.input);if(i.success)return i.data.todos}}return[]}function Kr(t){const e=[];for(const n of t)if("state"in n&&n.state==="approval-requested"&&"approval"in n&&n.approval?.id&&"toolCallId"in n&&n.toolCallId){const s="toolName"in n&&typeof n.toolName=="string"?n.toolName:n.type.startsWith("tool-")?n.type.replace("tool-",""):"Tool";e.push({approvalId:n.approval.id,toolCallId:n.toolCallId,toolName:s,friendlyName:Ua(Ka(s)),input:n.input})}return e}function qr(t){const e=[];for(const n of t)if("type"in n&&n.type==="tool-propose_plan"&&"state"in n&&n.state==="input-available"&&"toolCallId"in n&&"input"in n){const s=n.input;e.push({toolCallId:n.toolCallId,plan:s.plan,state:n.state})}return e}function $l(t){return t?t.message.startsWith("[CREDITS]"):!1}const zl={isCreditExhausted:!1,hasTodos:!1,showError:!1,showWarning:!1,hasApprovals:!1,hasPlans:!1,isWaitingForUserInput:!1};function Bl(t){const{messages:e,error:n,finishReason:s,isStreaming:r,isWaitingForApprovals:o}=t;if(!r&&n&&$l(n))return{...zl,isCreditExhausted:!0};const i=e.at(-1),l=i?.role==="assistant"?i.parts:[],u=l,f=!!u.filter(y=>y.type==="tool-user_ask").filter(y=>y.state!=="output-available").length,c=qr(l),m=Kr(u),V=Ur(e),x=!r&&!!n,p=m.length>0||r&&o,h=c.length>0,b=!r&&!!s&&s!=="stop"&&!(s==="tool-calls"&&(f||p||h))&&!x;return{isCreditExhausted:!1,hasTodos:V.length>0,showError:x,showWarning:b,hasApprovals:p,hasPlans:h,isWaitingForUserInput:f}}function Yr(){const t=F.c(6),{messages:e,error:n,finishReason:s,isStreaming:r,isWaitingForApprovals:o}=ut(),i=n??null,l=s??null;let u;return t[0]!==r||t[1]!==o||t[2]!==e||t[3]!==i||t[4]!==l?(u=Bl({messages:e,error:i,finishReason:l,isStreaming:r,isWaitingForApprovals:o}),t[0]=r,t[1]=o,t[2]=e,t[3]=i,t[4]=l,t[5]=u):u=t[5],u}function Ul(){const t=Yr();return t.isCreditExhausted?0:Number(t.hasTodos)+Number(t.showError)+Number(t.showWarning)+Number(t.hasApprovals)+Number(t.hasPlans)+Number(t.isWaitingForUserInput)}function Qr(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(n=>n.type==="hardBreak"||n.type==="text"&&(!n.text||n.text.trim()==="")):!1)}const Kl="__home__";function as(t,e){return da.chatDraft(t,e)}function ql(t){if(!t)return null;let e;try{e=JSON.parse(t)}catch{return null}if(!e||typeof e!="object"||typeof e.updatedAt!="number")return null;const n=e.tiptapDoc;return!n||typeof n!="object"||n.type!=="doc"||!Array.isArray(n.content)?null:n}function Yl(t,e,n,s,r){const o=as(e,n);if(Qr(s)){t.removeItem(o);return}const i={tiptapDoc:s,updatedAt:Date.now()},l=JSON.stringify(i);try{t.setItem(o,l)}catch(u){if(Hl(u)){const d=new TextEncoder().encode(l).byteLength;r?.onQuotaExceeded?.({docSizeBytes:d});return}throw u}}function ks(t,e,n){const s=as(e,n),r=t.getItem(s),o=ql(r);return r!==null&&o===null&&t.removeItem(s),o}function Ql(t,e,n){t.removeItem(as(e,n))}function Hl(t){if(!t||typeof t!="object")return!1;const e=t.name;return e==="QuotaExceededError"||e==="NS_ERROR_DOM_QUOTA_REACHED"}function Wl(t){const e=F.c(21),{current:n,total:s,onPrev:r,onNext:o}=t;if(s<=1)return null;const i=n===0,l=n===0?"opacity-30 cursor-not-allowed":"hover:text-foreground cursor-pointer";let u;e[0]!==l?(u=K("p-0.5 rounded transition-colors",l),e[0]=l,e[1]=u):u=e[1];let d;e[2]===Symbol.for("react.memo_cache_sentinel")?(d=a.jsx(zi,{size:14}),e[2]=d):d=e[2];let f;e[3]!==r||e[4]!==i||e[5]!==u?(f=a.jsx("button",{type:"button",onClick:r,disabled:i,className:u,"aria-label":"Previous question",children:d}),e[3]=r,e[4]=i,e[5]=u,e[6]=f):f=e[6];const c=n+1;let m;e[7]!==c||e[8]!==s?(m=a.jsxs("span",{className:"tabular-nums text-xs",children:[c," of ",s]}),e[7]=c,e[8]=s,e[9]=m):m=e[9];const V=n===s-1,x=n===s-1?"opacity-30 cursor-not-allowed":"hover:text-foreground cursor-pointer";let p;e[10]!==x?(p=K("p-0.5 rounded transition-colors",x),e[10]=x,e[11]=p):p=e[11];let h;e[12]===Symbol.for("react.memo_cache_sentinel")?(h=a.jsx(Ir,{size:14}),e[12]=h):h=e[12];let v;e[13]!==o||e[14]!==p||e[15]!==V?(v=a.jsx("button",{type:"button",onClick:o,disabled:V,className:p,"aria-label":"Next question",children:h}),e[13]=o,e[14]=p,e[15]=V,e[16]=v):v=e[16];let b;return e[17]!==v||e[18]!==f||e[19]!==m?(b=a.jsxs("div",{className:"flex items-center gap-1 text-sm text-muted-foreground",children:[f,m,v]}),e[17]=v,e[18]=f,e[19]=m,e[20]=b):b=e[20],b}function Hr(t){const e=F.c(8),{currentIndex:n,total:s,onPrev:r,onNext:o,extraLeft:i}=t;let l;e[0]!==n||e[1]!==o||e[2]!==r||e[3]!==s?(l=a.jsx(Wl,{current:n,total:s,onPrev:r,onNext:o}),e[0]=n,e[1]=o,e[2]=r,e[3]=s,e[4]=l):l=e[4];let u;return e[5]!==i||e[6]!==l?(u=a.jsxs("div",{className:"flex items-center gap-2",children:[l,i]}),e[5]=i,e[6]=l,e[7]=u):u=e[7],u}function Gl(t){const e=F.c(17),{isStreaming:n,isAllAnswered:s,isCurrentAnswered:r,onAdvanceOrSubmit:o,submitLabel:i,nextLabel:l}=t,f=s?i===void 0?"Submit":i:l===void 0?"Next":l,c=s?n:!r,m=c?s?"Waiting for the assistant to finish…":"Answer this item to continue":null;let V;e[0]!==c||e[1]!==o?(V=()=>{c||o()},e[0]=c,e[1]=o,e[2]=V):V=e[2];const x=c&&"opacity-50 cursor-not-allowed";let p;e[3]!==x?(p=K("h-7 px-2.5 text-xs",x),e[3]=x,e[4]=p):p=e[4];let h;e[5]!==c||e[6]!==f||e[7]!==V||e[8]!==p?(h=a.jsx(ae,{type:"button",size:"sm","aria-disabled":c,onClick:V,className:p,children:f}),e[5]=c,e[6]=f,e[7]=V,e[8]=p,e[9]=h):h=e[9];const v=h;if(!m)return v;let b;e[10]!==v?(b=a.jsx(Qe,{asChild:!0,children:v}),e[10]=v,e[11]=b):b=e[11];let y;e[12]!==m?(y=a.jsx(He,{children:m}),e[12]=m,e[13]=y):y=e[13];let C;return e[14]!==b||e[15]!==y?(C=a.jsxs(We,{children:[b,y]}),e[14]=b,e[15]=y,e[16]=C):C=e[16],C}function Wr(t,e,n){return t.findIndex(s=>e(s)===n)}function Es(t,e,n,s){return t.length===0?!1:t.every(r=>s(n[e(r)]))}function Is(t,e,n,s,r){if(t.length===0)return null;const o=Wr(t,e,r);for(let i=1;i<=t.length;i++){const l=t[(o+i)%t.length];if(!l)continue;const u=e(l);if(u!==r&&!s(n[u]))return u}return null}function Xl(t){return!t.isStreaming&&t.allAnswered}function Gr(t){const{parts:e,partKey:n,schema:s,defaultValues:r,isStreaming:o,hasAnswer:i,onSubmit:l}=t,u=e[0]?n(e[0]):"",[d,f]=g.useState(u),[c,m]=g.useState(!1),V=fa({resolver:Va(s),defaultValues:r}),x=V.watch(),p=Wr(e,n,d),h=p>=0?e[p]:void 0,v=i(x[d]),b=Es(e,n,x,i),y=Xl({isStreaming:o,allAnswered:b}),C=()=>{if(p>0){const k=e[p-1];k&&f(n(k))}},j=()=>{if(p>=0&&p<e.length-1){const k=e[p+1];k&&f(n(k))}},A=()=>{const k=V.getValues(),_=Is(e,n,k,i,d);_&&f(_)},w=()=>{V.handleSubmit(k=>{const _=k;for(const D of e)l(D,_[n(D)])})()},S=g.useRef(w);S.current=w;const N=()=>{y&&(m(!1),S.current())},E=()=>{const k=V.getValues();if(Es(e,n,k,i)){if(o){m(!0);return}m(!1),S.current()}else{const _=Is(e,n,k,i,d);_&&f(_)}};return g.useEffect(()=>{if(c&&!o){if(!b){m(!1);return}m(!1),S.current()}},[c,o,b]),{form:V,activeKey:d,setActiveKey:f,currentIndex:p,currentPart:h,isCurrentAnswered:v,isAllAnswered:b,canSubmit:y,goPrev:C,goNext:j,advanceToNextUnanswered:A,submit:N,submitOrAdvance:E}}const Xr="User denied this tool call, give other alternatives.";function Jr(t){const e=F.c(9),{onYolo:n}=t,[s,r]=lt();let o;e[0]!==n||e[1]!==s||e[2]!==r?(o=f=>{const c=f,m=s.toolApprovalLevel??"readonly";r({...s,toolApprovalLevel:c}),c==="auto"&&n(m)},e[0]=n,e[1]=s,e[2]=r,e[3]=o):o=e[3];const i=o;let l;e[4]===Symbol.for("react.memo_cache_sentinel")?(l=a.jsx(Fi,{size:"xs",className:"text-xs text-muted-foreground border-border/60 bg-transparent hover:bg-accent/60 h-7 gap-1",onClick:Zl,children:a.jsx($i,{})}),e[4]=l):l=e[4];let u;e[5]===Symbol.for("react.memo_cache_sentinel")?(u=a.jsx(Pi,{children:vt.map(Jl)}),e[5]=u):u=e[5];let d;return e[6]!==i||e[7]!==s.toolApprovalLevel?(d=a.jsxs(Oi,{value:s.toolApprovalLevel,onValueChange:i,children:[l,u]}),e[6]=i,e[7]=s.toolApprovalLevel,e[8]=d):d=e[8],d}function Jl(t){return a.jsx(Li,{value:t.value,children:t.label},t.value)}function Zl(t){return t.stopPropagation()}function Zr(t){const e=F.c(5),{input:n}=t;if(n==null){let o;return e[0]===Symbol.for("react.memo_cache_sentinel")?(o=a.jsx("div",{className:"px-4 text-xs text-muted-foreground",children:"No input"}),e[0]=o):o=e[0],o}let s;try{let o;e[1]!==n?(o=JSON.stringify(n,null,2),e[1]=n,e[2]=o):o=e[2],s=o}catch{s=String(n)}let r;return e[3]!==s?(r=a.jsx("div",{className:"px-4",children:a.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:s})}),e[3]=s,e[4]=r):r=e[4],r}function ec(t){const e=F.c(28),{approval:n,onRespond:s}=t,[r]=lt(),o=r.toolApprovalLevel??"readonly";let i;e[0]!==n.approvalId||e[1]!==o||e[2]!==s?(i=()=>s(n.approvalId,!1,Xr,o),e[0]=n.approvalId,e[1]=o,e[2]=s,e[3]=i):i=e[3];const l=i;let u;e[4]!==n.approvalId||e[5]!==o||e[6]!==s?(u=()=>s(n.approvalId,!0,void 0,o),e[4]=n.approvalId,e[5]=o,e[6]=s,e[7]=u):u=e[7];const d=u;let f;e[8]!==n.approvalId||e[9]!==s?(f=j=>s(n.approvalId,!0,void 0,j),e[8]=n.approvalId,e[9]=s,e[10]=f):f=e[10];const c=f;let m;e[11]!==c?(m=a.jsx("div",{className:"flex items-center gap-2",children:a.jsx(Jr,{onYolo:c})}),e[11]=c,e[12]=m):m=e[12];const V=m;let x;e[13]!==l?(x=a.jsx(ae,{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:l,children:"Deny"}),e[13]=l,e[14]=x):x=e[14];let p;e[15]!==d?(p=a.jsx(ae,{type:"button",size:"sm",className:"h-7 px-2.5 text-xs active:scale-[0.97] transition-transform",onClick:d,children:"Accept"}),e[15]=d,e[16]=p):p=e[16];let h;e[17]!==x||e[18]!==p?(h=a.jsxs(a.Fragment,{children:[x,p]}),e[17]=x,e[18]=p,e[19]=h):h=e[19];const v=h;let b;e[20]===Symbol.for("react.memo_cache_sentinel")?(b=a.jsx(mn,{size:14}),e[20]=b):b=e[20];let y;e[21]!==n.input?(y=a.jsx(Zr,{input:n.input}),e[21]=n.input,e[22]=y):y=e[22];let C;return e[23]!==n.friendlyName||e[24]!==V||e[25]!==v||e[26]!==y?(C=a.jsx(qe,{icon:b,label:"Approval needed",title:n.friendlyName,defaultExpanded:!0,footerLeft:V,footerRight:v,children:y}),e[23]=n.friendlyName,e[24]=V,e[25]=v,e[26]=y,e[27]=C):C=e[27],C}const tc=ma(at(),Je({approved:pa().optional(),levelOverride:Hn(["auto","readonly"]).optional()}));function nc(t){const e=F.c(42),{approvals:n,isStreaming:s,onRespond:r}=t,[o]=lt(),i=o.toolApprovalLevel??"readonly";let l;e[0]!==n?(l=Object.fromEntries(n.map(oc)),e[0]=n,e[1]=l):l=e[1];const u=l;let d;e[2]!==i||e[3]!==r?(d=(E,k)=>{const _=k;typeof _?.approved=="boolean"&&r(E.approvalId,_.approved,_.approved===!1?Xr:void 0,_.levelOverride??i)},e[2]=i,e[3]=r,e[4]=d):d=e[4];let f;e[5]!==n||e[6]!==u||e[7]!==s||e[8]!==d?(f={parts:n,partKey:rc,schema:tc,defaultValues:u,isStreaming:s,hasAnswer:sc,onSubmit:d},e[5]=n,e[6]=u,e[7]=s,e[8]=d,e[9]=f):f=e[9];const c=Gr(f);let m;e[10]!==n||e[11]!==c?(m=E=>{c.form.reset(Object.fromEntries(n.map(k=>[k.approvalId,{approved:!0,levelOverride:E}]))),c.submitOrAdvance()},e[10]=n,e[11]=c,e[12]=m):m=e[12];const V=m,x=c.currentPart;let p;e[13]!==c?(p=E=>{E.preventDefault(),c.submit()},e[13]=c,e[14]=p):p=e[14];let h;e[15]===Symbol.for("react.memo_cache_sentinel")?(h=a.jsx(mn,{size:14}),e[15]=h):h=e[15];const v=`${n.length} approvals pending`,b=x?.friendlyName??"";let y;e[16]!==V?(y=a.jsx(Jr,{onYolo:V}),e[16]=V,e[17]=y):y=e[17];let C;e[18]!==n.length||e[19]!==c.currentIndex||e[20]!==c.goNext||e[21]!==c.goPrev||e[22]!==y?(C=a.jsx(Hr,{currentIndex:c.currentIndex,total:n.length,onPrev:c.goPrev,onNext:c.goNext,extraLeft:y}),e[18]=n.length,e[19]=c.currentIndex,e[20]=c.goNext,e[21]=c.goPrev,e[22]=y,e[23]=C):C=e[23];let j;e[24]!==x||e[25]!==c.form.control||e[26]!==c.submitOrAdvance?(j=x?a.jsx(ac,{approvalId:x.approvalId,control:c.form.control,onChange:c.submitOrAdvance}):null,e[24]=x,e[25]=c.form.control,e[26]=c.submitOrAdvance,e[27]=j):j=e[27];let A;e[28]!==x?(A=x?a.jsx(Zr,{input:x.input}):null,e[28]=x,e[29]=A):A=e[29];let w;e[30]!==C||e[31]!==j||e[32]!==A||e[33]!==v||e[34]!==b?(w=a.jsx(qe,{icon:h,label:v,title:b,defaultExpanded:!0,footerLeft:C,footerRight:j,children:A}),e[30]=C,e[31]=j,e[32]=A,e[33]=v,e[34]=b,e[35]=w):w=e[35];let S;e[36]!==w||e[37]!==p?(S=a.jsx("form",{onSubmit:p,children:w}),e[36]=w,e[37]=p,e[38]=S):S=e[38];let N;return e[39]!==c.form||e[40]!==S?(N=a.jsx($n,{...c.form,children:S}),e[39]=c.form,e[40]=S,e[41]=N):N=e[41],N}function sc(t){return typeof t?.approved=="boolean"}function rc(t){return t.approvalId}function oc(t){return[t.approvalId,{approved:void 0}]}function ac(t){const e=F.c(6),{approvalId:n,control:s,onChange:r}=t,o=`${n}.approved`;let i;e[0]!==r?(i=u=>{const{field:d}=u,f=d.value===!0,c=d.value===!1;return a.jsxs(a.Fragment,{children:[a.jsx(ae,{type:"button",variant:c?"secondary":"ghost",size:"sm",className:"h-7 px-2.5 text-xs",onClick:()=>{d.onChange(!1),r()},"aria-pressed":c,children:"Deny"}),a.jsx(ae,{type:"button",variant:f?"default":"outline",size:"sm",className:"h-7 px-2.5 text-xs",onClick:()=>{d.onChange(!0),r()},"aria-pressed":f,children:"Accept"})]})},e[0]=r,e[1]=i):i=e[1];let l;return e[2]!==s||e[3]!==o||e[4]!==i?(l=a.jsx(ha,{control:s,name:o,render:i}),e[2]=s,e[3]=o,e[4]=i,e[5]=l):l=e[5],l}function ic(){const t=F.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=a.jsxs("div",{className:"flex items-center gap-2 p-4 border border-dashed rounded-lg bg-accent/50 w-[calc(100%-16px)] max-w-[640px] mx-auto mb-2",children:[a.jsx(mn,{className:"size-5 text-muted-foreground shimmer"}),a.jsx("span",{className:"text-sm text-muted-foreground shimmer",children:"Preparing approval request..."})]}),t[0]=e):e=t[0],e}function lc(t){const e=F.c(8),{approvals:n,isStreaming:s,onRespond:r}=t;if(s&&n.length===0){let i;return e[0]===Symbol.for("react.memo_cache_sentinel")?(i=a.jsx(ic,{}),e[0]=i):i=e[0],i}if(n.length===0)return null;if(n.length===1){const i=n[0];if(!i)return null;let l;return e[1]!==r||e[2]!==i?(l=a.jsx(ec,{approval:i,onRespond:r}),e[1]=r,e[2]=i,e[3]=l):l=e[3],l}let o;return e[4]!==n||e[5]!==s||e[6]!==r?(o=a.jsx(nc,{approvals:n,isStreaming:s,onRespond:r}),e[4]=n,e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function cc(t){const e=F.c(16),{plan:n,onApprove:s,onDismiss:r}=t;let o;e[0]!==s||e[1]!==n.plan?(o=()=>{s(n.plan)},e[0]=s,e[1]=n.plan,e[2]=o):o=e[2];const i=o;let l;e[3]!==r?(l=a.jsx(ae,{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:r,children:"Keep iterating"}),e[3]=r,e[4]=l):l=e[4];let u;e[5]!==i?(u=a.jsx(ae,{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:i,children:"Let's go"}),e[5]=i,e[6]=u):u=e[6];let d;e[7]!==l||e[8]!==u?(d=a.jsxs(a.Fragment,{children:[l,u]}),e[7]=l,e[8]=u,e[9]=d):d=e[9];const f=d;let c;e[10]===Symbol.for("react.memo_cache_sentinel")?(c=a.jsx(ji,{size:14}),e[10]=c):c=e[10];let m;e[11]!==n.plan?(m=a.jsx("div",{className:"px-4 max-h-64 overflow-y-auto",children:a.jsx("div",{className:"prose prose-sm max-w-none text-sm",children:a.jsx(qa,{id:"plan-preview",part:{type:"text",text:n.plan}})})}),e[11]=n.plan,e[12]=m):m=e[12];let V;return e[13]!==f||e[14]!==m?(V=a.jsx(qe,{icon:c,label:"Plan ready",title:"Implementation Plan",defaultExpanded:!0,footerRight:f,children:m}),e[13]=f,e[14]=m,e[15]=V):V=e[15],V}function uc(){const t=F.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=a.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-[640px] mx-auto mb-2",children:[a.jsx(Dt,{className:"size-5 text-purple-500 shimmer"}),a.jsx("span",{className:"text-sm text-muted-foreground shimmer",children:"Preparing plan..."})]}),t[0]=e):e=t[0],e}function dc(t){const e=F.c(7),{plans:n,isStreaming:s,onApprove:r,onDismiss:o}=t;if(s&&n.length===0){let d;return e[0]===Symbol.for("react.memo_cache_sentinel")?(d=a.jsx(uc,{}),e[0]=d):d=e[0],d}let i;e[1]!==n?(i=n.at(-1),e[1]=n,e[2]=i):i=e[2];const l=i;if(!l)return null;let u;return e[3]!==l||e[4]!==r||e[5]!==o?(u=a.jsx(cc,{plan:l,onApprove:r,onDismiss:o}),e[3]=l,e[4]=r,e[5]=o,e[6]=u):u=e[6],u}function eo(t){return t?"response"in t?t.response:t.option??t.draft:""}const Ds=Je({response:at().min(1,"Response is required")}),fc=Je({option:at().nullable(),draft:at()}).refine(t=>(t.option??t.draft).length>0,{message:"Please select or enter an option"}),Vc=Je({response:Hn(["yes","no"])});function mc(t){switch(t.type){case"text":return Ds;case"choice":return fc;case"confirm":return Vc;default:return Ds}}function pc(t){const e={};for(const n of t)e[n.toolCallId]=mc(n.input);return Je(e)}function hc(t){const e=F.c(6),{control:n,name:s,placeholder:r}=t;let o;e[0]!==r?(o=l=>{const{field:u}=l,d=u.value??"";return a.jsxs(Zn,{children:[a.jsx(es,{children:a.jsx("div",{className:"px-2",children:a.jsxs("div",{className:"flex items-center gap-3 px-2 py-3 rounded-lg bg-accent/50",children:[a.jsx("span",{className:"flex items-center justify-center size-6 rounded-md bg-muted shrink-0",children:a.jsx(Cr,{size:16,className:"text-muted-foreground"})}),a.jsx("input",{...u,value:d,type:"text",placeholder:r||"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"})]})})}),a.jsx(ts,{})]})},e[0]=r,e[1]=o):o=e[1];let i;return e[2]!==n||e[3]!==s||e[4]!==o?(i=a.jsx(Er,{control:n,name:s,render:o}),e[2]=n,e[3]=s,e[4]=o,e[5]=i):i=e[5],i}function to(t,e){const n=F.c(4);let s,r;n[0]!==t||n[1]!==e?(s=()=>{const o=i=>{const l=i.target.tagName;if(l==="INPUT"||l==="TEXTAREA"||i.metaKey||i.ctrlKey||i.altKey)return;const u=Number.parseInt(i.key,10);u>=1&&u<=t&&(i.preventDefault(),e(u-1))};return document.addEventListener("keydown",o),()=>document.removeEventListener("keydown",o)},r=[t,e],n[0]=t,n[1]=e,n[2]=s,n[3]=r):(s=n[2],r=n[3]),g.useEffect(s,r)}function gc(t){const e=F.c(40),{control:n,name:s,options:r}=t,o=`${s}.option`;let i;e[0]!==n||e[1]!==o?(i={control:n,name:o,defaultValue:null},e[0]=n,e[1]=o,e[2]=i):i=e[2];const{field:l}=xs(i),u=`${s}.draft`;let d;e[3]!==n||e[4]!==u?(d={control:n,name:u,defaultValue:""},e[3]=n,e[4]=u,e[5]=d):d=e[5];const{field:f}=xs(d),c=l.value,m=f.value??"";let V;if(e[6]!==l||e[7]!==r?(V=_=>{const D=r[_];D!=null&&l.onChange(D)},e[6]=l,e[7]=r,e[8]=V):V=e[8],to(r.length,V),r.length===0)return null;const x=c===null;let p;if(e[9]!==l||e[10]!==c||e[11]!==r){let _;e[13]!==l||e[14]!==c?(_=(D,R)=>{const P=c===D;return a.jsxs("button",{type:"button",onClick:()=>l.onChange(D),className:K("flex items-center gap-3 px-2 py-3 rounded-lg text-left transition-colors w-full",P&&"bg-accent/50",!P&&"hover:bg-accent/30"),"aria-label":`Select ${D}`,children:[a.jsx("span",{className:K("flex items-center justify-center size-6 rounded-md text-sm shrink-0",P?"bg-chart-1 text-white":"bg-muted text-foreground"),children:R+1}),a.jsx("span",{className:"text-sm text-foreground truncate",children:D})]},`${R}-${D}`)},e[13]=l,e[14]=c,e[15]=_):_=e[15],p=r.map(_),e[9]=l,e[10]=c,e[11]=r,e[12]=p}else p=e[12];const h=x&&"bg-accent/50",v=!x&&"hover:bg-accent/30";let b;e[16]!==h||e[17]!==v?(b=K("flex items-center gap-3 px-2 py-3 rounded-lg transition-colors w-full cursor-text",h,v),e[16]=h,e[17]=v,e[18]=b):b=e[18];let y;e[19]===Symbol.for("react.memo_cache_sentinel")?(y=a.jsx("span",{className:"flex items-center justify-center size-6 rounded-md bg-muted shrink-0",children:a.jsx(Cr,{size:16,className:"text-muted-foreground"})}),e[19]=y):y=e[19];const C=x?m:"";let j;e[20]!==f||e[21]!==l||e[22]!==c?(j=_=>{f.onChange(_.target.value),c!==null&&l.onChange(null)},e[20]=f,e[21]=l,e[22]=c,e[23]=j):j=e[23];let A;e[24]!==l||e[25]!==c?(A=()=>{c!==null&&l.onChange(null)},e[24]=l,e[25]=c,e[26]=A):A=e[26];let w;e[27]!==C||e[28]!==j||e[29]!==A?(w=a.jsx("input",{type:"text",value:C,onChange:j,onFocus:A,placeholder:"Something else...","aria-label":"Custom choice input",className:"flex-1 text-sm bg-transparent outline-none placeholder:text-foreground/25 text-foreground min-w-0"}),e[27]=C,e[28]=j,e[29]=A,e[30]=w):w=e[30];let S;e[31]!==w||e[32]!==b?(S=a.jsxs("label",{className:b,children:[y,w]}),e[31]=w,e[32]=b,e[33]=S):S=e[33];let N;e[34]!==S||e[35]!==p?(N=a.jsx(es,{children:a.jsxs("div",{className:"flex flex-col px-2",role:"group","aria-label":"Choice options",children:[p,S]})}),e[34]=S,e[35]=p,e[36]=N):N=e[36];let E;e[37]===Symbol.for("react.memo_cache_sentinel")?(E=a.jsx(ts,{}),e[37]=E):E=e[37];let k;return e[38]!==N?(k=a.jsxs(Zn,{children:[N,E]}),e[38]=N,e[39]=k):k=e[39],k}function xc(t){const e=F.c(6),{control:n,name:s}=t;let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=["yes","no"],e[0]=r):r=e[0];const o=r,i=g.useRef(null);let l;e[1]===Symbol.for("react.memo_cache_sentinel")?(l=f=>{i.current?.onChange(o[f]??"")},e[1]=l):l=e[1],to(o.length,l);let u;e[2]===Symbol.for("react.memo_cache_sentinel")?(u=f=>{const{field:c}=f;return i.current=c,a.jsxs(Zn,{children:[a.jsx(es,{children:a.jsx("div",{className:"flex gap-2 px-2",role:"group","aria-label":"Confirmation options",children:o.map(m=>{const V=c.value===m;return a.jsxs("button",{type:"button",onClick:()=>c.onChange(m),className:K("flex items-center gap-3 px-4 py-3 rounded-lg text-left transition-colors flex-1",V&&"bg-accent/50",!V&&"hover:bg-accent/30"),"aria-label":`Confirm ${m}`,children:[a.jsx("span",{className:K("flex items-center justify-center size-6 rounded-md text-sm shrink-0",V?"bg-chart-1 text-white":"bg-muted text-foreground"),children:m==="yes"?1:2}),a.jsx("span",{className:"text-sm text-foreground capitalize",children:m})]},m)})})}),a.jsx(ts,{})]})},e[2]=u):u=e[2];let d;return e[3]!==n||e[4]!==s?(d=a.jsx(Er,{control:n,name:s,render:u}),e[3]=n,e[4]=s,e[5]=d):d=e[5],d}function Ts(t){const e=F.c(13),{input:n,control:s,toolCallId:r}=t;switch(n.type){case"text":{const o=`${r}.response`;let i;return e[0]!==s||e[1]!==n.default||e[2]!==o?(i=a.jsx(hc,{control:s,name:o,placeholder:n.default}),e[0]=s,e[1]=n.default,e[2]=o,e[3]=i):i=e[3],i}case"choice":{let o;e[4]!==n.options?(o=n.options?.filter(Boolean)??[],e[4]=n.options,e[5]=o):o=e[5];const i=o;let l;return e[6]!==s||e[7]!==i||e[8]!==r?(l=a.jsx(gc,{control:s,name:r,options:i}),e[6]=s,e[7]=i,e[8]=r,e[9]=l):l=e[9],l}case"confirm":{const o=`${r}.response`;let i;return e[10]!==s||e[11]!==o?(i=a.jsx(xc,{control:s,name:o}),e[10]=s,e[11]=o,e[12]=i):i=e[12],i}default:return null}}function bc(t){const e=F.c(71),{parts:n,isStreaming:s,onSubmit:r}=t;let o;e[0]!==n?(o=pc(n.map(Ac)),e[0]=n,e[1]=o):o=e[1];const i=o;let l;e[2]!==n?(l=Object.fromEntries(n.map(wc)),e[2]=n,e[3]=l):l=e[3];const u=l;let d;e[4]!==r?(d=(T,M)=>{const L=eo(M);L&&r(T,L)},e[4]=r,e[5]=d):d=e[5];let f;e[6]!==u||e[7]!==s||e[8]!==n||e[9]!==i||e[10]!==d?(f={parts:n,partKey:yc,schema:i,defaultValues:u,isStreaming:s,hasAnswer:vc,onSubmit:d},e[6]=u,e[7]=s,e[8]=n,e[9]=i,e[10]=d,e[11]=f):f=e[11];const c=Gr(f),m=c.currentPart;let V;e[12]!==m||e[13]!==c?(V=()=>{const T=m;if(!T)return;const M=T.toolCallId;T.input?.type==="choice"?(c.form.setValue(`${M}.option`,null),c.form.setValue(`${M}.draft`,"user has skip this question")):c.form.setValue(`${M}.response`,"user has skip this question"),c.advanceToNextUnanswered()},e[12]=m,e[13]=c,e[14]=V):V=e[14];const x=V;let p;e[15]!==c.currentIndex||e[16]!==c.goNext||e[17]!==c.goPrev||e[18]!==n.length?(p=a.jsx(Hr,{currentIndex:c.currentIndex,total:n.length,onPrev:c.goPrev,onNext:c.goNext}),e[15]=c.currentIndex,e[16]=c.goNext,e[17]=c.goPrev,e[18]=n.length,e[19]=p):p=e[19];const h=p;let v;e[20]!==x?(v=a.jsx(ae,{type:"button",variant:"outline",size:"sm",onClick:x,className:"h-7",children:"Skip"}),e[20]=x,e[21]=v):v=e[21];let b;e[22]!==c.isAllAnswered||e[23]!==c.isCurrentAnswered||e[24]!==c.submitOrAdvance||e[25]!==s?(b=a.jsx(Gl,{isStreaming:s,isAllAnswered:c.isAllAnswered,isCurrentAnswered:c.isCurrentAnswered,onAdvanceOrSubmit:c.submitOrAdvance}),e[22]=c.isAllAnswered,e[23]=c.isCurrentAnswered,e[24]=c.submitOrAdvance,e[25]=s,e[26]=b):b=e[26];let y;e[27]!==v||e[28]!==b?(y=a.jsxs(a.Fragment,{children:[v,b]}),e[27]=v,e[28]=b,e[29]=y):y=e[29];const C=y;if(n.length===1){const T=n[0];if(!T?.input)return null;let M;e[30]!==c?(M=z=>{z.preventDefault(),c.submit()},e[30]=c,e[31]=M):M=e[31];let L;e[32]===Symbol.for("react.memo_cache_sentinel")?(L=a.jsx(zn,{size:14}),e[32]=L):L=e[32];const U=T.input?.prompt??"Question",$=T.input;let B;e[33]!==c.form.control||e[34]!==T.toolCallId||e[35]!==$?(B=a.jsx(Ts,{input:$,control:c.form.control,toolCallId:T.toolCallId}),e[33]=c.form.control,e[34]=T.toolCallId,e[35]=$,e[36]=B):B=e[36];let q;e[37]!==C||e[38]!==U||e[39]!==B?(q=a.jsx(qe,{icon:L,label:"Question pending",title:U,defaultExpanded:!0,footerRight:C,children:B}),e[37]=C,e[38]=U,e[39]=B,e[40]=q):q=e[40];let Q;e[41]!==M||e[42]!==q?(Q=a.jsx("form",{onSubmit:M,autoComplete:"off",children:q}),e[41]=M,e[42]=q,e[43]=Q):Q=e[43];let O;return e[44]!==c.form||e[45]!==Q?(O=a.jsx($n,{...c.form,children:Q}),e[44]=c.form,e[45]=Q,e[46]=O):O=e[46],O}const j=c.form;let A;e[47]!==c?(A=T=>{T.preventDefault(),c.submit()},e[47]=c,e[48]=A):A=e[48];let w;e[49]===Symbol.for("react.memo_cache_sentinel")?(w=a.jsx(zn,{size:14}),e[49]=w):w=e[49];const S=`${c.currentIndex+1} of ${n.length}`,N=m?.input?.prompt??"Question",E=c.activeKey,k=c.setActiveKey;let _;if(e[50]!==c.form||e[51]!==n){let T;e[53]!==c.form?(T=M=>a.jsx(Ui,{value:M.toolCallId,className:"mt-0",children:a.jsx(Ts,{input:M.input,control:c.form.control,toolCallId:M.toolCallId})},M.toolCallId),e[53]=c.form,e[54]=T):T=e[54],_=n.map(T),e[50]=c.form,e[51]=n,e[52]=_}else _=e[52];let D;e[55]!==c.activeKey||e[56]!==c.setActiveKey||e[57]!==_?(D=a.jsx(Ki,{value:E,onValueChange:k,children:_}),e[55]=c.activeKey,e[56]=c.setActiveKey,e[57]=_,e[58]=D):D=e[58];let R;e[59]!==h||e[60]!==C||e[61]!==S||e[62]!==N||e[63]!==D?(R=a.jsx(qe,{icon:w,label:"Question pending",count:S,title:N,defaultExpanded:!0,footerLeft:h,footerRight:C,children:D}),e[59]=h,e[60]=C,e[61]=S,e[62]=N,e[63]=D,e[64]=R):R=e[64];let P;e[65]!==A||e[66]!==R?(P=a.jsx("form",{onSubmit:A,autoComplete:"off",children:R}),e[65]=A,e[66]=R,e[67]=P):P=e[67];let I;return e[68]!==c.form||e[69]!==P?(I=a.jsx($n,{...j,children:P}),e[68]=c.form,e[69]=P,e[70]=I):I=e[70],I}function vc(t){return!!eo(t)}function yc(t){return t.toolCallId}function wc(t){return t.input?.type==="choice"?[t.toolCallId,{option:null,draft:""}]:[t.toolCallId,{response:""}]}function Ac(t){return{toolCallId:t.toolCallId,input:t.input}}function Sc(){const t=F.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=a.jsxs("div",{className:"flex items-center gap-2 p-4 border border-dashed rounded-lg bg-accent/50 w-[calc(100%-16px)] max-w-[640px] mx-auto mb-2",children:[a.jsx(zn,{className:"size-5 text-muted-foreground shimmer"}),a.jsx("span",{className:"text-sm text-muted-foreground shimmer",children:"Preparing question..."})]}),t[0]=e):e=t[0],e}function no(t){const e=F.c(7),{userAskParts:n,isStreaming:s,onSubmit:r}=t;let o;e[0]!==n?(o=n.filter(Cc),e[0]=n,e[1]=o):o=e[1];const i=o;if(i.length===0){if(s){let u;return e[2]===Symbol.for("react.memo_cache_sentinel")?(u=a.jsx(Sc,{}),e[2]=u):u=e[2],u}return null}let l;return e[3]!==s||e[4]!==r||e[5]!==i?(l=a.jsx(bc,{parts:i,isStreaming:s,onSubmit:r}),e[3]=s,e[4]=r,e[5]=i,e[6]=l):l=e[6],l}function Cc(t){return t.state==="input-available"}function jc(t){const e=t.filter(o=>o.status==="in_progress"),n=t.filter(o=>o.status==="completed").length,s=t.length;if(s>0&&n===s)return{icon:"completed",activity:"All done",progress:`${s}/${s}`};const[r]=e;return r&&e.length===1?{icon:"in_progress",activity:r.activeForm,progress:`${n}/${s} done`}:e.length>1?{icon:"in_progress",activity:`${e.length} in progress`,progress:`${n}/${s} done`}:n>0?{icon:"pending",activity:`${s-n} pending`,progress:`${n}/${s} done`}:{icon:"pending",activity:`${s} todos`,progress:"not started"}}function Nc(){const t=F.c(21),{messages:e}=ut();let n,s,r,o,i,l,u,d,f;if(t[0]!==e){f=Symbol.for("react.early_return_sentinel");e:{const V=Ur(e);if(V.length===0){f=null;break e}const x=jc(V);n=qe,i=a.jsx(Ic,{status:x.icon}),l=x.activity,u=x.progress,d=!1,s="todos-list",r="flex flex-col px-2 max-h-[40vh] overflow-y-auto",o=V.map(Rc)}t[0]=e,t[1]=n,t[2]=s,t[3]=r,t[4]=o,t[5]=i,t[6]=l,t[7]=u,t[8]=d,t[9]=f}else n=t[1],s=t[2],r=t[3],o=t[4],i=t[5],l=t[6],u=t[7],d=t[8],f=t[9];if(f!==Symbol.for("react.early_return_sentinel"))return f;let c;t[10]!==s||t[11]!==r||t[12]!==o?(c=a.jsx("ul",{"data-testid":s,className:r,children:o}),t[10]=s,t[11]=r,t[12]=o,t[13]=c):c=t[13];let m;return t[14]!==n||t[15]!==i||t[16]!==l||t[17]!==u||t[18]!==d||t[19]!==c?(m=a.jsx(n,{icon:i,label:l,count:u,defaultExpanded:d,children:c}),t[14]=n,t[15]=i,t[16]=l,t[17]=u,t[18]=d,t[19]=c,t[20]=m):m=t[20],m}function Rc(t,e){return a.jsx(kc,{todo:t},e)}function kc(t){const e=F.c(14),{todo:n}=t,s=n.status==="completed",o=n.status==="in_progress"?n.activeForm:n.content;let i;e[0]!==n.status?(i=a.jsx(Ec,{status:n.status}),e[0]=n.status,e[1]=i):i=e[1];const l=s&&"text-muted-foreground";let u;e[2]!==l?(u=K("relative text-sm leading-snug pt-px select-none",l),e[2]=l,e[3]=u):u=e[3];const d=s?"100%":"0%",f=s?"width 300ms ease 200ms":"width 150ms ease";let c;e[4]!==d||e[5]!==f?(c=a.jsx("span",{"aria-hidden":"true",style:{position:"absolute",left:0,top:"50%",height:"1px",background:"currentColor",width:d,transition:f}}),e[4]=d,e[5]=f,e[6]=c):c=e[6];let m;e[7]!==o||e[8]!==u||e[9]!==c?(m=a.jsxs("span",{className:u,children:[o,c]}),e[7]=o,e[8]=u,e[9]=c,e[10]=m):m=e[10];let V;return e[11]!==i||e[12]!==m?(V=a.jsxs("li",{className:"flex items-start gap-2.5 px-2 py-1.5 rounded-lg hover:bg-accent/50 transition-colors",children:[i,m]}),e[11]=i,e[12]=m,e[13]=V):V=e[13],V}function Ec(t){const e=F.c(4),{status:n}=t,s=n==="completed"?"true":void 0,r=n==="in_progress"?"true":void 0;let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=a.jsx("svg",{viewBox:"0 0 21 21",children:a.jsx("path",{d:"M5,10.75 L8.5,14.25 L19.4,2.3 C18.8333333,1.43333333 18.0333333,1 17,1 L4,1 C2.35,1 1,2.35 1,4 L1,17 C1,18.65 2.35,20 4,20 L17,20 C18.65,20 20,18.65 20,17 L20,7.99769186"})}),e[0]=o):o=e[0];let i;return e[1]!==s||e[2]!==r?(i=a.jsx("div",{className:"todo-cb mt-0.5","data-checked":s,"data-progress":r,"aria-hidden":"true",children:o}),e[1]=s,e[2]=r,e[3]=i):i=e[3],i}function Ic(t){const e=F.c(3),{status:n}=t;if(n==="completed"){let r;return e[0]===Symbol.for("react.memo_cache_sentinel")?(r=a.jsx("span",{"aria-label":"completed",className:"inline-flex items-center justify-center w-3.5 h-3.5 rounded-sm bg-primary",children:a.jsx("svg",{viewBox:"0 0 10 8",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",className:"w-2 h-2 text-primary-foreground",style:{strokeWidth:2},children:a.jsx("path",{d:"M1 4l2.5 2.5L9 1"})})}),e[0]=r):r=e[0],r}if(n==="in_progress"){let r;return e[1]===Symbol.for("react.memo_cache_sentinel")?(r=a.jsx("span",{"aria-label":"in progress",className:"inline-block w-2 h-2 rounded-full bg-primary animate-pulse shrink-0"}),e[1]=r):r=e[1],r}let s;return e[2]===Symbol.for("react.memo_cache_sentinel")?(s=a.jsx("span",{"aria-label":"pending",className:"inline-block w-3.5 h-3.5 rounded-sm border-[1.5px] border-muted-foreground/50 shrink-0"}),e[2]=s):s=e[2],s}const Dc={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"}]},Tc=["Access to 100+ AI models","Unified API, no separate keys needed","Pay only for what you use"];function so(t){const e=F.c(41),{onDismiss:n}=t,{org:s}=Se(),r=ct(),{decoKeyId:o}=_r(),i=Mr(),[l,u]=g.useState(""),[d,f]=g.useState(!1),[c,m]=g.useState("usd"),V=c==="brl"?"R$":"$";let x,p;e[0]!==s.id?(x=()=>{re("credits_exhausted_shown",{organization_id:s.id})},p=[s.id],e[0]=s.id,e[1]=x,e[2]=p):(x=e[1],p=e[2]),g.useEffect(x,p);let h;e[3]!==c||e[4]!==i?(h=async T=>{const{url:M}=await i.call("AI_PROVIDER_TOPUP_URL",{providerId:"deco",amountCents:T,currency:c});return M},e[3]=c,e[4]=i,e[5]=h):h=e[5];let v;e[6]!==n?(v=T=>{T&&window.open(T,"_blank","noopener,noreferrer"),n?.()},e[6]=n,e[7]=v):v=e[7];let b;e[8]!==h||e[9]!==v?(b={mutationFn:h,onSuccess:v,onError:Pc},e[8]=h,e[9]=v,e[10]=b):b=e[10];const{mutate:y,isPending:C}=Wn(b),j=parseFloat(l),A=!isNaN(j)&&j>=1;let w;e[11]!==n?(w=T=>!T&&n?.(),e[11]=n,e[12]=w):w=e[12];let S;e[13]===Symbol.for("react.memo_cache_sentinel")?(S=["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[13]=S):S=e[13];let N;e[14]===Symbol.for("react.memo_cache_sentinel")?(N=a.jsx("div",{className:"absolute inset-x-0 top-0 h-36 pointer-events-none",style:{backgroundImage:S.join(", "),maskImage:"linear-gradient(to bottom, black 0%, transparent 100%)",WebkitMaskImage:"linear-gradient(to bottom, black 0%, transparent 100%)"}}),e[14]=N):N=e[14];let E;e[15]===Symbol.for("react.memo_cache_sentinel")?(E=a.jsxs("div",{className:"relative px-8 pt-8 pb-2 overflow-hidden",children:[N,a.jsxs(an,{className:"relative gap-4",children:[a.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"}),a.jsxs("div",{children:[a.jsx(ln,{className:"text-xl font-semibold tracking-tight",children:"Top up to keep building"}),a.jsx(Jn,{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[15]=E):E=e[15];let k;e[16]!==c||e[17]!==V||e[18]!==l||e[19]!==j||e[20]!==o||e[21]!==A||e[22]!==C||e[23]!==d||e[24]!==y?(k=o&&a.jsxs("div",{className:"px-8 pt-5 pb-6",children:[a.jsx("div",{className:"mb-4",children:a.jsxs(Dr,{type:"single",variant:"outline",size:"sm",value:c,onValueChange:T=>{T&&m(T)},children:[a.jsx(Qt,{value:"usd",className:"h-8 px-3 text-xs",children:"USD"}),a.jsx(Qt,{value:"brl",className:"h-8 px-3 text-xs",children:"BRL"})]})}),a.jsxs("div",{className:"rounded-xl border border-border p-5",children:[a.jsx("div",{className:"grid grid-cols-3 gap-2.5",children:Dc[c].map(T=>{const{dollars:M,label:L}=T;return a.jsxs("button",{type:"button",disabled:C,onClick:()=>{re("credits_topup_clicked",{amount_cents:M*100,currency:c,tier_label:L,source:"exhausted_banner"}),y(M*100)},className:K("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:[a.jsxs("span",{className:"text-2xl font-semibold tabular-nums text-foreground",children:[V,M]}),a.jsx("span",{className:"text-xs text-muted-foreground",children:L})]},M)})}),d?a.jsxs("div",{className:"flex gap-2 mt-3",children:[a.jsxs("div",{className:"relative flex-1",children:[a.jsx("span",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-sm text-muted-foreground select-none",children:V}),a.jsx(Tr,{type:"number",min:"1",step:"1",placeholder:"50",value:l,onChange:T=>u(T.target.value),className:"h-10 text-sm pl-7",autoFocus:!0})]}),a.jsx(ae,{className:"h-10",disabled:!A||C,onClick:()=>{re("credits_topup_clicked",{amount_cents:Math.round(j*100),currency:c,tier_label:"custom",source:"exhausted_banner"}),y(Math.round(j*100))},children:C?"Opening...":"Add"})]}):a.jsx("button",{type:"button",className:"w-full mt-3 text-xs text-muted-foreground hover:text-foreground transition-colors py-1",onClick:()=>f(!0),children:"Enter custom amount"})]}),a.jsx("div",{className:"mt-5 rounded-xl bg-muted/25 border border-border/50 p-4 space-y-3",children:Tc.map(_c)})]}),e[16]=c,e[17]=V,e[18]=l,e[19]=j,e[20]=o,e[21]=A,e[22]=C,e[23]=d,e[24]=y,e[25]=k):k=e[25];let _;e[26]!==n?(_=a.jsx(ae,{variant:"ghost",size:"sm",onClick:n,children:"Dismiss"}),e[26]=n,e[27]=_):_=e[27];let D;e[28]!==r||e[29]!==n||e[30]!==s.slug?(D=a.jsx("button",{type:"button",className:"text-xs text-muted-foreground hover:text-foreground transition-colors",onClick:()=>{r({to:"/$org/settings/ai-providers",params:{org:s.slug}}),n?.()},children:"Manage providers"}),e[28]=r,e[29]=n,e[30]=s.slug,e[31]=D):D=e[31];let R;e[32]!==_||e[33]!==D?(R=a.jsxs("div",{className:"px-8 py-4 border-t border-border bg-muted/30 flex items-center justify-between",children:[_,D]}),e[32]=_,e[33]=D,e[34]=R):R=e[34];let P;e[35]!==k||e[36]!==R?(P=a.jsxs(cn,{className:"sm:max-w-[520px] gap-0 p-0 overflow-hidden",onOpenAutoFocus:Mc,children:[E,k,R]}),e[35]=k,e[36]=R,e[37]=P):P=e[37];let I;return e[38]!==P||e[39]!==w?(I=a.jsx(un,{open:!0,onOpenChange:w,children:P}),e[38]=P,e[39]=w,e[40]=I):I=e[40],I}function _c(t){return a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"flex items-center justify-center size-5 rounded-full bg-[hsl(var(--chart-1))]/15 shrink-0",children:a.jsx(Dt,{size:12,className:"text-[hsl(var(--chart-1))]"})}),a.jsx("span",{className:"text-sm text-foreground/80",children:t})]},t)}function Mc(t){return t.preventDefault()}function Pc(t){fe.error(`Top-up failed: ${t.message}`)}function Oc(){const t=F.c(5),e=rn(),n=Pr(),[s,r]=g.useState(!1);if(!(e?.lockedSandbox==="user-desktop")||!n.ready||n.online)return null;let i;t[0]===Symbol.for("react.memo_cache_sentinel")?(i=a.jsx(ns,{size:14}),t[0]=i):i=t[0];let l;t[1]===Symbol.for("react.memo_cache_sentinel")?(l=a.jsx(ae,{size:"sm",variant:"outline",className:"h-7 text-xs",onClick:()=>r(!0),children:"Reconnect desktop"}),t[1]=l):l=t[1];let u;t[2]===Symbol.for("react.memo_cache_sentinel")?(u=a.jsx(qe,{icon:i,label:"Your desktop is offline",title:"This chat runs on your desktop, which isn't connected right now.",defaultExpanded:!0,variant:"warning",footerRight:l,children:a.jsxs("p",{className:"mx-4 text-xs text-muted-foreground",children:["Run ",a.jsx("code",{className:"font-mono",children:"bunx decocms@latest link"})," in a terminal on that machine to bring it back. Messages you send while it's offline will fail."]})}),t[2]=u):u=t[2];let d;return t[3]!==s?(d=a.jsxs(a.Fragment,{children:[u,a.jsx(Hi,{open:s,onOpenChange:r})]}),t[3]=s,t[4]=d):d=t[4],d}function Lc(t){const e=t.trim(),n=e.startsWith("<")&&/<[a-z][\s\S]*>/i.test(e),s=/cloudflare|cf-[a-z-]+|error[\s_-]?code[\s_-]?5\d\d/i.test(e),r=/failed to fetch|networkerror|load failed|offline/i.test(e),o=/timeout|timed out|aborted|deadline/i.test(e),i=e.length>240,l=/sandbox failed to start(?::\s*(.+))?/is.exec(e);if(l){const u=l[1]?.trim().replace(/\.$/,"");return{summary:u?`Your sandbox didn't finish starting up (${u}). Try again.`:"Your sandbox didn't finish starting up. Try again.",rawDetails:t}}return/link_unavailable|user_desktop_link_/i.test(e)?/user_desktop_link_capability_missing/i.test(e)?{summary:"Your desktop is connected, but the CLI this chat uses wasn't detected there. Install it and sign in on your desktop, then try again.",rawDetails:t}:{summary:"Your desktop is offline. Run `bunx decocms@latest link` in a terminal on it, then try again.",rawDetails:t}:s||n&&i?{summary:"Our servers are having a moment. Try sending again in a few seconds.",rawDetails:t}:r?{summary:"Lost connection. Check your network and try again.",rawDetails:t}:o?{summary:"That took longer than expected. Try again.",rawDetails:t}:n||i?{summary:"Something unexpected came back from the server. Try again.",rawDetails:t}:{summary:t,rawDetails:null}}const Fc={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 Ht(t){const e=F.c(19),{variant:n,onDismiss:s}=t,r=n==="error",o=r?"Error occurred":"Response incomplete",i=r?kr:dr,l=r?t.error.message:Fc[t.finishReason]??`Response stopped unexpectedly: ${t.finishReason}`;let u;e[0]!==r||e[1]!==l?(u=r?Lc(l):{summary:l,rawDetails:null},e[0]=r,e[1]=l,e[2]=u):u=e[2];const{summary:d,rawDetails:f}=u;let c;e[3]!==i?(c=a.jsx(i,{size:14}),e[3]=i,e[4]=c):c=e[4];let m;e[5]!==r||e[6]!==t.onContinue||e[7]!==t.onFixInChat?(m=r?a.jsx(ae,{size:"sm",variant:"outline",onClick:t.onFixInChat,className:"h-7 text-xs",children:"Fix in chat"}):a.jsx(ae,{size:"sm",variant:"outline",onClick:t.onContinue,className:"h-7 text-xs",children:"Continue"}),e[5]=r,e[6]=t.onContinue,e[7]=t.onFixInChat,e[8]=m):m=e[8];let V;e[9]!==f?(V=f?a.jsxs("details",{className:"group mx-4",children:[a.jsxs("summary",{className:"flex cursor-pointer list-none items-center gap-1.5 text-xs text-muted-foreground transition-colors hover:text-foreground [&::-webkit-details-marker]:hidden",children:[a.jsx("svg",{"aria-hidden":"true",className:"size-3 transition-transform group-open:rotate-90",viewBox:"0 0 12 12",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:a.jsx("path",{d:"m4.5 3 3 3-3 3"})}),a.jsx("span",{className:"group-open:hidden",children:"Show technical details"}),a.jsx("span",{className:"hidden group-open:inline",children:"Hide technical details"})]}),a.jsxs("div",{className:"relative mt-2",children:[a.jsx("button",{type:"button",onClick:()=>{navigator.clipboard.writeText(f).then(zc).catch($c)},"aria-label":"Copy error details",title:"Copy",className:"absolute right-1.5 top-1.5 z-10 flex h-6 w-6 items-center justify-center rounded-md bg-background/80 text-muted-foreground backdrop-blur-sm transition-colors hover:bg-background hover:text-foreground",children:a.jsx(Mi,{className:"size-3.5"})}),a.jsx("pre",{className:"max-h-40 overflow-auto rounded-md border border-border/60 bg-background px-3 py-2 pr-8 font-mono text-xs text-foreground/80 whitespace-pre-wrap break-all",children:f})]})]}):null,e[9]=f,e[10]=V):V=e[10];let x;return e[11]!==o||e[12]!==s||e[13]!==d||e[14]!==c||e[15]!==m||e[16]!==V||e[17]!==n?(x=a.jsx(qe,{icon:c,label:o,title:d,defaultExpanded:!0,variant:n,onClose:s,footerRight:m,children:V}),e[11]=o,e[12]=s,e[13]=d,e[14]=c,e[15]=m,e[16]=V,e[17]=n,e[18]=x):x=e[18],x}function $c(){return fe.error("Could not copy")}function zc(){return fe.success("Copied to clipboard")}function hn(){const t=F.c(62),{error:e,clearError:n,finishReason:s,clearFinishReason:r,messages:o,isStreaming:i,submit:l,sendMessage:u}=ut(),[d,f]=lt(),{virtualMcpId:c,createTaskWithMessage:m}=gr(),{chatMode:V,simpleModeTier:x}=Ye();let p;t[0]!==V||t[1]!==x||t[2]!==c?(p=G=>({tier:x,mode:V,toolApprovalLevel:G,agent:c?{id:c}:void 0}),t[0]=V,t[1]=x,t[2]=c,t[3]=p):p=t[3];const h=p;let v;t[4]!==d.toolApprovalLevel?(v=d.toolApprovalLevel??ga(),t[4]=d.toolApprovalLevel,t[5]=v):v=t[5];const b=v,y=o.at(-1),C=y?.role==="assistant"?y.parts:[],j=C.filter(qc),A=qr(C),w=Kr(C);let S;t[6]!==e||t[7]!==u?(S=()=>{if(e){const oe={type:"doc",content:[{type:"paragraph",content:[{type:"text",text:`I encountered this error: ${e.message}. Can you help me fix it?`}]}]};u(oe)}},t[6]=e,t[7]=u,t[8]=S):S=t[8];const N=S;let E;t[9]!==u?(E=()=>{u({type:"doc",content:[{type:"paragraph",content:[{type:"text",text:"Please continue."}]}]})},t[9]=u,t[10]=E):E=t[10];const k=E;let _;t[11]!==h||t[12]!==b||t[13]!==l?(_=(G,oe)=>{l({kind:"toolOutput",toolCallId:G.toolCallId,output:{response:oe}},h(b))},t[11]=h,t[12]=b,t[13]=l,t[14]=_):_=t[14];const D=_;let R;t[15]!==m||t[16]!==d||t[17]!==f||t[18]!==c?(R=G=>{f({...d,toolApprovalLevel:"auto"}),m({virtualMcpId:c,message:{parts:[{type:"text",text:`Implement this plan:
2
2
 
3
3
  ${G}`}]}})},t[15]=m,t[16]=d,t[17]=f,t[18]=c,t[19]=R):R=t[19];const P=R,I=Kc;let T;t[20]!==h||t[21]!==l?(T=(G,oe,Z,pe)=>{l({kind:"approval",approvalId:G,approved:oe,...Z?{reason:Z}:{}},h(pe))},t[20]=h,t[21]=l,t[22]=T):T=t[22];const M=T,L=Yr();if(L.isCreditExhausted){let G;return t[23]!==n?(G=a.jsx(so,{onDismiss:n}),t[23]=n,t[24]=G):G=t[24],G}const{showError:U,showWarning:$,hasApprovals:B}=L,q=j.map(Uc).join("|"),Q=A[0]?.toolCallId??"",O=w.map(Bc).join("|");let z,W;t[25]===Symbol.for("react.memo_cache_sentinel")?(z=a.jsx(Nc,{}),W=a.jsx(Oc,{}),t[25]=z,t[26]=W):(z=t[25],W=t[26]);let H;t[27]!==n||t[28]!==e||t[29]!==N||t[30]!==U?(H=U&&a.jsx(Ht,{variant:"error",error:e,onDismiss:n,onFixInChat:N}),t[27]=n,t[28]=e,t[29]=N,t[30]=U,t[31]=H):H=t[31];let X;t[32]!==r||t[33]!==s||t[34]!==k||t[35]!==$?(X=$&&a.jsx(Ht,{variant:"warning",finishReason:s,onDismiss:r,onContinue:k}),t[32]=r,t[33]=s,t[34]=k,t[35]=$,t[36]=X):X=t[36];let Y;t[37]!==O||t[38]!==M||t[39]!==B||t[40]!==i||t[41]!==w?(Y=B&&a.jsx(lc,{approvals:w,isStreaming:i,onRespond:M},O),t[37]=O,t[38]=M,t[39]=B,t[40]=i,t[41]=w,t[42]=Y):Y=t[42];let te;t[43]!==L.hasPlans||t[44]!==P||t[45]!==I||t[46]!==i||t[47]!==A||t[48]!==Q?(te=L.hasPlans&&a.jsx(dc,{plans:A,isStreaming:i,onApprove:P,onDismiss:I},Q),t[43]=L.hasPlans,t[44]=P,t[45]=I,t[46]=i,t[47]=A,t[48]=Q,t[49]=te):te=t[49];let J;t[50]!==L.isWaitingForUserInput||t[51]!==D||t[52]!==i||t[53]!==q||t[54]!==j?(J=L.isWaitingForUserInput&&a.jsx(no,{userAskParts:j,isStreaming:i,onSubmit:D},q),t[50]=L.isWaitingForUserInput,t[51]=D,t[52]=i,t[53]=q,t[54]=j,t[55]=J):J=t[55];let ne;return t[56]!==X||t[57]!==Y||t[58]!==te||t[59]!==J||t[60]!==H?(ne=a.jsxs("div",{className:"absolute bottom-full left-0 right-0",children:[z,W,H,X,Y,te,J]}),t[56]=X,t[57]=Y,t[58]=te,t[59]=J,t[60]=H,t[61]=ne):ne=t[61],ne}function Bc(t){return t.approvalId}function Uc(t){return t.toolCallId}function Kc(){document.querySelector("[data-chat-input]")?.focus()}function qc(t){return t.type==="tool-user_ask"}hn.Error=function(e){return a.jsx(Ht,{variant:"error",error:e.error,onDismiss:e.onDismiss,onFixInChat:e.onFixInChat})};hn.Warning=function(e){return a.jsx(Ht,{variant:"warning",finishReason:e.finishReason,onDismiss:e.onDismiss,onContinue:e.onContinue})};hn.UserAskQuestion=no;function Yc(t){const e=F.c(12),{taskId:n}=t,s=xr(n),r=Pa(s),o=Oa(),{stop:i,removeLocalMessage:l}=ut();if(r.length===0)return null;let u;e[0]!==i?(u=()=>{i()},e[0]=i,e[1]=u):u=e[1];let d;e[2]===Symbol.for("react.memo_cache_sentinel")?(d=a.jsx(hr,{size:14}),e[2]=d):d=e[2];let f;e[3]!==u?(f=a.jsx(Qe,{asChild:!0,children:a.jsx(ae,{type:"button",variant:"ghost",size:"icon-sm",onClick:u,children:d})}),e[3]=u,e[4]=f):f=e[4];let c;e[5]===Symbol.for("react.memo_cache_sentinel")?(c=a.jsx(He,{side:"top",children:a.jsx("p",{className:"text-xs",children:"Send now"})}),e[5]=c):c=e[5];let m;e[6]!==f?(m=a.jsxs(We,{delayDuration:400,children:[f,c]}),e[6]=f,e[7]=m):m=e[7];let V;return e[8]!==o||e[9]!==l||e[10]!==n?(V=(x,p)=>a.jsxs("div",{className:"group/queuerow flex items-center gap-2 px-3 py-1.5",children:[a.jsx("span",{className:"flex size-[18px] shrink-0 items-center justify-center rounded-full bg-muted text-[10px] font-semibold text-muted-foreground dark:bg-background",children:p+1}),a.jsx("span",{className:"min-w-0 flex-1 truncate text-sm text-foreground",children:x.text}),a.jsx("div",{className:"flex shrink-0 items-center gap-1 opacity-0 transition-opacity group-hover/queuerow:opacity-100",children:a.jsx(ae,{type:"button",variant:"ghost",size:"icon-sm",title:"Remove from queue",onClick:()=>{o.cancel(n,x.messageId).then(h=>{h&&(La(n,x.messageId),l(x.messageId))})},children:a.jsx(Wi,{className:"size-3.5"})})})]},x.messageId),e[8]=o,e[9]=l,e[10]=n,e[11]=V):V=e[11],a.jsxs("div",{className:"mb-1 overflow-hidden rounded-2xl border border-border bg-card dark:bg-muted",children:[a.jsxs("div",{className:"flex items-center justify-between gap-2 border-b border-border py-1.5 pr-2 pl-3 text-xs text-muted-foreground",children:[a.jsxs("span",{children:[r.length," queued message",r.length>1?"s":""]}),m]}),r.map(V)]})}async function Qc(t,e,n){const s=await t.callTool({name:e,arguments:n});if(s.isError){const r=s.content?.[0]?.text??`Tool ${e} failed without a message`;throw new Error(r)}return s}const ro=["SANDBOX_START"],Ot=new Map,Hc=t=>`${t.virtualMcpId}::${t.branch??""}`,Rn=new Set,Wc={mark:(t,e)=>Rn.add(`${t}::${e}`),clear:(t,e)=>Rn.delete(`${t}::${e}`),isStopped:(t,e)=>Rn.has(`${t}::${e}`)};function Gc(t){const e=It();return Wn({mutationKey:ro,mutationFn:async n=>{n.branch&&Wc.clear(n.virtualMcpId,n.branch);const s=Hc(n),r=Ot.get(s);if(r)return r;const o=(async()=>(await Qc(t,"SANDBOX_START",n)).structuredContent)();Ot.set(s,o);try{return await o}finally{Ot.get(s)===o&&Ot.delete(s)}},onSuccess:()=>{xa(e)}})}function Mp(t,e){const n=F.c(3);let s;return n[0]!==e||n[1]!==t?(s={mutationKey:ro,predicate:o=>{if(!t)return!1;const i=o.state.variables;return!i||i.virtualMcpId!==t?!1:(i.branch??"")===(e??"")}},n[0]=e,n[1]=t,n[2]=s):s=n[2],yl(s)>0}function Xc(){const t=F.c(11),e=Pr(),n=ba();let s;t[0]!==e.capabilities||t[1]!==e.online?(s=e.online&&e.capabilities.includes("claude-code"),t[0]=e.capabilities,t[1]=e.online,t[2]=s):s=t[2];let r;t[3]!==e.capabilities||t[4]!==e.online?(r=e.online&&e.capabilities.includes("codex"),t[3]=e.capabilities,t[4]=e.online,t[5]=r):r=t[5];let o;return t[6]!==e.online||t[7]!==n.runtime.agentSandbox||t[8]!==s||t[9]!==r?(o={agentSandbox:n.runtime.agentSandbox,userDesktop:e.online,claudeCode:s,codex:r},t[6]=e.online,t[7]=n.runtime.agentSandbox,t[8]=s,t[9]=r,t[10]=o):o=t[10],o}const Jc={fast:{modelId:"claude-code:haiku",label:"Haiku 4.5"},smart:{modelId:"claude-code:sonnet",label:"Sonnet 5"},thinking:{modelId:"claude-code:opus-1m",label:"Opus 4.8 1M"}},Zc={fast:{modelId:"codex:gpt-5.6-luna",label:"GPT-5.6 Luna"},smart:{modelId:"codex:gpt-5.6-terra",label:"GPT-5.6 Terra"},thinking:{modelId:"codex:gpt-5.6-sol",label:"GPT-5.6 Sol"}};function eu(t){return t==="claude-code"?Jc:t==="codex"?Zc:null}function _s(t,e){return eu(t)?.[e]??null}const tu={"cloud-decopilot":"decopilot","local-decopilot":"decopilot-desktop","local-claude-code":"claude-code-desktop","local-codex":"codex-desktop"},nu={decopilot:"cloud-decopilot","decopilot-desktop":"local-decopilot","claude-code-desktop":"local-claude-code","codex-desktop":"local-codex"};function su(t){return tu[t]}function oo(t){return t===null?"cloud-decopilot":nu[t]}function ao(){const t=F.c(2),{pendingAgentOption:e}=Ye();let n;return t[0]!==e?(n=oo(e),t[0]=e,t[1]=n):n=t[1],n}function ru(){const t=F.c(2),{setPendingAgentOption:e}=Ye();let n;return t[0]!==e?(n=s=>e(su(s)),t[0]=e,t[1]=n):n=t[1],n}function ou(){return Ye().simpleModeTier}function au(){return Ye().setSimpleModeTier}const iu={fast:"Quicker responses",smart:"Balanced quality",thinking:"Deeper reasoning"};function lu(t,e){return t==="local-claude-code"?_s("claude-code",e)?.label??null:t==="local-codex"?_s("codex",e)?.label??null:iu[e]}const cu={decopilot:"Decopilot","claude-code":"Claude Code",codex:"Codex"},uu=dn("").icon;function Wt(t){const e=F.c(4),{compact:n}=t,r=(n===void 0?!1:n)?"size-3.5 rounded-sm":"size-4 rounded-sm";let o;e[0]!==r?(o=K(r),e[0]=r,e[1]=o):o=e[1];let i;return e[2]!==o?(i=a.jsx(jr,{icon:uu,name:"Decopilot",size:"2xs",className:o}),e[2]=o,e[3]=i):i=e[3],i}const du={mode:"cloud-decopilot",label:"Decopilot",description:"Runs in an agent sandbox",group:"cloud",icon:a.jsx(Wt,{}),isAvailable:t=>t.agentSandbox},fu={mode:"local-decopilot",label:"Decopilot",description:"Runs on your desktop",group:"local",icon:a.jsx(Wt,{}),isAvailable:t=>t.userDesktop},Vu={mode:"local-claude-code",label:"Claude Code",description:"Runs via Claude Code CLI",group:"local",icon:a.jsx(Or,{size:16}),isAvailable:t=>t.userDesktop&&t.claudeCode},mu={mode:"local-codex",label:"Codex",description:"Runs via Codex CLI",group:"local",icon:a.jsx(Lr,{size:16}),isAvailable:t=>t.userDesktop&&t.codex},Ms=[du,fu,Vu,mu];function pu(t,e){return t==="claude-code"?"local-claude-code":t==="codex"?"local-codex":e==="user-desktop"?"local-decopilot":"cloud-decopilot"}function hu({selectedMode:t,lockedHarness:e,lockedSandbox:n,isThreadLocked:s}){if(s&&e!=null){const r=Fa(e,n);return r?oo(r):pu(e,n)}return t}function io(t){return t==="local-decopilot"?{icon:a.jsx(Wt,{compact:!0}),text:"Decopilot"}:t==="local-claude-code"?{icon:a.jsx(Or,{size:14}),text:"Claude Code"}:t==="local-codex"?{icon:a.jsx(Lr,{size:14}),text:"Codex"}:{icon:a.jsx(Wt,{compact:!0}),text:"Decopilot"}}function gu(t){const{text:e}=io(t);return{icon:t==="cloud-decopilot"?a.jsx(Ni,{size:14}):a.jsx(ns,{size:14}),text:e}}function kn(t){return t==="cloud-decopilot"?"cloud":"desktop"}const xu="text-muted-foreground hover:text-foreground text-xs transition-[gap] duration-200",bu="text-success hover:text-success";function vu(t){const e=F.c(91),{mode:n,availability:s,locked:r,lockedHarness:o,onSelect:i}=t,[l,u]=g.useState(!1);let d;e[0]!==r||e[1]!==n?(d=r?io(n):gu(n),e[0]=r,e[1]=n,e[2]=d):d=e[2];const{icon:f,text:c}=d;let m;e[3]!==n?(m=kn(n),e[3]=n,e[4]=m):m=e[4];const V=`${c} on ${m}`,x=n!=="cloud-decopilot",p=o!=null,h=o?cu[o]:null;let v,b,y,C,j,A,w,S,N,E,k,_,D;if(e[5]!==s||e[6]!==h||e[7]!==f||e[8]!==x||e[9]!==V||e[10]!==r||e[11]!==n||e[12]!==i||e[13]!==l||e[14]!==p||e[15]!==c){let T;e[29]!==s?(T=Z=>Z.group==="cloud"&&Z.isAvailable(s),e[29]=s,e[30]=T):T=e[30];const M=Ms.filter(T),L=Ms.filter(yu);let U;e[31]!==i?(U=Z=>{i(Z),u(!1)},e[31]=i,e[32]=U):U=e[32];const $=U;b=ss,C=l,j=r?void 0:u;let B;e[33]!==h||e[34]!==V||e[35]!==n||e[36]!==p?(B=p&&h?`This chat is using ${h} on ${kn(n)}. Start a new chat to use a different runtime.`:V,e[33]=h,e[34]=V,e[35]=n,e[36]=p,e[37]=B):B=e[37];const q=r?"mode-picker-locked":"mode-picker",Q=x&&bu,O=r?"gap-0":"gap-0 @[320px]/chat-bottom:gap-1.5";let z;e[38]!==Q||e[39]!==O?(z=K(xu,Q,"shrink min-w-0",O),e[38]=Q,e[39]=O,e[40]=z):z=e[40];const W=!r&&"@[320px]/chat-bottom:max-w-32 @[320px]/chat-bottom:opacity-100";let H;e[41]!==W?(H=K("min-w-0 truncate transition-[max-width,opacity] duration-200 ease-out max-w-0 opacity-0",W),e[41]=W,e[42]=H):H=e[42];let X;e[43]!==H||e[44]!==c?(X=a.jsx("span",{className:H,children:c}),e[43]=H,e[44]=c,e[45]=X):X=e[45];let Y;e[46]!==r?(Y=!r&&a.jsx(Vn,{size:12,className:"opacity-60 hidden @[320px]/chat-bottom:inline-block"}),e[46]=r,e[47]=Y):Y=e[47];let te;e[48]!==f||e[49]!==r||e[50]!==B||e[51]!==q||e[52]!==z||e[53]!==X||e[54]!==Y?(te=a.jsx(Qe,{asChild:!0,children:a.jsx("span",{className:"inline-flex min-w-0 shrink",children:a.jsx(rs,{asChild:!0,children:a.jsxs(ae,{type:"button",variant:"ghost",size:"default","aria-label":B,disabled:r,"data-testid":q,className:z,children:[f,X,Y]})})})}),e[48]=f,e[49]=r,e[50]=B,e[51]=q,e[52]=z,e[53]=X,e[54]=Y,e[55]=te):te=e[55];let J;e[56]!==h||e[57]!==V||e[58]!==n||e[59]!==p?(J=p&&h?`This chat is using ${h} on ${kn(n)}. Start a new chat to use a different runtime.`:V,e[56]=h,e[57]=V,e[58]=n,e[59]=p,e[60]=J):J=e[60];let ne;e[61]!==J?(ne=a.jsx(He,{children:J}),e[61]=J,e[62]=ne):ne=e[62],e[63]!==te||e[64]!==ne?(A=a.jsxs(We,{children:[te,ne]}),e[63]=te,e[64]=ne,e[65]=A):A=e[65],v=os,D="start",y="p-1 w-64",w="menu",S="flex flex-col",N=M.length>0&&a.jsx(Ps,{title:"Cloud"});let G;e[66]!==$||e[67]!==n?(G=Z=>a.jsx(Os,{row:Z,active:n===Z.mode,onSelect:$},Z.mode),e[66]=$,e[67]=n,e[68]=G):G=e[68],E=M.map(G),k=L.length>0&&a.jsx(Ps,{title:"Local",variant:"success",icon:a.jsx(ns,{size:12,"data-testid":"local-section-desktop-icon"}),testId:"local-section-header"});let oe;e[69]!==s||e[70]!==$||e[71]!==n?(oe=Z=>{const pe=Z.isAvailable(s);return a.jsx(Os,{row:Z,active:n===Z.mode,onSelect:$,unavailableHint:pe?void 0:s.userDesktop?"Not detected on your desktop":"Desktop not detected"},Z.mode)},e[69]=s,e[70]=$,e[71]=n,e[72]=oe):oe=e[72],_=L.map(oe),e[5]=s,e[6]=h,e[7]=f,e[8]=x,e[9]=V,e[10]=r,e[11]=n,e[12]=i,e[13]=l,e[14]=p,e[15]=c,e[16]=v,e[17]=b,e[18]=y,e[19]=C,e[20]=j,e[21]=A,e[22]=w,e[23]=S,e[24]=N,e[25]=E,e[26]=k,e[27]=_,e[28]=D}else v=e[16],b=e[17],y=e[18],C=e[19],j=e[20],A=e[21],w=e[22],S=e[23],N=e[24],E=e[25],k=e[26],_=e[27],D=e[28];let R;e[73]!==w||e[74]!==S||e[75]!==N||e[76]!==E||e[77]!==k||e[78]!==_?(R=a.jsxs("div",{role:w,className:S,children:[N,E,k,_]}),e[73]=w,e[74]=S,e[75]=N,e[76]=E,e[77]=k,e[78]=_,e[79]=R):R=e[79];let P;e[80]!==v||e[81]!==y||e[82]!==R||e[83]!==D?(P=a.jsx(v,{align:D,className:y,children:R}),e[80]=v,e[81]=y,e[82]=R,e[83]=D,e[84]=P):P=e[84];let I;return e[85]!==b||e[86]!==C||e[87]!==j||e[88]!==A||e[89]!==P?(I=a.jsxs(b,{open:C,onOpenChange:j,children:[A,P]}),e[85]=b,e[86]=C,e[87]=j,e[88]=A,e[89]=P,e[90]=I):I=e[90],I}function yu(t){return t.group==="local"}function Ps(t){const e=F.c(9),{title:n,variant:s,icon:r,testId:o}=t,l=(s===void 0?"muted":s)==="success"?"bg-success/10 text-success":"text-muted-foreground";let u;e[0]!==l?(u=K("inline-flex w-fit items-center gap-2 mx-1 mt-2 mb-1 px-1.5 py-0.5 rounded text-[10px] font-medium uppercase tracking-wide",l),e[0]=l,e[1]=u):u=e[1];let d;e[2]!==n?(d=a.jsx("span",{children:n}),e[2]=n,e[3]=d):d=e[3];let f;return e[4]!==r||e[5]!==u||e[6]!==d||e[7]!==o?(f=a.jsxs("div",{"data-testid":o,className:u,children:[r,d]}),e[4]=r,e[5]=u,e[6]=d,e[7]=o,e[8]=f):f=e[8],f}function Os(t){const e=F.c(20),{row:n,active:s,onSelect:r,unavailableHint:o}=t;let i;e[0]!==r||e[1]!==n.mode?(i=()=>r(n.mode),e[0]=r,e[1]=n.mode,e[2]=i):i=e[2];let l;e[3]===Symbol.for("react.memo_cache_sentinel")?(l=K("flex items-start gap-2 px-2 py-1.5 rounded-md text-left","hover:bg-muted"),e[3]=l):l=e[3];let u;e[4]!==n.icon?(u=a.jsx("span",{className:"shrink-0 text-muted-foreground mt-0.5",children:n.icon}),e[4]=n.icon,e[5]=u):u=e[5];let d;e[6]!==n.label?(d=a.jsx("div",{className:"text-sm",children:n.label}),e[6]=n.label,e[7]=d):d=e[7];const f=o??n.description;let c;e[8]!==f?(c=a.jsx("div",{className:"text-xs text-muted-foreground",children:f}),e[8]=f,e[9]=c):c=e[9];let m;e[10]!==d||e[11]!==c?(m=a.jsxs("div",{className:"flex-1",children:[d,c]}),e[10]=d,e[11]=c,e[12]=m):m=e[12];let V;e[13]!==s?(V=s&&a.jsx(Dt,{size:14,className:"text-foreground mt-0.5"}),e[13]=s,e[14]=V):V=e[14];let x;return e[15]!==i||e[16]!==u||e[17]!==m||e[18]!==V?(x=a.jsxs("button",{type:"button",role:"menuitem",onClick:i,className:l,children:[u,m,V]}),e[15]=i,e[16]=u,e[17]=m,e[18]=V,e[19]=x):x=e[19],x}function wu(t){const e=F.c(19),{locked:n,currentBranch:s,virtualMcpId:r}=t,o=ao(),i=ru(),{org:l}=Se();let u;e[0]!==l.id||e[1]!==l.slug?(u={connectionId:pi,orgId:l.id,orgSlug:l.slug},e[0]=l.id,e[1]=l.slug,e[2]=u):u=e[2];const d=dt(u),f=Gc(d),c=rn(),m=c?.lockedHarness??null,V=c?.lockedSandbox??null,x=c?.isThreadLocked??!1,p=Xc();let h;e[3]!==x||e[4]!==m||e[5]!==V||e[6]!==o?(h=hu({selectedMode:o,lockedHarness:m,lockedSandbox:V,isThreadLocked:x}),e[3]=x,e[4]=m,e[5]=V,e[6]=o,e[7]=h):h=e[7];const v=h;let b;e[8]!==s||e[9]!==i||e[10]!==f||e[11]!==r?(b=j=>{i(j),re("agent_mode_selected",{mode:j}),s&&f.mutate({virtualMcpId:r,branch:s,sandboxProviderKind:j==="cloud-decopilot"?"agent-sandbox":"user-desktop"})},e[8]=s,e[9]=i,e[10]=f,e[11]=r,e[12]=b):b=e[12];const y=b;let C;return e[13]!==p||e[14]!==y||e[15]!==n||e[16]!==m||e[17]!==v?(C=a.jsx(a.Fragment,{children:a.jsx(vu,{mode:v,availability:p,locked:n,lockedHarness:m,onSelect:y})}),e[13]=p,e[14]=y,e[15]=n,e[16]=m,e[17]=v,e[18]=C):C=e[18],C}function Au(t){return(t??"").normalize("NFKD").replace(/[̀-ͯ]/g,"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||"user"}function Su(t){const e=Au(t),n=Date.now().toString(36).split("").reverse().join("");return`${e}-${n}`}const Bt=100;function Cu(t,e,n){const s=e.trim().toLowerCase();return s?(t??[]).some(r=>r.branches.some(o=>typeof o.name=="string"&&!n.has(o.name)&&o.name.toLowerCase().includes(s))):!0}function ju(t,e){const n=e.trim().toLowerCase();return n?[...t].some(s=>s.toLowerCase().includes(n)):!0}function Nu(t){const e=t;if(e.structuredContent)return e.structuredContent;const n=e.content?.find(s=>s.type==="text")?.text;if(n)try{return JSON.parse(n)}catch{return[]}return[]}function Ru(t){const e=F.c(48),{orgId:n,orgSlug:s,userId:r,connectionId:o,sandboxMap:i,owner:l,repo:u,enabled:d}=t,f=d===void 0?!0:d,c=o??null;let m;e[0]!==n||e[1]!==s||e[2]!==c?(m={connectionId:c,orgId:n,orgSlug:s},e[0]=n,e[1]=s,e[2]=c,e[3]=m):m=e[3];const V=dt(m);let x;e[4]!==o||e[5]!==n||e[6]!==s||e[7]!==l||e[8]!==u?(x=va.githubBranches(n,s,o,l,u),e[4]=o,e[5]=n,e[6]=s,e[7]=l,e[8]=u,e[9]=x):x=e[9];const p=f&&!!o&&!!l&&!!u;let h;e[10]!==V||e[11]!==l||e[12]!==u?(h=async $=>{const{pageParam:B,signal:q}=$,Q=Number(B),O=await V.callTool({name:"list_branches",arguments:{owner:l,repo:u,page:Q,perPage:Bt}},void 0,{signal:q}),z=Nu(O);return{branches:Array.isArray(z)?z:z.branches??[],default_branch:Array.isArray(z)?null:z.default_branch??null,page:Q}},e[10]=V,e[11]=l,e[12]=u,e[13]=h):h=e[13];let v;e[14]!==x||e[15]!==p||e[16]!==h?(v={queryKey:x,enabled:p,staleTime:3e4,retry:!1,initialPageParam:1,queryFn:h,getNextPageParam:_u},e[14]=x,e[15]=p,e[16]=h,e[17]=v):v=e[17];const{data:b,isLoading:y,isError:C,hasNextPage:j,isFetchingNextPage:A,fetchNextPage:w}=rl(v);let S,N;e[18]!==i||e[19]!==r?(N=new Set(Object.keys(i?.[r]??{})),S=[...N].sort().map(Tu),e[18]=i,e[19]=r,e[20]=S,e[21]=N):(S=e[20],N=e[21]);const E=S;let k;if(e[22]!==b?.pages){const $=new Map;for(const q of b?.pages??[])for(const Q of q.branches)typeof Q.name=="string"&&$.set(Q.name,Q);k=[...$.values()].filter(Du),e[22]=b?.pages,e[23]=k}else k=e[23];let _;e[24]!==k||e[25]!==N?(_=k.filter($=>!N.has($.name)).map(Iu),e[24]=k,e[25]=N,e[26]=_):_=e[26];const D=_;let R;e[27]!==b?.pages?(R=b?.pages.find(Eu)?.default_branch??null,e[27]=b?.pages,e[28]=R):R=e[28];const P=R;let I;e[29]!==b?.pages||e[30]!==w||e[31]!==A||e[32]!==N?(I=async($,B)=>{const q=B===void 0?ku:B;if(!q()||ju(N,$)||A)return;let Q=b?.pages??[];for(;q()&&!Cu(Q,$,N)&&(Q.at(-1)?.branches.length??Bt)>=Bt;){const O=await w();if(!q())break;const z=O.data?.pages??Q;if(z.length===Q.length)break;Q=z}},e[29]=b?.pages,e[30]=w,e[31]=A,e[32]=N,e[33]=I):I=e[33];const T=I,M=j??!1;let L;e[34]!==w||e[35]!==j||e[36]!==A?(L=()=>{j&&!A&&w()},e[34]=w,e[35]=j,e[36]=A,e[37]=L):L=e[37];let U;return e[38]!==P||e[39]!==T||e[40]!==C||e[41]!==A||e[42]!==y||e[43]!==D||e[44]!==M||e[45]!==L||e[46]!==E?(U={yours:E,others:D,defaultBase:P,isLoading:y,isError:C,hasMore:M,isFetchingMore:A,fetchMore:L,fetchUntilMatch:T},e[38]=P,e[39]=T,e[40]=C,e[41]=A,e[42]=y,e[43]=D,e[44]=M,e[45]=L,e[46]=E,e[47]=U):U=e[47],U}function ku(){return!0}function Eu(t){return t.default_branch}function Iu(t){return{name:t.name,source:"other",author:typeof t.commit?.author=="string"?t.commit.author:t.commit?.author?.login??null}}function Du(t){return typeof t.name=="string"}function Tu(t){return{name:t,source:"yours"}}function _u(t){if(!(t.branches.length<Bt))return t.page+1}function Mu(t){const e=F.c(85),{orgId:n,orgSlug:s,userId:r,userLabel:o,connectionId:i,owner:l,repo:u,sandboxMap:d,value:f,onChange:c,disabled:m,placement:V}=t,x=m===void 0?!1:m,h=(V===void 0?"chat":V)==="header",[v,b]=g.useState(!1),[y,C]=g.useState(""),[j,A]=g.useState(!1),w=g.useRef(0);let S;e[0]!==i||e[1]!==v||e[2]!==n||e[3]!==s||e[4]!==l||e[5]!==u||e[6]!==d||e[7]!==r?(S={orgId:n,orgSlug:s,userId:r,connectionId:i,sandboxMap:d,owner:l,repo:u,enabled:v},e[0]=i,e[1]=v,e[2]=n,e[3]=s,e[4]=l,e[5]=u,e[6]=d,e[7]=r,e[8]=S):S=e[8];const{yours:N,others:E,isLoading:k,isError:_,hasMore:D,isFetchingMore:R,fetchMore:P,fetchUntilMatch:I}=Ru(S);let T;e[9]!==c?(T=ie=>{c(ie),b(!1)},e[9]=c,e[10]=T):T=e[10];const M=T,L=f??"Select branch…";let U;e[11]!==I?(U=ie=>{C(ie),w.current=w.current+1;const ye=w.current,Ze=ie.trim();if(!Ze){A(!1);return}A(!0),I(Ze,()=>ye===w.current).finally(()=>{ye===w.current&&A(!1)})},e[11]=I,e[12]=U):U=e[12];const $=U;let B;e[13]!==P?(B=ie=>{const ye=ie.currentTarget;ye.scrollHeight-ye.scrollTop-ye.clientHeight<48&&P()},e[13]=P,e[14]=B):B=e[14];const q=B,Q=x?void 0:b,O=h?"outline":"ghost",z=h?"sm":"default";let W;e[15]!==x||e[16]!==h?(W=K("font-mono shrink min-w-0 max-w-[200px]",h?"gap-1.5 text-xs":K("text-xs text-muted-foreground hover:text-foreground transition-[gap] duration-200",x?"gap-0":"gap-0 @[320px]/chat-bottom:gap-1.5")),e[15]=x,e[16]=h,e[17]=W):W=e[17];let H;e[18]===Symbol.for("react.memo_cache_sentinel")?(H=a.jsx(zt,{className:"h-3.5 w-3.5 shrink-0"}),e[18]=H):H=e[18];const X=h?"":"transition-[max-width,opacity] duration-200 ease-out max-w-0 opacity-0 @[320px]/chat-bottom:max-w-[200px] @[320px]/chat-bottom:opacity-100";let Y;e[19]!==X?(Y=K("min-w-0 truncate",X),e[19]=X,e[20]=Y):Y=e[20];let te;e[21]!==L||e[22]!==Y?(te=a.jsx("span",{className:Y,children:L}),e[21]=L,e[22]=Y,e[23]=te):te=e[23];let J;e[24]!==x||e[25]!==h?(J=!x&&a.jsx(Vn,{size:12,className:K("opacity-60 shrink-0",h?"":"hidden @[320px]/chat-bottom:inline-block")}),e[24]=x,e[25]=h,e[26]=J):J=e[26];let ne;e[27]!==x||e[28]!==L||e[29]!==W||e[30]!==te||e[31]!==J||e[32]!==O||e[33]!==z?(ne=a.jsx(Qe,{asChild:!0,children:a.jsx("span",{className:"inline-flex min-w-0 shrink",children:a.jsx(rs,{asChild:!0,children:a.jsxs(ae,{variant:O,size:z,"aria-label":L,disabled:x,className:W,children:[H,te,J]})})})}),e[27]=x,e[28]=L,e[29]=W,e[30]=te,e[31]=J,e[32]=O,e[33]=z,e[34]=ne):ne=e[34];let G;e[35]!==L?(G=a.jsx(He,{children:L}),e[35]=L,e[36]=G):G=e[36];let oe;e[37]!==ne||e[38]!==G?(oe=a.jsxs(We,{children:[ne,G]}),e[37]=ne,e[38]=G,e[39]=oe):oe=e[39];let Z;e[40]!==$||e[41]!==y?(Z=a.jsx(el,{placeholder:"Search loaded branches…",value:y,onValueChange:$}),e[40]=$,e[41]=y,e[42]=Z):Z=e[42];let pe;e[43]!==M||e[44]!==o?(pe=a.jsx(ae,{variant:"outline",size:"sm",className:"h-7 shrink-0",onClick:()=>M(Su(o)),children:"New"}),e[43]=M,e[44]=o,e[45]=pe):pe=e[45];let ve;e[46]!==Z||e[47]!==pe?(ve=a.jsxs("div",{className:"*:data-[slot=command-input-wrapper]:flex-1 *:data-[slot=command-input-wrapper]:border-b-0 flex items-center border-b pr-2",children:[Z,pe]}),e[46]=Z,e[47]=pe,e[48]=ve):ve=e[48];let ee;e[49]!==_?(ee=_&&a.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[49]=_,e[50]=ee):ee=e[50];let ce;e[51]!==D||e[52]!==_||e[53]!==k?(ce=!_&&!k&&a.jsx(tl,{children:D?"Looking through more branches...":"No branches found."}),e[51]=D,e[52]=_,e[53]=k,e[54]=ce):ce=e[54];let Ce;e[55]!==M||e[56]!==N?(Ce=N.length>0&&a.jsx(ys,{heading:"Your branches",children:N.map(ie=>a.jsxs(ws,{value:ie.name,onSelect:()=>M(ie.name),children:[a.jsx(zt,{className:"mr-2 h-4 w-4"}),a.jsx("span",{className:"flex-1 truncate",children:ie.name})]},ie.name))}),e[55]=M,e[56]=N,e[57]=Ce):Ce=e[57];let je;e[58]!==E||e[59]!==M?(je=E.length>0&&a.jsxs(a.Fragment,{children:[a.jsx(Zi,{}),a.jsx(ys,{heading:"Other branches in repo",children:E.map(ie=>a.jsxs(ws,{value:ie.name,onSelect:()=>M(ie.name),children:[a.jsx(zt,{className:"mr-2 h-4 w-4"}),a.jsx("span",{className:"flex-1 truncate",children:ie.name}),ie.author&&a.jsxs("span",{className:"text-xs text-muted-foreground",children:["@",ie.author]})]},ie.name))})]}),e[58]=E,e[59]=M,e[60]=je):je=e[60];let Te;e[61]!==P||e[62]!==D||e[63]!==R||e[64]!==j?(Te=D&&a.jsx("div",{className:"border-t p-2",children:a.jsx(ae,{variant:"ghost",size:"sm",className:"h-7 w-full text-xs",disabled:R,onClick:P,children:R||j?"Loading more…":"Load more branches"})}),e[61]=P,e[62]=D,e[63]=R,e[64]=j,e[65]=Te):Te=e[65];let _e;e[66]!==D||e[67]!==E.length?(_e=!D&&E.length>0&&a.jsx("div",{className:"border-t p-2 text-center text-xs text-muted-foreground",children:"All loaded"}),e[66]=D,e[67]=E.length,e[68]=_e):_e=e[68];let Pe;e[69]!==q||e[70]!==ee||e[71]!==ce||e[72]!==Ce||e[73]!==je||e[74]!==Te||e[75]!==_e?(Pe=a.jsxs(nl,{onScroll:q,children:[ee,ce,Ce,je,Te,_e]}),e[69]=q,e[70]=ee,e[71]=ce,e[72]=Ce,e[73]=je,e[74]=Te,e[75]=_e,e[76]=Pe):Pe=e[76];let Oe;e[77]!==ve||e[78]!==Pe?(Oe=a.jsx(os,{className:"w-[min(420px,calc(100vw-2rem))] p-0",align:"start",children:a.jsxs(sl,{children:[ve,Pe]})}),e[77]=ve,e[78]=Pe,e[79]=Oe):Oe=e[79];let Ne;return e[80]!==v||e[81]!==oe||e[82]!==Oe||e[83]!==Q?(Ne=a.jsxs(ss,{open:v,onOpenChange:Q,children:[oe,Oe]}),e[80]=v,e[81]=oe,e[82]=Oe,e[83]=Q,e[84]=Ne):Ne=e[84],Ne}function Pu(t){const e=F.c(25);let n,s,r,o;e[0]!==t?({locked:n,placement:s,value:o,...r}=t,e[0]=t,e[1]=n,e[2]=s,e[3]=r,e[4]=o):(n=e[1],s=e[2],r=e[3],o=e[4]);const i=s==="header";if(n){const u=o??"(no branch)",d=i?"h-8 gap-1.5 border border-input bg-background px-2.5":"h-9 gap-0 px-2";let f;e[5]!==d?(f=K("inline-flex items-center rounded-md font-mono text-xs","text-muted-foreground cursor-default min-w-0 max-w-[200px]",d),e[5]=d,e[6]=f):f=e[6];let c;e[7]===Symbol.for("react.memo_cache_sentinel")?(c=a.jsx(zt,{className:"h-3.5 w-3.5 shrink-0","aria-hidden":"true"}),e[7]=c):c=e[7];const m=i?"":"max-w-0 opacity-0";let V;e[8]!==m?(V=K("min-w-0 truncate",m),e[8]=m,e[9]=V):V=e[9];let x;e[10]!==u||e[11]!==V?(x=a.jsx("span",{className:V,children:u}),e[10]=u,e[11]=V,e[12]=x):x=e[12];let p;e[13]!==f||e[14]!==x?(p=a.jsx(Qe,{asChild:!0,children:a.jsxs("span",{"data-testid":"branch-picker-locked","aria-disabled":"true",className:f,children:[c,x]})}),e[13]=f,e[14]=x,e[15]=p):p=e[15];let h;e[16]!==u?(h=a.jsxs(He,{children:["This chat is using branch ",u,". Start a new chat to use a different branch."]}),e[16]=u,e[17]=h):h=e[17];let v;return e[18]!==p||e[19]!==h?(v=a.jsxs(We,{children:[p,h]}),e[18]=p,e[19]=h,e[20]=v):v=e[20],v}let l;return e[21]!==s||e[22]!==r||e[23]!==o?(l=a.jsx(Mu,{...r,value:o,placement:s}),e[21]=s,e[22]=r,e[23]=o,e[24]=l):l=e[24],l}function Ou(t){const e=F.c(3),{branchPill:n,modePicker:s}=t;if(!n&&!s)return null;let r;return e[0]!==n||e[1]!==s?(r=a.jsxs(a.Fragment,{children:[s,n]}),e[0]=n,e[1]=s,e[2]=r):r=e[2],r}function Lu(t){const e=F.c(26),{virtualMcp:n,currentBranch:s}=t,r=br(),o=rn();let i;e[0]!==r?.messages||e[1]!==o?.isThreadLocked?(i=(r?.messages??[]).length>0||(o?.isThreadLocked??!1),e[0]=r?.messages,e[1]=o?.isThreadLocked,e[2]=i):i=e[2];const l=i,u=o?.setCurrentTaskBranch;let d;e[3]!==n?(d=qi(n),e[3]=n,e[4]=d):d=e[4];const f=d,c=f?.connectionId,{data:m}=fr.useSession(),V=m?.user?.id??"";let x;e[5]!==m?.user?.email||e[6]!==m?.user?.name?(x=m?.user?.name??m?.user?.email?.split("@")[0],e[5]=m?.user?.email,e[6]=m?.user?.name,e[7]=x):x=e[7];const p=x,{org:h}=Se();let v;e[8]!==c||e[9]!==s||e[10]!==f||e[11]!==l||e[12]!==h||e[13]!==u||e[14]!==V||e[15]!==p||e[16]!==n?.id||e[17]!==n?.metadata?.sandboxMap?(v=f&&c?a.jsx(Pu,{orgId:h.id,orgSlug:h.slug,userId:V,userLabel:p,virtualMcpId:n?.id??"",connectionId:c,owner:f.owner,repo:f.name,sandboxMap:n?.metadata?.sandboxMap,value:s,onChange:w=>{u&&u(w)},locked:l,placement:"chat"}):null,e[8]=c,e[9]=s,e[10]=f,e[11]=l,e[12]=h,e[13]=u,e[14]=V,e[15]=p,e[16]=n?.id,e[17]=n?.metadata?.sandboxMap,e[18]=v):v=e[18];const b=v,y=n?.id??"";let C;e[19]!==s||e[20]!==l||e[21]!==y?(C=a.jsx(wu,{locked:l,currentBranch:s,virtualMcpId:y}),e[19]=s,e[20]=l,e[21]=y,e[22]=C):C=e[22];const j=C;let A;return e[23]!==b||e[24]!==j?(A=a.jsx(Ou,{branchPill:b,modePicker:j}),e[23]=b,e[24]=j,e[25]=A):A=e[25],A}const Fu=["fast","smart","thinking"],xt={fast:"Fast",smart:"Smart",thinking:"Thinking"};function $u(t){const e=F.c(30),{tier:n,subtitleFor:s,iconFor:r,onSelect:o}=t,[i,l]=g.useState(!1);let u;e[0]!==o?(u=S=>{o(S),l(!1)},e[0]=o,e[1]=u):u=e[1];const d=u,f=xt[n];let c;e[2]===Symbol.for("react.memo_cache_sentinel")?(c=K("text-muted-foreground hover:text-foreground transition-[gap] duration-200 shrink min-w-0","gap-0 @[320px]/chat-bottom:gap-1.5"),e[2]=c):c=e[2];let m;e[3]!==r||e[4]!==n?(m=r?.(n),e[3]=r,e[4]=n,e[5]=m):m=e[5];let V;e[6]===Symbol.for("react.memo_cache_sentinel")?(V=K("min-w-0 truncate transition-[max-width,opacity] duration-200 ease-out max-w-0 opacity-0","@[320px]/chat-bottom:max-w-24 @[320px]/chat-bottom:opacity-100"),e[6]=V):V=e[6];const x=xt[n];let p;e[7]!==x?(p=a.jsx("span",{className:V,children:x}),e[7]=x,e[8]=p):p=e[8];let h;e[9]===Symbol.for("react.memo_cache_sentinel")?(h=a.jsx(Vn,{size:12,className:"opacity-60 hidden @[320px]/chat-bottom:inline-block"}),e[9]=h):h=e[9];let v;e[10]!==f||e[11]!==m||e[12]!==p?(v=a.jsx(Qe,{asChild:!0,children:a.jsx("span",{className:"inline-flex min-w-0 shrink",children:a.jsx(rs,{asChild:!0,children:a.jsxs(ae,{type:"button",variant:"ghost",size:"default","aria-label":f,className:c,children:[m,p,h]})})})}),e[10]=f,e[11]=m,e[12]=p,e[13]=v):v=e[13];const b=xt[n];let y;e[14]!==b?(y=a.jsx(He,{children:b}),e[14]=b,e[15]=y):y=e[15];let C;e[16]!==y||e[17]!==v?(C=a.jsxs(We,{children:[v,y]}),e[16]=y,e[17]=v,e[18]=C):C=e[18];let j;e[19]!==d||e[20]!==r||e[21]!==s||e[22]!==n?(j=Fu.map(S=>{const N=s(S),E=r?.(S),k=S===n;return a.jsxs("button",{type:"button",role:"menuitem","aria-label":xt[S],onClick:()=>d(S),className:K("flex items-start gap-2 px-2 py-1.5 rounded-md text-left","hover:bg-muted"),children:[E&&a.jsx("span",{className:"shrink-0 text-muted-foreground mt-0.5",children:E}),a.jsxs("div",{className:"flex-1",children:[a.jsx("div",{className:"text-sm",children:xt[S]}),N&&a.jsx("div",{className:"text-xs text-muted-foreground",children:N})]}),k&&a.jsx(Dt,{size:14,className:"text-foreground mt-0.5"})]},S)}),e[19]=d,e[20]=r,e[21]=s,e[22]=n,e[23]=j):j=e[23];let A;e[24]!==j?(A=a.jsx(os,{align:"end",className:"p-1 w-56",children:a.jsx("div",{role:"menu",className:"flex flex-col",children:j})}),e[24]=j,e[25]=A):A=e[25];let w;return e[26]!==i||e[27]!==C||e[28]!==A?(w=a.jsxs(ss,{open:i,onOpenChange:l,children:[C,A]}),e[26]=i,e[27]=C,e[28]=A,e[29]=w):w=e[29],w}function zu(t){return t==="fast"?a.jsx(Ri,{size:16}):t==="thinking"?a.jsx(ki,{size:16}):a.jsx(ol,{size:16})}function Bu(){const t=F.c(6),e=ou(),n=au(),s=ao();let r;t[0]!==s?(r=l=>lu(s,l),t[0]=s,t[1]=r):r=t[1];const o=r;let i;return t[2]!==n||t[3]!==o||t[4]!==e?(i=a.jsx($u,{tier:e,subtitleFor:o,iconFor:zu,onSelect:n}),t[2]=n,t[3]=o,t[4]=e,t[5]=i):i=t[5],i}async function is(t,e,n,s,r){if(!pn(e)){fe.error("Selected model does not support file uploads");return}const o=n.type||"application/octet-stream";if(!Gi(o,e)){const l=Fr(e),u=e?.title??"This model";r?r({fileName:n.name,modelName:u,accepted:l}):fe.error(`"${n.name}" can't be attached`,{description:`${u} accepts ${l}.`});return}const i=10*1024*1024;if(n.size>i){fe.error(`File "${n.name}" exceeds 10MB limit`);return}try{const l=new FileReader,u=new Promise((c,m)=>{l.onload=()=>{const V=l.result;if(typeof V!="string"){m(new Error("Failed to read file as data URL"));return}const x=V.includes(",")?V.split(",")[1]??V:V;c(x)},l.onerror=m});l.readAsDataURL(n);const d=await u,f={id:crypto.randomUUID(),name:n.name,mimeType:n.type||"application/octet-stream",size:n.size,data:d};Ya(t,{from:s,to:s},f)}catch(l){console.error("Failed to process file:",l),fe.error(`Failed to load file "${n.name}"`)}}function Uu(t){const e=F.c(8),{editor:n,selectedModel:s,onUnsupportedFile:r}=t,o=g.useRef(qu);let i,l;e[0]!==n||e[1]!==r||e[2]!==s?(i=()=>{o.current=async(f,c)=>{await is(n,s,f,c,r)}},l=[n,s,r],e[0]=n,e[1]=r,e[2]=s,e[3]=i,e[4]=l):(i=e[3],l=e[4]),g.useEffect(i,l);let u,d;return e[5]!==n?(u=()=>{if(n?.isDestroyed)return;const f=new Yt("fileDropHandler");n.state.plugins.find(V=>V.spec.key===f)&&n.unregisterPlugin(f);const m=new yr({key:f,props:{handleDrop:(V,x,p,h)=>{if(h)return!1;const v=x.dataTransfer?.files;if(!v||v.length===0)return!1;x.preventDefault();const b=V.posAtCoords({left:x.clientX,top:x.clientY});if(!b)return!1;const y=Array.from(v),C=b.pos;for(const j of y)o.current?.(j,C);return!0},handlePaste:(V,x)=>{const p=x.clipboardData?.items;if(!p)return!1;const h=Array.from(p).filter(Ku);if(h.length===0)return!1;x.preventDefault();const{from:v}=V.state.selection;for(const b of h){const y=b.getAsFile();y&&o.current?.(y,v)}return!0}}});return n.registerPlugin(m),()=>{n?.isDestroyed||n.unregisterPlugin(f)}},d=[n],e[5]=n,e[6]=u,e[7]=d):(u=e[6],d=e[7]),g.useEffect(u,d),null}function Ku(t){return t.kind==="file"}function qu(){return Promise.resolve()}function Yu(t){const e=F.c(26),{info:n,onClose:s}=t,r=n!==null;let o;e[0]!==s?(o=j=>!j&&s(),e[0]=s,e[1]=o):o=e[1];let i;e[2]===Symbol.for("react.memo_cache_sentinel")?(i=["radial-gradient(ellipse 40% 200% at -5% 100%, rgba(251,191,36,0.35) 0%, transparent 100%)","radial-gradient(ellipse 40% 200% at 105% -10%, rgba(244,114,182,0.25) 0%, transparent 100%)"],e[2]=i):i=e[2];let l;e[3]===Symbol.for("react.memo_cache_sentinel")?(l=a.jsx("div",{className:"absolute inset-x-0 top-0 h-36 pointer-events-none",style:{backgroundImage:i.join(", "),maskImage:"linear-gradient(to bottom, black 0%, transparent 100%)",WebkitMaskImage:"linear-gradient(to bottom, black 0%, transparent 100%)"}}),e[3]=l):l=e[3];let u,d;e[4]===Symbol.for("react.memo_cache_sentinel")?(u=a.jsx("div",{className:"flex items-center justify-center size-9 rounded-lg bg-amber-500/15 text-amber-600 dark:text-amber-400",children:a.jsx(dr,{size:18})}),d=a.jsx(ln,{className:"text-xl font-semibold tracking-tight",children:"File type not supported"}),e[4]=u,e[5]=d):(u=e[4],d=e[5]);const f=n?.fileName;let c;e[6]!==f?(c=a.jsxs("div",{className:"relative px-8 pt-8 pb-2 overflow-hidden",children:[l,a.jsxs(an,{className:"relative gap-4",children:[u,a.jsxs("div",{children:[d,a.jsxs(Jn,{className:"mt-1.5 text-sm leading-relaxed",children:[a.jsxs("span",{className:"font-medium text-foreground",children:["“",f,"”"]})," ","can't be attached to this chat."]})]})]})]}),e[6]=f,e[7]=c):c=e[7];const m=n?.modelName;let V;e[8]!==m?(V=a.jsxs("div",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground mb-2",children:[m," accepts"]}),e[8]=m,e[9]=V):V=e[9];let x;e[10]===Symbol.for("react.memo_cache_sentinel")?(x=a.jsx(Ei,{size:14,className:"text-muted-foreground"}),e[10]=x):x=e[10];const p=n?.accepted;let h;e[11]!==p?(h=a.jsxs("div",{className:"flex items-center gap-2 text-sm text-foreground",children:[x,a.jsx("span",{className:"capitalize",children:p})]}),e[11]=p,e[12]=h):h=e[12];let v;e[13]!==V||e[14]!==h?(v=a.jsx("div",{className:"px-8 pt-3 pb-6 space-y-3",children:a.jsxs("div",{className:"rounded-xl border border-border p-4",children:[V,h]})}),e[13]=V,e[14]=h,e[15]=v):v=e[15];let b;e[16]!==s?(b=a.jsx("div",{className:"px-8 py-4 border-t border-border bg-muted/30 flex items-center justify-end",children:a.jsx(ae,{onClick:s,children:"Got it"})}),e[16]=s,e[17]=b):b=e[17];let y;e[18]!==v||e[19]!==b||e[20]!==c?(y=a.jsxs(cn,{className:"sm:max-w-[480px] gap-0 p-0 overflow-hidden",onOpenAutoFocus:Qu,children:[c,v,b]}),e[18]=v,e[19]=b,e[20]=c,e[21]=y):y=e[21];let C;return e[22]!==r||e[23]!==y||e[24]!==o?(C=a.jsx(un,{open:r,onOpenChange:o,children:y}),e[22]=r,e[23]=y,e[24]=o,e[25]=C):C=e[25],C}function Qu(t){return t.preventDefault()}function Hu(){const t=F.c(3),[e,n]=g.useState(null);let s;t[0]===Symbol.for("react.memo_cache_sentinel")?(s=()=>n(null),t[0]=s):s=t[0];let r;return t[1]!==e?(r={unsupportedFile:e,onUnsupportedFile:n,clearUnsupportedFile:s},t[1]=e,t[2]=r):r=t[2],r}var Wu=Qa;var Gu=["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] *)"],Bn=Gu.join(","),lo=typeof Element>"u",jt=lo?function(){}:Element.prototype.matches||Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector,Gt=!lo&&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},Xt=function(e,n){var s;n===void 0&&(n=!0);var r=e==null||(s=e.getAttribute)===null||s===void 0?void 0:s.call(e,"inert"),o=r===""||r==="true",i=o||n&&e&&(typeof e.closest=="function"?e.closest("[inert]"):Xt(e.parentNode));return i},Xu=function(e){var n,s=e==null||(n=e.getAttribute)===null||n===void 0?void 0:n.call(e,"contenteditable");return s===""||s==="true"},Ju=function(e,n,s){if(Xt(e))return[];var r=Array.prototype.slice.apply(e.querySelectorAll(Bn));return n&&jt.call(e,Bn)&&r.unshift(e),r=r.filter(s),r},Un=function(e,n,s){for(var r=[],o=Array.from(e);o.length;){var i=o.shift();if(!Xt(i,!1))if(i.tagName==="SLOT"){var l=i.assignedElements(),u=l.length?l:i.children,d=Un(u,!0,s);s.flatten?r.push.apply(r,d):r.push({scopeParent:i,candidates:d})}else{var f=jt.call(i,Bn);f&&s.filter(i)&&(n||!e.includes(i))&&r.push(i);var c=i.shadowRoot||typeof s.getShadowRoot=="function"&&s.getShadowRoot(i),m=!Xt(c,!1)&&(!s.shadowRootFilter||s.shadowRootFilter(i));if(c&&m){var V=Un(c===!0?i.children:c.children,!0,s);s.flatten?r.push.apply(r,V):r.push({scopeParent:i,candidates:V})}else o.unshift.apply(o,i.children)}}return r},co=function(e){return!isNaN(parseInt(e.getAttribute("tabindex"),10))},uo=function(e){if(!e)throw new Error("No node provided");return e.tabIndex<0&&(/^(AUDIO|VIDEO|DETAILS)$/.test(e.tagName)||Xu(e))&&!co(e)?0:e.tabIndex},Zu=function(e,n){var s=uo(e);return s<0&&n&&!co(e)?0:s},ed=function(e,n){return e.tabIndex===n.tabIndex?e.documentOrder-n.documentOrder:e.tabIndex-n.tabIndex},fo=function(e){return e.tagName==="INPUT"},td=function(e){return fo(e)&&e.type==="hidden"},nd=function(e){var n=e.tagName==="DETAILS"&&Array.prototype.slice.apply(e.children).some(function(s){return s.tagName==="SUMMARY"});return n},sd=function(e,n){for(var s=0;s<e.length;s++)if(e[s].checked&&e[s].form===n)return e[s]},rd=function(e){if(!e.name)return!0;var n=e.form||Gt(e),s=function(l){return n.querySelectorAll('input[type="radio"][name="'+l+'"]')},r;if(typeof window<"u"&&typeof window.CSS<"u"&&typeof window.CSS.escape=="function")r=s(window.CSS.escape(e.name));else try{r=s(e.name)}catch(i){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",i.message),!1}var o=sd(r,e.form);return!o||o===e},od=function(e){return fo(e)&&e.type==="radio"},ad=function(e){return od(e)&&!rd(e)},id=function(e){var n,s=e&&Gt(e),r=(n=s)===null||n===void 0?void 0:n.host,o=!1;if(s&&s!==e){var i,l,u;for(o=!!((i=r)!==null&&i!==void 0&&(l=i.ownerDocument)!==null&&l!==void 0&&l.contains(r)||e!=null&&(u=e.ownerDocument)!==null&&u!==void 0&&u.contains(e));!o&&r;){var d,f,c;s=Gt(r),r=(d=s)===null||d===void 0?void 0:d.host,o=!!((f=r)!==null&&f!==void 0&&(c=f.ownerDocument)!==null&&c!==void 0&&c.contains(r))}}return o},Ls=function(e){var n=e.getBoundingClientRect(),s=n.width,r=n.height;return s===0&&r===0},ld=function(e,n){var s=n.displayCheck,r=n.getShadowRoot;if(s==="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 i=jt.call(e,"details>summary:first-of-type"),l=i?e.parentElement:e;if(jt.call(l,"details:not([open]) *"))return!0;if(!s||s==="full"||s==="full-native"||s==="legacy-full"){if(typeof r=="function"){for(var u=e;e;){var d=e.parentElement,f=Gt(e);if(d&&!d.shadowRoot&&r(d)===!0)return Ls(e);e.assignedSlot?e=e.assignedSlot:!d&&f!==e.ownerDocument?e=f.host:e=d}e=u}if(id(e))return!e.getClientRects().length;if(s!=="legacy-full")return!0}else if(s==="non-zero-area")return Ls(e);return!1},cd=function(e){if(/^(INPUT|BUTTON|SELECT|TEXTAREA)$/.test(e.tagName))for(var n=e.parentElement;n;){if(n.tagName==="FIELDSET"&&n.disabled){for(var s=0;s<n.children.length;s++){var r=n.children.item(s);if(r.tagName==="LEGEND")return jt.call(n,"fieldset[disabled] *")?!0:!r.contains(e)}return!0}n=n.parentElement}return!1},ud=function(e,n){return!(n.disabled||td(n)||ld(n,e)||nd(n)||cd(n))},Fs=function(e,n){return!(ad(n)||uo(n)<0||!ud(e,n))},dd=function(e){var n=parseInt(e.getAttribute("tabindex"),10);return!!(isNaN(n)||n>=0)},Vo=function(e){var n=[],s=[];return e.forEach(function(r,o){var i=!!r.scopeParent,l=i?r.scopeParent:r,u=Zu(l,i),d=i?Vo(r.candidates):l;u===0?i?n.push.apply(n,d):n.push(l):s.push({documentOrder:o,tabIndex:u,item:r,isScope:i,content:d})}),s.sort(ed).reduce(function(r,o){return o.isScope?r.push.apply(r,o.content):r.push(o.content),r},[]).concat(n)},mo=function(e,n){n=n||{};var s;return n.getShadowRoot?s=Un([e],n.includeContainer,{filter:Fs.bind(null,n),flatten:!1,getShadowRoot:n.getShadowRoot,shadowRootFilter:dd}):s=Ju(e,n.includeContainer,Fs.bind(null,n)),Vo(s)};function fd(){return/apple/i.test(navigator.vendor)}const $s="data-floating-ui-focusable";function Vd(t){let e=t.activeElement;for(;((n=e)==null||(n=n.shadowRoot)==null?void 0:n.activeElement)!=null;){var n;e=e.shadowRoot.activeElement}return e}function Kn(t,e){if(!t||!e)return!1;const n=e.getRootNode==null?void 0:e.getRootNode();if(t.contains(e))return!0;if(n&&ya(n)){let s=e;for(;s;){if(t===s)return!0;s=s.parentNode||s.host}}return!1}function bt(t){return"composedPath"in t?t.composedPath()[0]:t.target}function En(t,e){if(e==null)return!1;if("composedPath"in t)return t.composedPath().includes(e);const n=t;return n.target!=null&&e.contains(n.target)}function md(t){return t.matches("html,body")}function Nt(t){return t?.ownerDocument||document}function pd(t){return t?t.hasAttribute($s)?t:t.querySelector("["+$s+"]")||t:null}function Ut(t,e,n){return n===void 0&&(n=!0),t.filter(r=>{var o;return r.parentId===e&&(!n||((o=r.context)==null?void 0:o.open))}).flatMap(r=>[r,...Ut(t,r.id,n)])}function hd(t){return"nativeEvent"in t}var gd=typeof document<"u",xd=function(){},Ge=gd?g.useLayoutEffect:xd;const bd={...Vr},vd=bd.useInsertionEffect,yd=vd||(t=>t());function nt(t){const e=g.useRef(()=>{});return yd(()=>{e.current=t}),g.useCallback(function(){for(var n=arguments.length,s=new Array(n),r=0;r<n;r++)s[r]=arguments[r];return e.current==null?void 0:e.current(...s)},[])}const po=()=>({getShadowRoot:!0,displayCheck:typeof ResizeObserver=="function"&&ResizeObserver.toString().includes("[native code]")?"full":"none"});function ho(t,e){const n=mo(t,po()),s=n.length;if(s===0)return;const r=Vd(Nt(t)),o=n.indexOf(r),i=o===-1?e===1?0:s-1:o+e;return n[i]}function wd(t){return ho(Nt(t).body,1)||t}function Ad(t){return ho(Nt(t).body,-1)||t}function In(t,e){const n=e||t.currentTarget,s=t.relatedTarget;return!s||!Kn(n,s)}function Sd(t){mo(t,po()).forEach(n=>{n.dataset.tabindex=n.getAttribute("tabindex")||"",n.setAttribute("tabindex","-1")})}function zs(t){t.querySelectorAll("[data-tabindex]").forEach(n=>{const s=n.dataset.tabindex;delete n.dataset.tabindex,s?n.setAttribute("tabindex",s):n.removeAttribute("tabindex")})}const Cd="data-floating-ui-focusable",Bs="active",Us="selected",jd={...Vr};let Ks=!1,Nd=0;const qs=()=>"floating-ui-"+Math.random().toString(36).slice(2,6)+Nd++;function Rd(){const[t,e]=g.useState(()=>Ks?qs():void 0);return Ge(()=>{t==null&&e(qs())},[]),g.useEffect(()=>{Ks=!0},[]),t}const kd=jd.useId,ls=kd||Rd;function Ed(){const t=new Map;return{emit(e,n){var s;(s=t.get(e))==null||s.forEach(r=>r(n))},on(e,n){t.has(e)||t.set(e,new Set),t.get(e).add(n)},off(e,n){var s;(s=t.get(e))==null||s.delete(n)}}}const Id=g.createContext(null),Dd=g.createContext(null),go=()=>{var t;return((t=g.useContext(Id))==null?void 0:t.id)||null},xo=()=>g.useContext(Dd);function cs(t){return"data-floating-ui-"+t}const Td={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},Ys=g.forwardRef(function(e,n){const[s,r]=g.useState();Ge(()=>{fd()&&r("button")},[]);const o={ref:n,tabIndex:0,role:s,"aria-hidden":s?void 0:!0,[cs("focus-guard")]:"",style:Td};return a.jsx("span",{...e,...o})}),_d={clipPath:"inset(50%)",position:"fixed",top:0,left:0},bo=g.createContext(null),Qs=cs("portal");function Md(t){t===void 0&&(t={});const{id:e,root:n}=t,s=ls(),r=Od(),[o,i]=g.useState(null),l=g.useRef(null);return Ge(()=>()=>{o?.remove(),queueMicrotask(()=>{l.current=null})},[o]),Ge(()=>{if(!s||l.current)return;const u=e?document.getElementById(e):null;if(!u)return;const d=document.createElement("div");d.id=s,d.setAttribute(Qs,""),u.appendChild(d),l.current=d,i(d)},[e,s]),Ge(()=>{if(n===null||!s||l.current)return;let u=n||r?.portalNode;u&&!Na(u)&&(u=u.current),u=u||document.body;let d=null;e&&(d=document.createElement("div"),d.id=e,u.appendChild(d));const f=document.createElement("div");f.id=s,f.setAttribute(Qs,""),u=d||u,u.appendChild(f),l.current=f,i(f)},[e,n,s,r]),o}function Pd(t){const{children:e,id:n,root:s,preserveTabOrder:r=!0}=t,o=Md({id:n,root:s}),[i,l]=g.useState(null),u=g.useRef(null),d=g.useRef(null),f=g.useRef(null),c=g.useRef(null),m=i?.modal,V=i?.open,x=!!i&&!i.modal&&i.open&&r&&!!(s||o);return g.useEffect(()=>{if(!o||!r||m)return;function p(h){o&&In(h)&&(h.type==="focusin"?zs:Sd)(o)}return o.addEventListener("focusin",p,!0),o.addEventListener("focusout",p,!0),()=>{o.removeEventListener("focusin",p,!0),o.removeEventListener("focusout",p,!0)}},[o,r,m]),g.useEffect(()=>{o&&(V||zs(o))},[V,o]),a.jsxs(bo.Provider,{value:g.useMemo(()=>({preserveTabOrder:r,beforeOutsideRef:u,afterOutsideRef:d,beforeInsideRef:f,afterInsideRef:c,portalNode:o,setFocusManagerState:l}),[r,o]),children:[x&&o&&a.jsx(Ys,{"data-type":"outside",ref:u,onFocus:p=>{if(In(p,o)){var h;(h=f.current)==null||h.focus()}else{const v=i?i.domReference:null,b=Ad(v);b?.focus()}}}),x&&o&&a.jsx("span",{"aria-owns":o.id,style:_d}),o&&st.createPortal(e,o),x&&o&&a.jsx(Ys,{"data-type":"outside",ref:d,onFocus:p=>{if(In(p,o)){var h;(h=c.current)==null||h.focus()}else{const v=i?i.domReference:null,b=wd(v);b?.focus(),i?.closeOnFocusOut&&i?.onOpenChange(!1,p.nativeEvent,"focus-out")}}})]})}const Od=()=>g.useContext(bo),Ld={pointerdown:"onPointerDown",mousedown:"onMouseDown",click:"onClick"},Fd={pointerdown:"onPointerDownCapture",mousedown:"onMouseDownCapture",click:"onClickCapture"},Hs=t=>{var e,n;return{escapeKey:typeof t=="boolean"?t:(e=t?.escapeKey)!=null?e:!1,outsidePress:typeof t=="boolean"?t:(n=t?.outsidePress)!=null?n:!0}};function $d(t,e){e===void 0&&(e={});const{open:n,onOpenChange:s,elements:r,dataRef:o}=t,{enabled:i=!0,escapeKey:l=!0,outsidePress:u=!0,outsidePressEvent:d="pointerdown",referencePress:f=!1,referencePressEvent:c="pointerdown",ancestorScroll:m=!1,bubbles:V,capture:x}=e,p=xo(),h=nt(typeof u=="function"?u:()=>!1),v=typeof u=="function"?h:u,b=g.useRef(!1),{escapeKey:y,outsidePress:C}=Hs(V),{escapeKey:j,outsidePress:A}=Hs(x),w=g.useRef(!1),S=nt(R=>{var P;if(!n||!i||!l||R.key!=="Escape"||w.current)return;const I=(P=o.current.floatingContext)==null?void 0:P.nodeId,T=p?Ut(p.nodesRef.current,I):[];if(!y&&(R.stopPropagation(),T.length>0)){let M=!0;if(T.forEach(L=>{var U;if((U=L.context)!=null&&U.open&&!L.context.dataRef.current.__escapeKeyBubbles){M=!1;return}}),!M)return}s(!1,hd(R)?R.nativeEvent:R,"escape-key")}),N=nt(R=>{var P;const I=()=>{var T;S(R),(T=bt(R))==null||T.removeEventListener("keydown",I)};(P=bt(R))==null||P.addEventListener("keydown",I)}),E=nt(R=>{var P;const I=o.current.insideReactTree;o.current.insideReactTree=!1;const T=b.current;if(b.current=!1,d==="click"&&T||I||typeof v=="function"&&!v(R))return;const M=bt(R),L="["+cs("inert")+"]",U=Nt(r.floating).querySelectorAll(L);let $=De(M)?M:null;for(;$&&!jn($);){const O=Sa($);if(jn(O)||!De(O))break;$=O}if(U.length&&De(M)&&!md(M)&&!Kn(M,r.floating)&&Array.from(U).every(O=>!Kn($,O)))return;if(Ca(M)&&D){const O=jn(M),z=ja(M),W=/auto|scroll/,H=O||W.test(z.overflowX),X=O||W.test(z.overflowY),Y=H&&M.clientWidth>0&&M.scrollWidth>M.clientWidth,te=X&&M.clientHeight>0&&M.scrollHeight>M.clientHeight,J=z.direction==="rtl",ne=te&&(J?R.offsetX<=M.offsetWidth-M.clientWidth:R.offsetX>M.clientWidth),G=Y&&R.offsetY>M.clientHeight;if(ne||G)return}const B=(P=o.current.floatingContext)==null?void 0:P.nodeId,q=p&&Ut(p.nodesRef.current,B).some(O=>{var z;return En(R,(z=O.context)==null?void 0:z.elements.floating)});if(En(R,r.floating)||En(R,r.domReference)||q)return;const Q=p?Ut(p.nodesRef.current,B):[];if(Q.length>0){let O=!0;if(Q.forEach(z=>{var W;if((W=z.context)!=null&&W.open&&!z.context.dataRef.current.__outsidePressBubbles){O=!1;return}}),!O)return}s(!1,R,"outside-press")}),k=nt(R=>{var P;const I=()=>{var T;E(R),(T=bt(R))==null||T.removeEventListener(d,I)};(P=bt(R))==null||P.addEventListener(d,I)});g.useEffect(()=>{if(!n||!i)return;o.current.__escapeKeyBubbles=y,o.current.__outsidePressBubbles=C;let R=-1;function P(U){s(!1,U,"ancestor-scroll")}function I(){window.clearTimeout(R),w.current=!0}function T(){R=window.setTimeout(()=>{w.current=!1},Aa()?5:0)}const M=Nt(r.floating);l&&(M.addEventListener("keydown",j?N:S,j),M.addEventListener("compositionstart",I),M.addEventListener("compositionend",T)),v&&M.addEventListener(d,A?k:E,A);let L=[];return m&&(De(r.domReference)&&(L=Cn(r.domReference)),De(r.floating)&&(L=L.concat(Cn(r.floating))),!De(r.reference)&&r.reference&&r.reference.contextElement&&(L=L.concat(Cn(r.reference.contextElement)))),L=L.filter(U=>{var $;return U!==(($=M.defaultView)==null?void 0:$.visualViewport)}),L.forEach(U=>{U.addEventListener("scroll",P,{passive:!0})}),()=>{l&&(M.removeEventListener("keydown",j?N:S,j),M.removeEventListener("compositionstart",I),M.removeEventListener("compositionend",T)),v&&M.removeEventListener(d,A?k:E,A),L.forEach(U=>{U.removeEventListener("scroll",P)}),window.clearTimeout(R)}},[o,r,l,v,d,n,s,m,i,y,C,S,j,N,E,A,k]),g.useEffect(()=>{o.current.insideReactTree=!1},[o,v,d]);const _=g.useMemo(()=>({onKeyDown:S,...f&&{[Ld[c]]:R=>{s(!1,R.nativeEvent,"reference-press")},...c!=="click"&&{onClick(R){s(!1,R.nativeEvent,"reference-press")}}}}),[S,s,f,c]),D=g.useMemo(()=>{function R(P){P.button===0&&(b.current=!0)}return{onKeyDown:S,onMouseDown:R,onMouseUp:R,[Fd[d]]:()=>{o.current.insideReactTree=!0}}},[S,d,o]);return g.useMemo(()=>i?{reference:_,floating:D}:{},[i,_,D])}function zd(t){const{open:e=!1,onOpenChange:n,elements:s}=t,r=ls(),o=g.useRef({}),[i]=g.useState(()=>Ed()),l=go()!=null,[u,d]=g.useState(s.reference),f=nt((V,x,p)=>{o.current.openEvent=V?x:void 0,i.emit("openchange",{open:V,event:x,reason:p,nested:l}),n?.(V,x,p)}),c=g.useMemo(()=>({setPositionReference:d}),[]),m=g.useMemo(()=>({reference:u||s.reference||null,floating:s.floating||null,domReference:s.reference}),[u,s.reference,s.floating]);return g.useMemo(()=>({dataRef:o,open:e,onOpenChange:f,elements:m,events:i,floatingId:r,refs:c}),[e,f,m,i,r,c])}function Bd(t){t===void 0&&(t={});const{nodeId:e}=t,n=zd({...t,elements:{reference:null,floating:null,...t.elements}}),s=t.rootContext||n,r=s.elements,[o,i]=g.useState(null),[l,u]=g.useState(null),f=r?.domReference||o,c=g.useRef(null),m=xo();Ge(()=>{f&&(c.current=f)},[f]);const V=wa({...t,elements:{...r,...l&&{reference:l}}}),x=g.useCallback(y=>{const C=De(y)?{getBoundingClientRect:()=>y.getBoundingClientRect(),getClientRects:()=>y.getClientRects(),contextElement:y}:y;u(C),V.refs.setReference(C)},[V.refs]),p=g.useCallback(y=>{(De(y)||y===null)&&(c.current=y,i(y)),(De(V.refs.reference.current)||V.refs.reference.current===null||y!==null&&!De(y))&&V.refs.setReference(y)},[V.refs]),h=g.useMemo(()=>({...V.refs,setReference:p,setPositionReference:x,domReference:c}),[V.refs,p,x]),v=g.useMemo(()=>({...V.elements,domReference:f}),[V.elements,f]),b=g.useMemo(()=>({...V,...s,refs:h,elements:v,nodeId:e}),[V,h,v,e,s]);return Ge(()=>{s.dataRef.current.floatingContext=b;const y=m?.nodesRef.current.find(C=>C.id===e);y&&(y.context=b)}),g.useMemo(()=>({...V,context:b,refs:h,elements:v}),[V,h,v,b])}function Dn(t,e,n){const s=new Map,r=n==="item";let o=t;if(r&&t){const{[Bs]:i,[Us]:l,...u}=t;o=u}return{...n==="floating"&&{tabIndex:-1,[Cd]:""},...o,...e.map(i=>{const l=i?i[n]:null;return typeof l=="function"?t?l(t):null:l}).concat(t).reduce((i,l)=>(l&&Object.entries(l).forEach(u=>{let[d,f]=u;if(!(r&&[Bs,Us].includes(d)))if(d.indexOf("on")===0){if(s.has(d)||s.set(d,[]),typeof f=="function"){var c;(c=s.get(d))==null||c.push(f),i[d]=function(){for(var m,V=arguments.length,x=new Array(V),p=0;p<V;p++)x[p]=arguments[p];return(m=s.get(d))==null?void 0:m.map(h=>h(...x)).find(h=>h!==void 0)}}}else i[d]=f}),i),{})}}function Ud(t){t===void 0&&(t=[]);const e=t.map(l=>l?.reference),n=t.map(l=>l?.floating),s=t.map(l=>l?.item),r=g.useCallback(l=>Dn(l,t,"reference"),e),o=g.useCallback(l=>Dn(l,t,"floating"),n),i=g.useCallback(l=>Dn(l,t,"item"),s);return g.useMemo(()=>({getReferenceProps:r,getFloatingProps:o,getItemProps:i}),[r,o,i])}const Kd=new Map([["select","listbox"],["combobox","listbox"],["label",!1]]);function qd(t,e){var n,s;e===void 0&&(e={});const{open:r,elements:o,floatingId:i}=t,{enabled:l=!0,role:u="dialog"}=e,d=ls(),f=((n=o.domReference)==null?void 0:n.id)||d,c=g.useMemo(()=>{var b;return((b=pd(o.floating))==null?void 0:b.id)||i},[o.floating,i]),m=(s=Kd.get(u))!=null?s:u,x=go()!=null,p=g.useMemo(()=>m==="tooltip"||u==="label"?{["aria-"+(u==="label"?"labelledby":"describedby")]:r?c:void 0}:{"aria-expanded":r?"true":"false","aria-haspopup":m==="alertdialog"?"dialog":m,"aria-controls":r?c:void 0,...m==="listbox"&&{role:"combobox"},...m==="menu"&&{id:f},...m==="menu"&&x&&{role:"menuitem"},...u==="select"&&{"aria-autocomplete":"none"},...u==="combobox"&&{"aria-autocomplete":"list"}},[m,c,x,r,f,u]),h=g.useMemo(()=>{const b={id:c,...m&&{role:m}};return m==="tooltip"||u==="label"?b:{...b,...m==="menu"&&{"aria-labelledby":f}}},[m,c,f,u]),v=g.useCallback(b=>{let{active:y,selected:C}=b;const j={role:"option",...y&&{id:c+"-fui-option"}};switch(u){case"select":case"combobox":return{...j,"aria-selected":C}}return{}},[c,u]);return g.useMemo(()=>l?{reference:p,floating:h,item:v}:{},[l,p,h,v])}function Yd(t){var e;const{char:n,allowSpaces:s,allowToIncludeChar:r,allowedPrefixes:o,startOfLine:i,$position:l}=t,u=s&&!r,d=Ga(n),f=new RegExp(`\\s${d}$`),c=i?"^":"",m=r?"":d,V=u?new RegExp(`${c}${d}.*?(?=\\s${m}|$)`,"gm"):new RegExp(`${c}(?:^)?${d}[^\\s${m}]*`,"gm"),x=((e=l.nodeBefore)==null?void 0:e.isText)&&l.nodeBefore.text;if(!x)return null;const p=l.pos-x.length,h=Array.from(x.matchAll(V)).pop();if(!h||h.input===void 0||h.index===void 0)return null;const v=h.input.slice(Math.max(0,h.index-1),h.index),b=new RegExp(`^[${o?.join("")}\0]?$`).test(v);if(o!==null&&!b)return null;const y=p+h.index;let C=y+h[0].length;return u&&f.test(x.slice(C-1,C+1))&&(h[0]+=" ",C+=1),y<l.pos&&C>=l.pos?{range:{from:y,to:C},query:h[0].slice(n.length),text:h[0]}:null}var Qd=new Yt("suggestion");function Hd({pluginKey:t=Qd,editor:e,char:n="@",allowSpaces:s=!1,allowToIncludeChar:r=!1,allowedPrefixes:o=[" "],startOfLine:i=!1,decorationTag:l="span",decorationClass:u="suggestion",decorationContent:d="",decorationEmptyClass:f="is-empty",command:c=()=>null,items:m=()=>[],render:V=()=>({}),allow:x=()=>!0,findSuggestionMatch:p=Yd,shouldShow:h}){let v;const b=V?.(),y=()=>{const w=e.state.selection.$anchor.pos,S=e.view.coordsAtPos(w),{top:N,right:E,bottom:k,left:_}=S;try{return new DOMRect(_,N,E-_,k-N)}catch{return null}},C=(w,S)=>S?()=>{const N=t.getState(e.state),E=N?.decorationId,k=w.dom.querySelector(`[data-decoration-id="${E}"]`);return k?.getBoundingClientRect()||null}:y;function j(w,S){var N;try{const k=t.getState(w.state),_=k?.decorationId?w.dom.querySelector(`[data-decoration-id="${k.decorationId}"]`):null,D={editor:e,range:k?.range||{from:0,to:0},query:k?.query||null,text:k?.text||null,items:[],command:R=>c({editor:e,range:k?.range||{from:0,to:0},props:R}),decorationNode:_,clientRect:C(w,_)};(N=b?.onExit)==null||N.call(b,D)}catch{}const E=w.state.tr.setMeta(S,{exit:!0});w.dispatch(E)}const A=new yr({key:t,view(){return{update:async(w,S)=>{var N,E,k,_,D,R,P;const I=(N=this.key)==null?void 0:N.getState(S),T=(E=this.key)==null?void 0:E.getState(w.state),M=I.active&&T.active&&I.range.from!==T.range.from,L=!I.active&&T.active,U=I.active&&!T.active,$=!L&&!U&&I.query!==T.query,B=L||M&&$,q=$||M,Q=U||M&&$;if(!B&&!q&&!Q)return;const O=Q&&!B?I:T,z=w.dom.querySelector(`[data-decoration-id="${O.decorationId}"]`);v={editor:e,range:O.range,query:O.query,text:O.text,items:[],command:W=>c({editor:e,range:O.range,props:W}),decorationNode:z,clientRect:C(w,z)},B&&((k=b?.onBeforeStart)==null||k.call(b,v)),q&&((_=b?.onBeforeUpdate)==null||_.call(b,v)),(q||B)&&(v.items=await m({editor:e,query:O.query})),Q&&((D=b?.onExit)==null||D.call(b,v)),q&&((R=b?.onUpdate)==null||R.call(b,v)),B&&((P=b?.onStart)==null||P.call(b,v))},destroy:()=>{var w;v&&((w=b?.onExit)==null||w.call(b,v))}}},state:{init(){return{active:!1,range:{from:0,to:0},query:null,text:null,composing:!1}},apply(w,S,N,E){const{isEditable:k}=e,{composing:_}=e.view,{selection:D}=w,{empty:R,from:P}=D,I={...S},T=w.getMeta(t);if(T&&T.exit)return I.active=!1,I.decorationId=null,I.range={from:0,to:0},I.query=null,I.text=null,I;if(I.composing=_,k&&(R||e.view.composing)){(P<S.range.from||P>S.range.to)&&!_&&!S.composing&&(I.active=!1);const M=p({char:n,allowSpaces:s,allowToIncludeChar:r,allowedPrefixes:o,startOfLine:i,$position:D.$from}),L=`id_${Math.floor(Math.random()*4294967295)}`;M&&x({editor:e,state:E,range:M.range,isActive:S.active})&&(!h||h({editor:e,range:M.range,query:M.query,text:M.text,transaction:w}))?(I.active=!0,I.decorationId=S.decorationId?S.decorationId:L,I.range=M.range,I.query=M.query,I.text=M.text):I.active=!1}else I.active=!1;return I.active||(I.decorationId=null,I.range={from:0,to:0},I.query=null,I.text=null),I}},props:{handleKeyDown(w,S){var N,E,k,_;const{active:D,range:R}=A.getState(w.state);if(!D)return!1;if(S.key==="Escape"||S.key==="Esc"){const I=A.getState(w.state),T=(N=v?.decorationNode)!=null?N:null,M=T??(I?.decorationId?w.dom.querySelector(`[data-decoration-id="${I.decorationId}"]`):null);if(((E=b?.onKeyDown)==null?void 0:E.call(b,{view:w,event:S,range:I.range}))||!1)return!0;const U={editor:e,range:I.range,query:I.query,text:I.text,items:[],command:$=>c({editor:e,range:I.range,props:$}),decorationNode:M,clientRect:M?()=>M.getBoundingClientRect()||null:null};return(k=b?.onExit)==null||k.call(b,U),j(w,t),!0}return((_=b?.onKeyDown)==null?void 0:_.call(b,{view:w,event:S,range:R}))||!1},decorations(w){const{active:S,range:N,decorationId:E,query:k}=A.getState(w);if(!S)return null;const _=!k?.length,D=[u];return _&&D.push(f),Ha.create(w.doc,[Wa.inline(N.from,N.to,{nodeName:l,class:D.join(" "),"data-decoration-id":E,"data-decoration-content":d})])}}});return A}function Wd(t){const e=F.c(24),{editor:n,query:s,items:r,onSelect:o,onClose:i}=t,[l,u]=g.useState(0),d=g.useRef(r),f=g.useRef(l),c=g.useRef(o),m=g.useRef(i),V=g.useDeferredValue(s);let x;e[0]===Symbol.for("react.memo_cache_sentinel")?(x=()=>{u(0)},e[0]=x):x=e[0];let p;e[1]!==V?(p=[V],e[1]=V,e[2]=p):p=e[2],g.useEffect(x,p);let h,v;e[3]!==r.length||e[4]!==l?(h=()=>{l>=r.length&&r.length>0&&u(0)},v=[r.length,l],e[3]=r.length,e[4]=l,e[5]=h,e[6]=v):(h=e[5],v=e[6]),g.useEffect(h,v);let b,y;e[7]!==r?(b=()=>{d.current=r},y=[r],e[7]=r,e[8]=b,e[9]=y):(b=e[8],y=e[9]),g.useEffect(b,y);let C,j;e[10]!==l?(C=()=>{f.current=l},j=[l],e[10]=l,e[11]=C,e[12]=j):(C=e[11],j=e[12]),g.useEffect(C,j);let A,w;e[13]!==o?(w=()=>{c.current=o},A=[o],e[13]=o,e[14]=A,e[15]=w):(A=e[14],w=e[15]),g.useEffect(w,A);let S,N;e[16]!==i?(S=()=>{m.current=i},N=[i],e[16]=i,e[17]=S,e[18]=N):(S=e[17],N=e[18]),g.useEffect(S,N);let E,k;e[19]!==n?(E=()=>{if(n?.isDestroyed)return;let R;try{R=n.view.dom}catch{return}if(!R)return;const P=T=>{const M=d.current;if(!M.length)return!1;const L=()=>u($=>($+1)%M.length),U=()=>u($=>($-1+M.length)%M.length);switch(T.key){case"ArrowUp":return T.preventDefault(),U(),!0;case"ArrowDown":return T.preventDefault(),L(),!0;case"Tab":return T.preventDefault(),T.shiftKey?U():L(),!0;case"Home":return T.preventDefault(),u(0),!0;case"End":return T.preventDefault(),u(M.length-1),!0;case"Enter":{if(T.isComposing)return!1;T.preventDefault();const $=f.current;return $!==-1&&M[$]&&c.current?.(M[$],$),!0}case"Escape":return T.preventDefault(),m.current?.(),!0;default:return!1}},I=T=>{P(T)};return R.addEventListener("keydown",I,!0),()=>{R?.removeEventListener("keydown",I,!0)}},k=[n],e[19]=n,e[20]=E,e[21]=k):(E=e[20],k=e[21]),g.useEffect(E,k);const _=r.length?l:void 0;let D;return e[22]!==_?(D={selectedIndex:_,setSelectedIndex:u},e[22]=_,e[23]=D):D=e[23],D}function Gd(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 vo=g.createContext(void 0);function yo(){const t=g.useContext(vo);if(!t)throw new Error("useSuggestionContext must be used within a SuggestionContext.Provider");return t}function Xd({editor:t,char:e,pluginKey:n,allow:s,onOpenChange:r}){const[o,i]=g.useReducer(Gd,{open:!1,element:null,query:"",range:null,selectedItem:null}),l=g.useRef(r);return l.current=r,g.useEffect(()=>{if(t?.isDestroyed)return;const u=n instanceof Yt?n:new Yt(n);t.state.plugins.find(c=>c.spec.key===u)&&t.unregisterPlugin(u);const f=Hd({pluginKey:u,editor:t,char:e,allow(c){const m=t.state.doc.resolve(c.range.from);for(let V=m.depth;V>0;V--)if(m.node(V).type.name==="image")return!1;return!(s&&!s(c))},command(){},render:()=>({onStart:c=>{i({type:"ON_START",payload:{element:c.decorationNode??null,query:c.query,range:c.range}}),l.current?.(!0)},onUpdate:c=>{i({type:"ON_UPDATE",payload:{element:c.decorationNode??null,query:c.query,range:c.range}})},onKeyDown:c=>c.event.key==="Escape"?(i({type:"ON_EXIT"}),!0):!1,onExit:()=>{i({type:"ON_EXIT"}),l.current?.(!1)}}),items:()=>[]});return t.registerPlugin(f),()=>{t?.isDestroyed||t.unregisterPlugin(u)}},[t,n,e,i,s]),{state:o,dispatch:i}}function Jd({editor:t,queryKey:e,queryFn:n,onSelect:s}){const{state:r,dispatch:o}=yo(),i=g.useDeferredValue(r.query),{data:l}=Ra({queryKey:rt.suggestionItems(e,r.open,i),queryFn:()=>r.open?n({query:i}):[]}),u=()=>{o({type:"ON_EXIT"})},d=async(c,m)=>{if(!(r.selectedItem!==null||!r.range)){o({type:"SET_SELECTED_ITEM",payload:c});try{const{view:V}=t,p=V.state.selection.$to.nodeAfter?.text?.startsWith(" "),h=r.range?{...r.range}:{from:0,to:0};p&&r.range&&(h.to+=1),await s({range:h,item:c})===!1?o({type:"SET_SELECTED_ITEM",payload:null}):u()}catch{u()}}},{selectedIndex:f}=Wd({editor:t,query:i,items:l,onSelect:d,onClose:u});return{selectedItem:r.selectedItem,items:l,selectedIndex:f,close:u,onSelect:d}}function Zd({children:t}){const{state:e,dispatch:n}=yo(),{open:s,element:r}=e,o=()=>{n({type:"ON_EXIT"})},{refs:i,floatingStyles:l,context:u}=Bd({placement:"bottom-start",open:s,onOpenChange:m=>{m||o()},elements:{reference:r},middleware:[ka(10),Ea(),Ia()],whileElementsMounted:Da}),d=$d(u,{outsidePress:m=>!(m.target instanceof Element&&m.target.closest(".ProseMirror"))}),f=qd(u,{role:"listbox"}),{getFloatingProps:c}=Ud([d,f]);return s?a.jsx(Pd,{children:a.jsx("div",{ref:i.setFloating,style:l,...c(),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 ef=t=>{const e=F.c(29),{item:n,isSelected:s,onSelect:r,isLoading:o,ref:i}=t;let l;if(e[0]!==n){const A=Ke(n._meta);l=n.title||Gn(n.name,A),e[0]=n,e[1]=l}else l=e[1];const u=l,d=n.description||null,f=n.icon,c=s&&"bg-accent text-accent-foreground",m=o&&"pointer-events-none opacity-50";let V;e[2]!==c||e[3]!==m?(V=K("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",c,m),e[2]=c,e[3]=m,e[4]=V):V=e[4];let x;e[5]!==f||e[6]!==u?(x=f!==void 0&&a.jsx(jr,{icon:f,name:u,size:"xs",className:"mr-2"}),e[5]=f,e[6]=u,e[7]=x):x=e[7];let p;e[8]!==u?(p=a.jsx("span",{className:"font-medium flex items-center truncate capitalize",children:u}),e[8]=u,e[9]=p):p=e[9];let h;e[10]!==o?(h=o&&a.jsx(On,{size:"xs"}),e[10]=o,e[11]=h):h=e[11];let v;e[12]!==p||e[13]!==h?(v=a.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p,h]}),e[12]=p,e[13]=h,e[14]=v):v=e[14];let b;e[15]!==d?(b=d&&a.jsx("div",{className:"text-xs text-muted-foreground line-clamp-1",children:d}),e[15]=d,e[16]=b):b=e[16];let y;e[17]!==v||e[18]!==b?(y=a.jsxs("div",{className:"flex flex-col gap-0.5 flex-1 min-w-0",children:[v,b]}),e[17]=v,e[18]=b,e[19]=y):y=e[19];let C;e[20]!==n.drillable?(C=n.drillable&&a.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]=n.drillable,e[21]=C):C=e[21];let j;return e[22]!==r||e[23]!==i||e[24]!==y||e[25]!==C||e[26]!==V||e[27]!==x?(j=a.jsxs("div",{ref:i,onClick:r,className:V,children:[x,y,C]}),e[22]=r,e[23]=i,e[24]=y,e[25]=C,e[26]=V,e[27]=x,e[28]=j):j=e[28],j},tf=t=>{const e=F.c(18),{editor:n,queryKey:s,queryFn:r,onSelect:o}=t;let i;e[0]!==n||e[1]!==o||e[2]!==r||e[3]!==s?(i={editor:n,queryKey:s,queryFn:r,onSelect:o},e[0]=n,e[1]=o,e[2]=r,e[3]=s,e[4]=i):i=e[4];const{items:l,selectedIndex:u,onSelect:d,selectedItem:f}=Jd(i);if(!l.length){let x;return e[5]===Symbol.for("react.memo_cache_sentinel")?(x=a.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]=x):x=e[5],x}let c;e[6]===Symbol.for("react.memo_cache_sentinel")?(c={maxHeight:"min(320px, var(--radix-popover-content-available-height, 320px))"},e[6]=c):c=e[6];let m;if(e[7]!==d||e[8]!==l||e[9]!==u||e[10]!==f?.name){let x;e[12]!==d||e[13]!==u||e[14]!==f?.name?(x=(p,h)=>a.jsx(ef,{item:p,isSelected:h===u,ref:h===u?rf:void 0,onSelect:()=>d(p,h),isLoading:f?.name===p.name},`${p.kind??"item"}:${p.name}`),e[12]=d,e[13]=u,e[14]=f?.name,e[15]=x):x=e[15],m=l.map(x),e[7]=d,e[8]=l,e[9]=u,e[10]=f?.name,e[11]=m}else m=e[11];let V;return e[16]!==m?(V=a.jsx("div",{className:"min-w-[360px] max-w-[520px] bg-popover text-popover-foreground rounded-md overflow-y-auto",style:c,children:a.jsx("div",{className:"p-1",children:m})}),e[16]=m,e[17]=V):V=e[17],V};function nf(){const t=F.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=a.jsx("div",{className:"p-1",children:[...Array(3)].map(sf)}),t[0]=e):e=t[0],e}function sf(t,e){return a.jsxs("div",{className:"flex items-center gap-1.5 px-2 py-1.5 animate-pulse",children:[a.jsx("div",{className:"h-4 w-24 bg-muted rounded"}),a.jsx("div",{className:"h-3 w-32 bg-muted rounded"})]},e)}function wo(t){const e=F.c(18),{editor:n,char:s,pluginKey:r,queryKey:o,queryFn:i,onSelect:l,allow:u,onOpenChange:d}=t;let f;e[0]!==u||e[1]!==s||e[2]!==n||e[3]!==d||e[4]!==r?(f={editor:n,char:s,pluginKey:r,allow:u,onOpenChange:d},e[0]=u,e[1]=s,e[2]=n,e[3]=d,e[4]=r,e[5]=f):f=e[5];const{state:c,dispatch:m}=Xd(f);let V;e[6]!==m||e[7]!==c?(V={state:c,dispatch:m},e[6]=m,e[7]=c,e[8]=V):V=e[8];let x;e[9]===Symbol.for("react.memo_cache_sentinel")?(x=a.jsx(nf,{}),e[9]=x):x=e[9];let p;e[10]!==n||e[11]!==l||e[12]!==i||e[13]!==o?(p=a.jsx(Zd,{children:a.jsx(g.Suspense,{fallback:x,children:a.jsx(tf,{editor:n,queryKey:o,queryFn:i,onSelect:l})})}),e[10]=n,e[11]=l,e[12]=i,e[13]=o,e[14]=p):p=e[14];let h;return e[15]!==V||e[16]!==p?(h=a.jsx(vo.Provider,{value:V,children:p}),e[15]=V,e[16]=p,e[17]=h):h=e[17],h}function rf(t){t&&t.scrollIntoView({block:"center",behavior:"smooth"})}const of=[{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}],af=({editor:t,virtualMcpId:e})=>{const n=It(),{org:s}=Se(),r=Si(),o=Yi(r),i=dt({connectionId:e,orgId:s.id,orgSlug:s.slug}),l=rt.virtualMcpResources(e,s.id),[u,d]=g.useState("categories"),f=g.useRef(u);f.current=u;const c=g.useRef(null),m=g.useRef(!1),V=["at-mention",s.id,e??"default",u],x=async({item:v,range:b})=>{if(re("chat_picker_item_selected",{picker:"@",item_kind:v.kind,item_name:v.name}),v.kind!=="category"&&(m.current=!0),v.kind==="category")return d(v.name==="agents"?"agents":"resources"),!1;if(v.kind==="agent"&&v.agentId){it(t,b,{id:v.agentId,name:v.name,metadata:{agentId:v.agentId,title:v.name},char:"@"}),d("categories");return}if(v.kind==="resource"&&v.uri&&i){try{const y=await mr(i,v.uri);it(t,b,{id:v.uri,name:v.uri,metadata:y.contents,char:"@"})}catch(y){console.error("[at-mention] Failed to fetch resource:",y),fe.error("Failed to load resource. Please try again.")}d("categories");return}},p=async v=>{const{query:b}=v,y=f.current;if(y==="categories"){if(!b.trim())return of;const A=b.toLowerCase(),w=r.filter(N=>N.status==="active"&&(!N.id||!vs(N.id))&&!o.has(N.id)&&N.id!==e&&(N.title.toLowerCase().includes(A)||N.description?.toLowerCase().includes(A))).map(N=>({name:N.title,title:N.title,description:N.description??void 0,icon:N.icon??null,kind:"agent",agentId:N.id})),S=await(async()=>{if(!i)return[];let N=n.getQueryData(l);return N||(N=await n.fetchQuery({queryKey:l,queryFn:()=>wt(i),staleTime:6e4})),(N?.resources??[]).filter(E=>E.uri.toLowerCase().includes(A)||E.name?.toLowerCase().includes(A)||E.description?.toLowerCase().includes(A)).map(E=>({name:E.name??E.uri,title:E.name,description:E.description,kind:"resource",uri:E.uri}))})();return[...w,...S]}if(y==="agents"){let A=r.filter(w=>w.status==="active"&&(!w.id||!vs(w.id))&&!o.has(w.id)&&w.id!==e);if(b.trim()){const w=b.toLowerCase();A=A.filter(S=>S.title.toLowerCase().includes(w)||S.description?.toLowerCase().includes(w))}return A.map(w=>({name:w.title,title:w.title,description:w.description??void 0,icon:w.icon??null,kind:"agent",agentId:w.id}))}if(!i)return[];let C=n.getQueryData(l);C?n.fetchQuery({queryKey:l,queryFn:()=>wt(i),staleTime:6e4}).catch(()=>{}):C=await n.fetchQuery({queryKey:l,queryFn:()=>wt(i),staleTime:6e4});let j=C?.resources??[];if(b.trim()){const A=b.toLowerCase();j=j.filter(w=>w.uri.toLowerCase().includes(A)||w.name?.toLowerCase().includes(A)||w.description?.toLowerCase().includes(A))}return j.map(A=>({name:A.name??A.uri,title:A.name,description:A.description,kind:"resource",uri:A.uri}))},h=v=>{if(v)c.current=Date.now(),m.current=!1,re("chat_picker_opened",{picker:"@"});else{const b=c.current;re("chat_picker_closed",{picker:"@",outcome:m.current?"selected":"dismissed",duration_ms:b?Date.now()-b:null}),c.current=null,d("categories")}};return a.jsx(wo,{editor:t,char:"@",pluginKey:"atDropdownMenu",queryKey:V,queryFn:p,onSelect:x,onOpenChange:h})};async function Ws(t,e,n,s,r,o){try{const i=await fn(n,s,o);it(t,e,{id:s,name:on(s,r),metadata:i.messages,char:"/",kind:"prompt",args:o})}catch(i){console.error("[slash] Failed to fetch prompt:",i),fe.error("Failed to load prompt. Please try again.")}}async function lf(t,e,n,s){try{const r=await mr(n,s);it(t,e,{id:s,name:s,metadata:r.contents,char:"/",kind:"resource"})}catch(r){console.error("[slash] Failed to fetch resource:",r),fe.error("Failed to load resource. Please try again.")}}async function cf(t,e,n,s){try{const{files:r,omittedPaths:o}=await al(n,s.volume,s.path),i={sandboxPath:s.sandboxPath,files:r,omittedPaths:o};it(t,e,{id:s.id,name:s.name,metadata:i,char:"/",kind:"skill"})}catch(r){console.error("[slash] Failed to fetch skill:",r),fe.error("Failed to load skill. Please try again.")}}const uf=({editor:t,virtualMcpId:e})=>{const n=It(),{org:s}=Se(),r=dt({connectionId:e,orgId:s.id,orgSlug:s.slug}),o=rt.virtualMcpPrompts(e,s.id),i=rt.virtualMcpResources(e,s.id),l=rt.slashSkills(s.id),u=["slash-mention",s.id,e??"default"],[d,f]=g.useState(null),[c,m]=g.useState(null),V=Xa(t);V&&(V.onEditChip=async j=>{if(r)try{const w=(await Gs(n,o,r)).find(S=>S.name===j.promptId);if(!w?.arguments||w.arguments.length===0)return;m({...j,prompt:w})}catch(A){console.error("[slash] Failed to load prompt for editing:",A),fe.error("Failed to load prompt. Please try again.")}});const x=g.useRef(null),p=g.useRef(!1),h=async({item:j,range:A})=>{if(re("chat_picker_item_selected",{picker:"/",item_kind:j.kind,item_name:j.name}),p.current=!0,!!r)if(j.kind==="prompt"){if(j.arguments&&j.arguments.length>0){f({range:A,item:j});return}const w=Ke(j._meta);await Ws(t,A,r,j.name,w)}else j.kind==="skill"?j.skill&&await cf(t,A,s.slug,j.skill):j.uri&&await lf(t,A,r,j.uri)},v=async j=>{if(!d||!r)return;const{range:A,item:w}=d,S=Ke(w._meta);await Ws(t,A,r,w.name,S,j),f(null)},b=async j=>{if(!(!c||!r)){try{const A=await fn(r,c.promptId,j),w=Ke(c.prompt._meta);t.chain().focus().setNodeSelection(c.pos).deleteSelection().insertContentAt(c.pos,vr({id:c.promptId,name:on(c.promptId,w),metadata:A.messages,char:"/",kind:"prompt",args:j})).run(),re("chat_picker_item_selected",{picker:"/edit",item_kind:"prompt",item_name:c.promptId})}catch(A){console.error("[slash] Failed to update prompt:",A),fe.error("Failed to update prompt. Please try again.")}m(null)}},y=async j=>{const{query:A}=j;if(!r)return[];const[w,S,N]=await Promise.all([Gs(n,o,r),ff(n,i,r),df(n,l,s.slug)]),E=A.trim().toLowerCase(),k=(w??[]).filter(R=>!E||R.name.toLowerCase().includes(E)||R.title?.toLowerCase().includes(E)||R.description?.toLowerCase().includes(E)).map(R=>({name:R.name,title:R.title,description:R.description,kind:"prompt",arguments:R.arguments,_meta:R._meta})),_=(S??[]).filter(R=>!E||R.uri.toLowerCase().includes(E)||R.name?.toLowerCase().includes(E)||R.description?.toLowerCase().includes(E)).map(R=>({name:R.name??R.uri,title:R.name,description:R.description,kind:"resource",uri:R.uri})),D=(N??[]).filter(R=>!E||R.name.toLowerCase().includes(E)||R.id.toLowerCase().includes(E)||R.description?.toLowerCase().includes(E)).map(R=>({name:R.name,title:R.name,description:R.description??void 0,kind:"skill",skill:R}));return[...k,..._,...D]},C=d?.item.kind==="prompt"?{name:d.item.name,title:d.item.title,arguments:d.item.arguments,description:d.item.description,_meta:d.item._meta}:null;return a.jsxs(a.Fragment,{children:[a.jsx(wo,{editor:t,char:"/",pluginKey:"slashDropdownMenu",queryKey:u,queryFn:y,onSelect:h,onOpenChange:j=>{if(j)x.current=Date.now(),p.current=!1,re("chat_picker_opened",{picker:"/"});else{const A=x.current;re("chat_picker_closed",{picker:"/",outcome:p.current?"selected":"dismissed",duration_ms:A?Date.now()-A:null}),x.current=null}}}),a.jsx(qt,{prompt:C,setPrompt:()=>f(null),onSubmit:v}),a.jsx(qt,{prompt:c?.prompt??null,setPrompt:()=>m(null),onSubmit:b,defaultValues:c?.args},c?`edit-${c.promptId}-${c.pos}`:"edit-idle")]})};async function Gs(t,e,n){let s=t.getQueryData(e);return s?t.fetchQuery({queryKey:e,queryFn:()=>Fn(n),staleTime:6e4}).catch(()=>{}):s=await t.fetchQuery({queryKey:e,queryFn:()=>Fn(n),staleTime:6e4}),s?.prompts??[]}async function df(t,e,n){const s=t.getQueryData(e),r=()=>t.fetchQuery({queryKey:e,queryFn:()=>il(n),staleTime:6e4});return s?(r().catch(()=>{}),s):r().catch(()=>[])}async function ff(t,e,n){let s=t.getQueryData(e);return s?t.fetchQuery({queryKey:e,queryFn:()=>wt(n),staleTime:6e4}).catch(()=>{}):s=await t.fetchQuery({queryKey:e,queryFn:()=>wt(n),staleTime:6e4}),s?.resources??[]}function Vf(t){return[ni.configure({heading:!1,blockquote:!1,codeBlock:!1,horizontalRule:!1,dropcursor:!1}),Wu.configure({placeholder:()=>t.current??"Ask anything, / for prompts & skills, @ for agents & resources...",showOnlyWhenEditable:!1}),ei,ti]}function mf({tiptapDoc:t,setTiptapDoc:e,disabled:n=!1,enterToSubmit:s=!1,placeholder:r,onSubmit:o,children:i}){const l=g.useRef(o),u=g.useRef(e),d=g.useRef(s),f=g.useRef(r),c=Ja({extensions:Vf(f),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:(m,V)=>V.key==="Enter"&&!V.shiftKey&&d.current?(V.preventDefault(),l.current?.(),!0):!1},onUpdate:({editor:m})=>{u.current(m?.getJSON())}});return g.useEffect(()=>{c?.setEditable(!n)},[c,n]),g.useEffect(()=>{l.current=o},[o]),g.useEffect(()=>{u.current=e},[e]),g.useEffect(()=>{d.current=s},[s]),g.useEffect(()=>{f.current=r},[r]),g.useEffect(()=>{if(!c||c.isDestroyed)return;const m=JSON.stringify(c.getJSON()),V=JSON.stringify(t||{type:"doc",content:[]});m!==V&&c.commands.setContent(t||{type:"doc",content:[]})},[c,t]),a.jsx(Za.Provider,{value:{editor:c},children:i})}function pf(t){const e=F.c(26),{disabled:n,virtualMcpId:s,showFileUploader:r,selectedModel:o,onUnsupportedFile:i,ref:l,className:u}=t,d=n===void 0?!1:n,f=r===void 0?!1:r,{editor:c}=Xn();let m,V;if(e[0]!==c?(m=()=>({focus:()=>{c?.commands.focus()},clear:()=>{c?.commands.clearContent(!0)},appendText:S=>{if(!c)return;const N=c.state.doc.textContent.trim()==="";c.commands.focus("end"),N||c.commands.insertContent(" "),c.commands.insertContent(S)},syncVoiceText:(S,N)=>{if(c&&(c.commands.setContent(S||{type:"doc",content:[]}),N)){c.commands.focus("end");const E=c.state.doc.textContent.trim().length>0;c.commands.insertContent(E?" "+N:N)}},restoreContent:S=>{c&&c.commands.setContent(S||{type:"doc",content:[]})}}),V=[c],e[0]=c,e[1]=m,e[2]=V):(m=e[1],V=e[2]),g.useImperativeHandle(l??null,m,V),!c)return null;const x=d&&"cursor-not-allowed opacity-70",p=d&&"[&_.ProseMirror]:cursor-not-allowed";let h;e[3]!==u||e[4]!==x||e[5]!==p?(h=K("overflow-y-auto relative flex-1 max-h-[164px] min-h-[20px] w-full flex flex-col",u,"[&_.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",x,p),e[3]=u,e[4]=x,e[5]=p,e[6]=h):h=e[6];let v;e[7]!==c||e[8]!==h?(v=a.jsx(si,{editor:c,className:h}),e[7]=c,e[8]=h,e[9]=v):v=e[9];const b=s??null;let y;e[10]!==c||e[11]!==b?(y=a.jsx(g.Suspense,{fallback:null,children:a.jsx(uf,{editor:c,virtualMcpId:b})}),e[10]=c,e[11]=b,e[12]=y):y=e[12];const C=s??null;let j;e[13]!==c||e[14]!==C?(j=a.jsx(g.Suspense,{fallback:null,children:a.jsx(af,{editor:c,virtualMcpId:C})}),e[13]=c,e[14]=C,e[15]=j):j=e[15];let A;e[16]!==c||e[17]!==i||e[18]!==o||e[19]!==f?(A=f&&o?a.jsx(Uu,{editor:c,selectedModel:o,onUnsupportedFile:i}):null,e[16]=c,e[17]=i,e[18]=o,e[19]=f,e[20]=A):A=e[20];let w;return e[21]!==y||e[22]!==j||e[23]!==A||e[24]!==v?(w=a.jsxs(a.Fragment,{children:[v,y,j,A]}),e[21]=y,e[22]=j,e[23]=A,e[24]=v,e[25]=w):w=e[25],w}function Ao(t){const e=F.c(3),[n]=lt();let s;return e[0]!==n.enableSounds||e[1]!==t?(s=()=>{n.enableSounds&&gl(t.dataUri).catch(o=>{console.warn(`[sound] ${t.name} playback failed:`,o)})},e[0]=n.enableSounds,e[1]=t,e[2]=s):s=e[2],s}const hf={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"},gf=wi.togglePlanMode.keys.map(t=>t==="Shift"?"⇧":t).join(""),xf=[{src:"/connections/gmail.png",name:"Gmail"},{src:"/connections/perplexity.png",name:"Perplexity"},{src:"/connections/github.png",name:"GitHub"}];function bf(){const t=F.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=a.jsx("div",{className:"flex items-center -space-x-1.5",children:xf.map(vf)}),t[0]=e):e=t[0],e}function vf(t){return a.jsx("img",{src:t.src,alt:t.name,className:"size-5 rounded-sm ring-1 ring-border object-cover bg-white"},t.name)}function yf({disabled:t,onOpenConnections:e,virtualMcpId:n,selectedModel:s,isStreaming:r,onUnsupportedFile:o}){const[i,l]=g.useState(!1),u=Ao(hf),{org:d}=Se(),{editor:f}=Xn(),c=g.useRef(null),m=pn(s),V=()=>{!m||r||(l(!1),c.current?.click())},x=async O=>{const z=O.target.files;if(!z||z.length===0||!f)return;const W=Array.from(z),{from:H}=f.state.selection;try{for(const X of W)await is(f,s??null,X,H,o)}finally{c.current&&(c.current.value="")}},p=dt({connectionId:n,orgId:d.id,orgSlug:d.slug}),h=rt.virtualMcpPrompts(n,d.id),{data:v,isLoading:b}=Ta({queryKey:h,queryFn:()=>Fn(p),staleTime:6e4,enabled:i&&!!p}),y=v?.prompts??[],[C,j]=g.useState(null),{chatMode:A,setChatMode:w}=Ye(),[S,N]=lt(),k=(vt.find(O=>O.value===S.toolApprovalLevel)??vt[0]).short,_=O=>{const z=vt.find(W=>W.value===O);if(z){if(z.value===S.toolApprovalLevel){l(!1);return}u(),re("chat_approval_level_changed",{from_level:S.toolApprovalLevel,to_level:z.value,source:"tools_popover"}),N({...S,toolApprovalLevel:z.value}),l(!1)}},D=A==="plan",R=()=>{u();const O=D?"default":"plan";re("chat_mode_changed",{from_mode:A,to_mode:O,source:"tools_popover"}),w(O),l(!1)},P=()=>{e(),l(!1)},I=async(O,z)=>{if(!f||!p)return;const W=Ke(O._meta),H={from:f.state.selection.from,to:f.state.selection.to};try{const X=await fn(p,O.name,z);it(f,H,{id:O.name,name:on(O.name,W),metadata:X.messages,char:"/",kind:"prompt",args:z})}catch{fe.error("Failed to load prompt. Please try again.")}},T=async O=>{l(!1);const z=!!(O.arguments&&O.arguments.length>0);if(re("chat_prompt_inserted",{prompt_name:O.name,with_arguments:z}),z){j(O);return}await I(O)},M=async O=>{C&&(await I(C,O),j(null))},L=()=>{u();const O=A==="gen-image"?"default":"gen-image";re("chat_mode_changed",{from_mode:A,to_mode:O,source:"tools_popover"}),w(O),l(!1)},U=()=>{u();const O=A==="web-search"?"default":"web-search";re("chat_mode_changed",{from_mode:A,to_mode:O,source:"tools_popover"}),w(O),l(!1)},$=()=>{u();const O=A==="deep-research"?"default":"deep-research";re("chat_mode_changed",{from_mode:A,to_mode:O,source:"tools_popover"}),w(O),l(!1)},B=A==="gen-image",q=A==="web-search",Q=A==="deep-research";return a.jsxs(a.Fragment,{children:[a.jsx("input",{ref:c,type:"file",multiple:!0,accept:Xi(s??null),className:"hidden",onChange:x,disabled:r}),a.jsxs(fl,{open:i,onOpenChange:O=>{O&&!i&&re("chat_tools_popover_opened",{chat_mode:A}),l(O)},children:[a.jsx(Vl,{asChild:!0,children:a.jsxs(ae,{type:"button",variant:"ghost",size:"default",disabled:t,title:"Tools","aria-label":"Tools",className:K("text-muted-foreground hover:text-foreground transition-[gap] duration-200 shrink min-w-0","gap-0 @[320px]/chat-bottom:gap-1.5"),children:[a.jsx(Ii,{size:14}),a.jsx("span",{className:K("min-w-0 truncate transition-[max-width,opacity] duration-200 ease-out max-w-0 opacity-0","@[320px]/chat-bottom:max-w-24 @[320px]/chat-bottom:opacity-100"),children:"Tools"})]})}),a.jsxs(ml,{align:"start",className:"w-52 p-1.5 space-y-1",children:[m?a.jsxs(Be,{onClick:V,disabled:r,children:[a.jsx(js,{size:16}),a.jsx("span",{className:"flex-1",children:"Add file"})]}):a.jsxs(We,{children:[a.jsx(Qe,{asChild:!0,children:a.jsxs(Be,{"aria-disabled":"true",className:"opacity-50 cursor-not-allowed",onSelect:O=>O.preventDefault(),children:[a.jsx(js,{size:16}),a.jsx("span",{className:"flex-1",children:"Add file"})]})}),a.jsx(He,{side:"right",children:"The selected model does not support reading files or images."})]}),a.jsxs(Be,{onClick:R,className:K(D&&"text-violet-600 dark:text-violet-400"),children:[a.jsx(wr,{size:16,className:K(D&&"text-violet-500")}),a.jsx("span",{className:"flex-1",children:"Plan mode"}),a.jsx("span",{className:K("text-xs text-muted-foreground",D&&"text-violet-500 font-medium"),children:gf})]}),a.jsxs(Be,{onClick:L,className:K(B&&"text-pink-600 dark:text-pink-400"),children:[a.jsx(Sr,{size:16,className:K(B&&"text-pink-500")}),a.jsx("span",{className:"flex-1",children:"Create image"}),B&&a.jsx("span",{className:"text-xs text-pink-500 font-medium",children:"On"})]}),a.jsxs(Be,{onClick:U,className:K(q&&"text-blue-600 dark:text-blue-400"),children:[a.jsx(Ar,{size:16,className:K(q&&"text-blue-500")}),a.jsx("span",{className:"flex-1",children:"Web search"}),q&&a.jsx("span",{className:"text-xs text-blue-500 font-medium",children:"On"})]}),a.jsxs(Be,{onClick:$,className:K(Q&&"text-blue-600 dark:text-blue-400"),children:[a.jsx(Nr,{size:16,className:K(Q&&"text-blue-500")}),a.jsx("span",{className:"flex-1",children:"Deep research"}),Q&&a.jsx("span",{className:"text-xs text-blue-500 font-medium",children:"On"})]}),a.jsxs(As,{children:[a.jsxs(Ss,{className:"gap-2",children:[a.jsx("span",{className:"flex size-4 items-center justify-center text-base font-medium text-muted-foreground",children:"/"}),a.jsx("span",{className:"flex-1",children:"Prompts"})]}),a.jsx(Cs,{className:"w-80 max-h-72 overflow-y-auto p-1.5",children:b?a.jsxs("div",{className:"flex items-center gap-2 px-2 py-3 text-sm text-muted-foreground",children:[a.jsx(_a,{size:14,className:"animate-spin"}),"Loading prompts…"]}):y.length===0?a.jsx("div",{className:"px-2 py-3 text-sm text-muted-foreground",children:"No prompts available"}):y.map(O=>a.jsxs(Be,{onClick:()=>T(O),className:"flex flex-col items-start gap-0.5",children:[a.jsx("span",{className:"font-medium text-sm capitalize",children:O.title||Gn(O.name,Ke(O._meta))}),O.description&&a.jsx("span",{className:"text-xs text-muted-foreground line-clamp-2",children:O.description})]},O.name))})]}),a.jsxs(As,{children:[a.jsxs(Ss,{className:"gap-2",children:[a.jsx(mn,{size:16}),a.jsx("span",{className:"flex-1",children:"Approval"}),a.jsx("span",{className:"text-xs text-muted-foreground",children:k})]}),a.jsx(Cs,{className:"w-48 p-1.5",children:a.jsx(pl,{value:S.toolApprovalLevel,onValueChange:_,children:vt.map(O=>a.jsx(hl,{value:O.value,children:O.label},O.value))})})]}),a.jsxs(Be,{onClick:P,children:[a.jsx(Bi,{size:16}),a.jsx("span",{className:"flex-1",children:"Connections"}),a.jsx(g.Suspense,{children:a.jsx(bf,{})})]})]})]}),a.jsx(qt,{prompt:C,setPrompt:j,onSubmit:M})]})}const wf=[{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 Af(){const t=F.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=a.jsx("div",{className:"flex items-center -space-x-1",children:wf.map(Sf)}),t[0]=e):e=t[0],e}function Sf(t){return a.jsx("img",{src:t.src,alt:t.name,className:"size-5 rounded-sm ring-2 ring-muted object-cover bg-white"},t.name)}function Cf(t){const e=F.c(6),{onClick:n}=t;let s,r,o,i;e[0]===Symbol.for("react.memo_cache_sentinel")?(s=K("group relative z-10 flex items-center gap-3 w-full px-4 py-3","rounded-b-2xl","cursor-pointer"),r=a.jsx("p",{className:"flex-1 text-xs text-muted-foreground truncate text-left",children:"Connect tools and get more done"}),o=a.jsx(Af,{}),i=a.jsx(bl,{size:14,className:"shrink-0 text-muted-foreground/60 group-hover:text-muted-foreground transition-colors"}),e[0]=s,e[1]=r,e[2]=o,e[3]=i):(s=e[0],r=e[1],o=e[2],i=e[3]);let l;return e[4]!==n?(l=a.jsxs("button",{type:"button",onClick:n,className:s,children:[r,o,i]}),e[4]=n,e[5]=l):l=e[5],l}const yt=48;function jf(){const t=F.c(9),[e,n]=g.useState("idle"),[s,r]=g.useState(""),[o,i]=g.useState(""),[l,u]=g.useState(kf),d=g.useRef(null),f=g.useRef(null),c=g.useRef(null),m=g.useRef(null),V=g.useRef(0),x=g.useRef(!1),p=g.useRef(""),h=g.useRef(""),v=typeof window<"u"&&!!(window.SpeechRecognition||window.webkitSpeechRecognition);let b;t[0]===Symbol.for("react.memo_cache_sentinel")?(b=()=>{V.current&&(cancelAnimationFrame(V.current),V.current=0),f.current?.close().catch(Rf),m.current?.getTracks().forEach(Nf),c.current=null,f.current=null,m.current=null},t[0]=b):b=t[0];const y=b;let C;if(t[1]===Symbol.for("react.memo_cache_sentinel")){const k=_=>{m.current=_;const D=new AudioContext;f.current=D;const R=D.createMediaStreamSource(_),P=D.createAnalyser();P.fftSize=128,P.smoothingTimeConstant=.8,R.connect(P),c.current=P;const I=new Uint8Array(P.frequencyBinCount),T=()=>{if(!c.current)return;c.current.getByteFrequencyData(I);const M=[];for(let L=0;L<yt;L++){const U=Math.floor(L/yt*I.length);M.push(Math.max(.04,(I[U]??0)/255))}u(M),V.current=requestAnimationFrame(T)};T()};C=async()=>{const _=window.SpeechRecognition||window.webkitSpeechRecognition;if(!_){n("unsupported");return}let D;try{D=await navigator.mediaDevices.getUserMedia({audio:!0})}catch{n("permission-denied");return}r(""),i(""),h.current="",p.current="",x.current=!0,n("recording"),k(D);const R=new _;d.current=R,R.interimResults=!0,R.continuous=!0,R.lang=navigator.language||"en-US",R.onresult=P=>{let I="",T="";for(let M=P.resultIndex;M<P.results.length;M++){const L=P.results[M],U=L?.[0]?.transcript??"";L?.isFinal?T=T+U:I=I+U}T&&(p.current=p.current+T,r(p.current)),h.current=I,i(I)},R.onend=()=>{if(x.current)try{R.start()}catch{}};try{R.start()}catch{n("idle")}},t[1]=C}else C=t[1];const j=C;let A;t[2]===Symbol.for("react.memo_cache_sentinel")?(A=()=>{x.current=!1,d.current?.stop(),y(),n("idle"),u(Array(yt).fill(.05)),i("");const k=(p.current+(h.current?" "+h.current:"")).trim();return r(""),p.current="",h.current="",k},t[2]=A):A=t[2];const w=A;let S;t[3]===Symbol.for("react.memo_cache_sentinel")?(S=()=>{x.current=!1,d.current?.abort(),y(),n("idle"),r(""),i(""),u(Array(yt).fill(.05)),p.current="",h.current=""},t[3]=S):S=t[3];const N=S;let E;return t[4]!==o||t[5]!==e||t[6]!==s||t[7]!==l?(E={status:e,transcript:s,interimTranscript:o,waveformData:l,isSupported:v,startRecording:j,stopRecording:w,cancelRecording:N},t[4]=o,t[5]=e,t[6]=s,t[7]=l,t[8]=E):E=t[8],E}function Nf(t){return t.stop()}function Rf(){}function kf(){return Array(yt).fill(.05)}function Ef(t){const e=F.c(4),{data:n}=t;let s;e[0]!==n?(s=n.map(If),e[0]=n,e[1]=s):s=e[1];let r;return e[2]!==s?(r=a.jsx("div",{className:"flex items-center justify-center gap-[2px] h-10 overflow-hidden","aria-hidden":"true",children:s}),e[2]=s,e[3]=r):r=e[3],r}function If(t,e){return a.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)}function Df({messageCount:t,showConnectionsBanner:e}){return t>0||e}function Tf(t){return t.hasDraft?"send":t.isStreaming||t.isRunInProgress?"stop":"disabled"}function _f(t){const e=F.c(3),{message:n}=t;let s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s=a.jsx(pr,{size:14,className:"shrink-0"}),e[0]=s):s=e[0];let r;return e[1]!==n?(r=a.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:[s,a.jsx("span",{className:"text-sm",children:n})]}),e[1]=n,e[2]=r):r=e[2],r}function Mf(t,e){const n=F.c(5),{editor:s}=Xn(),[r,o]=g.useState(!1),i=g.useRef(0);let l,u;return n[0]!==s||n[1]!==e||n[2]!==t?(l=()=>{const d=V=>{V.dataTransfer?.types.includes("Files")&&(V.preventDefault(),i.current=i.current+1,o(!0))},f=V=>{V.preventDefault(),i.current=Math.max(0,i.current-1),i.current===0&&o(!1)},c=Pf,m=V=>{if(V.preventDefault(),i.current=0,o(!1),!s||!t||!pn(t))return;const x=V.dataTransfer?.files;if(!x||x.length===0)return;const{from:p}=s.state.selection;for(const h of Array.from(x))is(s,t,h,p,e)};return window.addEventListener("dragenter",d),window.addEventListener("dragleave",f),window.addEventListener("dragover",c),window.addEventListener("drop",m),()=>{window.removeEventListener("dragenter",d),window.removeEventListener("dragleave",f),window.removeEventListener("dragover",c),window.removeEventListener("drop",m)}},u=[s,t,e],n[0]=s,n[1]=e,n[2]=t,n[3]=l,n[4]=u):(l=n[3],u=n[4]),g.useEffect(l,u),r}function Pf(t){t.dataTransfer?.types.includes("Files")&&t.preventDefault()}function Of(t){const e=F.c(11),{selectedModel:n,onUnsupportedFile:s}=t,r=Mf(n,s);let o;e[0]!==n?(o=pn(n),e[0]=n,e[1]=o):o=e[1];const i=o,l=r?"opacity-100":"opacity-0 pointer-events-none",u=i?"border-primary/40 text-primary/70":"border-destructive/30 text-destructive/70";let d;e[2]!==l||e[3]!==u?(d=K("absolute inset-0 z-20 rounded-xl flex flex-col items-center justify-center gap-2 bg-muted border-2 border-dashed transition-opacity",l,u),e[2]=l,e[3]=u,e[4]=d):d=e[4];let f;e[5]!==n||e[6]!==i?(f=i?a.jsxs(a.Fragment,{children:[a.jsx(_i,{size:24}),a.jsxs("span",{className:"text-sm font-medium",children:["Drop ",Fr(n)," here"]})]}):a.jsxs(a.Fragment,{children:[a.jsx(pr,{size:24}),a.jsx("span",{className:"text-sm font-medium",children:"This model can't read attachments — switch to one with vision or file support"})]}),e[5]=n,e[6]=i,e[7]=f):f=e[7];let c;return e[8]!==d||e[9]!==f?(c=a.jsx("div",{className:d,children:f}),e[8]=d,e[9]=f,e[10]=c):c=e[10],c}function Lf(){const t=F.c(6),e=ct(),{org:n,locator:s}=Se(),{create:r}=bi();let o;return t[0]!==r||t[1]!==s||t[2]!==e||t[3]!==n.id||t[4]!==n.slug?(o=async i=>{const{tiptapDoc:l,virtualMcp:u}=i,d=crypto.randomUUID(),f=u?.id??dn(n.id).id;vi(sessionStorage,s,d,{tiptapDoc:l});try{await r({id:d,virtual_mcp_id:f})}catch{}const c={virtualmcpid:f,autosend:yi};e({to:"/$org/$taskId",params:{org:n.slug,taskId:d},search:c})},t[0]=r,t[1]=s,t[2]=e,t[3]=n.id,t[4]=n.slug,t[5]=o):o=t[5],o}function Ff({onOpenContextPanel:t,showConnectionsBanner:e=!1}){const n=br(),s=rn(),r=n?.messages??[],o=n?.isStreaming??!1,i=n?.isRunInProgress??!1,l=n?.stop??(()=>{}),u=s?.taskId??"",d=u||Kl,f=Lf(),{selectedModel:c,selectedVirtualMcp:m,isModelsLoading:V,tiptapDocRef:x,imageModel:p,webSearchModel:h,deepResearchModel:v,chatMode:b,setChatMode:y}=Ye(),{data:C}=fr.useSession(),j=C?.user?.id,{org:A,locator:w}=Se(),S=dn(A.id).id,N=Ci(m?.id??S),E=Ao(xl),[k,_]=g.useState(!1),{unsupportedFile:D,onUnsupportedFile:R,clearUnsupportedFile:P}=Hu(),I=jf(),T=g.useRef(void 0),M=async()=>{T.current=B,await I.startRecording();const ee=I.status==="recording"?"started":I.status==="unsupported"?"unsupported":I.status==="permission-denied"?"permission_denied":"unknown";re("chat_voice_started",{thread_id:u,outcome:ee})},L=()=>{re("chat_voice_confirmed",{thread_id:u});const ee=I.stopRecording();H.current?.syncVoiceText(T.current,ee),H.current?.focus()},U=()=>{re("chat_voice_cancelled",{thread_id:u}),I.cancelRecording(),H.current?.restoreContent(T.current)};g.useEffect(()=>{if(I.status!=="recording")return;const ee=(I.transcript+(I.interimTranscript?" "+I.interimTranscript:"")).trim();H.current?.syncVoiceText(T.current,ee)},[I.transcript,I.interimTranscript,I.status]);const $=s?.activeTask??null,[B,q]=g.useState(()=>ks(sessionStorage,w,d)??void 0),Q=ee=>{q(ee),x.current=ee,Yl(sessionStorage,w,d,ee,{onQuotaExceeded:({docSizeBytes:ce})=>{re("chat_draft_quota_exceeded",{thread_id:u||null,doc_size_bytes:ce}),console.warn("[chat-draft] sessionStorage quota exceeded; draft not saved")}})},O=g.useRef(u);if(O.current!==u){O.current=u;const ee=ks(sessionStorage,w,d)??void 0;q(ee),x.current=ee}const W=[...r].reverse().find(ee=>ee.role==="assistant")?.metadata?.modelLimits?.contextWindow??c?.limits?.contextWindow,H=g.useRef(null),X=b==="plan";g.useEffect(()=>{const ee=ce=>{Ai(ce)&&ce.code==="KeyL"&&(ce.preventDefault(),ce.shiftKey&&y(b==="plan"?"default":"plan"),H.current?.focus())};return document.addEventListener("keydown",ee),()=>document.removeEventListener("keydown",ee)},[b,y]);const Y=ri(r),J=[...r].reverse().find(ee=>ee.role==="assistant"&&ee.metadata?.usage)?.metadata?.usage?.contextTokens??0,ne=!V&&!Qr(B),G=Tf({hasDraft:ne,isStreaming:o,isRunInProgress:i}),oe=G==="send",Z=G==="stop",pe=Df({messageCount:r.length,showConnectionsBanner:e}),ve=ee=>{if(ee?.preventDefault(),G==="send"&&B){if(re("chat_message_sent",{thread_id:u||null,mode:b,model_id:c?.modelId??null,model_provider:c?.providerId??null,virtual_mcp_id:m?.id??null,submission:ee?"button_or_enter":"programmatic"}),n){if(n.isSendInFlight()){fe.info("Still sending your previous message — try again in a moment");return}n.sendMessage(B)}else f({tiptapDoc:B,virtualMcp:m});Ql(sessionStorage,w,d),Q(void 0)}else G==="stop"&&(re("chat_message_stopped",{thread_id:u}),l())};return j&&$?.created_by&&$.created_by!==j?a.jsx(_f,{message:"Read only - you're viewing someone else's thread"}):a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"flex flex-col w-full justify-end",children:a.jsxs("div",{className:"relative rounded-2xl w-full flex flex-col",children:[e&&a.jsx("div",{className:"absolute inset-0 rounded-2xl pointer-events-none bg-muted/50"}),n&&s&&a.jsx(hn,{}),n&&s&&u?a.jsx(Yc,{taskId:u}):null,a.jsx(mf,{tiptapDoc:B,setTiptapDoc:Q,disabled:!1,enterToSubmit:!0,onSubmit:ve,children:a.jsxs("form",{onSubmit:ve,className:K("w-full relative rounded-2xl min-h-[110px] md:min-h-[130px] flex flex-col bg-card dark:bg-muted card-shadow overflow-hidden"),children:[a.jsx(Of,{selectedModel:c,onUnsupportedFile:R}),a.jsx("div",{className:"group/input relative flex flex-col gap-2 flex-1",children:a.jsx(pf,{ref:H,disabled:I.status==="recording",virtualMcpId:m?.id??S,showFileUploader:!0,selectedModel:c,onUnsupportedFile:R})}),a.jsx("div",{className:"@container/chat-bottom flex items-center justify-between p-2.5 gap-1",children:I.status==="recording"?a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"flex-1"}),a.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[a.jsx(Ef,{data:I.waveformData.slice(0,28)}),a.jsx("button",{type:"button",onClick:U,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:a.jsx(tt,{size:16})}),a.jsx("button",{type:"button",onClick:L,className:"flex items-center justify-center size-8 rounded-lg bg-foreground text-background hover:opacity-80 transition-opacity","aria-label":"Use transcription",children:a.jsx(Dt,{size:16})})]})]}):a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[a.jsx(yf,{disabled:!1,onOpenConnections:()=>{re("connections_dialog_opened",{source:"tools_popover",mode:"add"}),_(!0)},virtualMcpId:m?.id??S,selectedModel:c,isStreaming:o,onUnsupportedFile:R}),X&&a.jsxs("button",{type:"button",onClick:()=>{E(),re("chat_mode_changed",{from_mode:"plan",to_mode:"default",source:"pill_dismiss"}),y("default")},title:"Plan mode","aria-label":"Plan mode",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 min-w-0 shrink animate-in fade-in duration-200",children:[a.jsx(wr,{size:14,className:"shrink-0"}),a.jsx("span",{className:"min-w-0 truncate transition-[max-width,opacity] duration-200 ease-out max-w-0 opacity-0 @[320px]/chat-bottom:max-w-32 @[320px]/chat-bottom:opacity-100",children:"Plan mode"}),a.jsx(tt,{size:14,className:"shrink-0 hidden group-hover:block group-disabled:hidden"})]}),b==="gen-image"&&p&&a.jsxs("button",{type:"button",onClick:()=>{E(),re("chat_mode_changed",{from_mode:"gen-image",to_mode:"default",source:"pill_dismiss"}),y("default")},title:"Create image","aria-label":"Create image",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 min-w-0 shrink animate-in fade-in duration-200 disabled:opacity-50 disabled:cursor-not-allowed disabled:hover:bg-transparent",children:[a.jsx(Sr,{size:14,className:"shrink-0"}),a.jsx("span",{className:"min-w-0 truncate transition-[max-width,opacity] duration-200 ease-out max-w-0 opacity-0 @[320px]/chat-bottom:max-w-[120px] @[320px]/chat-bottom:opacity-100",children:"Create image"}),a.jsx(tt,{size:14,className:"shrink-0 hidden group-hover:block group-disabled:hidden"})]}),b==="web-search"&&h&&a.jsxs("button",{type:"button",onClick:()=>{E(),re("chat_mode_changed",{from_mode:"web-search",to_mode:"default",source:"pill_dismiss"}),y("default")},title:"Web search","aria-label":"Web search",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 min-w-0 shrink animate-in fade-in duration-200 disabled:opacity-50 disabled:cursor-not-allowed disabled:hover:bg-transparent",children:[a.jsx(Ar,{size:14,className:"shrink-0"}),a.jsx("span",{className:"min-w-0 truncate transition-[max-width,opacity] duration-200 ease-out max-w-0 opacity-0 @[320px]/chat-bottom:max-w-[120px] @[320px]/chat-bottom:opacity-100",children:"Web search"}),a.jsx(tt,{size:14,className:"shrink-0 hidden group-hover:block group-disabled:hidden"})]}),b==="deep-research"&&v&&a.jsxs("button",{type:"button",onClick:()=>{E(),re("chat_mode_changed",{from_mode:"deep-research",to_mode:"default",source:"pill_dismiss"}),y("default")},title:"Deep research","aria-label":"Deep research",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 min-w-0 shrink animate-in fade-in duration-200 disabled:opacity-50 disabled:cursor-not-allowed disabled:hover:bg-transparent",children:[a.jsx(Nr,{size:14,className:"shrink-0"}),a.jsx("span",{className:"min-w-0 truncate transition-[max-width,opacity] duration-200 ease-out max-w-0 opacity-0 @[320px]/chat-bottom:max-w-[120px] @[320px]/chat-bottom:opacity-100",children:"Deep research"}),a.jsx(tt,{size:14,className:"shrink-0 hidden group-hover:block group-disabled:hidden"})]}),W&&J>0&&a.jsx(oi,{usage:Y,totalTokens:J,contextWindow:W,onOpenContextPanel:t})]}),a.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[pe&&a.jsx(Lu,{virtualMcp:N,currentBranch:s?.currentBranch??null}),a.jsx(Bu,{}),I.isSupported&&a.jsx(ae,{type:"button",onClick:M,disabled:!1,variant:"ghost",size:"icon",className:K("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:a.jsx(Di,{size:18})}),a.jsx(ae,{type:Z?"button":"submit",onClick:ee=>{Z&&(ee.preventDefault(),ee.stopPropagation(),l())},variant:oe||Z?"default":"ghost",size:"icon",disabled:!oe&&!Z,className:K("size-8 rounded-lg transition-all",!oe&&!Z&&"bg-muted text-muted-foreground hover:bg-muted hover:text-muted-foreground cursor-not-allowed"),title:G==="stop"?o?"Stop generating":"Cancel run":"Send message (Enter)",children:Z?a.jsx(Ti,{size:20}):a.jsx(hr,{size:20})})]})]})})]})},u),e&&a.jsx(Cf,{onClick:()=>{re("connections_banner_clicked",{source:"home_chat_input"}),re("connections_dialog_opened",{source:"home_banner",mode:"add"}),_(!0)}})]})}),a.jsx(Qi,{mode:"browse",open:k,onOpenChange:_,defaultTab:"all"}),a.jsx(Yu,{info:D,onClose:P})]})}const $f={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 So(t){return`deco-credits-empty-dismissed:${t}`}function Pp(t){try{return localStorage.getItem(So(t))==="1"}catch{return!1}}function zf(){const t=F.c(47),{org:e}=Se(),n=ct(),{decoKeyId:s}=_r(),r=Mr(),[o,i]=g.useState(!0),[l,u]=g.useState(""),[d,f]=g.useState(!1),[c,m]=g.useState("usd"),V=c==="brl"?"R$":"$";let x;t[0]!==e.id?(x=()=>{re("credits_empty_state_dismissed",{organization_id:e.id}),i(!1);try{localStorage.setItem(So(e.id),"1")}catch{}},t[0]=e.id,t[1]=x):x=t[1];const p=x;let h,v;t[2]!==o||t[3]!==e.id?(h=()=>{o&&re("credits_empty_state_shown",{organization_id:e.id})},v=[o,e.id],t[2]=o,t[3]=e.id,t[4]=h,t[5]=v):(h=t[4],v=t[5]),g.useEffect(h,v);let b;t[6]!==c||t[7]!==r?(b=async $=>{const{url:B}=await r.call("AI_PROVIDER_TOPUP_URL",{providerId:"deco",amountCents:$,currency:c});return B},t[6]=c,t[7]=r,t[8]=b):b=t[8];let y;t[9]!==p?(y=$=>{$&&window.open($,"_blank","noopener,noreferrer"),p()},t[9]=p,t[10]=y):y=t[10];let C;t[11]!==b||t[12]!==y?(C={mutationFn:b,onSuccess:y,onError:Uf},t[11]=b,t[12]=y,t[13]=C):C=t[13];const{mutate:j,isPending:A}=Wn(C),w=parseFloat(l),S=!isNaN(w)&&w>=1;if(!o)return null;let N;t[14]!==p?(N=$=>!$&&p(),t[14]=p,t[15]=N):N=t[15];let E;t[16]===Symbol.for("react.memo_cache_sentinel")?(E=a.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[16]=E):E=t[16];let k;t[17]===Symbol.for("react.memo_cache_sentinel")?(k=a.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:a.jsx(Rr,{size:20,className:"text-amber-600 dark:text-amber-400"})}),t[17]=k):k=t[17];let _;t[18]===Symbol.for("react.memo_cache_sentinel")?(_=a.jsxs("div",{className:"relative px-6 pt-7 pb-5",children:[E,a.jsxs(an,{className:"relative gap-3",children:[k,a.jsxs("div",{className:"text-center",children:[a.jsx(ln,{className:"text-lg font-semibold",children:"This workspace has no credits"}),a.jsx(Jn,{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[18]=_):_=t[18];let D;t[19]!==c||t[20]!==V||t[21]!==l||t[22]!==w||t[23]!==s||t[24]!==S||t[25]!==A||t[26]!==d||t[27]!==j?(D=s&&a.jsxs("div",{className:"px-6 pb-5",children:[a.jsx("div",{className:"mb-4",children:a.jsxs(Dr,{type:"single",variant:"outline",size:"sm",value:c,onValueChange:$=>{$&&m($)},children:[a.jsx(Qt,{value:"usd",className:"h-8 px-3 text-xs",children:"USD"}),a.jsx(Qt,{value:"brl",className:"h-8 px-3 text-xs",children:"BRL"})]})}),a.jsx("div",{className:"grid grid-cols-3 gap-2.5",children:$f[c].map($=>{const{dollars:B,label:q}=$;return a.jsxs("button",{type:"button",disabled:A,onClick:()=>{re("credits_topup_clicked",{amount_cents:B*100,currency:c,tier_label:q,source:"empty_state"}),j(B*100)},className:K("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:[a.jsxs("span",{className:"text-2xl font-semibold tabular-nums text-foreground",children:[V,B]}),a.jsx("span",{className:"text-xs text-muted-foreground",children:q})]},B)})}),d?a.jsxs("div",{className:"flex gap-2 mt-3",children:[a.jsxs("div",{className:"relative flex-1",children:[a.jsx("span",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-sm text-muted-foreground select-none",children:V}),a.jsx(Tr,{type:"number",min:"1",step:"1",placeholder:"50",value:l,onChange:$=>u($.target.value),className:"h-10 text-sm pl-7",autoFocus:!0})]}),a.jsx(ae,{className:"h-10",disabled:!S||A,onClick:()=>{re("credits_topup_clicked",{amount_cents:Math.round(w*100),currency:c,tier_label:"custom",source:"empty_state"}),j(Math.round(w*100))},children:A?"Opening...":"Add"})]}):a.jsx("button",{type:"button",className:"w-full mt-2.5 text-xs text-muted-foreground hover:text-foreground transition-colors py-1",onClick:()=>f(!0),children:"Enter custom amount"})]}),t[19]=c,t[20]=V,t[21]=l,t[22]=w,t[23]=s,t[24]=S,t[25]=A,t[26]=d,t[27]=j,t[28]=D):D=t[28];let R;t[29]!==p||t[30]!==n||t[31]!==e.slug?(R=()=>{n({to:"/$org/settings/ai-providers",params:{org:e.slug}}),p()},t[29]=p,t[30]=n,t[31]=e.slug,t[32]=R):R=t[32];let P;t[33]===Symbol.for("react.memo_cache_sentinel")?(P=a.jsx(Ir,{size:12,className:"transition-transform duration-150 group-hover:translate-x-0.5"}),t[33]=P):P=t[33];let I;t[34]!==R?(I=a.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",P]}),t[34]=R,t[35]=I):I=t[35];let T;t[36]!==p?(T=a.jsx(ae,{variant:"ghost",size:"sm",className:"text-xs text-muted-foreground",onClick:p,children:"Skip for now"}),t[36]=p,t[37]=T):T=t[37];let M;t[38]!==I||t[39]!==T?(M=a.jsxs("div",{className:"px-6 py-3.5 border-t border-border bg-muted/30 flex items-center justify-between",children:[I,T]}),t[38]=I,t[39]=T,t[40]=M):M=t[40];let L;t[41]!==D||t[42]!==M?(L=a.jsxs(cn,{className:"sm:max-w-[500px] gap-0 p-0 overflow-hidden",onOpenAutoFocus:Bf,children:[_,D,M]}),t[41]=D,t[42]=M,t[43]=L):L=t[43];let U;return t[44]!==L||t[45]!==N?(U=a.jsx(un,{open:!0,onOpenChange:N,children:L}),t[44]=L,t[45]=N,t[46]=U):U=t[46],U}function Bf(t){return t.preventDefault()}function Uf(t){fe.error(`Top-up failed: ${t.message}`)}function Kf(t){const e=F.c(6),{balanceDollars:n}=t;let s;e[0]!==n?(s=n.toFixed(2),e[0]=n,e[1]=s):s=e[1];const r=s;let o,i;e[2]===Symbol.for("react.memo_cache_sentinel")?(o=K("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"),i=a.jsx(Rr,{size:13,className:"text-emerald-600 dark:text-emerald-400"}),e[2]=o,e[3]=i):(o=e[2],i=e[3]);let l;return e[4]!==r?(l=a.jsxs("div",{className:o,children:[i,a.jsxs("span",{className:"text-xs font-medium text-emerald-700 dark:text-emerald-300 tabular-nums",children:["$",r," in credits to get started"]})]}),e[4]=r,e[5]=l):l=e[5],l}function qf(){const t=F.c(8),{org:e}=Se(),n=ct();let s;t[0]!==n||t[1]!==e.slug?(s=()=>n({to:"/$org/settings/ai-providers",params:{org:e.slug}}),t[0]=n,t[1]=e.slug,t[2]=s):s=t[2];let r,o,i;t[3]===Symbol.for("react.memo_cache_sentinel")?(r=K("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=a.jsx(kr,{size:13,className:"text-amber-600 dark:text-amber-400"}),i=a.jsx("span",{className:"text-xs font-medium text-amber-700 dark:text-amber-300",children:"No credits remaining · Add more"}),t[3]=r,t[4]=o,t[5]=i):(r=t[3],o=t[4],i=t[5]);let l;return t[6]!==s?(l=a.jsxs("button",{type:"button",onClick:s,className:r,children:[o,i]}),t[6]=s,t[7]=l):l=t[7],l}function Yf(t){const e=F.c(11),{className:n}=t;let s;e[0]!==n?(s=K("flex h-full w-full flex-col bg-background",n),e[0]=n,e[1]=s):s=e[1];let r;e[2]===Symbol.for("react.memo_cache_sentinel")?(r=a.jsx("div",{className:"size-6 rounded-lg bg-muted animate-pulse"}),e[2]=r):r=e[2];let o;e[3]===Symbol.for("react.memo_cache_sentinel")?(o=a.jsxs("div",{className:"flex items-center gap-3",children:[r,a.jsxs("div",{className:"flex flex-col gap-2",children:[a.jsx("div",{className:"h-3.5 w-28 rounded bg-muted animate-pulse"}),a.jsx("div",{className:"h-3 w-40 rounded bg-muted/60 animate-pulse"})]})]}),e[3]=o):o=e[3];let i;e[4]===Symbol.for("react.memo_cache_sentinel")?(i=a.jsx("div",{className:"flex items-center h-12 flex-none border-b border-border/80 px-4",children:a.jsxs("div",{className:"flex items-center justify-between gap-3 w-full",children:[o,a.jsxs("div",{className:"flex items-end gap-2",children:[a.jsx("div",{className:"h-6 w-6 rounded-full bg-muted animate-pulse"}),a.jsx("div",{className:"h-6 w-6 rounded-lg bg-muted animate-pulse"})]})]})}),e[4]=i):i=e[4];let l;e[5]===Symbol.for("react.memo_cache_sentinel")?(l=a.jsx("div",{className:"flex-1 overflow-hidden px-4 py-4",children:a.jsxs("div",{className:"mx-auto flex w-full max-w-2xl flex-col gap-4",children:[a.jsx(Lt,{align:"right",width:"w-3/4"}),a.jsx(Lt,{align:"left",width:"w-full",lines:3}),a.jsx(Lt,{align:"right",width:"w-2/3"}),a.jsx(Lt,{align:"left",width:"w-5/6",lines:2})]})}),e[5]=l):l=e[5];let u;e[6]===Symbol.for("react.memo_cache_sentinel")?(u=a.jsx("div",{className:"relative flex flex-1 flex-col gap-2 p-2.5",children:a.jsx("div",{className:"relative flex-1",children:a.jsxs("div",{className:"space-y-2 p-2",children:[a.jsx("div",{className:"h-3 w-full rounded bg-muted/40 animate-pulse"}),a.jsx("div",{className:"h-3 w-4/5 rounded bg-muted/40 animate-pulse"})]})})}),e[6]=u):u=e[6];let d;e[7]===Symbol.for("react.memo_cache_sentinel")?(d=a.jsx("div",{className:"flex items-center gap-1",children:a.jsx("div",{className:"size-8 rounded-full bg-muted/60 animate-pulse"})}),e[7]=d):d=e[7];let f;e[8]===Symbol.for("react.memo_cache_sentinel")?(f=a.jsx("div",{className:"px-4 py-4",children:a.jsx("div",{className:"mx-auto w-full max-w-2xl",children:a.jsxs("div",{className:"relative flex min-h-[130px] flex-col rounded-xl bg-background card-shadow",children:[u,a.jsxs("div",{className:"flex items-center justify-between px-2.5 pb-2.5",children:[d,a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsx("div",{className:"h-8 w-32 rounded-lg bg-muted/60 animate-pulse"}),a.jsx("div",{className:"size-8 rounded-full bg-muted animate-pulse"})]})]})]})})}),e[8]=f):f=e[8];let c;return e[9]!==s?(c=a.jsxs("div",{className:s,children:[i,l,f]}),e[9]=s,e[10]=c):c=e[10],c}function Lt(t){const e=F.c(22),{align:n,width:s,lines:r}=t,o=s===void 0?"w-full":s,i=r===void 0?1:r,l=n==="right"?"flex-row-reverse":"flex-row";let u;e[0]!==l?(u=K("flex w-full gap-4 px-4 py-2",l),e[0]=l,e[1]=u):u=e[1];const d=n==="right"?"ml-auto max-w-3/4 items-end":"w-full items-start";let f;e[2]!==d?(f=K("flex min-w-0 flex-col gap-2",d),e[2]=d,e[3]=f):f=e[3];let c;e[4]===Symbol.for("react.memo_cache_sentinel")?(c=a.jsx("div",{className:"h-3 w-16 rounded bg-muted/40 animate-pulse"}),e[4]=c):c=e[4];const m=n==="right"?"bg-muted":"bg-transparent border border-border/40";let V;e[5]!==m||e[6]!==o?(V=K("min-w-0 rounded-2xl p-4",m,o),e[5]=m,e[6]=o,e[7]=V):V=e[7];let x;e[8]!==i?(x=Array.from({length:i}),e[8]=i,e[9]=x):x=e[9];let p;e[10]!==i||e[11]!==x?(p=a.jsx("div",{className:"space-y-2",children:x.map((y,C)=>a.jsx("div",{className:K("h-3 rounded bg-muted-foreground/20 animate-pulse",C===i-1?"w-3/4":"w-full"),style:{animationDelay:`${C*.1}s`}},C))}),e[10]=i,e[11]=x,e[12]=p):p=e[12];let h;e[13]!==p||e[14]!==V?(h=a.jsx("div",{className:V,children:p}),e[13]=p,e[14]=V,e[15]=h):h=e[15];let v;e[16]!==h||e[17]!==f?(v=a.jsxs("div",{className:f,children:[c,h]}),e[16]=h,e[17]=f,e[18]=v):v=e[18];let b;return e[19]!==v||e[20]!==u?(b=a.jsx("div",{className:u,children:v}),e[19]=v,e[20]=u,e[21]=b):b=e[21],b}function Qf(t){const e=F.c(7),{scrollRef:n,sentinelRef:s,hasMoreOlder:r,isFetchingOlder:o,fetchOlderMessages:i}=t;let l,u;e[0]!==i||e[1]!==r||e[2]!==o||e[3]!==n||e[4]!==s?(l=()=>{const d=s.current,f=n.current;if(!d||!f||!r)return;const c=new IntersectionObserver(async m=>{if(!m[0]?.isIntersecting||o||!r)return;const x=f.scrollHeight,p=f.scrollTop;await i(),requestAnimationFrame(()=>{const h=f.scrollHeight;f.scrollTop=p+(h-x)})},{root:f,rootMargin:"200px 0px 0px 0px"});return c.observe(d),()=>c.disconnect()},u=[n,s,r,o,i],e[0]=i,e[1]=r,e[2]=o,e[3]=n,e[4]=s,e[5]=l,e[6]=u):(l=e[5],u=e[6]),g.useEffect(l,u)}function Hf(t){const e=F.c(5),{className:n,children:s}=t;let r;e[0]!==n?(r=K("flex flex-col h-full w-full bg-background transform-[translateZ(0)]",n),e[0]=n,e[1]=r):r=e[1];let o;return e[2]!==s||e[3]!==r?(o=a.jsx("div",{className:r,children:s}),e[2]=s,e[3]=r,e[4]=o):o=e[4],o}function Wf(t){const e=F.c(5),{children:n,className:s}=t;let r;e[0]!==s?(r=K("flex-1 min-h-0 overflow-y-auto isolate",s),e[0]=s,e[1]=r):r=e[1];let o;return e[2]!==n||e[3]!==r?(o=a.jsx("div",{className:r,children:n}),e[2]=n,e[3]=r,e[4]=o):o=e[4],o}function Gf(t){const e=F.c(2),{children:n}=t;let s;return e[0]!==n?(s=a.jsx("div",{className:"min-h-full shrink-0 w-full flex items-center justify-center max-w-2xl mx-auto py-10",children:n}),e[0]=n,e[1]=s):s=e[1],s}function Xf(){const{messages:t,status:e,hasMoreOlder:n,isFetchingOlder:s,fetchOlderMessages:r}=ut(),{taskId:o}=gr(),i=xr(o??""),l=Ba(i),u=l.size===0?t:t.filter(v=>!l.has(v.id)),d=ai(u),f=d.at(-1),m=Ul()*Il+16,V=g.useRef(null),x=g.useRef(null);Qf({scrollRef:V,sentinelRef:x,hasMoreOlder:n,isFetchingOlder:s,fetchOlderMessages:r});const p=ii({initial:!1}),h=v=>{V.current=v,p.scrollRef(v)};return a.jsx(li,{messages:t,children:a.jsxs("div",{className:"relative h-full w-full min-w-0",children:[a.jsx("div",{ref:h,"data-chat-scroller":!0,className:"w-full min-w-0 max-w-full overflow-y-auto h-full [container-type:size]",style:{paddingBottom:m},children:a.jsxs("div",{ref:p.contentRef,className:"overflow-x-clip",children:[a.jsxs("div",{className:"flex flex-col min-w-0 max-w-2xl mx-auto w-full",children:[a.jsx("div",{ref:x,"aria-hidden":!0,className:"h-px"}),s&&a.jsx("div",{className:"flex items-center justify-center py-3 text-xs text-muted-foreground",children:"Loading older messages…"}),d.slice(0,-1).map((v,b)=>a.jsx(bs,{pair:v,isLastPair:!1,status:b===d.length-1?e:void 0},`pair-${v.user?.id??v.assistant?.id}`))]}),f&&a.jsx("div",{className:"min-h-[100cqh] min-w-0 max-w-2xl mx-auto w-full",children:a.jsx(bs,{pair:f,isLastPair:!0,status:e},`pair-${f.user?.id??f.assistant?.id}`)})]})}),!p.isAtBottom&&a.jsx(ae,{type:"button",variant:"outline",size:"icon-sm","aria-label":"Jump to latest",className:"absolute left-1/2 z-50 -translate-x-1/2 rounded-full shadow-md animate-in fade-in duration-200 dark:bg-background dark:hover:bg-accent",style:{bottom:m+8},onClick:()=>{p.scrollToBottom()},children:a.jsx(Ma,{size:14})})]})})}function Jf(t){const e=F.c(5),{children:n,className:s}=t;let r;e[0]!==s?(r=K("flex-none w-full mx-auto p-2 pt-0","max-w-2xl min-w-0",s),e[0]=s,e[1]=r):r=e[1];let o;return e[2]!==n||e[3]!==r?(o=a.jsx("div",{className:r,children:n}),e[2]=n,e[3]=r,e[4]=o):o=e[4],o}const Op=Object.assign(Hf,{Main:Wf,Messages:Xf,EmptyState:Gf,Footer:Jf,Input:Ff,Provider:za,ActiveTaskProvider:$a,Skeleton:Yf,IceBreakers:El,NoAiProviderEmptyState:Ji,CreditsEmptyState:zf,CreditsEyebrow:Kf,NoCreditsEyebrow:qf,CreditsExhaustedBanner:so});function Zf(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return g.useMemo(()=>s=>{e.forEach(r=>r(s))},e)}const gn=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function ft(t){const e=Object.prototype.toString.call(t);return e==="[object Window]"||e==="[object global]"}function us(t){return"nodeType"in t}function he(t){var e,n;return t?ft(t)?t:us(t)&&(e=(n=t.ownerDocument)==null?void 0:n.defaultView)!=null?e:window:window}function ds(t){const{Document:e}=he(t);return t instanceof e}function Tt(t){return ft(t)?!1:t instanceof he(t).HTMLElement}function Co(t){return t instanceof he(t).SVGElement}function Vt(t){return t?ft(t)?t.document:us(t)?ds(t)?t:Tt(t)||Co(t)?t.ownerDocument:document:document:document}const Re=gn?g.useLayoutEffect:g.useEffect;function xn(t){const e=g.useRef(t);return Re(()=>{e.current=t}),g.useCallback(function(){for(var n=arguments.length,s=new Array(n),r=0;r<n;r++)s[r]=arguments[r];return e.current==null?void 0:e.current(...s)},[])}function eV(){const t=g.useRef(null),e=g.useCallback((s,r)=>{t.current=setInterval(s,r)},[]),n=g.useCallback(()=>{t.current!==null&&(clearInterval(t.current),t.current=null)},[]);return[e,n]}function Rt(t,e){e===void 0&&(e=[t]);const n=g.useRef(t);return Re(()=>{n.current!==t&&(n.current=t)},e),n}function _t(t,e){const n=g.useRef();return g.useMemo(()=>{const s=t(n.current);return n.current=s,s},[...e])}function Jt(t){const e=xn(t),n=g.useRef(null),s=g.useCallback(r=>{r!==n.current&&e?.(r,n.current),n.current=r},[]);return[n,s]}function Zt(t){const e=g.useRef();return g.useEffect(()=>{e.current=t},[t]),e.current}let Tn={};function Mt(t,e){return g.useMemo(()=>{if(e)return e;const n=Tn[t]==null?0:Tn[t]+1;return Tn[t]=n,t+"-"+n},[t,e])}function jo(t){return function(e){for(var n=arguments.length,s=new Array(n>1?n-1:0),r=1;r<n;r++)s[r-1]=arguments[r];return s.reduce((o,i)=>{const l=Object.entries(i);for(const[u,d]of l){const f=o[u];f!=null&&(o[u]=f+t*d)}return o},{...e})}}const ot=jo(1),kt=jo(-1);function tV(t){return"clientX"in t&&"clientY"in t}function bn(t){if(!t)return!1;const{KeyboardEvent:e}=he(t.target);return e&&t instanceof e}function nV(t){if(!t)return!1;const{TouchEvent:e}=he(t.target);return e&&t instanceof e}function en(t){if(nV(t)){if(t.touches&&t.touches.length){const{clientX:e,clientY:n}=t.touches[0];return{x:e,y:n}}else if(t.changedTouches&&t.changedTouches.length){const{clientX:e,clientY:n}=t.changedTouches[0];return{x:e,y:n}}}return tV(t)?{x:t.clientX,y:t.clientY}:null}const Xe=Object.freeze({Translate:{toString(t){if(!t)return;const{x:e,y:n}=t;return"translate3d("+(e?Math.round(e):0)+"px, "+(n?Math.round(n):0)+"px, 0)"}},Scale:{toString(t){if(!t)return;const{scaleX:e,scaleY:n}=t;return"scaleX("+e+") scaleY("+n+")"}},Transform:{toString(t){if(t)return[Xe.Translate.toString(t),Xe.Scale.toString(t)].join(" ")}},Transition:{toString(t){let{property:e,duration:n,easing:s}=t;return e+" "+n+"ms "+s}}}),Xs="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function sV(t){return t.matches(Xs)?t:t.querySelector(Xs)}const rV={display:"none"};function oV(t){let{id:e,value:n}=t;return le.createElement("div",{id:e,style:rV},n)}function aV(t){let{id:e,announcement:n,ariaLiveType:s="assertive"}=t;const r={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 le.createElement("div",{id:e,style:r,role:"status","aria-live":s,"aria-atomic":!0},n)}function iV(){const[t,e]=g.useState("");return{announce:g.useCallback(s=>{s!=null&&e(s)},[]),announcement:t}}const No=g.createContext(null);function lV(t){const e=g.useContext(No);g.useEffect(()=>{if(!e)throw new Error("useDndMonitor must be used within a children of <DndContext>");return e(t)},[t,e])}function cV(){const[t]=g.useState(()=>new Set),e=g.useCallback(s=>(t.add(s),()=>t.delete(s)),[t]);return[g.useCallback(s=>{let{type:r,event:o}=s;t.forEach(i=>{var l;return(l=i[r])==null?void 0:l.call(i,o)})},[t]),e]}const uV={draggable:`
4
4
  To pick up a draggable item, press the space bar.