decocms 2.446.0 → 2.447.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (230) hide show
  1. package/dist/client/assets/{AlertCircle-BgvyaAL6.js → AlertCircle-UbTrvmD8.js} +1 -1
  2. package/dist/client/assets/{ArrowUpRight-DrDPl1ww.js → ArrowUpRight-B-ghXq-_.js} +1 -1
  3. package/dist/client/assets/{Check-CpRgfX9v.js → Check-BWHZM20T.js} +1 -1
  4. package/dist/client/assets/{CheckCircle-B-pzErM9.js → CheckCircle-B6zciJm5.js} +1 -1
  5. package/dist/client/assets/{ChevronDown-Ck0kXXoi.js → ChevronDown-kizgpVbD.js} +1 -1
  6. package/dist/client/assets/{ChevronRight-C3-N31UD.js → ChevronRight-BHYJ3DEJ.js} +1 -1
  7. package/dist/client/assets/{ChevronUp-C1pNLnkX.js → ChevronUp-BtOuA1iC.js} +1 -1
  8. package/dist/client/assets/{Container-DtKKcYj1.js → Container-BkW3IR6n.js} +1 -1
  9. package/dist/client/assets/{DotsVertical-Dn-9kvPV.js → DotsVertical-B11N4XoI.js} +1 -1
  10. package/dist/client/assets/{Eye-L6l6QAVo.js → Eye-Bphw4qHW.js} +1 -1
  11. package/dist/client/assets/{FilterLines-vdidQTPZ.js → FilterLines-DOb8W880.js} +1 -1
  12. package/dist/client/assets/{Globe01-CmgkLjDA.js → Globe01-CU4shpSp.js} +1 -1
  13. package/dist/client/assets/{HardDrive-dDTShpdM.js → HardDrive-DSbDltiF.js} +1 -1
  14. package/dist/client/assets/{Key01-B4ofXTQm.js → Key01-zwhddqN8.js} +1 -1
  15. package/dist/client/assets/{LinkExternal01-WHe1S-E-.js → LinkExternal01-mlC9GXBP.js} +1 -1
  16. package/dist/client/assets/{Monitor01-FD67jx2m.js → Monitor01-BhL9ynh2.js} +1 -1
  17. package/dist/client/assets/{Palette-TC1tDkop.js → Palette-BuARXF-n.js} +1 -1
  18. package/dist/client/assets/{Play-C7Rue8fn.js → Play-DnwFxesH.js} +1 -1
  19. package/dist/client/assets/{Plus-DRIZd-2-.js → Plus-DapGfte9.js} +1 -1
  20. package/dist/client/assets/{RefreshCcw01-DpdZ9gm0.js → RefreshCcw01-42um-ufT.js} +1 -1
  21. package/dist/client/assets/{SearchMd-DShTT603.js → SearchMd-TUFumYUu.js} +1 -1
  22. package/dist/client/assets/{Settings02-MTx-k3S7.js → Settings02-B-7DoxYa.js} +1 -1
  23. package/dist/client/assets/{Shield01-BY4aDf21.js → Shield01-B58oeqIu.js} +1 -1
  24. package/dist/client/assets/{Star01-CDtvsxxe.js → Star01-Dj-yDvPD.js} +1 -1
  25. package/dist/client/assets/{Stars01-DzPa7_Zo.js → Stars01-DWP5CW8V.js} +1 -1
  26. package/dist/client/assets/{Stars02-UcqCQViA.js → Stars02-wLN6gYts.js} +1 -1
  27. package/dist/client/assets/{Sun-CFQIVViJ.js → Sun-DWOvfsiD.js} +1 -1
  28. package/dist/client/assets/{SwitchHorizontal01-B5oRfzWe.js → SwitchHorizontal01-8QRqIEQi.js} +1 -1
  29. package/dist/client/assets/{Tool01-4hNK4hhF.js → Tool01-9pPVu4xE.js} +1 -1
  30. package/dist/client/assets/{Trash01-Cd-TfU52.js → Trash01-C0uYWTct.js} +1 -1
  31. package/dist/client/assets/{Upload01-CODWkN2q.js → Upload01-mCrnkIKe.js} +1 -1
  32. package/dist/client/assets/{User01-gLhirg6x.js → User01-CN1cs4oO.js} +1 -1
  33. package/dist/client/assets/{Users01-DBWJec2Z.js → Users01-DEQxorlz.js} +1 -1
  34. package/dist/client/assets/{Users03-DrS1ThY-.js → Users03-CtHK3VTc.js} +1 -1
  35. package/dist/client/assets/{X-CzsiH5k2.js → X-BZIbRbas.js} +1 -1
  36. package/dist/client/assets/{XCircle-Btwiite7.js → XCircle-B_F-Nqsp.js} +1 -1
  37. package/dist/client/assets/{XClose-CtxwJX4P.js → XClose-gXcEWNUe.js} +1 -1
  38. package/dist/client/assets/{Zap-BT8r4Lfd.js → Zap-tFcxuoCY.js} +1 -1
  39. package/dist/client/assets/{ZapSquare-Alh3PeLr.js → ZapSquare-NM_4Hwrb.js} +1 -1
  40. package/dist/client/assets/ZoomOut-BShhdOnU.js +1 -0
  41. package/dist/client/assets/{access-gate-49AfiPid.js → access-gate-DSZtmJDO.js} +1 -1
  42. package/dist/client/assets/accordion-DwmTgXcH.js +1 -0
  43. package/dist/client/assets/{add-section-modal-BtCHVJdb.js → add-section-modal-I6U_0tzj.js} +1 -1
  44. package/dist/client/assets/{agent-capabilities-C1-nbsvP.js → agent-capabilities-BZuIDzdU.js} +1 -1
  45. package/dist/client/assets/agent-icon-B2kRhhvG.js +1 -0
  46. package/dist/client/assets/{agent-icons-VjS4qMx-.js → agent-icons-BEGVE6W-.js} +1 -1
  47. package/dist/client/assets/{agents-list-D59xaU6q.js → agents-list-BQqOdPYt.js} +1 -1
  48. package/dist/client/assets/{ai-providers-CjYWh7Ls.js → ai-providers-d8mlAFx2.js} +1 -1
  49. package/dist/client/assets/{alert-Deb5bKEP.js → alert-Obv-lLcu.js} +1 -1
  50. package/dist/client/assets/{alert-dialog-DRN5w-t8.js → alert-dialog-BNZF3kxZ.js} +1 -1
  51. package/dist/client/assets/app-editor-HtmK2stv.js +1 -0
  52. package/dist/client/assets/{auth-catchall-CB8huQUw.js → auth-catchall-BGtKEgHG.js} +1 -1
  53. package/dist/client/assets/{auth-split-layout-BvbFzAmT.js → auth-split-layout-DUOwgeDw.js} +1 -1
  54. package/dist/client/assets/{automation-list-row-74P8727s.js → automation-list-row-BjbqZnyx.js} +1 -1
  55. package/dist/client/assets/{automation-runs-C2k5umHE.js → automation-runs-CzaQvRkF.js} +1 -1
  56. package/dist/client/assets/{automations-CNCforTN.js → automations-CkbSceOA.js} +1 -1
  57. package/dist/client/assets/{avatar-BBV4QWEL.js → avatar-DqZBDcop.js} +1 -1
  58. package/dist/client/assets/{badge-BSpskrOH.js → badge-CFfIdhIE.js} +1 -1
  59. package/dist/client/assets/{brand-context-BSsu5ufV.js → brand-context-Do7Zsmm4.js} +1 -1
  60. package/dist/client/assets/{buckets-DObQcpCj.js → buckets-DUCTXQQ1.js} +1 -1
  61. package/dist/client/assets/{calendar-DUjAE_4N.js → calendar-CTrPS9iI.js} +1 -1
  62. package/dist/client/assets/{capability-load-error-YdVG6orY.js → capability-load-error-BNd5YqZc.js} +1 -1
  63. package/dist/client/assets/{card-DZwqn9tD.js → card-CyFdQD4G.js} +1 -1
  64. package/dist/client/assets/{chat-context-B2M4P5Ss.js → chat-context-BStm3zgD.js} +1 -1
  65. package/dist/client/assets/{checkbox-DVXfLKtH.js → checkbox-CnZ6PrCw.js} +1 -1
  66. package/dist/client/assets/{cli-auth-success-DWli23rz.js → cli-auth-success-CHliRY1X.js} +1 -1
  67. package/dist/client/assets/{collection-detail-7NZ-47Sk.js → collection-detail-CKmsmb2-.js} +1 -1
  68. package/dist/client/assets/{collection-display-button-BEtadCaE.js → collection-display-button-Bya9i5My.js} +1 -1
  69. package/dist/client/assets/{collection-search-CpScI8eY.js → collection-search-BX0jLWGA.js} +1 -1
  70. package/dist/client/assets/{collection-table-wrapper-6C_ptY1o.js → collection-table-wrapper-CgXWOHT6.js} +1 -1
  71. package/dist/client/assets/{collection-tabs-cISZZwXw.js → collection-tabs-DMGO-5kZ.js} +1 -1
  72. package/dist/client/assets/{collections-B9feqlnI.js → collections-C0702JvT.js} +1 -1
  73. package/dist/client/assets/{command-BJzE5xdm.js → command-DUxz0k_8.js} +1 -1
  74. package/dist/client/assets/{connect-desktop-dialog-5wbrfqC7.js → connect-desktop-dialog-Kd9yMGJt.js} +1 -1
  75. package/dist/client/assets/{connection-card-DUBuEg70.js → connection-card-DDu5P3MK.js} +1 -1
  76. package/dist/client/assets/{connection-detail-CGnEXhr8.js → connection-detail-D2rNBl5V.js} +1 -1
  77. package/dist/client/assets/{connection-form-helpers-C_G-pfMz.js → connection-form-helpers-DfO9XsmW.js} +1 -1
  78. package/dist/client/assets/{connections-LTMSCj4m.js → connections-BcomO7Cn.js} +1 -1
  79. package/dist/client/assets/{constants-zedJER97.js → constants-BWn08NPT.js} +1 -1
  80. package/dist/client/assets/{decopilot-sse-pool-COHY9r_J.js → decopilot-sse-pool-CMRm63c0.js} +1 -1
  81. package/dist/client/assets/{dialog-CE9cSi1n.js → dialog-C5tJKrIe.js} +1 -1
  82. package/dist/client/assets/{domain-settings-CoxAOXxT.js → domain-settings-CZBFKLKI.js} +1 -1
  83. package/dist/client/assets/{drawer-BbSfcrnZ.js → drawer-CLmcpYAq.js} +1 -1
  84. package/dist/client/assets/{dropdown-menu-BXdMM0hO.js → dropdown-menu-BMBIQAPu.js} +1 -1
  85. package/dist/client/assets/{dynamic-plugin-layout-ByCIwxNK.js → dynamic-plugin-layout-Bc2OKxjH.js} +1 -1
  86. package/dist/client/assets/{empty-state-bKARxats.js → empty-state-Dqb4pCPH.js} +1 -1
  87. package/dist/client/assets/{empty-state-DkGCUelT.js → empty-state-KuD-M7c2.js} +1 -1
  88. package/dist/client/assets/{extract-connection-data-uZfMlXLn.js → extract-connection-data-CvG4mot7.js} +1 -1
  89. package/dist/client/assets/{features-BWzvKvYJ.js → features-B-QA7uhn.js} +1 -1
  90. package/dist/client/assets/{file-explorer-CHPSau6D.js → file-explorer-DgfAbZ4C.js} +1 -1
  91. package/dist/client/assets/{file-preview-C9371Se2.js → file-preview--iW2cCbT.js} +1 -1
  92. package/dist/client/assets/{file-type-icon-Ba_yRUxi.js → file-type-icon-DxQG3lDM.js} +1 -1
  93. package/dist/client/assets/{files-BdRmGWWz.js → files-DF6KuP1y.js} +1 -1
  94. package/dist/client/assets/{form-BzcvWUSl.js → form-BNHFsJLI.js} +1 -1
  95. package/dist/client/assets/{general-DCWyYmET.js → general-DxQSk63x.js} +1 -1
  96. package/dist/client/assets/{generate-id-DY3u_JLh.js → generate-id-DdXBe7M0.js} +1 -1
  97. package/dist/client/assets/{github-repo-picker-Cq8oodHi.js → github-repo-picker-BzydTfYe.js} +1 -1
  98. package/dist/client/assets/{hover-card-42wepGnd.js → hover-card-DtQpoVUJ.js} +1 -1
  99. package/dist/client/assets/{image-field-zCWH1Q7t.js → image-field-C2sHdVR2.js} +1 -1
  100. package/dist/client/assets/{index-BFENlSRG.js → index-7OpXnpHB.js} +1 -1
  101. package/dist/client/assets/index-B3vKczw6.js +2 -0
  102. package/dist/client/assets/{index-DD1ygIbP.js → index-B8nA2Uho.js} +1 -1
  103. package/dist/client/assets/{index-hDhYAzuv.js → index-BHOlt3_w.js} +3 -3
  104. package/dist/client/assets/{index-DvR4XVkQ.js → index-BK7rHMiO.js} +4 -4
  105. package/dist/client/assets/{index-DR2x8aZ0.js → index-Bg1W0PYr.js} +1 -1
  106. package/dist/client/assets/{index-jHy-HnQ-.js → index-BuZauvg9.js} +1 -1
  107. package/dist/client/assets/{index-Bq4_1g_m.js → index-BxK6Bsji.js} +1 -1
  108. package/dist/client/assets/{index-D6arf7Ln.js → index-C5Yp63fx.js} +1 -1
  109. package/dist/client/assets/{index-BmaQNCkd.js → index-CRAc0JI1.js} +1 -1
  110. package/dist/client/assets/{index-V6nGCE5i.js → index-CYYHNGol.js} +1 -1
  111. package/dist/client/assets/{index-D5YGFAmw.js → index-DJA1Of1E.js} +1 -1
  112. package/dist/client/assets/index-Dlp1KhLa.js +1 -0
  113. package/dist/client/assets/{index-redirect-C5zpFU9B.js → index-redirect-BEWX9Nka.js} +1 -1
  114. package/dist/client/assets/{index-Bjl6aMmo.js → index-tKVxofyu.js} +1 -1
  115. package/dist/client/assets/{infiniteQueryObserver-B7HHD4ga.js → infiniteQueryObserver-D2dBaCpp.js} +1 -1
  116. package/dist/client/assets/{input-ohPOZpbr.js → input-D7Xl5u7v.js} +1 -1
  117. package/dist/client/assets/{integration-icon-DkUje5pL.js → integration-icon-cMlg_To9.js} +1 -1
  118. package/dist/client/assets/{label-CHl6K-PH.js → label-LgpCxCAi.js} +1 -1
  119. package/dist/client/assets/{layout-CHXGWT_X.js → layout-aEt2d_0f.js} +1 -1
  120. package/dist/client/assets/{login-U8YyQTqC.js → login-C4qFyNw-.js} +1 -1
  121. package/dist/client/assets/{members-DHFeYUG0.js → members-BV2-Rkpr.js} +1 -1
  122. package/dist/client/assets/{monaco-editor-B2aErRoU.js → monaco-editor-CSAZ3EKQ.js} +1 -1
  123. package/dist/client/assets/{monitoring-stats-row-jUek3ihW.js → monitoring-stats-row-DtC5seJ4.js} +1 -1
  124. package/dist/client/assets/{oauth-callback-ai-provider-wSQ_fnY_.js → oauth-callback-ai-provider-Bc49e7eQ.js} +1 -1
  125. package/dist/client/assets/{oauth-callback-Br4Ra2ei.js → oauth-callback-lQav_ffz.js} +1 -1
  126. package/dist/client/assets/{onboarding--zQLEMQI.js → onboarding-tmHMRVhM.js} +1 -1
  127. package/dist/client/assets/{org-install-BhG88aMC.js → org-install-BZPmVqzG.js} +1 -1
  128. package/dist/client/assets/{org-layout-CrjcRyfJ.js → org-layout-DHGGdXKJ.js} +1 -1
  129. package/dist/client/assets/{org-plugin-layout-D-POgMey.js → org-plugin-layout-DkiG0TUZ.js} +1 -1
  130. package/dist/client/assets/{page-seo-form-DKVorlIx.js → page-seo-form-D-iHlRIF.js} +1 -1
  131. package/dist/client/assets/page-seo-sheet-BiXExzzy.js +1 -0
  132. package/dist/client/assets/{pair-DoWxWQcr.js → pair-Cu2oYwNF.js} +1 -1
  133. package/dist/client/assets/{plugin-empty-state-BoEo3W91.js → plugin-empty-state-BkQ5fhVd.js} +1 -1
  134. package/dist/client/assets/{plugin-header-B7o311WU.js → plugin-header-D-hGf6a8.js} +1 -1
  135. package/dist/client/assets/{plugin-layout-BHhxMTkL.js → plugin-layout-BiJAyQAA.js} +1 -1
  136. package/dist/client/assets/{popover-CoUzivxr.js → popover-BXL_u5-N.js} +1 -1
  137. package/dist/client/assets/{post-editor-ioH2kBJn.js → post-editor-CK5Z9aaa.js} +1 -1
  138. package/dist/client/assets/{primitives-B1GrxuAu.js → primitives-BTbVkbYU.js} +1 -1
  139. package/dist/client/assets/{profile-DTVI1-0b.js → profile-DufN9cJ3.js} +1 -1
  140. package/dist/client/assets/{project-app-view-DSFKcRzU.js → project-app-view-CphyMKfg.js} +1 -1
  141. package/dist/client/assets/record-editor-DX9fm3fG.js +1 -0
  142. package/dist/client/assets/registry-BCFmDvsI.js +2 -0
  143. package/dist/client/assets/{registry-layout-CKsXjr2G.js → registry-layout-CfOUZsCh.js} +1 -1
  144. package/dist/client/assets/{require-capability-osNdEUYE.js → require-capability-CoPDq-Rj.js} +1 -1
  145. package/dist/client/assets/{required-auth-layout-ByKzWGwl.js → required-auth-layout-BWqnkRx0.js} +1 -1
  146. package/dist/client/assets/{reset-password-BYZ6IlU3.js → reset-password-B1jqxhyn.js} +1 -1
  147. package/dist/client/assets/{roles-CKvRJaL6.js → roles-Bt9F-DL3.js} +1 -1
  148. package/dist/client/assets/{save-status-nWpwLkZT.js → save-status-qh67FBPD.js} +1 -1
  149. package/dist/client/assets/schema-form-egJ2rUsF.js +1 -0
  150. package/dist/client/assets/{scroll-area-D2-klXVe.js → scroll-area-OESaEPnf.js} +1 -1
  151. package/dist/client/assets/{search-input-DdhTnIYb.js → search-input-D56p4X-b.js} +1 -1
  152. package/dist/client/assets/{secrets-DnYwB5yI.js → secrets-CQrWxvMH.js} +1 -1
  153. package/dist/client/assets/{sections-editor-RaAaC45Z.js → sections-editor-CPbI26Rh.js} +1 -1
  154. package/dist/client/assets/{select-B9hpehMO.js → select-BMjpJeFX.js} +1 -1
  155. package/dist/client/assets/{select-model-BVGmdezX.js → select-model-D6BsLxyu.js} +1 -1
  156. package/dist/client/assets/{seo-editor-DrYkry2i.js → seo-editor-l7M-6riW.js} +1 -1
  157. package/dist/client/assets/{settings-layout-CezlrERw.js → settings-layout-BLiI1KIC.js} +1 -1
  158. package/dist/client/assets/{settings-section-BwEX7g4K.js → settings-section-DbwjJzxj.js} +1 -1
  159. package/dist/client/assets/{sheet-B-rOc-m_.js → sheet-BUvCdoZQ.js} +1 -1
  160. package/dist/client/assets/{shell-controls-BvG6CznZ.js → shell-controls-CjiT39LA.js} +1 -1
  161. package/dist/client/assets/{shell-layout-4M44M6XO.js → shell-layout-DrFY_oBG.js} +1 -1
  162. package/dist/client/assets/{shell-route-loading-BaLk32Ff.js → shell-route-loading-TkERYWxM.js} +1 -1
  163. package/dist/client/assets/{sidebar-D2KGUQZ5.js → sidebar-awYzmomY.js} +1 -1
  164. package/dist/client/assets/{skeleton-4CAwOTLn.js → skeleton-TFyn3pzv.js} +1 -1
  165. package/dist/client/assets/{sortable.esm-CEfai7SC.js → sortable.esm-CmPftR_f.js} +1 -1
  166. package/dist/client/assets/{spinner-Bn6xRjgs.js → spinner-DFui8XPe.js} +1 -1
  167. package/dist/client/assets/{sso-sWh2Awf4.js → sso-CH40-KZX.js} +1 -1
  168. package/dist/client/assets/{store-6j-QguA5.js → store-CkTHaU9f.js} +1 -1
  169. package/dist/client/assets/store-registry-A7SyQYxV.js +2 -0
  170. package/dist/client/assets/{switch-CrkT_nnD.js → switch-5xUCHmkT.js} +1 -1
  171. package/dist/client/assets/{tab-id-hyQlI0Kb.js → tab-id-CjTcYziD.js} +1 -1
  172. package/dist/client/assets/{table-GpE0DrPT.js → table-D98kPNY0.js} +1 -1
  173. package/dist/client/assets/{tabs-BSUsSBSP.js → tabs-CZWwNusQ.js} +1 -1
  174. package/dist/client/assets/{task-status-CkT-gKVV.js → task-status-CIM0xXc0.js} +1 -1
  175. package/dist/client/assets/{textarea-DjJrPp__.js → textarea-D4A1N62o.js} +1 -1
  176. package/dist/client/assets/{toggle-group-BiI-swRj.js → toggle-group-BpGLMO7D.js} +1 -1
  177. package/dist/client/assets/{toolbar-Jc1Es0h2.js → toolbar-yXIYfyVw.js} +1 -1
  178. package/dist/client/assets/{tools-list-CxPJ9zQW.js → tools-list-0ZqVJIn4.js} +1 -1
  179. package/dist/client/assets/{tooltip-D7iVgucV.js → tooltip-Z3WOGi-N.js} +1 -1
  180. package/dist/client/assets/{types-DemhOgiB.js → types-Fo7n0of6.js} +1 -1
  181. package/dist/client/assets/{use-ai-providers-BZS-MpDa.js → use-ai-providers-BJ8jiUSI.js} +1 -1
  182. package/dist/client/assets/{use-automations-BrgymC39.js → use-automations-B7rD7lbR.js} +1 -1
  183. package/dist/client/assets/{use-capability-kezGfnPO.js → use-capability-Bstk9OqM.js} +1 -1
  184. package/dist/client/assets/{use-collections-Dv9VzQFM.js → use-collections-CsiUNwO7.js} +1 -1
  185. package/dist/client/assets/{use-connection-BDUQZCEk.js → use-connection-EwKc1CSj.js} +1 -1
  186. package/dist/client/assets/{use-copy-DIglwQFC.js → use-copy-CXTqzOru.js} +1 -1
  187. package/dist/client/assets/{use-create-virtual-mcp-Cf_tJTHh.js → use-create-virtual-mcp-CfbNB_45.js} +1 -1
  188. package/dist/client/assets/{use-debounced-autosave-CkBn5Xwg.js → use-debounced-autosave-hLy-iXvw.js} +1 -1
  189. package/dist/client/assets/{use-delete-connection-Dqd8Xa7q.js → use-delete-connection-BkHLs4FD.js} +1 -1
  190. package/dist/client/assets/{use-file-configs-BlvDBMfZ.js → use-file-configs-BlWZC2vL.js} +1 -1
  191. package/dist/client/assets/{use-infinite-scroll-CcZDhELS.js → use-infinite-scroll-qNPf8x9e.js} +1 -1
  192. package/dist/client/assets/{use-list-state-bHGgac3-.js → use-list-state-C1mFKxI_.js} +1 -1
  193. package/dist/client/assets/{use-mcp-prompts-CqiV5bO8.js → use-mcp-prompts-Bn3Wm9k3.js} +1 -1
  194. package/dist/client/assets/{use-mcp-tools-CT9H5Tgt.js → use-mcp-tools-R1mbAIRT.js} +1 -1
  195. package/dist/client/assets/{use-members-GWDjSfUU.js → use-members-BQrHXcu4.js} +1 -1
  196. package/dist/client/assets/{use-navigate-to-agent-nrQW475X.js → use-navigate-to-agent-DGXgnEHQ.js} +1 -1
  197. package/dist/client/assets/{use-org-auth-client-QDIKZNDh.js → use-org-auth-client-gFpgtb_P.js} +1 -1
  198. package/dist/client/assets/{use-org-sso-Bj7NT1Lh.js → use-org-sso-BT99qfx_.js} +1 -1
  199. package/dist/client/assets/{use-organization-roles-D5YSssEn.js → use-organization-roles-ZqphKn4l.js} +1 -1
  200. package/dist/client/assets/{use-organization-settings-C-NwnAkJ.js → use-organization-settings-FQITAKM_.js} +1 -1
  201. package/dist/client/assets/{use-registry-connections-XEfm3Coy.js → use-registry-connections-WhwzWNQl.js} +1 -1
  202. package/dist/client/assets/{use-secrets-mtYI3rLo.js → use-secrets-DfLXBHDx.js} +1 -1
  203. package/dist/client/assets/{use-status-sounds-BVgXSRy3.js → use-status-sounds-B1ZobK3j.js} +1 -1
  204. package/dist/client/assets/{use-view-mode-BuXYfEXk.js → use-view-mode-Btr0kDbm.js} +1 -1
  205. package/dist/client/assets/{use-virtual-mcp-Cs8ggUiu.js → use-virtual-mcp-Dw0zlGSm.js} +1 -1
  206. package/dist/client/assets/useInfiniteQuery-9SqW16Wp.js +1 -0
  207. package/dist/client/assets/{useRouterState-ox0nLJMv.js → useRouterState-B2r4ZzAD.js} +1 -1
  208. package/dist/client/assets/useSuspenseInfiniteQuery-DfuEN5UX.js +1 -0
  209. package/dist/client/assets/{user-Co-otLks.js → user-Cgwj96C0.js} +1 -1
  210. package/dist/client/assets/{view-mode-toggle-D8ejVQgU.js → view-mode-toggle-C-3tjzqA.js} +1 -1
  211. package/dist/client/assets/{workflow-q47qWEbL.js → workflow-CQzovLAQ.js} +1 -1
  212. package/dist/client/assets/workflow-detail-CIjyqgXf.js +1 -0
  213. package/dist/client/index.html +1 -1
  214. package/dist/server/cli.js +323 -322
  215. package/dist/server/server.js +225 -224
  216. package/package.json +1 -1
  217. package/dist/client/assets/ZoomOut-DcRrZEDD.js +0 -1
  218. package/dist/client/assets/accordion-qSwNd8Sp.js +0 -1
  219. package/dist/client/assets/agent-icon-Cskjq81z.js +0 -1
  220. package/dist/client/assets/app-editor-DmXODpUq.js +0 -1
  221. package/dist/client/assets/index-B9wTguzP.js +0 -1
  222. package/dist/client/assets/index-_OB7PRq3.js +0 -2
  223. package/dist/client/assets/page-seo-sheet-BL6Qr_fp.js +0 -1
  224. package/dist/client/assets/record-editor-UjdJtAq9.js +0 -1
  225. package/dist/client/assets/registry-BxrdgO67.js +0 -2
  226. package/dist/client/assets/schema-form-CGiurH71.js +0 -1
  227. package/dist/client/assets/store-registry-B_w6ZYZP.js +0 -2
  228. package/dist/client/assets/useInfiniteQuery-DjQiRGez.js +0 -1
  229. package/dist/client/assets/useSuspenseInfiniteQuery-tT6OVxOk.js +0 -1
  230. package/dist/client/assets/workflow-detail-WxnU9dcU.js +0 -1
@@ -1,5 +1,5 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/sections-editor-RaAaC45Z.js","assets/index-hDhYAzuv.js","assets/index-LtT7znvk.css","assets/ChevronDown-Ck0kXXoi.js","assets/ChevronRight-C3-N31UD.js","assets/ChevronUp-C1pNLnkX.js","assets/agent-icon-Cskjq81z.js","assets/AlertCircle-BgvyaAL6.js","assets/Tool01-4hNK4hhF.js","assets/SwitchHorizontal01-B5oRfzWe.js","assets/RefreshCcw01-DpdZ9gm0.js","assets/XCircle-Btwiite7.js","assets/ArrowUpRight-DrDPl1ww.js","assets/ZapSquare-Alh3PeLr.js","assets/Users03-DrS1ThY-.js","assets/CheckCircle-B-pzErM9.js","assets/Check-CpRgfX9v.js","assets/DotsVertical-Dn-9kvPV.js","assets/Container-DtKKcYj1.js","assets/Eye-L6l6QAVo.js","assets/Globe01-CmgkLjDA.js","assets/FilterLines-vdidQTPZ.js","assets/ZoomOut-DcRrZEDD.js","assets/Star01-CDtvsxxe.js","assets/Palette-TC1tDkop.js","assets/HardDrive-dDTShpdM.js","assets/Stars02-UcqCQViA.js","assets/Key01-B4ofXTQm.js","assets/sheet-B-rOc-m_.js","assets/X-CzsiH5k2.js","assets/LinkExternal01-WHe1S-E-.js","assets/Monitor01-FD67jx2m.js","assets/Sun-CFQIVViJ.js","assets/Play-C7Rue8fn.js","assets/Plus-DRIZd-2-.js","assets/SearchMd-DShTT603.js","assets/Settings02-MTx-k3S7.js","assets/Shield01-BY4aDf21.js","assets/Stars01-DzPa7_Zo.js","assets/Trash01-Cd-TfU52.js","assets/Upload01-CODWkN2q.js","assets/User01-gLhirg6x.js","assets/Users01-DBWJec2Z.js","assets/XClose-CtxwJX4P.js","assets/Zap-BT8r4Lfd.js","assets/scroll-area-D2-klXVe.js","assets/select-B9hpehMO.js","assets/tooltip-D7iVgucV.js","assets/dialog-CE9cSi1n.js","assets/input-ohPOZpbr.js","assets/dropdown-menu-BXdMM0hO.js","assets/sortable.esm-CEfai7SC.js","assets/connection-slug-eyAPH6o3.js","assets/connection-card-DUBuEg70.js","assets/use-registry-connections-XEfm3Coy.js","assets/use-connection-BDUQZCEk.js","assets/use-collections-Dv9VzQFM.js","assets/constants-zedJER97.js","assets/use-organization-settings-C-NwnAkJ.js","assets/useInfiniteQuery-DjQiRGez.js","assets/infiniteQueryObserver-B7HHD4ga.js","assets/extract-connection-data-uZfMlXLn.js","assets/generate-id-DY3u_JLh.js","assets/collections-B9feqlnI.js","assets/card-DZwqn9tD.js","assets/integration-icon-DkUje5pL.js","assets/collection-search-CpScI8eY.js","assets/collection-tabs-cISZZwXw.js","assets/badge-BSpskrOH.js","assets/drawer-BbSfcrnZ.js","assets/form-BzcvWUSl.js","assets/label-CHl6K-PH.js","assets/textarea-DjJrPp__.js","assets/connection-form-helpers-C_G-pfMz.js","assets/use-infinite-scroll-CcZDhELS.js","assets/useSuspenseInfiniteQuery-tT6OVxOk.js","assets/schema-form-CGiurH71.js","assets/calendar-DUjAE_4N.js","assets/popover-CoUzivxr.js","assets/switch-CrkT_nnD.js","assets/image-field-zCWH1Q7t.js","assets/skeleton-4CAwOTLn.js","assets/tabs-BSUsSBSP.js","assets/use-file-configs-BlvDBMfZ.js","assets/unwrap-tool-result-BYXdCQMg.js","assets/page-seo-form-DKVorlIx.js","assets/command-BJzE5xdm.js","assets/index-D5YGFAmw.js","assets/add-section-modal-BtCHVJdb.js","assets/agent-capabilities-C1-nbsvP.js","assets/pair-DoWxWQcr.js","assets/format-time-Cy7tTmZp.js","assets/differenceInSeconds-NQ4PDo0z.js","assets/use-copy-DIglwQFC.js","assets/file-type-icon-Ba_yRUxi.js","assets/content-blocks-o63cs2vh.js","assets/types-DemhOgiB.js","assets/chat-context-B2M4P5Ss.js","assets/tab-id-hyQlI0Kb.js","assets/decopilot-sse-pool-COHY9r_J.js","assets/create-sse-subscription-BS5983N4.js","assets/use-virtual-mcp-Cs8ggUiu.js","assets/use-ai-providers-BZS-MpDa.js","assets/shell-layout-4M44M6XO.js","assets/avatar-BBV4QWEL.js","assets/required-auth-layout-ByKzWGwl.js","assets/useRouterState-ox0nLJMv.js","assets/use-org-sso-Bj7NT1Lh.js","assets/use-navigate-to-agent-nrQW475X.js","assets/use-mcp-prompts-CqiV5bO8.js","assets/spinner-Bn6xRjgs.js","assets/toggle-group-BiI-swRj.js","assets/agent-icons-VjS4qMx-.js","assets/checkbox-DVXfLKtH.js","assets/ai-providers-logos-DD3qZ33J.js","assets/settings-section-BwEX7g4K.js","assets/connect-desktop-dialog-5wbrfqC7.js","assets/index-DD1ygIbP.js","assets/question-004-sINsf4GQ.js","assets/shell-route-loading-BaLk32Ff.js","assets/sidebar-D2KGUQZ5.js","assets/toolbar-Jc1Es0h2.js","assets/use-create-virtual-mcp-Cf_tJTHh.js","assets/github-repo-picker-Cq8oodHi.js","assets/use-mcp-tools-CT9H5Tgt.js","assets/alert-dialog-DRN5w-t8.js","assets/index-D6arf7Ln.js","assets/use-org-auth-client-QDIKZNDh.js","assets/hover-card-42wepGnd.js","assets/task-status-CkT-gKVV.js","assets/use-status-sounds-BVgXSRy3.js","assets/empty-state-bKARxats.js","assets/accordion-qSwNd8Sp.js","assets/use-capability-kezGfnPO.js","assets/monaco-editor-B2aErRoU.js","assets/user-Co-otLks.js","assets/tools-list-CxPJ9zQW.js","assets/use-debounced-autosave-CkBn5Xwg.js","assets/index-BmaQNCkd.js","assets/search-input-DdhTnIYb.js","assets/use-secrets-mtYI3rLo.js","assets/formatDistanceToNow-Cb2QZZJn.js","assets/view-mode-toggle-D8ejVQgU.js","assets/select-model-BVGmdezX.js","assets/use-automations-BrgymC39.js","assets/automation-runs-C2k5umHE.js","assets/table-GpE0DrPT.js","assets/use-members-GWDjSfUU.js","assets/automation-list-row-74P8727s.js","assets/file-preview-C9371Se2.js","assets/page-seo-sheet-BL6Qr_fp.js","assets/file-explorer-CHPSau6D.js","assets/app-editor-DmXODpUq.js","assets/save-status-nWpwLkZT.js","assets/post-editor-ioH2kBJn.js","assets/primitives-B1GrxuAu.js","assets/record-editor-UjdJtAq9.js","assets/seo-editor-DrYkry2i.js","assets/project-app-view-DSFKcRzU.js"])))=>i.map(i=>d[i]);
2
- import{e as W,r as P,c as oe,j as n,l as we,q as Te,b as Vs,E as Ht,f as es,d as To,g as xc,p as mu,L as pu,n as qs,K as Dt,s as _u,o as ne,B as ie,v as bc,V as gu,t as Le,w as yc,x as vu,y as Ur,z as Ai,C as vt,D as xu,F as Gs,G as Sc,H as bu,I as yu,J as Pa,M as Su,P as Kr,Q as wu,a as Ys,R as hr,T as vi,U as jt,_ as Kt}from"./index-hDhYAzuv.js";import{C as Me,a as Cu,u as ku,b as Xs,h as ju,w as Nu,c as wc,d as Ro,s as An,T as Eu,e as Tu,g as Ru,f as Pu}from"./agent-capabilities-C1-nbsvP.js";import{g as Po,u as tt,S as ws,a as Cc}from"./constants-zedJER97.js";import{u as It,a as Du,b as Au,c as Iu}from"./use-virtual-mcp-Cs8ggUiu.js";import{a as Cs,b as ts,c as Do,d as kc,u as Bu,t as Lu,e as Mu,f as Ou}from"./chat-context-B2M4P5Ss.js";import{i as Fi}from"./AlertCircle-BgvyaAL6.js";import{i as jc}from"./CheckCircle-B-pzErM9.js";import{n as Da,a as Nc}from"./ZapSquare-Alh3PeLr.js";import{i as $u,a as zu}from"./XCircle-Btwiite7.js";import{s as fs}from"./XClose-CtxwJX4P.js";import{c as Fu,u as Hu,a as Ec,O as Wu,t as Aa,G as Uu,g as Ku,s as Vu,C as qu,b as Gu,d as Yu}from"./pair-DoWxWQcr.js";import{I as Vt}from"./integration-icon-DkUje5pL.js";import{a as Xu}from"./Users03-DrS1ThY-.js";import{t as ks}from"./ChevronDown-Ck0kXXoi.js";import{u as Tc}from"./use-ai-providers-BZS-MpDa.js";import{r as Ju,u as Ao,i as Zu}from"./shell-layout-4M44M6XO.js";import{b as Qu,a as ef}from"./shell-route-loading-BaLk32Ff.js";import{u as tf}from"./sidebar-D2KGUQZ5.js";import{i as sf,S as rf,a as nf,b as of}from"./sheet-B-rOc-m_.js";import{u as Rc,T as ke,a as je,b as Ne,c as Pc}from"./tooltip-D7iVgucV.js";import{i as Ii,a as Vr,b as Dc,c as af,p as qr,g as Gr,d as Io,e as Ac,h as In,f as cn,j as Ia,A as Ba,k as lf,l as cf,n as hf,m as df,o as uf,t as ff,q as mf,r as Ic,s as Yr,u as pf,v as La,w as Ma,x as _f,y as gf,z as vf,B as xf,C as Bo,D as yr,E as Lo,F as Bc,G as Lc,H as bf,I as yf,J as Sf,K as wf,L as Cf,M as Oa,N as kf,O as jf,P as ki,Q as Nf,R as Mc,S as Oc,T as $c,U as Ef}from"./agent-icon-Cskjq81z.js";import{u as Tf}from"./use-status-sounds-BVgXSRy3.js";import{E as Sr}from"./empty-state-bKARxats.js";import{u as Rf,r as Bn,a as Pf,p as zc,f as $a,b as Fc,c as Hc,d as Df,F as Af,i as If,e as Bf,g as Lf,h as Mf,j as Of}from"./tab-id-hyQlI0Kb.js";import{g as Js,A as $f}from"./sortable.esm-CEfai7SC.js";import{T as za,a as Ln}from"./toolbar-Jc1Es0h2.js";import{A as zf,a as Ff,b as Hf,c as Wf,R as Wc,d as Uf,e as Kf}from"./accordion-qSwNd8Sp.js";import{u as Hi,a as Mo,b as Vf}from"./use-connection-BDUQZCEk.js";import{u as Xr,a as qf,b as Gf}from"./use-mcp-tools-CT9H5Tgt.js";import{u as Yf}from"./use-capability-kezGfnPO.js";import{F as Oo,M as $o}from"./file-type-icon-Ba_yRUxi.js";import{i as Jr,n as Xf}from"./Globe01-CmgkLjDA.js";import{P as js,a as Ns,b as Es}from"./popover-CoUzivxr.js";import{S as Uc}from"./spinner-Bn6xRjgs.js";import{D as Zs,a as Qs,b as ei,c as et,d as dr,e as Jf,f as Zf,g as Qf}from"./dropdown-menu-BXdMM0hO.js";import{D as Bt,a as Lt,b as ss,c as is,d as ti,e as zo}from"./dialog-CE9cSi1n.js";import{I as qe}from"./input-ohPOZpbr.js";import{T as vs,a as Fo,b as ji,c as Ho}from"./tabs-BSUsSBSP.js";import{T as wr}from"./textarea-DjJrPp__.js";import{a as Zt,s as em}from"./Eye-L6l6QAVo.js";import{t as Zr}from"./Stars01-DzPa7_Zo.js";import{l as tm,w as sm,M as im}from"./monaco-editor-B2aErRoU.js";import{i as rm}from"./ChevronRight-C3-N31UD.js";import{g as nm}from"./generate-id-DY3u_JLh.js";import{u as om,g as am}from"./types-DemhOgiB.js";import{U as Kc}from"./user-Co-otLks.js";import{T as lm,u as Vc}from"./tools-list-CxPJ9zQW.js";import{u as cm}from"./unwrap-tool-result-BYXdCQMg.js";import{s as qc,g as hm}from"./connection-slug-eyAPH6o3.js";import{A as Cr,a as kr,b as jr,c as Nr,d as Er,e as Tr,f as Rr,g as Pr}from"./alert-dialog-DRN5w-t8.js";import{C as Gc,a as Mn}from"./card-DZwqn9tD.js";import{L as Ct}from"./label-CHl6K-PH.js";import{S as Et,a as Tt,b as Rt,c as at,d as Pt}from"./select-B9hpehMO.js";import{S as Dr}from"./switch-CrkT_nnD.js";import{i as Hs}from"./Play-C7Rue8fn.js";import{s as At}from"./Plus-DRIZd-2-.js";import{a as dm}from"./Settings02-MTx-k3S7.js";import{s as Bi}from"./Trash01-Cd-TfU52.js";import{u as Ar}from"./use-debounced-autosave-CkBn5Xwg.js";import{S as Qr}from"./scroll-area-D2-klXVe.js";import{i as Wo}from"./SearchMd-DShTT603.js";import{i as um}from"./Upload01-CODWkN2q.js";import{P as Nt}from"./index-BmaQNCkd.js";import{C as en}from"./checkbox-DVXfLKtH.js";import{S as Yc}from"./search-input-DdhTnIYb.js";import{C as Xc}from"./collection-tabs-cISZZwXw.js";import{u as fm}from"./use-mcp-prompts-CqiV5bO8.js";import{D as mm,a as pm,b as _m}from"./drawer-BbSfcrnZ.js";import{i as si}from"./Check-CpRgfX9v.js";import{i as Jc}from"./Key01-B4ofXTQm.js";import{S as Os}from"./skeleton-4CAwOTLn.js";import{s as gm}from"./User01-gLhirg6x.js";import{t as Uo}from"./Users01-DBWJec2Z.js";import{u as vm,a as xm}from"./use-secrets-mtYI3rLo.js";import{G as bm}from"./github-repo-picker-Cq8oodHi.js";import{f as ym}from"./formatDistanceToNow-Cb2QZZJn.js";import{n as Ts}from"./LinkExternal01-WHe1S-E-.js";import{s as Ws}from"./Star01-CDtvsxxe.js";import{i as Zc}from"./Stars02-UcqCQViA.js";import{V as Sm}from"./view-mode-toggle-D8ejVQgU.js";import{i as Ko,a as wm,b as Vo}from"./Tool01-4hNK4hhF.js";import{c as Qc,i as Cm}from"./SwitchHorizontal01-B5oRfzWe.js";import{i as Fa}from"./ZoomOut-DcRrZEDD.js";import{i as km}from"./Monitor01-FD67jx2m.js";import{B as jm}from"./badge-BSpskrOH.js";import{C as Nm,a as Ha,b as Em,c as Tm,d as Rm,e as Pm}from"./command-BJzE5xdm.js";import{M as Dm}from"./select-model-BVGmdezX.js";import{u as Wi,a as Am,b as Im,c as Bm,d as Lm}from"./use-automations-BrgymC39.js";import{i as eh}from"./RefreshCcw01-DpdZ9gm0.js";import{i as Li}from"./Zap-BT8r4Lfd.js";import{A as Mm}from"./automation-runs-C2k5umHE.js";import{A as Om}from"./automation-list-row-74P8727s.js";import{F as $m,a as zm,f as Fm}from"./file-preview-C9371Se2.js";import{i as Hm}from"./X-CzsiH5k2.js";function ci(t){return t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}k`:String(t)}function Wa(t){if(!t)return"—";const e=typeof t=="string"?new Date(t):t;return isNaN(e.getTime())?"—":e.toLocaleString("en-US",{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit"})}function Wm(t){return t?t.replace(/-\d{8}(?:-[a-z0-9]+)*$/i,"").replace(/-/g," "):"—"}function Um(t){const e=W.c(4),{items:s}=t;let i;e[0]!==s?(i=s.map(Km),e[0]=s,e[1]=i):i=e[1];let r;return e[2]!==i?(r=n.jsx("div",{className:"grid grid-cols-2 gap-x-8 gap-y-6",children:i}),e[2]=i,e[3]=r):r=e[3],r}function Km(t){return n.jsxs("div",{className:"flex flex-col gap-1 min-w-0",children:[n.jsx("span",{className:"text-xs text-muted-foreground truncate",children:t.label}),n.jsx("span",{className:"text-sm text-foreground tabular-nums truncate",children:t.value})]},t.label)}function Vm(t){const e=W.c(30),{userTokens:s,assistantTokens:i,otherTokens:r}=t,o=s+i+r,a=o>0?s/o*100:0,l=o>0?i/o*100:0,h=o>0?r/o*100:0;let c;e[0]!==a?(c=a>0&&n.jsx("div",{className:"h-full bg-chart-1",style:{width:`${a}%`}}),e[0]=a,e[1]=c):c=e[1];let d;e[2]!==l?(d=l>0&&n.jsx("div",{className:"h-full bg-chart-2",style:{width:`${l}%`}}),e[2]=l,e[3]=d):d=e[3];let u;e[4]!==h?(u=h>0&&n.jsx("div",{className:"h-full bg-muted-foreground/30",style:{width:`${h}%`}}),e[4]=h,e[5]=u):u=e[5];let f;e[6]!==c||e[7]!==d||e[8]!==u?(f=n.jsxs("div",{className:"flex h-2 w-full overflow-hidden rounded-full bg-muted",children:[c,d,u]}),e[6]=c,e[7]=d,e[8]=u,e[9]=f):f=e[9];let m;e[10]===Symbol.for("react.memo_cache_sentinel")?(m=n.jsx("span",{className:"inline-block h-2 w-2 rounded-sm bg-chart-1 shrink-0"}),e[10]=m):m=e[10];let p;e[11]!==a?(p=a.toFixed(1),e[11]=a,e[12]=p):p=e[12];let _;e[13]!==p?(_=n.jsxs("div",{className:"flex items-center gap-1.5",children:[m,n.jsxs("span",{className:"text-xs text-muted-foreground",children:["User ",p,"%"]})]}),e[13]=p,e[14]=_):_=e[14];let g;e[15]===Symbol.for("react.memo_cache_sentinel")?(g=n.jsx("span",{className:"inline-block h-2 w-2 rounded-sm bg-chart-2 shrink-0"}),e[15]=g):g=e[15];let v;e[16]!==l?(v=l.toFixed(1),e[16]=l,e[17]=v):v=e[17];let y;e[18]!==v?(y=n.jsxs("div",{className:"flex items-center gap-1.5",children:[g,n.jsxs("span",{className:"text-xs text-muted-foreground",children:["Assistant ",v,"%"]})]}),e[18]=v,e[19]=y):y=e[19];let x;e[20]!==h||e[21]!==r?(x=r>0&&n.jsxs("div",{className:"flex items-center gap-1.5",children:[n.jsx("span",{className:"inline-block h-2 w-2 rounded-sm bg-muted-foreground/30 shrink-0"}),n.jsxs("span",{className:"text-xs text-muted-foreground",children:["Other ",h.toFixed(1),"%"]})]}),e[20]=h,e[21]=r,e[22]=x):x=e[22];let b;e[23]!==y||e[24]!==x||e[25]!==_?(b=n.jsxs("div",{className:"flex flex-wrap gap-x-3 gap-y-1",children:[_,y,x]}),e[23]=y,e[24]=x,e[25]=_,e[26]=b):b=e[26];let S;return e[27]!==b||e[28]!==f?(S=n.jsxs("div",{className:"flex flex-col gap-2",children:[f,b]}),e[27]=b,e[28]=f,e[29]=S):S=e[29],S}function qm(t){const e=W.c(11),{agentId:s,isError:i}=t,r=It(s),o=r?.title??"Subtask",a=r?.icon??null;let l;e[0]!==a||e[1]!==o?(l=n.jsx(Vt,{icon:a,name:o,size:"xs",className:"size-6 rounded-md shrink-0"}),e[0]=a,e[1]=o,e[2]=l):l=e[2];const h=i?"text-destructive":"text-foreground";let c;e[3]!==h?(c=oe("shrink-0 font-medium",h),e[3]=h,e[4]=c):c=e[4];let d;e[5]!==o||e[6]!==c?(d=n.jsx("span",{className:c,children:o}),e[5]=o,e[6]=c,e[7]=d):d=e[7];let u;return e[8]!==l||e[9]!==d?(u=n.jsxs(n.Fragment,{children:[l,d]}),e[8]=l,e[9]=d,e[10]=u):u=e[10],u}function Gm(t){const e=W.c(5),{isError:s}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=n.jsx(Vt,{icon:null,name:"Subtask",size:"xs",className:"size-6 rounded-md shrink-0"}),e[0]=i):i=e[0];const r=s?"text-destructive":"text-foreground";let o;e[1]!==r?(o=oe("shrink-0 font-medium",r),e[1]=r,e[2]=o):o=e[2];let a;return e[3]!==o?(a=n.jsxs(n.Fragment,{children:[i,n.jsx("span",{className:o,children:"Subtask"})]}),e[3]=o,e[4]=a):a=e[4],a}function Ym(t){const e=W.c(18),{part:s}=t,i=s.input?.agent_id,r=s.state==="input-streaming"||s.state==="input-available"||s.state==="output-available"&&s.preliminary===!0,o=s.state==="output-error",a=s.state==="approval-requested";let l;e[0]!==o?(l=n.jsx(Gm,{isError:o}),e[0]=o,e[1]=l):l=e[1];let h;e[2]!==i||e[3]!==o?(h=n.jsx(qm,{agentId:i,isError:o}),e[2]=i,e[3]=o,e[4]=h):h=e[4];let c;e[5]!==l||e[6]!==h?(c=n.jsx(P.Suspense,{fallback:l,children:h}),e[5]=l,e[6]=h,e[7]=c):c=e[7];let d;e[8]!==s.input?(d=s.input?.prompt&&n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"text-muted-foreground/50",children:"·"}),n.jsx("span",{className:"truncate text-muted-foreground",children:s.input.prompt})]}),e[8]=s.input,e[9]=d):d=e[9];let u;e[10]!==a||e[11]!==o||e[12]!==r?(u=n.jsx("span",{className:"ml-auto shrink-0",children:r?n.jsx(we,{size:12,className:"animate-spin text-muted-foreground"}):o?n.jsx($u,{size:12,className:"text-destructive"}):a?n.jsx(Fi,{size:12,className:"text-warning"}):n.jsx(jc,{size:12,className:"text-emerald-500"})}),e[10]=a,e[11]=o,e[12]=r,e[13]=u):u=e[13];let f;return e[14]!==c||e[15]!==d||e[16]!==u?(f=n.jsxs("div",{className:"flex items-center gap-2 text-xs min-w-0",children:[c,d,u]}),e[14]=c,e[15]=d,e[16]=u,e[17]=f):f=e[17],f}function Xm(t){const e=W.c(55),{onClose:s,back:i,className:r}=t,[o,a]=P.useState(null),{messages:l}=Cs(),{activeTask:h}=ts(),{selectedModel:c,selectedVirtualMcp:d}=Do();let u,f,m,p,_,g,v,y;if(e[0]!==h||e[1]!==i||e[2]!==r||e[3]!==l||e[4]!==s||e[5]!==o?.id||e[6]!==c||e[7]!==d?.title){y=Symbol.for("react.early_return_sentinel");e:{const S=Fu(l),w=[...l].reverse().find(ap),k=w?.metadata?.usage,N=w?.metadata?.modelLimits?.contextWindow??c?.limits?.contextWindow??null,I=k?.contextTokens??0,D=N&&N>0?(I/N*100).toFixed(1):null,R=l;let j;e[16]!==R?(j=R.filter(op).reduce(np,0),e[16]=R,e[17]=j):j=e[17];const C=j,A=l;let E;e[18]!==A?(E=A.filter(rp).reduce(ip,0),e[18]=A,e[19]=E):E=e[19];const T=E,L=Math.max(0,S.totalTokens-C-T),B=l[0],O=l.at(-1),F=B?.metadata?.created_at??h?.created_at,H=O?.metadata?.created_at??h?.updated_at,M=l.filter(sp),U=l.flatMap(ep),V=c?.modelId?Wm(c.modelId):"—",K=d?.title??"Decopilot",Y=[{label:"Session",value:h?.title??"New chat"},{label:"Messages",value:M.length},{label:"Agent",value:K},{label:"Model",value:V},{label:"Context Limit",value:N?ci(N):"—"},{label:"Session Tokens (billed)",value:S.totalTokens>0?ci(S.totalTokens):"0"},{label:"Usage",value:D!==null?`${D}%`:"—"},{label:"Input Tokens",value:S.inputTokens>0?ci(S.inputTokens):"0"},{label:"Output Tokens",value:S.outputTokens>0?ci(S.outputTokens):"0"},{label:"Reasoning Tokens",value:S.reasoningTokens>0?ci(S.reasoningTokens):"0"},{label:"Cost",value:S.cost>0?`$${S.cost<.001?S.cost.toFixed(6):S.cost.toFixed(4)}`:"$0.00"},{label:"Session Created",value:Wa(F)},{label:"Last Activity",value:Wa(H)}];if(!h&&M.length===0){let z;e[20]!==r?(z=oe("flex flex-col h-full w-full border-l border-border bg-background",r),e[20]=r,e[21]=z):z=e[21];let te;e[22]===Symbol.for("react.memo_cache_sentinel")?(te=n.jsx("span",{className:"text-sm font-medium text-foreground",children:"Context"}),e[22]=te):te=e[22];let ee;e[23]!==i?(ee=i?n.jsx(Da,{size:14,className:"text-muted-foreground"}):n.jsx(fs,{size:14,className:"text-muted-foreground"}),e[23]=i,e[24]=ee):ee=e[24];let q;e[25]!==s||e[26]!==ee?(q=n.jsxs("div",{className:"h-11 px-4 flex items-center justify-between shrink-0 border-b border-border/50",children:[te,n.jsx("button",{type:"button",onClick:s,className:"flex size-6 items-center justify-center rounded hover:bg-accent transition-colors",children:ee})]}),e[25]=s,e[26]=ee,e[27]=q):q=e[27];let $;e[28]===Symbol.for("react.memo_cache_sentinel")?($=n.jsx("div",{className:"flex-1 flex items-center justify-center px-4 text-center",children:n.jsx("p",{className:"text-xs text-muted-foreground",children:"Start a conversation to see context"})}),e[28]=$):$=e[28];let ae;e[29]!==z||e[30]!==q?(ae=n.jsxs("div",{className:z,children:[q,$]}),e[29]=z,e[30]=q,e[31]=ae):ae=e[31],y=ae;break e}e[32]!==r?(g=oe("flex flex-col h-full w-full border-l border-border bg-background overflow-y-auto",r),e[32]=r,e[33]=g):g=e[33];let Q;e[34]===Symbol.for("react.memo_cache_sentinel")?(Q=n.jsx("span",{className:"text-sm font-medium text-foreground",children:"Context"}),e[34]=Q):Q=e[34];let se;e[35]!==i?(se=i?n.jsx(Da,{size:14}):n.jsx(fs,{size:14}),e[35]=i,e[36]=se):se=e[36],e[37]!==s||e[38]!==se?(v=n.jsxs("div",{className:"flex h-11 shrink-0 items-center justify-between border-b border-border/50 px-4",children:[Q,n.jsx("button",{type:"button",onClick:s,className:"flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-accent hover:text-foreground",children:se})]}),e[37]=s,e[38]=se,e[39]=v):v=e[39],u="flex flex-col gap-8 p-6",f=U.length>0&&n.jsxs("div",{className:"flex flex-col gap-3",children:[n.jsx("span",{className:"text-xs text-muted-foreground",children:"Subtasks"}),n.jsx("div",{className:"flex flex-col gap-1",children:U.map(Qm)})]}),m=n.jsx(Um,{items:Y});let he;e[40]===Symbol.for("react.memo_cache_sentinel")?(he=n.jsx("span",{className:"text-xs text-muted-foreground",children:"Context Breakdown"}),e[40]=he):he=e[40],e[41]!==T||e[42]!==L||e[43]!==C?(p=n.jsxs("div",{className:"flex flex-col gap-3",children:[he,n.jsx(Vm,{userTokens:C,assistantTokens:T,otherTokens:L})]}),e[41]=T,e[42]=L,e[43]=C,e[44]=p):p=e[44],_=M.length>0&&n.jsxs("div",{className:"flex flex-col gap-3",children:[n.jsx("span",{className:"text-xs text-muted-foreground",children:"Raw messages"}),n.jsx("div",{className:"flex flex-col gap-1",children:M.map(z=>{const te=z.metadata?.created_at,ee=o?.id===z.id;return n.jsxs("div",{className:"rounded-md border border-border/50 overflow-hidden",children:[n.jsxs("button",{type:"button",onClick:()=>a(ee?null:z),className:"flex items-center justify-between gap-2 px-3 py-2 text-xs hover:bg-accent/50 w-full text-left cursor-pointer",children:[n.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[n.jsx("span",{className:oe("shrink-0 font-medium",z.role==="user"?"text-chart-1":"text-chart-2"),children:z.role}),n.jsx("span",{className:"text-muted-foreground",children:"•"}),n.jsx("span",{className:"truncate text-muted-foreground font-mono",children:z.id})]}),te&&n.jsx("span",{className:"shrink-0 text-muted-foreground tabular-nums",children:new Date(te).toLocaleString("en-US",{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit"})})]}),ee&&n.jsxs(n.Fragment,{children:[z.role==="assistant"&&(()=>{const q=z.metadata?._request;if(!q)return null;const $=q.systemSections??[],ae=Math.max(1,...$.map(Zm)),de=$.reduce(Jm,0);return n.jsxs("div",{className:"border-t border-border/50 px-3 py-2.5 text-xs space-y-2.5",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx("span",{className:"font-medium text-foreground",children:"Request"}),n.jsxs("span",{className:"text-muted-foreground tabular-nums",children:[q.activeTools??0," / ",q.tools??0," ","tools active"]})]}),$.length>0&&n.jsxs("div",{className:"space-y-1.5",children:[n.jsxs("div",{className:"text-muted-foreground",children:["System prompt"," ",n.jsxs("span",{className:"tabular-nums",children:["~",Math.round(de/4).toLocaleString()," ","tok"]})]}),$.map((me,le)=>{const G=me.preview.match(/^<([a-z-]+)/i)?.[1]??`section ${le}`,pe=me.chars/ae*100,ue=Math.round(me.chars/4);return n.jsxs("div",{className:"space-y-0.5",children:[n.jsxs("div",{className:"flex items-center justify-between gap-2",children:[n.jsx("span",{className:"font-mono text-foreground truncate",children:G}),n.jsxs("span",{className:"text-muted-foreground tabular-nums shrink-0",children:["~",ue.toLocaleString()," tok"]})]}),n.jsx("div",{className:"h-1 w-full rounded-full bg-muted overflow-hidden",children:n.jsx("div",{className:"h-full rounded-full bg-chart-3",style:{width:`${pe}%`}})})]},le)})]})]})})(),n.jsx("pre",{className:"text-xs font-mono bg-muted px-3 py-2 overflow-auto whitespace-pre-wrap break-all border-t border-border/50 max-h-64",children:JSON.stringify(z,null,2)})]})]},z.id)})})]})}e[0]=h,e[1]=i,e[2]=r,e[3]=l,e[4]=s,e[5]=o?.id,e[6]=c,e[7]=d?.title,e[8]=u,e[9]=f,e[10]=m,e[11]=p,e[12]=_,e[13]=g,e[14]=v,e[15]=y}else u=e[8],f=e[9],m=e[10],p=e[11],_=e[12],g=e[13],v=e[14],y=e[15];if(y!==Symbol.for("react.early_return_sentinel"))return y;let x;e[45]!==u||e[46]!==f||e[47]!==m||e[48]!==p||e[49]!==_?(x=n.jsxs("div",{className:u,children:[f,m,p,_]}),e[45]=u,e[46]=f,e[47]=m,e[48]=p,e[49]=_,e[50]=x):x=e[50];let b;return e[51]!==g||e[52]!==v||e[53]!==x?(b=n.jsxs("div",{className:g,children:[v,x]}),e[51]=g,e[52]=v,e[53]=x,e[54]=b):b=e[54],b}function Jm(t,e){return t+e.chars}function Zm(t){return t.chars}function Qm(t,e){return n.jsx(Ym,{part:t},e)}function ep(t){return(t.parts??[]).filter(tp)}function tp(t){return t.type==="tool-subtask"}function sp(t){return t.role!=="system"}function ip(t,e){const s=e.metadata?.usage;return t+(s?.outputTokens??0)}function rp(t){return t.role==="assistant"}function np(t,e){const s=e.metadata?.usage;return t+(s?.inputTokens??0)}function op(t){return t.role==="user"}function ap(t){return t.role==="assistant"&&t.metadata?.usage}function lp(t){const e=W.c(13),{readOnly:s,identity:i,aboveRow:r,input:o,iceBreakers:a}=t,l=!s&&i?i:null;let h;e[0]!==r||e[1]!==s?(h=!s&&r?n.jsx("div",{"data-chat-above-row":"true",className:"@container/chat-bottom flex justify-start gap-1",children:r}):null,e[0]=r,e[1]=s,e[2]=h):h=e[2];let c;e[3]!==o||e[4]!==h?(c=n.jsxs("div",{className:"flex flex-col gap-2",children:[h,o]}),e[3]=o,e[4]=h,e[5]=c):c=e[5];let d;e[6]!==a||e[7]!==s?(d=!s&&a?n.jsx("div",{className:"w-full",children:a}):null,e[6]=a,e[7]=s,e[8]=d):d=e[8];let u;return e[9]!==l||e[10]!==c||e[11]!==d?(u=n.jsx("div",{"data-chat-centered":"true",className:"h-full w-full flex flex-col items-center justify-center px-4 gap-6",children:n.jsxs("div",{className:"w-full max-w-3xl flex flex-col gap-6",children:[l,c,d]})}),e[9]=l,e[10]=c,e[11]=d,e[12]=u):u=e[12],u}function cp(t){const e=W.c(25),{onOpenContextPanel:s}=t,{org:i}=Te(),{selectedVirtualMcp:r}=Do();let o;e[0]!==i.id?(o=Po(i.id),e[0]=i.id,e[1]=o):o=e[1];const l=r??o,h=It(l.id),c=kc(),{data:d}=Vs.useSession(),u=d?.user?.id,f=c?.activeTask??null,m=!!(u&&f?.created_by&&f.created_by!==u);let p;e[2]===Symbol.for("react.memo_cache_sentinel")?(p=n.jsx(Xu,{size:32}),e[2]=p):p=e[2];let _;e[3]!==l.icon||e[4]!==l.title?(_=n.jsx(Vt,{icon:l.icon,name:l.title,size:"lg",fallbackIcon:p,className:"size-10 min-w-10 md:size-[60px]! md:min-w-[60px] rounded-xl md:rounded-[18px]!"}),e[3]=l.icon,e[4]=l.title,e[5]=_):_=e[5];let g;e[6]!==l.title?(g=n.jsx("h3",{className:"text-base md:text-xl font-medium text-foreground",children:l.title}),e[6]=l.title,e[7]=g):g=e[7];const v=l.description??"Ask anything about configuring model providers or using MCP Mesh.";let y;e[8]!==v?(y=n.jsx("div",{className:"text-muted-foreground text-center text-base max-w-md line-clamp-2",children:v}),e[8]=v,e[9]=y):y=e[9];let x;e[10]!==_||e[11]!==g||e[12]!==y?(x=n.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 md:gap-4 text-center",children:[_,g,y]}),e[10]=_,e[11]=g,e[12]=y,e[13]=x):x=e[13];const b=c?.currentBranch??null;let S;e[14]!==h||e[15]!==b?(S=n.jsx(Cu,{virtualMcp:h,currentBranch:b}),e[14]=h,e[15]=b,e[16]=S):S=e[16];let w;e[17]!==s?(w=n.jsx(Me.Input,{onOpenContextPanel:s}),e[17]=s,e[18]=w):w=e[18];let k;e[19]===Symbol.for("react.memo_cache_sentinel")?(k=n.jsx(Me.IceBreakers,{}),e[19]=k):k=e[19];let N;return e[20]!==m||e[21]!==w||e[22]!==x||e[23]!==S?(N=n.jsx(lp,{readOnly:m,identity:x,aboveRow:S,input:w,iceBreakers:k}),e[20]=m,e[21]=w,e[22]=x,e[23]=S,e[24]=N):N=e[24],N}function Ua(t){const e=W.c(17),{outputs:s,collapsed:i,onToggle:r,variant:o}=t,a=o==="card"?"rounded-xl border border-border bg-muted/95 shadow-sm backdrop-blur-sm":"border-b border-border bg-background";let l;e[0]!==a?(l=oe(a),e[0]=a,e[1]=l):l=e[1];let h;e[2]===Symbol.for("react.memo_cache_sentinel")?(h=n.jsx("span",{className:"text-sm font-medium text-foreground",children:"Files in this task"}),e[2]=h):h=e[2];const c=i&&"-rotate-90";let d;e[3]!==c?(d=oe("size-4 text-muted-foreground transition-transform",c),e[3]=c,e[4]=d):d=e[4];let u;e[5]!==d?(u=n.jsx(ks,{className:d}),e[5]=d,e[6]=u):u=e[6];let f;e[7]!==r||e[8]!==u?(f=n.jsxs("button",{type:"button",onClick:r,className:"flex w-full items-center justify-between px-3 py-2.5 text-left",children:[h,u]}),e[7]=r,e[8]=u,e[9]=f):f=e[9];let m;e[10]!==i||e[11]!==s?(m=!i&&n.jsx("div",{className:"flex max-h-72 flex-col gap-1.5 overflow-y-auto px-2 pb-2",children:s.map(hp)}),e[10]=i,e[11]=s,e[12]=m):m=e[12];let p;return e[13]!==l||e[14]!==f||e[15]!==m?(p=n.jsxs("div",{className:l,children:[f,m]}),e[13]=l,e[14]=f,e[15]=m,e[16]=p):p=e[16],p}function hp(t){return n.jsx(Wu,{file:t},t.key)}function dp(){const t=W.c(13),e=kc()?.taskId??null,s=Hu();let i;t[0]!==s?(i={enabled:s},t[0]=s,t[1]=i):i=t[1];const{data:r}=Ec(e,i),[o,a]=P.useState(!1),[l,h]=P.useState(!0);if(!e||!r||r.length===0)return null;let c;t[2]===Symbol.for("react.memo_cache_sentinel")?(c=()=>a(fp),t[2]=c):c=t[2];let d;t[3]!==o||t[4]!==r?(d=n.jsx("div",{className:"absolute top-2 right-2 z-10 hidden w-72 @[1280px]:block",children:n.jsx(Ua,{variant:"card",outputs:r,collapsed:o,onToggle:c})}),t[3]=o,t[4]=r,t[5]=d):d=t[5];let u;t[6]===Symbol.for("react.memo_cache_sentinel")?(u=()=>h(up),t[6]=u):u=t[6];let f;t[7]!==l||t[8]!==r?(f=n.jsx("div",{className:"shrink-0 @[1280px]:hidden",children:n.jsx(Ua,{variant:"bar",outputs:r,collapsed:l,onToggle:u})}),t[7]=l,t[8]=r,t[9]=f):f=t[9];let m;return t[10]!==d||t[11]!==f?(m=n.jsxs(n.Fragment,{children:[d,f]}),t[10]=d,t[11]=f,t[12]=m):m=t[12],m}function up(t){return!t}function fp(t){return!t}function mp(){const t=W.c(28),{org:e}=Te(),s=Tc(),{isChatEmpty:i}=Cs(),[r,o]=P.useState("chat"),a=ku(),{selectedVirtualMcp:l}=Do();let h;t[0]!==e.id?(h=Po(e.id),t[0]=e.id,t[1]=h):h=t[1];const u=It((l??h).id),f=Bu(),m=Xs(u?.metadata);if(s.length===0&&!(m&&ju(f))){let R;return t[2]===Symbol.for("react.memo_cache_sentinel")?(R=n.jsx(Me,{className:"animate-in fade-in-0 duration-200",children:n.jsx(Me.Main,{className:"flex flex-col items-center",children:n.jsx(Me.EmptyState,{children:n.jsx(Me.NoAiProviderEmptyState,{})})})}),t[2]=R):R=t[2],R}let _;t[3]!==a.hasDecoKey||t[4]!==a.hasOnlyDecoProvider||t[5]!==a.isLoading||t[6]!==a.isZeroBalance||t[7]!==i||t[8]!==e.id?(_=a.hasDecoKey&&a.isZeroBalance&&a.hasOnlyDecoProvider&&!a.isLoading&&i&&!Nu(e.id),t[3]=a.hasDecoKey,t[4]=a.hasOnlyDecoProvider,t[5]=a.isLoading,t[6]=a.isZeroBalance,t[7]=i,t[8]=e.id,t[9]=_):_=t[9];const g=_;let v;t[10]!==g?(v=g&&n.jsx(Me.CreditsEmptyState,{}),t[10]=g,t[11]=v):v=t[11];const y=r!=="chat"?"opacity-0 pointer-events-none":"opacity-100";let x;t[12]!==y?(x=oe("absolute inset-0 flex flex-col transition-opacity duration-100 ease-out",y),t[12]=y,t[13]=x):x=t[13];let b;t[14]!==i?(b=i?n.jsx(Me.Main,{children:n.jsx(cp,{onOpenContextPanel:()=>o("context")})}):n.jsxs(n.Fragment,{children:[n.jsxs(Me.Main,{className:"relative flex flex-col overflow-hidden @container",children:[n.jsx(dp,{}),n.jsx("div",{className:"min-h-0 flex-1",children:n.jsx(Me.Messages,{})})]}),n.jsx(Me.Footer,{children:n.jsx(Me.Input,{onOpenContextPanel:()=>o("context")})})]}),t[14]=i,t[15]=b):b=t[15];let S;t[16]!==x||t[17]!==b?(S=n.jsx("div",{className:x,children:b}),t[16]=x,t[17]=b,t[18]=S):S=t[18];const w=r==="context"?"opacity-100":"opacity-0 pointer-events-none";let k;t[19]!==w?(k=oe("absolute inset-0 flex flex-col transition-opacity duration-100 ease-out",w),t[19]=w,t[20]=k):k=t[20];let N;t[21]===Symbol.for("react.memo_cache_sentinel")?(N=n.jsx(Xm,{back:!0,onClose:()=>o("chat")}),t[21]=N):N=t[21];let I;t[22]!==k?(I=n.jsx("div",{className:k,children:N}),t[22]=k,t[23]=I):I=t[23];let D;return t[24]!==I||t[25]!==v||t[26]!==S?(D=n.jsxs(Me,{className:"relative overflow-hidden animate-in fade-in-0 duration-200",children:[v,S,I]}),t[24]=I,t[25]=v,t[26]=S,t[27]=D):D=t[27],D}function th(){const t=W.c(2);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsx(Me.Skeleton,{}),t[0]=e):e=t[0];let s;return t[1]===Symbol.for("react.memo_cache_sentinel")?(s=n.jsx(Ht,{fallback:e,children:n.jsx(P.Suspense,{fallback:n.jsx(Me.Skeleton,{}),children:n.jsx(mp,{})})}),t[1]=s):s=t[1],s}function pp(t){const e=t.entityMetadata?.defaultMainView??null,s=e==null||e.type==="chat",i=t.mainParamPresent?t.mainParamValue!=="0":!s,r=s?!0:t.entityMetadata?.chatDefaultOpen??!1;return{mainOpen:i,chatOpen:r}}function Ka(t,e){return t&&e?{chat:45,main:55}:t&&!e?{chat:100,main:0}:!t&&e?{chat:0,main:100}:{chat:0,main:0}}function _p(t,e){return t===1?!0:t===0?!1:e}function gp(t,e){const s=es(),i=To({strict:!1}),r=xc({strict:!1}),{create:o}=Rf(),{locator:a}=Te(),{virtualMcpId:l,orgSlug:h,isAgentRoute:c}=e,d=pp({entityMetadata:t,mainParamPresent:i.main!==void 0,mainParamValue:i.main}),u=_p(i.chat,d.chatOpen),f=d.mainOpen,m=P.useRef(crypto.randomUUID()),p=r.taskId??m.current,_="/$org/$taskId",g=I=>({org:h,taskId:I}),v=c?{virtualmcpid:l}:{},y=(I,D)=>{s({to:_,params:g(p),search:R=>({...R,...I}),replace:D?.replace??!1})},x=(I,D)=>{s({to:_,params:g(I),search:R=>{const j={};return D?j.virtualmcpid=D:c&&(j.virtualmcpid=l),j}})},b=()=>{f?y({main:"0"},{replace:!0}):y({main:Bn(t)},{replace:!0})},S=()=>{y({chat:u?0:1},{replace:!0})},w=()=>{u||y({chat:1},{replace:!0})},k=async()=>{const I=crypto.randomUUID(),D=Ju(h,a,p);try{await o({id:I,virtual_mcp_id:l,...D?{branch:D}:{}})}catch{}s({to:_,params:g(I),search:R=>({...v,chat:1})})},N=I=>{y({main:I},{replace:!0})};return{taskId:p,mainOpen:f,chatOpen:u,mainParam:i.main,setTaskId:x,toggleMain:b,toggleChat:S,openChat:w,createNewTask:k,openTab:N}}const qo=45;function sh(t,e=qo){const s=typeof t=="number"?t:Number(t);return!Number.isFinite(s)||s<=0||s>=100?e:s}function vp(t){return sh(t,qo)}function xp(){const t=W.c(6);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=pu.decoChatPanelWidth(),t[0]=e):e=t[0];const[s,i]=mu(e,vp);let r;t[1]!==s?(r=sh(s,qo),t[1]=s,t[2]=r):r=t[2];const o=r;let a;return t[3]!==i||t[4]!==o?(a=[o,i],t[3]=i,t[4]=o,t[5]=a):a=t[5],a}function bp(t){try{return JSON.parse(t)}catch{return null}}function yp(t){if(!t||typeof t!="object")return null;const e=t,s=e.content?.find(o=>o.type==="text")?.text,i=s?bp(s):null,r=e.structuredContent;return r==null?i:typeof r=="object"&&!Array.isArray(r)&&Object.keys(r).length===0?i??r:r}function Rs(t){const e=yp(t);return e===null?null:e}function Go(t){if(!t)return null;const e=t.match(/\/pull\/(\d+)\b/);if(!e)return null;const s=Number(e[1]);return Number.isFinite(s)&&s>0?s:null}function Sp(t){if(!t||typeof t!="object")return null;const e=t.content?.find(r=>r.type==="text")?.text;if(!e)return null;const s=e.match(/https:\/\/github\.com\/[^\s"]+\/pull\/\d+/)?.[0],i=Go(s);return!i||!s?null:{number:i,htmlUrl:s}}const Va=/[\r\n<>]/,wp=/^[^\s@<>]+@[^\s@<>]+\.[^\s@<>]+$/;function Ui(t){const e=t?.userName?.trim();if(!e||Va.test(e))return null;const s=t?.userEmail?.trim();return!s||Va.test(s)?{userName:e}:wp.test(s)?{userName:e,userEmail:s}:{userName:e}}function Cp(t){return t.split(`
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/sections-editor-CPbI26Rh.js","assets/index-BHOlt3_w.js","assets/index-LtT7znvk.css","assets/ChevronDown-kizgpVbD.js","assets/ChevronRight-BHYJ3DEJ.js","assets/ChevronUp-BtOuA1iC.js","assets/agent-icon-B2kRhhvG.js","assets/AlertCircle-UbTrvmD8.js","assets/Tool01-9pPVu4xE.js","assets/SwitchHorizontal01-8QRqIEQi.js","assets/RefreshCcw01-42um-ufT.js","assets/XCircle-B_F-Nqsp.js","assets/ArrowUpRight-B-ghXq-_.js","assets/ZapSquare-NM_4Hwrb.js","assets/Users03-CtHK3VTc.js","assets/CheckCircle-B6zciJm5.js","assets/Check-BWHZM20T.js","assets/DotsVertical-B11N4XoI.js","assets/Container-BkW3IR6n.js","assets/Eye-Bphw4qHW.js","assets/Globe01-CU4shpSp.js","assets/FilterLines-DOb8W880.js","assets/ZoomOut-BShhdOnU.js","assets/Star01-Dj-yDvPD.js","assets/Palette-BuARXF-n.js","assets/HardDrive-DSbDltiF.js","assets/Stars02-wLN6gYts.js","assets/Key01-zwhddqN8.js","assets/sheet-BUvCdoZQ.js","assets/X-BZIbRbas.js","assets/LinkExternal01-mlC9GXBP.js","assets/Monitor01-BhL9ynh2.js","assets/Sun-DWOvfsiD.js","assets/Play-DnwFxesH.js","assets/Plus-DapGfte9.js","assets/SearchMd-TUFumYUu.js","assets/Settings02-B-7DoxYa.js","assets/Shield01-B58oeqIu.js","assets/Stars01-DWP5CW8V.js","assets/Trash01-C0uYWTct.js","assets/Upload01-mCrnkIKe.js","assets/User01-CN1cs4oO.js","assets/Users01-DEQxorlz.js","assets/XClose-gXcEWNUe.js","assets/Zap-tFcxuoCY.js","assets/scroll-area-OESaEPnf.js","assets/select-BMjpJeFX.js","assets/tooltip-Z3WOGi-N.js","assets/dialog-C5tJKrIe.js","assets/input-D7Xl5u7v.js","assets/dropdown-menu-BMBIQAPu.js","assets/sortable.esm-CmPftR_f.js","assets/connection-slug-eyAPH6o3.js","assets/connection-card-DDu5P3MK.js","assets/use-registry-connections-WhwzWNQl.js","assets/use-connection-EwKc1CSj.js","assets/use-collections-CsiUNwO7.js","assets/constants-BWn08NPT.js","assets/use-organization-settings-FQITAKM_.js","assets/useInfiniteQuery-9SqW16Wp.js","assets/infiniteQueryObserver-D2dBaCpp.js","assets/extract-connection-data-CvG4mot7.js","assets/generate-id-DdXBe7M0.js","assets/collections-C0702JvT.js","assets/card-CyFdQD4G.js","assets/integration-icon-cMlg_To9.js","assets/collection-search-BX0jLWGA.js","assets/collection-tabs-DMGO-5kZ.js","assets/badge-CFfIdhIE.js","assets/drawer-CLmcpYAq.js","assets/form-BNHFsJLI.js","assets/label-LgpCxCAi.js","assets/textarea-D4A1N62o.js","assets/connection-form-helpers-DfO9XsmW.js","assets/use-infinite-scroll-qNPf8x9e.js","assets/useSuspenseInfiniteQuery-DfuEN5UX.js","assets/schema-form-egJ2rUsF.js","assets/calendar-CTrPS9iI.js","assets/popover-BXL_u5-N.js","assets/switch-5xUCHmkT.js","assets/image-field-C2sHdVR2.js","assets/skeleton-TFyn3pzv.js","assets/tabs-CZWwNusQ.js","assets/use-file-configs-BlWZC2vL.js","assets/unwrap-tool-result-BYXdCQMg.js","assets/page-seo-form-D-iHlRIF.js","assets/command-DUxz0k_8.js","assets/index-DJA1Of1E.js","assets/add-section-modal-I6U_0tzj.js","assets/agent-capabilities-BZuIDzdU.js","assets/pair-Cu2oYwNF.js","assets/format-time-Cy7tTmZp.js","assets/differenceInSeconds-NQ4PDo0z.js","assets/use-copy-CXTqzOru.js","assets/file-type-icon-DxQG3lDM.js","assets/content-blocks-o63cs2vh.js","assets/types-Fo7n0of6.js","assets/chat-context-BStm3zgD.js","assets/tab-id-CjTcYziD.js","assets/decopilot-sse-pool-CMRm63c0.js","assets/create-sse-subscription-BS5983N4.js","assets/use-virtual-mcp-Dw0zlGSm.js","assets/use-ai-providers-BJ8jiUSI.js","assets/shell-layout-DrFY_oBG.js","assets/avatar-DqZBDcop.js","assets/required-auth-layout-BWqnkRx0.js","assets/useRouterState-B2r4ZzAD.js","assets/use-org-sso-BT99qfx_.js","assets/use-navigate-to-agent-DGXgnEHQ.js","assets/use-mcp-prompts-Bn3Wm9k3.js","assets/spinner-DFui8XPe.js","assets/toggle-group-BpGLMO7D.js","assets/agent-icons-BEGVE6W-.js","assets/checkbox-CnZ6PrCw.js","assets/ai-providers-logos-DD3qZ33J.js","assets/settings-section-DbwjJzxj.js","assets/connect-desktop-dialog-Kd9yMGJt.js","assets/index-B8nA2Uho.js","assets/question-004-sINsf4GQ.js","assets/shell-route-loading-TkERYWxM.js","assets/sidebar-awYzmomY.js","assets/toolbar-yXIYfyVw.js","assets/use-create-virtual-mcp-CfbNB_45.js","assets/github-repo-picker-BzydTfYe.js","assets/use-mcp-tools-R1mbAIRT.js","assets/alert-dialog-BNZF3kxZ.js","assets/index-C5Yp63fx.js","assets/use-org-auth-client-gFpgtb_P.js","assets/hover-card-DtQpoVUJ.js","assets/task-status-CIM0xXc0.js","assets/use-status-sounds-B1ZobK3j.js","assets/empty-state-Dqb4pCPH.js","assets/accordion-DwmTgXcH.js","assets/use-capability-Bstk9OqM.js","assets/monaco-editor-CSAZ3EKQ.js","assets/user-Cgwj96C0.js","assets/tools-list-0ZqVJIn4.js","assets/use-debounced-autosave-hLy-iXvw.js","assets/index-CRAc0JI1.js","assets/search-input-D56p4X-b.js","assets/use-secrets-DfLXBHDx.js","assets/formatDistanceToNow-Cb2QZZJn.js","assets/view-mode-toggle-C-3tjzqA.js","assets/select-model-D6BsLxyu.js","assets/use-automations-B7rD7lbR.js","assets/automation-runs-CzaQvRkF.js","assets/table-D98kPNY0.js","assets/use-members-BQrHXcu4.js","assets/automation-list-row-BjbqZnyx.js","assets/file-preview--iW2cCbT.js","assets/page-seo-sheet-BiXExzzy.js","assets/file-explorer-DgfAbZ4C.js","assets/app-editor-HtmK2stv.js","assets/save-status-qh67FBPD.js","assets/post-editor-CK5Z9aaa.js","assets/primitives-BTbVkbYU.js","assets/record-editor-DX9fm3fG.js","assets/seo-editor-l7M-6riW.js","assets/project-app-view-CphyMKfg.js"])))=>i.map(i=>d[i]);
2
+ import{e as W,r as P,c as oe,j as n,l as we,q as Te,b as Vs,E as Ht,f as es,d as To,g as xc,p as mu,L as pu,n as qs,K as Dt,s as _u,o as ne,B as ie,v as bc,V as gu,t as Le,w as yc,x as vu,y as Ur,z as Ai,C as vt,D as xu,F as Gs,G as Sc,H as bu,I as yu,J as Pa,M as Su,P as Kr,Q as wu,a as Ys,R as hr,T as vi,U as jt,_ as Kt}from"./index-BHOlt3_w.js";import{C as Me,a as Cu,u as ku,b as Xs,h as ju,w as Nu,c as wc,d as Ro,s as An,T as Eu,e as Tu,g as Ru,f as Pu}from"./agent-capabilities-BZuIDzdU.js";import{g as Po,u as tt,S as ws,a as Cc}from"./constants-BWn08NPT.js";import{u as It,a as Du,b as Au,c as Iu}from"./use-virtual-mcp-Dw0zlGSm.js";import{a as Cs,b as ts,c as Do,d as kc,u as Bu,t as Lu,e as Mu,f as Ou}from"./chat-context-BStm3zgD.js";import{i as Fi}from"./AlertCircle-UbTrvmD8.js";import{i as jc}from"./CheckCircle-B6zciJm5.js";import{n as Da,a as Nc}from"./ZapSquare-NM_4Hwrb.js";import{i as $u,a as zu}from"./XCircle-B_F-Nqsp.js";import{s as fs}from"./XClose-gXcEWNUe.js";import{c as Fu,u as Hu,a as Ec,O as Wu,t as Aa,G as Uu,g as Ku,s as Vu,C as qu,b as Gu,d as Yu}from"./pair-Cu2oYwNF.js";import{I as Vt}from"./integration-icon-cMlg_To9.js";import{a as Xu}from"./Users03-CtHK3VTc.js";import{t as ks}from"./ChevronDown-kizgpVbD.js";import{u as Tc}from"./use-ai-providers-BJ8jiUSI.js";import{r as Ju,u as Ao,i as Zu}from"./shell-layout-DrFY_oBG.js";import{b as Qu,a as ef}from"./shell-route-loading-TkERYWxM.js";import{u as tf}from"./sidebar-awYzmomY.js";import{i as sf,S as rf,a as nf,b as of}from"./sheet-BUvCdoZQ.js";import{u as Rc,T as ke,a as je,b as Ne,c as Pc}from"./tooltip-Z3WOGi-N.js";import{i as Ii,a as Vr,b as Dc,c as af,p as qr,g as Gr,d as Io,e as Ac,h as In,f as cn,j as Ia,A as Ba,k as lf,l as cf,n as hf,m as df,o as uf,t as ff,q as mf,r as Ic,s as Yr,u as pf,v as La,w as Ma,x as _f,y as gf,z as vf,B as xf,C as Bo,D as yr,E as Lo,F as Bc,G as Lc,H as bf,I as yf,J as Sf,K as wf,L as Cf,M as Oa,N as kf,O as jf,P as ki,Q as Nf,R as Mc,S as Oc,T as $c,U as Ef}from"./agent-icon-B2kRhhvG.js";import{u as Tf}from"./use-status-sounds-B1ZobK3j.js";import{E as Sr}from"./empty-state-Dqb4pCPH.js";import{u as Rf,r as Bn,a as Pf,p as zc,f as $a,b as Fc,c as Hc,d as Df,F as Af,i as If,e as Bf,g as Lf,h as Mf,j as Of}from"./tab-id-CjTcYziD.js";import{g as Js,A as $f}from"./sortable.esm-CmPftR_f.js";import{T as za,a as Ln}from"./toolbar-yXIYfyVw.js";import{A as zf,a as Ff,b as Hf,c as Wf,R as Wc,d as Uf,e as Kf}from"./accordion-DwmTgXcH.js";import{u as Hi,a as Mo,b as Vf}from"./use-connection-EwKc1CSj.js";import{u as Xr,a as qf,b as Gf}from"./use-mcp-tools-R1mbAIRT.js";import{u as Yf}from"./use-capability-Bstk9OqM.js";import{F as Oo,M as $o}from"./file-type-icon-DxQG3lDM.js";import{i as Jr,n as Xf}from"./Globe01-CU4shpSp.js";import{P as js,a as Ns,b as Es}from"./popover-BXL_u5-N.js";import{S as Uc}from"./spinner-DFui8XPe.js";import{D as Zs,a as Qs,b as ei,c as et,d as dr,e as Jf,f as Zf,g as Qf}from"./dropdown-menu-BMBIQAPu.js";import{D as Bt,a as Lt,b as ss,c as is,d as ti,e as zo}from"./dialog-C5tJKrIe.js";import{I as qe}from"./input-D7Xl5u7v.js";import{T as vs,a as Fo,b as ji,c as Ho}from"./tabs-CZWwNusQ.js";import{T as wr}from"./textarea-D4A1N62o.js";import{a as Zt,s as em}from"./Eye-Bphw4qHW.js";import{t as Zr}from"./Stars01-DWP5CW8V.js";import{l as tm,w as sm,M as im}from"./monaco-editor-CSAZ3EKQ.js";import{i as rm}from"./ChevronRight-BHYJ3DEJ.js";import{g as nm}from"./generate-id-DdXBe7M0.js";import{u as om,g as am}from"./types-Fo7n0of6.js";import{U as Kc}from"./user-Cgwj96C0.js";import{T as lm,u as Vc}from"./tools-list-0ZqVJIn4.js";import{u as cm}from"./unwrap-tool-result-BYXdCQMg.js";import{s as qc,g as hm}from"./connection-slug-eyAPH6o3.js";import{A as Cr,a as kr,b as jr,c as Nr,d as Er,e as Tr,f as Rr,g as Pr}from"./alert-dialog-BNZF3kxZ.js";import{C as Gc,a as Mn}from"./card-CyFdQD4G.js";import{L as Ct}from"./label-LgpCxCAi.js";import{S as Et,a as Tt,b as Rt,c as at,d as Pt}from"./select-BMjpJeFX.js";import{S as Dr}from"./switch-5xUCHmkT.js";import{i as Hs}from"./Play-DnwFxesH.js";import{s as At}from"./Plus-DapGfte9.js";import{a as dm}from"./Settings02-B-7DoxYa.js";import{s as Bi}from"./Trash01-C0uYWTct.js";import{u as Ar}from"./use-debounced-autosave-hLy-iXvw.js";import{S as Qr}from"./scroll-area-OESaEPnf.js";import{i as Wo}from"./SearchMd-TUFumYUu.js";import{i as um}from"./Upload01-mCrnkIKe.js";import{P as Nt}from"./index-CRAc0JI1.js";import{C as en}from"./checkbox-CnZ6PrCw.js";import{S as Yc}from"./search-input-D56p4X-b.js";import{C as Xc}from"./collection-tabs-DMGO-5kZ.js";import{u as fm}from"./use-mcp-prompts-Bn3Wm9k3.js";import{D as mm,a as pm,b as _m}from"./drawer-CLmcpYAq.js";import{i as si}from"./Check-BWHZM20T.js";import{i as Jc}from"./Key01-zwhddqN8.js";import{S as Os}from"./skeleton-TFyn3pzv.js";import{s as gm}from"./User01-CN1cs4oO.js";import{t as Uo}from"./Users01-DEQxorlz.js";import{u as vm,a as xm}from"./use-secrets-DfLXBHDx.js";import{G as bm}from"./github-repo-picker-BzydTfYe.js";import{f as ym}from"./formatDistanceToNow-Cb2QZZJn.js";import{n as Ts}from"./LinkExternal01-mlC9GXBP.js";import{s as Ws}from"./Star01-Dj-yDvPD.js";import{i as Zc}from"./Stars02-wLN6gYts.js";import{V as Sm}from"./view-mode-toggle-C-3tjzqA.js";import{i as Ko,a as wm,b as Vo}from"./Tool01-9pPVu4xE.js";import{c as Qc,i as Cm}from"./SwitchHorizontal01-8QRqIEQi.js";import{i as Fa}from"./ZoomOut-BShhdOnU.js";import{i as km}from"./Monitor01-BhL9ynh2.js";import{B as jm}from"./badge-CFfIdhIE.js";import{C as Nm,a as Ha,b as Em,c as Tm,d as Rm,e as Pm}from"./command-DUxz0k_8.js";import{M as Dm}from"./select-model-D6BsLxyu.js";import{u as Wi,a as Am,b as Im,c as Bm,d as Lm}from"./use-automations-B7rD7lbR.js";import{i as eh}from"./RefreshCcw01-42um-ufT.js";import{i as Li}from"./Zap-tFcxuoCY.js";import{A as Mm}from"./automation-runs-CzaQvRkF.js";import{A as Om}from"./automation-list-row-BjbqZnyx.js";import{F as $m,a as zm,f as Fm}from"./file-preview--iW2cCbT.js";import{i as Hm}from"./X-BZIbRbas.js";function ci(t){return t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}k`:String(t)}function Wa(t){if(!t)return"—";const e=typeof t=="string"?new Date(t):t;return isNaN(e.getTime())?"—":e.toLocaleString("en-US",{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit"})}function Wm(t){return t?t.replace(/-\d{8}(?:-[a-z0-9]+)*$/i,"").replace(/-/g," "):"—"}function Um(t){const e=W.c(4),{items:s}=t;let i;e[0]!==s?(i=s.map(Km),e[0]=s,e[1]=i):i=e[1];let r;return e[2]!==i?(r=n.jsx("div",{className:"grid grid-cols-2 gap-x-8 gap-y-6",children:i}),e[2]=i,e[3]=r):r=e[3],r}function Km(t){return n.jsxs("div",{className:"flex flex-col gap-1 min-w-0",children:[n.jsx("span",{className:"text-xs text-muted-foreground truncate",children:t.label}),n.jsx("span",{className:"text-sm text-foreground tabular-nums truncate",children:t.value})]},t.label)}function Vm(t){const e=W.c(30),{userTokens:s,assistantTokens:i,otherTokens:r}=t,o=s+i+r,a=o>0?s/o*100:0,l=o>0?i/o*100:0,h=o>0?r/o*100:0;let c;e[0]!==a?(c=a>0&&n.jsx("div",{className:"h-full bg-chart-1",style:{width:`${a}%`}}),e[0]=a,e[1]=c):c=e[1];let d;e[2]!==l?(d=l>0&&n.jsx("div",{className:"h-full bg-chart-2",style:{width:`${l}%`}}),e[2]=l,e[3]=d):d=e[3];let u;e[4]!==h?(u=h>0&&n.jsx("div",{className:"h-full bg-muted-foreground/30",style:{width:`${h}%`}}),e[4]=h,e[5]=u):u=e[5];let f;e[6]!==c||e[7]!==d||e[8]!==u?(f=n.jsxs("div",{className:"flex h-2 w-full overflow-hidden rounded-full bg-muted",children:[c,d,u]}),e[6]=c,e[7]=d,e[8]=u,e[9]=f):f=e[9];let m;e[10]===Symbol.for("react.memo_cache_sentinel")?(m=n.jsx("span",{className:"inline-block h-2 w-2 rounded-sm bg-chart-1 shrink-0"}),e[10]=m):m=e[10];let p;e[11]!==a?(p=a.toFixed(1),e[11]=a,e[12]=p):p=e[12];let _;e[13]!==p?(_=n.jsxs("div",{className:"flex items-center gap-1.5",children:[m,n.jsxs("span",{className:"text-xs text-muted-foreground",children:["User ",p,"%"]})]}),e[13]=p,e[14]=_):_=e[14];let g;e[15]===Symbol.for("react.memo_cache_sentinel")?(g=n.jsx("span",{className:"inline-block h-2 w-2 rounded-sm bg-chart-2 shrink-0"}),e[15]=g):g=e[15];let v;e[16]!==l?(v=l.toFixed(1),e[16]=l,e[17]=v):v=e[17];let y;e[18]!==v?(y=n.jsxs("div",{className:"flex items-center gap-1.5",children:[g,n.jsxs("span",{className:"text-xs text-muted-foreground",children:["Assistant ",v,"%"]})]}),e[18]=v,e[19]=y):y=e[19];let x;e[20]!==h||e[21]!==r?(x=r>0&&n.jsxs("div",{className:"flex items-center gap-1.5",children:[n.jsx("span",{className:"inline-block h-2 w-2 rounded-sm bg-muted-foreground/30 shrink-0"}),n.jsxs("span",{className:"text-xs text-muted-foreground",children:["Other ",h.toFixed(1),"%"]})]}),e[20]=h,e[21]=r,e[22]=x):x=e[22];let b;e[23]!==y||e[24]!==x||e[25]!==_?(b=n.jsxs("div",{className:"flex flex-wrap gap-x-3 gap-y-1",children:[_,y,x]}),e[23]=y,e[24]=x,e[25]=_,e[26]=b):b=e[26];let S;return e[27]!==b||e[28]!==f?(S=n.jsxs("div",{className:"flex flex-col gap-2",children:[f,b]}),e[27]=b,e[28]=f,e[29]=S):S=e[29],S}function qm(t){const e=W.c(11),{agentId:s,isError:i}=t,r=It(s),o=r?.title??"Subtask",a=r?.icon??null;let l;e[0]!==a||e[1]!==o?(l=n.jsx(Vt,{icon:a,name:o,size:"xs",className:"size-6 rounded-md shrink-0"}),e[0]=a,e[1]=o,e[2]=l):l=e[2];const h=i?"text-destructive":"text-foreground";let c;e[3]!==h?(c=oe("shrink-0 font-medium",h),e[3]=h,e[4]=c):c=e[4];let d;e[5]!==o||e[6]!==c?(d=n.jsx("span",{className:c,children:o}),e[5]=o,e[6]=c,e[7]=d):d=e[7];let u;return e[8]!==l||e[9]!==d?(u=n.jsxs(n.Fragment,{children:[l,d]}),e[8]=l,e[9]=d,e[10]=u):u=e[10],u}function Gm(t){const e=W.c(5),{isError:s}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=n.jsx(Vt,{icon:null,name:"Subtask",size:"xs",className:"size-6 rounded-md shrink-0"}),e[0]=i):i=e[0];const r=s?"text-destructive":"text-foreground";let o;e[1]!==r?(o=oe("shrink-0 font-medium",r),e[1]=r,e[2]=o):o=e[2];let a;return e[3]!==o?(a=n.jsxs(n.Fragment,{children:[i,n.jsx("span",{className:o,children:"Subtask"})]}),e[3]=o,e[4]=a):a=e[4],a}function Ym(t){const e=W.c(18),{part:s}=t,i=s.input?.agent_id,r=s.state==="input-streaming"||s.state==="input-available"||s.state==="output-available"&&s.preliminary===!0,o=s.state==="output-error",a=s.state==="approval-requested";let l;e[0]!==o?(l=n.jsx(Gm,{isError:o}),e[0]=o,e[1]=l):l=e[1];let h;e[2]!==i||e[3]!==o?(h=n.jsx(qm,{agentId:i,isError:o}),e[2]=i,e[3]=o,e[4]=h):h=e[4];let c;e[5]!==l||e[6]!==h?(c=n.jsx(P.Suspense,{fallback:l,children:h}),e[5]=l,e[6]=h,e[7]=c):c=e[7];let d;e[8]!==s.input?(d=s.input?.prompt&&n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"text-muted-foreground/50",children:"·"}),n.jsx("span",{className:"truncate text-muted-foreground",children:s.input.prompt})]}),e[8]=s.input,e[9]=d):d=e[9];let u;e[10]!==a||e[11]!==o||e[12]!==r?(u=n.jsx("span",{className:"ml-auto shrink-0",children:r?n.jsx(we,{size:12,className:"animate-spin text-muted-foreground"}):o?n.jsx($u,{size:12,className:"text-destructive"}):a?n.jsx(Fi,{size:12,className:"text-warning"}):n.jsx(jc,{size:12,className:"text-emerald-500"})}),e[10]=a,e[11]=o,e[12]=r,e[13]=u):u=e[13];let f;return e[14]!==c||e[15]!==d||e[16]!==u?(f=n.jsxs("div",{className:"flex items-center gap-2 text-xs min-w-0",children:[c,d,u]}),e[14]=c,e[15]=d,e[16]=u,e[17]=f):f=e[17],f}function Xm(t){const e=W.c(55),{onClose:s,back:i,className:r}=t,[o,a]=P.useState(null),{messages:l}=Cs(),{activeTask:h}=ts(),{selectedModel:c,selectedVirtualMcp:d}=Do();let u,f,m,p,_,g,v,y;if(e[0]!==h||e[1]!==i||e[2]!==r||e[3]!==l||e[4]!==s||e[5]!==o?.id||e[6]!==c||e[7]!==d?.title){y=Symbol.for("react.early_return_sentinel");e:{const S=Fu(l),w=[...l].reverse().find(ap),k=w?.metadata?.usage,N=w?.metadata?.modelLimits?.contextWindow??c?.limits?.contextWindow??null,I=k?.contextTokens??0,D=N&&N>0?(I/N*100).toFixed(1):null,R=l;let j;e[16]!==R?(j=R.filter(op).reduce(np,0),e[16]=R,e[17]=j):j=e[17];const C=j,A=l;let E;e[18]!==A?(E=A.filter(rp).reduce(ip,0),e[18]=A,e[19]=E):E=e[19];const T=E,L=Math.max(0,S.totalTokens-C-T),B=l[0],O=l.at(-1),F=B?.metadata?.created_at??h?.created_at,H=O?.metadata?.created_at??h?.updated_at,M=l.filter(sp),U=l.flatMap(ep),V=c?.modelId?Wm(c.modelId):"—",K=d?.title??"Decopilot",Y=[{label:"Session",value:h?.title??"New chat"},{label:"Messages",value:M.length},{label:"Agent",value:K},{label:"Model",value:V},{label:"Context Limit",value:N?ci(N):"—"},{label:"Session Tokens (billed)",value:S.totalTokens>0?ci(S.totalTokens):"0"},{label:"Usage",value:D!==null?`${D}%`:"—"},{label:"Input Tokens",value:S.inputTokens>0?ci(S.inputTokens):"0"},{label:"Output Tokens",value:S.outputTokens>0?ci(S.outputTokens):"0"},{label:"Reasoning Tokens",value:S.reasoningTokens>0?ci(S.reasoningTokens):"0"},{label:"Cost",value:S.cost>0?`$${S.cost<.001?S.cost.toFixed(6):S.cost.toFixed(4)}`:"$0.00"},{label:"Session Created",value:Wa(F)},{label:"Last Activity",value:Wa(H)}];if(!h&&M.length===0){let z;e[20]!==r?(z=oe("flex flex-col h-full w-full border-l border-border bg-background",r),e[20]=r,e[21]=z):z=e[21];let te;e[22]===Symbol.for("react.memo_cache_sentinel")?(te=n.jsx("span",{className:"text-sm font-medium text-foreground",children:"Context"}),e[22]=te):te=e[22];let ee;e[23]!==i?(ee=i?n.jsx(Da,{size:14,className:"text-muted-foreground"}):n.jsx(fs,{size:14,className:"text-muted-foreground"}),e[23]=i,e[24]=ee):ee=e[24];let q;e[25]!==s||e[26]!==ee?(q=n.jsxs("div",{className:"h-11 px-4 flex items-center justify-between shrink-0 border-b border-border/50",children:[te,n.jsx("button",{type:"button",onClick:s,className:"flex size-6 items-center justify-center rounded hover:bg-accent transition-colors",children:ee})]}),e[25]=s,e[26]=ee,e[27]=q):q=e[27];let $;e[28]===Symbol.for("react.memo_cache_sentinel")?($=n.jsx("div",{className:"flex-1 flex items-center justify-center px-4 text-center",children:n.jsx("p",{className:"text-xs text-muted-foreground",children:"Start a conversation to see context"})}),e[28]=$):$=e[28];let ae;e[29]!==z||e[30]!==q?(ae=n.jsxs("div",{className:z,children:[q,$]}),e[29]=z,e[30]=q,e[31]=ae):ae=e[31],y=ae;break e}e[32]!==r?(g=oe("flex flex-col h-full w-full border-l border-border bg-background overflow-y-auto",r),e[32]=r,e[33]=g):g=e[33];let Q;e[34]===Symbol.for("react.memo_cache_sentinel")?(Q=n.jsx("span",{className:"text-sm font-medium text-foreground",children:"Context"}),e[34]=Q):Q=e[34];let se;e[35]!==i?(se=i?n.jsx(Da,{size:14}):n.jsx(fs,{size:14}),e[35]=i,e[36]=se):se=e[36],e[37]!==s||e[38]!==se?(v=n.jsxs("div",{className:"flex h-11 shrink-0 items-center justify-between border-b border-border/50 px-4",children:[Q,n.jsx("button",{type:"button",onClick:s,className:"flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-accent hover:text-foreground",children:se})]}),e[37]=s,e[38]=se,e[39]=v):v=e[39],u="flex flex-col gap-8 p-6",f=U.length>0&&n.jsxs("div",{className:"flex flex-col gap-3",children:[n.jsx("span",{className:"text-xs text-muted-foreground",children:"Subtasks"}),n.jsx("div",{className:"flex flex-col gap-1",children:U.map(Qm)})]}),m=n.jsx(Um,{items:Y});let he;e[40]===Symbol.for("react.memo_cache_sentinel")?(he=n.jsx("span",{className:"text-xs text-muted-foreground",children:"Context Breakdown"}),e[40]=he):he=e[40],e[41]!==T||e[42]!==L||e[43]!==C?(p=n.jsxs("div",{className:"flex flex-col gap-3",children:[he,n.jsx(Vm,{userTokens:C,assistantTokens:T,otherTokens:L})]}),e[41]=T,e[42]=L,e[43]=C,e[44]=p):p=e[44],_=M.length>0&&n.jsxs("div",{className:"flex flex-col gap-3",children:[n.jsx("span",{className:"text-xs text-muted-foreground",children:"Raw messages"}),n.jsx("div",{className:"flex flex-col gap-1",children:M.map(z=>{const te=z.metadata?.created_at,ee=o?.id===z.id;return n.jsxs("div",{className:"rounded-md border border-border/50 overflow-hidden",children:[n.jsxs("button",{type:"button",onClick:()=>a(ee?null:z),className:"flex items-center justify-between gap-2 px-3 py-2 text-xs hover:bg-accent/50 w-full text-left cursor-pointer",children:[n.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[n.jsx("span",{className:oe("shrink-0 font-medium",z.role==="user"?"text-chart-1":"text-chart-2"),children:z.role}),n.jsx("span",{className:"text-muted-foreground",children:"•"}),n.jsx("span",{className:"truncate text-muted-foreground font-mono",children:z.id})]}),te&&n.jsx("span",{className:"shrink-0 text-muted-foreground tabular-nums",children:new Date(te).toLocaleString("en-US",{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit"})})]}),ee&&n.jsxs(n.Fragment,{children:[z.role==="assistant"&&(()=>{const q=z.metadata?._request;if(!q)return null;const $=q.systemSections??[],ae=Math.max(1,...$.map(Zm)),de=$.reduce(Jm,0);return n.jsxs("div",{className:"border-t border-border/50 px-3 py-2.5 text-xs space-y-2.5",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx("span",{className:"font-medium text-foreground",children:"Request"}),n.jsxs("span",{className:"text-muted-foreground tabular-nums",children:[q.activeTools??0," / ",q.tools??0," ","tools active"]})]}),$.length>0&&n.jsxs("div",{className:"space-y-1.5",children:[n.jsxs("div",{className:"text-muted-foreground",children:["System prompt"," ",n.jsxs("span",{className:"tabular-nums",children:["~",Math.round(de/4).toLocaleString()," ","tok"]})]}),$.map((me,le)=>{const G=me.preview.match(/^<([a-z-]+)/i)?.[1]??`section ${le}`,pe=me.chars/ae*100,ue=Math.round(me.chars/4);return n.jsxs("div",{className:"space-y-0.5",children:[n.jsxs("div",{className:"flex items-center justify-between gap-2",children:[n.jsx("span",{className:"font-mono text-foreground truncate",children:G}),n.jsxs("span",{className:"text-muted-foreground tabular-nums shrink-0",children:["~",ue.toLocaleString()," tok"]})]}),n.jsx("div",{className:"h-1 w-full rounded-full bg-muted overflow-hidden",children:n.jsx("div",{className:"h-full rounded-full bg-chart-3",style:{width:`${pe}%`}})})]},le)})]})]})})(),n.jsx("pre",{className:"text-xs font-mono bg-muted px-3 py-2 overflow-auto whitespace-pre-wrap break-all border-t border-border/50 max-h-64",children:JSON.stringify(z,null,2)})]})]},z.id)})})]})}e[0]=h,e[1]=i,e[2]=r,e[3]=l,e[4]=s,e[5]=o?.id,e[6]=c,e[7]=d?.title,e[8]=u,e[9]=f,e[10]=m,e[11]=p,e[12]=_,e[13]=g,e[14]=v,e[15]=y}else u=e[8],f=e[9],m=e[10],p=e[11],_=e[12],g=e[13],v=e[14],y=e[15];if(y!==Symbol.for("react.early_return_sentinel"))return y;let x;e[45]!==u||e[46]!==f||e[47]!==m||e[48]!==p||e[49]!==_?(x=n.jsxs("div",{className:u,children:[f,m,p,_]}),e[45]=u,e[46]=f,e[47]=m,e[48]=p,e[49]=_,e[50]=x):x=e[50];let b;return e[51]!==g||e[52]!==v||e[53]!==x?(b=n.jsxs("div",{className:g,children:[v,x]}),e[51]=g,e[52]=v,e[53]=x,e[54]=b):b=e[54],b}function Jm(t,e){return t+e.chars}function Zm(t){return t.chars}function Qm(t,e){return n.jsx(Ym,{part:t},e)}function ep(t){return(t.parts??[]).filter(tp)}function tp(t){return t.type==="tool-subtask"}function sp(t){return t.role!=="system"}function ip(t,e){const s=e.metadata?.usage;return t+(s?.outputTokens??0)}function rp(t){return t.role==="assistant"}function np(t,e){const s=e.metadata?.usage;return t+(s?.inputTokens??0)}function op(t){return t.role==="user"}function ap(t){return t.role==="assistant"&&t.metadata?.usage}function lp(t){const e=W.c(13),{readOnly:s,identity:i,aboveRow:r,input:o,iceBreakers:a}=t,l=!s&&i?i:null;let h;e[0]!==r||e[1]!==s?(h=!s&&r?n.jsx("div",{"data-chat-above-row":"true",className:"@container/chat-bottom flex justify-start gap-1",children:r}):null,e[0]=r,e[1]=s,e[2]=h):h=e[2];let c;e[3]!==o||e[4]!==h?(c=n.jsxs("div",{className:"flex flex-col gap-2",children:[h,o]}),e[3]=o,e[4]=h,e[5]=c):c=e[5];let d;e[6]!==a||e[7]!==s?(d=!s&&a?n.jsx("div",{className:"w-full",children:a}):null,e[6]=a,e[7]=s,e[8]=d):d=e[8];let u;return e[9]!==l||e[10]!==c||e[11]!==d?(u=n.jsx("div",{"data-chat-centered":"true",className:"h-full w-full flex flex-col items-center justify-center px-4 gap-6",children:n.jsxs("div",{className:"w-full max-w-3xl flex flex-col gap-6",children:[l,c,d]})}),e[9]=l,e[10]=c,e[11]=d,e[12]=u):u=e[12],u}function cp(t){const e=W.c(25),{onOpenContextPanel:s}=t,{org:i}=Te(),{selectedVirtualMcp:r}=Do();let o;e[0]!==i.id?(o=Po(i.id),e[0]=i.id,e[1]=o):o=e[1];const l=r??o,h=It(l.id),c=kc(),{data:d}=Vs.useSession(),u=d?.user?.id,f=c?.activeTask??null,m=!!(u&&f?.created_by&&f.created_by!==u);let p;e[2]===Symbol.for("react.memo_cache_sentinel")?(p=n.jsx(Xu,{size:32}),e[2]=p):p=e[2];let _;e[3]!==l.icon||e[4]!==l.title?(_=n.jsx(Vt,{icon:l.icon,name:l.title,size:"lg",fallbackIcon:p,className:"size-10 min-w-10 md:size-[60px]! md:min-w-[60px] rounded-xl md:rounded-[18px]!"}),e[3]=l.icon,e[4]=l.title,e[5]=_):_=e[5];let g;e[6]!==l.title?(g=n.jsx("h3",{className:"text-base md:text-xl font-medium text-foreground",children:l.title}),e[6]=l.title,e[7]=g):g=e[7];const v=l.description??"Ask anything about configuring model providers or using MCP Mesh.";let y;e[8]!==v?(y=n.jsx("div",{className:"text-muted-foreground text-center text-base max-w-md line-clamp-2",children:v}),e[8]=v,e[9]=y):y=e[9];let x;e[10]!==_||e[11]!==g||e[12]!==y?(x=n.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 md:gap-4 text-center",children:[_,g,y]}),e[10]=_,e[11]=g,e[12]=y,e[13]=x):x=e[13];const b=c?.currentBranch??null;let S;e[14]!==h||e[15]!==b?(S=n.jsx(Cu,{virtualMcp:h,currentBranch:b}),e[14]=h,e[15]=b,e[16]=S):S=e[16];let w;e[17]!==s?(w=n.jsx(Me.Input,{onOpenContextPanel:s}),e[17]=s,e[18]=w):w=e[18];let k;e[19]===Symbol.for("react.memo_cache_sentinel")?(k=n.jsx(Me.IceBreakers,{}),e[19]=k):k=e[19];let N;return e[20]!==m||e[21]!==w||e[22]!==x||e[23]!==S?(N=n.jsx(lp,{readOnly:m,identity:x,aboveRow:S,input:w,iceBreakers:k}),e[20]=m,e[21]=w,e[22]=x,e[23]=S,e[24]=N):N=e[24],N}function Ua(t){const e=W.c(17),{outputs:s,collapsed:i,onToggle:r,variant:o}=t,a=o==="card"?"rounded-xl border border-border bg-muted/95 shadow-sm backdrop-blur-sm":"border-b border-border bg-background";let l;e[0]!==a?(l=oe(a),e[0]=a,e[1]=l):l=e[1];let h;e[2]===Symbol.for("react.memo_cache_sentinel")?(h=n.jsx("span",{className:"text-sm font-medium text-foreground",children:"Files in this task"}),e[2]=h):h=e[2];const c=i&&"-rotate-90";let d;e[3]!==c?(d=oe("size-4 text-muted-foreground transition-transform",c),e[3]=c,e[4]=d):d=e[4];let u;e[5]!==d?(u=n.jsx(ks,{className:d}),e[5]=d,e[6]=u):u=e[6];let f;e[7]!==r||e[8]!==u?(f=n.jsxs("button",{type:"button",onClick:r,className:"flex w-full items-center justify-between px-3 py-2.5 text-left",children:[h,u]}),e[7]=r,e[8]=u,e[9]=f):f=e[9];let m;e[10]!==i||e[11]!==s?(m=!i&&n.jsx("div",{className:"flex max-h-72 flex-col gap-1.5 overflow-y-auto px-2 pb-2",children:s.map(hp)}),e[10]=i,e[11]=s,e[12]=m):m=e[12];let p;return e[13]!==l||e[14]!==f||e[15]!==m?(p=n.jsxs("div",{className:l,children:[f,m]}),e[13]=l,e[14]=f,e[15]=m,e[16]=p):p=e[16],p}function hp(t){return n.jsx(Wu,{file:t},t.key)}function dp(){const t=W.c(13),e=kc()?.taskId??null,s=Hu();let i;t[0]!==s?(i={enabled:s},t[0]=s,t[1]=i):i=t[1];const{data:r}=Ec(e,i),[o,a]=P.useState(!1),[l,h]=P.useState(!0);if(!e||!r||r.length===0)return null;let c;t[2]===Symbol.for("react.memo_cache_sentinel")?(c=()=>a(fp),t[2]=c):c=t[2];let d;t[3]!==o||t[4]!==r?(d=n.jsx("div",{className:"absolute top-2 right-2 z-10 hidden w-72 @[1280px]:block",children:n.jsx(Ua,{variant:"card",outputs:r,collapsed:o,onToggle:c})}),t[3]=o,t[4]=r,t[5]=d):d=t[5];let u;t[6]===Symbol.for("react.memo_cache_sentinel")?(u=()=>h(up),t[6]=u):u=t[6];let f;t[7]!==l||t[8]!==r?(f=n.jsx("div",{className:"shrink-0 @[1280px]:hidden",children:n.jsx(Ua,{variant:"bar",outputs:r,collapsed:l,onToggle:u})}),t[7]=l,t[8]=r,t[9]=f):f=t[9];let m;return t[10]!==d||t[11]!==f?(m=n.jsxs(n.Fragment,{children:[d,f]}),t[10]=d,t[11]=f,t[12]=m):m=t[12],m}function up(t){return!t}function fp(t){return!t}function mp(){const t=W.c(28),{org:e}=Te(),s=Tc(),{isChatEmpty:i}=Cs(),[r,o]=P.useState("chat"),a=ku(),{selectedVirtualMcp:l}=Do();let h;t[0]!==e.id?(h=Po(e.id),t[0]=e.id,t[1]=h):h=t[1];const u=It((l??h).id),f=Bu(),m=Xs(u?.metadata);if(s.length===0&&!(m&&ju(f))){let R;return t[2]===Symbol.for("react.memo_cache_sentinel")?(R=n.jsx(Me,{className:"animate-in fade-in-0 duration-200",children:n.jsx(Me.Main,{className:"flex flex-col items-center",children:n.jsx(Me.EmptyState,{children:n.jsx(Me.NoAiProviderEmptyState,{})})})}),t[2]=R):R=t[2],R}let _;t[3]!==a.hasDecoKey||t[4]!==a.hasOnlyDecoProvider||t[5]!==a.isLoading||t[6]!==a.isZeroBalance||t[7]!==i||t[8]!==e.id?(_=a.hasDecoKey&&a.isZeroBalance&&a.hasOnlyDecoProvider&&!a.isLoading&&i&&!Nu(e.id),t[3]=a.hasDecoKey,t[4]=a.hasOnlyDecoProvider,t[5]=a.isLoading,t[6]=a.isZeroBalance,t[7]=i,t[8]=e.id,t[9]=_):_=t[9];const g=_;let v;t[10]!==g?(v=g&&n.jsx(Me.CreditsEmptyState,{}),t[10]=g,t[11]=v):v=t[11];const y=r!=="chat"?"opacity-0 pointer-events-none":"opacity-100";let x;t[12]!==y?(x=oe("absolute inset-0 flex flex-col transition-opacity duration-100 ease-out",y),t[12]=y,t[13]=x):x=t[13];let b;t[14]!==i?(b=i?n.jsx(Me.Main,{children:n.jsx(cp,{onOpenContextPanel:()=>o("context")})}):n.jsxs(n.Fragment,{children:[n.jsxs(Me.Main,{className:"relative flex flex-col overflow-hidden @container",children:[n.jsx(dp,{}),n.jsx("div",{className:"min-h-0 flex-1",children:n.jsx(Me.Messages,{})})]}),n.jsx(Me.Footer,{children:n.jsx(Me.Input,{onOpenContextPanel:()=>o("context")})})]}),t[14]=i,t[15]=b):b=t[15];let S;t[16]!==x||t[17]!==b?(S=n.jsx("div",{className:x,children:b}),t[16]=x,t[17]=b,t[18]=S):S=t[18];const w=r==="context"?"opacity-100":"opacity-0 pointer-events-none";let k;t[19]!==w?(k=oe("absolute inset-0 flex flex-col transition-opacity duration-100 ease-out",w),t[19]=w,t[20]=k):k=t[20];let N;t[21]===Symbol.for("react.memo_cache_sentinel")?(N=n.jsx(Xm,{back:!0,onClose:()=>o("chat")}),t[21]=N):N=t[21];let I;t[22]!==k?(I=n.jsx("div",{className:k,children:N}),t[22]=k,t[23]=I):I=t[23];let D;return t[24]!==I||t[25]!==v||t[26]!==S?(D=n.jsxs(Me,{className:"relative overflow-hidden animate-in fade-in-0 duration-200",children:[v,S,I]}),t[24]=I,t[25]=v,t[26]=S,t[27]=D):D=t[27],D}function th(){const t=W.c(2);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsx(Me.Skeleton,{}),t[0]=e):e=t[0];let s;return t[1]===Symbol.for("react.memo_cache_sentinel")?(s=n.jsx(Ht,{fallback:e,children:n.jsx(P.Suspense,{fallback:n.jsx(Me.Skeleton,{}),children:n.jsx(mp,{})})}),t[1]=s):s=t[1],s}function pp(t){const e=t.entityMetadata?.defaultMainView??null,s=e==null||e.type==="chat",i=t.mainParamPresent?t.mainParamValue!=="0":!s,r=s?!0:t.entityMetadata?.chatDefaultOpen??!1;return{mainOpen:i,chatOpen:r}}function Ka(t,e){return t&&e?{chat:45,main:55}:t&&!e?{chat:100,main:0}:!t&&e?{chat:0,main:100}:{chat:0,main:0}}function _p(t,e){return t===1?!0:t===0?!1:e}function gp(t,e){const s=es(),i=To({strict:!1}),r=xc({strict:!1}),{create:o}=Rf(),{locator:a}=Te(),{virtualMcpId:l,orgSlug:h,isAgentRoute:c}=e,d=pp({entityMetadata:t,mainParamPresent:i.main!==void 0,mainParamValue:i.main}),u=_p(i.chat,d.chatOpen),f=d.mainOpen,m=P.useRef(crypto.randomUUID()),p=r.taskId??m.current,_="/$org/$taskId",g=I=>({org:h,taskId:I}),v=c?{virtualmcpid:l}:{},y=(I,D)=>{s({to:_,params:g(p),search:R=>({...R,...I}),replace:D?.replace??!1})},x=(I,D)=>{s({to:_,params:g(I),search:R=>{const j={};return D?j.virtualmcpid=D:c&&(j.virtualmcpid=l),j}})},b=()=>{f?y({main:"0"},{replace:!0}):y({main:Bn(t)},{replace:!0})},S=()=>{y({chat:u?0:1},{replace:!0})},w=()=>{u||y({chat:1},{replace:!0})},k=async()=>{const I=crypto.randomUUID(),D=Ju(h,a,p);try{await o({id:I,virtual_mcp_id:l,...D?{branch:D}:{}})}catch{}s({to:_,params:g(I),search:R=>({...v,chat:1})})},N=I=>{y({main:I},{replace:!0})};return{taskId:p,mainOpen:f,chatOpen:u,mainParam:i.main,setTaskId:x,toggleMain:b,toggleChat:S,openChat:w,createNewTask:k,openTab:N}}const qo=45;function sh(t,e=qo){const s=typeof t=="number"?t:Number(t);return!Number.isFinite(s)||s<=0||s>=100?e:s}function vp(t){return sh(t,qo)}function xp(){const t=W.c(6);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=pu.decoChatPanelWidth(),t[0]=e):e=t[0];const[s,i]=mu(e,vp);let r;t[1]!==s?(r=sh(s,qo),t[1]=s,t[2]=r):r=t[2];const o=r;let a;return t[3]!==i||t[4]!==o?(a=[o,i],t[3]=i,t[4]=o,t[5]=a):a=t[5],a}function bp(t){try{return JSON.parse(t)}catch{return null}}function yp(t){if(!t||typeof t!="object")return null;const e=t,s=e.content?.find(o=>o.type==="text")?.text,i=s?bp(s):null,r=e.structuredContent;return r==null?i:typeof r=="object"&&!Array.isArray(r)&&Object.keys(r).length===0?i??r:r}function Rs(t){const e=yp(t);return e===null?null:e}function Go(t){if(!t)return null;const e=t.match(/\/pull\/(\d+)\b/);if(!e)return null;const s=Number(e[1]);return Number.isFinite(s)&&s>0?s:null}function Sp(t){if(!t||typeof t!="object")return null;const e=t.content?.find(r=>r.type==="text")?.text;if(!e)return null;const s=e.match(/https:\/\/github\.com\/[^\s"]+\/pull\/\d+/)?.[0],i=Go(s);return!i||!s?null:{number:i,htmlUrl:s}}const Va=/[\r\n<>]/,wp=/^[^\s@<>]+@[^\s@<>]+\.[^\s@<>]+$/;function Ui(t){const e=t?.userName?.trim();if(!e||Va.test(e))return null;const s=t?.userEmail?.trim();return!s||Va.test(s)?{userName:e}:wp.test(s)?{userName:e,userEmail:s}:{userName:e}}function Cp(t){return t.split(`
3
3
  `).filter(e=>!/^Co-authored-by:\s/i.test(e)).join(`
4
4
  `).trimEnd()}function kp(t){const e=t.userName.trim(),s=t.userEmail?.trim();return s?`Co-authored-by: ${e} <${s}>`:`Co-authored-by: ${e}`}function ih(t,e){const s=Ui(e);if(!s)return t;const i=Cp(t),r=kp(s);if(i.includes(r))return i;const o=i.trimEnd();return o.length>0?`${o}
5
5
 
@@ -273,7 +273,7 @@ ${te}`:te;c.setValue("metadata.instructions",ee,{shouldDirty:!0})},K=new Set(d.m
273
273
  8% { opacity: 1; }
274
274
  22% { opacity: 0; }
275
275
  }
276
- `}),e[26]=b):b=e[26];let S;return e[27]!==x||e[28]!==d?(S=n.jsxs("div",{className:"relative flex w-full flex-col items-center justify-center gap-12 select-none [clip-path:inset(-24px_0_-200px_0)]",children:[d,x,b]}),e[27]=x,e[28]=d,e[29]=S):S=e[29],S}function er(t){const e=W.c(10),{phase:s,current:i,children:r}=t,o=s-i,a=o<0,l=o===0,h=a?90:o*-22,c=a?.94:1-Math.max(o,0)*.04,d=a?0:l?1:o===1?.8:.55,u=a?10:30-o,f=!l;let m;e[0]===Symbol.for("react.memo_cache_sentinel")?(m=oe("absolute inset-0 overflow-hidden rounded-xl border border-foreground/10 bg-background shadow-[0_20px_60px_-20px_rgb(0_0_0_/_0.35)] transition-all ease-[cubic-bezier(0.22,1,0.36,1)]"),e[0]=m):m=e[0];const p=`translateY(${h}px) scale(${c})`,_=l?"auto":"none";let g;e[1]!==d||e[2]!==p||e[3]!==_||e[4]!==u?(g={transform:p,opacity:d,zIndex:u,transitionDuration:"1000ms",pointerEvents:_},e[1]=d,e[2]=p,e[3]=_,e[4]=u,e[5]=g):g=e[5];let v;return e[6]!==r||e[7]!==f||e[8]!==g?(v=n.jsx("div",{"aria-hidden":f,className:m,style:g,children:r}),e[6]=r,e[7]=f,e[8]=g,e[9]=v):v=e[9],v}function tn(t){const e=W.c(7),{showUrl:s}=t,i=s===void 0?!1:s;let r,o,a;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=n.jsx("div",{className:oe("size-2.5 rounded-full",St)}),o=n.jsx("div",{className:oe("size-2.5 rounded-full",St)}),a=n.jsx("div",{className:oe("size-2.5 rounded-full",St)}),e[0]=r,e[1]=o,e[2]=a):(r=e[0],o=e[1],a=e[2]);let l;e[3]!==i?(l=i&&n.jsx("div",{className:oe("ml-3 h-3.5 max-w-[220px] flex-1 rounded-sm",zt)}),e[3]=i,e[4]=l):l=e[4];let h;return e[5]!==l?(h=n.jsxs("div",{className:"flex h-7 shrink-0 items-center gap-1.5 px-3",children:[r,o,a,l]}),e[5]=l,e[6]=h):h=e[6],h}function Xv(){const t=W.c(2);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsx(tn,{}),t[0]=e):e=t[0];let s;return t[1]===Symbol.for("react.memo_cache_sentinel")?(s=n.jsxs("div",{className:"flex h-full flex-col",children:[e,n.jsx("div",{className:"flex flex-1 px-8 py-5",children:n.jsx("div",{className:"grid h-full w-full grid-cols-8 grid-rows-6 gap-2",children:Uv.map(Jv)})})]}),t[1]=s):s=t[1],s}function Jv(t,e){if(e===Kh)return n.jsx("div",{className:"rounded-md bg-chart-1/[0.55]",style:{animation:"vm-breathe 2.4s ease-in-out infinite"}},e);const s=t;return n.jsx("div",{className:oe("relative rounded-md",St),children:n.jsx("div",{className:"absolute inset-0 rounded-md bg-chart-1/40 opacity-0",style:{animation:`vm-rack-scan ${Vh}s ease-in-out infinite`,animationDelay:`${s}s`}})},e)}function Zv(){const t=W.c(5);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsx(tn,{}),t[0]=e):e=t[0];let s;t[1]===Symbol.for("react.memo_cache_sentinel")?(s=n.jsx("div",{className:oe("w-[18%] rounded-md",zt),style:{animation:"vm-breathe 3s ease-in-out infinite"}}),t[1]=s):s=t[1];let i;t[2]===Symbol.for("react.memo_cache_sentinel")?(i=n.jsx("div",{className:"h-[42%] shrink-0 rounded-md bg-chart-3/[0.12]",style:{animation:"vm-breathe 3s ease-in-out 0.4s infinite"}}),t[2]=i):i=t[2];let r;t[3]===Symbol.for("react.memo_cache_sentinel")?(r=n.jsx("div",{className:"col-span-3 rounded-md bg-chart-3/[0.12]",style:{animation:"vm-breathe 3s ease-in-out 0.8s infinite"}}),t[3]=r):r=t[3];let o;return t[4]===Symbol.for("react.memo_cache_sentinel")?(o=n.jsxs("div",{className:"flex h-full flex-col",children:[e,n.jsxs("div",{className:"flex min-h-0 flex-1 gap-1.5 p-3",children:[s,n.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-1.5",children:[i,n.jsxs("div",{className:"grid min-h-0 flex-1 grid-cols-5 gap-1.5",children:[r,n.jsxs("div",{className:"col-span-2 grid grid-rows-2 gap-1.5",children:[n.jsx("div",{className:oe("rounded-md",zt),style:{animation:"vm-breathe 3s ease-in-out 1.2s infinite"}}),n.jsx("div",{className:oe("rounded-md",zt),style:{animation:"vm-breathe 3s ease-in-out 1.6s infinite"}})]})]})]})]})]}),t[4]=o):o=t[4],o}function Qv(){const t=W.c(2);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsx(tn,{}),t[0]=e):e=t[0];let s;return t[1]===Symbol.for("react.memo_cache_sentinel")?(s=n.jsxs("div",{className:"flex h-full flex-col",children:[e,n.jsx("div",{className:"relative flex flex-1 items-center justify-center px-8 py-5",children:n.jsx("div",{className:"grid w-full gap-2",style:{gridTemplateColumns:"repeat(7, minmax(0, 1fr))"},children:qv.map(e1)})})]}),t[1]=s):s=t[1],s}function e1(t,e){return n.jsx("div",{className:oe("aspect-square rounded-md",Gv[e]?"bg-chart-2/70":St),style:{animation:`vm-pulse-soft 2.2s ease-in-out ${t}s infinite`}},e)}function t1(){const t=W.c(11);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsx(tn,{showUrl:!0}),t[0]=e):e=t[0];let s,i,r,o,a;t[1]===Symbol.for("react.memo_cache_sentinel")?(s=n.jsx("div",{className:"mb-2 h-5 rounded-md bg-chart-1/[0.10]"}),i=n.jsx("div",{className:oe("h-1.5 w-[70%] rounded-sm",St)}),r=n.jsx("div",{className:oe("h-1.5 w-[55%] rounded-sm",St)}),o=n.jsx("div",{className:oe("h-1.5 w-[80%] rounded-sm",St)}),a=n.jsx("div",{className:oe("h-1.5 w-[50%] rounded-sm",St)}),t[1]=s,t[2]=i,t[3]=r,t[4]=o,t[5]=a):(s=t[1],i=t[2],r=t[3],o=t[4],a=t[5]);let l;t[6]===Symbol.for("react.memo_cache_sentinel")?(l=n.jsxs("div",{className:"flex w-[18%] shrink-0 flex-col gap-1.5 bg-chart-1/[0.05] p-2.5",children:[s,i,r,o,a,n.jsx("div",{className:"mt-auto",children:n.jsx("div",{className:oe("h-4 rounded-md",St)})})]}),t[6]=l):l=t[6];let h;t[7]===Symbol.for("react.memo_cache_sentinel")?(h=n.jsx("div",{className:"relative h-[42%] shrink-0 overflow-hidden bg-chart-1/[0.10]",children:n.jsxs("div",{className:"absolute right-3 bottom-3 left-3 space-y-1.5",children:[n.jsx("div",{className:"h-3 w-[35%] rounded-sm bg-chart-1/[0.15]"}),n.jsx("div",{className:oe("h-1.5 w-[55%] rounded-sm",zt)})]})}),t[7]=h):h=t[7];let c;t[8]===Symbol.for("react.memo_cache_sentinel")?(c=n.jsxs("div",{className:"flex shrink-0 gap-1.5",children:[n.jsx("div",{className:"h-4 w-12 rounded-full bg-chart-1/[0.12]"}),n.jsx("div",{className:oe("h-4 w-10 rounded-full",zt)}),n.jsx("div",{className:oe("h-4 w-14 rounded-full",zt)})]}),t[8]=c):c=t[8];let d;t[9]===Symbol.for("react.memo_cache_sentinel")?(d=n.jsxs("div",{className:oe("col-span-3 flex flex-col justify-end gap-1 rounded-md p-2",zt),children:[n.jsx("div",{className:oe("h-1.5 w-[50%] rounded-sm",St)}),n.jsx("div",{className:oe("h-1 w-[75%] rounded-sm",St)})]}),t[9]=d):d=t[9];let u;return t[10]===Symbol.for("react.memo_cache_sentinel")?(u=n.jsxs("div",{className:"flex h-full flex-col",children:[e,n.jsxs("div",{className:"flex min-h-0 flex-1",children:[l,n.jsxs("div",{className:"flex min-w-0 flex-1 flex-col",children:[h,n.jsxs("div",{className:"flex min-h-0 flex-1 flex-col gap-2.5 p-3",children:[c,n.jsxs("div",{className:"grid min-h-0 flex-1 grid-cols-5 gap-2",children:[d,n.jsxs("div",{className:"col-span-2 grid grid-rows-2 gap-2",children:[n.jsx("div",{className:oe("rounded-md",zt)}),n.jsx("div",{className:oe("rounded-md",zt)})]})]})]})]})]})]}),t[10]=u):u=t[10],u}function Br(t){const e=W.c(9);if(t.kind==="starting"){let l;return e[0]!==t.claimPhase||e[1]!==t.progress?(l=n.jsx("div",{className:"flex h-full w-full items-center justify-center bg-background p-6",children:n.jsx(Yv,{progress:t.progress,claimPhase:t.claimPhase})}),e[0]=t.claimPhase,e[1]=t.progress,e[2]=l):l=e[2],l}let s;e[3]===Symbol.for("react.memo_cache_sentinel")?(s=n.jsx(pf,{className:"size-12 text-blue-500"}),e[3]=s):s=e[3];let i,r;e[4]===Symbol.for("react.memo_cache_sentinel")?(i=n.jsx("h3",{className:"text-lg font-medium",children:Hv("suspended")}),r=n.jsx("p",{className:"max-w-sm text-sm text-muted-foreground",children:"Resume to continue."}),e[4]=i,e[5]=r):(i=e[4],r=e[5]);let o;e[6]===Symbol.for("react.memo_cache_sentinel")?(o=n.jsx(Hs,{className:"size-4"}),e[6]=o):o=e[6];let a;return e[7]!==t.onResume?(a=n.jsx("div",{className:"flex h-full w-full items-center justify-center bg-background p-6",children:n.jsxs("div",{className:"flex w-full max-w-md flex-col items-center gap-4 text-center",children:[s,i,r,n.jsxs(ie,{onClick:t.onResume,className:"mt-2",children:[o," Resume"]})]})}),e[7]=t.onResume,e[8]=a):a=e[8],a}const s1=P.lazy(()=>Kt(()=>import("./sections-editor-RaAaC45Z.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149])).then(t=>({default:t.SectionsEditor}))),i1=P.lazy(()=>Kt(()=>import("./page-seo-sheet-BL6Qr_fp.js"),__vite__mapDeps([150,1,2,28,29,45,46,47,16,3,5,85,71,79,76,6,7,8,9,10,11,12,13,14,15,4,17,18,19,20,21,22,23,24,25,26,27,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,77,49,78,72,50,80,48,81,82,83,57,84,59,60,89,90,91,92,93,94,95,96,97,98,99,100,101,56,102,58,103,104,105,106,107,65,108,55,109,70,110,69,66,111,112,113,114,115,64,116,86,87,51,52,53,54,61,62,63,67,68,73,74,75,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149])).then(t=>({default:t.SeoSheet}))),r1=P.lazy(()=>Kt(()=>import("./file-explorer-CHPSau6D.js"),__vite__mapDeps([151,1,2,134,110,6,7,8,9,10,11,12,13,14,15,16,3,4,5,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,125,97,98,57,99,100,84,101,56,102,58,103,104,48,105,106,107,49,119,120,121,81,78,69,122,108,123,55,66,113,124,61,62,63,70,71,126,51,52,53,54,59,60,64,65,67,68,72,73,74,75,86,87,127,128,129,91,92,89,90,93,94,95,96,109,82,111,112,114,115,116,117,50,118,130,131,132,133,135,136,79,137,138,139,140,141,142,143,144,145,146,147,148,149])).then(t=>({default:t.FileExplorer}))),pn=500,n1={mobile:375,tablet:768,desktop:null},_n=["desktop","mobile","tablet"],o1={mobile:"Mobile (375px)",tablet:"Tablet (768px)",desktop:"Desktop"};function a1(t,e){const s=new URL(t,window.location.href);return s.searchParams.set("deviceHint",e),s.href}function l1(){const t=Ji(),{currentBranch:e}=ts(),[s,i]=P.useState("preview"),[r,o]=P.useState("desktop"),[a,l]=P.useState(null),h=P.useRef(null),c=s==="cms",[d,u]=P.useState(null),[f,m]=P.useState(384),p=P.useRef(!1),_=P.useRef(0),g=P.useRef(0),v=P.useRef(null),[y,x]=P.useState(!1),[b,S]=P.useState(""),w=P.useRef(null),[k,N]=P.useState(!1),[I,D]=P.useState(),[R,j]=P.useState(null),[C,A]=P.useState(null),[E,T]=P.useState("/"),[L,B]=P.useState(!1),[O,F]=P.useState(!1),[H,M]=P.useState(null),U=t?.entity?.id??null,{org:V}=Te(),K=qt(),Y=zh(),Q=Y.vmEntry,se=Y.previewUrl,he=K.lifecycle.phase,z=he==="running",te=U&&e&&z?{orgSlug:V.slug,virtualMcpId:U,branch:e}:null,{data:ee}=Qo(te,{fetchEnabled:z}),{data:q}=ea(te,{fetchEnabled:z}),$=U&&e?{orgSlug:V.slug,virtualMcpId:U,branch:e}:null,ae=Dv($),de=ee?na(ee).sort((Z,ve)=>Z.name.localeCompare(ve.name)):[],me=ee&&q?oa(ee,q):[],le=Ei,G=de.filter(Z=>{if(!b)return!0;const ve=b.toLowerCase();return Z.name.toLowerCase().includes(ve)||Z.path.toLowerCase().includes(ve)}),pe=me.filter(Z=>{if(!b)return!0;const ve=b.toLowerCase();return Z.name.toLowerCase().includes(ve)||Z.key.toLowerCase().includes(ve)||Z.resolveType.toLowerCase().includes(ve)}),ue=R?null:de.find(Z=>le(Z.path)===le(E))??null,ze=R?R.name:ue?.name,ct=ue?.key??null,Pe=P.useRef(null),ft=P.useRef(null);f_(()=>{const Z=h.current,ve=Pe.current;!Z||!ve||(Z.src=ve)});const li=K.status.state==="paused",J=K.phase,xe=Uh({claimPhase:J,lifecycle:K.lifecycle}),fe=Y.previewState,Se=Y.userStopped,Ce=fe.kind==="iframe"?a1(C??new URL(E,fe.previewUrl).href,r):null,[Ye,ln]=P.useState(null);if(fe.kind==="iframe"&&Ye!==fe.previewUrl){const Z=Ye!==null;ln(fe.previewUrl),Z&&(ft.current=null,T("/"),A(null),j(null))}Pe.current=Ce;const Zi=!!U&&!!e&&!K.notFound&&!Se&&!li&&(J?.kind==="ready"||he!=="idle"),As=fe.kind!=="iframe"&&(s==="visual"||s==="cms")?"preview":s;P.useEffect(()=>{if(!se)return;let Z;try{Z=new URL(se,window.location.href).origin}catch{return}const ve=rt=>{if(rt.origin===Z){if(rt.data?.type==="visual-editor::element-clicked"){const nt=Iv.safeParse(rt.data.payload);nt.success&&l(nt.data)}else if(rt.data?.type==="cms-editor::section-clicked"){const nt=Lv.safeParse(rt.data.payload);nt.success&&u(nt.data.sectionIndex)}}};return window.addEventListener("message",ve),()=>window.removeEventListener("message",ve)},[se]),P.useEffect(()=>{if(!y)return;const Z=ve=>{w.current?.contains(ve.target)||(x(!1),S(""))};return document.addEventListener("pointerdown",Z),()=>document.removeEventListener("pointerdown",Z)},[y]),P.useEffect(()=>{if(!c)return;const Z=rt=>{const nt=rt.target;nt&&nt!==h.current&&(v.current=nt)},ve=()=>{requestAnimationFrame(()=>{const rt=document.activeElement;(rt===document.body||rt===h.current)&&v.current&&v.current.focus()})};return document.addEventListener("focusin",Z),document.addEventListener("blur",ve,!0),()=>{document.removeEventListener("focusin",Z),document.removeEventListener("blur",ve,!0)}},[c]);const ge=()=>{const Z=h.current?.contentWindow;Z&&Z.postMessage({type:"visual-editor::activate",script:Bv},"*")},Re=()=>{const Z=h.current?.contentWindow;Z&&Z.postMessage({type:"visual-editor::deactivate"},"*")},it=()=>{const Z=h.current?.contentWindow;Z&&Z.postMessage({type:"visual-editor::activate",script:Mv},"*")},xt=()=>{const Z=h.current?.contentWindow;Z&&Z.postMessage({type:"cms-editor::deactivate"},"*")},He=Z=>{const ve=s;i(Z),l(null),Z!=="code"&&M(null),Z!=="cms"&&u(null),ve==="visual"&&Re(),ve==="cms"&&xt(),Z==="visual"&&ge(),Z==="cms"&&it()},nu=()=>{if(!h.current||!Ce)return;const Z=h.current;Z.src=Ce},ou=()=>{if(!h.current||!Ce)return;const Z=Ce.includes("?")?"&":"?";h.current.src=`${Ce}${Z}_r=${Date.now()}`},au=()=>{const Z=_n.indexOf(r);o(_n[(Z+1)%_n.length])},lu=()=>{const Z=h.current?.contentWindow?.location?.href??Ce??se;Z&&navigator.clipboard.writeText(Z)},cu=(()=>{if(!se)return"No server running";if(R)return R.name;try{const Z=new URL(se),ve=E==="/"?"":E;return`${Z.host}${ve}`}catch{return se}})(),Ra=Z=>{ft.current=Z,j(null),A(null),T(Z),u(null),B(!1)},hu=Z=>{if(!se||!q){ne.error("Preview metadata not ready yet");return}ft.current=null;const ve=bh(q),rt=Ev(se,ve,Z.key);j(Z),A(rt),u(null)},du=async({name:Z,path:ve})=>{if(!U||!e)return;const rt=da(ve);if(rt){D(rt);return}const nt=ve.trim().startsWith("/")?ve.trim():`/${ve.trim()}`;if(de.some(Gt=>le(Gt.path)===le(nt))){D(`A page with path "${nt}" already exists.`);return}D(void 0);try{const Gt=await ae.mutateAsync({name:Z,path:nt});N(!1),ne.success(`Page "${Z}" created`),await new Promise(fu=>setTimeout(fu,pn)),Ra(Gt.path),He("cms")}catch(Gt){D(Gt instanceof Error?Gt.message:"Failed to create page")}},uu=[{value:"preview",icon:n.jsx(La,{size:14}),tooltip:"Interactive"},...fe.kind==="iframe"?[{value:"visual",icon:n.jsx(Ma,{size:14}),tooltip:"Visual editor"}]:[],...fe.kind==="iframe"&&ra(ee,q)?[{value:"cms",icon:n.jsx(_f,{size:14}),tooltip:"Sections editor"}]:[],{value:"code",icon:n.jsx(gf,{size:14}),tooltip:"Code editor"}];return n.jsxs("div",{className:"flex flex-col w-full h-full",children:[Zi&&n.jsxs("div",{className:"flex h-12 shrink-0 items-center gap-4 border-b border-border/60 px-3 md:px-4",children:[n.jsx("div",{className:"flex shrink-0 items-center gap-1",children:n.jsx(Sm,{value:As,onValueChange:He,options:uu,size:"sm",className:"shrink-0 bg-foreground/4.5"})}),fe.kind==="iframe"&&n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:oe("flex min-w-0 flex-1 items-center gap-0.5 ml-2",s==="code"&&"hidden"),children:[n.jsxs(Ne,{children:[n.jsx(ke,{asChild:!0,children:n.jsx(ie,{variant:"ghost",size:"icon",onClick:nu,children:n.jsx(Ai,{size:14})})}),n.jsx(je,{side:"bottom",children:"Refresh"})]}),n.jsxs(Ne,{children:[n.jsx(ke,{asChild:!0,children:n.jsx(ie,{variant:"ghost",size:"icon",onClick:au,children:n.jsxs("span",{className:"flex items-center justify-center animate-device-icon-pop",children:[r==="mobile"&&n.jsx(vf,{size:14}),r==="tablet"&&n.jsx(xf,{size:14}),r==="desktop"&&n.jsx(La,{size:14})]},r)})}),n.jsx(je,{side:"bottom",children:o1[r]})]}),n.jsxs("div",{ref:w,className:"relative min-w-0 flex-1",children:[n.jsxs("button",{type:"button",className:"flex h-8 w-full min-w-0 items-center gap-1 rounded-md bg-background px-2 transition-colors duration-200 hover:bg-accent",onClick:()=>x(Z=>!Z),children:[R&&n.jsxs("span",{className:"shrink-0 inline-flex items-center gap-1 rounded bg-global-section/14 px-1.5 py-0.5 text-[11px] font-medium text-global-section-fg dark:text-global-section-fg-dark",children:[n.jsx(Ws,{size:11}),"Global"]}),n.jsx("span",{className:"min-w-0 flex-1 truncate text-left text-[12px] text-foreground/88",children:cu}),ze&&!R&&n.jsx("span",{className:"shrink-0 text-[12px] text-muted-foreground",children:ze}),n.jsx(ks,{size:12,className:oe("shrink-0 text-muted-foreground transition-transform",y&&"rotate-180")})]}),y&&n.jsxs("div",{className:"absolute left-0 right-0 top-full z-50 mt-1.5 overflow-hidden rounded-lg border bg-popover shadow-lg",children:[n.jsxs("div",{className:"px-2 h-10 flex items-center gap-2 border-b",children:[n.jsx(Zc,{size:14,className:"shrink-0 text-muted-foreground","aria-hidden":!0}),n.jsx("input",{type:"text",value:b,onChange:Z=>S(Z.target.value),placeholder:"Search pages and components...",className:"w-full bg-transparent text-sm outline-none placeholder:text-muted-foreground",autoFocus:!0})]}),n.jsx("div",{className:"p-1.5 border-b",children:n.jsxs("button",{type:"button",className:"flex w-full items-center gap-2.5 rounded-md px-3 py-2.5 text-left text-sm hover:bg-accent hover:text-accent-foreground",onMouseDown:Z=>{Z.preventDefault(),x(!1),S(""),D(void 0),N(!0)},children:[n.jsx(At,{size:16,className:"shrink-0 text-muted-foreground"}),n.jsx("span",{className:"flex-1 font-medium",children:"Create new page"})]})}),G.length===0&&pe.length===0?n.jsx("div",{className:"px-4 py-5 text-center text-xs text-muted-foreground",children:de.length===0&&me.length===0?"No pages found in this site.":"No results match your search."}):n.jsxs("div",{className:"max-h-80 overflow-y-auto overscroll-contain",children:[G.length>0&&n.jsx("div",{className:"p-1.5",children:G.map(Z=>n.jsxs("button",{type:"button",className:"flex w-full items-center gap-3 rounded-md px-3 py-2.5 text-left text-sm hover:bg-accent hover:text-accent-foreground",onMouseDown:ve=>{ve.preventDefault(),x(!1),S(""),Ra(Z.path)},children:[n.jsx(Bo,{size:16,className:"shrink-0 text-muted-foreground"}),n.jsx("span",{className:"min-w-0 flex-1 truncate font-medium",children:Z.name}),n.jsx("span",{className:"shrink-0 text-xs text-muted-foreground",children:Z.path})]},Z.key))}),pe.length>0&&n.jsxs("div",{className:oe("p-1.5",G.length>0&&"border-t"),children:[n.jsx("div",{className:"px-3 py-2 text-xs font-medium text-muted-foreground",children:"Global components"}),pe.map(Z=>n.jsxs("button",{type:"button",className:"flex w-full items-center gap-3 rounded-md px-3 py-2.5 text-left text-sm hover:bg-accent hover:text-accent-foreground",onMouseDown:ve=>{ve.preventDefault(),x(!1),S(""),hu(Z)},children:[n.jsx(Ws,{size:16,className:"shrink-0 text-muted-foreground"}),n.jsx("span",{className:"min-w-0 flex-1 truncate font-medium",children:Z.name}),n.jsx("span",{className:"shrink-0 text-xs text-muted-foreground",children:Z.resolveType.split("/").pop()?.replace(/\.tsx?$/,"")})]},Z.key))]})]})]})]})]}),n.jsxs("div",{className:oe("flex shrink-0 items-center gap-0.5",s==="code"&&"hidden"),children:[n.jsxs(Ne,{children:[n.jsx(ke,{asChild:!0,children:n.jsx(ie,{variant:"ghost",size:"icon",onClick:()=>{const Z=Ce??fe.previewUrl;Z&&window.open(Z,"_blank","noopener")},children:n.jsx(Ts,{size:14})})}),n.jsx(je,{side:"bottom",children:"Open in new tab"})]}),n.jsxs(Zs,{children:[n.jsx(Qs,{asChild:!0,children:n.jsx(ie,{variant:"ghost",size:"icon",children:n.jsx(Yr,{size:14})})}),n.jsxs(ei,{align:"end",className:"w-44",children:[n.jsx(et,{onClick:ou,children:"Hard Reload"}),n.jsx(et,{onClick:lu,children:"Copy Current URL"}),ee&&q&&n.jsxs(n.Fragment,{children:[n.jsx(dr,{}),ct&&n.jsxs(et,{onClick:()=>{B(!0),He("cms")},children:[n.jsx(yr,{size:14}),"Edit SEO"]}),ct&&n.jsxs(et,{onClick:()=>{try{M(ll(ct)),He("code")}catch{ne.error("Invalid page block key")}},children:[n.jsx(Lo,{size:14}),"View JSON"]}),n.jsxs(et,{onClick:()=>F(!0),children:[n.jsx(yr,{size:14}),"Site SEO"]})]})]})]})]})]})]}),n.jsxs("div",{className:"flex-1 flex overflow-hidden",children:[c&&se&&e&&U&&n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"shrink-0 border-r overflow-hidden",style:{width:f},children:n.jsx(P.Suspense,{fallback:n.jsx("div",{className:"h-full flex items-center justify-center",children:n.jsx(we,{size:20,className:"animate-spin text-muted-foreground"})}),children:n.jsx(s1,{orgSlug:V.slug,virtualMcpId:U,branch:e,previewReady:z,previewUrl:se,currentPath:E,activeGlobalBlockKey:R?.key??null,externalSelectedIndex:R?null:d,onSaved:()=>{setTimeout(()=>{const Z=h.current;if(!Z)return;const ve=document.activeElement,rt=Z.tabIndex;Z.tabIndex=-1,Z.style.pointerEvents="none",Z.blur();try{Z.contentWindow?.location.reload()}catch{const Gt=Pe.current;Gt&&(Z.src=Gt)}const nt=()=>{Z.tabIndex=rt,Z.style.pointerEvents="",ve?.focus(),Z.removeEventListener("load",nt)};Z.addEventListener("load",nt),setTimeout(nt,3e3)},pn)},initialEditSeo:L,onExitSeo:()=>B(!1),onViewJsonFile:Z=>{try{M(ll(Z)),He("code")}catch{ne.error("Invalid page block key")}}})})}),n.jsx("div",{className:"w-1 shrink-0 cursor-col-resize bg-transparent hover:bg-border transition-colors",onPointerDown:Z=>{p.current=!0,_.current=Z.clientX,g.current=f,Z.currentTarget.setPointerCapture(Z.pointerId)},onPointerMove:Z=>{if(!p.current)return;const ve=Z.clientX-_.current;m(Math.max(240,Math.min(640,g.current+ve)))},onPointerUp:()=>{p.current=!1}})]}),n.jsxs("div",{className:oe("flex-1 relative overflow-hidden",r!=="desktop"&&fe.kind==="iframe"&&s!=="code"&&"flex justify-center bg-muted/30"),children:[fe.kind==="starting"&&n.jsx("div",{className:"absolute inset-0 z-30",children:n.jsx(Br,{kind:"starting",progress:xe,claimPhase:J})}),fe.kind==="suspended"&&n.jsx("div",{className:"absolute inset-0 z-30",children:n.jsx(Br,{kind:"suspended",onResume:Y.resume})}),As==="visual"&&!a&&n.jsxs("div",{className:"absolute top-2 left-1/2 -translate-x-1/2 z-20 flex items-center gap-1.5 rounded-full border border-violet-400/40 bg-violet-500/90 px-3 py-1 text-xs font-medium text-white shadow-md backdrop-blur-sm pointer-events-none select-none",children:[n.jsx(Ma,{size:12}),"Click any element to ask the AI"]}),As==="visual"&&a&&n.jsx(zv,{element:a,onDismiss:()=>l(null)}),s==="code"&&Zi&&U&&e&&n.jsx("div",{className:"absolute inset-0 z-10 bg-background",children:n.jsx(P.Suspense,{fallback:n.jsx("div",{className:"h-full flex items-center justify-center",children:n.jsx(we,{size:20,className:"animate-spin text-muted-foreground"})}),children:n.jsx(r1,{orgSlug:V.slug,virtualMcpId:U,branch:e,openPath:H})})}),fe.kind==="iframe"&&Ce&&n.jsx("div",{className:oe("h-full transition-[width] duration-250 [transition-timing-function:var(--ease-in-out-cubic)]",r!=="desktop"&&s!=="code"&&"w-full max-w-full border-x border-border bg-background shadow-sm"),style:{width:r==="desktop"||s==="code"?"100%":`${n1[r]}px`},children:n.jsx("iframe",{ref:h,src:Ce,className:oe("w-full h-full border-0",s==="code"&&"invisible"),title:"Dev Server Preview",tabIndex:c?-1:void 0,onLoad:()=>{if(Le("vm_preview_loaded",{view_mode:s,vm_id:Q?.sandboxHandle??null}),!R)try{const Z=h.current?.contentWindow?.location?.pathname;if(!Z)return;const ve=ft.current;if(ve!==null){ft.current=null,le(Z)===le(ve)&&T(Z);return}T(Z)}catch{}s==="visual"&&ge(),s==="cms"&&it()}},fe.previewUrl)})]})]}),n.jsx(Av,{open:k,onOpenChange:N,isPending:ae.isPending,error:I,onSubmit:du}),O&&ee&&q&&n.jsx(P.Suspense,{fallback:null,children:n.jsx(i1,{open:O,onOpenChange:F,orgSlug:V.slug,virtualMcpId:U??"",branch:e??"",decofile:ee,meta:q,onSaved:()=>{setTimeout(()=>{const Z=h.current;if(Z)try{Z.contentWindow?.location.reload()}catch{const ve=Pe.current;ve&&(Z.src=ve)}},pn)},target:{kind:"site"}})})]})}function c1(t){const e=W.c(2),{virtualMcpId:s}=t,i=It(s);if(!Xs(i?.metadata)){let a;return e[0]===Symbol.for("react.memo_cache_sentinel")?(a=n.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center gap-2 text-center text-sm text-muted-foreground p-6",children:[n.jsx(Fi,{size:24,className:"text-muted-foreground/60"}),n.jsx("div",{children:"No source to preview."}),n.jsx("div",{className:"text-xs text-muted-foreground/80",children:"Connect a GitHub repository from the Connections tab to enable Preview."})]}),e[0]=a):a=e[0],a}let o;return e[1]===Symbol.for("react.memo_cache_sentinel")?(o=n.jsx(l1,{}),e[1]=o):o=e[1],o}function h1({orgSlug:t,virtualMcpId:e,branch:s}){const i=Gs();return Ys({mutationFn:async({blockKey:r})=>{const o=ua(r),a=await fetch(`/api/${t}/sandbox/${encodeURIComponent(e)}/${encodeURIComponent(s)}/unlink`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({path:o})});if(!a.ok){const l=await a.json().catch(()=>({}));throw new Error(l.error??`Delete failed (${a.status})`)}return a.json()},onMutate:async({blockKey:r})=>{const o=`${t}/${e}/${s}`,a=Dt.decofile(o);await i.cancelQueries({queryKey:a});const l=i.getQueryData(a);return i.setQueryData(a,h=>{if(!h)return h;const{[r]:c,...d}=h;return d}),{previous:l,queryKey:a}},onError:(r,o,a)=>{a?.queryKey&&i.setQueryData(a.queryKey,a.previous)},onSuccess:()=>{const r=`${t}/${e}/${s}`;i.invalidateQueries({queryKey:Dt.liveMeta(r)})}})}function sn(t,e){return`${t}-${e}`}function pa(t,e){return`site/apps/${t}/${e}.ts`}function _a(t){const e=t.match(/^site\/apps\/([^/]+)\/([^/.]+)\.tsx?$/);if(e)return{vendor:e[1],app:e[2]};const s=t.match(/^([^/]+)\/apps\/([^/.]+)\.tsx?$/);return s?{vendor:s[1],app:s[2]}:null}function qh(t,e,s){const i=new Set([sn(t,e),e].map(o=>o.toLowerCase())),r=pa(t,e);for(const[o,a]of Object.entries(s)){if(o.includes("/")||!a||typeof a!="object"||Array.isArray(a))continue;const l=a;if(i.has(o.toLowerCase())||l.__resolveType===r)return o}return null}function d1(t,e){const s=t.vendor.alias,i=t.name,r=qh(s,i,e);return{id:sn(s,i),app:i,vendor:s,title:t.title||t.name,description:t.description,category:t.category??"Other",logo:t.logo||void 0,resolveType:pa(s,i),blockKey:r,installed:r!==null}}function u1(t,e,s){if(t===Ni)return null;const i=_a(t);if(!i)return null;const{vendor:r,app:o}=i,a=qh(r,o,s),l=Ki(t,e);return{id:sn(r,o),app:o,vendor:r,title:l.title??o,description:l.description??"",category:"Others",logo:l.logo??l.icon,resolveType:t,blockKey:a,installed:a!==null}}function f1(t,e,s){const i=new Map;for(const o of t){const a=d1(o,s);i.set(a.id,a)}const r=e.manifest?.blocks?.apps??{};for(const o of Object.keys(r)){const a=u1(o,e,s);!a||i.has(a.id)||i.set(a.id,a)}for(const o of _1(s,e)){const a=_a(o.resolveType);if(!a)continue;const l=sn(a.vendor,a.app);i.has(l)||i.set(l,{id:l,app:a.app,vendor:a.vendor,title:o.name,description:"",category:"Installed",resolveType:o.resolveType,blockKey:o.key,installed:!0})}return[...i.values()].sort(m1)}function m1(t,e){return t.installed!==e.installed?t.installed?-1:1:t.title.localeCompare(e.title)}function p1(t,e,s){const i=t.manifest?.blocks?.apps??{};for(const r of[pa(e,s),`site/apps/${e}/${s}.tsx`,`${e}/apps/${s}.ts`,`${e}/apps/${s}.tsx`])if(r in i)return!0;return!1}function _1(t,e){const s=[];for(const[i,r]of Object.entries(t)){if(i.includes("/")||!r||typeof r!="object"||Array.isArray(r))continue;const o=r,a=o.__resolveType;if(typeof a!="string"||wh(i,o))continue;const l=_a(a)??(()=>{const h=i.match(/^([^-]+)-(.+)$/);return h?{vendor:h[1],app:h[2]}:null})();!l||!p1(e,l.vendor,l.app)||s.push({key:i,name:i.replace(/[-_]/g," ").replace(/\b\w/g,h=>h.toUpperCase()),resolveType:a})}return s}async function g1(){const t=await fetch("/api/deco-apps");if(!t.ok)throw new Error(`Failed to fetch deco apps: ${t.status}`);return(await t.json()).apps??[]}function v1(t,e,s){const i=W.c(12),r=s?.enabled??!0;let o;i[0]===Symbol.for("react.memo_cache_sentinel")?(o=Dt.decoApps(),i[0]=o):o=i[0];let a;i[1]!==r?(a={queryKey:o,queryFn:g1,staleTime:3e5,retry:1,enabled:r},i[1]=r,i[2]=a):a=i[2];const l=qs(a);let h;i[3]!==e||i[4]!==t||i[5]!==l.data?(h=t&&e?f1(l.data??[],t,e):[],i[3]=e,i[4]=t,i[5]=l.data,i[6]=h):h=i[6];const c=h,d=l.isLoading&&!l.isError;let u;return i[7]!==c||i[8]!==l.isError||i[9]!==l.refetch||i[10]!==d?(u={catalog:c,isLoading:d,isError:l.isError,refetch:l.refetch},i[7]=c,i[8]=l.isError,i[9]=l.refetch,i[10]=d,i[11]=u):u=i[11],u}const x1=new Set(["website/pages/Page.tsx","$live/pages/LivePage.tsx"]);function b1(t){return t.includes("matchers")||t.includes("Match")}function y1(t,e){const s=t.__resolveType;return typeof s!="string"||!s||x1.has(s)?!1:e?qp(e,s):b1(s)}function Vi(t,e,s){if(!t)return!1;const i=t.__resolveType;if(typeof i!="string"||!sa(i)||!Object.hasOwn(e,i))return!1;const r=e[i];return!r||typeof r!="object"||Array.isArray(r)?!1:y1(r,s)}function gC(t,e,s){return Vi(t,e,s)?t?.__resolveType??null:null}function Gh(t,e,s){if(!t)return null;const i=t.__resolveType??"";if(!i)return null;if(Vi(t,e,s)){const a=e[i]??{},l=a.__resolveType??i,{__resolveType:h,name:c,...d}=a;return{resolveType:l,data:d,blockKey:i}}const{__resolveType:r,...o}=t;return{resolveType:i,data:o}}function S1(t,e,s){const i=Gh(t,e,s);return i?{__resolveType:i.resolveType,...i.data}:{__resolveType:""}}function vC(t,e,s){if(t)return Vi(t,e,s)?S1(t,e,s):t}function w1(t,e,s,i){if(!t)return"Default";if(Vi(t,e,i)){const r=t.__resolveType??"",o=e[r];return Ch(r,o)}return s(t)}function xC(t,e,s){return{__resolveType:t,...e,name:s}}function bC(t){return{__resolveType:t}}function yC(t,e,s){const i=Gh(t,e,s);return i?{resolveType:i.resolveType,formValue:i.data}:{resolveType:"",formValue:{}}}function Yh(t){const e=t.__resolveType??"";return Qt(e)?t.section??t:t}function Lr(t){const r=(Qt(t.__resolveType??"")?t.section:t)?.variants?.[0];return r?.rule?.__resolveType!==_h?null:r?.value??null}function SC(t){const e=Yh(t);return{__resolveType:Qp,variants:[{value:e,rule:{__resolveType:_h}}]}}function wC(t){const e=t.__resolveType??"";if(!e)return null;if(Qt(e))return t.section??null;const s=Lr(t);return s?Qt(s.__resolveType??"")?s:{__resolveType:Xa,section:Yh(s)}:{__resolveType:Xa,section:t}}function tr(t){const e=t.__resolveType??"";if(!e)return null;if(Qt(e)){const s=t.section,i=s?.__resolveType??"";return!i||!s?null:{resolveType:i,data:s}}return{resolveType:e,data:t}}function CC(t){const e=Lr(t);if(e)return tr(e);if(Qt(t.__resolveType??"")){const i=t.section;if(!i)return null;const r=Lr(i);return tr(r||i)}return tr(t)}function kC(t){return Lr(t)}const C1=["website/matchers/always.ts","$live/matchers/MatchAlways.ts"];function Xh(t){if(!t)return!1;const e=t.__resolveType??"";return e===""?Object.keys(t).length===0:C1.includes(e)||e.includes("always")}function k1(t){const e=t.variants??[];if(e.length===0)return-1;const s=e.findIndex(i=>Xh(i.rule));return s!==-1?s:e.length-1}function jC(t,e,s){const i=s.variants??[];if(i.length===0)return null;const r=k1(s),o=i[r]?.value;if(!o)return null;const a=structuredClone(o);return e.isLazy?{...t,section:a}:a}function NC(t,e){return e.isMultivariate?e.isLazy?t.section??null:t:null}function EC(t,e){return Array.isArray(t.variants)?t.variants.map((s,i)=>({label:e(s.rule)||`Variant ${i+1}`,value:s.value??{},rule:s.rule})):[]}function TC(t,e){const s=t.__resolveType??"";if(!s)return null;if(Qt(s)){const i=t.section??t,r=i.__resolveType??s;if(!r.includes("/")&&r in e){const o=e[r]??{};return{data:{...o},resolveType:o.__resolveType??r}}return{data:{...i},resolveType:r}}if(!s.includes("/")&&s in e){const i=e[s]??{};return{data:{...i},resolveType:i.__resolveType??s}}return{data:{...t},resolveType:s}}function j1(t,e){const s=t.__resolveType??"";return Qt(s)?{...t,section:e}:e}function RC(t,e,s){return e.isLazy?{...t,section:s}:s}function PC(t,e,s){const i=[...t.variants??[]],r=i[e];if(!r)return t;const o=r.value??{};return i[e]={...r,value:j1(o,s)},{...t,variants:i}}function DC(t,e,s){const i=[...t.variants??[]];return i[e]?(i[e]={...i[e],rule:s},{...t,variants:i}):t}function AC(t,e){const s=[...t.variants??[]],i=s[e];return i?(s.splice(e+1,0,structuredClone(i)),{...t,variants:s}):t}function IC(t,e){const s=[...t.variants??[]];return s.length<=1?null:(s.splice(e,1),{...t,variants:s})}const N1=new Set(["website/pages/Page.tsx","$live/pages/LivePage.tsx"]);function E1(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;const e=t;return typeof e.__resolveType=="string"&&N1.has(e.__resolveType)&&typeof e.path=="string"}function Jh(t,e){const i=t[e]?.sections;if(!i||Array.isArray(i))return 1;const r=i;return Array.isArray(r.variants)?r.variants.length:1}function T1(t,e,s){const r=t[e]?.sections;if(Array.isArray(r))return s===0?r:[];if(r&&typeof r=="object"){const o=r.variants;if(Array.isArray(o)){const a=o[s];return Array.isArray(a?.value)?a.value:[]}}return[]}function BC(t,e,s){if(Array.isArray(t))return[{label:"Default",sections:t}];if(t&&typeof t=="object"){const i=t;if(Array.isArray(i.variants)){const r=i.variants,o=r.map(h=>w1(h.rule,e,s)),a=o.reduce((h,c)=>(h[c]=(h[c]??0)+1,h),{}),l={};return r.map((h,c)=>{const d=o[c]??`Variant ${c+1}`,u=a[d]??1;let f=d;return u>1&&(l[d]=(l[d]??0)+1,f=`${d} ${l[d]}`),{label:f||`Variant ${c+1}`,sections:Array.isArray(h.value)?h.value:[],rule:h.rule}})}}return[]}function R1(){return{__resolveType:Jp}}function hi(t){return{rule:R1(),value:t}}function Fs(t,e){return{...e,__resolveType:Zp,variants:t}}function P1(t,e){const s=structuredClone(e);if(Array.isArray(t))return Fs([hi(t),hi(s)]);if(t&&typeof t=="object"){const i=t;return Array.isArray(i.variants)?Fs([...i.variants,hi(s)],i):null}return Fs([hi([]),hi(s)])}function LC(t){const e=t.variants;return Array.isArray(e)?e.length-1:1}function MC(t,e){if(e.length===0)return Fs([],t);if(e.length===1){const s=e[0],i=s?.rule;if(!Xh(i))return Fs(e,t);if(Array.isArray(s?.value))return s.value}return Fs(e,t)}function D1(t,e){for(const[s,i]of Object.entries(t)){if(!E1(i))continue;const r=i.sections;if(Array.isArray(r)){e(void 0,s,0);continue}if(!r||typeof r!="object")continue;const o=r.variants;if(Array.isArray(o))for(let a=0;a<o.length;a++){const l=o[a];e(l?.rule,s,a)}}}function OC(t,e,s){let i=0;return D1(t,r=>{if(!r)return;(r.__resolveType??"")===e&&Vi(r,t,s)&&i++}),i}function dl(t,e){const s=e.replace(/\s*\(copy(?:\s+\d+)?\)\s*$/,"").trim(),i=`${s} (copy)`;if(!t.has(i))return i;for(let r=2;r<1e3;r++){const o=`${s} (copy ${r})`;if(!t.has(o))return o}return`${s} (copy ${Date.now()})`}function A1(t,e){const s=Ei,i=e.replace(/-copy(?:-\d+)?$/,""),r=`${i}-copy`;if(!t.has(s(r)))return r;for(let o=2;o<1e3;o++){const a=`${i}-copy-${o}`;if(!t.has(s(a)))return a}return`${i}-copy-${Date.now()}`}function ul(t,e){const s=e.replace(/_copy(?:_\d+)?$/,""),i=`${s}_copy`;if(!Object.hasOwn(t,i))return i;for(let r=2;r<1e3;r++){const o=`${s}_copy_${r}`;if(!Object.hasOwn(t,o))return o}return`${s}_copy_${Date.now()}`}function I1(t){const e=fa(t.newName),s={...t.source,name:t.newName,path:t.newPath};return{key:e,data:s}}function B1(t,e){return Hh(t,e)}const L1=1e3;function M1(t,e){for(let s=0;s<L1;s++){const i=fa(e);if(!Object.hasOwn(t,i))return i}throw new Error("Could not generate a unique page block key")}const O1={create:"Create new page",duplicate:"Duplicate page",rename:"Rename page"},$1={create:"Create",duplicate:"Duplicate",rename:"Save"},z1={create:"Creating…",duplicate:"Duplicating…",rename:"Saving…"};function F1(t){const e=W.c(54),{open:s,mode:i,initialName:r,initialPath:o,isPending:a,error:l,validate:h,onSubmit:c,onOpenChange:d}=t,u=a===void 0?!1:a,[f,m]=P.useState(r),[p,_]=P.useState(o),[g,v]=P.useState(null),[y,x]=P.useState(s);s!==y&&(x(s),s&&(m(r),_(o),v(null)));let b;e[0]!==u||e[1]!==d?(b=Q=>{!Q&&!u&&(v(null),d(!1))},e[0]=u,e[1]=d,e[2]=b):b=e[2];const S=b;let w;e[3]!==u||e[4]!==f||e[5]!==c||e[6]!==p||e[7]!==h?(w=async Q=>{Q.preventDefault();const se=f.trim(),he=p.trim();if(!se||!he||u)return;const z=da(he);if(z){v(z);return}const te=h?.({name:se,path:he});if(te){v(te);return}v(null),await c({name:se,path:he})},e[3]=u,e[4]=f,e[5]=c,e[6]=p,e[7]=h,e[8]=w):w=e[8];const k=w,N=g??l,I=O1[i];let D;e[9]!==I?(D=n.jsx(ss,{children:n.jsx(is,{children:I})}),e[9]=I,e[10]=D):D=e[10];let R;e[11]===Symbol.for("react.memo_cache_sentinel")?(R=n.jsx("label",{htmlFor:"page-form-name",className:"text-xs font-medium text-muted-foreground",children:"Name"}),e[11]=R):R=e[11];let j;e[12]===Symbol.for("react.memo_cache_sentinel")?(j=Q=>m(Q.target.value),e[12]=j):j=e[12];let C;e[13]!==u||e[14]!==f?(C=n.jsxs("div",{className:"space-y-1.5",children:[R,n.jsx(qe,{id:"page-form-name",value:f,onChange:j,placeholder:"My page",autoFocus:!0,disabled:u})]}),e[13]=u,e[14]=f,e[15]=C):C=e[15];let A;e[16]===Symbol.for("react.memo_cache_sentinel")?(A=n.jsx("label",{htmlFor:"page-form-path",className:"text-xs font-medium text-muted-foreground",children:"Path"}),e[16]=A):A=e[16];let E;e[17]===Symbol.for("react.memo_cache_sentinel")?(E=Q=>_(Q.target.value),e[17]=E):E=e[17];let T;e[18]!==u||e[19]!==p?(T=n.jsxs("div",{className:"space-y-1.5",children:[A,n.jsx(qe,{id:"page-form-path",value:p,onChange:E,placeholder:"/example",disabled:u})]}),e[18]=u,e[19]=p,e[20]=T):T=e[20];let L;e[21]!==N?(L=N&&n.jsx("p",{className:"text-xs text-destructive",children:N}),e[21]=N,e[22]=L):L=e[22];let B;e[23]!==T||e[24]!==L||e[25]!==C?(B=n.jsxs("div",{className:"space-y-4 py-4",children:[C,T,L]}),e[23]=T,e[24]=L,e[25]=C,e[26]=B):B=e[26];let O;e[27]!==d?(O=()=>d(!1),e[27]=d,e[28]=O):O=e[28];let F;e[29]!==u||e[30]!==O?(F=n.jsx(ie,{type:"button",variant:"outline",onClick:O,disabled:u,children:"Cancel"}),e[29]=u,e[30]=O,e[31]=F):F=e[31];let H;e[32]!==u||e[33]!==f||e[34]!==p?(H=!f.trim()||!p.trim()||u,e[32]=u,e[33]=f,e[34]=p,e[35]=H):H=e[35];let M;e[36]!==u||e[37]!==i?(M=u?n.jsxs(n.Fragment,{children:[n.jsx(we,{size:14,className:"animate-spin"}),z1[i]]}):$1[i],e[36]=u,e[37]=i,e[38]=M):M=e[38];let U;e[39]!==H||e[40]!==M?(U=n.jsx(ie,{type:"submit",disabled:H,children:M}),e[39]=H,e[40]=M,e[41]=U):U=e[41];let V;e[42]!==F||e[43]!==U?(V=n.jsxs(ti,{children:[F,U]}),e[42]=F,e[43]=U,e[44]=V):V=e[44];let K;e[45]!==k||e[46]!==B||e[47]!==V||e[48]!==D?(K=n.jsx(Lt,{className:"sm:max-w-md",children:n.jsxs("form",{onSubmit:k,children:[D,B,V]})}),e[45]=k,e[46]=B,e[47]=V,e[48]=D,e[49]=K):K=e[49];let Y;return e[50]!==S||e[51]!==s||e[52]!==K?(Y=n.jsx(Bt,{open:s,onOpenChange:S,children:K}),e[50]=S,e[51]=s,e[52]=K,e[53]=Y):Y=e[53],Y}function H1(t){const e=W.c(43),{open:s,blockKey:i,initialName:r,isPending:o,onSubmit:a,onOpenChange:l}=t,h=o===void 0?!1:o,[c,d]=P.useState(r),[u,f]=P.useState(s);s!==u&&(f(s),s&&d(r));let m;e[0]!==h||e[1]!==l?(m=T=>{!T&&!h&&l(!1)},e[0]=h,e[1]=l,e[2]=m):m=e[2];const p=m;let _;e[3]!==h||e[4]!==c||e[5]!==a?(_=async T=>{T.preventDefault();const L=c.trim();!L||h||await a(L)},e[3]=h,e[4]=c,e[5]=a,e[6]=_):_=e[6];const g=_;let v;e[7]===Symbol.for("react.memo_cache_sentinel")?(v=n.jsxs(ss,{children:[n.jsx(is,{children:"Rename section"}),n.jsx(zo,{children:"Updates the display name. The internal key stays the same so pages referencing this section keep working."})]}),e[7]=v):v=e[7];let y;e[8]===Symbol.for("react.memo_cache_sentinel")?(y=n.jsx("label",{htmlFor:"section-rename-name",className:"text-xs font-medium text-muted-foreground",children:"Name"}),e[8]=y):y=e[8];let x;e[9]===Symbol.for("react.memo_cache_sentinel")?(x=T=>d(T.target.value),e[9]=x):x=e[9];let b;e[10]!==h||e[11]!==c?(b=n.jsxs("div",{className:"space-y-1.5",children:[y,n.jsx(qe,{id:"section-rename-name",value:c,onChange:x,autoFocus:!0,disabled:h})]}),e[10]=h,e[11]=c,e[12]=b):b=e[12];let S;e[13]===Symbol.for("react.memo_cache_sentinel")?(S=n.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:"Key"}),e[13]=S):S=e[13];let w;e[14]!==i?(w=n.jsxs("div",{className:"space-y-1.5",children:[S,n.jsx(qe,{value:i,readOnly:!0,disabled:!0,className:"font-mono"})]}),e[14]=i,e[15]=w):w=e[15];let k;e[16]!==b||e[17]!==w?(k=n.jsxs("div",{className:"space-y-4 py-4",children:[b,w]}),e[16]=b,e[17]=w,e[18]=k):k=e[18];let N;e[19]!==l?(N=()=>l(!1),e[19]=l,e[20]=N):N=e[20];let I;e[21]!==h||e[22]!==N?(I=n.jsx(ie,{type:"button",variant:"outline",onClick:N,disabled:h,children:"Cancel"}),e[21]=h,e[22]=N,e[23]=I):I=e[23];let D;e[24]!==h||e[25]!==c?(D=!c.trim()||h,e[24]=h,e[25]=c,e[26]=D):D=e[26];let R;e[27]!==h?(R=h?n.jsxs(n.Fragment,{children:[n.jsx(we,{size:14,className:"animate-spin"}),"Saving…"]}):"Save",e[27]=h,e[28]=R):R=e[28];let j;e[29]!==D||e[30]!==R?(j=n.jsx(ie,{type:"submit",disabled:D,children:R}),e[29]=D,e[30]=R,e[31]=j):j=e[31];let C;e[32]!==I||e[33]!==j?(C=n.jsxs(ti,{children:[I,j]}),e[32]=I,e[33]=j,e[34]=C):C=e[34];let A;e[35]!==g||e[36]!==k||e[37]!==C?(A=n.jsx(Lt,{className:"sm:max-w-md",children:n.jsxs("form",{onSubmit:g,children:[v,k,C]})}),e[35]=g,e[36]=k,e[37]=C,e[38]=A):A=e[38];let E;return e[39]!==p||e[40]!==s||e[41]!==A?(E=n.jsx(Bt,{open:s,onOpenChange:p,children:A}),e[39]=p,e[40]=s,e[41]=A,e[42]=E):E=e[42],E}const gn={post:"blog/loaders/Blogpost.ts",author:"blog/loaders/Author.ts",category:"blog/loaders/Category.ts"},W1="blog/sections/blocks/",ga=["posts","authors","categories"],Ti={posts:"post",authors:"author",categories:"category"};function Ri(t){return ga.includes(t)}const va={posts:"post",authors:"author",categories:"category"},Zh={posts:gn.post,authors:gn.author,categories:gn.category},U1=Object.fromEntries(Object.entries(Zh).map(([t,e])=>[e,t]));function K1(t){return typeof t=="string"?U1[t]??null:null}function Mr(t){return t&&typeof t=="object"&&!Array.isArray(t)?t:null}function Bs(t){return typeof t=="string"?t:""}function V1(t,e){switch(t){case"posts":return{label:Bs(e.title)||"Untitled post",subtitle:Bs(e.slug)};case"authors":return{label:Bs(e.name)||"Unnamed author",subtitle:Bs(e.email)};case"categories":return{label:Bs(e.name)||"Unnamed category",subtitle:Bs(e.slug)};default:{const s=t;throw new Error(`Unhandled blog kind: ${String(s)}`)}}}function Qh(t){const e={posts:[],authors:[],categories:[]};for(const[s,i]of Object.entries(t)){const r=Mr(i);if(!r)continue;const o=K1(r.__resolveType);if(!o)continue;const a=Mr(r[va[o]])??{},{label:l,subtitle:h}=V1(o,a);e[o].push({key:s,kind:o,label:l,subtitle:h})}for(const s of ga)e[s].sort((i,r)=>i.label.localeCompare(r.label));return e}function q1(t,e){return Qh(t)[e]}function $C(t,e){return q1(t,e).map(s=>({key:s.key,payload:ed(Mr(t[s.key])??void 0,e)}))}function ed(t,e){return t?Mr(t[va[e]])??{}:{}}function fl(t,e,s){return{name:t,__resolveType:Zh[e],[va[e]]:s}}function td(t){return`.deco/blocks/${encodeURIComponent(t)}.json`}function Wn(t){const e=new Uint8Array(Math.ceil(t/2));return crypto.getRandomValues(e),Array.from(e,s=>s.toString(16).padStart(2,"0")).join("").slice(0,t)}function ml(t,e){const s=`collections/blog/${e}/${Wn(12)}`;if(!Object.hasOwn(t,s))return s;throw new Error("Could not generate a unique blog block key")}function G1(t){switch(t){case"posts":return{title:"Untitled post",excerpt:"",slug:`untitled-${Wn(8)}`,date:new Date().toISOString().slice(0,10),image:"",authors:[],categories:[],sections:[]};case"authors":return{name:"New author",email:"",jobTitle:"",company:"",avatar:""};case"categories":return{name:"New category",slug:`category-${Wn(8)}`};default:{const e=t;throw new Error(`Unhandled blog kind: ${String(e)}`)}}}function zC(t){const e=new Set,s=[],i=t.manifest?.blocks??{};for(const r of Object.values(i))for(const o of Object.keys(r)){if(!o.startsWith(W1)||e.has(o))continue;e.add(o);const a=Ki(o,t);s.push({resolveType:o,title:a.title??Y1(o),description:a.description,icon:a.icon})}return s.sort((r,o)=>r.title.localeCompare(o.title))}function Y1(t){return(t.split("/").pop()??t).replace(/\.(tsx?|jsx?)$/,"")}const X1=["blog/sections/blocks/","site/sections/Blog/Post/"];function FC(t){return X1.some(e=>t.startsWith(e))}function sd({orgSlug:t,virtualMcpId:e,branch:s}){return Dt.decofile(`${t}/${e}/${s}`)}function id({orgSlug:t,virtualMcpId:e,branch:s},i){return`/api/${t}/sandbox/${encodeURIComponent(e)}/${encodeURIComponent(s)}/${i}`}function J1(t){const e=W.c(11),s=Gs();let i;e[0]!==t?(i=async l=>{const{blockKey:h,data:c}=l,d=await fetch(id(t,"write"),{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({path:td(h),content:JSON.stringify(c,null,2)})});if(!d.ok){const u=await d.json().catch(Z1);throw new Error(u.error??`Write failed (${d.status})`)}return d.json()},e[0]=t,e[1]=i):i=e[1];let r;e[2]!==t||e[3]!==s?(r=async l=>{const{blockKey:h,data:c}=l,d=sd(t);await s.cancelQueries({queryKey:d});const u=s.getQueryData(d);return s.setQueryData(d,f=>({...f??{},[h]:c})),{previous:u,queryKey:d}},e[2]=t,e[3]=s,e[4]=r):r=e[4];let o;e[5]!==s?(o=(l,h,c)=>{c?.queryKey&&s.setQueryData(c.queryKey,c.previous)},e[5]=s,e[6]=o):o=e[6];let a;return e[7]!==i||e[8]!==r||e[9]!==o?(a={mutationFn:i,onMutate:r,onError:o},e[7]=i,e[8]=r,e[9]=o,e[10]=a):a=e[10],Ys(a)}function Z1(){return{}}function Q1(t){const e=Gs();return Ys({mutationFn:async({blockKey:s})=>{const i=await fetch(id(t,"unlink"),{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({path:td(s)})});if(!i.ok){const r=await i.json().catch(()=>({}));throw new Error(r.error??`Delete failed (${i.status})`)}return i.json()},onMutate:async({blockKey:s})=>{const i=sd(t);await e.cancelQueries({queryKey:i});const r=e.getQueryData(i);return e.setQueryData(i,o=>{if(!o)return o;const{[s]:a,...l}=o;return l}),{previous:r,queryKey:i}},onError:(s,i,r)=>{r?.queryKey&&e.setQueryData(r.queryKey,r.previous)}})}function ex(t){const e=W.c(20),{open:s,onOpenChange:i,pageKey:r,decofile:o}=t,[a,l]=P.useState(!1),h=o[r];let c;e[0]!==h?(c=h===void 0?"// Page not found.":JSON.stringify(h,null,2),e[0]=h,e[1]=c):c=e[1];const d=c;let u;e[2]!==d?(u=()=>{navigator.clipboard.writeText(d).then(()=>{l(!0),setTimeout(()=>l(!1),2e3)})},e[2]=d,e[3]=u):u=e[3];const f=u;let m;e[4]===Symbol.for("react.memo_cache_sentinel")?(m=n.jsx(is,{className:"text-sm font-semibold",children:"Page JSON"}),e[4]=m):m=e[4];let p;e[5]!==a?(p=a?n.jsx(jc,{size:12}):n.jsx(Zt,{size:12}),e[5]=a,e[6]=p):p=e[6];const _=a?"Copied":"Copy";let g;e[7]!==f||e[8]!==p||e[9]!==_?(g=n.jsxs(ss,{className:"px-4 py-3 border-b flex-row items-center justify-between space-y-0",children:[m,n.jsxs(ie,{variant:"ghost",size:"sm",onClick:f,className:"h-7 gap-1.5 text-xs",children:[p,_]})]}),e[7]=f,e[8]=p,e[9]=_,e[10]=g):g=e[10];let v;e[11]!==d?(v=n.jsx(Qr,{className:"max-h-[70vh]",children:n.jsx("pre",{className:"p-4 text-xs font-mono text-foreground/90 whitespace-pre overflow-auto",children:d})}),e[11]=d,e[12]=v):v=e[12];let y;e[13]!==g||e[14]!==v?(y=n.jsxs(Lt,{className:"max-w-2xl p-0 gap-0",children:[g,v]}),e[13]=g,e[14]=v,e[15]=y):y=e[15];let x;return e[16]!==i||e[17]!==s||e[18]!==y?(x=n.jsx(Bt,{open:s,onOpenChange:i,children:y}),e[16]=i,e[17]=s,e[18]=y,e[19]=x):x=e[19],x}const pl=P.lazy(()=>Kt(()=>import("./app-editor-DmXODpUq.js"),__vite__mapDeps([152,1,2,45,46,47,16,3,5,76,6,7,8,9,10,11,12,13,14,15,4,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,77,49,71,78,72,79,50,80,48,81,82,83,57,84,59,60,153,89,90,91,92,93,94,95,96,97,98,99,100,101,56,102,58,103,104,105,106,107,65,108,55,109,70,110,69,66,111,112,113,114,115,64,116,86,87,51,52,53,54,61,62,63,67,68,73,74,75,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149])).then(t=>({default:t.AppEditor}))),tx=P.lazy(()=>Kt(()=>import("./post-editor-ioH2kBJn.js"),__vite__mapDeps([154,1,2,3,6,7,8,9,10,11,12,13,14,15,16,4,5,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,48,69,47,70,71,49,46,72,73,74,75,90,91,92,45,93,94,95,96,97,98,99,100,84,101,102,103,104,105,106,107,108,109,110,145,146,131,147,127,129,144,113,86,87,78,80,50,81,82,83,76,77,79,155,153,89,111,112,114,115,116,117,118,119,120,121,122,123,124,125,126,128,130,132,133,134,135,136,137,138,139,140,141,142,143,148,149])).then(t=>({default:t.PostEditor}))),sx=P.lazy(()=>Kt(()=>import("./record-editor-UjdJtAq9.js"),__vite__mapDeps([156,1,2,49,71,72,80,8,39,40,7,16,19,17,6,9,10,11,12,13,14,15,3,4,5,18,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,41,42,43,44,48,50,81,82,83,57,84,59,60,155,153,89,90,91,92,45,46,47,93,94,95,96,97,98,99,100,101,56,102,58,103,104,105,106,107,65,108,55,109,70,110,69,66,111,112,113,114,115,64,116,78,86,87,51,52,53,54,61,62,63,67,68,73,74,75,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,79,137,138,139,140,141,142,143,144,145,146,147,148,149])).then(t=>({default:t.RecordEditor}))),ix=P.lazy(()=>Kt(()=>import("./sections-editor-RaAaC45Z.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149])).then(t=>({default:t.SectionsEditor}))),rx=P.lazy(()=>Kt(()=>import("./seo-editor-DrYkry2i.js"),__vite__mapDeps([157,1,2,4,6,7,8,9,10,11,12,13,14,15,16,3,5,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,85,71,79,76,77,49,78,72,50,80,48,81,82,83,57,84,59,60,89,90,91,92,93,94,95,96,97,98,99,100,101,56,102,58,103,104,105,106,107,65,108,55,109,70,110,69,66,111,112,113,114,115,64,116,86,87,51,52,53,54,61,62,63,67,68,73,74,75,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149])).then(t=>({default:t.SeoEditor}))),nx=P.lazy(()=>Kt(()=>import("./add-section-modal-BtCHVJdb.js"),__vite__mapDeps([88,1,2,6,7,8,9,10,11,12,13,14,15,16,3,4,5,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,48,49,89,90,91,92,45,46,47,93,94,95,96,57,97,98,99,100,84,101,56,102,58,103,104,105,106,107,65,108,55,109,70,71,110,69,66,82,111,112,113,81,114,115,64,116,78,86,87,59,60,51,52,53,54,61,62,63,67,68,72,73,74,75,117,50,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,79,137,138,139,140,141,142,143,144,145,146,147,148,149])).then(t=>({default:t.AddSectionModal}))),Un="oklch(0.65 0.15 160)";function ox(){const t=W.c(18),e=Ji(),{data:s}=Vs.useSession(),{currentBranch:i}=ts(),{org:r}=Te(),o=e?.entity?.id??null,a=s?.user?.id,l=e?.entity?.metadata,h=a&&i?Kr(l?.sandboxMap?.[a]?.[i]):{},c=Object.values(h),u=(c.find(ax)??c[0])?.previewUrl??null,f=qt(),m=e?.entity?.organization_id??"";let p;t[0]!==r.slug||t[1]!==m?(p={connectionId:ws,orgId:m,orgSlug:r.slug},t[0]=r.slug,t[1]=m,t[2]=p):p=t[2];const _=tt(p),g=Ro(_);let v;t[3]!==i||t[4]!==g||t[5]!==o?(v=()=>{if(!o)return;const w={virtualMcpId:o};i&&(w.branch=i),g.mutate(w)},t[3]=i,t[4]=g,t[5]=o,t[6]=v):v=t[6];const y=v,x=!!o&&!!i&&An.isStopped(o,i),b=Oh({previewUrl:u,appPaused:f.status.state==="paused",userStopped:x});if(b.kind!=="iframe"){let w;return t[7]!==b||t[8]!==y||t[9]!==f.lifecycle||t[10]!==f.phase?(w=n.jsx(ux,{state:b,claimPhase:f.phase,lifecycle:f.lifecycle,onStart:y}),t[7]=b,t[8]=y,t[9]=f.lifecycle,t[10]=f.phase,t[11]=w):w=t[11],w}if(!o||!i){let w;return t[12]===Symbol.for("react.memo_cache_sentinel")?(w=n.jsx(xi,{title:"Waiting for sandbox context…"}),t[12]=w):w=t[12],w}let S;return t[13]!==i||t[14]!==r.slug||t[15]!==u||t[16]!==o?(S=n.jsx(lx,{orgSlug:r.slug,virtualMcpId:o,branch:i,previewUrl:u}),t[13]=i,t[14]=r.slug,t[15]=u,t[16]=o,t[17]=S):S=t[17],S}function ax(t){return t.sandboxProviderKind!=="user-desktop"}function lx({orgSlug:t,virtualMcpId:e,branch:s,previewUrl:i}){const r={orgSlug:t,virtualMcpId:e,branch:s},{data:o,isLoading:a}=Qo(r),[l,h]=P.useState("pages"),[c,d]=P.useState(null),[u,f]=P.useState(null),[m,p]=P.useState(""),[_,g]=P.useState(l);_!==l&&(g(l),p(""));const v=2e3,y=15,{data:x,isLoading:b}=ea(r,{refetchInterval:J=>{if(l!=="apps"||!c||c.collection!=="apps")return!1;const fe=o?.[c.key]?.__resolveType;if(typeof fe!="string")return!1;const Se=J.state.data;return Se&&($n(fe,Se)||J.state.dataUpdateCount>=y)?!1:v}}),{catalog:S,isLoading:w}=v1(x??void 0,o??void 0,{enabled:l==="apps"}),k=ma(r),N=h1(r),I=J1(r),D=Q1(r),[R,j]=P.useState(null),[C,A]=P.useState(),[E,T]=P.useState(!1),[L,B]=P.useState(null),[O,F]=P.useState(null),[H,M]=P.useState(null);if(a||b)return n.jsx("div",{className:"h-full w-full flex items-center justify-center",children:n.jsx(we,{size:20,className:"animate-spin text-muted-foreground"})});if(!o||!x)return n.jsx(xi,{title:"Could not load site data."});const U=na(o).sort((J,xe)=>J.name.localeCompare(xe.name)),V=oa(o,x),K=kh(o,x),Y=Qh(o),Q=ga.some(J=>Y[J].length>0),se=Ri(l)?Y[l]:[];if(!ra(o,x)&&!Q)return n.jsx(xi,{icon:Fi,title:"No editable content",description:"This project doesn't expose any Deco pages, sections, or apps."});const he={pages:U.length,sections:V.length,apps:S.length,posts:Y.posts.length,authors:Y.authors.length,categories:Y.categories.length},z=new Set(U.map(J=>Ei(J.path))),te=new Set(U.map(J=>J.name)),ee=new Set(V.map(J=>J.name)),q=async J=>{const xe=o[J.key];if(!xe)return;const fe=Jh(o,J.key),Se=T1(o,J.key,Math.max(0,fe-1)),Ce=P1(xe.sections,Se);if(Ce)try{await k.mutateAsync({blockKey:J.key,data:{...xe,sections:Ce}}),ne.success(`Variant added to "${J.name}"`),d({collection:"pages",key:J.key,path:J.path})}catch(Ye){ne.error(Ye instanceof Error?Ye.message:"Could not add variant")}},$=()=>{A(void 0),j({mode:"create",sourceKey:null,initialName:"My new page",initialPath:"/example"})},ae=J=>{A(void 0),j({mode:"duplicate",sourceKey:J.key,initialName:dl(te,J.name),initialPath:A1(z,J.path)})},de=J=>{A(void 0),j({mode:"rename",sourceKey:J.key,initialName:J.name,initialPath:J.path})},me=async J=>{if(!R)return;const{mode:xe,sourceKey:fe}=R;try{if(xe==="create"){const Se=B1(J.name,J.path),Ce=M1(o,J.name);await k.mutateAsync({blockKey:Ce,data:Se}),ne.success(`Created "${J.name}"`),d({collection:"pages",key:Ce,path:J.path})}else if(xe==="duplicate"&&fe){const Se=o[fe];if(!Se)throw new Error("Source page not found");const{key:Ce,data:Ye}=I1({source:Se,pages:U,newName:J.name,newPath:J.path});await k.mutateAsync({blockKey:Ce,data:Ye}),ne.success(`Duplicated as "${J.name}"`),d({collection:"pages",key:Ce,path:J.path})}else if(xe==="rename"&&fe){const Se=o[fe];if(!Se)throw new Error("Page not found");const Ce={...Se,name:J.name,path:J.path};await k.mutateAsync({blockKey:fe,data:Ce}),ne.success("Page updated"),c?.collection==="pages"&&c.key===fe&&d({collection:"pages",key:fe,path:J.path})}j(null)}catch(Se){A(Se instanceof Error?Se.message:"Save failed")}},le=({path:J})=>{if(!R)return null;const xe=Ei(J);return(R.mode==="rename"?Ei(R.initialPath):null)!==xe&&z.has(xe)?`A page with path "${J}" already exists.`:null},G=async J=>{const xe=(J.title||J.resolveType.split("/").pop()||"").replace(/\.(tsx?|jsx?)$/,"").replace(/[^A-Za-z0-9_-]/g,""),fe=/^[A-Za-z]/.test(xe)&&xe.length>0?xe:"Section",Se=ul(o,fe),Ce={__resolveType:J.resolveType,name:Se};try{await k.mutateAsync({blockKey:Se,data:Ce}),ne.success(`Created section "${Se}"`),T(!1),d({collection:"sections",key:Se})}catch(Ye){ne.error(Ye instanceof Error?Ye.message:"Could not create section")}},pe=async J=>{const xe=o[J.key];if(!xe){ne.error("Section not found.");return}const fe=ul(o,J.key),Se=dl(ee,J.name),Ce={...xe,name:Se};try{await k.mutateAsync({blockKey:fe,data:Ce}),ne.success(`Duplicated "${J.name}"`),d({collection:"sections",key:fe})}catch(Ye){ne.error(Ye instanceof Error?Ye.message:"Duplicate failed")}},ue=async J=>{if(!L)return;const xe=o[L];if(!xe){ne.error("Section not found.");return}try{await k.mutateAsync({blockKey:L,data:{...xe,name:J}}),ne.success("Section renamed"),B(null)}catch(fe){ne.error(fe instanceof Error?fe.message:"Rename failed")}},ze=async J=>{const xe=ml(o,J),fe=fl(xe,J,G1(J));try{await I.mutateAsync({blockKey:xe,data:fe}),ne.success(`Created ${Ti[J]}`),d({collection:J,key:xe})}catch(Se){ne.error(Se instanceof Error?Se.message:"Could not create")}},ct=async J=>{const xe=o[J.key];if(!xe){ne.error("Record not found.");return}const fe=ml(o,J.kind),Se=J.kind==="posts"?"title":"name",Ce={...structuredClone(ed(xe,J.kind)),[Se]:`${J.label} (copy)`};try{await I.mutateAsync({blockKey:fe,data:fl(fe,J.kind,Ce)}),ne.success(`Duplicated "${J.label}"`),d({collection:J.kind,key:fe})}catch(Ye){ne.error(Ye instanceof Error?Ye.message:"Duplicate failed")}},Pe=async()=>{if(!O)return;const{kind:J,key:xe,label:fe}=O;try{J==="blog"?await D.mutateAsync({blockKey:xe}):await N.mutateAsync({blockKey:xe}),ne.success(`Deleted "${fe}"`),c&&c.key===xe&&d(null),F(null)}catch(Se){ne.error(Se instanceof Error?Se.message:"Delete failed")}},ft=N.isPending||D.isPending,li=O?.kind==="blog"?Ti[O.blogKind]:O?.kind??"item";return n.jsxs("div",{className:"flex h-full w-full",children:[n.jsx(cx,{active:l,counts:he,showBlog:Q,onSelect:J=>{h(J),d(null),f(null)}}),l!=="seo"&&l!=="site"&&n.jsx(hx,{activeCollection:l,pages:U,sections:V,appCatalog:S,appCatalogLoading:w,blogEntries:se,decofile:o,searchQuery:m,onSearchChange:p,selection:c,onSelect:J=>{d(J),f(null)},previewUrl:i,onCreate:()=>{l==="pages"?$():Ri(l)?ze(l):i?T(!0):ne.error("Start the preview dev server to add sections.")},onDuplicatePage:ae,onRenamePage:de,onAddPageVariant:q,onDeletePage:J=>F({kind:"page",key:J.key,label:J.name}),onEditPageSeo:J=>{d({collection:"pages",key:J.key,path:J.path}),f(J.key)},onViewPageJson:J=>M(J.key),onDuplicateSection:pe,onRenameSection:J=>B(J.key),onDeleteSection:J=>F({kind:"section",key:J.key,label:J.name}),onDuplicateBlog:ct,onDeleteBlog:J=>F({kind:"blog",blogKind:J.kind,key:J.key,label:J.label})}),n.jsx("div",{className:"flex-1 min-w-0",children:n.jsx(P.Suspense,{fallback:n.jsx("div",{className:"h-full flex items-center justify-center",children:n.jsx(we,{size:20,className:"animate-spin text-muted-foreground"})}),children:l==="site"?K?n.jsx(pl,{orgSlug:t,virtualMcpId:e,branch:s,blockKey:K.key,block:o[K.key],meta:x,title:"Site",excludeFields:["seo"]},`site:${K.key}`):n.jsx(xi,{title:"Site settings not found",description:"This project doesn't have a site app block (site/apps/site.ts)."}):l==="seo"?n.jsx(rx,{orgSlug:t,virtualMcpId:e,branch:s,decofile:o,meta:x,target:{kind:"site"},previewBaseUrl:i}):c?c.collection==="apps"?n.jsx(pl,{orgSlug:t,virtualMcpId:e,branch:s,blockKey:c.key,block:o[c.key],meta:x,schemaPending:typeof o[c.key]?.__resolveType=="string"&&!$n(String(o[c.key].__resolveType),x)},`app:${c.key}`):c.collection==="posts"?n.jsx(tx,{orgSlug:t,virtualMcpId:e,branch:s,blockKey:c.key,block:o[c.key],decofile:o,meta:x},`post:${c.key}`):c.collection==="authors"||c.collection==="categories"?n.jsx(sx,{orgSlug:t,virtualMcpId:e,branch:s,kind:c.collection,blockKey:c.key,block:o[c.key]},`${c.collection}:${c.key}`):n.jsx(ix,{orgSlug:t,virtualMcpId:e,branch:s,previewReady:!0,previewUrl:i??void 0,currentPath:c.collection==="pages"?c.path:"/",activePageBlockKey:c.collection==="pages"?c.key:null,activeGlobalBlockKey:c.collection==="sections"?c.key:null,initialEditSeo:c.collection==="pages"&&u===c.key,onExitSeo:()=>f(null)},c.collection==="pages"?`page:${c.key}`:`section:${c.key}`):n.jsx(xi,{title:`Select ${Ri(l)?`a ${Ti[l]}`:l==="pages"?"a page":l==="apps"?"an app":"a section"} to edit`,description:l==="apps"?"Browse all apps and select an installed one to edit its settings.":'Pick an item from the list, or click "+" to create one.'})})}),R&&n.jsx(F1,{open:!!R,mode:R.mode,initialName:R.initialName,initialPath:R.initialPath,isPending:k.isPending,error:C,validate:le,onSubmit:me,onOpenChange:J=>{J||(j(null),A(void 0))}}),L&&n.jsx(H1,{open:!!L,blockKey:L,initialName:V.find(J=>J.key===L)?.name??L,isPending:k.isPending,onSubmit:ue,onOpenChange:J=>{J||B(null)}}),E&&i&&n.jsx(P.Suspense,{fallback:null,children:n.jsx(nx,{open:E,onOpenChange:T,meta:x,decofile:o,previewBaseUrl:i,onSelect:G})}),H&&n.jsx(ex,{open:!!H,onOpenChange:J=>{J||M(null)},pageKey:H,decofile:o}),n.jsx(Cr,{open:!!O,onOpenChange:J=>{!J&&!ft&&F(null)},children:n.jsxs(kr,{children:[n.jsxs(jr,{children:[n.jsx(Nr,{children:`Delete ${li}?`}),n.jsx(Er,{children:O?.kind==="section"?`"${O.label}" will be removed. Pages that still reference it will lose this section.`:O?`"${O.label}" will be removed permanently. This can't be undone.`:null})]}),n.jsxs(Tr,{children:[n.jsx(Rr,{disabled:ft,children:"Cancel"}),n.jsx(Pr,{onClick:J=>{J.preventDefault(),Pe()},disabled:ft,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:ft?n.jsxs(n.Fragment,{children:[n.jsx(we,{size:14,className:"animate-spin"}),"Deleting…"]}):"Delete"})]})]})})]})}function cx(t){const e=W.c(33),{active:s,counts:i,showBlog:r,onSelect:o}=t;let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=n.jsx("div",{className:"px-3 h-12 flex items-center border-b shrink-0",children:n.jsx("span",{className:"text-sm font-medium",children:"Content"})}),e[0]=a):a=e[0];const l=s==="pages";let h;e[1]!==i.pages||e[2]!==o||e[3]!==l?(h=n.jsx(os,{id:"pages",icon:Bo,label:"Pages",count:i.pages,active:l,onSelect:o}),e[1]=i.pages,e[2]=o,e[3]=l,e[4]=h):h=e[4];const c=s==="sections";let d;e[5]!==i.sections||e[6]!==o||e[7]!==c?(d=n.jsx(os,{id:"sections",icon:Ws,label:"Sections",count:i.sections,active:c,onSelect:o}),e[5]=i.sections,e[6]=o,e[7]=c,e[8]=d):d=e[8];const u=s==="apps";let f;e[9]!==i.apps||e[10]!==o||e[11]!==u?(f=n.jsx(os,{id:"apps",icon:Qc,label:"Apps",count:i.apps,active:u,onSelect:o}),e[9]=i.apps,e[10]=o,e[11]=u,e[12]=f):f=e[12];let m;e[13]!==s||e[14]!==i.authors||e[15]!==i.categories||e[16]!==i.posts||e[17]!==o||e[18]!==r?(m=r&&n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"mt-3 flex items-center gap-1.5 px-2.5 pb-1 pt-1 text-xs font-medium text-muted-foreground/70",children:[n.jsx(Nc,{size:13,className:"shrink-0"}),"Blog"]}),n.jsx(os,{id:"posts",icon:Bc,label:"Posts",count:i.posts,active:s==="posts",onSelect:o}),n.jsx(os,{id:"authors",icon:Uo,label:"Authors",count:i.authors,active:s==="authors",onSelect:o}),n.jsx(os,{id:"categories",icon:Lc,label:"Categories",count:i.categories,active:s==="categories",onSelect:o})]}),e[13]=s,e[14]=i.authors,e[15]=i.categories,e[16]=i.posts,e[17]=o,e[18]=r,e[19]=m):m=e[19];const p=s==="site";let _;e[20]!==o||e[21]!==p?(_=n.jsx(os,{id:"site",icon:bf,label:"Site",active:p,onSelect:o}),e[20]=o,e[21]=p,e[22]=_):_=e[22];const g=s==="seo";let v;e[23]!==o||e[24]!==g?(v=n.jsx(os,{id:"seo",icon:yr,label:"SEO",active:g,onSelect:o}),e[23]=o,e[24]=g,e[25]=v):v=e[25];let y;return e[26]!==_||e[27]!==v||e[28]!==h||e[29]!==d||e[30]!==f||e[31]!==m?(y=n.jsxs("div",{className:"w-[208px] shrink-0 border-r flex flex-col",children:[a,n.jsxs("nav",{className:"flex flex-col p-1.5 gap-0.5",children:[h,d,f,m,_,v]})]}),e[26]=_,e[27]=v,e[28]=h,e[29]=d,e[30]=f,e[31]=m,e[32]=y):y=e[32],y}function os(t){const e=W.c(18),{id:s,icon:i,label:r,count:o,active:a,onSelect:l}=t;let h;e[0]!==s||e[1]!==l?(h=()=>l(s),e[0]=s,e[1]=l,e[2]=h):h=e[2];const c=a?"bg-accent text-accent-foreground":"text-muted-foreground hover:bg-muted hover:text-foreground";let d;e[3]!==c?(d=oe("flex w-full items-center gap-2 rounded-md px-2.5 py-1.5 text-left text-sm transition-colors cursor-pointer",c),e[3]=c,e[4]=d):d=e[4];let u;e[5]!==i?(u=n.jsx(i,{size:16,className:"shrink-0"}),e[5]=i,e[6]=u):u=e[6];let f;e[7]!==r?(f=n.jsx("span",{className:"flex-1 truncate",children:r}),e[7]=r,e[8]=f):f=e[8];let m;e[9]!==a||e[10]!==o?(m=o!==void 0&&n.jsx("span",{className:oe("shrink-0 text-xs tabular-nums",a?"text-accent-foreground/70":"text-muted-foreground/70"),children:o}),e[9]=a,e[10]=o,e[11]=m):m=e[11];let p;return e[12]!==h||e[13]!==d||e[14]!==u||e[15]!==f||e[16]!==m?(p=n.jsxs("button",{type:"button",onClick:h,className:d,children:[u,f,m]}),e[12]=h,e[13]=d,e[14]=u,e[15]=f,e[16]=m,e[17]=p):p=e[17],p}function hx(t){const e=W.c(57),{activeCollection:s,pages:i,sections:r,appCatalog:o,appCatalogLoading:a,blogEntries:l,decofile:h,previewUrl:c,searchQuery:d,onSearchChange:u,selection:f,onSelect:m,onCreate:p,onDuplicatePage:_,onRenamePage:g,onAddPageVariant:v,onDeletePage:y,onEditPageSeo:x,onViewPageJson:b,onDuplicateSection:S,onRenameSection:w,onDeleteSection:k,onDuplicateBlog:N,onDeleteBlog:I}=t;let D,R,j,C,A,E;if(e[0]!==s||e[1]!==o||e[2]!==a||e[3]!==l||e[4]!==h||e[5]!==v||e[6]!==p||e[7]!==I||e[8]!==y||e[9]!==k||e[10]!==N||e[11]!==_||e[12]!==S||e[13]!==x||e[14]!==g||e[15]!==w||e[16]!==u||e[17]!==m||e[18]!==b||e[19]!==i||e[20]!==c||e[21]!==d||e[22]!==r||e[23]!==f){const O=d.toLowerCase(),F=i.filter($=>!O||$.name.toLowerCase().includes(O)||$.path.toLowerCase().includes(O)),H=r.filter($=>!O||$.name.toLowerCase().includes(O)||$.key.toLowerCase().includes(O)||$.resolveType.toLowerCase().includes(O)),M=o.filter($=>!O||$.title.toLowerCase().includes(O)||$.app.toLowerCase().includes(O)||$.vendor.toLowerCase().includes(O)||$.category.toLowerCase().includes(O)),U=l.filter($=>!O||$.label.toLowerCase().includes(O)||$.subtitle.toLowerCase().includes(O)),V=`Search ${s}…`,K=Ri(s)?`Create new ${Ti[s]}`:s==="pages"?"Create new page":"Create new section",Y=s==="sections"&&!c,Q=s!=="apps",se=Y,he=Y?"Start the preview dev server to add sections":void 0;A="w-[300px] shrink-0 border-r flex flex-col min-h-0";let z;e[30]===Symbol.for("react.memo_cache_sentinel")?(z=n.jsx(Zc,{size:14,className:"shrink-0 text-muted-foreground","aria-hidden":!0}),e[30]=z):z=e[30];let te;e[31]!==u?(te=$=>u($.target.value),e[31]=u,e[32]=te):te=e[32];let ee;e[33]!==V||e[34]!==d||e[35]!==te?(ee=n.jsxs("div",{className:"flex flex-1 items-center gap-2 pl-1",children:[z,n.jsx("input",{type:"text",value:d,onChange:te,placeholder:V,"aria-label":V,className:"w-full bg-transparent text-sm outline-none placeholder:text-muted-foreground"})]}),e[33]=V,e[34]=d,e[35]=te,e[36]=ee):ee=e[36];let q;e[37]!==se||e[38]!==he||e[39]!==K||e[40]!==p||e[41]!==Q?(q=Q&&n.jsxs(Ne,{children:[n.jsx(ke,{asChild:!0,children:n.jsx(ie,{variant:"ghost",size:"icon",onClick:p,disabled:se,"aria-label":K,"aria-disabled":se,children:n.jsx(At,{size:14})})}),n.jsx(je,{side:"bottom",children:he??K})]}),e[37]=se,e[38]=he,e[39]=K,e[40]=p,e[41]=Q,e[42]=q):q=e[42],e[43]!==ee||e[44]!==q?(E=n.jsxs("div",{className:"px-2 h-12 flex items-center gap-1 border-b shrink-0",children:[ee,q]}),e[43]=ee,e[44]=q,e[45]=E):E=e[45],D=Qr,C="flex-1 min-h-0 [&_[data-slot=scroll-area-viewport]>div]:!block",R="flex flex-col gap-1 p-1.5",j=s==="pages"?F.length===0?n.jsx(ir,{hasItems:i.length>0,emptyLabel:"No pages yet.",emptyHint:'Click "+" to create your first page.'}):F.map($=>{const ae=f?.collection==="pages"&&f.key===$.key,de=Jh(h,$.key);return n.jsx(sr,{icon:Bo,title:$.name,subtitle:$.path,active:ae,variantCount:de,onClick:()=>m({collection:"pages",key:$.key,path:$.path}),menu:n.jsx(vn,{onDuplicate:()=>_($),onRename:()=>g($),onAddVariant:()=>v($),onEditSeo:()=>x($),onViewJson:()=>b($),onDelete:()=>y($)})},$.key)}):s==="sections"?H.length===0?n.jsx(ir,{hasItems:r.length>0,emptyLabel:"No saved sections yet.",emptyHint:'Click "+" to create one, or save a section from a page.'}):H.map($=>{const ae=f?.collection==="sections"&&f.key===$.key,de=$.resolveType.split("/").pop()?.replace(/\.tsx?$/,"");return n.jsx(sr,{icon:Ws,title:$.name,subtitle:de??$.resolveType,active:ae,onClick:()=>m({collection:"sections",key:$.key}),menu:n.jsx(vn,{onDuplicate:()=>S($),onRename:()=>w($),onDelete:()=>k($)})},$.key)}):s==="apps"?a?n.jsx("div",{className:"flex items-center justify-center py-8",children:n.jsx(we,{size:18,className:"animate-spin text-muted-foreground"})}):M.length===0?n.jsx(ir,{hasItems:o.length>0,emptyLabel:"No apps found.",emptyHint:"Try a different search term."}):M.map($=>{const ae=f?.collection==="apps"&&$.blockKey!==null&&f.key===$.blockKey;return n.jsx(sr,{icon:Qc,logoUrl:$.logo,title:$.title,subtitle:$.category,active:ae,trailing:$.installed?n.jsx("span",{className:"shrink-0 rounded-full bg-emerald-500/15 px-1.5 py-0.5 text-[10px] font-medium text-emerald-700 dark:text-emerald-400",children:"Installed"}):void 0,onClick:()=>{if(!$.installed||!$.blockKey){ne.message(`${$.title} is not installed on this site.`);return}m({collection:"apps",key:$.blockKey})}},$.id)}):U.length===0?n.jsx(ir,{hasItems:l.length>0,emptyLabel:`No ${s} yet.`,emptyHint:`Click "+" to create your first ${Ri(s)?Ti[s]:"item"}.`}):U.map($=>{const ae=f?.collection===$.kind&&f.key===$.key;return n.jsx(sr,{icon:$.kind==="posts"?Bc:$.kind==="authors"?Uo:Lc,title:$.label,subtitle:$.subtitle,active:ae,onClick:()=>m({collection:$.kind,key:$.key}),menu:n.jsx(vn,{onDuplicate:()=>N($),onDelete:()=>I($)})},$.key)}),e[0]=s,e[1]=o,e[2]=a,e[3]=l,e[4]=h,e[5]=v,e[6]=p,e[7]=I,e[8]=y,e[9]=k,e[10]=N,e[11]=_,e[12]=S,e[13]=x,e[14]=g,e[15]=w,e[16]=u,e[17]=m,e[18]=b,e[19]=i,e[20]=c,e[21]=d,e[22]=r,e[23]=f,e[24]=D,e[25]=R,e[26]=j,e[27]=C,e[28]=A,e[29]=E}else D=e[24],R=e[25],j=e[26],C=e[27],A=e[28],E=e[29];let T;e[46]!==R||e[47]!==j?(T=n.jsx("div",{className:R,children:j}),e[46]=R,e[47]=j,e[48]=T):T=e[48];let L;e[49]!==D||e[50]!==C||e[51]!==T?(L=n.jsx(D,{className:C,children:T}),e[49]=D,e[50]=C,e[51]=T,e[52]=L):L=e[52];let B;return e[53]!==A||e[54]!==E||e[55]!==L?(B=n.jsxs("div",{className:A,children:[E,L]}),e[53]=A,e[54]=E,e[55]=L,e[56]=B):B=e[56],B}function sr(t){const e=W.c(29),{icon:s,logoUrl:i,title:r,subtitle:o,active:a,variantCount:l,trailing:h,onClick:c,menu:d}=t;let u;e[0]!==s||e[1]!==a||e[2]!==i||e[3]!==l?(u=l&&l>1?n.jsxs(Ne,{children:[n.jsx(ke,{asChild:!0,children:n.jsx(s,{size:16,className:"shrink-0",style:{color:Un}})}),n.jsxs(je,{side:"right",children:[l," variants"]})]}):i?n.jsx("img",{src:i,alt:"",className:"size-8 shrink-0 rounded-lg object-cover bg-muted"}):n.jsx(s,{size:16,className:oe("shrink-0",a?"text-accent-foreground":"text-muted-foreground")}),e[0]=s,e[1]=a,e[2]=i,e[3]=l,e[4]=u):u=e[4];const f=u,m=a?"bg-accent text-accent-foreground":"hover:bg-muted";let p;e[5]!==m?(p=oe("group relative flex min-w-0 items-center rounded-md transition-colors",m),e[5]=m,e[6]=p):p=e[6];let _;e[7]!==r?(_=n.jsx("span",{className:"block truncate text-sm font-medium",children:r}),e[7]=r,e[8]=_):_=e[8];const g=a?"text-accent-foreground/70":"text-muted-foreground";let v;e[9]!==g?(v=oe("block truncate text-xs",g),e[9]=g,e[10]=v):v=e[10];let y;e[11]!==o||e[12]!==v?(y=n.jsx("span",{className:v,children:o}),e[11]=o,e[12]=v,e[13]=y):y=e[13];let x;e[14]!==_||e[15]!==y?(x=n.jsxs("span",{className:"min-w-0 flex-1",children:[_,y]}),e[14]=_,e[15]=y,e[16]=x):x=e[16];let b;e[17]!==c||e[18]!==f||e[19]!==x||e[20]!==h?(b=n.jsxs("button",{type:"button",onClick:c,className:"flex min-w-0 flex-1 items-center gap-2.5 rounded-md px-2.5 py-2 text-left cursor-pointer",children:[f,x,h]}),e[17]=c,e[18]=f,e[19]=x,e[20]=h,e[21]=b):b=e[21];let S;e[22]!==a||e[23]!==d?(S=d&&n.jsx("div",{className:oe("pr-1 opacity-0 transition-opacity group-hover:opacity-100",a&&"opacity-100"),children:d}),e[22]=a,e[23]=d,e[24]=S):S=e[24];let w;return e[25]!==S||e[26]!==p||e[27]!==b?(w=n.jsxs("div",{className:p,children:[b,S]}),e[25]=S,e[26]=p,e[27]=b,e[28]=w):w=e[28],w}function vn(t){const e=W.c(21),{onDuplicate:s,onRename:i,onAddVariant:r,onEditSeo:o,onViewJson:a,onDelete:l}=t;let h;e[0]===Symbol.for("react.memo_cache_sentinel")?(h=n.jsx(Qs,{asChild:!0,children:n.jsx("button",{type:"button","aria-label":"More actions",className:"flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground hover:bg-background hover:text-foreground cursor-pointer",onClick:dx,children:n.jsx(Yr,{size:14})})}),e[0]=h):h=e[0];let c;e[1]!==i?(c=i&&n.jsxs(et,{onClick:i,children:[n.jsx(Ko,{size:14}),"Rename"]}),e[1]=i,e[2]=c):c=e[2];let d;e[3]===Symbol.for("react.memo_cache_sentinel")?(d=n.jsx(Zt,{size:14}),e[3]=d):d=e[3];let u;e[4]!==s?(u=n.jsxs(et,{onClick:s,children:[d,"Duplicate"]}),e[4]=s,e[5]=u):u=e[5];let f;e[6]!==r?(f=r&&n.jsxs(n.Fragment,{children:[n.jsx(dr,{}),n.jsxs(et,{onClick:r,className:"cursor-pointer",style:{color:Un},children:[n.jsx(yf,{size:14,style:{color:Un}}),"Add variant"]})]}),e[6]=r,e[7]=f):f=e[7];let m;e[8]!==o||e[9]!==a?(m=(o||a)&&n.jsxs(n.Fragment,{children:[n.jsx(dr,{}),o&&n.jsxs(et,{onClick:o,children:[n.jsx(yr,{size:14}),"Edit SEO"]}),a&&n.jsxs(et,{onClick:a,children:[n.jsx(Lo,{size:14}),"View JSON"]})]}),e[8]=o,e[9]=a,e[10]=m):m=e[10];let p;e[11]===Symbol.for("react.memo_cache_sentinel")?(p=n.jsx(dr,{}),e[11]=p):p=e[11];let _;e[12]===Symbol.for("react.memo_cache_sentinel")?(_=n.jsx(Bi,{size:14}),e[12]=_):_=e[12];let g;e[13]!==l?(g=n.jsxs(et,{onClick:l,className:"text-destructive focus:text-destructive",children:[_,"Delete"]}),e[13]=l,e[14]=g):g=e[14];let v;return e[15]!==c||e[16]!==u||e[17]!==f||e[18]!==m||e[19]!==g?(v=n.jsxs(Zs,{children:[h,n.jsxs(ei,{align:"end",className:"w-44",children:[c,u,f,m,p,g]})]}),e[15]=c,e[16]=u,e[17]=f,e[18]=m,e[19]=g,e[20]=v):v=e[20],v}function dx(t){return t.stopPropagation()}function ir(t){const e=W.c(6),{hasItems:s,emptyLabel:i,emptyHint:r}=t;let o;e[0]!==r||e[1]!==i||e[2]!==s?(o=s?"No results match your search.":n.jsxs(n.Fragment,{children:[n.jsx("div",{children:i}),n.jsx("div",{className:"mt-1 text-muted-foreground/80",children:r})]}),e[0]=r,e[1]=i,e[2]=s,e[3]=o):o=e[3];let a;return e[4]!==o?(a=n.jsx("div",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:o}),e[4]=o,e[5]=a):a=e[5],a}function ux(t){const e=W.c(8),{state:s,claimPhase:i,lifecycle:r,onStart:o}=t;switch(s.kind){case"starting":{let a;e[0]!==i||e[1]!==r?(a=Uh({claimPhase:i,lifecycle:r}),e[0]=i,e[1]=r,e[2]=a):a=e[2];let l;return e[3]!==i||e[4]!==a?(l=n.jsx(Br,{kind:"starting",progress:a,claimPhase:i}),e[3]=i,e[4]=a,e[5]=l):l=e[5],l}case"suspended":{let a;return e[6]!==o?(a=n.jsx(Br,{kind:"suspended",onResume:o}),e[6]=o,e[7]=a):a=e[7],a}}}function xi(t){const e=W.c(10),{icon:s,title:i,description:r}=t;let o;e[0]!==s?(o=s&&n.jsx(s,{size:24,className:"text-muted-foreground/60"}),e[0]=s,e[1]=o):o=e[1];let a;e[2]!==i?(a=n.jsx("div",{children:i}),e[2]=i,e[3]=a):a=e[3];let l;e[4]!==r?(l=r&&n.jsx("div",{className:"text-xs text-muted-foreground/80 max-w-sm",children:r}),e[4]=r,e[5]=l):l=e[5];let h;return e[6]!==o||e[7]!==a||e[8]!==l?(h=n.jsxs("div",{className:"flex h-full w-full flex-col items-center justify-center gap-2 p-6 text-center text-sm text-muted-foreground",children:[o,a,l]}),e[6]=o,e[7]=a,e[8]=l,e[9]=h):h=e[9],h}function fx(t){const e=W.c(2),{virtualMcpId:s}=t,i=It(s);if(!Xs(i?.metadata)){let a;return e[0]===Symbol.for("react.memo_cache_sentinel")?(a=n.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center gap-2 text-center text-sm text-muted-foreground p-6",children:[n.jsx(Fi,{size:24,className:"text-muted-foreground/60"}),n.jsx("div",{children:"No content to edit."}),n.jsx("div",{className:"text-xs text-muted-foreground/80",children:"Connect a GitHub repository from the Settings tab to enable Content."})]}),e[0]=a):a=e[0],a}let o;return e[1]===Symbol.for("react.memo_cache_sentinel")?(o=n.jsx(ox,{}),e[1]=o):o=e[1],o}const xn={fast:{label:"Fast",subtitle:"Quick responses for simple tasks",icon:Dc},smart:{label:"Smart",subtitle:"Balanced quality and speed",icon:Zr},thinking:{label:"Thinking",subtitle:"Deeper reasoning for hard tasks",icon:kf}},mx=["fast","smart","thinking"];function px(t){const e=W.c(15),{tier:s,onSelect:i}=t,[r,o]=P.useState(!1),a=xn[s].icon;let l;e[0]!==a?(l=n.jsx(a,{size:14,className:"text-muted-foreground"}),e[0]=a,e[1]=l):l=e[1];const h=xn[s];let c;e[2]===Symbol.for("react.memo_cache_sentinel")?(c=n.jsx(ks,{size:14,className:"text-muted-foreground"}),e[2]=c):c=e[2];let d;e[3]!==l||e[4]!==h.label?(d=n.jsx(Ns,{asChild:!0,children:n.jsxs(ie,{variant:"outline",size:"sm",className:"w-fit gap-1.5",children:[l,h.label,c]})}),e[3]=l,e[4]=h.label,e[5]=d):d=e[5];let u;e[6]!==i||e[7]!==s?(u=mx.map(p=>{const _=xn[p],g=_.icon;return n.jsxs("button",{type:"button",onClick:()=>{i(p),o(!1)},className:oe("flex items-start gap-2 px-2 py-1.5 rounded-md text-left hover:bg-muted"),children:[n.jsx(g,{size:16,className:"shrink-0 text-muted-foreground mt-0.5"}),n.jsxs("div",{className:"flex-1",children:[n.jsx("div",{className:"text-sm",children:_.label}),n.jsx("div",{className:"text-xs text-muted-foreground",children:_.subtitle})]}),p===s&&n.jsx(si,{size:14,className:"text-foreground mt-0.5"})]},p)}),e[6]=i,e[7]=s,e[8]=u):u=e[8];let f;e[9]!==u?(f=n.jsx(Es,{align:"start",className:"p-1 w-64",children:n.jsx("div",{className:"flex flex-col",children:u})}),e[9]=u,e[10]=f):f=e[10];let m;return e[11]!==r||e[12]!==d||e[13]!==f?(m=n.jsxs(js,{open:r,onOpenChange:o,children:[d,f]}),e[11]=r,e[12]=d,e[13]=f,e[14]=m):m=e[14],m}function _x(t){const e=W.c(15),{tier:s,onTierChange:i,override:r,onOverrideChange:o}=t,[a,l]=P.useState(r!==null);let h;e[0]===Symbol.for("react.memo_cache_sentinel")?(h=n.jsx("span",{className:"text-xs font-semibold text-muted-foreground/60",children:"Model"}),e[0]=h):h=e[0];let c;e[1]!==o||e[2]!==i||e[3]!==r||e[4]!==s||e[5]!==a?(c=a?n.jsx(P.Suspense,{fallback:n.jsx(ie,{variant:"outline",size:"sm",disabled:!0,className:"w-fit",children:"Loading models…"}),children:n.jsx(gx,{override:r,onOverrideChange:o})}):n.jsx(px,{tier:s,onSelect:i}),e[1]=o,e[2]=i,e[3]=r,e[4]=s,e[5]=a,e[6]=c):c=e[6];let d;e[7]!==o?(d=m=>{l(m),m||o(null)},e[7]=o,e[8]=d):d=e[8];let u;e[9]!==d||e[10]!==a?(u=n.jsxs("label",{className:"flex items-center gap-2 text-xs text-muted-foreground cursor-pointer select-none",children:[n.jsx(Dr,{checked:a,onCheckedChange:d,className:"cursor-pointer"}),"Specific model"]}),e[9]=d,e[10]=a,e[11]=u):u=e[11];let f;return e[12]!==c||e[13]!==u?(f=n.jsxs("div",{className:"flex flex-col gap-2",children:[h,n.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[c,u]})]}),e[12]=c,e[13]=u,e[14]=f):f=e[14],f}function gx(t){const e=W.c(10),{override:s,onOverrideChange:i}=t,r=Tc(),o=r[0]?.id??null,[a,l]=P.useState(s?.credentialId??o);let h;e[0]!==s?(h=s?{modelId:s.modelId,title:s.title||s.modelId,keyId:s.credentialId,providerId:"deco",description:null,logo:null,capabilities:[],limits:null,costs:null}:null,e[0]=s,e[1]=h):h=e[1];const c=h;if(r.length===0){let f;return e[2]===Symbol.for("react.memo_cache_sentinel")?(f=n.jsx("span",{className:"text-xs text-muted-foreground italic",children:"Connect an AI provider in settings to pick a specific model."}),e[2]=f):f=e[2],f}let d;e[3]!==a||e[4]!==i?(d=f=>{const m=f.keyId??a??"";l(m),i({modelId:f.modelId,credentialId:m,title:f.title??f.modelId})},e[3]=a,e[4]=i,e[5]=d):d=e[5];let u;return e[6]!==a||e[7]!==c||e[8]!==d?(u=n.jsx("div",{className:"w-fit max-w-full [&_button]:rounded-md",children:n.jsx(Dm,{variant:"bordered",placeholder:"Pick a model",model:c,credentialId:a,onCredentialChange:l,onModelChange:d})}),e[6]=a,e[7]=c,e[8]=d,e[9]=u):u=e[9],u}const rd=[{key:"capabilities",heading:"Built-in capabilities",icon:Vo,tools:[{name:"web_search",title:"Web search",description:"Look up current information on the web",icon:Jr},{name:"generate_image",title:"Generate image",description:"Create images from a text prompt",icon:wm},{name:"subtask",title:"Subtask",description:"Spawn a focused sub-agent to handle part of the work",icon:Ii},{name:"user_ask",title:"Ask the user",description:"Pause to ask the user a clarifying question",icon:Sf}]},{key:"files",heading:"Files & code",icon:Fa,tools:[{name:"read",title:"Read File",description:"Read a file from the workspace",icon:Ic},{name:"write",title:"Write File",description:"Create or overwrite a file",icon:Ko},{name:"edit",title:"Edit File",description:"Make targeted edits to an existing file",icon:wf},{name:"grep",title:"Search Content",description:"Search file contents by pattern",icon:Wo},{name:"glob",title:"Find Files",description:"Find files by name pattern",icon:Fa},{name:"bash",title:"Run Command",description:"Run shell commands in the sandbox",icon:Cf}]},{key:"context",heading:"Context",icon:Oa,tools:[{name:"read_resource",title:"Read Resource",description:"Read an MCP resource by URI",icon:Oa},{name:"read_prompt",title:"Read Prompt",description:"Read an MCP prompt definition",icon:Nc}]},{key:"browser",heading:"Browser",icon:Ws,tools:[{name:"take_screenshot",title:"Take Screenshot",description:"Capture a screenshot of a web page",icon:km},{name:"scrape_url",title:"Scrape URL",description:"Fetch and extract content from a URL",icon:Ws},{name:"inspect_page",title:"Inspect Page",description:"Inspect a web page's structure",icon:Lo}]}],vx=rd.flatMap(t=>t.tools.map(e=>e.name));function xx(t){const e=t.replace(/[_-]+/g," ").trim();return e?e.toLowerCase().replace(/\b\w/g,s=>s.toUpperCase()):t}function bx(t){const e=W.c(5),{agentId:s,value:i,onChange:r}=t;let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=n.jsx("span",{className:"text-xs font-semibold text-muted-foreground/60",children:"Tools"}),e[0]=o):o=e[0];let a;return e[1]!==s||e[2]!==r||e[3]!==i?(a=n.jsxs("div",{className:"flex flex-col gap-2",children:[o,s?n.jsx(P.Suspense,{fallback:n.jsxs(ie,{variant:"outline",size:"sm",disabled:!0,className:"w-fit",children:[n.jsx(Vo,{size:14}),"Loading tools…"]}),children:n.jsx(yx,{agentId:s,value:i,onChange:r})}):n.jsx("span",{className:"text-xs text-muted-foreground italic",children:"Pick an agent first"})]}),e[1]=s,e[2]=r,e[3]=i,e[4]=a):a=e[4],a}function _l(t){const e=W.c(17),{value:s,checked:i,onToggle:r,title:o,description:a,leading:l}=t;let h;e[0]!==i?(h=n.jsx(en,{checked:i,className:"pointer-events-none mt-0.5"}),e[0]=i,e[1]=h):h=e[1];let c;e[2]!==l?(c=l&&n.jsx("span",{className:"mt-px shrink-0",children:l}),e[2]=l,e[3]=c):c=e[3];let d;e[4]!==o?(d=n.jsx("span",{className:"truncate text-sm leading-tight",children:o}),e[4]=o,e[5]=d):d=e[5];let u;e[6]!==a?(u=a&&n.jsx("span",{className:"line-clamp-2 text-xs leading-snug text-muted-foreground",children:a}),e[6]=a,e[7]=u):u=e[7];let f;e[8]!==d||e[9]!==u?(f=n.jsxs("div",{className:"flex min-w-0 flex-col gap-0.5",children:[d,u]}),e[8]=d,e[9]=u,e[10]=f):f=e[10];let m;return e[11]!==r||e[12]!==h||e[13]!==c||e[14]!==f||e[15]!==s?(m=n.jsxs(Pm,{value:s,onSelect:r,className:"items-start gap-2.5 py-2",children:[h,c,f]}),e[11]=r,e[12]=h,e[13]=c,e[14]=f,e[15]=s,e[16]=m):m=e[16],m}function gl(t){const e=W.c(20),{conn:s,label:i,icon:r,on:o,total:a,onToggle:l}=t,h=o===a;let c;e[0]!==r||e[1]!==s?(c=s?n.jsx(Vt,{icon:s.icon,name:s.title,size:"2xs"}):r?n.jsx(r,{size:14,className:"text-muted-foreground"}):n.jsx(jf,{size:14,className:"text-muted-foreground"}),e[0]=r,e[1]=s,e[2]=c):c=e[2];const d=s?.title??i??"Other tools";let u;e[3]!==d?(u=n.jsx("span",{className:"truncate",children:d}),e[3]=d,e[4]=u):u=e[4];let f;e[5]!==o||e[6]!==a?(f=n.jsxs("span",{className:"text-[11px] font-normal tabular-nums text-muted-foreground/70",children:[o,"/",a]}),e[5]=o,e[6]=a,e[7]=f):f=e[7];let m;e[8]!==l?(m=y=>{y.stopPropagation(),l()},e[8]=l,e[9]=m):m=e[9];const p=h?"None":"All";let _;e[10]!==m||e[11]!==p?(_=n.jsx("button",{type:"button",onClick:m,className:"text-[11px] font-medium text-primary hover:underline",children:p}),e[10]=m,e[11]=p,e[12]=_):_=e[12];let g;e[13]!==f||e[14]!==_?(g=n.jsxs("span",{className:"ml-auto flex items-center gap-2",children:[f,_]}),e[13]=f,e[14]=_,e[15]=g):g=e[15];let v;return e[16]!==c||e[17]!==u||e[18]!==g?(v=n.jsxs("div",{className:"flex items-center gap-2",children:[c,u,g]}),e[16]=c,e[17]=u,e[18]=g,e[19]=v):v=e[19],v}function yx(t){const e=W.c(70),{agentId:s,value:i,onChange:r}=t,{org:o}=Te(),[a,l]=P.useState(!1);let h;e[0]!==s||e[1]!==o.id||e[2]!==o.slug?(h={connectionId:s,orgId:o.id,orgSlug:o.slug},e[0]=s,e[1]=o.id,e[2]=o.slug,e[3]=h):h=e[3];const c=tt(h);let d;e[4]!==c?(d={client:c},e[4]=c,e[5]=d):d=e[5];const{data:u,isLoading:f}=Gf(d),m=Hi();let p,_,g,v,y,x,b,S,w,k,N,I,D;if(e[6]!==m||e[7]!==u?.tools||e[8]!==f||e[9]!==r||e[10]!==a||e[11]!==i){const E=new Map(m.map(jx)),T=new Map;for(const le of u?.tools??[]){const G=Ku(le._meta)??"__other__",pe=Vu(le.name,G==="__other__"?void 0:G),ue=le.title,ze=ue&&ue!==le.name?ue:xx(pe);T.has(G)||T.set(G,{clientId:G,conn:E.get(G),tools:[]}),T.get(G).tools.push({name:le.name,display:ze,description:le.description})}const L=[...T.values()].sort(kx),B=(u?.tools??[]).map(Cx),O=[...vx,...B],F=i===null?new Set(O):new Set(i),H=O.every(le=>F.has(le)),M=le=>r(O.every(G=>le.has(G))?null:[...le]),U=le=>{const G=new Set(F);G.has(le)?G.delete(le):G.add(le),M(G)},V=(le,G)=>{const pe=new Set(F);for(const ue of le)G?pe.add(ue):pe.delete(ue);M(pe)};v=js,D=a,y=l;let K;e[25]===Symbol.for("react.memo_cache_sentinel")?(K=n.jsx(Vo,{size:14,className:"text-muted-foreground"}),e[25]=K):K=e[25];const Y=H?"All tools":"Tools",Q=!H&&n.jsxs(jm,{variant:"secondary",className:"ml-0.5 h-5 px-1.5 text-[11px] tabular-nums",children:[F.size,"/",O.length]});let se;e[26]===Symbol.for("react.memo_cache_sentinel")?(se=n.jsx(ks,{size:14,className:"text-muted-foreground"}),e[26]=se):se=e[26],e[27]!==Y||e[28]!==Q?(x=n.jsx(Ns,{asChild:!0,children:n.jsxs(ie,{variant:"outline",size:"sm",className:"w-fit gap-1.5",children:[K,Y,Q,se]})}),e[27]=Y,e[28]=Q,e[29]=x):x=e[29],g=Es,N="p-0 w-80",I="start",_=Em,e[30]===Symbol.for("react.memo_cache_sentinel")?(w=n.jsx(Tm,{placeholder:"Search tools..."}),e[30]=w):w=e[30];const he=H?`All ${O.length} tools enabled`:`${F.size} of ${O.length} enabled`;let z;e[31]!==he?(z=n.jsx("span",{className:"text-xs text-muted-foreground",children:he}),e[31]=he,e[32]=z):z=e[32];let te;e[33]!==r?(te=()=>r(null),e[33]=r,e[34]=te):te=e[34];let ee;e[35]!==H||e[36]!==te?(ee=n.jsx("button",{type:"button",onClick:te,disabled:H,className:"text-xs font-medium text-primary hover:underline disabled:cursor-default disabled:opacity-40 disabled:no-underline",children:"Select all"}),e[35]=H,e[36]=te,e[37]=ee):ee=e[37];let q;e[38]===Symbol.for("react.memo_cache_sentinel")?(q=n.jsx("span",{className:"text-muted-foreground/30",children:"·"}),e[38]=q):q=e[38];let $;e[39]!==r?($=()=>r([]),e[39]=r,e[40]=$):$=e[40];const ae=F.size===0;let de;e[41]!==$||e[42]!==ae?(de=n.jsx("button",{type:"button",onClick:$,disabled:ae,className:"text-xs font-medium text-muted-foreground hover:underline disabled:cursor-default disabled:opacity-40 disabled:no-underline",children:"Clear"}),e[41]=$,e[42]=ae,e[43]=de):de=e[43];let me;e[44]!==ee||e[45]!==de?(me=n.jsxs("div",{className:"flex items-center gap-2",children:[ee,q,de]}),e[44]=ee,e[45]=de,e[46]=me):me=e[46],e[47]!==z||e[48]!==me?(k=n.jsxs("div",{className:"flex items-center justify-between border-b px-3 py-2",children:[z,me]}),e[47]=z,e[48]=me,e[49]=k):k=e[49],p=Rm,b="max-h-80",S=f?n.jsx("div",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:"Loading tools…"}):n.jsxs(n.Fragment,{children:[n.jsx(Nm,{children:"No tools found"}),rd.map(le=>{const G=le.tools.map(wx),pe=G.filter(ue=>F.has(ue)).length;return n.jsx(Ha,{heading:n.jsx(gl,{label:le.heading,icon:le.icon,on:pe,total:G.length,onToggle:()=>V(G,pe!==G.length)}),children:le.tools.map(ue=>n.jsx(_l,{value:`${ue.title} ${ue.name}`,checked:F.has(ue.name),onToggle:()=>U(ue.name),title:ue.title,description:ue.description,leading:n.jsx(ue.icon,{size:16,className:"text-muted-foreground"})},ue.name))},le.key)}),L.map(le=>{const G=le.tools.map(Sx),pe=G.filter(ue=>F.has(ue)).length;return n.jsx(Ha,{heading:n.jsx(gl,{conn:le.conn,on:pe,total:G.length,onToggle:()=>V(G,pe!==G.length)}),children:le.tools.map(ue=>n.jsx(_l,{value:`${ue.display} ${ue.name} ${le.conn?.title??""}`,checked:F.has(ue.name),onToggle:()=>U(ue.name),title:ue.display,description:ue.description},ue.name))},le.clientId)})]}),e[6]=m,e[7]=u?.tools,e[8]=f,e[9]=r,e[10]=a,e[11]=i,e[12]=p,e[13]=_,e[14]=g,e[15]=v,e[16]=y,e[17]=x,e[18]=b,e[19]=S,e[20]=w,e[21]=k,e[22]=N,e[23]=I,e[24]=D}else p=e[12],_=e[13],g=e[14],v=e[15],y=e[16],x=e[17],b=e[18],S=e[19],w=e[20],k=e[21],N=e[22],I=e[23],D=e[24];let R;e[50]!==p||e[51]!==b||e[52]!==S?(R=n.jsx(p,{className:b,children:S}),e[50]=p,e[51]=b,e[52]=S,e[53]=R):R=e[53];let j;e[54]!==_||e[55]!==R||e[56]!==w||e[57]!==k?(j=n.jsxs(_,{children:[w,k,R]}),e[54]=_,e[55]=R,e[56]=w,e[57]=k,e[58]=j):j=e[58];let C;e[59]!==g||e[60]!==j||e[61]!==N||e[62]!==I?(C=n.jsx(g,{className:N,align:I,children:j}),e[59]=g,e[60]=j,e[61]=N,e[62]=I,e[63]=C):C=e[63];let A;return e[64]!==v||e[65]!==y||e[66]!==x||e[67]!==C||e[68]!==D?(A=n.jsxs(v,{open:D,onOpenChange:y,children:[x,C]}),e[64]=v,e[65]=y,e[66]=x,e[67]=C,e[68]=D,e[69]=A):A=e[69],A}function Sx(t){return t.name}function wx(t){return t.name}function Cx(t){return t.name}function kx(t,e){return(t.conn?.title??t.clientId).localeCompare(e.conn?.title??e.clientId)}function jx(t){return[t.id,t]}function Pi(t){const e=t.trim().split(/\s+/);return e.length!==5?!1:e.every(s=>/^[\d*/,-]+$/.test(s))}function Nx(t){if(!t)return"Unknown schedule";const e=t.trim();if(e==="* * * * *")return"Every minute";if(e==="0 * * * *")return"Every hour";if(e==="0 0 * * *")return"Every day";if(e==="0 0 * * 1")return"Every week";const s=e.match(/^\*\/(\d+)\s+\*\s+\*\s+\*\s+\*$/);if(s)return`Every ${s[1]} minutes`;const i=e.match(/^0\s+\*\/(\d+)\s+\*\s+\*\s+\*$/);if(i)return`Every ${i[1]} hours`;const r=e.match(/^0\s+0\s+\*\/(\d+)\s+\*\s+\*$/);if(r){const l=parseInt(r[1]??"1");return l%7===0?`Every ${l/7} weeks`:`Every ${l} days`}const o=e.match(/^(\d+)\s+(\d+)\s+\*\s+\*\s+\*$/);if(o){const l=(o[2]??"0").padStart(2,"0"),h=(o[1]??"0").padStart(2,"0");return`Every day at ${l}:${h} UTC`}const a=e.match(/^(\d+)\s+(\d+)\s+\*\s+\*\s+(\d)$/);if(a){const h=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"][parseInt(a[3]??"0")]??"day",c=(a[2]??"0").padStart(2,"0"),d=(a[1]??"0").padStart(2,"0");return`Every ${h} at ${c}:${d} UTC`}return t}function Ex(t,e){const s=Math.max(1,t);switch(e){case"minutes":return s===1?"* * * * *":`*/${s} * * * *`;case"hours":return s===1?"0 * * * *":`0 */${s} * * *`;case"days":return s===1?"0 0 * * *":`0 0 */${s} * *`;case"weeks":return s===1?"0 0 * * 1":`0 0 */${s*7} * *`}}function Tx(t){const e=t.trim();if(e==="* * * * *")return{count:1,unit:"minutes"};if(e==="0 * * * *")return{count:1,unit:"hours"};if(e==="0 0 * * *")return{count:1,unit:"days"};if(e==="0 0 * * 1")return{count:1,unit:"weeks"};const s=e.match(/^\*\/(\d+)\s+\*\s+\*\s+\*\s+\*$/);if(s)return{count:parseInt(s[1]),unit:"minutes"};const i=e.match(/^0\s+\*\/(\d+)\s+\*\s+\*\s+\*$/);if(i)return{count:parseInt(i[1]),unit:"hours"};const r=e.match(/^0\s+0\s+\*\/(\d+)\s+\*\s+\*$/);if(r){const o=parseInt(r[1]);return o%7===0?{count:o/7,unit:"weeks"}:{count:o,unit:"days"}}return null}function Rx(t,e){return e===1?{minutes:"minute",hours:"hour",days:"day",weeks:"week"}[t]??t:t}const Px=[{label:"5 minutes",cron:"*/5 * * * *"},{label:"Hour",cron:"0 * * * *"},{label:"Day",cron:"0 0 * * *"},{label:"Week",cron:"0 0 * * 1"}];function Dx({automationId:t,open:e,onOpenChange:s,onCustomSelect:i,onEventSelect:r,onWebhookCreated:o}){const{triggerAdd:a}=Wi(),[l,h]=P.useState(!1),c=e??l,d=m=>{s?s(m):h(m)},u=async m=>{try{await a.mutateAsync({automation_id:t,type:"cron",cron_expression:m}),ne.success("Starter added"),d(!1)}catch(p){const _=p instanceof Error?p.message:"Failed to add starter";ne.error(_)}},f=async()=>{try{const m=await a.mutateAsync({automation_id:t,type:"webhook"});d(!1),m.webhook?o?.(m.webhook):ne.success("Webhook starter added")}catch(m){const p=m instanceof Error?m.message:"Failed to add webhook starter";ne.error(p)}};return n.jsxs(Zs,{open:c,onOpenChange:d,children:[n.jsx(Qs,{asChild:!0,children:n.jsxs(ie,{variant:"outline",size:"sm",children:[n.jsx(At,{size:14}),"Add Starter"]})}),n.jsxs(ei,{align:"end",className:"w-[200px]",children:[n.jsxs(Jf,{children:[n.jsxs(Zf,{className:"gap-2.5",children:[n.jsx(ki,{size:14,className:"text-muted-foreground shrink-0"}),"Every..."]}),n.jsx(Qf,{className:"w-[160px]",children:Px.map(m=>n.jsxs(et,{className:"gap-2.5",onSelect:()=>u(m.cron),disabled:a.isPending,children:[n.jsx(ki,{size:14,className:"text-muted-foreground shrink-0"}),"Every ",m.label]},m.cron))})]}),n.jsxs(et,{className:"gap-2.5",onSelect:()=>{d(!1),i?.()},children:[n.jsx(ki,{size:14,className:"text-muted-foreground shrink-0"}),"Custom (cron)"]}),n.jsxs(et,{className:"gap-2.5",onSelect:()=>{d(!1),r?.()},children:[n.jsx(Li,{size:14,className:"text-muted-foreground shrink-0"}),"Event"]}),n.jsxs(et,{className:"gap-2.5",onSelect:()=>{f()},disabled:a.isPending,children:[n.jsx(Jr,{size:14,className:"text-muted-foreground shrink-0"}),"Webhook"]})]})]})}function nd(t){const e=W.c(31),{open:s,onOpenChange:i,url:r,token:o,title:a,description:l}=t,h=a===void 0?"Webhook ready":a,c=l===void 0?"Send a POST to this URL with the bearer token to fire the automation. The token is shown once — copy it now.":l,[d,u]=P.useState(null),[f,m]=P.useState("curl"),[p,_]=P.useState("header"),g=P.useId();let v;e[0]===Symbol.for("react.memo_cache_sentinel")?(v=async(E,T)=>{try{await navigator.clipboard.writeText(E),u(T),ne.success("Copied"),setTimeout(()=>u(null),1500)}catch{ne.error("Failed to copy")}},e[0]=v):v=e[0];const y=v;let x;e[1]!==p||e[2]!==o||e[3]!==r?(x=r&&o&&p==="url"?`${r.replace(/\/$/,"")}/${o}`:r??"",e[1]=p,e[2]=o,e[3]=r,e[4]=x):x=e[4];const b=x,S=r&&o?p==="header"?`curl -X POST "${b}" \\
276
+ `}),e[26]=b):b=e[26];let S;return e[27]!==x||e[28]!==d?(S=n.jsxs("div",{className:"relative flex w-full flex-col items-center justify-center gap-12 select-none [clip-path:inset(-24px_0_-200px_0)]",children:[d,x,b]}),e[27]=x,e[28]=d,e[29]=S):S=e[29],S}function er(t){const e=W.c(10),{phase:s,current:i,children:r}=t,o=s-i,a=o<0,l=o===0,h=a?90:o*-22,c=a?.94:1-Math.max(o,0)*.04,d=a?0:l?1:o===1?.8:.55,u=a?10:30-o,f=!l;let m;e[0]===Symbol.for("react.memo_cache_sentinel")?(m=oe("absolute inset-0 overflow-hidden rounded-xl border border-foreground/10 bg-background shadow-[0_20px_60px_-20px_rgb(0_0_0_/_0.35)] transition-all ease-[cubic-bezier(0.22,1,0.36,1)]"),e[0]=m):m=e[0];const p=`translateY(${h}px) scale(${c})`,_=l?"auto":"none";let g;e[1]!==d||e[2]!==p||e[3]!==_||e[4]!==u?(g={transform:p,opacity:d,zIndex:u,transitionDuration:"1000ms",pointerEvents:_},e[1]=d,e[2]=p,e[3]=_,e[4]=u,e[5]=g):g=e[5];let v;return e[6]!==r||e[7]!==f||e[8]!==g?(v=n.jsx("div",{"aria-hidden":f,className:m,style:g,children:r}),e[6]=r,e[7]=f,e[8]=g,e[9]=v):v=e[9],v}function tn(t){const e=W.c(7),{showUrl:s}=t,i=s===void 0?!1:s;let r,o,a;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=n.jsx("div",{className:oe("size-2.5 rounded-full",St)}),o=n.jsx("div",{className:oe("size-2.5 rounded-full",St)}),a=n.jsx("div",{className:oe("size-2.5 rounded-full",St)}),e[0]=r,e[1]=o,e[2]=a):(r=e[0],o=e[1],a=e[2]);let l;e[3]!==i?(l=i&&n.jsx("div",{className:oe("ml-3 h-3.5 max-w-[220px] flex-1 rounded-sm",zt)}),e[3]=i,e[4]=l):l=e[4];let h;return e[5]!==l?(h=n.jsxs("div",{className:"flex h-7 shrink-0 items-center gap-1.5 px-3",children:[r,o,a,l]}),e[5]=l,e[6]=h):h=e[6],h}function Xv(){const t=W.c(2);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsx(tn,{}),t[0]=e):e=t[0];let s;return t[1]===Symbol.for("react.memo_cache_sentinel")?(s=n.jsxs("div",{className:"flex h-full flex-col",children:[e,n.jsx("div",{className:"flex flex-1 px-8 py-5",children:n.jsx("div",{className:"grid h-full w-full grid-cols-8 grid-rows-6 gap-2",children:Uv.map(Jv)})})]}),t[1]=s):s=t[1],s}function Jv(t,e){if(e===Kh)return n.jsx("div",{className:"rounded-md bg-chart-1/[0.55]",style:{animation:"vm-breathe 2.4s ease-in-out infinite"}},e);const s=t;return n.jsx("div",{className:oe("relative rounded-md",St),children:n.jsx("div",{className:"absolute inset-0 rounded-md bg-chart-1/40 opacity-0",style:{animation:`vm-rack-scan ${Vh}s ease-in-out infinite`,animationDelay:`${s}s`}})},e)}function Zv(){const t=W.c(5);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsx(tn,{}),t[0]=e):e=t[0];let s;t[1]===Symbol.for("react.memo_cache_sentinel")?(s=n.jsx("div",{className:oe("w-[18%] rounded-md",zt),style:{animation:"vm-breathe 3s ease-in-out infinite"}}),t[1]=s):s=t[1];let i;t[2]===Symbol.for("react.memo_cache_sentinel")?(i=n.jsx("div",{className:"h-[42%] shrink-0 rounded-md bg-chart-3/[0.12]",style:{animation:"vm-breathe 3s ease-in-out 0.4s infinite"}}),t[2]=i):i=t[2];let r;t[3]===Symbol.for("react.memo_cache_sentinel")?(r=n.jsx("div",{className:"col-span-3 rounded-md bg-chart-3/[0.12]",style:{animation:"vm-breathe 3s ease-in-out 0.8s infinite"}}),t[3]=r):r=t[3];let o;return t[4]===Symbol.for("react.memo_cache_sentinel")?(o=n.jsxs("div",{className:"flex h-full flex-col",children:[e,n.jsxs("div",{className:"flex min-h-0 flex-1 gap-1.5 p-3",children:[s,n.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-1.5",children:[i,n.jsxs("div",{className:"grid min-h-0 flex-1 grid-cols-5 gap-1.5",children:[r,n.jsxs("div",{className:"col-span-2 grid grid-rows-2 gap-1.5",children:[n.jsx("div",{className:oe("rounded-md",zt),style:{animation:"vm-breathe 3s ease-in-out 1.2s infinite"}}),n.jsx("div",{className:oe("rounded-md",zt),style:{animation:"vm-breathe 3s ease-in-out 1.6s infinite"}})]})]})]})]})]}),t[4]=o):o=t[4],o}function Qv(){const t=W.c(2);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsx(tn,{}),t[0]=e):e=t[0];let s;return t[1]===Symbol.for("react.memo_cache_sentinel")?(s=n.jsxs("div",{className:"flex h-full flex-col",children:[e,n.jsx("div",{className:"relative flex flex-1 items-center justify-center px-8 py-5",children:n.jsx("div",{className:"grid w-full gap-2",style:{gridTemplateColumns:"repeat(7, minmax(0, 1fr))"},children:qv.map(e1)})})]}),t[1]=s):s=t[1],s}function e1(t,e){return n.jsx("div",{className:oe("aspect-square rounded-md",Gv[e]?"bg-chart-2/70":St),style:{animation:`vm-pulse-soft 2.2s ease-in-out ${t}s infinite`}},e)}function t1(){const t=W.c(11);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsx(tn,{showUrl:!0}),t[0]=e):e=t[0];let s,i,r,o,a;t[1]===Symbol.for("react.memo_cache_sentinel")?(s=n.jsx("div",{className:"mb-2 h-5 rounded-md bg-chart-1/[0.10]"}),i=n.jsx("div",{className:oe("h-1.5 w-[70%] rounded-sm",St)}),r=n.jsx("div",{className:oe("h-1.5 w-[55%] rounded-sm",St)}),o=n.jsx("div",{className:oe("h-1.5 w-[80%] rounded-sm",St)}),a=n.jsx("div",{className:oe("h-1.5 w-[50%] rounded-sm",St)}),t[1]=s,t[2]=i,t[3]=r,t[4]=o,t[5]=a):(s=t[1],i=t[2],r=t[3],o=t[4],a=t[5]);let l;t[6]===Symbol.for("react.memo_cache_sentinel")?(l=n.jsxs("div",{className:"flex w-[18%] shrink-0 flex-col gap-1.5 bg-chart-1/[0.05] p-2.5",children:[s,i,r,o,a,n.jsx("div",{className:"mt-auto",children:n.jsx("div",{className:oe("h-4 rounded-md",St)})})]}),t[6]=l):l=t[6];let h;t[7]===Symbol.for("react.memo_cache_sentinel")?(h=n.jsx("div",{className:"relative h-[42%] shrink-0 overflow-hidden bg-chart-1/[0.10]",children:n.jsxs("div",{className:"absolute right-3 bottom-3 left-3 space-y-1.5",children:[n.jsx("div",{className:"h-3 w-[35%] rounded-sm bg-chart-1/[0.15]"}),n.jsx("div",{className:oe("h-1.5 w-[55%] rounded-sm",zt)})]})}),t[7]=h):h=t[7];let c;t[8]===Symbol.for("react.memo_cache_sentinel")?(c=n.jsxs("div",{className:"flex shrink-0 gap-1.5",children:[n.jsx("div",{className:"h-4 w-12 rounded-full bg-chart-1/[0.12]"}),n.jsx("div",{className:oe("h-4 w-10 rounded-full",zt)}),n.jsx("div",{className:oe("h-4 w-14 rounded-full",zt)})]}),t[8]=c):c=t[8];let d;t[9]===Symbol.for("react.memo_cache_sentinel")?(d=n.jsxs("div",{className:oe("col-span-3 flex flex-col justify-end gap-1 rounded-md p-2",zt),children:[n.jsx("div",{className:oe("h-1.5 w-[50%] rounded-sm",St)}),n.jsx("div",{className:oe("h-1 w-[75%] rounded-sm",St)})]}),t[9]=d):d=t[9];let u;return t[10]===Symbol.for("react.memo_cache_sentinel")?(u=n.jsxs("div",{className:"flex h-full flex-col",children:[e,n.jsxs("div",{className:"flex min-h-0 flex-1",children:[l,n.jsxs("div",{className:"flex min-w-0 flex-1 flex-col",children:[h,n.jsxs("div",{className:"flex min-h-0 flex-1 flex-col gap-2.5 p-3",children:[c,n.jsxs("div",{className:"grid min-h-0 flex-1 grid-cols-5 gap-2",children:[d,n.jsxs("div",{className:"col-span-2 grid grid-rows-2 gap-2",children:[n.jsx("div",{className:oe("rounded-md",zt)}),n.jsx("div",{className:oe("rounded-md",zt)})]})]})]})]})]})]}),t[10]=u):u=t[10],u}function Br(t){const e=W.c(9);if(t.kind==="starting"){let l;return e[0]!==t.claimPhase||e[1]!==t.progress?(l=n.jsx("div",{className:"flex h-full w-full items-center justify-center bg-background p-6",children:n.jsx(Yv,{progress:t.progress,claimPhase:t.claimPhase})}),e[0]=t.claimPhase,e[1]=t.progress,e[2]=l):l=e[2],l}let s;e[3]===Symbol.for("react.memo_cache_sentinel")?(s=n.jsx(pf,{className:"size-12 text-blue-500"}),e[3]=s):s=e[3];let i,r;e[4]===Symbol.for("react.memo_cache_sentinel")?(i=n.jsx("h3",{className:"text-lg font-medium",children:Hv("suspended")}),r=n.jsx("p",{className:"max-w-sm text-sm text-muted-foreground",children:"Resume to continue."}),e[4]=i,e[5]=r):(i=e[4],r=e[5]);let o;e[6]===Symbol.for("react.memo_cache_sentinel")?(o=n.jsx(Hs,{className:"size-4"}),e[6]=o):o=e[6];let a;return e[7]!==t.onResume?(a=n.jsx("div",{className:"flex h-full w-full items-center justify-center bg-background p-6",children:n.jsxs("div",{className:"flex w-full max-w-md flex-col items-center gap-4 text-center",children:[s,i,r,n.jsxs(ie,{onClick:t.onResume,className:"mt-2",children:[o," Resume"]})]})}),e[7]=t.onResume,e[8]=a):a=e[8],a}const s1=P.lazy(()=>Kt(()=>import("./sections-editor-CPbI26Rh.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149])).then(t=>({default:t.SectionsEditor}))),i1=P.lazy(()=>Kt(()=>import("./page-seo-sheet-BiXExzzy.js"),__vite__mapDeps([150,1,2,28,29,45,46,47,16,3,5,85,71,79,76,6,7,8,9,10,11,12,13,14,15,4,17,18,19,20,21,22,23,24,25,26,27,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,77,49,78,72,50,80,48,81,82,83,57,84,59,60,89,90,91,92,93,94,95,96,97,98,99,100,101,56,102,58,103,104,105,106,107,65,108,55,109,70,110,69,66,111,112,113,114,115,64,116,86,87,51,52,53,54,61,62,63,67,68,73,74,75,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149])).then(t=>({default:t.SeoSheet}))),r1=P.lazy(()=>Kt(()=>import("./file-explorer-DgfAbZ4C.js"),__vite__mapDeps([151,1,2,134,110,6,7,8,9,10,11,12,13,14,15,16,3,4,5,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,125,97,98,57,99,100,84,101,56,102,58,103,104,48,105,106,107,49,119,120,121,81,78,69,122,108,123,55,66,113,124,61,62,63,70,71,126,51,52,53,54,59,60,64,65,67,68,72,73,74,75,86,87,127,128,129,91,92,89,90,93,94,95,96,109,82,111,112,114,115,116,117,50,118,130,131,132,133,135,136,79,137,138,139,140,141,142,143,144,145,146,147,148,149])).then(t=>({default:t.FileExplorer}))),pn=500,n1={mobile:375,tablet:768,desktop:null},_n=["desktop","mobile","tablet"],o1={mobile:"Mobile (375px)",tablet:"Tablet (768px)",desktop:"Desktop"};function a1(t,e){const s=new URL(t,window.location.href);return s.searchParams.set("deviceHint",e),s.href}function l1(){const t=Ji(),{currentBranch:e}=ts(),[s,i]=P.useState("preview"),[r,o]=P.useState("desktop"),[a,l]=P.useState(null),h=P.useRef(null),c=s==="cms",[d,u]=P.useState(null),[f,m]=P.useState(384),p=P.useRef(!1),_=P.useRef(0),g=P.useRef(0),v=P.useRef(null),[y,x]=P.useState(!1),[b,S]=P.useState(""),w=P.useRef(null),[k,N]=P.useState(!1),[I,D]=P.useState(),[R,j]=P.useState(null),[C,A]=P.useState(null),[E,T]=P.useState("/"),[L,B]=P.useState(!1),[O,F]=P.useState(!1),[H,M]=P.useState(null),U=t?.entity?.id??null,{org:V}=Te(),K=qt(),Y=zh(),Q=Y.vmEntry,se=Y.previewUrl,he=K.lifecycle.phase,z=he==="running",te=U&&e&&z?{orgSlug:V.slug,virtualMcpId:U,branch:e}:null,{data:ee}=Qo(te,{fetchEnabled:z}),{data:q}=ea(te,{fetchEnabled:z}),$=U&&e?{orgSlug:V.slug,virtualMcpId:U,branch:e}:null,ae=Dv($),de=ee?na(ee).sort((Z,ve)=>Z.name.localeCompare(ve.name)):[],me=ee&&q?oa(ee,q):[],le=Ei,G=de.filter(Z=>{if(!b)return!0;const ve=b.toLowerCase();return Z.name.toLowerCase().includes(ve)||Z.path.toLowerCase().includes(ve)}),pe=me.filter(Z=>{if(!b)return!0;const ve=b.toLowerCase();return Z.name.toLowerCase().includes(ve)||Z.key.toLowerCase().includes(ve)||Z.resolveType.toLowerCase().includes(ve)}),ue=R?null:de.find(Z=>le(Z.path)===le(E))??null,ze=R?R.name:ue?.name,ct=ue?.key??null,Pe=P.useRef(null),ft=P.useRef(null);f_(()=>{const Z=h.current,ve=Pe.current;!Z||!ve||(Z.src=ve)});const li=K.status.state==="paused",J=K.phase,xe=Uh({claimPhase:J,lifecycle:K.lifecycle}),fe=Y.previewState,Se=Y.userStopped,Ce=fe.kind==="iframe"?a1(C??new URL(E,fe.previewUrl).href,r):null,[Ye,ln]=P.useState(null);if(fe.kind==="iframe"&&Ye!==fe.previewUrl){const Z=Ye!==null;ln(fe.previewUrl),Z&&(ft.current=null,T("/"),A(null),j(null))}Pe.current=Ce;const Zi=!!U&&!!e&&!K.notFound&&!Se&&!li&&(J?.kind==="ready"||he!=="idle"),As=fe.kind!=="iframe"&&(s==="visual"||s==="cms")?"preview":s;P.useEffect(()=>{if(!se)return;let Z;try{Z=new URL(se,window.location.href).origin}catch{return}const ve=rt=>{if(rt.origin===Z){if(rt.data?.type==="visual-editor::element-clicked"){const nt=Iv.safeParse(rt.data.payload);nt.success&&l(nt.data)}else if(rt.data?.type==="cms-editor::section-clicked"){const nt=Lv.safeParse(rt.data.payload);nt.success&&u(nt.data.sectionIndex)}}};return window.addEventListener("message",ve),()=>window.removeEventListener("message",ve)},[se]),P.useEffect(()=>{if(!y)return;const Z=ve=>{w.current?.contains(ve.target)||(x(!1),S(""))};return document.addEventListener("pointerdown",Z),()=>document.removeEventListener("pointerdown",Z)},[y]),P.useEffect(()=>{if(!c)return;const Z=rt=>{const nt=rt.target;nt&&nt!==h.current&&(v.current=nt)},ve=()=>{requestAnimationFrame(()=>{const rt=document.activeElement;(rt===document.body||rt===h.current)&&v.current&&v.current.focus()})};return document.addEventListener("focusin",Z),document.addEventListener("blur",ve,!0),()=>{document.removeEventListener("focusin",Z),document.removeEventListener("blur",ve,!0)}},[c]);const ge=()=>{const Z=h.current?.contentWindow;Z&&Z.postMessage({type:"visual-editor::activate",script:Bv},"*")},Re=()=>{const Z=h.current?.contentWindow;Z&&Z.postMessage({type:"visual-editor::deactivate"},"*")},it=()=>{const Z=h.current?.contentWindow;Z&&Z.postMessage({type:"visual-editor::activate",script:Mv},"*")},xt=()=>{const Z=h.current?.contentWindow;Z&&Z.postMessage({type:"cms-editor::deactivate"},"*")},He=Z=>{const ve=s;i(Z),l(null),Z!=="code"&&M(null),Z!=="cms"&&u(null),ve==="visual"&&Re(),ve==="cms"&&xt(),Z==="visual"&&ge(),Z==="cms"&&it()},nu=()=>{if(!h.current||!Ce)return;const Z=h.current;Z.src=Ce},ou=()=>{if(!h.current||!Ce)return;const Z=Ce.includes("?")?"&":"?";h.current.src=`${Ce}${Z}_r=${Date.now()}`},au=()=>{const Z=_n.indexOf(r);o(_n[(Z+1)%_n.length])},lu=()=>{const Z=h.current?.contentWindow?.location?.href??Ce??se;Z&&navigator.clipboard.writeText(Z)},cu=(()=>{if(!se)return"No server running";if(R)return R.name;try{const Z=new URL(se),ve=E==="/"?"":E;return`${Z.host}${ve}`}catch{return se}})(),Ra=Z=>{ft.current=Z,j(null),A(null),T(Z),u(null),B(!1)},hu=Z=>{if(!se||!q){ne.error("Preview metadata not ready yet");return}ft.current=null;const ve=bh(q),rt=Ev(se,ve,Z.key);j(Z),A(rt),u(null)},du=async({name:Z,path:ve})=>{if(!U||!e)return;const rt=da(ve);if(rt){D(rt);return}const nt=ve.trim().startsWith("/")?ve.trim():`/${ve.trim()}`;if(de.some(Gt=>le(Gt.path)===le(nt))){D(`A page with path "${nt}" already exists.`);return}D(void 0);try{const Gt=await ae.mutateAsync({name:Z,path:nt});N(!1),ne.success(`Page "${Z}" created`),await new Promise(fu=>setTimeout(fu,pn)),Ra(Gt.path),He("cms")}catch(Gt){D(Gt instanceof Error?Gt.message:"Failed to create page")}},uu=[{value:"preview",icon:n.jsx(La,{size:14}),tooltip:"Interactive"},...fe.kind==="iframe"?[{value:"visual",icon:n.jsx(Ma,{size:14}),tooltip:"Visual editor"}]:[],...fe.kind==="iframe"&&ra(ee,q)?[{value:"cms",icon:n.jsx(_f,{size:14}),tooltip:"Sections editor"}]:[],{value:"code",icon:n.jsx(gf,{size:14}),tooltip:"Code editor"}];return n.jsxs("div",{className:"flex flex-col w-full h-full",children:[Zi&&n.jsxs("div",{className:"flex h-12 shrink-0 items-center gap-4 border-b border-border/60 px-3 md:px-4",children:[n.jsx("div",{className:"flex shrink-0 items-center gap-1",children:n.jsx(Sm,{value:As,onValueChange:He,options:uu,size:"sm",className:"shrink-0 bg-foreground/4.5"})}),fe.kind==="iframe"&&n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:oe("flex min-w-0 flex-1 items-center gap-0.5 ml-2",s==="code"&&"hidden"),children:[n.jsxs(Ne,{children:[n.jsx(ke,{asChild:!0,children:n.jsx(ie,{variant:"ghost",size:"icon",onClick:nu,children:n.jsx(Ai,{size:14})})}),n.jsx(je,{side:"bottom",children:"Refresh"})]}),n.jsxs(Ne,{children:[n.jsx(ke,{asChild:!0,children:n.jsx(ie,{variant:"ghost",size:"icon",onClick:au,children:n.jsxs("span",{className:"flex items-center justify-center animate-device-icon-pop",children:[r==="mobile"&&n.jsx(vf,{size:14}),r==="tablet"&&n.jsx(xf,{size:14}),r==="desktop"&&n.jsx(La,{size:14})]},r)})}),n.jsx(je,{side:"bottom",children:o1[r]})]}),n.jsxs("div",{ref:w,className:"relative min-w-0 flex-1",children:[n.jsxs("button",{type:"button",className:"flex h-8 w-full min-w-0 items-center gap-1 rounded-md bg-background px-2 transition-colors duration-200 hover:bg-accent",onClick:()=>x(Z=>!Z),children:[R&&n.jsxs("span",{className:"shrink-0 inline-flex items-center gap-1 rounded bg-global-section/14 px-1.5 py-0.5 text-[11px] font-medium text-global-section-fg dark:text-global-section-fg-dark",children:[n.jsx(Ws,{size:11}),"Global"]}),n.jsx("span",{className:"min-w-0 flex-1 truncate text-left text-[12px] text-foreground/88",children:cu}),ze&&!R&&n.jsx("span",{className:"shrink-0 text-[12px] text-muted-foreground",children:ze}),n.jsx(ks,{size:12,className:oe("shrink-0 text-muted-foreground transition-transform",y&&"rotate-180")})]}),y&&n.jsxs("div",{className:"absolute left-0 right-0 top-full z-50 mt-1.5 overflow-hidden rounded-lg border bg-popover shadow-lg",children:[n.jsxs("div",{className:"px-2 h-10 flex items-center gap-2 border-b",children:[n.jsx(Zc,{size:14,className:"shrink-0 text-muted-foreground","aria-hidden":!0}),n.jsx("input",{type:"text",value:b,onChange:Z=>S(Z.target.value),placeholder:"Search pages and components...",className:"w-full bg-transparent text-sm outline-none placeholder:text-muted-foreground",autoFocus:!0})]}),n.jsx("div",{className:"p-1.5 border-b",children:n.jsxs("button",{type:"button",className:"flex w-full items-center gap-2.5 rounded-md px-3 py-2.5 text-left text-sm hover:bg-accent hover:text-accent-foreground",onMouseDown:Z=>{Z.preventDefault(),x(!1),S(""),D(void 0),N(!0)},children:[n.jsx(At,{size:16,className:"shrink-0 text-muted-foreground"}),n.jsx("span",{className:"flex-1 font-medium",children:"Create new page"})]})}),G.length===0&&pe.length===0?n.jsx("div",{className:"px-4 py-5 text-center text-xs text-muted-foreground",children:de.length===0&&me.length===0?"No pages found in this site.":"No results match your search."}):n.jsxs("div",{className:"max-h-80 overflow-y-auto overscroll-contain",children:[G.length>0&&n.jsx("div",{className:"p-1.5",children:G.map(Z=>n.jsxs("button",{type:"button",className:"flex w-full items-center gap-3 rounded-md px-3 py-2.5 text-left text-sm hover:bg-accent hover:text-accent-foreground",onMouseDown:ve=>{ve.preventDefault(),x(!1),S(""),Ra(Z.path)},children:[n.jsx(Bo,{size:16,className:"shrink-0 text-muted-foreground"}),n.jsx("span",{className:"min-w-0 flex-1 truncate font-medium",children:Z.name}),n.jsx("span",{className:"shrink-0 text-xs text-muted-foreground",children:Z.path})]},Z.key))}),pe.length>0&&n.jsxs("div",{className:oe("p-1.5",G.length>0&&"border-t"),children:[n.jsx("div",{className:"px-3 py-2 text-xs font-medium text-muted-foreground",children:"Global components"}),pe.map(Z=>n.jsxs("button",{type:"button",className:"flex w-full items-center gap-3 rounded-md px-3 py-2.5 text-left text-sm hover:bg-accent hover:text-accent-foreground",onMouseDown:ve=>{ve.preventDefault(),x(!1),S(""),hu(Z)},children:[n.jsx(Ws,{size:16,className:"shrink-0 text-muted-foreground"}),n.jsx("span",{className:"min-w-0 flex-1 truncate font-medium",children:Z.name}),n.jsx("span",{className:"shrink-0 text-xs text-muted-foreground",children:Z.resolveType.split("/").pop()?.replace(/\.tsx?$/,"")})]},Z.key))]})]})]})]})]}),n.jsxs("div",{className:oe("flex shrink-0 items-center gap-0.5",s==="code"&&"hidden"),children:[n.jsxs(Ne,{children:[n.jsx(ke,{asChild:!0,children:n.jsx(ie,{variant:"ghost",size:"icon",onClick:()=>{const Z=Ce??fe.previewUrl;Z&&window.open(Z,"_blank","noopener")},children:n.jsx(Ts,{size:14})})}),n.jsx(je,{side:"bottom",children:"Open in new tab"})]}),n.jsxs(Zs,{children:[n.jsx(Qs,{asChild:!0,children:n.jsx(ie,{variant:"ghost",size:"icon",children:n.jsx(Yr,{size:14})})}),n.jsxs(ei,{align:"end",className:"w-44",children:[n.jsx(et,{onClick:ou,children:"Hard Reload"}),n.jsx(et,{onClick:lu,children:"Copy Current URL"}),ee&&q&&n.jsxs(n.Fragment,{children:[n.jsx(dr,{}),ct&&n.jsxs(et,{onClick:()=>{B(!0),He("cms")},children:[n.jsx(yr,{size:14}),"Edit SEO"]}),ct&&n.jsxs(et,{onClick:()=>{try{M(ll(ct)),He("code")}catch{ne.error("Invalid page block key")}},children:[n.jsx(Lo,{size:14}),"View JSON"]}),n.jsxs(et,{onClick:()=>F(!0),children:[n.jsx(yr,{size:14}),"Site SEO"]})]})]})]})]})]})]}),n.jsxs("div",{className:"flex-1 flex overflow-hidden",children:[c&&se&&e&&U&&n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"shrink-0 border-r overflow-hidden",style:{width:f},children:n.jsx(P.Suspense,{fallback:n.jsx("div",{className:"h-full flex items-center justify-center",children:n.jsx(we,{size:20,className:"animate-spin text-muted-foreground"})}),children:n.jsx(s1,{orgSlug:V.slug,virtualMcpId:U,branch:e,previewReady:z,previewUrl:se,currentPath:E,activeGlobalBlockKey:R?.key??null,externalSelectedIndex:R?null:d,onSaved:()=>{setTimeout(()=>{const Z=h.current;if(!Z)return;const ve=document.activeElement,rt=Z.tabIndex;Z.tabIndex=-1,Z.style.pointerEvents="none",Z.blur();try{Z.contentWindow?.location.reload()}catch{const Gt=Pe.current;Gt&&(Z.src=Gt)}const nt=()=>{Z.tabIndex=rt,Z.style.pointerEvents="",ve?.focus(),Z.removeEventListener("load",nt)};Z.addEventListener("load",nt),setTimeout(nt,3e3)},pn)},initialEditSeo:L,onExitSeo:()=>B(!1),onViewJsonFile:Z=>{try{M(ll(Z)),He("code")}catch{ne.error("Invalid page block key")}}})})}),n.jsx("div",{className:"w-1 shrink-0 cursor-col-resize bg-transparent hover:bg-border transition-colors",onPointerDown:Z=>{p.current=!0,_.current=Z.clientX,g.current=f,Z.currentTarget.setPointerCapture(Z.pointerId)},onPointerMove:Z=>{if(!p.current)return;const ve=Z.clientX-_.current;m(Math.max(240,Math.min(640,g.current+ve)))},onPointerUp:()=>{p.current=!1}})]}),n.jsxs("div",{className:oe("flex-1 relative overflow-hidden",r!=="desktop"&&fe.kind==="iframe"&&s!=="code"&&"flex justify-center bg-muted/30"),children:[fe.kind==="starting"&&n.jsx("div",{className:"absolute inset-0 z-30",children:n.jsx(Br,{kind:"starting",progress:xe,claimPhase:J})}),fe.kind==="suspended"&&n.jsx("div",{className:"absolute inset-0 z-30",children:n.jsx(Br,{kind:"suspended",onResume:Y.resume})}),As==="visual"&&!a&&n.jsxs("div",{className:"absolute top-2 left-1/2 -translate-x-1/2 z-20 flex items-center gap-1.5 rounded-full border border-violet-400/40 bg-violet-500/90 px-3 py-1 text-xs font-medium text-white shadow-md backdrop-blur-sm pointer-events-none select-none",children:[n.jsx(Ma,{size:12}),"Click any element to ask the AI"]}),As==="visual"&&a&&n.jsx(zv,{element:a,onDismiss:()=>l(null)}),s==="code"&&Zi&&U&&e&&n.jsx("div",{className:"absolute inset-0 z-10 bg-background",children:n.jsx(P.Suspense,{fallback:n.jsx("div",{className:"h-full flex items-center justify-center",children:n.jsx(we,{size:20,className:"animate-spin text-muted-foreground"})}),children:n.jsx(r1,{orgSlug:V.slug,virtualMcpId:U,branch:e,openPath:H})})}),fe.kind==="iframe"&&Ce&&n.jsx("div",{className:oe("h-full transition-[width] duration-250 [transition-timing-function:var(--ease-in-out-cubic)]",r!=="desktop"&&s!=="code"&&"w-full max-w-full border-x border-border bg-background shadow-sm"),style:{width:r==="desktop"||s==="code"?"100%":`${n1[r]}px`},children:n.jsx("iframe",{ref:h,src:Ce,className:oe("w-full h-full border-0",s==="code"&&"invisible"),title:"Dev Server Preview",tabIndex:c?-1:void 0,onLoad:()=>{if(Le("vm_preview_loaded",{view_mode:s,vm_id:Q?.sandboxHandle??null}),!R)try{const Z=h.current?.contentWindow?.location?.pathname;if(!Z)return;const ve=ft.current;if(ve!==null){ft.current=null,le(Z)===le(ve)&&T(Z);return}T(Z)}catch{}s==="visual"&&ge(),s==="cms"&&it()}},fe.previewUrl)})]})]}),n.jsx(Av,{open:k,onOpenChange:N,isPending:ae.isPending,error:I,onSubmit:du}),O&&ee&&q&&n.jsx(P.Suspense,{fallback:null,children:n.jsx(i1,{open:O,onOpenChange:F,orgSlug:V.slug,virtualMcpId:U??"",branch:e??"",decofile:ee,meta:q,onSaved:()=>{setTimeout(()=>{const Z=h.current;if(Z)try{Z.contentWindow?.location.reload()}catch{const ve=Pe.current;ve&&(Z.src=ve)}},pn)},target:{kind:"site"}})})]})}function c1(t){const e=W.c(2),{virtualMcpId:s}=t,i=It(s);if(!Xs(i?.metadata)){let a;return e[0]===Symbol.for("react.memo_cache_sentinel")?(a=n.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center gap-2 text-center text-sm text-muted-foreground p-6",children:[n.jsx(Fi,{size:24,className:"text-muted-foreground/60"}),n.jsx("div",{children:"No source to preview."}),n.jsx("div",{className:"text-xs text-muted-foreground/80",children:"Connect a GitHub repository from the Connections tab to enable Preview."})]}),e[0]=a):a=e[0],a}let o;return e[1]===Symbol.for("react.memo_cache_sentinel")?(o=n.jsx(l1,{}),e[1]=o):o=e[1],o}function h1({orgSlug:t,virtualMcpId:e,branch:s}){const i=Gs();return Ys({mutationFn:async({blockKey:r})=>{const o=ua(r),a=await fetch(`/api/${t}/sandbox/${encodeURIComponent(e)}/${encodeURIComponent(s)}/unlink`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({path:o})});if(!a.ok){const l=await a.json().catch(()=>({}));throw new Error(l.error??`Delete failed (${a.status})`)}return a.json()},onMutate:async({blockKey:r})=>{const o=`${t}/${e}/${s}`,a=Dt.decofile(o);await i.cancelQueries({queryKey:a});const l=i.getQueryData(a);return i.setQueryData(a,h=>{if(!h)return h;const{[r]:c,...d}=h;return d}),{previous:l,queryKey:a}},onError:(r,o,a)=>{a?.queryKey&&i.setQueryData(a.queryKey,a.previous)},onSuccess:()=>{const r=`${t}/${e}/${s}`;i.invalidateQueries({queryKey:Dt.liveMeta(r)})}})}function sn(t,e){return`${t}-${e}`}function pa(t,e){return`site/apps/${t}/${e}.ts`}function _a(t){const e=t.match(/^site\/apps\/([^/]+)\/([^/.]+)\.tsx?$/);if(e)return{vendor:e[1],app:e[2]};const s=t.match(/^([^/]+)\/apps\/([^/.]+)\.tsx?$/);return s?{vendor:s[1],app:s[2]}:null}function qh(t,e,s){const i=new Set([sn(t,e),e].map(o=>o.toLowerCase())),r=pa(t,e);for(const[o,a]of Object.entries(s)){if(o.includes("/")||!a||typeof a!="object"||Array.isArray(a))continue;const l=a;if(i.has(o.toLowerCase())||l.__resolveType===r)return o}return null}function d1(t,e){const s=t.vendor.alias,i=t.name,r=qh(s,i,e);return{id:sn(s,i),app:i,vendor:s,title:t.title||t.name,description:t.description,category:t.category??"Other",logo:t.logo||void 0,resolveType:pa(s,i),blockKey:r,installed:r!==null}}function u1(t,e,s){if(t===Ni)return null;const i=_a(t);if(!i)return null;const{vendor:r,app:o}=i,a=qh(r,o,s),l=Ki(t,e);return{id:sn(r,o),app:o,vendor:r,title:l.title??o,description:l.description??"",category:"Others",logo:l.logo??l.icon,resolveType:t,blockKey:a,installed:a!==null}}function f1(t,e,s){const i=new Map;for(const o of t){const a=d1(o,s);i.set(a.id,a)}const r=e.manifest?.blocks?.apps??{};for(const o of Object.keys(r)){const a=u1(o,e,s);!a||i.has(a.id)||i.set(a.id,a)}for(const o of _1(s,e)){const a=_a(o.resolveType);if(!a)continue;const l=sn(a.vendor,a.app);i.has(l)||i.set(l,{id:l,app:a.app,vendor:a.vendor,title:o.name,description:"",category:"Installed",resolveType:o.resolveType,blockKey:o.key,installed:!0})}return[...i.values()].sort(m1)}function m1(t,e){return t.installed!==e.installed?t.installed?-1:1:t.title.localeCompare(e.title)}function p1(t,e,s){const i=t.manifest?.blocks?.apps??{};for(const r of[pa(e,s),`site/apps/${e}/${s}.tsx`,`${e}/apps/${s}.ts`,`${e}/apps/${s}.tsx`])if(r in i)return!0;return!1}function _1(t,e){const s=[];for(const[i,r]of Object.entries(t)){if(i.includes("/")||!r||typeof r!="object"||Array.isArray(r))continue;const o=r,a=o.__resolveType;if(typeof a!="string"||wh(i,o))continue;const l=_a(a)??(()=>{const h=i.match(/^([^-]+)-(.+)$/);return h?{vendor:h[1],app:h[2]}:null})();!l||!p1(e,l.vendor,l.app)||s.push({key:i,name:i.replace(/[-_]/g," ").replace(/\b\w/g,h=>h.toUpperCase()),resolveType:a})}return s}async function g1(){const t=await fetch("/api/deco-apps");if(!t.ok)throw new Error(`Failed to fetch deco apps: ${t.status}`);return(await t.json()).apps??[]}function v1(t,e,s){const i=W.c(12),r=s?.enabled??!0;let o;i[0]===Symbol.for("react.memo_cache_sentinel")?(o=Dt.decoApps(),i[0]=o):o=i[0];let a;i[1]!==r?(a={queryKey:o,queryFn:g1,staleTime:3e5,retry:1,enabled:r},i[1]=r,i[2]=a):a=i[2];const l=qs(a);let h;i[3]!==e||i[4]!==t||i[5]!==l.data?(h=t&&e?f1(l.data??[],t,e):[],i[3]=e,i[4]=t,i[5]=l.data,i[6]=h):h=i[6];const c=h,d=l.isLoading&&!l.isError;let u;return i[7]!==c||i[8]!==l.isError||i[9]!==l.refetch||i[10]!==d?(u={catalog:c,isLoading:d,isError:l.isError,refetch:l.refetch},i[7]=c,i[8]=l.isError,i[9]=l.refetch,i[10]=d,i[11]=u):u=i[11],u}const x1=new Set(["website/pages/Page.tsx","$live/pages/LivePage.tsx"]);function b1(t){return t.includes("matchers")||t.includes("Match")}function y1(t,e){const s=t.__resolveType;return typeof s!="string"||!s||x1.has(s)?!1:e?qp(e,s):b1(s)}function Vi(t,e,s){if(!t)return!1;const i=t.__resolveType;if(typeof i!="string"||!sa(i)||!Object.hasOwn(e,i))return!1;const r=e[i];return!r||typeof r!="object"||Array.isArray(r)?!1:y1(r,s)}function gC(t,e,s){return Vi(t,e,s)?t?.__resolveType??null:null}function Gh(t,e,s){if(!t)return null;const i=t.__resolveType??"";if(!i)return null;if(Vi(t,e,s)){const a=e[i]??{},l=a.__resolveType??i,{__resolveType:h,name:c,...d}=a;return{resolveType:l,data:d,blockKey:i}}const{__resolveType:r,...o}=t;return{resolveType:i,data:o}}function S1(t,e,s){const i=Gh(t,e,s);return i?{__resolveType:i.resolveType,...i.data}:{__resolveType:""}}function vC(t,e,s){if(t)return Vi(t,e,s)?S1(t,e,s):t}function w1(t,e,s,i){if(!t)return"Default";if(Vi(t,e,i)){const r=t.__resolveType??"",o=e[r];return Ch(r,o)}return s(t)}function xC(t,e,s){return{__resolveType:t,...e,name:s}}function bC(t){return{__resolveType:t}}function yC(t,e,s){const i=Gh(t,e,s);return i?{resolveType:i.resolveType,formValue:i.data}:{resolveType:"",formValue:{}}}function Yh(t){const e=t.__resolveType??"";return Qt(e)?t.section??t:t}function Lr(t){const r=(Qt(t.__resolveType??"")?t.section:t)?.variants?.[0];return r?.rule?.__resolveType!==_h?null:r?.value??null}function SC(t){const e=Yh(t);return{__resolveType:Qp,variants:[{value:e,rule:{__resolveType:_h}}]}}function wC(t){const e=t.__resolveType??"";if(!e)return null;if(Qt(e))return t.section??null;const s=Lr(t);return s?Qt(s.__resolveType??"")?s:{__resolveType:Xa,section:Yh(s)}:{__resolveType:Xa,section:t}}function tr(t){const e=t.__resolveType??"";if(!e)return null;if(Qt(e)){const s=t.section,i=s?.__resolveType??"";return!i||!s?null:{resolveType:i,data:s}}return{resolveType:e,data:t}}function CC(t){const e=Lr(t);if(e)return tr(e);if(Qt(t.__resolveType??"")){const i=t.section;if(!i)return null;const r=Lr(i);return tr(r||i)}return tr(t)}function kC(t){return Lr(t)}const C1=["website/matchers/always.ts","$live/matchers/MatchAlways.ts"];function Xh(t){if(!t)return!1;const e=t.__resolveType??"";return e===""?Object.keys(t).length===0:C1.includes(e)||e.includes("always")}function k1(t){const e=t.variants??[];if(e.length===0)return-1;const s=e.findIndex(i=>Xh(i.rule));return s!==-1?s:e.length-1}function jC(t,e,s){const i=s.variants??[];if(i.length===0)return null;const r=k1(s),o=i[r]?.value;if(!o)return null;const a=structuredClone(o);return e.isLazy?{...t,section:a}:a}function NC(t,e){return e.isMultivariate?e.isLazy?t.section??null:t:null}function EC(t,e){return Array.isArray(t.variants)?t.variants.map((s,i)=>({label:e(s.rule)||`Variant ${i+1}`,value:s.value??{},rule:s.rule})):[]}function TC(t,e){const s=t.__resolveType??"";if(!s)return null;if(Qt(s)){const i=t.section??t,r=i.__resolveType??s;if(!r.includes("/")&&r in e){const o=e[r]??{};return{data:{...o},resolveType:o.__resolveType??r}}return{data:{...i},resolveType:r}}if(!s.includes("/")&&s in e){const i=e[s]??{};return{data:{...i},resolveType:i.__resolveType??s}}return{data:{...t},resolveType:s}}function j1(t,e){const s=t.__resolveType??"";return Qt(s)?{...t,section:e}:e}function RC(t,e,s){return e.isLazy?{...t,section:s}:s}function PC(t,e,s){const i=[...t.variants??[]],r=i[e];if(!r)return t;const o=r.value??{};return i[e]={...r,value:j1(o,s)},{...t,variants:i}}function DC(t,e,s){const i=[...t.variants??[]];return i[e]?(i[e]={...i[e],rule:s},{...t,variants:i}):t}function AC(t,e){const s=[...t.variants??[]],i=s[e];return i?(s.splice(e+1,0,structuredClone(i)),{...t,variants:s}):t}function IC(t,e){const s=[...t.variants??[]];return s.length<=1?null:(s.splice(e,1),{...t,variants:s})}const N1=new Set(["website/pages/Page.tsx","$live/pages/LivePage.tsx"]);function E1(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;const e=t;return typeof e.__resolveType=="string"&&N1.has(e.__resolveType)&&typeof e.path=="string"}function Jh(t,e){const i=t[e]?.sections;if(!i||Array.isArray(i))return 1;const r=i;return Array.isArray(r.variants)?r.variants.length:1}function T1(t,e,s){const r=t[e]?.sections;if(Array.isArray(r))return s===0?r:[];if(r&&typeof r=="object"){const o=r.variants;if(Array.isArray(o)){const a=o[s];return Array.isArray(a?.value)?a.value:[]}}return[]}function BC(t,e,s){if(Array.isArray(t))return[{label:"Default",sections:t}];if(t&&typeof t=="object"){const i=t;if(Array.isArray(i.variants)){const r=i.variants,o=r.map(h=>w1(h.rule,e,s)),a=o.reduce((h,c)=>(h[c]=(h[c]??0)+1,h),{}),l={};return r.map((h,c)=>{const d=o[c]??`Variant ${c+1}`,u=a[d]??1;let f=d;return u>1&&(l[d]=(l[d]??0)+1,f=`${d} ${l[d]}`),{label:f||`Variant ${c+1}`,sections:Array.isArray(h.value)?h.value:[],rule:h.rule}})}}return[]}function R1(){return{__resolveType:Jp}}function hi(t){return{rule:R1(),value:t}}function Fs(t,e){return{...e,__resolveType:Zp,variants:t}}function P1(t,e){const s=structuredClone(e);if(Array.isArray(t))return Fs([hi(t),hi(s)]);if(t&&typeof t=="object"){const i=t;return Array.isArray(i.variants)?Fs([...i.variants,hi(s)],i):null}return Fs([hi([]),hi(s)])}function LC(t){const e=t.variants;return Array.isArray(e)?e.length-1:1}function MC(t,e){if(e.length===0)return Fs([],t);if(e.length===1){const s=e[0],i=s?.rule;if(!Xh(i))return Fs(e,t);if(Array.isArray(s?.value))return s.value}return Fs(e,t)}function D1(t,e){for(const[s,i]of Object.entries(t)){if(!E1(i))continue;const r=i.sections;if(Array.isArray(r)){e(void 0,s,0);continue}if(!r||typeof r!="object")continue;const o=r.variants;if(Array.isArray(o))for(let a=0;a<o.length;a++){const l=o[a];e(l?.rule,s,a)}}}function OC(t,e,s){let i=0;return D1(t,r=>{if(!r)return;(r.__resolveType??"")===e&&Vi(r,t,s)&&i++}),i}function dl(t,e){const s=e.replace(/\s*\(copy(?:\s+\d+)?\)\s*$/,"").trim(),i=`${s} (copy)`;if(!t.has(i))return i;for(let r=2;r<1e3;r++){const o=`${s} (copy ${r})`;if(!t.has(o))return o}return`${s} (copy ${Date.now()})`}function A1(t,e){const s=Ei,i=e.replace(/-copy(?:-\d+)?$/,""),r=`${i}-copy`;if(!t.has(s(r)))return r;for(let o=2;o<1e3;o++){const a=`${i}-copy-${o}`;if(!t.has(s(a)))return a}return`${i}-copy-${Date.now()}`}function ul(t,e){const s=e.replace(/_copy(?:_\d+)?$/,""),i=`${s}_copy`;if(!Object.hasOwn(t,i))return i;for(let r=2;r<1e3;r++){const o=`${s}_copy_${r}`;if(!Object.hasOwn(t,o))return o}return`${s}_copy_${Date.now()}`}function I1(t){const e=fa(t.newName),s={...t.source,name:t.newName,path:t.newPath};return{key:e,data:s}}function B1(t,e){return Hh(t,e)}const L1=1e3;function M1(t,e){for(let s=0;s<L1;s++){const i=fa(e);if(!Object.hasOwn(t,i))return i}throw new Error("Could not generate a unique page block key")}const O1={create:"Create new page",duplicate:"Duplicate page",rename:"Rename page"},$1={create:"Create",duplicate:"Duplicate",rename:"Save"},z1={create:"Creating…",duplicate:"Duplicating…",rename:"Saving…"};function F1(t){const e=W.c(54),{open:s,mode:i,initialName:r,initialPath:o,isPending:a,error:l,validate:h,onSubmit:c,onOpenChange:d}=t,u=a===void 0?!1:a,[f,m]=P.useState(r),[p,_]=P.useState(o),[g,v]=P.useState(null),[y,x]=P.useState(s);s!==y&&(x(s),s&&(m(r),_(o),v(null)));let b;e[0]!==u||e[1]!==d?(b=Q=>{!Q&&!u&&(v(null),d(!1))},e[0]=u,e[1]=d,e[2]=b):b=e[2];const S=b;let w;e[3]!==u||e[4]!==f||e[5]!==c||e[6]!==p||e[7]!==h?(w=async Q=>{Q.preventDefault();const se=f.trim(),he=p.trim();if(!se||!he||u)return;const z=da(he);if(z){v(z);return}const te=h?.({name:se,path:he});if(te){v(te);return}v(null),await c({name:se,path:he})},e[3]=u,e[4]=f,e[5]=c,e[6]=p,e[7]=h,e[8]=w):w=e[8];const k=w,N=g??l,I=O1[i];let D;e[9]!==I?(D=n.jsx(ss,{children:n.jsx(is,{children:I})}),e[9]=I,e[10]=D):D=e[10];let R;e[11]===Symbol.for("react.memo_cache_sentinel")?(R=n.jsx("label",{htmlFor:"page-form-name",className:"text-xs font-medium text-muted-foreground",children:"Name"}),e[11]=R):R=e[11];let j;e[12]===Symbol.for("react.memo_cache_sentinel")?(j=Q=>m(Q.target.value),e[12]=j):j=e[12];let C;e[13]!==u||e[14]!==f?(C=n.jsxs("div",{className:"space-y-1.5",children:[R,n.jsx(qe,{id:"page-form-name",value:f,onChange:j,placeholder:"My page",autoFocus:!0,disabled:u})]}),e[13]=u,e[14]=f,e[15]=C):C=e[15];let A;e[16]===Symbol.for("react.memo_cache_sentinel")?(A=n.jsx("label",{htmlFor:"page-form-path",className:"text-xs font-medium text-muted-foreground",children:"Path"}),e[16]=A):A=e[16];let E;e[17]===Symbol.for("react.memo_cache_sentinel")?(E=Q=>_(Q.target.value),e[17]=E):E=e[17];let T;e[18]!==u||e[19]!==p?(T=n.jsxs("div",{className:"space-y-1.5",children:[A,n.jsx(qe,{id:"page-form-path",value:p,onChange:E,placeholder:"/example",disabled:u})]}),e[18]=u,e[19]=p,e[20]=T):T=e[20];let L;e[21]!==N?(L=N&&n.jsx("p",{className:"text-xs text-destructive",children:N}),e[21]=N,e[22]=L):L=e[22];let B;e[23]!==T||e[24]!==L||e[25]!==C?(B=n.jsxs("div",{className:"space-y-4 py-4",children:[C,T,L]}),e[23]=T,e[24]=L,e[25]=C,e[26]=B):B=e[26];let O;e[27]!==d?(O=()=>d(!1),e[27]=d,e[28]=O):O=e[28];let F;e[29]!==u||e[30]!==O?(F=n.jsx(ie,{type:"button",variant:"outline",onClick:O,disabled:u,children:"Cancel"}),e[29]=u,e[30]=O,e[31]=F):F=e[31];let H;e[32]!==u||e[33]!==f||e[34]!==p?(H=!f.trim()||!p.trim()||u,e[32]=u,e[33]=f,e[34]=p,e[35]=H):H=e[35];let M;e[36]!==u||e[37]!==i?(M=u?n.jsxs(n.Fragment,{children:[n.jsx(we,{size:14,className:"animate-spin"}),z1[i]]}):$1[i],e[36]=u,e[37]=i,e[38]=M):M=e[38];let U;e[39]!==H||e[40]!==M?(U=n.jsx(ie,{type:"submit",disabled:H,children:M}),e[39]=H,e[40]=M,e[41]=U):U=e[41];let V;e[42]!==F||e[43]!==U?(V=n.jsxs(ti,{children:[F,U]}),e[42]=F,e[43]=U,e[44]=V):V=e[44];let K;e[45]!==k||e[46]!==B||e[47]!==V||e[48]!==D?(K=n.jsx(Lt,{className:"sm:max-w-md",children:n.jsxs("form",{onSubmit:k,children:[D,B,V]})}),e[45]=k,e[46]=B,e[47]=V,e[48]=D,e[49]=K):K=e[49];let Y;return e[50]!==S||e[51]!==s||e[52]!==K?(Y=n.jsx(Bt,{open:s,onOpenChange:S,children:K}),e[50]=S,e[51]=s,e[52]=K,e[53]=Y):Y=e[53],Y}function H1(t){const e=W.c(43),{open:s,blockKey:i,initialName:r,isPending:o,onSubmit:a,onOpenChange:l}=t,h=o===void 0?!1:o,[c,d]=P.useState(r),[u,f]=P.useState(s);s!==u&&(f(s),s&&d(r));let m;e[0]!==h||e[1]!==l?(m=T=>{!T&&!h&&l(!1)},e[0]=h,e[1]=l,e[2]=m):m=e[2];const p=m;let _;e[3]!==h||e[4]!==c||e[5]!==a?(_=async T=>{T.preventDefault();const L=c.trim();!L||h||await a(L)},e[3]=h,e[4]=c,e[5]=a,e[6]=_):_=e[6];const g=_;let v;e[7]===Symbol.for("react.memo_cache_sentinel")?(v=n.jsxs(ss,{children:[n.jsx(is,{children:"Rename section"}),n.jsx(zo,{children:"Updates the display name. The internal key stays the same so pages referencing this section keep working."})]}),e[7]=v):v=e[7];let y;e[8]===Symbol.for("react.memo_cache_sentinel")?(y=n.jsx("label",{htmlFor:"section-rename-name",className:"text-xs font-medium text-muted-foreground",children:"Name"}),e[8]=y):y=e[8];let x;e[9]===Symbol.for("react.memo_cache_sentinel")?(x=T=>d(T.target.value),e[9]=x):x=e[9];let b;e[10]!==h||e[11]!==c?(b=n.jsxs("div",{className:"space-y-1.5",children:[y,n.jsx(qe,{id:"section-rename-name",value:c,onChange:x,autoFocus:!0,disabled:h})]}),e[10]=h,e[11]=c,e[12]=b):b=e[12];let S;e[13]===Symbol.for("react.memo_cache_sentinel")?(S=n.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:"Key"}),e[13]=S):S=e[13];let w;e[14]!==i?(w=n.jsxs("div",{className:"space-y-1.5",children:[S,n.jsx(qe,{value:i,readOnly:!0,disabled:!0,className:"font-mono"})]}),e[14]=i,e[15]=w):w=e[15];let k;e[16]!==b||e[17]!==w?(k=n.jsxs("div",{className:"space-y-4 py-4",children:[b,w]}),e[16]=b,e[17]=w,e[18]=k):k=e[18];let N;e[19]!==l?(N=()=>l(!1),e[19]=l,e[20]=N):N=e[20];let I;e[21]!==h||e[22]!==N?(I=n.jsx(ie,{type:"button",variant:"outline",onClick:N,disabled:h,children:"Cancel"}),e[21]=h,e[22]=N,e[23]=I):I=e[23];let D;e[24]!==h||e[25]!==c?(D=!c.trim()||h,e[24]=h,e[25]=c,e[26]=D):D=e[26];let R;e[27]!==h?(R=h?n.jsxs(n.Fragment,{children:[n.jsx(we,{size:14,className:"animate-spin"}),"Saving…"]}):"Save",e[27]=h,e[28]=R):R=e[28];let j;e[29]!==D||e[30]!==R?(j=n.jsx(ie,{type:"submit",disabled:D,children:R}),e[29]=D,e[30]=R,e[31]=j):j=e[31];let C;e[32]!==I||e[33]!==j?(C=n.jsxs(ti,{children:[I,j]}),e[32]=I,e[33]=j,e[34]=C):C=e[34];let A;e[35]!==g||e[36]!==k||e[37]!==C?(A=n.jsx(Lt,{className:"sm:max-w-md",children:n.jsxs("form",{onSubmit:g,children:[v,k,C]})}),e[35]=g,e[36]=k,e[37]=C,e[38]=A):A=e[38];let E;return e[39]!==p||e[40]!==s||e[41]!==A?(E=n.jsx(Bt,{open:s,onOpenChange:p,children:A}),e[39]=p,e[40]=s,e[41]=A,e[42]=E):E=e[42],E}const gn={post:"blog/loaders/Blogpost.ts",author:"blog/loaders/Author.ts",category:"blog/loaders/Category.ts"},W1="blog/sections/blocks/",ga=["posts","authors","categories"],Ti={posts:"post",authors:"author",categories:"category"};function Ri(t){return ga.includes(t)}const va={posts:"post",authors:"author",categories:"category"},Zh={posts:gn.post,authors:gn.author,categories:gn.category},U1=Object.fromEntries(Object.entries(Zh).map(([t,e])=>[e,t]));function K1(t){return typeof t=="string"?U1[t]??null:null}function Mr(t){return t&&typeof t=="object"&&!Array.isArray(t)?t:null}function Bs(t){return typeof t=="string"?t:""}function V1(t,e){switch(t){case"posts":return{label:Bs(e.title)||"Untitled post",subtitle:Bs(e.slug)};case"authors":return{label:Bs(e.name)||"Unnamed author",subtitle:Bs(e.email)};case"categories":return{label:Bs(e.name)||"Unnamed category",subtitle:Bs(e.slug)};default:{const s=t;throw new Error(`Unhandled blog kind: ${String(s)}`)}}}function Qh(t){const e={posts:[],authors:[],categories:[]};for(const[s,i]of Object.entries(t)){const r=Mr(i);if(!r)continue;const o=K1(r.__resolveType);if(!o)continue;const a=Mr(r[va[o]])??{},{label:l,subtitle:h}=V1(o,a);e[o].push({key:s,kind:o,label:l,subtitle:h})}for(const s of ga)e[s].sort((i,r)=>i.label.localeCompare(r.label));return e}function q1(t,e){return Qh(t)[e]}function $C(t,e){return q1(t,e).map(s=>({key:s.key,payload:ed(Mr(t[s.key])??void 0,e)}))}function ed(t,e){return t?Mr(t[va[e]])??{}:{}}function fl(t,e,s){return{name:t,__resolveType:Zh[e],[va[e]]:s}}function td(t){return`.deco/blocks/${encodeURIComponent(t)}.json`}function Wn(t){const e=new Uint8Array(Math.ceil(t/2));return crypto.getRandomValues(e),Array.from(e,s=>s.toString(16).padStart(2,"0")).join("").slice(0,t)}function ml(t,e){const s=`collections/blog/${e}/${Wn(12)}`;if(!Object.hasOwn(t,s))return s;throw new Error("Could not generate a unique blog block key")}function G1(t){switch(t){case"posts":return{title:"Untitled post",excerpt:"",slug:`untitled-${Wn(8)}`,date:new Date().toISOString().slice(0,10),image:"",authors:[],categories:[],sections:[]};case"authors":return{name:"New author",email:"",jobTitle:"",company:"",avatar:""};case"categories":return{name:"New category",slug:`category-${Wn(8)}`};default:{const e=t;throw new Error(`Unhandled blog kind: ${String(e)}`)}}}function zC(t){const e=new Set,s=[],i=t.manifest?.blocks??{};for(const r of Object.values(i))for(const o of Object.keys(r)){if(!o.startsWith(W1)||e.has(o))continue;e.add(o);const a=Ki(o,t);s.push({resolveType:o,title:a.title??Y1(o),description:a.description,icon:a.icon})}return s.sort((r,o)=>r.title.localeCompare(o.title))}function Y1(t){return(t.split("/").pop()??t).replace(/\.(tsx?|jsx?)$/,"")}const X1=["blog/sections/blocks/","site/sections/Blog/Post/"];function FC(t){return X1.some(e=>t.startsWith(e))}function sd({orgSlug:t,virtualMcpId:e,branch:s}){return Dt.decofile(`${t}/${e}/${s}`)}function id({orgSlug:t,virtualMcpId:e,branch:s},i){return`/api/${t}/sandbox/${encodeURIComponent(e)}/${encodeURIComponent(s)}/${i}`}function J1(t){const e=W.c(11),s=Gs();let i;e[0]!==t?(i=async l=>{const{blockKey:h,data:c}=l,d=await fetch(id(t,"write"),{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({path:td(h),content:JSON.stringify(c,null,2)})});if(!d.ok){const u=await d.json().catch(Z1);throw new Error(u.error??`Write failed (${d.status})`)}return d.json()},e[0]=t,e[1]=i):i=e[1];let r;e[2]!==t||e[3]!==s?(r=async l=>{const{blockKey:h,data:c}=l,d=sd(t);await s.cancelQueries({queryKey:d});const u=s.getQueryData(d);return s.setQueryData(d,f=>({...f??{},[h]:c})),{previous:u,queryKey:d}},e[2]=t,e[3]=s,e[4]=r):r=e[4];let o;e[5]!==s?(o=(l,h,c)=>{c?.queryKey&&s.setQueryData(c.queryKey,c.previous)},e[5]=s,e[6]=o):o=e[6];let a;return e[7]!==i||e[8]!==r||e[9]!==o?(a={mutationFn:i,onMutate:r,onError:o},e[7]=i,e[8]=r,e[9]=o,e[10]=a):a=e[10],Ys(a)}function Z1(){return{}}function Q1(t){const e=Gs();return Ys({mutationFn:async({blockKey:s})=>{const i=await fetch(id(t,"unlink"),{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({path:td(s)})});if(!i.ok){const r=await i.json().catch(()=>({}));throw new Error(r.error??`Delete failed (${i.status})`)}return i.json()},onMutate:async({blockKey:s})=>{const i=sd(t);await e.cancelQueries({queryKey:i});const r=e.getQueryData(i);return e.setQueryData(i,o=>{if(!o)return o;const{[s]:a,...l}=o;return l}),{previous:r,queryKey:i}},onError:(s,i,r)=>{r?.queryKey&&e.setQueryData(r.queryKey,r.previous)}})}function ex(t){const e=W.c(20),{open:s,onOpenChange:i,pageKey:r,decofile:o}=t,[a,l]=P.useState(!1),h=o[r];let c;e[0]!==h?(c=h===void 0?"// Page not found.":JSON.stringify(h,null,2),e[0]=h,e[1]=c):c=e[1];const d=c;let u;e[2]!==d?(u=()=>{navigator.clipboard.writeText(d).then(()=>{l(!0),setTimeout(()=>l(!1),2e3)})},e[2]=d,e[3]=u):u=e[3];const f=u;let m;e[4]===Symbol.for("react.memo_cache_sentinel")?(m=n.jsx(is,{className:"text-sm font-semibold",children:"Page JSON"}),e[4]=m):m=e[4];let p;e[5]!==a?(p=a?n.jsx(jc,{size:12}):n.jsx(Zt,{size:12}),e[5]=a,e[6]=p):p=e[6];const _=a?"Copied":"Copy";let g;e[7]!==f||e[8]!==p||e[9]!==_?(g=n.jsxs(ss,{className:"px-4 py-3 border-b flex-row items-center justify-between space-y-0",children:[m,n.jsxs(ie,{variant:"ghost",size:"sm",onClick:f,className:"h-7 gap-1.5 text-xs",children:[p,_]})]}),e[7]=f,e[8]=p,e[9]=_,e[10]=g):g=e[10];let v;e[11]!==d?(v=n.jsx(Qr,{className:"max-h-[70vh]",children:n.jsx("pre",{className:"p-4 text-xs font-mono text-foreground/90 whitespace-pre overflow-auto",children:d})}),e[11]=d,e[12]=v):v=e[12];let y;e[13]!==g||e[14]!==v?(y=n.jsxs(Lt,{className:"max-w-2xl p-0 gap-0",children:[g,v]}),e[13]=g,e[14]=v,e[15]=y):y=e[15];let x;return e[16]!==i||e[17]!==s||e[18]!==y?(x=n.jsx(Bt,{open:s,onOpenChange:i,children:y}),e[16]=i,e[17]=s,e[18]=y,e[19]=x):x=e[19],x}const pl=P.lazy(()=>Kt(()=>import("./app-editor-HtmK2stv.js"),__vite__mapDeps([152,1,2,45,46,47,16,3,5,76,6,7,8,9,10,11,12,13,14,15,4,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,77,49,71,78,72,79,50,80,48,81,82,83,57,84,59,60,153,89,90,91,92,93,94,95,96,97,98,99,100,101,56,102,58,103,104,105,106,107,65,108,55,109,70,110,69,66,111,112,113,114,115,64,116,86,87,51,52,53,54,61,62,63,67,68,73,74,75,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149])).then(t=>({default:t.AppEditor}))),tx=P.lazy(()=>Kt(()=>import("./post-editor-CK5Z9aaa.js"),__vite__mapDeps([154,1,2,3,6,7,8,9,10,11,12,13,14,15,16,4,5,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,48,69,47,70,71,49,46,72,73,74,75,90,91,92,45,93,94,95,96,97,98,99,100,84,101,102,103,104,105,106,107,108,109,110,145,146,131,147,127,129,144,113,86,87,78,80,50,81,82,83,76,77,79,155,153,89,111,112,114,115,116,117,118,119,120,121,122,123,124,125,126,128,130,132,133,134,135,136,137,138,139,140,141,142,143,148,149])).then(t=>({default:t.PostEditor}))),sx=P.lazy(()=>Kt(()=>import("./record-editor-DX9fm3fG.js"),__vite__mapDeps([156,1,2,49,71,72,80,8,39,40,7,16,19,17,6,9,10,11,12,13,14,15,3,4,5,18,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,41,42,43,44,48,50,81,82,83,57,84,59,60,155,153,89,90,91,92,45,46,47,93,94,95,96,97,98,99,100,101,56,102,58,103,104,105,106,107,65,108,55,109,70,110,69,66,111,112,113,114,115,64,116,78,86,87,51,52,53,54,61,62,63,67,68,73,74,75,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,79,137,138,139,140,141,142,143,144,145,146,147,148,149])).then(t=>({default:t.RecordEditor}))),ix=P.lazy(()=>Kt(()=>import("./sections-editor-CPbI26Rh.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149])).then(t=>({default:t.SectionsEditor}))),rx=P.lazy(()=>Kt(()=>import("./seo-editor-l7M-6riW.js"),__vite__mapDeps([157,1,2,4,6,7,8,9,10,11,12,13,14,15,16,3,5,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,85,71,79,76,77,49,78,72,50,80,48,81,82,83,57,84,59,60,89,90,91,92,93,94,95,96,97,98,99,100,101,56,102,58,103,104,105,106,107,65,108,55,109,70,110,69,66,111,112,113,114,115,64,116,86,87,51,52,53,54,61,62,63,67,68,73,74,75,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149])).then(t=>({default:t.SeoEditor}))),nx=P.lazy(()=>Kt(()=>import("./add-section-modal-I6U_0tzj.js"),__vite__mapDeps([88,1,2,6,7,8,9,10,11,12,13,14,15,16,3,4,5,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,48,49,89,90,91,92,45,46,47,93,94,95,96,57,97,98,99,100,84,101,56,102,58,103,104,105,106,107,65,108,55,109,70,71,110,69,66,82,111,112,113,81,114,115,64,116,78,86,87,59,60,51,52,53,54,61,62,63,67,68,72,73,74,75,117,50,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,79,137,138,139,140,141,142,143,144,145,146,147,148,149])).then(t=>({default:t.AddSectionModal}))),Un="oklch(0.65 0.15 160)";function ox(){const t=W.c(18),e=Ji(),{data:s}=Vs.useSession(),{currentBranch:i}=ts(),{org:r}=Te(),o=e?.entity?.id??null,a=s?.user?.id,l=e?.entity?.metadata,h=a&&i?Kr(l?.sandboxMap?.[a]?.[i]):{},c=Object.values(h),u=(c.find(ax)??c[0])?.previewUrl??null,f=qt(),m=e?.entity?.organization_id??"";let p;t[0]!==r.slug||t[1]!==m?(p={connectionId:ws,orgId:m,orgSlug:r.slug},t[0]=r.slug,t[1]=m,t[2]=p):p=t[2];const _=tt(p),g=Ro(_);let v;t[3]!==i||t[4]!==g||t[5]!==o?(v=()=>{if(!o)return;const w={virtualMcpId:o};i&&(w.branch=i),g.mutate(w)},t[3]=i,t[4]=g,t[5]=o,t[6]=v):v=t[6];const y=v,x=!!o&&!!i&&An.isStopped(o,i),b=Oh({previewUrl:u,appPaused:f.status.state==="paused",userStopped:x});if(b.kind!=="iframe"){let w;return t[7]!==b||t[8]!==y||t[9]!==f.lifecycle||t[10]!==f.phase?(w=n.jsx(ux,{state:b,claimPhase:f.phase,lifecycle:f.lifecycle,onStart:y}),t[7]=b,t[8]=y,t[9]=f.lifecycle,t[10]=f.phase,t[11]=w):w=t[11],w}if(!o||!i){let w;return t[12]===Symbol.for("react.memo_cache_sentinel")?(w=n.jsx(xi,{title:"Waiting for sandbox context…"}),t[12]=w):w=t[12],w}let S;return t[13]!==i||t[14]!==r.slug||t[15]!==u||t[16]!==o?(S=n.jsx(lx,{orgSlug:r.slug,virtualMcpId:o,branch:i,previewUrl:u}),t[13]=i,t[14]=r.slug,t[15]=u,t[16]=o,t[17]=S):S=t[17],S}function ax(t){return t.sandboxProviderKind!=="user-desktop"}function lx({orgSlug:t,virtualMcpId:e,branch:s,previewUrl:i}){const r={orgSlug:t,virtualMcpId:e,branch:s},{data:o,isLoading:a}=Qo(r),[l,h]=P.useState("pages"),[c,d]=P.useState(null),[u,f]=P.useState(null),[m,p]=P.useState(""),[_,g]=P.useState(l);_!==l&&(g(l),p(""));const v=2e3,y=15,{data:x,isLoading:b}=ea(r,{refetchInterval:J=>{if(l!=="apps"||!c||c.collection!=="apps")return!1;const fe=o?.[c.key]?.__resolveType;if(typeof fe!="string")return!1;const Se=J.state.data;return Se&&($n(fe,Se)||J.state.dataUpdateCount>=y)?!1:v}}),{catalog:S,isLoading:w}=v1(x??void 0,o??void 0,{enabled:l==="apps"}),k=ma(r),N=h1(r),I=J1(r),D=Q1(r),[R,j]=P.useState(null),[C,A]=P.useState(),[E,T]=P.useState(!1),[L,B]=P.useState(null),[O,F]=P.useState(null),[H,M]=P.useState(null);if(a||b)return n.jsx("div",{className:"h-full w-full flex items-center justify-center",children:n.jsx(we,{size:20,className:"animate-spin text-muted-foreground"})});if(!o||!x)return n.jsx(xi,{title:"Could not load site data."});const U=na(o).sort((J,xe)=>J.name.localeCompare(xe.name)),V=oa(o,x),K=kh(o,x),Y=Qh(o),Q=ga.some(J=>Y[J].length>0),se=Ri(l)?Y[l]:[];if(!ra(o,x)&&!Q)return n.jsx(xi,{icon:Fi,title:"No editable content",description:"This project doesn't expose any Deco pages, sections, or apps."});const he={pages:U.length,sections:V.length,apps:S.length,posts:Y.posts.length,authors:Y.authors.length,categories:Y.categories.length},z=new Set(U.map(J=>Ei(J.path))),te=new Set(U.map(J=>J.name)),ee=new Set(V.map(J=>J.name)),q=async J=>{const xe=o[J.key];if(!xe)return;const fe=Jh(o,J.key),Se=T1(o,J.key,Math.max(0,fe-1)),Ce=P1(xe.sections,Se);if(Ce)try{await k.mutateAsync({blockKey:J.key,data:{...xe,sections:Ce}}),ne.success(`Variant added to "${J.name}"`),d({collection:"pages",key:J.key,path:J.path})}catch(Ye){ne.error(Ye instanceof Error?Ye.message:"Could not add variant")}},$=()=>{A(void 0),j({mode:"create",sourceKey:null,initialName:"My new page",initialPath:"/example"})},ae=J=>{A(void 0),j({mode:"duplicate",sourceKey:J.key,initialName:dl(te,J.name),initialPath:A1(z,J.path)})},de=J=>{A(void 0),j({mode:"rename",sourceKey:J.key,initialName:J.name,initialPath:J.path})},me=async J=>{if(!R)return;const{mode:xe,sourceKey:fe}=R;try{if(xe==="create"){const Se=B1(J.name,J.path),Ce=M1(o,J.name);await k.mutateAsync({blockKey:Ce,data:Se}),ne.success(`Created "${J.name}"`),d({collection:"pages",key:Ce,path:J.path})}else if(xe==="duplicate"&&fe){const Se=o[fe];if(!Se)throw new Error("Source page not found");const{key:Ce,data:Ye}=I1({source:Se,pages:U,newName:J.name,newPath:J.path});await k.mutateAsync({blockKey:Ce,data:Ye}),ne.success(`Duplicated as "${J.name}"`),d({collection:"pages",key:Ce,path:J.path})}else if(xe==="rename"&&fe){const Se=o[fe];if(!Se)throw new Error("Page not found");const Ce={...Se,name:J.name,path:J.path};await k.mutateAsync({blockKey:fe,data:Ce}),ne.success("Page updated"),c?.collection==="pages"&&c.key===fe&&d({collection:"pages",key:fe,path:J.path})}j(null)}catch(Se){A(Se instanceof Error?Se.message:"Save failed")}},le=({path:J})=>{if(!R)return null;const xe=Ei(J);return(R.mode==="rename"?Ei(R.initialPath):null)!==xe&&z.has(xe)?`A page with path "${J}" already exists.`:null},G=async J=>{const xe=(J.title||J.resolveType.split("/").pop()||"").replace(/\.(tsx?|jsx?)$/,"").replace(/[^A-Za-z0-9_-]/g,""),fe=/^[A-Za-z]/.test(xe)&&xe.length>0?xe:"Section",Se=ul(o,fe),Ce={__resolveType:J.resolveType,name:Se};try{await k.mutateAsync({blockKey:Se,data:Ce}),ne.success(`Created section "${Se}"`),T(!1),d({collection:"sections",key:Se})}catch(Ye){ne.error(Ye instanceof Error?Ye.message:"Could not create section")}},pe=async J=>{const xe=o[J.key];if(!xe){ne.error("Section not found.");return}const fe=ul(o,J.key),Se=dl(ee,J.name),Ce={...xe,name:Se};try{await k.mutateAsync({blockKey:fe,data:Ce}),ne.success(`Duplicated "${J.name}"`),d({collection:"sections",key:fe})}catch(Ye){ne.error(Ye instanceof Error?Ye.message:"Duplicate failed")}},ue=async J=>{if(!L)return;const xe=o[L];if(!xe){ne.error("Section not found.");return}try{await k.mutateAsync({blockKey:L,data:{...xe,name:J}}),ne.success("Section renamed"),B(null)}catch(fe){ne.error(fe instanceof Error?fe.message:"Rename failed")}},ze=async J=>{const xe=ml(o,J),fe=fl(xe,J,G1(J));try{await I.mutateAsync({blockKey:xe,data:fe}),ne.success(`Created ${Ti[J]}`),d({collection:J,key:xe})}catch(Se){ne.error(Se instanceof Error?Se.message:"Could not create")}},ct=async J=>{const xe=o[J.key];if(!xe){ne.error("Record not found.");return}const fe=ml(o,J.kind),Se=J.kind==="posts"?"title":"name",Ce={...structuredClone(ed(xe,J.kind)),[Se]:`${J.label} (copy)`};try{await I.mutateAsync({blockKey:fe,data:fl(fe,J.kind,Ce)}),ne.success(`Duplicated "${J.label}"`),d({collection:J.kind,key:fe})}catch(Ye){ne.error(Ye instanceof Error?Ye.message:"Duplicate failed")}},Pe=async()=>{if(!O)return;const{kind:J,key:xe,label:fe}=O;try{J==="blog"?await D.mutateAsync({blockKey:xe}):await N.mutateAsync({blockKey:xe}),ne.success(`Deleted "${fe}"`),c&&c.key===xe&&d(null),F(null)}catch(Se){ne.error(Se instanceof Error?Se.message:"Delete failed")}},ft=N.isPending||D.isPending,li=O?.kind==="blog"?Ti[O.blogKind]:O?.kind??"item";return n.jsxs("div",{className:"flex h-full w-full",children:[n.jsx(cx,{active:l,counts:he,showBlog:Q,onSelect:J=>{h(J),d(null),f(null)}}),l!=="seo"&&l!=="site"&&n.jsx(hx,{activeCollection:l,pages:U,sections:V,appCatalog:S,appCatalogLoading:w,blogEntries:se,decofile:o,searchQuery:m,onSearchChange:p,selection:c,onSelect:J=>{d(J),f(null)},previewUrl:i,onCreate:()=>{l==="pages"?$():Ri(l)?ze(l):i?T(!0):ne.error("Start the preview dev server to add sections.")},onDuplicatePage:ae,onRenamePage:de,onAddPageVariant:q,onDeletePage:J=>F({kind:"page",key:J.key,label:J.name}),onEditPageSeo:J=>{d({collection:"pages",key:J.key,path:J.path}),f(J.key)},onViewPageJson:J=>M(J.key),onDuplicateSection:pe,onRenameSection:J=>B(J.key),onDeleteSection:J=>F({kind:"section",key:J.key,label:J.name}),onDuplicateBlog:ct,onDeleteBlog:J=>F({kind:"blog",blogKind:J.kind,key:J.key,label:J.label})}),n.jsx("div",{className:"flex-1 min-w-0",children:n.jsx(P.Suspense,{fallback:n.jsx("div",{className:"h-full flex items-center justify-center",children:n.jsx(we,{size:20,className:"animate-spin text-muted-foreground"})}),children:l==="site"?K?n.jsx(pl,{orgSlug:t,virtualMcpId:e,branch:s,blockKey:K.key,block:o[K.key],meta:x,title:"Site",excludeFields:["seo"]},`site:${K.key}`):n.jsx(xi,{title:"Site settings not found",description:"This project doesn't have a site app block (site/apps/site.ts)."}):l==="seo"?n.jsx(rx,{orgSlug:t,virtualMcpId:e,branch:s,decofile:o,meta:x,target:{kind:"site"},previewBaseUrl:i}):c?c.collection==="apps"?n.jsx(pl,{orgSlug:t,virtualMcpId:e,branch:s,blockKey:c.key,block:o[c.key],meta:x,schemaPending:typeof o[c.key]?.__resolveType=="string"&&!$n(String(o[c.key].__resolveType),x)},`app:${c.key}`):c.collection==="posts"?n.jsx(tx,{orgSlug:t,virtualMcpId:e,branch:s,blockKey:c.key,block:o[c.key],decofile:o,meta:x},`post:${c.key}`):c.collection==="authors"||c.collection==="categories"?n.jsx(sx,{orgSlug:t,virtualMcpId:e,branch:s,kind:c.collection,blockKey:c.key,block:o[c.key]},`${c.collection}:${c.key}`):n.jsx(ix,{orgSlug:t,virtualMcpId:e,branch:s,previewReady:!0,previewUrl:i??void 0,currentPath:c.collection==="pages"?c.path:"/",activePageBlockKey:c.collection==="pages"?c.key:null,activeGlobalBlockKey:c.collection==="sections"?c.key:null,initialEditSeo:c.collection==="pages"&&u===c.key,onExitSeo:()=>f(null)},c.collection==="pages"?`page:${c.key}`:`section:${c.key}`):n.jsx(xi,{title:`Select ${Ri(l)?`a ${Ti[l]}`:l==="pages"?"a page":l==="apps"?"an app":"a section"} to edit`,description:l==="apps"?"Browse all apps and select an installed one to edit its settings.":'Pick an item from the list, or click "+" to create one.'})})}),R&&n.jsx(F1,{open:!!R,mode:R.mode,initialName:R.initialName,initialPath:R.initialPath,isPending:k.isPending,error:C,validate:le,onSubmit:me,onOpenChange:J=>{J||(j(null),A(void 0))}}),L&&n.jsx(H1,{open:!!L,blockKey:L,initialName:V.find(J=>J.key===L)?.name??L,isPending:k.isPending,onSubmit:ue,onOpenChange:J=>{J||B(null)}}),E&&i&&n.jsx(P.Suspense,{fallback:null,children:n.jsx(nx,{open:E,onOpenChange:T,meta:x,decofile:o,previewBaseUrl:i,onSelect:G})}),H&&n.jsx(ex,{open:!!H,onOpenChange:J=>{J||M(null)},pageKey:H,decofile:o}),n.jsx(Cr,{open:!!O,onOpenChange:J=>{!J&&!ft&&F(null)},children:n.jsxs(kr,{children:[n.jsxs(jr,{children:[n.jsx(Nr,{children:`Delete ${li}?`}),n.jsx(Er,{children:O?.kind==="section"?`"${O.label}" will be removed. Pages that still reference it will lose this section.`:O?`"${O.label}" will be removed permanently. This can't be undone.`:null})]}),n.jsxs(Tr,{children:[n.jsx(Rr,{disabled:ft,children:"Cancel"}),n.jsx(Pr,{onClick:J=>{J.preventDefault(),Pe()},disabled:ft,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:ft?n.jsxs(n.Fragment,{children:[n.jsx(we,{size:14,className:"animate-spin"}),"Deleting…"]}):"Delete"})]})]})})]})}function cx(t){const e=W.c(33),{active:s,counts:i,showBlog:r,onSelect:o}=t;let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=n.jsx("div",{className:"px-3 h-12 flex items-center border-b shrink-0",children:n.jsx("span",{className:"text-sm font-medium",children:"Content"})}),e[0]=a):a=e[0];const l=s==="pages";let h;e[1]!==i.pages||e[2]!==o||e[3]!==l?(h=n.jsx(os,{id:"pages",icon:Bo,label:"Pages",count:i.pages,active:l,onSelect:o}),e[1]=i.pages,e[2]=o,e[3]=l,e[4]=h):h=e[4];const c=s==="sections";let d;e[5]!==i.sections||e[6]!==o||e[7]!==c?(d=n.jsx(os,{id:"sections",icon:Ws,label:"Sections",count:i.sections,active:c,onSelect:o}),e[5]=i.sections,e[6]=o,e[7]=c,e[8]=d):d=e[8];const u=s==="apps";let f;e[9]!==i.apps||e[10]!==o||e[11]!==u?(f=n.jsx(os,{id:"apps",icon:Qc,label:"Apps",count:i.apps,active:u,onSelect:o}),e[9]=i.apps,e[10]=o,e[11]=u,e[12]=f):f=e[12];let m;e[13]!==s||e[14]!==i.authors||e[15]!==i.categories||e[16]!==i.posts||e[17]!==o||e[18]!==r?(m=r&&n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"mt-3 flex items-center gap-1.5 px-2.5 pb-1 pt-1 text-xs font-medium text-muted-foreground/70",children:[n.jsx(Nc,{size:13,className:"shrink-0"}),"Blog"]}),n.jsx(os,{id:"posts",icon:Bc,label:"Posts",count:i.posts,active:s==="posts",onSelect:o}),n.jsx(os,{id:"authors",icon:Uo,label:"Authors",count:i.authors,active:s==="authors",onSelect:o}),n.jsx(os,{id:"categories",icon:Lc,label:"Categories",count:i.categories,active:s==="categories",onSelect:o})]}),e[13]=s,e[14]=i.authors,e[15]=i.categories,e[16]=i.posts,e[17]=o,e[18]=r,e[19]=m):m=e[19];const p=s==="site";let _;e[20]!==o||e[21]!==p?(_=n.jsx(os,{id:"site",icon:bf,label:"Site",active:p,onSelect:o}),e[20]=o,e[21]=p,e[22]=_):_=e[22];const g=s==="seo";let v;e[23]!==o||e[24]!==g?(v=n.jsx(os,{id:"seo",icon:yr,label:"SEO",active:g,onSelect:o}),e[23]=o,e[24]=g,e[25]=v):v=e[25];let y;return e[26]!==_||e[27]!==v||e[28]!==h||e[29]!==d||e[30]!==f||e[31]!==m?(y=n.jsxs("div",{className:"w-[208px] shrink-0 border-r flex flex-col",children:[a,n.jsxs("nav",{className:"flex flex-col p-1.5 gap-0.5",children:[h,d,f,m,_,v]})]}),e[26]=_,e[27]=v,e[28]=h,e[29]=d,e[30]=f,e[31]=m,e[32]=y):y=e[32],y}function os(t){const e=W.c(18),{id:s,icon:i,label:r,count:o,active:a,onSelect:l}=t;let h;e[0]!==s||e[1]!==l?(h=()=>l(s),e[0]=s,e[1]=l,e[2]=h):h=e[2];const c=a?"bg-accent text-accent-foreground":"text-muted-foreground hover:bg-muted hover:text-foreground";let d;e[3]!==c?(d=oe("flex w-full items-center gap-2 rounded-md px-2.5 py-1.5 text-left text-sm transition-colors cursor-pointer",c),e[3]=c,e[4]=d):d=e[4];let u;e[5]!==i?(u=n.jsx(i,{size:16,className:"shrink-0"}),e[5]=i,e[6]=u):u=e[6];let f;e[7]!==r?(f=n.jsx("span",{className:"flex-1 truncate",children:r}),e[7]=r,e[8]=f):f=e[8];let m;e[9]!==a||e[10]!==o?(m=o!==void 0&&n.jsx("span",{className:oe("shrink-0 text-xs tabular-nums",a?"text-accent-foreground/70":"text-muted-foreground/70"),children:o}),e[9]=a,e[10]=o,e[11]=m):m=e[11];let p;return e[12]!==h||e[13]!==d||e[14]!==u||e[15]!==f||e[16]!==m?(p=n.jsxs("button",{type:"button",onClick:h,className:d,children:[u,f,m]}),e[12]=h,e[13]=d,e[14]=u,e[15]=f,e[16]=m,e[17]=p):p=e[17],p}function hx(t){const e=W.c(57),{activeCollection:s,pages:i,sections:r,appCatalog:o,appCatalogLoading:a,blogEntries:l,decofile:h,previewUrl:c,searchQuery:d,onSearchChange:u,selection:f,onSelect:m,onCreate:p,onDuplicatePage:_,onRenamePage:g,onAddPageVariant:v,onDeletePage:y,onEditPageSeo:x,onViewPageJson:b,onDuplicateSection:S,onRenameSection:w,onDeleteSection:k,onDuplicateBlog:N,onDeleteBlog:I}=t;let D,R,j,C,A,E;if(e[0]!==s||e[1]!==o||e[2]!==a||e[3]!==l||e[4]!==h||e[5]!==v||e[6]!==p||e[7]!==I||e[8]!==y||e[9]!==k||e[10]!==N||e[11]!==_||e[12]!==S||e[13]!==x||e[14]!==g||e[15]!==w||e[16]!==u||e[17]!==m||e[18]!==b||e[19]!==i||e[20]!==c||e[21]!==d||e[22]!==r||e[23]!==f){const O=d.toLowerCase(),F=i.filter($=>!O||$.name.toLowerCase().includes(O)||$.path.toLowerCase().includes(O)),H=r.filter($=>!O||$.name.toLowerCase().includes(O)||$.key.toLowerCase().includes(O)||$.resolveType.toLowerCase().includes(O)),M=o.filter($=>!O||$.title.toLowerCase().includes(O)||$.app.toLowerCase().includes(O)||$.vendor.toLowerCase().includes(O)||$.category.toLowerCase().includes(O)),U=l.filter($=>!O||$.label.toLowerCase().includes(O)||$.subtitle.toLowerCase().includes(O)),V=`Search ${s}…`,K=Ri(s)?`Create new ${Ti[s]}`:s==="pages"?"Create new page":"Create new section",Y=s==="sections"&&!c,Q=s!=="apps",se=Y,he=Y?"Start the preview dev server to add sections":void 0;A="w-[300px] shrink-0 border-r flex flex-col min-h-0";let z;e[30]===Symbol.for("react.memo_cache_sentinel")?(z=n.jsx(Zc,{size:14,className:"shrink-0 text-muted-foreground","aria-hidden":!0}),e[30]=z):z=e[30];let te;e[31]!==u?(te=$=>u($.target.value),e[31]=u,e[32]=te):te=e[32];let ee;e[33]!==V||e[34]!==d||e[35]!==te?(ee=n.jsxs("div",{className:"flex flex-1 items-center gap-2 pl-1",children:[z,n.jsx("input",{type:"text",value:d,onChange:te,placeholder:V,"aria-label":V,className:"w-full bg-transparent text-sm outline-none placeholder:text-muted-foreground"})]}),e[33]=V,e[34]=d,e[35]=te,e[36]=ee):ee=e[36];let q;e[37]!==se||e[38]!==he||e[39]!==K||e[40]!==p||e[41]!==Q?(q=Q&&n.jsxs(Ne,{children:[n.jsx(ke,{asChild:!0,children:n.jsx(ie,{variant:"ghost",size:"icon",onClick:p,disabled:se,"aria-label":K,"aria-disabled":se,children:n.jsx(At,{size:14})})}),n.jsx(je,{side:"bottom",children:he??K})]}),e[37]=se,e[38]=he,e[39]=K,e[40]=p,e[41]=Q,e[42]=q):q=e[42],e[43]!==ee||e[44]!==q?(E=n.jsxs("div",{className:"px-2 h-12 flex items-center gap-1 border-b shrink-0",children:[ee,q]}),e[43]=ee,e[44]=q,e[45]=E):E=e[45],D=Qr,C="flex-1 min-h-0 [&_[data-slot=scroll-area-viewport]>div]:!block",R="flex flex-col gap-1 p-1.5",j=s==="pages"?F.length===0?n.jsx(ir,{hasItems:i.length>0,emptyLabel:"No pages yet.",emptyHint:'Click "+" to create your first page.'}):F.map($=>{const ae=f?.collection==="pages"&&f.key===$.key,de=Jh(h,$.key);return n.jsx(sr,{icon:Bo,title:$.name,subtitle:$.path,active:ae,variantCount:de,onClick:()=>m({collection:"pages",key:$.key,path:$.path}),menu:n.jsx(vn,{onDuplicate:()=>_($),onRename:()=>g($),onAddVariant:()=>v($),onEditSeo:()=>x($),onViewJson:()=>b($),onDelete:()=>y($)})},$.key)}):s==="sections"?H.length===0?n.jsx(ir,{hasItems:r.length>0,emptyLabel:"No saved sections yet.",emptyHint:'Click "+" to create one, or save a section from a page.'}):H.map($=>{const ae=f?.collection==="sections"&&f.key===$.key,de=$.resolveType.split("/").pop()?.replace(/\.tsx?$/,"");return n.jsx(sr,{icon:Ws,title:$.name,subtitle:de??$.resolveType,active:ae,onClick:()=>m({collection:"sections",key:$.key}),menu:n.jsx(vn,{onDuplicate:()=>S($),onRename:()=>w($),onDelete:()=>k($)})},$.key)}):s==="apps"?a?n.jsx("div",{className:"flex items-center justify-center py-8",children:n.jsx(we,{size:18,className:"animate-spin text-muted-foreground"})}):M.length===0?n.jsx(ir,{hasItems:o.length>0,emptyLabel:"No apps found.",emptyHint:"Try a different search term."}):M.map($=>{const ae=f?.collection==="apps"&&$.blockKey!==null&&f.key===$.blockKey;return n.jsx(sr,{icon:Qc,logoUrl:$.logo,title:$.title,subtitle:$.category,active:ae,trailing:$.installed?n.jsx("span",{className:"shrink-0 rounded-full bg-emerald-500/15 px-1.5 py-0.5 text-[10px] font-medium text-emerald-700 dark:text-emerald-400",children:"Installed"}):void 0,onClick:()=>{if(!$.installed||!$.blockKey){ne.message(`${$.title} is not installed on this site.`);return}m({collection:"apps",key:$.blockKey})}},$.id)}):U.length===0?n.jsx(ir,{hasItems:l.length>0,emptyLabel:`No ${s} yet.`,emptyHint:`Click "+" to create your first ${Ri(s)?Ti[s]:"item"}.`}):U.map($=>{const ae=f?.collection===$.kind&&f.key===$.key;return n.jsx(sr,{icon:$.kind==="posts"?Bc:$.kind==="authors"?Uo:Lc,title:$.label,subtitle:$.subtitle,active:ae,onClick:()=>m({collection:$.kind,key:$.key}),menu:n.jsx(vn,{onDuplicate:()=>N($),onDelete:()=>I($)})},$.key)}),e[0]=s,e[1]=o,e[2]=a,e[3]=l,e[4]=h,e[5]=v,e[6]=p,e[7]=I,e[8]=y,e[9]=k,e[10]=N,e[11]=_,e[12]=S,e[13]=x,e[14]=g,e[15]=w,e[16]=u,e[17]=m,e[18]=b,e[19]=i,e[20]=c,e[21]=d,e[22]=r,e[23]=f,e[24]=D,e[25]=R,e[26]=j,e[27]=C,e[28]=A,e[29]=E}else D=e[24],R=e[25],j=e[26],C=e[27],A=e[28],E=e[29];let T;e[46]!==R||e[47]!==j?(T=n.jsx("div",{className:R,children:j}),e[46]=R,e[47]=j,e[48]=T):T=e[48];let L;e[49]!==D||e[50]!==C||e[51]!==T?(L=n.jsx(D,{className:C,children:T}),e[49]=D,e[50]=C,e[51]=T,e[52]=L):L=e[52];let B;return e[53]!==A||e[54]!==E||e[55]!==L?(B=n.jsxs("div",{className:A,children:[E,L]}),e[53]=A,e[54]=E,e[55]=L,e[56]=B):B=e[56],B}function sr(t){const e=W.c(29),{icon:s,logoUrl:i,title:r,subtitle:o,active:a,variantCount:l,trailing:h,onClick:c,menu:d}=t;let u;e[0]!==s||e[1]!==a||e[2]!==i||e[3]!==l?(u=l&&l>1?n.jsxs(Ne,{children:[n.jsx(ke,{asChild:!0,children:n.jsx(s,{size:16,className:"shrink-0",style:{color:Un}})}),n.jsxs(je,{side:"right",children:[l," variants"]})]}):i?n.jsx("img",{src:i,alt:"",className:"size-8 shrink-0 rounded-lg object-cover bg-muted"}):n.jsx(s,{size:16,className:oe("shrink-0",a?"text-accent-foreground":"text-muted-foreground")}),e[0]=s,e[1]=a,e[2]=i,e[3]=l,e[4]=u):u=e[4];const f=u,m=a?"bg-accent text-accent-foreground":"hover:bg-muted";let p;e[5]!==m?(p=oe("group relative flex min-w-0 items-center rounded-md transition-colors",m),e[5]=m,e[6]=p):p=e[6];let _;e[7]!==r?(_=n.jsx("span",{className:"block truncate text-sm font-medium",children:r}),e[7]=r,e[8]=_):_=e[8];const g=a?"text-accent-foreground/70":"text-muted-foreground";let v;e[9]!==g?(v=oe("block truncate text-xs",g),e[9]=g,e[10]=v):v=e[10];let y;e[11]!==o||e[12]!==v?(y=n.jsx("span",{className:v,children:o}),e[11]=o,e[12]=v,e[13]=y):y=e[13];let x;e[14]!==_||e[15]!==y?(x=n.jsxs("span",{className:"min-w-0 flex-1",children:[_,y]}),e[14]=_,e[15]=y,e[16]=x):x=e[16];let b;e[17]!==c||e[18]!==f||e[19]!==x||e[20]!==h?(b=n.jsxs("button",{type:"button",onClick:c,className:"flex min-w-0 flex-1 items-center gap-2.5 rounded-md px-2.5 py-2 text-left cursor-pointer",children:[f,x,h]}),e[17]=c,e[18]=f,e[19]=x,e[20]=h,e[21]=b):b=e[21];let S;e[22]!==a||e[23]!==d?(S=d&&n.jsx("div",{className:oe("pr-1 opacity-0 transition-opacity group-hover:opacity-100",a&&"opacity-100"),children:d}),e[22]=a,e[23]=d,e[24]=S):S=e[24];let w;return e[25]!==S||e[26]!==p||e[27]!==b?(w=n.jsxs("div",{className:p,children:[b,S]}),e[25]=S,e[26]=p,e[27]=b,e[28]=w):w=e[28],w}function vn(t){const e=W.c(21),{onDuplicate:s,onRename:i,onAddVariant:r,onEditSeo:o,onViewJson:a,onDelete:l}=t;let h;e[0]===Symbol.for("react.memo_cache_sentinel")?(h=n.jsx(Qs,{asChild:!0,children:n.jsx("button",{type:"button","aria-label":"More actions",className:"flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground hover:bg-background hover:text-foreground cursor-pointer",onClick:dx,children:n.jsx(Yr,{size:14})})}),e[0]=h):h=e[0];let c;e[1]!==i?(c=i&&n.jsxs(et,{onClick:i,children:[n.jsx(Ko,{size:14}),"Rename"]}),e[1]=i,e[2]=c):c=e[2];let d;e[3]===Symbol.for("react.memo_cache_sentinel")?(d=n.jsx(Zt,{size:14}),e[3]=d):d=e[3];let u;e[4]!==s?(u=n.jsxs(et,{onClick:s,children:[d,"Duplicate"]}),e[4]=s,e[5]=u):u=e[5];let f;e[6]!==r?(f=r&&n.jsxs(n.Fragment,{children:[n.jsx(dr,{}),n.jsxs(et,{onClick:r,className:"cursor-pointer",style:{color:Un},children:[n.jsx(yf,{size:14,style:{color:Un}}),"Add variant"]})]}),e[6]=r,e[7]=f):f=e[7];let m;e[8]!==o||e[9]!==a?(m=(o||a)&&n.jsxs(n.Fragment,{children:[n.jsx(dr,{}),o&&n.jsxs(et,{onClick:o,children:[n.jsx(yr,{size:14}),"Edit SEO"]}),a&&n.jsxs(et,{onClick:a,children:[n.jsx(Lo,{size:14}),"View JSON"]})]}),e[8]=o,e[9]=a,e[10]=m):m=e[10];let p;e[11]===Symbol.for("react.memo_cache_sentinel")?(p=n.jsx(dr,{}),e[11]=p):p=e[11];let _;e[12]===Symbol.for("react.memo_cache_sentinel")?(_=n.jsx(Bi,{size:14}),e[12]=_):_=e[12];let g;e[13]!==l?(g=n.jsxs(et,{onClick:l,className:"text-destructive focus:text-destructive",children:[_,"Delete"]}),e[13]=l,e[14]=g):g=e[14];let v;return e[15]!==c||e[16]!==u||e[17]!==f||e[18]!==m||e[19]!==g?(v=n.jsxs(Zs,{children:[h,n.jsxs(ei,{align:"end",className:"w-44",children:[c,u,f,m,p,g]})]}),e[15]=c,e[16]=u,e[17]=f,e[18]=m,e[19]=g,e[20]=v):v=e[20],v}function dx(t){return t.stopPropagation()}function ir(t){const e=W.c(6),{hasItems:s,emptyLabel:i,emptyHint:r}=t;let o;e[0]!==r||e[1]!==i||e[2]!==s?(o=s?"No results match your search.":n.jsxs(n.Fragment,{children:[n.jsx("div",{children:i}),n.jsx("div",{className:"mt-1 text-muted-foreground/80",children:r})]}),e[0]=r,e[1]=i,e[2]=s,e[3]=o):o=e[3];let a;return e[4]!==o?(a=n.jsx("div",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:o}),e[4]=o,e[5]=a):a=e[5],a}function ux(t){const e=W.c(8),{state:s,claimPhase:i,lifecycle:r,onStart:o}=t;switch(s.kind){case"starting":{let a;e[0]!==i||e[1]!==r?(a=Uh({claimPhase:i,lifecycle:r}),e[0]=i,e[1]=r,e[2]=a):a=e[2];let l;return e[3]!==i||e[4]!==a?(l=n.jsx(Br,{kind:"starting",progress:a,claimPhase:i}),e[3]=i,e[4]=a,e[5]=l):l=e[5],l}case"suspended":{let a;return e[6]!==o?(a=n.jsx(Br,{kind:"suspended",onResume:o}),e[6]=o,e[7]=a):a=e[7],a}}}function xi(t){const e=W.c(10),{icon:s,title:i,description:r}=t;let o;e[0]!==s?(o=s&&n.jsx(s,{size:24,className:"text-muted-foreground/60"}),e[0]=s,e[1]=o):o=e[1];let a;e[2]!==i?(a=n.jsx("div",{children:i}),e[2]=i,e[3]=a):a=e[3];let l;e[4]!==r?(l=r&&n.jsx("div",{className:"text-xs text-muted-foreground/80 max-w-sm",children:r}),e[4]=r,e[5]=l):l=e[5];let h;return e[6]!==o||e[7]!==a||e[8]!==l?(h=n.jsxs("div",{className:"flex h-full w-full flex-col items-center justify-center gap-2 p-6 text-center text-sm text-muted-foreground",children:[o,a,l]}),e[6]=o,e[7]=a,e[8]=l,e[9]=h):h=e[9],h}function fx(t){const e=W.c(2),{virtualMcpId:s}=t,i=It(s);if(!Xs(i?.metadata)){let a;return e[0]===Symbol.for("react.memo_cache_sentinel")?(a=n.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center gap-2 text-center text-sm text-muted-foreground p-6",children:[n.jsx(Fi,{size:24,className:"text-muted-foreground/60"}),n.jsx("div",{children:"No content to edit."}),n.jsx("div",{className:"text-xs text-muted-foreground/80",children:"Connect a GitHub repository from the Settings tab to enable Content."})]}),e[0]=a):a=e[0],a}let o;return e[1]===Symbol.for("react.memo_cache_sentinel")?(o=n.jsx(ox,{}),e[1]=o):o=e[1],o}const xn={fast:{label:"Fast",subtitle:"Quick responses for simple tasks",icon:Dc},smart:{label:"Smart",subtitle:"Balanced quality and speed",icon:Zr},thinking:{label:"Thinking",subtitle:"Deeper reasoning for hard tasks",icon:kf}},mx=["fast","smart","thinking"];function px(t){const e=W.c(15),{tier:s,onSelect:i}=t,[r,o]=P.useState(!1),a=xn[s].icon;let l;e[0]!==a?(l=n.jsx(a,{size:14,className:"text-muted-foreground"}),e[0]=a,e[1]=l):l=e[1];const h=xn[s];let c;e[2]===Symbol.for("react.memo_cache_sentinel")?(c=n.jsx(ks,{size:14,className:"text-muted-foreground"}),e[2]=c):c=e[2];let d;e[3]!==l||e[4]!==h.label?(d=n.jsx(Ns,{asChild:!0,children:n.jsxs(ie,{variant:"outline",size:"sm",className:"w-fit gap-1.5",children:[l,h.label,c]})}),e[3]=l,e[4]=h.label,e[5]=d):d=e[5];let u;e[6]!==i||e[7]!==s?(u=mx.map(p=>{const _=xn[p],g=_.icon;return n.jsxs("button",{type:"button",onClick:()=>{i(p),o(!1)},className:oe("flex items-start gap-2 px-2 py-1.5 rounded-md text-left hover:bg-muted"),children:[n.jsx(g,{size:16,className:"shrink-0 text-muted-foreground mt-0.5"}),n.jsxs("div",{className:"flex-1",children:[n.jsx("div",{className:"text-sm",children:_.label}),n.jsx("div",{className:"text-xs text-muted-foreground",children:_.subtitle})]}),p===s&&n.jsx(si,{size:14,className:"text-foreground mt-0.5"})]},p)}),e[6]=i,e[7]=s,e[8]=u):u=e[8];let f;e[9]!==u?(f=n.jsx(Es,{align:"start",className:"p-1 w-64",children:n.jsx("div",{className:"flex flex-col",children:u})}),e[9]=u,e[10]=f):f=e[10];let m;return e[11]!==r||e[12]!==d||e[13]!==f?(m=n.jsxs(js,{open:r,onOpenChange:o,children:[d,f]}),e[11]=r,e[12]=d,e[13]=f,e[14]=m):m=e[14],m}function _x(t){const e=W.c(15),{tier:s,onTierChange:i,override:r,onOverrideChange:o}=t,[a,l]=P.useState(r!==null);let h;e[0]===Symbol.for("react.memo_cache_sentinel")?(h=n.jsx("span",{className:"text-xs font-semibold text-muted-foreground/60",children:"Model"}),e[0]=h):h=e[0];let c;e[1]!==o||e[2]!==i||e[3]!==r||e[4]!==s||e[5]!==a?(c=a?n.jsx(P.Suspense,{fallback:n.jsx(ie,{variant:"outline",size:"sm",disabled:!0,className:"w-fit",children:"Loading models…"}),children:n.jsx(gx,{override:r,onOverrideChange:o})}):n.jsx(px,{tier:s,onSelect:i}),e[1]=o,e[2]=i,e[3]=r,e[4]=s,e[5]=a,e[6]=c):c=e[6];let d;e[7]!==o?(d=m=>{l(m),m||o(null)},e[7]=o,e[8]=d):d=e[8];let u;e[9]!==d||e[10]!==a?(u=n.jsxs("label",{className:"flex items-center gap-2 text-xs text-muted-foreground cursor-pointer select-none",children:[n.jsx(Dr,{checked:a,onCheckedChange:d,className:"cursor-pointer"}),"Specific model"]}),e[9]=d,e[10]=a,e[11]=u):u=e[11];let f;return e[12]!==c||e[13]!==u?(f=n.jsxs("div",{className:"flex flex-col gap-2",children:[h,n.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[c,u]})]}),e[12]=c,e[13]=u,e[14]=f):f=e[14],f}function gx(t){const e=W.c(10),{override:s,onOverrideChange:i}=t,r=Tc(),o=r[0]?.id??null,[a,l]=P.useState(s?.credentialId??o);let h;e[0]!==s?(h=s?{modelId:s.modelId,title:s.title||s.modelId,keyId:s.credentialId,providerId:"deco",description:null,logo:null,capabilities:[],limits:null,costs:null}:null,e[0]=s,e[1]=h):h=e[1];const c=h;if(r.length===0){let f;return e[2]===Symbol.for("react.memo_cache_sentinel")?(f=n.jsx("span",{className:"text-xs text-muted-foreground italic",children:"Connect an AI provider in settings to pick a specific model."}),e[2]=f):f=e[2],f}let d;e[3]!==a||e[4]!==i?(d=f=>{const m=f.keyId??a??"";l(m),i({modelId:f.modelId,credentialId:m,title:f.title??f.modelId})},e[3]=a,e[4]=i,e[5]=d):d=e[5];let u;return e[6]!==a||e[7]!==c||e[8]!==d?(u=n.jsx("div",{className:"w-fit max-w-full [&_button]:rounded-md",children:n.jsx(Dm,{variant:"bordered",placeholder:"Pick a model",model:c,credentialId:a,onCredentialChange:l,onModelChange:d})}),e[6]=a,e[7]=c,e[8]=d,e[9]=u):u=e[9],u}const rd=[{key:"capabilities",heading:"Built-in capabilities",icon:Vo,tools:[{name:"web_search",title:"Web search",description:"Look up current information on the web",icon:Jr},{name:"generate_image",title:"Generate image",description:"Create images from a text prompt",icon:wm},{name:"subtask",title:"Subtask",description:"Spawn a focused sub-agent to handle part of the work",icon:Ii},{name:"user_ask",title:"Ask the user",description:"Pause to ask the user a clarifying question",icon:Sf}]},{key:"files",heading:"Files & code",icon:Fa,tools:[{name:"read",title:"Read File",description:"Read a file from the workspace",icon:Ic},{name:"write",title:"Write File",description:"Create or overwrite a file",icon:Ko},{name:"edit",title:"Edit File",description:"Make targeted edits to an existing file",icon:wf},{name:"grep",title:"Search Content",description:"Search file contents by pattern",icon:Wo},{name:"glob",title:"Find Files",description:"Find files by name pattern",icon:Fa},{name:"bash",title:"Run Command",description:"Run shell commands in the sandbox",icon:Cf}]},{key:"context",heading:"Context",icon:Oa,tools:[{name:"read_resource",title:"Read Resource",description:"Read an MCP resource by URI",icon:Oa},{name:"read_prompt",title:"Read Prompt",description:"Read an MCP prompt definition",icon:Nc}]},{key:"browser",heading:"Browser",icon:Ws,tools:[{name:"take_screenshot",title:"Take Screenshot",description:"Capture a screenshot of a web page",icon:km},{name:"scrape_url",title:"Scrape URL",description:"Fetch and extract content from a URL",icon:Ws},{name:"inspect_page",title:"Inspect Page",description:"Inspect a web page's structure",icon:Lo}]}],vx=rd.flatMap(t=>t.tools.map(e=>e.name));function xx(t){const e=t.replace(/[_-]+/g," ").trim();return e?e.toLowerCase().replace(/\b\w/g,s=>s.toUpperCase()):t}function bx(t){const e=W.c(5),{agentId:s,value:i,onChange:r}=t;let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=n.jsx("span",{className:"text-xs font-semibold text-muted-foreground/60",children:"Tools"}),e[0]=o):o=e[0];let a;return e[1]!==s||e[2]!==r||e[3]!==i?(a=n.jsxs("div",{className:"flex flex-col gap-2",children:[o,s?n.jsx(P.Suspense,{fallback:n.jsxs(ie,{variant:"outline",size:"sm",disabled:!0,className:"w-fit",children:[n.jsx(Vo,{size:14}),"Loading tools…"]}),children:n.jsx(yx,{agentId:s,value:i,onChange:r})}):n.jsx("span",{className:"text-xs text-muted-foreground italic",children:"Pick an agent first"})]}),e[1]=s,e[2]=r,e[3]=i,e[4]=a):a=e[4],a}function _l(t){const e=W.c(17),{value:s,checked:i,onToggle:r,title:o,description:a,leading:l}=t;let h;e[0]!==i?(h=n.jsx(en,{checked:i,className:"pointer-events-none mt-0.5"}),e[0]=i,e[1]=h):h=e[1];let c;e[2]!==l?(c=l&&n.jsx("span",{className:"mt-px shrink-0",children:l}),e[2]=l,e[3]=c):c=e[3];let d;e[4]!==o?(d=n.jsx("span",{className:"truncate text-sm leading-tight",children:o}),e[4]=o,e[5]=d):d=e[5];let u;e[6]!==a?(u=a&&n.jsx("span",{className:"line-clamp-2 text-xs leading-snug text-muted-foreground",children:a}),e[6]=a,e[7]=u):u=e[7];let f;e[8]!==d||e[9]!==u?(f=n.jsxs("div",{className:"flex min-w-0 flex-col gap-0.5",children:[d,u]}),e[8]=d,e[9]=u,e[10]=f):f=e[10];let m;return e[11]!==r||e[12]!==h||e[13]!==c||e[14]!==f||e[15]!==s?(m=n.jsxs(Pm,{value:s,onSelect:r,className:"items-start gap-2.5 py-2",children:[h,c,f]}),e[11]=r,e[12]=h,e[13]=c,e[14]=f,e[15]=s,e[16]=m):m=e[16],m}function gl(t){const e=W.c(20),{conn:s,label:i,icon:r,on:o,total:a,onToggle:l}=t,h=o===a;let c;e[0]!==r||e[1]!==s?(c=s?n.jsx(Vt,{icon:s.icon,name:s.title,size:"2xs"}):r?n.jsx(r,{size:14,className:"text-muted-foreground"}):n.jsx(jf,{size:14,className:"text-muted-foreground"}),e[0]=r,e[1]=s,e[2]=c):c=e[2];const d=s?.title??i??"Other tools";let u;e[3]!==d?(u=n.jsx("span",{className:"truncate",children:d}),e[3]=d,e[4]=u):u=e[4];let f;e[5]!==o||e[6]!==a?(f=n.jsxs("span",{className:"text-[11px] font-normal tabular-nums text-muted-foreground/70",children:[o,"/",a]}),e[5]=o,e[6]=a,e[7]=f):f=e[7];let m;e[8]!==l?(m=y=>{y.stopPropagation(),l()},e[8]=l,e[9]=m):m=e[9];const p=h?"None":"All";let _;e[10]!==m||e[11]!==p?(_=n.jsx("button",{type:"button",onClick:m,className:"text-[11px] font-medium text-primary hover:underline",children:p}),e[10]=m,e[11]=p,e[12]=_):_=e[12];let g;e[13]!==f||e[14]!==_?(g=n.jsxs("span",{className:"ml-auto flex items-center gap-2",children:[f,_]}),e[13]=f,e[14]=_,e[15]=g):g=e[15];let v;return e[16]!==c||e[17]!==u||e[18]!==g?(v=n.jsxs("div",{className:"flex items-center gap-2",children:[c,u,g]}),e[16]=c,e[17]=u,e[18]=g,e[19]=v):v=e[19],v}function yx(t){const e=W.c(70),{agentId:s,value:i,onChange:r}=t,{org:o}=Te(),[a,l]=P.useState(!1);let h;e[0]!==s||e[1]!==o.id||e[2]!==o.slug?(h={connectionId:s,orgId:o.id,orgSlug:o.slug},e[0]=s,e[1]=o.id,e[2]=o.slug,e[3]=h):h=e[3];const c=tt(h);let d;e[4]!==c?(d={client:c},e[4]=c,e[5]=d):d=e[5];const{data:u,isLoading:f}=Gf(d),m=Hi();let p,_,g,v,y,x,b,S,w,k,N,I,D;if(e[6]!==m||e[7]!==u?.tools||e[8]!==f||e[9]!==r||e[10]!==a||e[11]!==i){const E=new Map(m.map(jx)),T=new Map;for(const le of u?.tools??[]){const G=Ku(le._meta)??"__other__",pe=Vu(le.name,G==="__other__"?void 0:G),ue=le.title,ze=ue&&ue!==le.name?ue:xx(pe);T.has(G)||T.set(G,{clientId:G,conn:E.get(G),tools:[]}),T.get(G).tools.push({name:le.name,display:ze,description:le.description})}const L=[...T.values()].sort(kx),B=(u?.tools??[]).map(Cx),O=[...vx,...B],F=i===null?new Set(O):new Set(i),H=O.every(le=>F.has(le)),M=le=>r(O.every(G=>le.has(G))?null:[...le]),U=le=>{const G=new Set(F);G.has(le)?G.delete(le):G.add(le),M(G)},V=(le,G)=>{const pe=new Set(F);for(const ue of le)G?pe.add(ue):pe.delete(ue);M(pe)};v=js,D=a,y=l;let K;e[25]===Symbol.for("react.memo_cache_sentinel")?(K=n.jsx(Vo,{size:14,className:"text-muted-foreground"}),e[25]=K):K=e[25];const Y=H?"All tools":"Tools",Q=!H&&n.jsxs(jm,{variant:"secondary",className:"ml-0.5 h-5 px-1.5 text-[11px] tabular-nums",children:[F.size,"/",O.length]});let se;e[26]===Symbol.for("react.memo_cache_sentinel")?(se=n.jsx(ks,{size:14,className:"text-muted-foreground"}),e[26]=se):se=e[26],e[27]!==Y||e[28]!==Q?(x=n.jsx(Ns,{asChild:!0,children:n.jsxs(ie,{variant:"outline",size:"sm",className:"w-fit gap-1.5",children:[K,Y,Q,se]})}),e[27]=Y,e[28]=Q,e[29]=x):x=e[29],g=Es,N="p-0 w-80",I="start",_=Em,e[30]===Symbol.for("react.memo_cache_sentinel")?(w=n.jsx(Tm,{placeholder:"Search tools..."}),e[30]=w):w=e[30];const he=H?`All ${O.length} tools enabled`:`${F.size} of ${O.length} enabled`;let z;e[31]!==he?(z=n.jsx("span",{className:"text-xs text-muted-foreground",children:he}),e[31]=he,e[32]=z):z=e[32];let te;e[33]!==r?(te=()=>r(null),e[33]=r,e[34]=te):te=e[34];let ee;e[35]!==H||e[36]!==te?(ee=n.jsx("button",{type:"button",onClick:te,disabled:H,className:"text-xs font-medium text-primary hover:underline disabled:cursor-default disabled:opacity-40 disabled:no-underline",children:"Select all"}),e[35]=H,e[36]=te,e[37]=ee):ee=e[37];let q;e[38]===Symbol.for("react.memo_cache_sentinel")?(q=n.jsx("span",{className:"text-muted-foreground/30",children:"·"}),e[38]=q):q=e[38];let $;e[39]!==r?($=()=>r([]),e[39]=r,e[40]=$):$=e[40];const ae=F.size===0;let de;e[41]!==$||e[42]!==ae?(de=n.jsx("button",{type:"button",onClick:$,disabled:ae,className:"text-xs font-medium text-muted-foreground hover:underline disabled:cursor-default disabled:opacity-40 disabled:no-underline",children:"Clear"}),e[41]=$,e[42]=ae,e[43]=de):de=e[43];let me;e[44]!==ee||e[45]!==de?(me=n.jsxs("div",{className:"flex items-center gap-2",children:[ee,q,de]}),e[44]=ee,e[45]=de,e[46]=me):me=e[46],e[47]!==z||e[48]!==me?(k=n.jsxs("div",{className:"flex items-center justify-between border-b px-3 py-2",children:[z,me]}),e[47]=z,e[48]=me,e[49]=k):k=e[49],p=Rm,b="max-h-80",S=f?n.jsx("div",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:"Loading tools…"}):n.jsxs(n.Fragment,{children:[n.jsx(Nm,{children:"No tools found"}),rd.map(le=>{const G=le.tools.map(wx),pe=G.filter(ue=>F.has(ue)).length;return n.jsx(Ha,{heading:n.jsx(gl,{label:le.heading,icon:le.icon,on:pe,total:G.length,onToggle:()=>V(G,pe!==G.length)}),children:le.tools.map(ue=>n.jsx(_l,{value:`${ue.title} ${ue.name}`,checked:F.has(ue.name),onToggle:()=>U(ue.name),title:ue.title,description:ue.description,leading:n.jsx(ue.icon,{size:16,className:"text-muted-foreground"})},ue.name))},le.key)}),L.map(le=>{const G=le.tools.map(Sx),pe=G.filter(ue=>F.has(ue)).length;return n.jsx(Ha,{heading:n.jsx(gl,{conn:le.conn,on:pe,total:G.length,onToggle:()=>V(G,pe!==G.length)}),children:le.tools.map(ue=>n.jsx(_l,{value:`${ue.display} ${ue.name} ${le.conn?.title??""}`,checked:F.has(ue.name),onToggle:()=>U(ue.name),title:ue.display,description:ue.description},ue.name))},le.clientId)})]}),e[6]=m,e[7]=u?.tools,e[8]=f,e[9]=r,e[10]=a,e[11]=i,e[12]=p,e[13]=_,e[14]=g,e[15]=v,e[16]=y,e[17]=x,e[18]=b,e[19]=S,e[20]=w,e[21]=k,e[22]=N,e[23]=I,e[24]=D}else p=e[12],_=e[13],g=e[14],v=e[15],y=e[16],x=e[17],b=e[18],S=e[19],w=e[20],k=e[21],N=e[22],I=e[23],D=e[24];let R;e[50]!==p||e[51]!==b||e[52]!==S?(R=n.jsx(p,{className:b,children:S}),e[50]=p,e[51]=b,e[52]=S,e[53]=R):R=e[53];let j;e[54]!==_||e[55]!==R||e[56]!==w||e[57]!==k?(j=n.jsxs(_,{children:[w,k,R]}),e[54]=_,e[55]=R,e[56]=w,e[57]=k,e[58]=j):j=e[58];let C;e[59]!==g||e[60]!==j||e[61]!==N||e[62]!==I?(C=n.jsx(g,{className:N,align:I,children:j}),e[59]=g,e[60]=j,e[61]=N,e[62]=I,e[63]=C):C=e[63];let A;return e[64]!==v||e[65]!==y||e[66]!==x||e[67]!==C||e[68]!==D?(A=n.jsxs(v,{open:D,onOpenChange:y,children:[x,C]}),e[64]=v,e[65]=y,e[66]=x,e[67]=C,e[68]=D,e[69]=A):A=e[69],A}function Sx(t){return t.name}function wx(t){return t.name}function Cx(t){return t.name}function kx(t,e){return(t.conn?.title??t.clientId).localeCompare(e.conn?.title??e.clientId)}function jx(t){return[t.id,t]}function Pi(t){const e=t.trim().split(/\s+/);return e.length!==5?!1:e.every(s=>/^[\d*/,-]+$/.test(s))}function Nx(t){if(!t)return"Unknown schedule";const e=t.trim();if(e==="* * * * *")return"Every minute";if(e==="0 * * * *")return"Every hour";if(e==="0 0 * * *")return"Every day";if(e==="0 0 * * 1")return"Every week";const s=e.match(/^\*\/(\d+)\s+\*\s+\*\s+\*\s+\*$/);if(s)return`Every ${s[1]} minutes`;const i=e.match(/^0\s+\*\/(\d+)\s+\*\s+\*\s+\*$/);if(i)return`Every ${i[1]} hours`;const r=e.match(/^0\s+0\s+\*\/(\d+)\s+\*\s+\*$/);if(r){const l=parseInt(r[1]??"1");return l%7===0?`Every ${l/7} weeks`:`Every ${l} days`}const o=e.match(/^(\d+)\s+(\d+)\s+\*\s+\*\s+\*$/);if(o){const l=(o[2]??"0").padStart(2,"0"),h=(o[1]??"0").padStart(2,"0");return`Every day at ${l}:${h} UTC`}const a=e.match(/^(\d+)\s+(\d+)\s+\*\s+\*\s+(\d)$/);if(a){const h=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"][parseInt(a[3]??"0")]??"day",c=(a[2]??"0").padStart(2,"0"),d=(a[1]??"0").padStart(2,"0");return`Every ${h} at ${c}:${d} UTC`}return t}function Ex(t,e){const s=Math.max(1,t);switch(e){case"minutes":return s===1?"* * * * *":`*/${s} * * * *`;case"hours":return s===1?"0 * * * *":`0 */${s} * * *`;case"days":return s===1?"0 0 * * *":`0 0 */${s} * *`;case"weeks":return s===1?"0 0 * * 1":`0 0 */${s*7} * *`}}function Tx(t){const e=t.trim();if(e==="* * * * *")return{count:1,unit:"minutes"};if(e==="0 * * * *")return{count:1,unit:"hours"};if(e==="0 0 * * *")return{count:1,unit:"days"};if(e==="0 0 * * 1")return{count:1,unit:"weeks"};const s=e.match(/^\*\/(\d+)\s+\*\s+\*\s+\*\s+\*$/);if(s)return{count:parseInt(s[1]),unit:"minutes"};const i=e.match(/^0\s+\*\/(\d+)\s+\*\s+\*\s+\*$/);if(i)return{count:parseInt(i[1]),unit:"hours"};const r=e.match(/^0\s+0\s+\*\/(\d+)\s+\*\s+\*$/);if(r){const o=parseInt(r[1]);return o%7===0?{count:o/7,unit:"weeks"}:{count:o,unit:"days"}}return null}function Rx(t,e){return e===1?{minutes:"minute",hours:"hour",days:"day",weeks:"week"}[t]??t:t}const Px=[{label:"5 minutes",cron:"*/5 * * * *"},{label:"Hour",cron:"0 * * * *"},{label:"Day",cron:"0 0 * * *"},{label:"Week",cron:"0 0 * * 1"}];function Dx({automationId:t,open:e,onOpenChange:s,onCustomSelect:i,onEventSelect:r,onWebhookCreated:o}){const{triggerAdd:a}=Wi(),[l,h]=P.useState(!1),c=e??l,d=m=>{s?s(m):h(m)},u=async m=>{try{await a.mutateAsync({automation_id:t,type:"cron",cron_expression:m}),ne.success("Starter added"),d(!1)}catch(p){const _=p instanceof Error?p.message:"Failed to add starter";ne.error(_)}},f=async()=>{try{const m=await a.mutateAsync({automation_id:t,type:"webhook"});d(!1),m.webhook?o?.(m.webhook):ne.success("Webhook starter added")}catch(m){const p=m instanceof Error?m.message:"Failed to add webhook starter";ne.error(p)}};return n.jsxs(Zs,{open:c,onOpenChange:d,children:[n.jsx(Qs,{asChild:!0,children:n.jsxs(ie,{variant:"outline",size:"sm",children:[n.jsx(At,{size:14}),"Add Starter"]})}),n.jsxs(ei,{align:"end",className:"w-[200px]",children:[n.jsxs(Jf,{children:[n.jsxs(Zf,{className:"gap-2.5",children:[n.jsx(ki,{size:14,className:"text-muted-foreground shrink-0"}),"Every..."]}),n.jsx(Qf,{className:"w-[160px]",children:Px.map(m=>n.jsxs(et,{className:"gap-2.5",onSelect:()=>u(m.cron),disabled:a.isPending,children:[n.jsx(ki,{size:14,className:"text-muted-foreground shrink-0"}),"Every ",m.label]},m.cron))})]}),n.jsxs(et,{className:"gap-2.5",onSelect:()=>{d(!1),i?.()},children:[n.jsx(ki,{size:14,className:"text-muted-foreground shrink-0"}),"Custom (cron)"]}),n.jsxs(et,{className:"gap-2.5",onSelect:()=>{d(!1),r?.()},children:[n.jsx(Li,{size:14,className:"text-muted-foreground shrink-0"}),"Event"]}),n.jsxs(et,{className:"gap-2.5",onSelect:()=>{f()},disabled:a.isPending,children:[n.jsx(Jr,{size:14,className:"text-muted-foreground shrink-0"}),"Webhook"]})]})]})}function nd(t){const e=W.c(31),{open:s,onOpenChange:i,url:r,token:o,title:a,description:l}=t,h=a===void 0?"Webhook ready":a,c=l===void 0?"Send a POST to this URL with the bearer token to fire the automation. The token is shown once — copy it now.":l,[d,u]=P.useState(null),[f,m]=P.useState("curl"),[p,_]=P.useState("header"),g=P.useId();let v;e[0]===Symbol.for("react.memo_cache_sentinel")?(v=async(E,T)=>{try{await navigator.clipboard.writeText(E),u(T),ne.success("Copied"),setTimeout(()=>u(null),1500)}catch{ne.error("Failed to copy")}},e[0]=v):v=e[0];const y=v;let x;e[1]!==p||e[2]!==o||e[3]!==r?(x=r&&o&&p==="url"?`${r.replace(/\/$/,"")}/${o}`:r??"",e[1]=p,e[2]=o,e[3]=r,e[4]=x):x=e[4];const b=x,S=r&&o?p==="header"?`curl -X POST "${b}" \\
277
277
  -H "Authorization: Bearer ${o}" \\
278
278
  -H "Content-Type: application/json" \\
279
279
  -d '{"hello":"world"}'`:`curl -X POST "${b}" \\
@@ -292,7 +292,7 @@ ${te}`:te;c.setValue("metadata.instructions",ee,{shouldDirty:!0})},K=new Set(d.m
292
292
  },
293
293
  body: JSON.stringify({ hello: "world" }),
294
294
  });`:"",k=f==="curl"?S:w;let N;e[5]!==h?(N=n.jsx(is,{children:h}),e[5]=h,e[6]=N):N=e[6];let I;e[7]!==c?(I=n.jsx(zo,{children:c}),e[7]=c,e[8]=I):I=e[8];let D;e[9]!==N||e[10]!==I?(D=n.jsxs(ss,{children:[N,I]}),e[9]=N,e[10]=I,e[11]=D):D=e[11];let R;e[12]!==p||e[13]!==d||e[14]!==b||e[15]!==f||e[16]!==k||e[17]!==o||e[18]!==g||e[19]!==r?(R=r&&o?n.jsxs("div",{className:"flex flex-col gap-3 min-w-0",children:[n.jsxs("div",{className:"flex flex-col gap-1",children:[n.jsx("span",{className:"text-xs font-semibold text-muted-foreground",children:"URL"}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("code",{className:"flex-1 min-w-0 text-xs font-mono bg-muted rounded-md px-2 py-1.5 truncate",children:b}),n.jsxs(ie,{size:"sm",variant:"outline",onClick:()=>y(b,"url"),children:[n.jsx(Zt,{size:13}),d==="url"?"Copied":"Copy"]})]})]}),n.jsxs("div",{className:"flex flex-col gap-1",children:[n.jsx("span",{className:"text-xs font-semibold text-muted-foreground",children:"Token (shown once)"}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("code",{className:"flex-1 min-w-0 text-xs font-mono bg-muted rounded-md px-2 py-1.5 truncate",children:o}),n.jsxs(ie,{size:"sm",variant:"outline",onClick:()=>y(o,"token"),children:[n.jsx(Zt,{size:13}),d==="token"?"Copied":"Copy"]})]})]}),n.jsxs("div",{className:"flex flex-col gap-2",children:[n.jsx("span",{className:"text-xs font-semibold text-muted-foreground",children:"Snippet"}),n.jsxs("div",{className:"flex items-center justify-between gap-3",children:[n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsx(Ho,{value:f,onValueChange:E=>m(E),children:n.jsxs(Fo,{className:"h-8 p-[2px]",children:[n.jsx(vs,{value:"curl",className:"h-7 px-2.5 text-xs",children:"curl"}),n.jsx(vs,{value:"fetch",className:"h-7 px-2.5 text-xs",children:"fetch"})]})}),n.jsxs("label",{htmlFor:g,className:"flex items-center gap-1.5 text-xs text-muted-foreground cursor-pointer select-none",children:[n.jsx(en,{id:g,checked:p==="url",onCheckedChange:E=>_(E?"url":"header")}),"Token in URL"]})]}),n.jsxs(ie,{size:"sm",variant:"outline",onClick:()=>y(k,"example"),children:[n.jsx(Zt,{size:13}),d==="example"?"Copied":"Copy"]})]}),n.jsx("div",{className:"rounded-md border overflow-hidden min-w-0",children:n.jsx(im,{code:k,language:f==="curl"?"shell":"typescript",readOnly:!0,disableDiagnostics:!0,height:180})})]})]}):null,e[12]=p,e[13]=d,e[14]=b,e[15]=f,e[16]=k,e[17]=o,e[18]=g,e[19]=r,e[20]=R):R=e[20];let j;e[21]!==i?(j=n.jsx(ti,{children:n.jsx(ie,{onClick:()=>i(!1),children:"Done"})}),e[21]=i,e[22]=j):j=e[22];let C;e[23]!==D||e[24]!==R||e[25]!==j?(C=n.jsxs(Lt,{className:"max-w-lg",children:[D,R,j]}),e[23]=D,e[24]=R,e[25]=j,e[26]=C):C=e[26];let A;return e[27]!==i||e[28]!==s||e[29]!==C?(A=n.jsx(Bt,{open:s,onOpenChange:i,children:C}),e[27]=i,e[28]=s,e[29]=C,e[30]=A):A=e[30],A}function Ax(t){const e=W.c(83),{trigger:s,automationId:i,connectionName:r}=t,{triggerAdd:o,triggerRemove:a,triggerRotateToken:l}=Wi(),[h,c]=P.useState(!1),[d,u]=P.useState(!1),[f,m]=P.useState(null);let p;e[0]!==s.cron_expression?(p=s.cron_expression?Tx(s.cron_expression):null,e[0]=s.cron_expression,e[1]=p):p=e[1];const _=p,[g,v]=P.useState(_?.count??1),[y,x]=P.useState(!1),[b,S]=P.useState(s.cron_expression??""),w=a.isPending||o.isPending||l.isPending,k=s.type==="cron",N=s.type==="webhook";let I;e[2]!==i||e[3]!==a||e[4]!==s.id?(I=async()=>{try{await a.mutateAsync({trigger_id:s.id,automation_id:i}),ne.success("Starter removed")}catch{ne.error("Failed to remove starter")}c(!1)},e[2]=i,e[3]=a,e[4]=s.id,e[5]=I):I=e[5];const D=I;let R;e[6]!==o||e[7]!==i||e[8]!==b||e[9]!==a||e[10]!==s.cron_expression||e[11]!==s.id?(R=async()=>{const G=b.trim();if(!G||!Pi(G)||G===s.cron_expression){x(!1),S(s.cron_expression??"");return}try{await o.mutateAsync({automation_id:i,type:"cron",cron_expression:G}),await a.mutateAsync({trigger_id:s.id,automation_id:i}),x(!1)}catch{ne.error("Failed to update starter"),S(s.cron_expression??""),x(!1)}},e[6]=o,e[7]=i,e[8]=b,e[9]=a,e[10]=s.cron_expression,e[11]=s.id,e[12]=R):R=e[12];const j=R;let C;e[13]!==i||e[14]!==l||e[15]!==s.id?(C=async()=>{u(!1);try{const G=await l.mutateAsync({trigger_id:s.id,automation_id:i});m({url:G.url,token:G.token})}catch(G){const pe=G,ue=pe instanceof Error?pe.message:"Failed to rotate token";ne.error(ue)}},e[13]=i,e[14]=l,e[15]=s.id,e[16]=C):C=e[16];const A=C;let E;e[17]!==o||e[18]!==i||e[19]!==_||e[20]!==a||e[21]!==s.cron_expression||e[22]!==s.id?(E=async G=>{if(!_)return;const pe=_.unit==="minutes"?5:1,ue=Math.max(pe,G);ue!==G&&v(ue);const ze=Ex(ue,_.unit);if(ze!==s.cron_expression)try{await o.mutateAsync({automation_id:i,type:"cron",cron_expression:ze}),await a.mutateAsync({trigger_id:s.id,automation_id:i})}catch{ne.error("Failed to update starter"),v(_.count)}},e[17]=o,e[18]=i,e[19]=_,e[20]=a,e[21]=s.cron_expression,e[22]=s.id,e[23]=E):E=e[23];const T=E;let L;e[24]!==k||e[25]!==N?(L=k?n.jsx(ki,{size:14,className:"text-muted-foreground shrink-0"}):N?n.jsx(Jr,{size:14,className:"text-muted-foreground shrink-0"}):n.jsx(Li,{size:14,className:"text-muted-foreground shrink-0"}),e[24]=k,e[25]=N,e[26]=L):L=e[26];let B;e[27]!==r||e[28]!==g||e[29]!==b||e[30]!==T||e[31]!==j||e[32]!==_||e[33]!==k||e[34]!==y||e[35]!==w||e[36]!==N||e[37]!==s.cron_expression||e[38]!==s.event_type||e[39]!==s.params?(B=_&&k?n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"text-sm text-muted-foreground",children:"Every"}),n.jsx("input",{type:"number",min:_.unit==="minutes"?5:1,value:g,onChange:G=>v(parseInt(G.target.value)||1),onBlur:()=>T(g),onKeyDown:G=>{G.key==="Enter"&&G.target.blur(),G.key==="Escape"&&v(_.count)},disabled:w,className:"w-12 text-center text-sm h-7 border border-border rounded-md bg-background px-1 focus:outline-none focus:ring-1 focus:ring-ring"}),n.jsx("span",{className:"text-sm",children:Rx(_.unit,g)})]}):k&&y?n.jsxs(n.Fragment,{children:[n.jsx("input",{type:"text",value:b,onChange:G=>S(G.target.value),onBlur:j,onKeyDown:G=>{G.key==="Enter"&&G.target.blur(),G.key==="Escape"&&(x(!1),S(s.cron_expression??""))},className:"flex-1 text-sm font-mono bg-transparent outline-none",autoFocus:!0}),b&&!Pi(b)&&n.jsx("span",{className:"text-xs text-muted-foreground/60 shrink-0",children:"invalid"})]}):n.jsxs("div",{className:"flex flex-col gap-0.5 flex-1 min-w-0",children:[n.jsx("span",{className:"text-sm font-mono text-xs text-muted-foreground truncate",children:k?Nx(s.cron_expression??""):N?"Webhook · POST to fire":`${s.event_type}${r?` · ${r}`:""}`}),!k&&!N&&s.params&&Object.keys(s.params).length>0&&n.jsx("span",{className:"text-xs text-muted-foreground/60 truncate",children:Object.entries(s.params).map(Ix).join(", ")})]}),e[27]=r,e[28]=g,e[29]=b,e[30]=T,e[31]=j,e[32]=_,e[33]=k,e[34]=y,e[35]=w,e[36]=N,e[37]=s.cron_expression,e[38]=s.event_type,e[39]=s.params,e[40]=B):B=e[40];let O;e[41]!==w?(O=w&&n.jsx(we,{size:13,className:"animate-spin text-muted-foreground"}),e[41]=w,e[42]=O):O=e[42];let F;e[43]!==_||e[44]!==k||e[45]!==y||e[46]!==s.cron_expression?(F=k&&!_&&!y&&n.jsx(ie,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 opacity-0 group-hover:opacity-100 transition-opacity",onClick:()=>{S(s.cron_expression??""),x(!0)},children:n.jsx(Ko,{size:13,className:"text-muted-foreground"})}),e[43]=_,e[44]=k,e[45]=y,e[46]=s.cron_expression,e[47]=F):F=e[47];let H;e[48]!==N?(H=N&&n.jsx(ie,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 opacity-0 group-hover:opacity-100 transition-opacity",title:"Rotate token",onClick:()=>u(!0),children:n.jsx(Ai,{size:13,className:"text-muted-foreground"})}),e[48]=N,e[49]=H):H=e[49];let M;e[50]===Symbol.for("react.memo_cache_sentinel")?(M=n.jsx(ie,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 opacity-0 group-hover:opacity-100 transition-opacity",onClick:()=>c(!0),children:n.jsx(fs,{size:13,className:"text-muted-foreground"})}),e[50]=M):M=e[50];let U;e[51]!==H||e[52]!==O||e[53]!==F?(U=n.jsxs("div",{className:"ml-auto flex items-center gap-1",children:[O,F,H,M]}),e[51]=H,e[52]=O,e[53]=F,e[54]=U):U=e[54];let V;e[55]!==U||e[56]!==L||e[57]!==B?(V=n.jsxs("div",{className:"flex items-center gap-2.5 px-3 py-2.5 rounded-lg border border-border bg-background group",children:[L,B,U]}),e[55]=U,e[56]=L,e[57]=B,e[58]=V):V=e[58];let K;e[59]===Symbol.for("react.memo_cache_sentinel")?(K=n.jsxs(jr,{children:[n.jsx(Nr,{children:"Remove Starter"}),n.jsx(Er,{children:"Are you sure you want to remove this starter?"})]}),e[59]=K):K=e[59];let Y;e[60]===Symbol.for("react.memo_cache_sentinel")?(Y=n.jsx(Rr,{children:"Cancel"}),e[60]=Y):Y=e[60];let Q;e[61]!==D?(Q=n.jsxs(kr,{children:[K,n.jsxs(Tr,{children:[Y,n.jsx(Pr,{onClick:D,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Remove"})]})]}),e[61]=D,e[62]=Q):Q=e[62];let se;e[63]!==h||e[64]!==Q?(se=n.jsx(Cr,{open:h,onOpenChange:c,children:Q}),e[63]=h,e[64]=Q,e[65]=se):se=e[65];let he;e[66]===Symbol.for("react.memo_cache_sentinel")?(he=n.jsxs(jr,{children:[n.jsx(Nr,{children:"Rotate webhook token"}),n.jsx(Er,{children:"A new token will be generated and the current token will stop working. Any senders using the old token must be updated."})]}),e[66]=he):he=e[66];let z;e[67]===Symbol.for("react.memo_cache_sentinel")?(z=n.jsx(Rr,{children:"Cancel"}),e[67]=z):z=e[67];let te;e[68]!==A?(te=n.jsxs(kr,{children:[he,n.jsxs(Tr,{children:[z,n.jsx(Pr,{onClick:A,children:"Rotate"})]})]}),e[68]=A,e[69]=te):te=e[69];let ee;e[70]!==d||e[71]!==te?(ee=n.jsx(Cr,{open:d,onOpenChange:u,children:te}),e[70]=d,e[71]=te,e[72]=ee):ee=e[72];const q=f!==null;let $;e[73]===Symbol.for("react.memo_cache_sentinel")?($=G=>{G||m(null)},e[73]=$):$=e[73];const ae=f?.url??null,de=f?.token??null;let me;e[74]!==q||e[75]!==ae||e[76]!==de?(me=n.jsx(nd,{open:q,onOpenChange:$,url:ae,token:de,title:"New webhook token",description:"The previous token has been revoked. Copy the new token now — it will not be shown again."}),e[74]=q,e[75]=ae,e[76]=de,e[77]=me):me=e[77];let le;return e[78]!==V||e[79]!==se||e[80]!==ee||e[81]!==me?(le=n.jsxs(n.Fragment,{children:[V,se,ee,me]}),e[78]=V,e[79]=se,e[80]=ee,e[81]=me,e[82]=le):le=e[82],le}function Ix(t){const[e,s]=t;return`${e}: ${s}`}const Bx=30;function Lx(t,e){switch(e.type){case"accumulate":{const s=t??{start:e.now,fields:new Set,saveCount:0},i=new Set(s.fields);for(const r of e.fields)i.add(r);return{...s,fields:i,saveCount:s.saveCount+1}}case"reset":return null}}function Mx(t){const e=W.c(55),{automationId:s,onDone:i}=t;let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r={binding:"TRIGGER"},e[0]=r):r=e[0];const o=Hi(r),[a,l]=P.useState(),[h,c]=P.useState();let d;e[1]===Symbol.for("react.memo_cache_sentinel")?(d={},e[1]=d):d=e[1];const[u,f]=P.useState(d),{triggerAdd:m}=Wi(),{data:p,isLoading:_}=Am(a);let g,v,y,x,b,S;if(e[2]!==m||e[3]!==s||e[4]!==a||e[5]!==h||e[6]!==_||e[7]!==i||e[8]!==u||e[9]!==o||e[10]!==p){const N=p?.find(B=>B.type===h);let I;e[17]!==m||e[18]!==s||e[19]!==a||e[20]!==h||e[21]!==i||e[22]!==u?(I=async()=>{if(!(!a||!h))try{await m.mutateAsync({automation_id:s,type:"event",event_type:h,connection_id:a,params:u}),Le("automation_trigger_added",{automation_id:s,trigger_type:"event",connection_id:a,event_type:h}),ne.success("Event trigger added"),i()}catch{ne.error("Failed to add event trigger")}},e[17]=m,e[18]=s,e[19]=a,e[20]=h,e[21]=i,e[22]=u,e[23]=I):I=e[23],g=I,v="flex flex-col gap-3 px-3 py-3 rounded-lg border border-border bg-background";let D,R;e[24]===Symbol.for("react.memo_cache_sentinel")?(R=n.jsx(Li,{size:14,className:"text-muted-foreground shrink-0"}),D=n.jsx("span",{className:"text-sm font-medium",children:"Event trigger"}),e[24]=D,e[25]=R):(D=e[24],R=e[25]);let j;e[26]===Symbol.for("react.memo_cache_sentinel")?(j=n.jsx(fs,{size:13}),e[26]=j):j=e[26],e[27]!==i?(y=n.jsxs("div",{className:"flex items-center gap-2",children:[R,D,n.jsx("button",{type:"button",className:"ml-auto shrink-0 p-0.5 rounded text-muted-foreground hover:text-foreground",onClick:i,children:j})]}),e[27]=i,e[28]=y):y=e[28];const C=a??"";let A;e[29]===Symbol.for("react.memo_cache_sentinel")?(A=B=>{l(B),c(void 0),f({})},e[29]=A):A=e[29];let E;e[30]===Symbol.for("react.memo_cache_sentinel")?(E=n.jsx(Et,{className:"w-full",children:n.jsx(Tt,{placeholder:"Select connection..."})}),e[30]=E):E=e[30];let T;e[31]!==o?(T=o.length===0?n.jsx("div",{className:"px-2 py-3 text-center text-xs text-muted-foreground",children:"No connections with trigger support"}):o.map(zx),e[31]=o,e[32]=T):T=e[32];let L;e[33]!==T?(L=n.jsx(Rt,{children:T}),e[33]=T,e[34]=L):L=e[34],e[35]!==C||e[36]!==L?(x=n.jsxs(Pt,{value:C,onValueChange:A,children:[E,L]}),e[35]=C,e[36]=L,e[37]=x):x=e[37],e[38]!==a||e[39]!==h||e[40]!==_||e[41]!==p?(b=a&&n.jsxs(Pt,{value:h??"",onValueChange:B=>{c(B),f({})},children:[n.jsx(Et,{className:"w-full",children:_?n.jsxs("span",{className:"flex items-center gap-2 text-muted-foreground",children:[n.jsx(we,{size:13,className:"animate-spin"}),"Loading events..."]}):n.jsx(Tt,{placeholder:"Select event type...",children:h??"Select event type..."})}),n.jsx(Rt,{children:p?.map($x)})]}),e[38]=a,e[39]=h,e[40]=_,e[41]=p,e[42]=b):b=e[42],S=N?.paramsSchema&&Object.keys(N.paramsSchema).length>0&&n.jsx("div",{className:"flex flex-col gap-2",children:Object.entries(N.paramsSchema).map(B=>{const[O,F]=B;return n.jsxs("div",{className:"flex flex-col gap-1",children:[n.jsxs("label",{className:"text-xs text-muted-foreground",children:[O,F.description&&n.jsxs("span",{className:"text-muted-foreground/60",children:[" ","— ",F.description]})]}),F.enum?n.jsxs(Pt,{value:u[O]??"",onValueChange:H=>f(M=>({...M,[O]:H})),children:[n.jsx(Et,{className:"w-full",children:n.jsx(Tt,{placeholder:`Select ${O}...`})}),n.jsx(Rt,{children:F.enum.map(Ox)})]}):n.jsx("input",{type:"text",value:u[O]??"",onChange:H=>f(M=>({...M,[O]:H.target.value})),placeholder:F.description??O,className:"text-sm border border-border rounded-md bg-background px-2 py-1.5 focus:outline-none focus:ring-1 focus:ring-ring"})]},O)})}),e[2]=m,e[3]=s,e[4]=a,e[5]=h,e[6]=_,e[7]=i,e[8]=u,e[9]=o,e[10]=p,e[11]=g,e[12]=v,e[13]=y,e[14]=x,e[15]=b,e[16]=S}else g=e[11],v=e[12],y=e[13],x=e[14],b=e[15],S=e[16];let w;e[43]!==m||e[44]!==a||e[45]!==h||e[46]!==g?(w=a&&h&&n.jsx(ie,{size:"sm",onClick:g,disabled:m.isPending,children:m.isPending?n.jsx(we,{size:13,className:"animate-spin"}):"Add trigger"}),e[43]=m,e[44]=a,e[45]=h,e[46]=g,e[47]=w):w=e[47];let k;return e[48]!==v||e[49]!==y||e[50]!==x||e[51]!==b||e[52]!==S||e[53]!==w?(k=n.jsxs("div",{className:v,children:[y,x,b,S,w]}),e[48]=v,e[49]=y,e[50]=x,e[51]=b,e[52]=S,e[53]=w,e[54]=k):k=e[54],k}function Ox(t){return n.jsx(at,{value:t,children:t},t)}function $x(t){return n.jsx(at,{value:t.type,children:n.jsxs("div",{className:"flex flex-col",children:[n.jsx("span",{children:t.type}),n.jsx("span",{className:"text-xs text-muted-foreground",children:t.description})]})},t.type)}function zx(t){return n.jsx(at,{value:t.id,children:t.title},t.id)}function Fx({automationId:t,automation:e,onBack:s,onDelete:i}){const r=e.virtual_mcp_id,{org:o}=Te(),{update:a,triggerAdd:l,run:h}=Wi(),c=Hi(),d=new Map(c.map($=>[$.id,$.title])),{openTask:u}=ts(),{setChatOpen:f}=Ao(),{sendMessage:m}=Cs(),p=e.messages?.[0]?.metadata?.tiptapDoc??void 0,[_,g]=P.useState(p),[v,y]=P.useState(!1),[x,b]=P.useState(!1),[S,w]=P.useState(!1),[k,N]=P.useState(""),[I,D]=P.useState(!1),[R,j]=P.useState(null),[C,A]=P.useState(!1),[E,T]=P.useState(!1),[L,B]=P.useState(!1),O=async()=>{if(C)return;const ae=Mu(_).filter(de=>de.type==="text").map(de=>de.text).join(`
295
- `);if(ae.trim()){A(!0);try{te(),Le("automation_improve_clicked",{automation_id:t,agent_id:r,instructions_length:ae.length}),f(!0),await m({tiptapDoc:Eh({managerAgentId:Cc.AUTOMATION_MANAGER(o.id),managerName:"Automation Manager",kind:"automation",id:t,instructions:ae})})}finally{A(!1)}}},F=e.models?.tier??"smart",H=e.models?.modelId&&e.models?.credentialId?{modelId:e.models.modelId,credentialId:e.models.credentialId,title:e.models.modelTitle??e.models.modelId}:null,M=Sc({defaultValues:{name:e.name,active:e.active,tier:F,modelOverride:H,tools:e.tools??null,maxAgentSteps:e.maxAgentSteps??null}}),U=M.watch("active"),[V,K]=P.useReducer(Lx,null),Y=()=>{V!==null&&(Le("automation_updated",{automation_id:t,agent_id:r,fields:Array.from(V.fields),save_count:V.saveCount,edit_duration_ms:Date.now()-V.start}),K({type:"reset"}))},Q=async()=>{const $=M.control._formState.dirtyFields,ae=Object.keys($);if(ae.length===0&&!L)return!0;const de=M.getValues(),me=M.control._defaultValues;M.reset(de,{keepValues:!0});const le=L;B(!1);const G={tier:de.tier,...de.modelOverride?{modelId:de.modelOverride.modelId,credentialId:de.modelOverride.credentialId,modelTitle:de.modelOverride.title}:{}},pe={id:t,name:de.name,active:de.active,models:G,tools:de.tools,maxAgentSteps:de.maxAgentSteps,messages:Lu(_),temperature:0};try{await a.mutateAsync(pe)}catch{return M.reset(me,{keepValues:!0}),le&&B(!0),!1}const ue=[...ae];return le&&ue.push("messages"),K({type:"accumulate",now:Date.now(),fields:ue}),z(),!0},{schedule:se,flush:he}=Ar({save:Q}),{schedule:z,flush:te}=Ar({delayMs:3e4,save:async()=>Y()});P.useEffect(()=>{const $=M.watch(()=>se());return()=>$.unsubscribe()},[]);const ee=$=>{if(g($),!E){T(!0);return}B(!0),se()},q=async()=>{Le("automation_test_clicked",{automation_id:t,agent_id:r});const $=await he();if(te(),!!$){if(!_){ne.error("No instructions configured for this automation");return}try{const ae=await h.mutateAsync(t);ae.threadId&&(f(!0),u(ae.threadId))}catch{}}};return n.jsxs(n.Fragment,{children:[s&&n.jsx("div",{className:"flex items-center pb-4 shrink-0",children:n.jsxs(ie,{variant:"ghost",size:"sm",onClick:s,children:[n.jsx(eh,{size:14}),"Back to list"]})}),n.jsxs("div",{className:"flex flex-col gap-8",children:[n.jsxs("div",{className:"flex flex-col gap-1.5",children:[n.jsxs("div",{className:"flex items-center justify-between gap-4",children:[n.jsx(vt,{control:M.control,name:"name",render:({field:$})=>n.jsx(qe,{...$,placeholder:"Automation name",className:"border border-transparent shadow-none px-0 text-lg font-medium h-auto focus-visible:ring-0 focus-visible:border-border bg-transparent flex-1",style:{boxShadow:"none"}})}),i&&n.jsx(ie,{variant:"ghost",size:"icon",className:"text-muted-foreground hover:text-destructive shrink-0",onClick:i,children:n.jsx(Bi,{size:14})})]}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(vt,{control:M.control,name:"active",render:({field:$})=>n.jsx(Dr,{checked:$.value,onCheckedChange:ae=>{$.onChange(ae),he()},className:"cursor-pointer"})}),n.jsx("span",{className:"text-sm text-muted-foreground",children:U?"Active":"Inactive"}),n.jsx("span",{className:"text-muted-foreground/50 text-sm",children:"·"}),n.jsx(Kc,{id:e.created_by,size:"2xs",className:"text-sm text-muted-foreground"})]})]}),n.jsxs("div",{className:"flex flex-col gap-2.5",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx("span",{className:"text-xs font-semibold text-muted-foreground/60",children:"Starter"}),n.jsx(Dx,{automationId:t,open:v,onOpenChange:y,onCustomSelect:()=>{w(!0),D(!1),N("")},onEventSelect:()=>{D(!0),w(!1)},onWebhookCreated:$=>{Le("automation_trigger_added",{automation_id:t,trigger_type:"webhook"}),j($)}})]}),e.triggers.length===0&&!S?n.jsx("div",{className:"rounded-lg border border-dashed border-border px-4 py-6 text-center",children:n.jsxs("p",{className:"text-sm text-muted-foreground",children:["When should this automation run?"," ",n.jsx("button",{type:"button",className:"text-foreground underline underline-offset-2 cursor-pointer hover:text-foreground/80 transition-colors",onClick:()=>y(!0),children:"Add a starter"})," ","to get going."]})}):n.jsx("div",{className:"flex flex-col gap-2",children:e.triggers.map($=>n.jsx(Ax,{trigger:$,automationId:t,connectionName:$.connection_id?d.get($.connection_id):void 0},$.id))}),S&&n.jsxs("div",{className:"flex items-center gap-2.5 px-3 py-2.5 rounded-lg border border-border bg-background group",children:[n.jsx(ki,{size:14,className:"text-muted-foreground shrink-0"}),n.jsx("input",{type:"text",value:k,onChange:$=>N($.target.value),onBlur:async()=>{const $=k.trim();if(!(!$||!Pi($)))try{await l.mutateAsync({automation_id:t,type:"cron",cron_expression:$}),Le("automation_trigger_added",{automation_id:t,trigger_type:"cron"}),ne.success("Starter added"),w(!1),N("")}catch{ne.error("Failed to add starter")}},onKeyDown:async $=>{const ae=k.trim();$.key==="Enter"&&ae&&Pi(ae)&&$.target.blur(),$.key==="Escape"&&(w(!1),N(""))},placeholder:"0 9 * * 1-5",className:"flex-1 text-sm font-mono bg-transparent outline-none placeholder:text-muted-foreground/40",autoFocus:!0}),k&&!Pi(k)&&n.jsx("span",{className:"text-xs text-muted-foreground/60 shrink-0",children:"invalid"}),l.isPending&&n.jsx(we,{size:13,className:"animate-spin text-muted-foreground shrink-0"}),n.jsx("button",{type:"button",className:"shrink-0 p-0.5 rounded text-muted-foreground opacity-0 group-hover:opacity-100 hover:text-foreground transition-opacity",onClick:()=>{w(!1),N("")},children:n.jsx(fs,{size:13})})]}),I&&n.jsx(P.Suspense,{fallback:n.jsxs("div",{className:"flex items-center gap-2 px-3 py-3 rounded-lg border border-border bg-background",children:[n.jsx(we,{size:13,className:"animate-spin text-muted-foreground"}),n.jsx("span",{className:"text-sm text-muted-foreground",children:"Loading connections..."})]}),children:n.jsx(Mx,{automationId:t,onDone:()=>D(!1)})}),n.jsx(nd,{open:R!==null,onOpenChange:$=>{$||j(null)},url:R?.url??null,token:R?.token??null})]}),n.jsxs("div",{className:"flex flex-col gap-2.5",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx("span",{className:"text-xs font-semibold text-muted-foreground/60",children:"Instructions"}),n.jsxs(ie,{variant:"outline",size:"sm",className:"h-7 gap-1.5 px-2 text-xs",disabled:C||!_,onClick:O,children:[n.jsx(Zr,{size:13}),"Improve"]})]}),n.jsx(Eu,{tiptapDoc:_,setTiptapDoc:ee,placeholder:"What should this automation do?",children:n.jsxs("div",{className:"rounded-xl border border-border min-h-[120px] flex flex-col",children:[n.jsx(Tu,{virtualMcpId:r||null,className:"max-h-[45vh]"}),n.jsx("div",{className:"@container/chat-bottom flex items-center justify-end gap-1.5 p-2.5",children:n.jsxs(Ne,{children:[n.jsx(ke,{asChild:!0,children:n.jsxs(ie,{type:"button",variant:"default",className:"h-8 gap-1.5 rounded-md px-3 text-sm font-medium",onClick:q,disabled:!r,children:[n.jsx(Cm,{size:16}),"Test"]})}),n.jsx(je,{children:"Test Automation"})]})})]})})]}),n.jsxs(qu,{open:x,onOpenChange:b,className:"flex flex-col gap-2.5",children:[n.jsxs(Gu,{className:"group flex w-fit cursor-pointer items-center gap-1.5",children:[n.jsx("span",{className:"text-xs font-semibold text-muted-foreground/60",children:"Advanced"}),n.jsx(ks,{size:14,className:"text-muted-foreground/60 transition-transform group-data-[state=open]:rotate-180"})]}),n.jsxs(Yu,{className:"flex flex-col gap-5 pt-0.5",children:[n.jsx(_x,{tier:M.watch("tier"),onTierChange:$=>M.setValue("tier",$,{shouldDirty:!0}),override:M.watch("modelOverride"),onOverrideChange:$=>M.setValue("modelOverride",$,{shouldDirty:!0})}),n.jsx(bx,{agentId:r||null,value:M.watch("tools"),onChange:$=>M.setValue("tools",$,{shouldDirty:!0})}),n.jsxs("div",{className:"flex flex-col gap-2",children:[n.jsx("span",{className:"text-xs font-semibold text-muted-foreground/60",children:"Max steps"}),n.jsx(qe,{type:"number",min:1,max:100,className:"w-40",placeholder:`${Bx} (default)`,value:M.watch("maxAgentSteps")??"",onChange:$=>{const ae=$.target.value.trim(),de=ae===""?null:Number(ae);M.setValue("maxAgentSteps",de===null||Number.isNaN(de)?null:de,{shouldDirty:!0})}})]})]})]})]})]})}function Us(){const t=W.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsx("div",{"data-testid":"main-panel-loading",className:"flex h-full w-full items-center justify-center",children:n.jsx(we,{size:20,className:"animate-spin text-muted-foreground"})}),t[0]=e):e=t[0],e}const od=[{key:"24h",label:"Last 24 hours",ms:1440*60*1e3},{key:"7d",label:"Last 7 days",ms:10080*60*1e3},{key:"30d",label:"Last 30 days",ms:720*60*60*1e3}];function ad(t){const e=od.find(i=>i.key===t).ms,s=Date.now();return{startDate:new Date(s-e).toISOString(),endDate:new Date(s).toISOString()}}function Hx(t){const e=W.c(12),{automationId:s,triggerIds:i}=t,[r,o]=P.useState("30d"),[a,l]=P.useState(Ux);let h;e[0]===Symbol.for("react.memo_cache_sentinel")?(h=p=>{const _=p;o(_),l(ad(_))},e[0]=h):h=e[0];let c;e[1]===Symbol.for("react.memo_cache_sentinel")?(c=n.jsx(Et,{className:"w-44",children:n.jsx(Tt,{})}),e[1]=c):c=e[1];let d;e[2]===Symbol.for("react.memo_cache_sentinel")?(d=n.jsx(Rt,{children:od.map(Wx)}),e[2]=d):d=e[2];let u;e[3]!==r?(u=n.jsx("div",{className:"flex items-center justify-end",children:n.jsxs(Pt,{value:r,onValueChange:h,children:[c,d]})}),e[3]=r,e[4]=u):u=e[4];let f;e[5]!==s||e[6]!==a||e[7]!==i?(f=n.jsx(Mm,{automationId:s,triggerIds:i,range:a}),e[5]=s,e[6]=a,e[7]=i,e[8]=f):f=e[8];let m;return e[9]!==u||e[10]!==f?(m=n.jsxs("div",{className:"flex flex-col gap-5",children:[u,f]}),e[9]=u,e[10]=f,e[11]=m):m=e[11],m}function Wx(t){return n.jsx(at,{value:t.key,children:t.label},t.key)}function Ux(){return ad("30d")}function Kx(t){const e=W.c(5),{tabId:s}=t;let i;e[0]!==s?(i=zc(s),e[0]=s,e[1]=i):i=e[1];const r=i;if(!r)return null;let o;e[2]===Symbol.for("react.memo_cache_sentinel")?(o=n.jsx(Us,{}),e[2]=o):o=e[2];let a;return e[3]!==r.id?(a=n.jsx(P.Suspense,{fallback:o,children:n.jsx(Vx,{id:r.id})}),e[3]=r.id,e[4]=a):a=e[4],a}function Vx(t){const e=W.c(24),{id:s}=t,i=es(),{data:r,isLoading:o}=Im(s),[a,l]=P.useState("settings");let h;e[0]!==i?(h=()=>{i({to:".",search:Gx,replace:!0})},e[0]=i,e[1]=h):h=e[1];const c=h;if(o){let b;return e[2]===Symbol.for("react.memo_cache_sentinel")?(b=n.jsx(Us,{}),e[2]=b):b=e[2],b}if(!r){let b;return e[3]===Symbol.for("react.memo_cache_sentinel")?(b=n.jsx("div",{className:"flex h-full w-full items-center justify-center text-sm text-muted-foreground",children:"Automation not found"}),e[3]=b):b=e[3],b}let d;e[4]!==r.triggers?(d=r.triggers.map(qx),e[4]=r.triggers,e[5]=d):d=e[5];const u=d;let f;e[6]===Symbol.for("react.memo_cache_sentinel")?(f=n.jsx(eh,{size:14}),e[6]=f):f=e[6];let m;e[7]!==c?(m=n.jsxs(ie,{variant:"ghost",size:"sm",onClick:c,children:[f,"Back to list"]}),e[7]=c,e[8]=m):m=e[8];let p;e[9]===Symbol.for("react.memo_cache_sentinel")?(p=[{id:"settings",label:"Settings"},{id:"runs",label:"Runs"}],e[9]=p):p=e[9];let _;e[10]===Symbol.for("react.memo_cache_sentinel")?(_=b=>l(b),e[10]=_):_=e[10];let g;e[11]!==a?(g=n.jsx(Xc,{tabs:p,activeTab:a,onTabChange:_}),e[11]=a,e[12]=g):g=e[12];let v;e[13]!==m||e[14]!==g?(v=n.jsxs("div",{className:"flex items-center justify-between pb-4 shrink-0",children:[m,g]}),e[13]=m,e[14]=g,e[15]=v):v=e[15];let y;e[16]!==r||e[17]!==s||e[18]!==a||e[19]!==u?(y=a==="settings"?n.jsx(Fx,{automationId:s,automation:r}):n.jsx(Hx,{automationId:s,triggerIds:u}),e[16]=r,e[17]=s,e[18]=a,e[19]=u,e[20]=y):y=e[20];let x;return e[21]!==v||e[22]!==y?(x=n.jsx(Nt,{children:n.jsx(Nt.Content,{children:n.jsxs(Nt.Body,{children:[v,y]})})}),e[21]=v,e[22]=y,e[23]=x):x=e[23],x}function qx(t){return t.id}function Gx(t){return{...t,main:"automations"}}function Yx(t){const e=W.c(20),{virtualMcpId:s}=t,i=es(),{data:r}=Bm(s),o=r===void 0?[]:r,{create:a}=Wi(),[l,h]=P.useState(""),c=l.toLowerCase(),d=o.filter(R=>R.name.toLowerCase().includes(c));let u;e[0]!==i?(u=R=>i({to:".",search:j=>({...j,main:"automation:"+R}),replace:!0}),e[0]=i,e[1]=u):u=e[1];const f=u,m=async()=>{if(a.isPending)return;Le("automation_new_clicked",{virtual_mcp_id:s,existing_count:o.length});const R=await a.mutateAsync(Lm(s));f(R.id)};let p;e[2]===Symbol.for("react.memo_cache_sentinel")?(p=n.jsx(At,{size:14}),e[2]=p):p=e[2];let _;e[3]!==a.isPending||e[4]!==m?(_=n.jsxs(ie,{size:"sm",onClick:m,disabled:a.isPending,children:[p,"New automation"]}),e[3]=a.isPending,e[4]=m,e[5]=_):_=e[5];const g=_,v=Nt,y=Nt,x=Nt;let b;e[6]===Symbol.for("react.memo_cache_sentinel")?(b=n.jsx(Nt.Title,{children:"Automations"}),e[6]=b):b=e[6];const S=o.length>0&&n.jsx(Yc,{value:l,onChange:h,placeholder:"Search automations...",className:"w-full md:w-[375px]"});let w;e[7]!==g||e[8]!==S?(w=n.jsxs("div",{className:"flex flex-col gap-6",children:[b,n.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[S,g]})]}),e[7]=g,e[8]=S,e[9]=w):w=e[9];const k=o.length===0?n.jsx("div",{className:"flex items-center justify-center py-20",children:n.jsx(Sr,{image:n.jsx(Li,{size:48,className:"text-muted-foreground"}),title:"No automations yet",description:"Create your first automation to run this agent on a schedule or in response to events.",actions:g})}):d.length===0?n.jsx("div",{className:"flex items-center justify-center py-20",children:n.jsx(Sr,{image:n.jsx(Li,{size:48,className:"text-muted-foreground"}),title:"No automations found",description:`No automations match "${l}"`})}):n.jsx("div",{className:"mt-6 rounded-xl border border-border overflow-hidden",children:d.map(R=>n.jsx(Om,{automation:R,onClick:()=>f(R.id)},R.id))});let N;e[10]!==k||e[11]!==x.Body||e[12]!==w?(N=n.jsxs(x.Body,{children:[w,k]}),e[10]=k,e[11]=x.Body,e[12]=w,e[13]=N):N=e[13];let I;e[14]!==N||e[15]!==y.Content?(I=n.jsx(y.Content,{children:N}),e[14]=N,e[15]=y.Content,e[16]=I):I=e[16];let D;return e[17]!==v||e[18]!==I?(D=n.jsx(v,{children:I}),e[17]=v,e[18]=I,e[19]=D):D=e[19],D}function Xx(t){const e=W.c(3),{virtualMcpId:s}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=n.jsx(Us,{}),e[0]=i):i=e[0];let r;return e[1]!==s?(r=n.jsx(P.Suspense,{fallback:i,children:n.jsx(Yx,{virtualMcpId:s})}),e[1]=s,e[2]=r):r=e[2],r}const vl=300;function ld(){const t=W.c(2);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsx(Os,{className:"h-6 w-2/3"}),t[0]=e):e=t[0];let s;return t[1]===Symbol.for("react.memo_cache_sentinel")?(s=n.jsx("div",{className:"flex h-full w-full items-center justify-center bg-white",children:n.jsxs("div",{className:"flex w-3/4 max-w-md flex-col gap-3 p-6",children:[e,n.jsxs("div",{className:"flex flex-col gap-1.5",children:[n.jsx(Os,{className:"h-3 w-full"}),n.jsx(Os,{className:"h-3 w-5/6"}),n.jsx(Os,{className:"h-3 w-2/3"})]}),n.jsx(Os,{className:"mt-2 h-8 w-24"})]})}),t[1]=s):s=t[1],s}function Jx(t){const e=W.c(14),{url:s,title:i}=t,[r,o]=P.useState(!1),[a,l]=P.useState(!0);let h;e[0]===Symbol.for("react.memo_cache_sentinel")?(h=()=>o(!0),e[0]=h):h=e[0];const c=r?"opacity-100":"opacity-0";let d;e[1]!==c?(d=oe("absolute inset-0 block w-full h-full bg-white","transition-opacity ease-out",c),e[1]=c,e[2]=d):d=e[2];let u;e[3]===Symbol.for("react.memo_cache_sentinel")?(u={transitionDuration:`${vl}ms`},e[3]=u):u=e[3];let f;e[4]!==d||e[5]!==i||e[6]!==s?(f=n.jsx("iframe",{src:s,onLoad:h,sandbox:"allow-scripts",className:d,style:u,title:i}),e[4]=d,e[5]=i,e[6]=s,e[7]=f):f=e[7];let m;e[8]!==r||e[9]!==a?(m=a&&n.jsx("div",{className:oe("absolute inset-0 transition-opacity ease-out",r?"opacity-0 pointer-events-none":"opacity-100"),style:{transitionDuration:`${vl}ms`},onTransitionEnd:_=>{_.propertyName==="opacity"&&r&&l(!1)},children:n.jsx(ld,{})}),e[8]=r,e[9]=a,e[10]=m):m=e[10];let p;return e[11]!==f||e[12]!==m?(p=n.jsxs("div",{className:"relative h-full w-full bg-background",children:[f,m]}),e[11]=f,e[12]=m,e[13]=p):p=e[13],p}function Zx(t,e){for(let s=t.length-1;s>=0;s--){const i=t[s]?.parts;if(i)for(let r=i.length-1;r>=0;r--){const o=i[r];if(!o||o.type!=="data-html-page-published")continue;const a=o.data;if(a&&a.slug===e)return a}}return null}function Qx(t){const e=W.c(32),{url:s}=t,[i,r]=P.useState(!1);let o;e[0]!==s?(o=()=>{navigator.clipboard.writeText(s),r(!0),window.setTimeout(()=>r(!1),1500)},e[0]=s,e[1]=o):o=e[1];const a=o;let l;e[2]!==s?(l=()=>window.open(s,"_blank","noopener"),e[2]=s,e[3]=l):l=e[3];let h;e[4]!==s?(h=n.jsx("span",{className:"truncate",children:s}),e[4]=s,e[5]=h):h=e[5];let c;e[6]!==l||e[7]!==h||e[8]!==s?(c=n.jsx("button",{type:"button",onClick:l,className:"flex min-w-0 flex-1 items-center rounded-md px-2 py-1 text-left text-xs text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",title:s,children:h}),e[6]=l,e[7]=h,e[8]=s,e[9]=c):c=e[9];let d;e[10]!==i?(d=i?n.jsx(si,{size:14}):n.jsx(Zt,{size:14}),e[10]=i,e[11]=d):d=e[11];let u;e[12]!==a||e[13]!==d?(u=n.jsx(ke,{asChild:!0,children:n.jsx(ie,{variant:"ghost",size:"icon",onClick:a,children:d})}),e[12]=a,e[13]=d,e[14]=u):u=e[14];const f=i?"Copied":"Copy URL";let m;e[15]!==f?(m=n.jsx(je,{side:"bottom",children:f}),e[15]=f,e[16]=m):m=e[16];let p;e[17]!==u||e[18]!==m?(p=n.jsxs(Ne,{children:[u,m]}),e[17]=u,e[18]=m,e[19]=p):p=e[19];let _;e[20]!==s?(_=()=>window.open(s,"_blank","noopener"),e[20]=s,e[21]=_):_=e[21];let g;e[22]===Symbol.for("react.memo_cache_sentinel")?(g=n.jsx(Ts,{size:14}),e[22]=g):g=e[22];let v;e[23]!==_?(v=n.jsx(ke,{asChild:!0,children:n.jsx(ie,{variant:"ghost",size:"icon",onClick:_,children:g})}),e[23]=_,e[24]=v):v=e[24];let y;e[25]===Symbol.for("react.memo_cache_sentinel")?(y=n.jsx(je,{side:"bottom",children:"Open in new tab"}),e[25]=y):y=e[25];let x;e[26]!==v?(x=n.jsxs(Ne,{children:[v,y]}),e[26]=v,e[27]=x):x=e[27];let b;return e[28]!==x||e[29]!==c||e[30]!==p?(b=n.jsxs("div",{className:"flex h-9 shrink-0 items-center gap-1 border-b border-border/60 px-2",children:[c,p,x]}),e[28]=x,e[29]=c,e[30]=p,e[31]=b):b=e[31],b}function eb(t){const e=W.c(15),{slug:s}=t,i=Ou();let r,o,a,l;if(e[0]!==s||e[1]!==i?.messages){l=Symbol.for("react.early_return_sentinel");e:{const m=i?.messages??[];if(r=Zx(m,s),!r){let p;e[6]===Symbol.for("react.memo_cache_sentinel")?(p=n.jsx("div",{className:"h-full w-full bg-background",children:n.jsx(ld,{})}),e[6]=p):p=e[6],l=p;break e}o=r.url,a=r.url.includes("?")?"&":"?"}e[0]=s,e[1]=i?.messages,e[2]=r,e[3]=o,e[4]=a,e[5]=l}else r=e[2],o=e[3],a=e[4],l=e[5];if(l!==Symbol.for("react.early_return_sentinel"))return l;const h=`${o}${a}v=${r.bytes}`;let c;e[7]!==r.url?(c=n.jsx(Qx,{url:r.url}),e[7]=r.url,e[8]=c):c=e[8];const d=`${s}.html`;let u;e[9]!==h||e[10]!==d?(u=n.jsx("div",{className:"relative flex-1",children:n.jsx(Jx,{url:h,title:d})}),e[9]=h,e[10]=d,e[11]=u):u=e[11];let f;return e[12]!==c||e[13]!==u?(f=n.jsxs("div",{className:"flex h-full w-full flex-col bg-background",children:[c,u]}),e[12]=c,e[13]=u,e[14]=f):f=e[14],f}function tb(t){const e=W.c(37),{file:s,onClose:i}=t;let r,o;e[0]!==s.filename?(r=n.jsx(Oo,{filename:s.filename,className:"h-4.5 w-3.5 shrink-0"}),o=n.jsx("span",{className:"truncate text-xs font-medium text-foreground",children:s.filename}),e[0]=s.filename,e[1]=r,e[2]=o):(r=e[1],o=e[2]);let a;e[3]!==s.size?(a=Fm(s.size),e[3]=s.size,e[4]=a):a=e[4];let l;e[5]!==a?(l=n.jsx("span",{className:"shrink-0 text-xs text-muted-foreground",children:a}),e[5]=a,e[6]=l):l=e[6];let h;e[7]!==r||e[8]!==o||e[9]!==l?(h=n.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2 px-2",children:[r,o,l]}),e[7]=r,e[8]=o,e[9]=l,e[10]=h):h=e[10];let c;e[11]===Symbol.for("react.memo_cache_sentinel")?(c=n.jsx(Xf,{size:14}),e[11]=c):c=e[11];let d;e[12]!==s.downloadUrl||e[13]!==s.filename?(d=n.jsx(ke,{asChild:!0,children:n.jsx(ie,{variant:"ghost",size:"icon",asChild:!0,children:n.jsx("a",{href:s.downloadUrl,download:s.filename,children:c})})}),e[12]=s.downloadUrl,e[13]=s.filename,e[14]=d):d=e[14];let u;e[15]===Symbol.for("react.memo_cache_sentinel")?(u=n.jsx(je,{side:"bottom",children:"Download"}),e[15]=u):u=e[15];let f;e[16]!==d?(f=n.jsxs(Ne,{children:[d,u]}),e[16]=d,e[17]=f):f=e[17];let m;e[18]!==s.downloadUrl?(m=()=>window.open(s.downloadUrl,"_blank","noopener"),e[18]=s.downloadUrl,e[19]=m):m=e[19];let p;e[20]===Symbol.for("react.memo_cache_sentinel")?(p=n.jsx(Ts,{size:14}),e[20]=p):p=e[20];let _;e[21]!==m?(_=n.jsx(ke,{asChild:!0,children:n.jsx(ie,{variant:"ghost",size:"icon",onClick:m,children:p})}),e[21]=m,e[22]=_):_=e[22];let g;e[23]===Symbol.for("react.memo_cache_sentinel")?(g=n.jsx(je,{side:"bottom",children:"Open in new tab"}),e[23]=g):g=e[23];let v;e[24]!==_?(v=n.jsxs(Ne,{children:[_,g]}),e[24]=_,e[25]=v):v=e[25];let y;e[26]===Symbol.for("react.memo_cache_sentinel")?(y=n.jsx(fs,{size:14}),e[26]=y):y=e[26];let x;e[27]!==i?(x=n.jsx(ke,{asChild:!0,children:n.jsx(ie,{variant:"ghost",size:"icon",onClick:i,children:y})}),e[27]=i,e[28]=x):x=e[28];let b;e[29]===Symbol.for("react.memo_cache_sentinel")?(b=n.jsx(je,{side:"bottom",children:"Close"}),e[29]=b):b=e[29];let S;e[30]!==x?(S=n.jsxs(Ne,{children:[x,b]}),e[30]=x,e[31]=S):S=e[31];let w;return e[32]!==v||e[33]!==S||e[34]!==h||e[35]!==f?(w=n.jsxs("div",{className:"flex h-9 shrink-0 items-center gap-1 border-b border-border/60 px-2",children:[h,f,v,S]}),e[32]=v,e[33]=S,e[34]=h,e[35]=f,e[36]=w):w=e[36],w}function sb(t){const e=W.c(24),{fileKey:s,taskId:i}=t,r=es(),{data:o,isPending:a}=Ec(i);let l;e[0]!==s||e[1]!==o?(l=o?.find(p=>p.key===s)??null,e[0]=s,e[1]=o,e[2]=l):l=e[2];const h=l;let c;e[3]!==r?(c=()=>r({to:".",search:ib,replace:!0}),e[3]=r,e[4]=c):c=e[4];const d=c;if(!h){if(a){let x;return e[5]===Symbol.for("react.memo_cache_sentinel")?(x=n.jsx("div",{className:"h-full w-full bg-background",children:n.jsx($m,{})}),e[5]=x):x=e[5],x}let p;e[6]!==s?(p=s.split("/").pop()??s,e[6]=s,e[7]=p):p=e[7];let _;e[8]!==p?(_=n.jsx(Oo,{filename:p,className:"h-7.5 w-6"}),e[8]=p,e[9]=_):_=e[9];let g;e[10]===Symbol.for("react.memo_cache_sentinel")?(g=n.jsx("span",{className:"text-sm text-muted-foreground",children:"This file is no longer available."}),e[10]=g):g=e[10];let v;e[11]!==d?(v=n.jsx(ie,{variant:"ghost",size:"sm",onClick:d,children:"Close"}),e[11]=d,e[12]=v):v=e[12];let y;return e[13]!==_||e[14]!==v?(y=n.jsxs("div",{className:"flex h-full w-full flex-col items-center justify-center gap-2 bg-background",children:[_,g,v]}),e[13]=_,e[14]=v,e[15]=y):y=e[15],y}let u;e[16]!==h||e[17]!==d?(u=n.jsx(tb,{file:h,onClose:d}),e[16]=h,e[17]=d,e[18]=u):u=e[18];let f;e[19]!==h?(f=n.jsx("div",{className:"relative min-h-0 flex-1",children:n.jsx(zm,{file:h})}),e[19]=h,e[20]=f):f=e[20];let m;return e[21]!==u||e[22]!==f?(m=n.jsxs("div",{className:"flex h-full w-full flex-col bg-background",children:[u,f]}),e[21]=u,e[22]=f,e[23]=m):m=e[23],m}function ib(t){return{...t,main:"0"}}const xl=P.lazy(()=>Kt(()=>import("./project-app-view-DSFKcRzU.js"),__vite__mapDeps([158,1,2,90,6,7,8,9,10,11,12,13,14,15,16,3,4,5,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,91,92,45,46,47,93,94,48,95,96,57,97,98,99,100,84,101,56,102,58,103,104,105,106,107,65,108,55,109,70,71,49,110,124])).then(t=>({default:t.AppViewContent})));function rb(t){const e=W.c(49),{activeTab:s,virtualMcpId:i,taskId:r,layoutTabs:o,expandedTools:a,automationTabParsed:l}=t;if(If(s)){let v;return e[0]!==i?(v=n.jsx(il,{virtualMcpId:i}),e[0]=i,e[1]=v):v=e[1],v}if(s==="git"){let v;return e[2]!==i?(v=n.jsx(pv,{virtualMcpId:i}),e[2]=i,e[3]=v):v=e[3],v}if(s==="automations"){let v;return e[4]!==i?(v=n.jsx(Xx,{virtualMcpId:i}),e[4]=i,e[5]=v):v=e[5],v}if(s==="preview"){let v;return e[6]!==i?(v=n.jsx(c1,{virtualMcpId:i}),e[6]=i,e[7]=v):v=e[7],v}if(s==="content"){let v;return e[8]!==i?(v=n.jsx(fx,{virtualMcpId:i}),e[8]=i,e[9]=v):v=e[9],v}if(l){let v;return e[10]!==s?(v=n.jsx(Kx,{tabId:s}),e[10]=s,e[11]=v):v=e[11],v}let h;e[12]!==s?(h=Bf(s),e[12]=s,e[13]=h):h=e[13];const c=h;if(c){let v;return e[14]!==c.slug?(v=n.jsx(eb,{slug:c.slug}),e[14]=c.slug,e[15]=v):v=e[15],v}let d;e[16]!==s?(d=Fc(s),e[16]=s,e[17]=d):d=e[17];const u=d;if(u){let v;return e[18]!==u.key||e[19]!==r?(v=n.jsx(sb,{fileKey:u.key,taskId:r}),e[18]=u.key,e[19]=r,e[20]=v):v=e[20],v}let f;e[21]!==s?(f=Lf(s),e[21]=s,e[22]=f):f=e[22];const m=f;if(m){let v;if(e[23]!==a||e[24]!==m.connectionId||e[25]!==m.toolName){let w;e[27]!==m.connectionId||e[28]!==m.toolName?(w=k=>k.appId===m.connectionId&&k.toolName===m.toolName,e[27]=m.connectionId,e[28]=m.toolName,e[29]=w):w=e[29],v=a.find(w),e[23]=a,e[24]=m.connectionId,e[25]=m.toolName,e[26]=v}else v=e[26];const y=v;let x;e[30]===Symbol.for("react.memo_cache_sentinel")?(x=n.jsx(Us,{}),e[30]=x):x=e[30];const b=y?.args;let S;return e[31]!==s||e[32]!==m.connectionId||e[33]!==m.toolName||e[34]!==b?(S=n.jsx(P.Suspense,{fallback:x,children:n.jsx(xl,{connectionId:m.connectionId,toolName:m.toolName,args:b},s)}),e[31]=s,e[32]=m.connectionId,e[33]=m.toolName,e[34]=b,e[35]=S):S=e[35],S}let p;if(e[36]!==s||e[37]!==o){let v;e[39]!==s?(v=y=>y.id===s,e[39]=s,e[40]=v):v=e[40],p=o.find(v),e[36]=s,e[37]=o,e[38]=p}else p=e[38];const _=p;if(_){let v;e[41]===Symbol.for("react.memo_cache_sentinel")?(v=n.jsx(Us,{}),e[41]=v):v=e[41];let y;return e[42]!==s||e[43]!==_.id||e[44]!==_.view.appId||e[45]!==_.view.args?(y=n.jsx(P.Suspense,{fallback:v,children:n.jsx(xl,{connectionId:_.view.appId,toolName:_.id,args:_.view.args},s)}),e[42]=s,e[43]=_.id,e[44]=_.view.appId,e[45]=_.view.args,e[46]=y):y=e[46],y}let g;return e[47]!==i?(g=n.jsx(il,{virtualMcpId:i}),e[47]=i,e[48]=g):g=e[48],g}function nb(t){const e=W.c(14),{taskId:s,virtualMcpId:i}=t;let r;e[0]!==s||e[1]!==i?(r={virtualMcpId:i,taskId:s},e[0]=s,e[1]=i,e[2]=r):r=e[2];const{activeTab:o,layoutTabs:a,expandedTools:l,automationTabParsed:h}=Nh(r);let c;e[3]===Symbol.for("react.memo_cache_sentinel")?(c=n.jsx(Us,{}),e[3]=c):c=e[3];let d;e[4]!==o||e[5]!==h||e[6]!==l||e[7]!==a||e[8]!==s||e[9]!==i?(d=n.jsx(P.Suspense,{fallback:c,children:n.jsx(rb,{activeTab:o,virtualMcpId:i,taskId:s,layoutTabs:a,expandedTools:l,automationTabParsed:h})}),e[4]=o,e[5]=h,e[6]=l,e[7]=a,e[8]=s,e[9]=i,e[10]=d):d=e[10];let u;return e[11]!==o||e[12]!==d?(u=n.jsx(Ht,{children:d},o),e[11]=o,e[12]=d,e[13]=u):u=e[13],u}const xs="setup";function ob(t){const e=W.c(35);let s;if(e[0]!==t.scriptTabs||e[1]!==t.scripts){let m;e[3]!==t.scriptTabs?(m=p=>!t.scriptTabs.includes(p),e[3]=t.scriptTabs,e[4]=m):m=e[4],s=t.scripts.filter(m),e[0]=t.scriptTabs,e[1]=t.scripts,e[2]=s}else s=e[2];const i=s;let r;e[5]!==t?(r=()=>{t.active===xs?t.onToggle():t.onSelectTab(xs)},e[5]=t,e[6]=r):r=e[6];const o=r,a=t.active===xs;let l;e[7]!==o||e[8]!==t.open||e[9]!==a?(l=n.jsx(ab,{active:a,open:t.open,onClick:o}),e[7]=o,e[8]=t.open,e[9]=a,e[10]=l):l=e[10];let h;e[11]!==t?(h=t.scriptTabs.map(m=>n.jsx(cb,{active:t.active===m,onClick:()=>t.onSelectTab(m),onClose:()=>t.onCloseScript(m),children:m},m)),e[11]=t,e[12]=h):h=e[12];let c;e[13]!==i||e[14]!==t.onAddScript?(c=n.jsx(hb,{scripts:i,onRun:t.onAddScript}),e[13]=i,e[14]=t.onAddScript,e[15]=c):c=e[15];let d;e[16]!==l||e[17]!==h||e[18]!==c?(d=n.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-1 overflow-x-auto",children:[l,h,c]}),e[16]=l,e[17]=h,e[18]=c,e[19]=d):d=e[19];let u;e[20]!==t.onRestart||e[21]!==t.onResume||e[22]!==t.onRetry||e[23]!==t.onRunActiveScript||e[24]!==t.onStart||e[25]!==t.onStop||e[26]!==t.onStopActiveScript||e[27]!==t.scriptIsKilling||e[28]!==t.scriptIsRunning||e[29]!==t.showScriptControls||e[30]!==t.status?(u=t.showScriptControls?n.jsx(db,{isRunning:t.scriptIsRunning,isKilling:t.scriptIsKilling,onRun:t.onRunActiveScript,onStop:t.onStopActiveScript}):n.jsx(lb,{status:t.status,onStart:t.onStart,onStop:t.onStop,onRestart:t.onRestart,onResume:t.onResume,onRetry:t.onRetry}),e[20]=t.onRestart,e[21]=t.onResume,e[22]=t.onRetry,e[23]=t.onRunActiveScript,e[24]=t.onStart,e[25]=t.onStop,e[26]=t.onStopActiveScript,e[27]=t.scriptIsKilling,e[28]=t.scriptIsRunning,e[29]=t.showScriptControls,e[30]=t.status,e[31]=u):u=e[31];let f;return e[32]!==d||e[33]!==u?(f=n.jsxs("div",{className:"flex h-10 shrink-0 items-center gap-1 border-t border-b border-border bg-muted/60 px-3",children:[d,u]}),e[32]=d,e[33]=u,e[34]=f):f=e[34],f}function ab(t){const e=W.c(8),{active:s,open:i,onClick:r}=t,o=s&&i,a=s&&i,l=s?"border-border bg-background font-medium text-foreground shadow-sm":"border-transparent text-muted-foreground hover:bg-background/50 hover:text-foreground";let h;e[0]!==l?(h=oe("flex h-7 items-center gap-1.5 rounded-md border px-2.5 text-xs",l),e[0]=l,e[1]=h):h=e[1];let c;e[2]===Symbol.for("react.memo_cache_sentinel")?(c=n.jsx(Nf,{className:"size-3.5"}),e[2]=c):c=e[2];let d;return e[3]!==r||e[4]!==o||e[5]!==a||e[6]!==h?(d=n.jsxs("button",{type:"button","aria-pressed":o,"aria-expanded":a,onClick:r,className:h,children:[c,"sandbox"]}),e[3]=r,e[4]=o,e[5]=a,e[6]=h,e[7]=d):d=e[7],d}function lb(t){const e=W.c(24),{status:s,onStart:i,onStop:r,onRestart:o,onResume:a,onRetry:l}=t;if(s==="idle"&&i){let h;e[0]===Symbol.for("react.memo_cache_sentinel")?(h=n.jsx(Hs,{className:"size-3.5"}),e[0]=h):h=e[0];let c;return e[1]!==i?(c=n.jsxs(ie,{variant:"outline",size:"sm",onClick:i,children:[h," Start"]}),e[1]=i,e[2]=c):c=e[2],c}if(s==="suspended"&&a){let h;e[3]===Symbol.for("react.memo_cache_sentinel")?(h=n.jsx(Hs,{className:"size-3.5"}),e[3]=h):h=e[3];let c;return e[4]!==a?(c=n.jsxs(ie,{variant:"outline",size:"sm",onClick:a,children:[h," Resume"]}),e[4]=a,e[5]=c):c=e[5],c}if(s==="errored"&&l){let h;e[6]===Symbol.for("react.memo_cache_sentinel")?(h=n.jsx(Ai,{className:"size-3.5"}),e[6]=h):h=e[6];let c;return e[7]!==l?(c=n.jsxs(ie,{variant:"outline",size:"sm",onClick:l,children:[h," Retry"]}),e[7]=l,e[8]=c):c=e[8],c}if(s==="starting"||s==="running"){const h=s==="running"&&!!o,c=h?"rounded-r-none border-r-0":void 0;let d;e[9]!==c?(d=oe(c),e[9]=c,e[10]=d):d=e[10];let u;e[11]===Symbol.for("react.memo_cache_sentinel")?(u=n.jsx(Mc,{className:"size-3.5"}),e[11]=u):u=e[11];let f;e[12]!==r||e[13]!==d?(f=n.jsx(ke,{asChild:!0,children:n.jsxs(ie,{variant:"outline",size:"sm",onClick:r,className:d,children:[u," Stop"]})}),e[12]=r,e[13]=d,e[14]=f):f=e[14];let m;e[15]===Symbol.for("react.memo_cache_sentinel")?(m=n.jsx(je,{children:"Stop sandbox"}),e[15]=m):m=e[15];let p;e[16]!==f?(p=n.jsxs(Ne,{children:[f,m]}),e[16]=f,e[17]=p):p=e[17];let _;e[18]!==o||e[19]!==h?(_=h&&n.jsxs(Zs,{children:[n.jsx(Qs,{asChild:!0,children:n.jsx(ie,{variant:"outline",size:"sm",className:"rounded-l-none px-1",children:n.jsx(ks,{className:"size-3"})})}),n.jsx(ei,{align:"end",children:n.jsxs(et,{onClick:o,children:[n.jsx(Ai,{className:"size-3.5"})," Restart"]})})]}),e[18]=o,e[19]=h,e[20]=_):_=e[20];let g;return e[21]!==p||e[22]!==_?(g=n.jsxs("div",{className:"flex items-center",children:[p,_]}),e[21]=p,e[22]=_,e[23]=g):g=e[23],g}return null}function cb(t){const e=W.c(16),{active:s,onClick:i,onClose:r,children:o}=t,a=s?"border-border bg-background shadow-sm":"border-transparent hover:bg-background/50";let l;e[0]!==a?(l=oe("flex h-7 items-center rounded-md border text-xs",a),e[0]=a,e[1]=l):l=e[1];const h=r?"pl-2.5 pr-1":"px-2.5",c=s?"font-medium text-foreground":"text-muted-foreground hover:text-foreground";let d;e[2]!==h||e[3]!==c?(d=oe("flex h-full items-center",h,c),e[2]=h,e[3]=c,e[4]=d):d=e[4];let u;e[5]!==o||e[6]!==i||e[7]!==d?(u=n.jsx("button",{type:"button",onClick:i,className:d,children:o}),e[5]=o,e[6]=i,e[7]=d,e[8]=u):u=e[8];let f;e[9]!==o||e[10]!==r?(f=r&&n.jsx("button",{type:"button","aria-label":`Close ${o}`,onClick:r,className:"pr-1.5 text-muted-foreground hover:text-foreground",children:n.jsx(Hm,{className:"size-3"})}),e[9]=o,e[10]=r,e[11]=f):f=e[11];let m;return e[12]!==l||e[13]!==u||e[14]!==f?(m=n.jsxs("div",{className:l,children:[u,f]}),e[12]=l,e[13]=u,e[14]=f,e[15]=m):m=e[15],m}function hb(t){const e=W.c(10),{scripts:s,onRun:i}=t,[r,o]=P.useState(!1);let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=n.jsxs(Ne,{children:[n.jsx(ke,{asChild:!0,children:n.jsx(Ns,{asChild:!0,children:n.jsx(ie,{variant:"ghost",size:"sm","aria-label":"Run script",children:n.jsx(At,{className:"size-3.5"})})})}),n.jsx(je,{children:"Run script"})]}),e[0]=a):a=e[0];let l;e[1]===Symbol.for("react.memo_cache_sentinel")?(l=n.jsx("div",{className:"px-2 py-1 text-[10px] uppercase tracking-wide text-muted-foreground",children:"run a script"}),e[1]=l):l=e[1];let h;e[2]!==i||e[3]!==s?(h=s.length===0?n.jsx("div",{className:"px-2 py-2 text-xs text-muted-foreground",children:"No scripts found"}):s.map(u=>n.jsxs("button",{type:"button",onClick:()=>{o(!1),i(u)},className:"w-full rounded-md px-2 py-1.5 text-left text-xs hover:bg-accent",children:["▸ ",u]},u)),e[2]=i,e[3]=s,e[4]=h):h=e[4];let c;e[5]!==h?(c=n.jsxs(Es,{align:"start",className:"p-1 w-56",children:[l,h]}),e[5]=h,e[6]=c):c=e[6];let d;return e[7]!==r||e[8]!==c?(d=n.jsxs(js,{open:r,onOpenChange:o,children:[a,c]}),e[7]=r,e[8]=c,e[9]=d):d=e[9],d}function db(t){const e=W.c(13),{isRunning:s,isKilling:i,onRun:r,onStop:o}=t;if(i){let d;return e[0]===Symbol.for("react.memo_cache_sentinel")?(d=n.jsxs(ie,{variant:"outline",size:"sm",disabled:!0,children:[n.jsx(we,{className:"size-3.5 animate-spin"})," Stopping…"]}),e[0]=d):d=e[0],d}if(!s){let d;e[1]===Symbol.for("react.memo_cache_sentinel")?(d=n.jsx(Hs,{className:"size-3.5"}),e[1]=d):d=e[1];let u;e[2]!==r?(u=n.jsx(ke,{asChild:!0,children:n.jsxs(ie,{variant:"outline",size:"sm",onClick:r,children:[d," Run"]})}),e[2]=r,e[3]=u):u=e[3];let f;e[4]===Symbol.for("react.memo_cache_sentinel")?(f=n.jsx(je,{children:"Start process"}),e[4]=f):f=e[4];let m;return e[5]!==u?(m=n.jsxs(Ne,{children:[u,f]}),e[5]=u,e[6]=m):m=e[6],m}let a;e[7]===Symbol.for("react.memo_cache_sentinel")?(a=n.jsx(Mc,{className:"size-3.5"}),e[7]=a):a=e[7];let l;e[8]!==o?(l=n.jsx(ke,{asChild:!0,children:n.jsxs(ie,{variant:"outline",size:"sm",onClick:o,children:[a," Stop"]})}),e[8]=o,e[9]=l):l=e[9];let h;e[10]===Symbol.for("react.memo_cache_sentinel")?(h=n.jsx(je,{children:"Stop process"}),e[10]=h):h=e[10];let c;return e[11]!==l?(c=n.jsxs(Ne,{children:[l,h]}),e[11]=l,e[12]=c):c=e[12],c}var cd=Object.defineProperty,ub=Object.getOwnPropertyDescriptor,fb=(t,e)=>{for(var s in e)cd(t,s,{get:e[s],enumerable:!0})},$e=(t,e,s,i)=>{for(var r=i>1?void 0:i?ub(e,s):e,o=t.length-1,a;o>=0;o--)(a=t[o])&&(r=(i?a(e,s,r):a(r))||r);return i&&r&&cd(e,s,r),r},ce=(t,e)=>(s,i)=>e(s,i,t),bl="Terminal input",Kn={get:()=>bl,set:t=>bl=t},yl="Too much output to announce, navigate to rows manually to read",Vn={get:()=>yl,set:t=>yl=t};function mb(t){return t.replace(/\r?\n/g,"\r")}function pb(t,e){return e?"\x1B[200~"+t+"\x1B[201~":t}function _b(t,e){t.clipboardData&&t.clipboardData.setData("text/plain",e.selectionText),t.preventDefault()}function gb(t,e,s,i){if(t.stopPropagation(),t.clipboardData){let r=t.clipboardData.getData("text/plain");hd(r,e,s,i)}}function hd(t,e,s,i){t=mb(t),t=pb(t,s.decPrivateModes.bracketedPasteMode&&i.rawOptions.ignoreBracketedPasteMode!==!0),s.triggerDataEvent(t,!0),e.value=""}function dd(t,e,s){let i=s.getBoundingClientRect(),r=t.clientX-i.left-10,o=t.clientY-i.top-10;e.style.width="20px",e.style.height="20px",e.style.left=`${r}px`,e.style.top=`${o}px`,e.style.zIndex="1000",e.focus()}function Sl(t,e,s,i,r){dd(t,e,s),r&&i.rightClickSelect(t),e.value=i.selectionText,e.select()}function hs(t){return t>65535?(t-=65536,String.fromCharCode((t>>10)+55296)+String.fromCharCode(t%1024+56320)):String.fromCharCode(t)}function rn(t,e=0,s=t.length){let i="";for(let r=e;r<s;++r){let o=t[r];o>65535?(o-=65536,i+=String.fromCharCode((o>>10)+55296)+String.fromCharCode(o%1024+56320)):i+=String.fromCharCode(o)}return i}var vb=class{constructor(){this._interim=0}clear(){this._interim=0}decode(t,e){let s=t.length;if(!s)return 0;let i=0,r=0;if(this._interim){let o=t.charCodeAt(r++);56320<=o&&o<=57343?e[i++]=(this._interim-55296)*1024+o-56320+65536:(e[i++]=this._interim,e[i++]=o),this._interim=0}for(let o=r;o<s;++o){let a=t.charCodeAt(o);if(55296<=a&&a<=56319){if(++o>=s)return this._interim=a,i;let l=t.charCodeAt(o);56320<=l&&l<=57343?e[i++]=(a-55296)*1024+l-56320+65536:(e[i++]=a,e[i++]=l);continue}a!==65279&&(e[i++]=a)}return i}},xb=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(t,e){let s=t.length;if(!s)return 0;let i=0,r,o,a,l,h=0,c=0;if(this.interim[0]){let f=!1,m=this.interim[0];m&=(m&224)===192?31:(m&240)===224?15:7;let p=0,_;for(;(_=this.interim[++p]&63)&&p<4;)m<<=6,m|=_;let g=(this.interim[0]&224)===192?2:(this.interim[0]&240)===224?3:4,v=g-p;for(;c<v;){if(c>=s)return 0;if(_=t[c++],(_&192)!==128){c--,f=!0;break}else this.interim[p++]=_,m<<=6,m|=_&63}f||(g===2?m<128?c--:e[i++]=m:g===3?m<2048||m>=55296&&m<=57343||m===65279||(e[i++]=m):m<65536||m>1114111||(e[i++]=m)),this.interim.fill(0)}let d=s-4,u=c;for(;u<s;){for(;u<d&&!((r=t[u])&128)&&!((o=t[u+1])&128)&&!((a=t[u+2])&128)&&!((l=t[u+3])&128);)e[i++]=r,e[i++]=o,e[i++]=a,e[i++]=l,u+=4;if(r=t[u++],r<128)e[i++]=r;else if((r&224)===192){if(u>=s)return this.interim[0]=r,i;if(o=t[u++],(o&192)!==128){u--;continue}if(h=(r&31)<<6|o&63,h<128){u--;continue}e[i++]=h}else if((r&240)===224){if(u>=s)return this.interim[0]=r,i;if(o=t[u++],(o&192)!==128){u--;continue}if(u>=s)return this.interim[0]=r,this.interim[1]=o,i;if(a=t[u++],(a&192)!==128){u--;continue}if(h=(r&15)<<12|(o&63)<<6|a&63,h<2048||h>=55296&&h<=57343||h===65279)continue;e[i++]=h}else if((r&248)===240){if(u>=s)return this.interim[0]=r,i;if(o=t[u++],(o&192)!==128){u--;continue}if(u>=s)return this.interim[0]=r,this.interim[1]=o,i;if(a=t[u++],(a&192)!==128){u--;continue}if(u>=s)return this.interim[0]=r,this.interim[1]=o,this.interim[2]=a,i;if(l=t[u++],(l&192)!==128){u--;continue}if(h=(r&7)<<18|(o&63)<<12|(a&63)<<6|l&63,h<65536||h>1114111)continue;e[i++]=h}}return i}},ud="",ds=" ",qi=class fd{constructor(){this.fg=0,this.bg=0,this.extended=new Or}static toColorRGB(e){return[e>>>16&255,e>>>8&255,e&255]}static fromColorRGB(e){return(e[0]&255)<<16|(e[1]&255)<<8|e[2]&255}clone(){let e=new fd;return e.fg=this.fg,e.bg=this.bg,e.extended=this.extended.clone(),e}isInverse(){return this.fg&67108864}isBold(){return this.fg&134217728}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:this.fg&268435456}isBlink(){return this.fg&536870912}isInvisible(){return this.fg&1073741824}isItalic(){return this.bg&67108864}isDim(){return this.bg&134217728}isStrikethrough(){return this.fg&2147483648}isProtected(){return this.bg&536870912}isOverline(){return this.bg&1073741824}getFgColorMode(){return this.fg&50331648}getBgColorMode(){return this.bg&50331648}isFgRGB(){return(this.fg&50331648)===50331648}isBgRGB(){return(this.bg&50331648)===50331648}isFgPalette(){return(this.fg&50331648)===16777216||(this.fg&50331648)===33554432}isBgPalette(){return(this.bg&50331648)===16777216||(this.bg&50331648)===33554432}isFgDefault(){return(this.fg&50331648)===0}isBgDefault(){return(this.bg&50331648)===0}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(this.fg&50331648){case 16777216:case 33554432:return this.fg&255;case 50331648:return this.fg&16777215;default:return-1}}getBgColor(){switch(this.bg&50331648){case 16777216:case 33554432:return this.bg&255;case 50331648:return this.bg&16777215;default:return-1}}hasExtendedAttrs(){return this.bg&268435456}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(this.bg&268435456&&~this.extended.underlineColor)switch(this.extended.underlineColor&50331648){case 16777216:case 33554432:return this.extended.underlineColor&255;case 50331648:return this.extended.underlineColor&16777215;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return this.bg&268435456&&~this.extended.underlineColor?this.extended.underlineColor&50331648:this.getFgColorMode()}isUnderlineColorRGB(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===50331648:this.isFgRGB()}isUnderlineColorPalette(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===16777216||(this.extended.underlineColor&50331648)===33554432:this.isFgPalette()}isUnderlineColorDefault(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===0:this.isFgDefault()}getUnderlineStyle(){return this.fg&268435456?this.bg&268435456?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},Or=class md{constructor(e=0,s=0){this._ext=0,this._urlId=0,this._ext=e,this._urlId=s}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(e){this._ext=e}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(e){this._ext&=-469762049,this._ext|=e<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(e){this._ext&=-67108864,this._ext|=e&67108863}get urlId(){return this._urlId}set urlId(e){this._urlId=e}get underlineVariantOffset(){let e=(this._ext&3758096384)>>29;return e<0?e^4294967288:e}set underlineVariantOffset(e){this._ext&=536870911,this._ext|=e<<29&3758096384}clone(){return new md(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},kt=class pd extends qi{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new Or,this.combinedData=""}static fromCharData(e){let s=new pd;return s.setFromCharData(e),s}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?hs(this.content&2097151):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(e){this.fg=e[0],this.bg=0;let s=!1;if(e[1].length>2)s=!0;else if(e[1].length===2){let i=e[1].charCodeAt(0);if(55296<=i&&i<=56319){let r=e[1].charCodeAt(1);56320<=r&&r<=57343?this.content=(i-55296)*1024+r-56320+65536|e[2]<<22:s=!0}else s=!0}else this.content=e[1].charCodeAt(0)|e[2]<<22;s&&(this.combinedData=e[1],this.content=2097152|e[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},wl="di$target",qn="di$dependencies",bn=new Map;function bb(t){return t[qn]||[]}function st(t){if(bn.has(t))return bn.get(t);let e=function(s,i,r){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");yb(e,s,r)};return e._id=t,bn.set(t,e),e}function yb(t,e,s){e[wl]===e?e[qn].push({id:t,index:s}):(e[qn]=[{id:t,index:s}],e[wl]=e)}var dt=st("BufferService"),_d=st("CoreMouseService"),Ds=st("CoreService"),Sb=st("CharsetService"),xa=st("InstantiationService"),gd=st("LogService"),ut=st("OptionsService"),vd=st("OscLinkService"),wb=st("UnicodeService"),Gi=st("DecorationService"),Gn=class{constructor(t,e,s){this._bufferService=t,this._optionsService=e,this._oscLinkService=s}provideLinks(t,e){let s=this._bufferService.buffer.lines.get(t-1);if(!s){e(void 0);return}let i=[],r=this._optionsService.rawOptions.linkHandler,o=new kt,a=s.getTrimmedLength(),l=-1,h=-1,c=!1;for(let d=0;d<a;d++)if(!(h===-1&&!s.hasContent(d))){if(s.loadCell(d,o),o.hasExtendedAttrs()&&o.extended.urlId)if(h===-1){h=d,l=o.extended.urlId;continue}else c=o.extended.urlId!==l;else h!==-1&&(c=!0);if(c||h!==-1&&d===a-1){let u=this._oscLinkService.getLinkData(l)?.uri;if(u){let f={start:{x:h+1,y:t},end:{x:d+(!c&&d===a-1?1:0),y:t}},m=!1;if(!r?.allowNonHttpProtocols)try{let p=new URL(u);["http:","https:"].includes(p.protocol)||(m=!0)}catch{m=!0}m||i.push({text:u,range:f,activate:(p,_)=>r?r.activate(p,_,f):Cb(p,_),hover:(p,_)=>r?.hover?.(p,_,f),leave:(p,_)=>r?.leave?.(p,_,f)})}c=!1,o.hasExtendedAttrs()&&o.extended.urlId?(h=d,l=o.extended.urlId):(h=-1,l=-1)}}e(i)}};Gn=$e([ce(0,dt),ce(1,ut),ce(2,vd)],Gn);function Cb(t,e){if(confirm(`Do you want to navigate to ${e}?
295
+ `);if(ae.trim()){A(!0);try{te(),Le("automation_improve_clicked",{automation_id:t,agent_id:r,instructions_length:ae.length}),f(!0),await m({tiptapDoc:Eh({managerAgentId:Cc.AUTOMATION_MANAGER(o.id),managerName:"Automation Manager",kind:"automation",id:t,instructions:ae})})}finally{A(!1)}}},F=e.models?.tier??"smart",H=e.models?.modelId&&e.models?.credentialId?{modelId:e.models.modelId,credentialId:e.models.credentialId,title:e.models.modelTitle??e.models.modelId}:null,M=Sc({defaultValues:{name:e.name,active:e.active,tier:F,modelOverride:H,tools:e.tools??null,maxAgentSteps:e.maxAgentSteps??null}}),U=M.watch("active"),[V,K]=P.useReducer(Lx,null),Y=()=>{V!==null&&(Le("automation_updated",{automation_id:t,agent_id:r,fields:Array.from(V.fields),save_count:V.saveCount,edit_duration_ms:Date.now()-V.start}),K({type:"reset"}))},Q=async()=>{const $=M.control._formState.dirtyFields,ae=Object.keys($);if(ae.length===0&&!L)return!0;const de=M.getValues(),me=M.control._defaultValues;M.reset(de,{keepValues:!0});const le=L;B(!1);const G={tier:de.tier,...de.modelOverride?{modelId:de.modelOverride.modelId,credentialId:de.modelOverride.credentialId,modelTitle:de.modelOverride.title}:{}},pe={id:t,name:de.name,active:de.active,models:G,tools:de.tools,maxAgentSteps:de.maxAgentSteps,messages:Lu(_),temperature:0};try{await a.mutateAsync(pe)}catch{return M.reset(me,{keepValues:!0}),le&&B(!0),!1}const ue=[...ae];return le&&ue.push("messages"),K({type:"accumulate",now:Date.now(),fields:ue}),z(),!0},{schedule:se,flush:he}=Ar({save:Q}),{schedule:z,flush:te}=Ar({delayMs:3e4,save:async()=>Y()});P.useEffect(()=>{const $=M.watch(()=>se());return()=>$.unsubscribe()},[]);const ee=$=>{if(g($),!E){T(!0);return}B(!0),se()},q=async()=>{Le("automation_test_clicked",{automation_id:t,agent_id:r});const $=await he();if(te(),!!$){if(!_){ne.error("No instructions configured for this automation");return}try{const ae=await h.mutateAsync(t);ae.threadId&&(f(!0),u(ae.threadId))}catch{}}};return n.jsxs(n.Fragment,{children:[s&&n.jsx("div",{className:"flex items-center pb-4 shrink-0",children:n.jsxs(ie,{variant:"ghost",size:"sm",onClick:s,children:[n.jsx(eh,{size:14}),"Back to list"]})}),n.jsxs("div",{className:"flex flex-col gap-8",children:[n.jsxs("div",{className:"flex flex-col gap-1.5",children:[n.jsxs("div",{className:"flex items-center justify-between gap-4",children:[n.jsx(vt,{control:M.control,name:"name",render:({field:$})=>n.jsx(qe,{...$,placeholder:"Automation name",className:"border border-transparent shadow-none px-0 text-lg font-medium h-auto focus-visible:ring-0 focus-visible:border-border bg-transparent flex-1",style:{boxShadow:"none"}})}),i&&n.jsx(ie,{variant:"ghost",size:"icon",className:"text-muted-foreground hover:text-destructive shrink-0",onClick:i,children:n.jsx(Bi,{size:14})})]}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(vt,{control:M.control,name:"active",render:({field:$})=>n.jsx(Dr,{checked:$.value,onCheckedChange:ae=>{$.onChange(ae),he()},className:"cursor-pointer"})}),n.jsx("span",{className:"text-sm text-muted-foreground",children:U?"Active":"Inactive"}),n.jsx("span",{className:"text-muted-foreground/50 text-sm",children:"·"}),n.jsx(Kc,{id:e.created_by,size:"2xs",className:"text-sm text-muted-foreground"})]})]}),n.jsxs("div",{className:"flex flex-col gap-2.5",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx("span",{className:"text-xs font-semibold text-muted-foreground/60",children:"Starter"}),n.jsx(Dx,{automationId:t,open:v,onOpenChange:y,onCustomSelect:()=>{w(!0),D(!1),N("")},onEventSelect:()=>{D(!0),w(!1)},onWebhookCreated:$=>{Le("automation_trigger_added",{automation_id:t,trigger_type:"webhook"}),j($)}})]}),e.triggers.length===0&&!S?n.jsx("div",{className:"rounded-lg border border-dashed border-border px-4 py-6 text-center",children:n.jsxs("p",{className:"text-sm text-muted-foreground",children:["When should this automation run?"," ",n.jsx("button",{type:"button",className:"text-foreground underline underline-offset-2 cursor-pointer hover:text-foreground/80 transition-colors",onClick:()=>y(!0),children:"Add a starter"})," ","to get going."]})}):n.jsx("div",{className:"flex flex-col gap-2",children:e.triggers.map($=>n.jsx(Ax,{trigger:$,automationId:t,connectionName:$.connection_id?d.get($.connection_id):void 0},$.id))}),S&&n.jsxs("div",{className:"flex items-center gap-2.5 px-3 py-2.5 rounded-lg border border-border bg-background group",children:[n.jsx(ki,{size:14,className:"text-muted-foreground shrink-0"}),n.jsx("input",{type:"text",value:k,onChange:$=>N($.target.value),onBlur:async()=>{const $=k.trim();if(!(!$||!Pi($)))try{await l.mutateAsync({automation_id:t,type:"cron",cron_expression:$}),Le("automation_trigger_added",{automation_id:t,trigger_type:"cron"}),ne.success("Starter added"),w(!1),N("")}catch{ne.error("Failed to add starter")}},onKeyDown:async $=>{const ae=k.trim();$.key==="Enter"&&ae&&Pi(ae)&&$.target.blur(),$.key==="Escape"&&(w(!1),N(""))},placeholder:"0 9 * * 1-5",className:"flex-1 text-sm font-mono bg-transparent outline-none placeholder:text-muted-foreground/40",autoFocus:!0}),k&&!Pi(k)&&n.jsx("span",{className:"text-xs text-muted-foreground/60 shrink-0",children:"invalid"}),l.isPending&&n.jsx(we,{size:13,className:"animate-spin text-muted-foreground shrink-0"}),n.jsx("button",{type:"button",className:"shrink-0 p-0.5 rounded text-muted-foreground opacity-0 group-hover:opacity-100 hover:text-foreground transition-opacity",onClick:()=>{w(!1),N("")},children:n.jsx(fs,{size:13})})]}),I&&n.jsx(P.Suspense,{fallback:n.jsxs("div",{className:"flex items-center gap-2 px-3 py-3 rounded-lg border border-border bg-background",children:[n.jsx(we,{size:13,className:"animate-spin text-muted-foreground"}),n.jsx("span",{className:"text-sm text-muted-foreground",children:"Loading connections..."})]}),children:n.jsx(Mx,{automationId:t,onDone:()=>D(!1)})}),n.jsx(nd,{open:R!==null,onOpenChange:$=>{$||j(null)},url:R?.url??null,token:R?.token??null})]}),n.jsxs("div",{className:"flex flex-col gap-2.5",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx("span",{className:"text-xs font-semibold text-muted-foreground/60",children:"Instructions"}),n.jsxs(ie,{variant:"outline",size:"sm",className:"h-7 gap-1.5 px-2 text-xs",disabled:C||!_,onClick:O,children:[n.jsx(Zr,{size:13}),"Improve"]})]}),n.jsx(Eu,{tiptapDoc:_,setTiptapDoc:ee,placeholder:"What should this automation do?",children:n.jsxs("div",{className:"rounded-xl border border-border min-h-[120px] flex flex-col",children:[n.jsx(Tu,{virtualMcpId:r||null,className:"max-h-[45vh]"}),n.jsx("div",{className:"@container/chat-bottom flex items-center justify-end gap-1.5 p-2.5",children:n.jsxs(Ne,{children:[n.jsx(ke,{asChild:!0,children:n.jsxs(ie,{type:"button",variant:"default",className:"h-8 gap-1.5 rounded-md px-3 text-sm font-medium",onClick:q,disabled:!r,children:[n.jsx(Cm,{size:16}),"Test"]})}),n.jsx(je,{children:"Test Automation"})]})})]})})]}),n.jsxs(qu,{open:x,onOpenChange:b,className:"flex flex-col gap-2.5",children:[n.jsxs(Gu,{className:"group flex w-fit cursor-pointer items-center gap-1.5",children:[n.jsx("span",{className:"text-xs font-semibold text-muted-foreground/60",children:"Advanced"}),n.jsx(ks,{size:14,className:"text-muted-foreground/60 transition-transform group-data-[state=open]:rotate-180"})]}),n.jsxs(Yu,{className:"flex flex-col gap-5 pt-0.5",children:[n.jsx(_x,{tier:M.watch("tier"),onTierChange:$=>M.setValue("tier",$,{shouldDirty:!0}),override:M.watch("modelOverride"),onOverrideChange:$=>M.setValue("modelOverride",$,{shouldDirty:!0})}),n.jsx(bx,{agentId:r||null,value:M.watch("tools"),onChange:$=>M.setValue("tools",$,{shouldDirty:!0})}),n.jsxs("div",{className:"flex flex-col gap-2",children:[n.jsx("span",{className:"text-xs font-semibold text-muted-foreground/60",children:"Max steps"}),n.jsx(qe,{type:"number",min:1,max:100,className:"w-40",placeholder:`${Bx} (default)`,value:M.watch("maxAgentSteps")??"",onChange:$=>{const ae=$.target.value.trim(),de=ae===""?null:Number(ae);M.setValue("maxAgentSteps",de===null||Number.isNaN(de)?null:de,{shouldDirty:!0})}})]})]})]})]})]})}function Us(){const t=W.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsx("div",{"data-testid":"main-panel-loading",className:"flex h-full w-full items-center justify-center",children:n.jsx(we,{size:20,className:"animate-spin text-muted-foreground"})}),t[0]=e):e=t[0],e}const od=[{key:"24h",label:"Last 24 hours",ms:1440*60*1e3},{key:"7d",label:"Last 7 days",ms:10080*60*1e3},{key:"30d",label:"Last 30 days",ms:720*60*60*1e3}];function ad(t){const e=od.find(i=>i.key===t).ms,s=Date.now();return{startDate:new Date(s-e).toISOString(),endDate:new Date(s).toISOString()}}function Hx(t){const e=W.c(12),{automationId:s,triggerIds:i}=t,[r,o]=P.useState("30d"),[a,l]=P.useState(Ux);let h;e[0]===Symbol.for("react.memo_cache_sentinel")?(h=p=>{const _=p;o(_),l(ad(_))},e[0]=h):h=e[0];let c;e[1]===Symbol.for("react.memo_cache_sentinel")?(c=n.jsx(Et,{className:"w-44",children:n.jsx(Tt,{})}),e[1]=c):c=e[1];let d;e[2]===Symbol.for("react.memo_cache_sentinel")?(d=n.jsx(Rt,{children:od.map(Wx)}),e[2]=d):d=e[2];let u;e[3]!==r?(u=n.jsx("div",{className:"flex items-center justify-end",children:n.jsxs(Pt,{value:r,onValueChange:h,children:[c,d]})}),e[3]=r,e[4]=u):u=e[4];let f;e[5]!==s||e[6]!==a||e[7]!==i?(f=n.jsx(Mm,{automationId:s,triggerIds:i,range:a}),e[5]=s,e[6]=a,e[7]=i,e[8]=f):f=e[8];let m;return e[9]!==u||e[10]!==f?(m=n.jsxs("div",{className:"flex flex-col gap-5",children:[u,f]}),e[9]=u,e[10]=f,e[11]=m):m=e[11],m}function Wx(t){return n.jsx(at,{value:t.key,children:t.label},t.key)}function Ux(){return ad("30d")}function Kx(t){const e=W.c(5),{tabId:s}=t;let i;e[0]!==s?(i=zc(s),e[0]=s,e[1]=i):i=e[1];const r=i;if(!r)return null;let o;e[2]===Symbol.for("react.memo_cache_sentinel")?(o=n.jsx(Us,{}),e[2]=o):o=e[2];let a;return e[3]!==r.id?(a=n.jsx(P.Suspense,{fallback:o,children:n.jsx(Vx,{id:r.id})}),e[3]=r.id,e[4]=a):a=e[4],a}function Vx(t){const e=W.c(24),{id:s}=t,i=es(),{data:r,isLoading:o}=Im(s),[a,l]=P.useState("settings");let h;e[0]!==i?(h=()=>{i({to:".",search:Gx,replace:!0})},e[0]=i,e[1]=h):h=e[1];const c=h;if(o){let b;return e[2]===Symbol.for("react.memo_cache_sentinel")?(b=n.jsx(Us,{}),e[2]=b):b=e[2],b}if(!r){let b;return e[3]===Symbol.for("react.memo_cache_sentinel")?(b=n.jsx("div",{className:"flex h-full w-full items-center justify-center text-sm text-muted-foreground",children:"Automation not found"}),e[3]=b):b=e[3],b}let d;e[4]!==r.triggers?(d=r.triggers.map(qx),e[4]=r.triggers,e[5]=d):d=e[5];const u=d;let f;e[6]===Symbol.for("react.memo_cache_sentinel")?(f=n.jsx(eh,{size:14}),e[6]=f):f=e[6];let m;e[7]!==c?(m=n.jsxs(ie,{variant:"ghost",size:"sm",onClick:c,children:[f,"Back to list"]}),e[7]=c,e[8]=m):m=e[8];let p;e[9]===Symbol.for("react.memo_cache_sentinel")?(p=[{id:"settings",label:"Settings"},{id:"runs",label:"Runs"}],e[9]=p):p=e[9];let _;e[10]===Symbol.for("react.memo_cache_sentinel")?(_=b=>l(b),e[10]=_):_=e[10];let g;e[11]!==a?(g=n.jsx(Xc,{tabs:p,activeTab:a,onTabChange:_}),e[11]=a,e[12]=g):g=e[12];let v;e[13]!==m||e[14]!==g?(v=n.jsxs("div",{className:"flex items-center justify-between pb-4 shrink-0",children:[m,g]}),e[13]=m,e[14]=g,e[15]=v):v=e[15];let y;e[16]!==r||e[17]!==s||e[18]!==a||e[19]!==u?(y=a==="settings"?n.jsx(Fx,{automationId:s,automation:r}):n.jsx(Hx,{automationId:s,triggerIds:u}),e[16]=r,e[17]=s,e[18]=a,e[19]=u,e[20]=y):y=e[20];let x;return e[21]!==v||e[22]!==y?(x=n.jsx(Nt,{children:n.jsx(Nt.Content,{children:n.jsxs(Nt.Body,{children:[v,y]})})}),e[21]=v,e[22]=y,e[23]=x):x=e[23],x}function qx(t){return t.id}function Gx(t){return{...t,main:"automations"}}function Yx(t){const e=W.c(20),{virtualMcpId:s}=t,i=es(),{data:r}=Bm(s),o=r===void 0?[]:r,{create:a}=Wi(),[l,h]=P.useState(""),c=l.toLowerCase(),d=o.filter(R=>R.name.toLowerCase().includes(c));let u;e[0]!==i?(u=R=>i({to:".",search:j=>({...j,main:"automation:"+R}),replace:!0}),e[0]=i,e[1]=u):u=e[1];const f=u,m=async()=>{if(a.isPending)return;Le("automation_new_clicked",{virtual_mcp_id:s,existing_count:o.length});const R=await a.mutateAsync(Lm(s));f(R.id)};let p;e[2]===Symbol.for("react.memo_cache_sentinel")?(p=n.jsx(At,{size:14}),e[2]=p):p=e[2];let _;e[3]!==a.isPending||e[4]!==m?(_=n.jsxs(ie,{size:"sm",onClick:m,disabled:a.isPending,children:[p,"New automation"]}),e[3]=a.isPending,e[4]=m,e[5]=_):_=e[5];const g=_,v=Nt,y=Nt,x=Nt;let b;e[6]===Symbol.for("react.memo_cache_sentinel")?(b=n.jsx(Nt.Title,{children:"Automations"}),e[6]=b):b=e[6];const S=o.length>0&&n.jsx(Yc,{value:l,onChange:h,placeholder:"Search automations...",className:"w-full md:w-[375px]"});let w;e[7]!==g||e[8]!==S?(w=n.jsxs("div",{className:"flex flex-col gap-6",children:[b,n.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[S,g]})]}),e[7]=g,e[8]=S,e[9]=w):w=e[9];const k=o.length===0?n.jsx("div",{className:"flex items-center justify-center py-20",children:n.jsx(Sr,{image:n.jsx(Li,{size:48,className:"text-muted-foreground"}),title:"No automations yet",description:"Create your first automation to run this agent on a schedule or in response to events.",actions:g})}):d.length===0?n.jsx("div",{className:"flex items-center justify-center py-20",children:n.jsx(Sr,{image:n.jsx(Li,{size:48,className:"text-muted-foreground"}),title:"No automations found",description:`No automations match "${l}"`})}):n.jsx("div",{className:"mt-6 rounded-xl border border-border overflow-hidden",children:d.map(R=>n.jsx(Om,{automation:R,onClick:()=>f(R.id)},R.id))});let N;e[10]!==k||e[11]!==x.Body||e[12]!==w?(N=n.jsxs(x.Body,{children:[w,k]}),e[10]=k,e[11]=x.Body,e[12]=w,e[13]=N):N=e[13];let I;e[14]!==N||e[15]!==y.Content?(I=n.jsx(y.Content,{children:N}),e[14]=N,e[15]=y.Content,e[16]=I):I=e[16];let D;return e[17]!==v||e[18]!==I?(D=n.jsx(v,{children:I}),e[17]=v,e[18]=I,e[19]=D):D=e[19],D}function Xx(t){const e=W.c(3),{virtualMcpId:s}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=n.jsx(Us,{}),e[0]=i):i=e[0];let r;return e[1]!==s?(r=n.jsx(P.Suspense,{fallback:i,children:n.jsx(Yx,{virtualMcpId:s})}),e[1]=s,e[2]=r):r=e[2],r}const vl=300;function ld(){const t=W.c(2);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsx(Os,{className:"h-6 w-2/3"}),t[0]=e):e=t[0];let s;return t[1]===Symbol.for("react.memo_cache_sentinel")?(s=n.jsx("div",{className:"flex h-full w-full items-center justify-center bg-white",children:n.jsxs("div",{className:"flex w-3/4 max-w-md flex-col gap-3 p-6",children:[e,n.jsxs("div",{className:"flex flex-col gap-1.5",children:[n.jsx(Os,{className:"h-3 w-full"}),n.jsx(Os,{className:"h-3 w-5/6"}),n.jsx(Os,{className:"h-3 w-2/3"})]}),n.jsx(Os,{className:"mt-2 h-8 w-24"})]})}),t[1]=s):s=t[1],s}function Jx(t){const e=W.c(14),{url:s,title:i}=t,[r,o]=P.useState(!1),[a,l]=P.useState(!0);let h;e[0]===Symbol.for("react.memo_cache_sentinel")?(h=()=>o(!0),e[0]=h):h=e[0];const c=r?"opacity-100":"opacity-0";let d;e[1]!==c?(d=oe("absolute inset-0 block w-full h-full bg-white","transition-opacity ease-out",c),e[1]=c,e[2]=d):d=e[2];let u;e[3]===Symbol.for("react.memo_cache_sentinel")?(u={transitionDuration:`${vl}ms`},e[3]=u):u=e[3];let f;e[4]!==d||e[5]!==i||e[6]!==s?(f=n.jsx("iframe",{src:s,onLoad:h,sandbox:"allow-scripts",className:d,style:u,title:i}),e[4]=d,e[5]=i,e[6]=s,e[7]=f):f=e[7];let m;e[8]!==r||e[9]!==a?(m=a&&n.jsx("div",{className:oe("absolute inset-0 transition-opacity ease-out",r?"opacity-0 pointer-events-none":"opacity-100"),style:{transitionDuration:`${vl}ms`},onTransitionEnd:_=>{_.propertyName==="opacity"&&r&&l(!1)},children:n.jsx(ld,{})}),e[8]=r,e[9]=a,e[10]=m):m=e[10];let p;return e[11]!==f||e[12]!==m?(p=n.jsxs("div",{className:"relative h-full w-full bg-background",children:[f,m]}),e[11]=f,e[12]=m,e[13]=p):p=e[13],p}function Zx(t,e){for(let s=t.length-1;s>=0;s--){const i=t[s]?.parts;if(i)for(let r=i.length-1;r>=0;r--){const o=i[r];if(!o||o.type!=="data-html-page-published")continue;const a=o.data;if(a&&a.slug===e)return a}}return null}function Qx(t){const e=W.c(32),{url:s}=t,[i,r]=P.useState(!1);let o;e[0]!==s?(o=()=>{navigator.clipboard.writeText(s),r(!0),window.setTimeout(()=>r(!1),1500)},e[0]=s,e[1]=o):o=e[1];const a=o;let l;e[2]!==s?(l=()=>window.open(s,"_blank","noopener"),e[2]=s,e[3]=l):l=e[3];let h;e[4]!==s?(h=n.jsx("span",{className:"truncate",children:s}),e[4]=s,e[5]=h):h=e[5];let c;e[6]!==l||e[7]!==h||e[8]!==s?(c=n.jsx("button",{type:"button",onClick:l,className:"flex min-w-0 flex-1 items-center rounded-md px-2 py-1 text-left text-xs text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",title:s,children:h}),e[6]=l,e[7]=h,e[8]=s,e[9]=c):c=e[9];let d;e[10]!==i?(d=i?n.jsx(si,{size:14}):n.jsx(Zt,{size:14}),e[10]=i,e[11]=d):d=e[11];let u;e[12]!==a||e[13]!==d?(u=n.jsx(ke,{asChild:!0,children:n.jsx(ie,{variant:"ghost",size:"icon",onClick:a,children:d})}),e[12]=a,e[13]=d,e[14]=u):u=e[14];const f=i?"Copied":"Copy URL";let m;e[15]!==f?(m=n.jsx(je,{side:"bottom",children:f}),e[15]=f,e[16]=m):m=e[16];let p;e[17]!==u||e[18]!==m?(p=n.jsxs(Ne,{children:[u,m]}),e[17]=u,e[18]=m,e[19]=p):p=e[19];let _;e[20]!==s?(_=()=>window.open(s,"_blank","noopener"),e[20]=s,e[21]=_):_=e[21];let g;e[22]===Symbol.for("react.memo_cache_sentinel")?(g=n.jsx(Ts,{size:14}),e[22]=g):g=e[22];let v;e[23]!==_?(v=n.jsx(ke,{asChild:!0,children:n.jsx(ie,{variant:"ghost",size:"icon",onClick:_,children:g})}),e[23]=_,e[24]=v):v=e[24];let y;e[25]===Symbol.for("react.memo_cache_sentinel")?(y=n.jsx(je,{side:"bottom",children:"Open in new tab"}),e[25]=y):y=e[25];let x;e[26]!==v?(x=n.jsxs(Ne,{children:[v,y]}),e[26]=v,e[27]=x):x=e[27];let b;return e[28]!==x||e[29]!==c||e[30]!==p?(b=n.jsxs("div",{className:"flex h-9 shrink-0 items-center gap-1 border-b border-border/60 px-2",children:[c,p,x]}),e[28]=x,e[29]=c,e[30]=p,e[31]=b):b=e[31],b}function eb(t){const e=W.c(15),{slug:s}=t,i=Ou();let r,o,a,l;if(e[0]!==s||e[1]!==i?.messages){l=Symbol.for("react.early_return_sentinel");e:{const m=i?.messages??[];if(r=Zx(m,s),!r){let p;e[6]===Symbol.for("react.memo_cache_sentinel")?(p=n.jsx("div",{className:"h-full w-full bg-background",children:n.jsx(ld,{})}),e[6]=p):p=e[6],l=p;break e}o=r.url,a=r.url.includes("?")?"&":"?"}e[0]=s,e[1]=i?.messages,e[2]=r,e[3]=o,e[4]=a,e[5]=l}else r=e[2],o=e[3],a=e[4],l=e[5];if(l!==Symbol.for("react.early_return_sentinel"))return l;const h=`${o}${a}v=${r.bytes}`;let c;e[7]!==r.url?(c=n.jsx(Qx,{url:r.url}),e[7]=r.url,e[8]=c):c=e[8];const d=`${s}.html`;let u;e[9]!==h||e[10]!==d?(u=n.jsx("div",{className:"relative flex-1",children:n.jsx(Jx,{url:h,title:d})}),e[9]=h,e[10]=d,e[11]=u):u=e[11];let f;return e[12]!==c||e[13]!==u?(f=n.jsxs("div",{className:"flex h-full w-full flex-col bg-background",children:[c,u]}),e[12]=c,e[13]=u,e[14]=f):f=e[14],f}function tb(t){const e=W.c(37),{file:s,onClose:i}=t;let r,o;e[0]!==s.filename?(r=n.jsx(Oo,{filename:s.filename,className:"h-4.5 w-3.5 shrink-0"}),o=n.jsx("span",{className:"truncate text-xs font-medium text-foreground",children:s.filename}),e[0]=s.filename,e[1]=r,e[2]=o):(r=e[1],o=e[2]);let a;e[3]!==s.size?(a=Fm(s.size),e[3]=s.size,e[4]=a):a=e[4];let l;e[5]!==a?(l=n.jsx("span",{className:"shrink-0 text-xs text-muted-foreground",children:a}),e[5]=a,e[6]=l):l=e[6];let h;e[7]!==r||e[8]!==o||e[9]!==l?(h=n.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2 px-2",children:[r,o,l]}),e[7]=r,e[8]=o,e[9]=l,e[10]=h):h=e[10];let c;e[11]===Symbol.for("react.memo_cache_sentinel")?(c=n.jsx(Xf,{size:14}),e[11]=c):c=e[11];let d;e[12]!==s.downloadUrl||e[13]!==s.filename?(d=n.jsx(ke,{asChild:!0,children:n.jsx(ie,{variant:"ghost",size:"icon",asChild:!0,children:n.jsx("a",{href:s.downloadUrl,download:s.filename,children:c})})}),e[12]=s.downloadUrl,e[13]=s.filename,e[14]=d):d=e[14];let u;e[15]===Symbol.for("react.memo_cache_sentinel")?(u=n.jsx(je,{side:"bottom",children:"Download"}),e[15]=u):u=e[15];let f;e[16]!==d?(f=n.jsxs(Ne,{children:[d,u]}),e[16]=d,e[17]=f):f=e[17];let m;e[18]!==s.downloadUrl?(m=()=>window.open(s.downloadUrl,"_blank","noopener"),e[18]=s.downloadUrl,e[19]=m):m=e[19];let p;e[20]===Symbol.for("react.memo_cache_sentinel")?(p=n.jsx(Ts,{size:14}),e[20]=p):p=e[20];let _;e[21]!==m?(_=n.jsx(ke,{asChild:!0,children:n.jsx(ie,{variant:"ghost",size:"icon",onClick:m,children:p})}),e[21]=m,e[22]=_):_=e[22];let g;e[23]===Symbol.for("react.memo_cache_sentinel")?(g=n.jsx(je,{side:"bottom",children:"Open in new tab"}),e[23]=g):g=e[23];let v;e[24]!==_?(v=n.jsxs(Ne,{children:[_,g]}),e[24]=_,e[25]=v):v=e[25];let y;e[26]===Symbol.for("react.memo_cache_sentinel")?(y=n.jsx(fs,{size:14}),e[26]=y):y=e[26];let x;e[27]!==i?(x=n.jsx(ke,{asChild:!0,children:n.jsx(ie,{variant:"ghost",size:"icon",onClick:i,children:y})}),e[27]=i,e[28]=x):x=e[28];let b;e[29]===Symbol.for("react.memo_cache_sentinel")?(b=n.jsx(je,{side:"bottom",children:"Close"}),e[29]=b):b=e[29];let S;e[30]!==x?(S=n.jsxs(Ne,{children:[x,b]}),e[30]=x,e[31]=S):S=e[31];let w;return e[32]!==v||e[33]!==S||e[34]!==h||e[35]!==f?(w=n.jsxs("div",{className:"flex h-9 shrink-0 items-center gap-1 border-b border-border/60 px-2",children:[h,f,v,S]}),e[32]=v,e[33]=S,e[34]=h,e[35]=f,e[36]=w):w=e[36],w}function sb(t){const e=W.c(24),{fileKey:s,taskId:i}=t,r=es(),{data:o,isPending:a}=Ec(i);let l;e[0]!==s||e[1]!==o?(l=o?.find(p=>p.key===s)??null,e[0]=s,e[1]=o,e[2]=l):l=e[2];const h=l;let c;e[3]!==r?(c=()=>r({to:".",search:ib,replace:!0}),e[3]=r,e[4]=c):c=e[4];const d=c;if(!h){if(a){let x;return e[5]===Symbol.for("react.memo_cache_sentinel")?(x=n.jsx("div",{className:"h-full w-full bg-background",children:n.jsx($m,{})}),e[5]=x):x=e[5],x}let p;e[6]!==s?(p=s.split("/").pop()??s,e[6]=s,e[7]=p):p=e[7];let _;e[8]!==p?(_=n.jsx(Oo,{filename:p,className:"h-7.5 w-6"}),e[8]=p,e[9]=_):_=e[9];let g;e[10]===Symbol.for("react.memo_cache_sentinel")?(g=n.jsx("span",{className:"text-sm text-muted-foreground",children:"This file is no longer available."}),e[10]=g):g=e[10];let v;e[11]!==d?(v=n.jsx(ie,{variant:"ghost",size:"sm",onClick:d,children:"Close"}),e[11]=d,e[12]=v):v=e[12];let y;return e[13]!==_||e[14]!==v?(y=n.jsxs("div",{className:"flex h-full w-full flex-col items-center justify-center gap-2 bg-background",children:[_,g,v]}),e[13]=_,e[14]=v,e[15]=y):y=e[15],y}let u;e[16]!==h||e[17]!==d?(u=n.jsx(tb,{file:h,onClose:d}),e[16]=h,e[17]=d,e[18]=u):u=e[18];let f;e[19]!==h?(f=n.jsx("div",{className:"relative min-h-0 flex-1",children:n.jsx(zm,{file:h})}),e[19]=h,e[20]=f):f=e[20];let m;return e[21]!==u||e[22]!==f?(m=n.jsxs("div",{className:"flex h-full w-full flex-col bg-background",children:[u,f]}),e[21]=u,e[22]=f,e[23]=m):m=e[23],m}function ib(t){return{...t,main:"0"}}const xl=P.lazy(()=>Kt(()=>import("./project-app-view-CphyMKfg.js"),__vite__mapDeps([158,1,2,90,6,7,8,9,10,11,12,13,14,15,16,3,4,5,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,91,92,45,46,47,93,94,48,95,96,57,97,98,99,100,84,101,56,102,58,103,104,105,106,107,65,108,55,109,70,71,49,110,124])).then(t=>({default:t.AppViewContent})));function rb(t){const e=W.c(49),{activeTab:s,virtualMcpId:i,taskId:r,layoutTabs:o,expandedTools:a,automationTabParsed:l}=t;if(If(s)){let v;return e[0]!==i?(v=n.jsx(il,{virtualMcpId:i}),e[0]=i,e[1]=v):v=e[1],v}if(s==="git"){let v;return e[2]!==i?(v=n.jsx(pv,{virtualMcpId:i}),e[2]=i,e[3]=v):v=e[3],v}if(s==="automations"){let v;return e[4]!==i?(v=n.jsx(Xx,{virtualMcpId:i}),e[4]=i,e[5]=v):v=e[5],v}if(s==="preview"){let v;return e[6]!==i?(v=n.jsx(c1,{virtualMcpId:i}),e[6]=i,e[7]=v):v=e[7],v}if(s==="content"){let v;return e[8]!==i?(v=n.jsx(fx,{virtualMcpId:i}),e[8]=i,e[9]=v):v=e[9],v}if(l){let v;return e[10]!==s?(v=n.jsx(Kx,{tabId:s}),e[10]=s,e[11]=v):v=e[11],v}let h;e[12]!==s?(h=Bf(s),e[12]=s,e[13]=h):h=e[13];const c=h;if(c){let v;return e[14]!==c.slug?(v=n.jsx(eb,{slug:c.slug}),e[14]=c.slug,e[15]=v):v=e[15],v}let d;e[16]!==s?(d=Fc(s),e[16]=s,e[17]=d):d=e[17];const u=d;if(u){let v;return e[18]!==u.key||e[19]!==r?(v=n.jsx(sb,{fileKey:u.key,taskId:r}),e[18]=u.key,e[19]=r,e[20]=v):v=e[20],v}let f;e[21]!==s?(f=Lf(s),e[21]=s,e[22]=f):f=e[22];const m=f;if(m){let v;if(e[23]!==a||e[24]!==m.connectionId||e[25]!==m.toolName){let w;e[27]!==m.connectionId||e[28]!==m.toolName?(w=k=>k.appId===m.connectionId&&k.toolName===m.toolName,e[27]=m.connectionId,e[28]=m.toolName,e[29]=w):w=e[29],v=a.find(w),e[23]=a,e[24]=m.connectionId,e[25]=m.toolName,e[26]=v}else v=e[26];const y=v;let x;e[30]===Symbol.for("react.memo_cache_sentinel")?(x=n.jsx(Us,{}),e[30]=x):x=e[30];const b=y?.args;let S;return e[31]!==s||e[32]!==m.connectionId||e[33]!==m.toolName||e[34]!==b?(S=n.jsx(P.Suspense,{fallback:x,children:n.jsx(xl,{connectionId:m.connectionId,toolName:m.toolName,args:b},s)}),e[31]=s,e[32]=m.connectionId,e[33]=m.toolName,e[34]=b,e[35]=S):S=e[35],S}let p;if(e[36]!==s||e[37]!==o){let v;e[39]!==s?(v=y=>y.id===s,e[39]=s,e[40]=v):v=e[40],p=o.find(v),e[36]=s,e[37]=o,e[38]=p}else p=e[38];const _=p;if(_){let v;e[41]===Symbol.for("react.memo_cache_sentinel")?(v=n.jsx(Us,{}),e[41]=v):v=e[41];let y;return e[42]!==s||e[43]!==_.id||e[44]!==_.view.appId||e[45]!==_.view.args?(y=n.jsx(P.Suspense,{fallback:v,children:n.jsx(xl,{connectionId:_.view.appId,toolName:_.id,args:_.view.args},s)}),e[42]=s,e[43]=_.id,e[44]=_.view.appId,e[45]=_.view.args,e[46]=y):y=e[46],y}let g;return e[47]!==i?(g=n.jsx(il,{virtualMcpId:i}),e[47]=i,e[48]=g):g=e[48],g}function nb(t){const e=W.c(14),{taskId:s,virtualMcpId:i}=t;let r;e[0]!==s||e[1]!==i?(r={virtualMcpId:i,taskId:s},e[0]=s,e[1]=i,e[2]=r):r=e[2];const{activeTab:o,layoutTabs:a,expandedTools:l,automationTabParsed:h}=Nh(r);let c;e[3]===Symbol.for("react.memo_cache_sentinel")?(c=n.jsx(Us,{}),e[3]=c):c=e[3];let d;e[4]!==o||e[5]!==h||e[6]!==l||e[7]!==a||e[8]!==s||e[9]!==i?(d=n.jsx(P.Suspense,{fallback:c,children:n.jsx(rb,{activeTab:o,virtualMcpId:i,taskId:s,layoutTabs:a,expandedTools:l,automationTabParsed:h})}),e[4]=o,e[5]=h,e[6]=l,e[7]=a,e[8]=s,e[9]=i,e[10]=d):d=e[10];let u;return e[11]!==o||e[12]!==d?(u=n.jsx(Ht,{children:d},o),e[11]=o,e[12]=d,e[13]=u):u=e[13],u}const xs="setup";function ob(t){const e=W.c(35);let s;if(e[0]!==t.scriptTabs||e[1]!==t.scripts){let m;e[3]!==t.scriptTabs?(m=p=>!t.scriptTabs.includes(p),e[3]=t.scriptTabs,e[4]=m):m=e[4],s=t.scripts.filter(m),e[0]=t.scriptTabs,e[1]=t.scripts,e[2]=s}else s=e[2];const i=s;let r;e[5]!==t?(r=()=>{t.active===xs?t.onToggle():t.onSelectTab(xs)},e[5]=t,e[6]=r):r=e[6];const o=r,a=t.active===xs;let l;e[7]!==o||e[8]!==t.open||e[9]!==a?(l=n.jsx(ab,{active:a,open:t.open,onClick:o}),e[7]=o,e[8]=t.open,e[9]=a,e[10]=l):l=e[10];let h;e[11]!==t?(h=t.scriptTabs.map(m=>n.jsx(cb,{active:t.active===m,onClick:()=>t.onSelectTab(m),onClose:()=>t.onCloseScript(m),children:m},m)),e[11]=t,e[12]=h):h=e[12];let c;e[13]!==i||e[14]!==t.onAddScript?(c=n.jsx(hb,{scripts:i,onRun:t.onAddScript}),e[13]=i,e[14]=t.onAddScript,e[15]=c):c=e[15];let d;e[16]!==l||e[17]!==h||e[18]!==c?(d=n.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-1 overflow-x-auto",children:[l,h,c]}),e[16]=l,e[17]=h,e[18]=c,e[19]=d):d=e[19];let u;e[20]!==t.onRestart||e[21]!==t.onResume||e[22]!==t.onRetry||e[23]!==t.onRunActiveScript||e[24]!==t.onStart||e[25]!==t.onStop||e[26]!==t.onStopActiveScript||e[27]!==t.scriptIsKilling||e[28]!==t.scriptIsRunning||e[29]!==t.showScriptControls||e[30]!==t.status?(u=t.showScriptControls?n.jsx(db,{isRunning:t.scriptIsRunning,isKilling:t.scriptIsKilling,onRun:t.onRunActiveScript,onStop:t.onStopActiveScript}):n.jsx(lb,{status:t.status,onStart:t.onStart,onStop:t.onStop,onRestart:t.onRestart,onResume:t.onResume,onRetry:t.onRetry}),e[20]=t.onRestart,e[21]=t.onResume,e[22]=t.onRetry,e[23]=t.onRunActiveScript,e[24]=t.onStart,e[25]=t.onStop,e[26]=t.onStopActiveScript,e[27]=t.scriptIsKilling,e[28]=t.scriptIsRunning,e[29]=t.showScriptControls,e[30]=t.status,e[31]=u):u=e[31];let f;return e[32]!==d||e[33]!==u?(f=n.jsxs("div",{className:"flex h-10 shrink-0 items-center gap-1 border-t border-b border-border bg-muted/60 px-3",children:[d,u]}),e[32]=d,e[33]=u,e[34]=f):f=e[34],f}function ab(t){const e=W.c(8),{active:s,open:i,onClick:r}=t,o=s&&i,a=s&&i,l=s?"border-border bg-background font-medium text-foreground shadow-sm":"border-transparent text-muted-foreground hover:bg-background/50 hover:text-foreground";let h;e[0]!==l?(h=oe("flex h-7 items-center gap-1.5 rounded-md border px-2.5 text-xs",l),e[0]=l,e[1]=h):h=e[1];let c;e[2]===Symbol.for("react.memo_cache_sentinel")?(c=n.jsx(Nf,{className:"size-3.5"}),e[2]=c):c=e[2];let d;return e[3]!==r||e[4]!==o||e[5]!==a||e[6]!==h?(d=n.jsxs("button",{type:"button","aria-pressed":o,"aria-expanded":a,onClick:r,className:h,children:[c,"sandbox"]}),e[3]=r,e[4]=o,e[5]=a,e[6]=h,e[7]=d):d=e[7],d}function lb(t){const e=W.c(24),{status:s,onStart:i,onStop:r,onRestart:o,onResume:a,onRetry:l}=t;if(s==="idle"&&i){let h;e[0]===Symbol.for("react.memo_cache_sentinel")?(h=n.jsx(Hs,{className:"size-3.5"}),e[0]=h):h=e[0];let c;return e[1]!==i?(c=n.jsxs(ie,{variant:"outline",size:"sm",onClick:i,children:[h," Start"]}),e[1]=i,e[2]=c):c=e[2],c}if(s==="suspended"&&a){let h;e[3]===Symbol.for("react.memo_cache_sentinel")?(h=n.jsx(Hs,{className:"size-3.5"}),e[3]=h):h=e[3];let c;return e[4]!==a?(c=n.jsxs(ie,{variant:"outline",size:"sm",onClick:a,children:[h," Resume"]}),e[4]=a,e[5]=c):c=e[5],c}if(s==="errored"&&l){let h;e[6]===Symbol.for("react.memo_cache_sentinel")?(h=n.jsx(Ai,{className:"size-3.5"}),e[6]=h):h=e[6];let c;return e[7]!==l?(c=n.jsxs(ie,{variant:"outline",size:"sm",onClick:l,children:[h," Retry"]}),e[7]=l,e[8]=c):c=e[8],c}if(s==="starting"||s==="running"){const h=s==="running"&&!!o,c=h?"rounded-r-none border-r-0":void 0;let d;e[9]!==c?(d=oe(c),e[9]=c,e[10]=d):d=e[10];let u;e[11]===Symbol.for("react.memo_cache_sentinel")?(u=n.jsx(Mc,{className:"size-3.5"}),e[11]=u):u=e[11];let f;e[12]!==r||e[13]!==d?(f=n.jsx(ke,{asChild:!0,children:n.jsxs(ie,{variant:"outline",size:"sm",onClick:r,className:d,children:[u," Stop"]})}),e[12]=r,e[13]=d,e[14]=f):f=e[14];let m;e[15]===Symbol.for("react.memo_cache_sentinel")?(m=n.jsx(je,{children:"Stop sandbox"}),e[15]=m):m=e[15];let p;e[16]!==f?(p=n.jsxs(Ne,{children:[f,m]}),e[16]=f,e[17]=p):p=e[17];let _;e[18]!==o||e[19]!==h?(_=h&&n.jsxs(Zs,{children:[n.jsx(Qs,{asChild:!0,children:n.jsx(ie,{variant:"outline",size:"sm",className:"rounded-l-none px-1",children:n.jsx(ks,{className:"size-3"})})}),n.jsx(ei,{align:"end",children:n.jsxs(et,{onClick:o,children:[n.jsx(Ai,{className:"size-3.5"})," Restart"]})})]}),e[18]=o,e[19]=h,e[20]=_):_=e[20];let g;return e[21]!==p||e[22]!==_?(g=n.jsxs("div",{className:"flex items-center",children:[p,_]}),e[21]=p,e[22]=_,e[23]=g):g=e[23],g}return null}function cb(t){const e=W.c(16),{active:s,onClick:i,onClose:r,children:o}=t,a=s?"border-border bg-background shadow-sm":"border-transparent hover:bg-background/50";let l;e[0]!==a?(l=oe("flex h-7 items-center rounded-md border text-xs",a),e[0]=a,e[1]=l):l=e[1];const h=r?"pl-2.5 pr-1":"px-2.5",c=s?"font-medium text-foreground":"text-muted-foreground hover:text-foreground";let d;e[2]!==h||e[3]!==c?(d=oe("flex h-full items-center",h,c),e[2]=h,e[3]=c,e[4]=d):d=e[4];let u;e[5]!==o||e[6]!==i||e[7]!==d?(u=n.jsx("button",{type:"button",onClick:i,className:d,children:o}),e[5]=o,e[6]=i,e[7]=d,e[8]=u):u=e[8];let f;e[9]!==o||e[10]!==r?(f=r&&n.jsx("button",{type:"button","aria-label":`Close ${o}`,onClick:r,className:"pr-1.5 text-muted-foreground hover:text-foreground",children:n.jsx(Hm,{className:"size-3"})}),e[9]=o,e[10]=r,e[11]=f):f=e[11];let m;return e[12]!==l||e[13]!==u||e[14]!==f?(m=n.jsxs("div",{className:l,children:[u,f]}),e[12]=l,e[13]=u,e[14]=f,e[15]=m):m=e[15],m}function hb(t){const e=W.c(10),{scripts:s,onRun:i}=t,[r,o]=P.useState(!1);let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=n.jsxs(Ne,{children:[n.jsx(ke,{asChild:!0,children:n.jsx(Ns,{asChild:!0,children:n.jsx(ie,{variant:"ghost",size:"sm","aria-label":"Run script",children:n.jsx(At,{className:"size-3.5"})})})}),n.jsx(je,{children:"Run script"})]}),e[0]=a):a=e[0];let l;e[1]===Symbol.for("react.memo_cache_sentinel")?(l=n.jsx("div",{className:"px-2 py-1 text-[10px] uppercase tracking-wide text-muted-foreground",children:"run a script"}),e[1]=l):l=e[1];let h;e[2]!==i||e[3]!==s?(h=s.length===0?n.jsx("div",{className:"px-2 py-2 text-xs text-muted-foreground",children:"No scripts found"}):s.map(u=>n.jsxs("button",{type:"button",onClick:()=>{o(!1),i(u)},className:"w-full rounded-md px-2 py-1.5 text-left text-xs hover:bg-accent",children:["▸ ",u]},u)),e[2]=i,e[3]=s,e[4]=h):h=e[4];let c;e[5]!==h?(c=n.jsxs(Es,{align:"start",className:"p-1 w-56",children:[l,h]}),e[5]=h,e[6]=c):c=e[6];let d;return e[7]!==r||e[8]!==c?(d=n.jsxs(js,{open:r,onOpenChange:o,children:[a,c]}),e[7]=r,e[8]=c,e[9]=d):d=e[9],d}function db(t){const e=W.c(13),{isRunning:s,isKilling:i,onRun:r,onStop:o}=t;if(i){let d;return e[0]===Symbol.for("react.memo_cache_sentinel")?(d=n.jsxs(ie,{variant:"outline",size:"sm",disabled:!0,children:[n.jsx(we,{className:"size-3.5 animate-spin"})," Stopping…"]}),e[0]=d):d=e[0],d}if(!s){let d;e[1]===Symbol.for("react.memo_cache_sentinel")?(d=n.jsx(Hs,{className:"size-3.5"}),e[1]=d):d=e[1];let u;e[2]!==r?(u=n.jsx(ke,{asChild:!0,children:n.jsxs(ie,{variant:"outline",size:"sm",onClick:r,children:[d," Run"]})}),e[2]=r,e[3]=u):u=e[3];let f;e[4]===Symbol.for("react.memo_cache_sentinel")?(f=n.jsx(je,{children:"Start process"}),e[4]=f):f=e[4];let m;return e[5]!==u?(m=n.jsxs(Ne,{children:[u,f]}),e[5]=u,e[6]=m):m=e[6],m}let a;e[7]===Symbol.for("react.memo_cache_sentinel")?(a=n.jsx(Mc,{className:"size-3.5"}),e[7]=a):a=e[7];let l;e[8]!==o?(l=n.jsx(ke,{asChild:!0,children:n.jsxs(ie,{variant:"outline",size:"sm",onClick:o,children:[a," Stop"]})}),e[8]=o,e[9]=l):l=e[9];let h;e[10]===Symbol.for("react.memo_cache_sentinel")?(h=n.jsx(je,{children:"Stop process"}),e[10]=h):h=e[10];let c;return e[11]!==l?(c=n.jsxs(Ne,{children:[l,h]}),e[11]=l,e[12]=c):c=e[12],c}var cd=Object.defineProperty,ub=Object.getOwnPropertyDescriptor,fb=(t,e)=>{for(var s in e)cd(t,s,{get:e[s],enumerable:!0})},$e=(t,e,s,i)=>{for(var r=i>1?void 0:i?ub(e,s):e,o=t.length-1,a;o>=0;o--)(a=t[o])&&(r=(i?a(e,s,r):a(r))||r);return i&&r&&cd(e,s,r),r},ce=(t,e)=>(s,i)=>e(s,i,t),bl="Terminal input",Kn={get:()=>bl,set:t=>bl=t},yl="Too much output to announce, navigate to rows manually to read",Vn={get:()=>yl,set:t=>yl=t};function mb(t){return t.replace(/\r?\n/g,"\r")}function pb(t,e){return e?"\x1B[200~"+t+"\x1B[201~":t}function _b(t,e){t.clipboardData&&t.clipboardData.setData("text/plain",e.selectionText),t.preventDefault()}function gb(t,e,s,i){if(t.stopPropagation(),t.clipboardData){let r=t.clipboardData.getData("text/plain");hd(r,e,s,i)}}function hd(t,e,s,i){t=mb(t),t=pb(t,s.decPrivateModes.bracketedPasteMode&&i.rawOptions.ignoreBracketedPasteMode!==!0),s.triggerDataEvent(t,!0),e.value=""}function dd(t,e,s){let i=s.getBoundingClientRect(),r=t.clientX-i.left-10,o=t.clientY-i.top-10;e.style.width="20px",e.style.height="20px",e.style.left=`${r}px`,e.style.top=`${o}px`,e.style.zIndex="1000",e.focus()}function Sl(t,e,s,i,r){dd(t,e,s),r&&i.rightClickSelect(t),e.value=i.selectionText,e.select()}function hs(t){return t>65535?(t-=65536,String.fromCharCode((t>>10)+55296)+String.fromCharCode(t%1024+56320)):String.fromCharCode(t)}function rn(t,e=0,s=t.length){let i="";for(let r=e;r<s;++r){let o=t[r];o>65535?(o-=65536,i+=String.fromCharCode((o>>10)+55296)+String.fromCharCode(o%1024+56320)):i+=String.fromCharCode(o)}return i}var vb=class{constructor(){this._interim=0}clear(){this._interim=0}decode(t,e){let s=t.length;if(!s)return 0;let i=0,r=0;if(this._interim){let o=t.charCodeAt(r++);56320<=o&&o<=57343?e[i++]=(this._interim-55296)*1024+o-56320+65536:(e[i++]=this._interim,e[i++]=o),this._interim=0}for(let o=r;o<s;++o){let a=t.charCodeAt(o);if(55296<=a&&a<=56319){if(++o>=s)return this._interim=a,i;let l=t.charCodeAt(o);56320<=l&&l<=57343?e[i++]=(a-55296)*1024+l-56320+65536:(e[i++]=a,e[i++]=l);continue}a!==65279&&(e[i++]=a)}return i}},xb=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(t,e){let s=t.length;if(!s)return 0;let i=0,r,o,a,l,h=0,c=0;if(this.interim[0]){let f=!1,m=this.interim[0];m&=(m&224)===192?31:(m&240)===224?15:7;let p=0,_;for(;(_=this.interim[++p]&63)&&p<4;)m<<=6,m|=_;let g=(this.interim[0]&224)===192?2:(this.interim[0]&240)===224?3:4,v=g-p;for(;c<v;){if(c>=s)return 0;if(_=t[c++],(_&192)!==128){c--,f=!0;break}else this.interim[p++]=_,m<<=6,m|=_&63}f||(g===2?m<128?c--:e[i++]=m:g===3?m<2048||m>=55296&&m<=57343||m===65279||(e[i++]=m):m<65536||m>1114111||(e[i++]=m)),this.interim.fill(0)}let d=s-4,u=c;for(;u<s;){for(;u<d&&!((r=t[u])&128)&&!((o=t[u+1])&128)&&!((a=t[u+2])&128)&&!((l=t[u+3])&128);)e[i++]=r,e[i++]=o,e[i++]=a,e[i++]=l,u+=4;if(r=t[u++],r<128)e[i++]=r;else if((r&224)===192){if(u>=s)return this.interim[0]=r,i;if(o=t[u++],(o&192)!==128){u--;continue}if(h=(r&31)<<6|o&63,h<128){u--;continue}e[i++]=h}else if((r&240)===224){if(u>=s)return this.interim[0]=r,i;if(o=t[u++],(o&192)!==128){u--;continue}if(u>=s)return this.interim[0]=r,this.interim[1]=o,i;if(a=t[u++],(a&192)!==128){u--;continue}if(h=(r&15)<<12|(o&63)<<6|a&63,h<2048||h>=55296&&h<=57343||h===65279)continue;e[i++]=h}else if((r&248)===240){if(u>=s)return this.interim[0]=r,i;if(o=t[u++],(o&192)!==128){u--;continue}if(u>=s)return this.interim[0]=r,this.interim[1]=o,i;if(a=t[u++],(a&192)!==128){u--;continue}if(u>=s)return this.interim[0]=r,this.interim[1]=o,this.interim[2]=a,i;if(l=t[u++],(l&192)!==128){u--;continue}if(h=(r&7)<<18|(o&63)<<12|(a&63)<<6|l&63,h<65536||h>1114111)continue;e[i++]=h}}return i}},ud="",ds=" ",qi=class fd{constructor(){this.fg=0,this.bg=0,this.extended=new Or}static toColorRGB(e){return[e>>>16&255,e>>>8&255,e&255]}static fromColorRGB(e){return(e[0]&255)<<16|(e[1]&255)<<8|e[2]&255}clone(){let e=new fd;return e.fg=this.fg,e.bg=this.bg,e.extended=this.extended.clone(),e}isInverse(){return this.fg&67108864}isBold(){return this.fg&134217728}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:this.fg&268435456}isBlink(){return this.fg&536870912}isInvisible(){return this.fg&1073741824}isItalic(){return this.bg&67108864}isDim(){return this.bg&134217728}isStrikethrough(){return this.fg&2147483648}isProtected(){return this.bg&536870912}isOverline(){return this.bg&1073741824}getFgColorMode(){return this.fg&50331648}getBgColorMode(){return this.bg&50331648}isFgRGB(){return(this.fg&50331648)===50331648}isBgRGB(){return(this.bg&50331648)===50331648}isFgPalette(){return(this.fg&50331648)===16777216||(this.fg&50331648)===33554432}isBgPalette(){return(this.bg&50331648)===16777216||(this.bg&50331648)===33554432}isFgDefault(){return(this.fg&50331648)===0}isBgDefault(){return(this.bg&50331648)===0}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(this.fg&50331648){case 16777216:case 33554432:return this.fg&255;case 50331648:return this.fg&16777215;default:return-1}}getBgColor(){switch(this.bg&50331648){case 16777216:case 33554432:return this.bg&255;case 50331648:return this.bg&16777215;default:return-1}}hasExtendedAttrs(){return this.bg&268435456}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(this.bg&268435456&&~this.extended.underlineColor)switch(this.extended.underlineColor&50331648){case 16777216:case 33554432:return this.extended.underlineColor&255;case 50331648:return this.extended.underlineColor&16777215;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return this.bg&268435456&&~this.extended.underlineColor?this.extended.underlineColor&50331648:this.getFgColorMode()}isUnderlineColorRGB(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===50331648:this.isFgRGB()}isUnderlineColorPalette(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===16777216||(this.extended.underlineColor&50331648)===33554432:this.isFgPalette()}isUnderlineColorDefault(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===0:this.isFgDefault()}getUnderlineStyle(){return this.fg&268435456?this.bg&268435456?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},Or=class md{constructor(e=0,s=0){this._ext=0,this._urlId=0,this._ext=e,this._urlId=s}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(e){this._ext=e}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(e){this._ext&=-469762049,this._ext|=e<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(e){this._ext&=-67108864,this._ext|=e&67108863}get urlId(){return this._urlId}set urlId(e){this._urlId=e}get underlineVariantOffset(){let e=(this._ext&3758096384)>>29;return e<0?e^4294967288:e}set underlineVariantOffset(e){this._ext&=536870911,this._ext|=e<<29&3758096384}clone(){return new md(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},kt=class pd extends qi{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new Or,this.combinedData=""}static fromCharData(e){let s=new pd;return s.setFromCharData(e),s}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?hs(this.content&2097151):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(e){this.fg=e[0],this.bg=0;let s=!1;if(e[1].length>2)s=!0;else if(e[1].length===2){let i=e[1].charCodeAt(0);if(55296<=i&&i<=56319){let r=e[1].charCodeAt(1);56320<=r&&r<=57343?this.content=(i-55296)*1024+r-56320+65536|e[2]<<22:s=!0}else s=!0}else this.content=e[1].charCodeAt(0)|e[2]<<22;s&&(this.combinedData=e[1],this.content=2097152|e[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},wl="di$target",qn="di$dependencies",bn=new Map;function bb(t){return t[qn]||[]}function st(t){if(bn.has(t))return bn.get(t);let e=function(s,i,r){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");yb(e,s,r)};return e._id=t,bn.set(t,e),e}function yb(t,e,s){e[wl]===e?e[qn].push({id:t,index:s}):(e[qn]=[{id:t,index:s}],e[wl]=e)}var dt=st("BufferService"),_d=st("CoreMouseService"),Ds=st("CoreService"),Sb=st("CharsetService"),xa=st("InstantiationService"),gd=st("LogService"),ut=st("OptionsService"),vd=st("OscLinkService"),wb=st("UnicodeService"),Gi=st("DecorationService"),Gn=class{constructor(t,e,s){this._bufferService=t,this._optionsService=e,this._oscLinkService=s}provideLinks(t,e){let s=this._bufferService.buffer.lines.get(t-1);if(!s){e(void 0);return}let i=[],r=this._optionsService.rawOptions.linkHandler,o=new kt,a=s.getTrimmedLength(),l=-1,h=-1,c=!1;for(let d=0;d<a;d++)if(!(h===-1&&!s.hasContent(d))){if(s.loadCell(d,o),o.hasExtendedAttrs()&&o.extended.urlId)if(h===-1){h=d,l=o.extended.urlId;continue}else c=o.extended.urlId!==l;else h!==-1&&(c=!0);if(c||h!==-1&&d===a-1){let u=this._oscLinkService.getLinkData(l)?.uri;if(u){let f={start:{x:h+1,y:t},end:{x:d+(!c&&d===a-1?1:0),y:t}},m=!1;if(!r?.allowNonHttpProtocols)try{let p=new URL(u);["http:","https:"].includes(p.protocol)||(m=!0)}catch{m=!0}m||i.push({text:u,range:f,activate:(p,_)=>r?r.activate(p,_,f):Cb(p,_),hover:(p,_)=>r?.hover?.(p,_,f),leave:(p,_)=>r?.leave?.(p,_,f)})}c=!1,o.hasExtendedAttrs()&&o.extended.urlId?(h=d,l=o.extended.urlId):(h=-1,l=-1)}}e(i)}};Gn=$e([ce(0,dt),ce(1,ut),ce(2,vd)],Gn);function Cb(t,e){if(confirm(`Do you want to navigate to ${e}?
296
296
 
297
297
  WARNING: This link could potentially be dangerous`)){let s=window.open();if(s){try{s.opener=null}catch{}s.location.href=e}else console.warn("Opening link blocked as opener could not be cleared")}}var nn=st("CharSizeService"),rs=st("CoreBrowserService"),ba=st("MouseService"),ns=st("RenderService"),kb=st("SelectionService"),xd=st("CharacterJoinerService"),oi=st("ThemeService"),bd=st("LinkProviderService"),jb=class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(t){setTimeout(()=>{throw t.stack?Cl.isErrorNoTelemetry(t)?new Cl(t.message+`
298
298