decocms 3.21.3 → 3.23.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 (232) hide show
  1. package/dist/client/assets/{AlertCircle-CPDzwcNm.js → AlertCircle-Cie6Yisc.js} +1 -1
  2. package/dist/client/assets/{ArrowUpRight-ShCMNuxq.js → ArrowUpRight-Bup5q9aR.js} +1 -1
  3. package/dist/client/assets/{Check-notD5fT5.js → Check-CWWWjir3.js} +1 -1
  4. package/dist/client/assets/{CheckCircle-8aHxGN9L.js → CheckCircle-Uw6Si4Uu.js} +1 -1
  5. package/dist/client/assets/{ChevronDown-DagjZ4eX.js → ChevronDown-DPCmMamP.js} +1 -1
  6. package/dist/client/assets/{ChevronLeft-BaqaOx9Y.js → ChevronLeft-BFKiUL-g.js} +1 -1
  7. package/dist/client/assets/{ChevronRight-DVtjidio.js → ChevronRight-BPW30xu2.js} +1 -1
  8. package/dist/client/assets/{ChevronUp-BMDnNzvq.js → ChevronUp-Bj0jQsTk.js} +1 -1
  9. package/dist/client/assets/{Container-D6z1XWRo.js → Container-CPU0lOb2.js} +1 -1
  10. package/dist/client/assets/{DotsVertical-BJhFy0Ao.js → DotsVertical-BnsTBCnN.js} +1 -1
  11. package/dist/client/assets/{Eye-BB6Aus5x.js → Eye-Dj0PXl1o.js} +1 -1
  12. package/dist/client/assets/{FilterLines-DMByO-IA.js → FilterLines-D8oi1Sof.js} +1 -1
  13. package/dist/client/assets/{Globe01-CIsVQmOA.js → Globe01-D6rc4c2I.js} +1 -1
  14. package/dist/client/assets/{HardDrive-DuCt5CIe.js → HardDrive-BsP_WnUS.js} +1 -1
  15. package/dist/client/assets/{Key01-CngsxG29.js → Key01-ZzkGvXus.js} +1 -1
  16. package/dist/client/assets/{LayoutLeft-DgM7tZde.js → LayoutLeft-BrLgpS4_.js} +1 -1
  17. package/dist/client/assets/{LinkExternal01-CQF0MYqY.js → LinkExternal01-CYjY9tw_.js} +1 -1
  18. package/dist/client/assets/{Monitor01-CT1u4DKh.js → Monitor01-Co7esQF_.js} +1 -1
  19. package/dist/client/assets/{Palette-GNFXWUwf.js → Palette-C633yKaN.js} +1 -1
  20. package/dist/client/assets/{Play-QmNwPHc_.js → Play-DOVnYSwF.js} +1 -1
  21. package/dist/client/assets/{Plus-Dppw3z2O.js → Plus-G5Gw5kPM.js} +1 -1
  22. package/dist/client/assets/{RefreshCcw01-BEoOvUD1.js → RefreshCcw01-C5jOy04q.js} +1 -1
  23. package/dist/client/assets/{SearchMd-FY1Qclyu.js → SearchMd-DM0EjhEJ.js} +1 -1
  24. package/dist/client/assets/{Settings02-ocCz49Kz.js → Settings02-CtCQn3Yf.js} +1 -1
  25. package/dist/client/assets/{Shield01-BzHglsiw.js → Shield01-DlzHY_dC.js} +1 -1
  26. package/dist/client/assets/{Star01-BlvJ3i4w.js → Star01-39vpRLS0.js} +1 -1
  27. package/dist/client/assets/{Stars01-DukS22FM.js → Stars01-D40cNl8a.js} +1 -1
  28. package/dist/client/assets/{Stars02-De2-tT4k.js → Stars02-LHx1LC9_.js} +1 -1
  29. package/dist/client/assets/{Sun-BcFWhCSK.js → Sun-D5VbC5bQ.js} +1 -1
  30. package/dist/client/assets/{SwitchHorizontal01-D-Tt77nJ.js → SwitchHorizontal01-Sw4pGPNn.js} +1 -1
  31. package/dist/client/assets/{Tool01-BJXGaU-M.js → Tool01-WQP4RZxz.js} +1 -1
  32. package/dist/client/assets/{Trash01-CZnJ0avm.js → Trash01-cARQt3ei.js} +1 -1
  33. package/dist/client/assets/{Upload01-76tsCZMd.js → Upload01-Dmm1X5SO.js} +1 -1
  34. package/dist/client/assets/{User01-CWOXdoG4.js → User01-CqHZqKxf.js} +1 -1
  35. package/dist/client/assets/{Users01-WG_iZnJh.js → Users01-Dsn_tDG5.js} +1 -1
  36. package/dist/client/assets/{Users03-AoZrK_H4.js → Users03-hkJxAqIG.js} +1 -1
  37. package/dist/client/assets/{X-B0rYwlAH.js → X-D7vVBDXl.js} +1 -1
  38. package/dist/client/assets/{XCircle-7rwkbF3y.js → XCircle-CGKRZUbS.js} +1 -1
  39. package/dist/client/assets/{XClose-DFcy3zV5.js → XClose-MKIx3xLp.js} +1 -1
  40. package/dist/client/assets/{Zap-DkP77k_W.js → Zap-jV52NH8a.js} +1 -1
  41. package/dist/client/assets/{ZapSquare-1g_0m2Au.js → ZapSquare-DVdUXxhF.js} +1 -1
  42. package/dist/client/assets/{ZoomOut-B72QEIIU.js → ZoomOut-0Ur-V1Tn.js} +1 -1
  43. package/dist/client/assets/{access-gate-CzWH8hLh.js → access-gate-roIhjIJn.js} +1 -1
  44. package/dist/client/assets/{accordion-DmyLwYep.js → accordion-C0j3DHtl.js} +1 -1
  45. package/dist/client/assets/{add-section-modal-BwyDPP_M.js → add-section-modal-CRKAmuUu.js} +1 -1
  46. package/dist/client/assets/{agent-capabilities-xX47CwbD.js → agent-capabilities-BWvW99VB.js} +1 -1
  47. package/dist/client/assets/{agent-icon-CMmthzuk.js → agent-icon-B_ENO9HH.js} +1 -1
  48. package/dist/client/assets/{agent-icons-kCVtwvlc.js → agent-icons-CpkNElG-.js} +1 -1
  49. package/dist/client/assets/{agents-list-DAgV94Pu.js → agents-list-CQWA2zjQ.js} +1 -1
  50. package/dist/client/assets/{ai-providers-OepmZUy0.js → ai-providers-BH3PHgWL.js} +1 -1
  51. package/dist/client/assets/{alert-dialog-BqYd6k15.js → alert-dialog-BGwOQ-hv.js} +1 -1
  52. package/dist/client/assets/{alert-kB1ztaR5.js → alert-kjgZx1ez.js} +1 -1
  53. package/dist/client/assets/app-editor-n5gUpE-7.js +1 -0
  54. package/dist/client/assets/{auth-catchall-CA2oimt4.js → auth-catchall-DA8u5lih.js} +1 -1
  55. package/dist/client/assets/{auth-split-layout-g9cK_SyP.js → auth-split-layout-to9tM4yy.js} +1 -1
  56. package/dist/client/assets/{automation-list-row-Bfqyr7I3.js → automation-list-row-BNAgjK8x.js} +1 -1
  57. package/dist/client/assets/{automation-runs-NbYM1cjn.js → automation-runs-C92-yFsO.js} +1 -1
  58. package/dist/client/assets/{automations-C7jEtNny.js → automations-DYeroRPO.js} +1 -1
  59. package/dist/client/assets/{avatar-GhNVlFfA.js → avatar-B3Bw52dv.js} +1 -1
  60. package/dist/client/assets/{badge-Dwfe01sI.js → badge-5MzROStc.js} +1 -1
  61. package/dist/client/assets/{brand-context-5t0UmL9A.js → brand-context-qldfN3Pe.js} +1 -1
  62. package/dist/client/assets/{buckets-BbeD50DH.js → buckets-BVaOFRcL.js} +1 -1
  63. package/dist/client/assets/{calendar-DUj5Hjlg.js → calendar-DOA8Nces.js} +1 -1
  64. package/dist/client/assets/{capability-load-error-DU6WRPuJ.js → capability-load-error-DPd39UC9.js} +1 -1
  65. package/dist/client/assets/{card-lBnnILto.js → card-B4WowcKq.js} +1 -1
  66. package/dist/client/assets/{chat-context-sLONPn-0.js → chat-context-BqvG5V6J.js} +1 -1
  67. package/dist/client/assets/{checkbox-B0Z95T9p.js → checkbox-DHuCa6fF.js} +1 -1
  68. package/dist/client/assets/{cli-auth-success-EC1gaXEN.js → cli-auth-success-DnDM0bD5.js} +1 -1
  69. package/dist/client/assets/{collection-detail-COeu5gwR.js → collection-detail-DczB6N_Y.js} +1 -1
  70. package/dist/client/assets/{collection-display-button-D_AdA-xg.js → collection-display-button-xjCpr5m2.js} +1 -1
  71. package/dist/client/assets/{collection-search-DEQMWm_z.js → collection-search-C3AEVd7W.js} +1 -1
  72. package/dist/client/assets/{collection-table-wrapper-L2lki_mC.js → collection-table-wrapper-fHqcoUDz.js} +1 -1
  73. package/dist/client/assets/{collection-tabs-BLluwkr_.js → collection-tabs-azv2LaTo.js} +1 -1
  74. package/dist/client/assets/{collections-t21R7Da7.js → collections-B9PQucdo.js} +1 -1
  75. package/dist/client/assets/{command-De_vHwL2.js → command-BSLuC415.js} +1 -1
  76. package/dist/client/assets/{connect-desktop-dialog-DT9M25jO.js → connect-desktop-dialog-DNq0ek1i.js} +1 -1
  77. package/dist/client/assets/{connection-card-HxhqgvOF.js → connection-card-DJ5vpD6m.js} +1 -1
  78. package/dist/client/assets/{connection-detail-C9F-N40Y.js → connection-detail-C1eDlvQw.js} +1 -1
  79. package/dist/client/assets/{connection-form-helpers-BMXuAyPa.js → connection-form-helpers-Ck21v4Z3.js} +1 -1
  80. package/dist/client/assets/{connections-R13TTVYD.js → connections-CNeRQvwK.js} +1 -1
  81. package/dist/client/assets/{decopilot-sse-pool-D3C-kBei.js → decopilot-sse-pool-koFlJuH3.js} +1 -1
  82. package/dist/client/assets/{dialog-B3n4osS2.js → dialog-qWglm5p2.js} +1 -1
  83. package/dist/client/assets/{domain-settings-D2tBGsHy.js → domain-settings-_1OAKDWb.js} +1 -1
  84. package/dist/client/assets/{drawer-DVtZCj6U.js → drawer-C6RzB17v.js} +1 -1
  85. package/dist/client/assets/{dropdown-menu-C0lExS63.js → dropdown-menu-Vxh4zyXD.js} +1 -1
  86. package/dist/client/assets/{dynamic-plugin-layout-Bd7E6PZe.js → dynamic-plugin-layout-tPcjYD_K.js} +1 -1
  87. package/dist/client/assets/{empty-state-q0Pbk8UD.js → empty-state-BKbPqk3T.js} +1 -1
  88. package/dist/client/assets/{empty-state-Cigz9ucf.js → empty-state-vFbdMLGr.js} +1 -1
  89. package/dist/client/assets/{extract-connection-data-PFgGg6kx.js → extract-connection-data-yJgJfD7f.js} +1 -1
  90. package/dist/client/assets/{features-B_D2RqKH.js → features-Bhw07HYI.js} +1 -1
  91. package/dist/client/assets/{file-explorer-DwYs1O3Y.js → file-explorer-BJqHY4-p.js} +1 -1
  92. package/dist/client/assets/{file-type-icon-CE1JVL_T.js → file-type-icon-BilQa1o9.js} +36 -36
  93. package/dist/client/assets/{files-CMa9vZqb.js → files-DSh9h1Hm.js} +1 -1
  94. package/dist/client/assets/{form-BDTBUfjP.js → form-gGZaN2er.js} +1 -1
  95. package/dist/client/assets/{general-DuuKH-Lu.js → general-BxrPlmF2.js} +1 -1
  96. package/dist/client/assets/{generate-id-B00Lqcz6.js → generate-id-1zLHnSNC.js} +1 -1
  97. package/dist/client/assets/{github-repo-picker-CiY30Vug.js → github-repo-picker-CtaqsXDt.js} +1 -1
  98. package/dist/client/assets/{header-tab-button-P7xz_OdB.js → header-tab-button-2KdmhnCN.js} +1 -1
  99. package/dist/client/assets/{hover-card-BuyKR5LS.js → hover-card-BmPYfkmQ.js} +1 -1
  100. package/dist/client/assets/{image-field-BKg_4VXm.js → image-field-BAOOv2VL.js} +1 -1
  101. package/dist/client/assets/{index-CXAAlsD9.js → index-27pfCAzj.js} +1 -1
  102. package/dist/client/assets/{index-D8AZU2vU.js → index-3lvkMmcU.js} +4 -4
  103. package/dist/client/assets/{index-Cbyz112R.js → index-B8DD41FV.js} +1 -1
  104. package/dist/client/assets/{index-BZQmTAzr.js → index-BZfWDol4.js} +1 -1
  105. package/dist/client/assets/{index-wz9jNcYo.js → index-BsdusiDa.js} +1 -1
  106. package/dist/client/assets/{index-CZFRR26-.js → index-C-Ei6mai.js} +1 -1
  107. package/dist/client/assets/{index-Bo8GgkCy.js → index-CCLk37y2.js} +1 -1
  108. package/dist/client/assets/{index-C4D2JWLP.css → index-CQuY_IDP.css} +1 -1
  109. package/dist/client/assets/{index-CP5nxTWj.js → index-CXpnZeu8.js} +1 -1
  110. package/dist/client/assets/{index-DKa2bYTS.js → index-ChYUSQjJ.js} +3 -3
  111. package/dist/client/assets/{index-CKYhesP2.js → index-DFvrEDgo.js} +1 -1
  112. package/dist/client/assets/{index-DI-ETavs.js → index-Dk3pxVwF.js} +1 -1
  113. package/dist/client/assets/{index-DfIw3rZP.js → index-DpDZUDEm.js} +1 -1
  114. package/dist/client/assets/{index-CSU1Z8Qf.js → index-FaQ0ocaw.js} +1 -1
  115. package/dist/client/assets/{index-BwI2_EhO.js → index-qXKJFTio.js} +1 -1
  116. package/dist/client/assets/{index-BGZfQmzG.js → index-qlEv8kim.js} +1 -1
  117. package/dist/client/assets/{index-redirect-BW-9U163.js → index-redirect-CXll09VO.js} +1 -1
  118. package/dist/client/assets/{infiniteQueryObserver-CAoHOrzQ.js → infiniteQueryObserver-CwLfraWt.js} +1 -1
  119. package/dist/client/assets/{input-BjUn5ElR.js → input-Cm-_5NLx.js} +1 -1
  120. package/dist/client/assets/{integration-icon-CxZb-fPL.js → integration-icon-CjuSu3xL.js} +1 -1
  121. package/dist/client/assets/{label-kHH3gI2u.js → label-CyHrJvd7.js} +1 -1
  122. package/dist/client/assets/{layout-B6WN2IOm.js → layout-kTyPnw7s.js} +1 -1
  123. package/dist/client/assets/{login-DkvZH0k5.js → login-5UgWIAg7.js} +1 -1
  124. package/dist/client/assets/{members-KnkycCao.js → members-hzfBOAY3.js} +1 -1
  125. package/dist/client/assets/{monaco-editor-DYGOFuTO.js → monaco-editor-DpalAqoH.js} +1 -1
  126. package/dist/client/assets/{monitoring-stats-row-CLmZT1As.js → monitoring-stats-row-elDMWfR-.js} +1 -1
  127. package/dist/client/assets/{oauth-callback-Cr_yeFgN.js → oauth-callback-DFmkESZu.js} +1 -1
  128. package/dist/client/assets/{oauth-callback-ai-provider-BrYkYKpa.js → oauth-callback-ai-provider-CkFUU1_z.js} +1 -1
  129. package/dist/client/assets/{onboarding-C2HWtNhq.js → onboarding-3PzLCg0J.js} +1 -1
  130. package/dist/client/assets/{org-install-Ds2eKuZ9.js → org-install-DnqbGePU.js} +1 -1
  131. package/dist/client/assets/{org-layout-CWlJCCTr.js → org-layout-C3XnS-Cd.js} +1 -1
  132. package/dist/client/assets/{org-plugin-layout-DXvLF6tF.js → org-plugin-layout-XMmCXebK.js} +1 -1
  133. package/dist/client/assets/{page-seo-form-gwUc3t6W.js → page-seo-form-Bd0DSnoH.js} +1 -1
  134. package/dist/client/assets/page-seo-sheet-BY0ZczJ9.js +1 -0
  135. package/dist/client/assets/{pair-0yfESYcy.js → pair-CrxtZLmo.js} +6 -6
  136. package/dist/client/assets/{plugin-empty-state-BKFo--oT.js → plugin-empty-state-DVk1q1TN.js} +1 -1
  137. package/dist/client/assets/{plugin-header-Lxzh4dkA.js → plugin-header-BrF2G38h.js} +1 -1
  138. package/dist/client/assets/{plugin-layout-u2AXSeK4.js → plugin-layout-CKTbFu5I.js} +1 -1
  139. package/dist/client/assets/{popover-B-ZF248I.js → popover-DmAofN68.js} +1 -1
  140. package/dist/client/assets/{post-editor-CZlHz9jV.js → post-editor-M-6yKdac.js} +1 -1
  141. package/dist/client/assets/{primitives-yLIBPquV.js → primitives-DypFIPbl.js} +1 -1
  142. package/dist/client/assets/{profile-Dr7PSo2c.js → profile-4Qps65XF.js} +1 -1
  143. package/dist/client/assets/{project-app-view-CjNYmwJu.js → project-app-view-B86ITaCE.js} +1 -1
  144. package/dist/client/assets/record-editor-DOYxf9X2.js +1 -0
  145. package/dist/client/assets/registry-DEATlg_a.js +2 -0
  146. package/dist/client/assets/{registry-layout-BfSrEMey.js → registry-layout-BbCvfAb2.js} +1 -1
  147. package/dist/client/assets/{require-capability-AhMmvh6N.js → require-capability-D5WFhc1C.js} +1 -1
  148. package/dist/client/assets/{required-auth-layout-1NjGJ1GA.js → required-auth-layout-MFF8-ZJT.js} +1 -1
  149. package/dist/client/assets/{reset-password-BJ3JyWvy.js → reset-password-Cej2r1ig.js} +1 -1
  150. package/dist/client/assets/{resizable-CDnnGLy_.js → resizable-Dvc6mjD2.js} +1 -1
  151. package/dist/client/assets/{roles-DSakMOYs.js → roles-C3KCV148.js} +1 -1
  152. package/dist/client/assets/save-referenced-block-DfCtlYLI.js +1 -0
  153. package/dist/client/assets/{save-status-Bhokzo-6.js → save-status-BNra3mAM.js} +1 -1
  154. package/dist/client/assets/{schema-form-BdhlzGvI.js → schema-form-B08gOdyg.js} +1 -1
  155. package/dist/client/assets/{scroll-area-C2jindzS.js → scroll-area-BdohAM0t.js} +1 -1
  156. package/dist/client/assets/{search-input-C7EV5zgy.js → search-input-BOsI1GRw.js} +1 -1
  157. package/dist/client/assets/{secrets-BeMofwrf.js → secrets-DX0AnBxx.js} +1 -1
  158. package/dist/client/assets/{sections-editor-D-D4fXgu.js → sections-editor-BRdCJB8j.js} +1 -1
  159. package/dist/client/assets/{select-PwFJPxWI.js → select-2pE_Mne6.js} +1 -1
  160. package/dist/client/assets/{select-model-Cj0XuQ9B.js → select-model-CrWeciHf.js} +1 -1
  161. package/dist/client/assets/{seo-editor-BTy_Py6L.js → seo-editor-DGLH1irm.js} +1 -1
  162. package/dist/client/assets/{settings-layout-JnI_wktk.js → settings-layout-DEjJewKl.js} +1 -1
  163. package/dist/client/assets/{settings-section-CcsLWjfi.js → settings-section-BZqGjpLm.js} +1 -1
  164. package/dist/client/assets/{sheet-Dlzq2DLm.js → sheet-BhIiqWhI.js} +1 -1
  165. package/dist/client/assets/{shell-controls-D69Fs-y1.js → shell-controls-Drtt8Eg1.js} +1 -1
  166. package/dist/client/assets/{shell-layout-U6oRxAp4.js → shell-layout-DIvP19WX.js} +1 -1
  167. package/dist/client/assets/{shell-route-loading-Bk2X9n-X.js → shell-route-loading-C61C46w4.js} +1 -1
  168. package/dist/client/assets/{sidebar-wL4mjwdl.js → sidebar-ujCPJCBV.js} +1 -1
  169. package/dist/client/assets/{skeleton-Bjc1-vnR.js → skeleton-DekfpK4t.js} +1 -1
  170. package/dist/client/assets/{sortable.esm-BaLGniPk.js → sortable.esm-Cra7DBkd.js} +1 -1
  171. package/dist/client/assets/{spinner-Cerb4AAl.js → spinner-ukxdHUOu.js} +1 -1
  172. package/dist/client/assets/{sso-B8r0KeHz.js → sso-BWArPYWD.js} +1 -1
  173. package/dist/client/assets/{store-DZoqqgcV.js → store-DSNAhE0j.js} +1 -1
  174. package/dist/client/assets/store-registry-BJU2S8Bb.js +2 -0
  175. package/dist/client/assets/{switch-AaQYpmii.js → switch-DgVVL7zp.js} +1 -1
  176. package/dist/client/assets/{tab-id-ClQkYZph.js → tab-id-C7RjxJTr.js} +1 -1
  177. package/dist/client/assets/{table-tXZdu4xg.js → table-C2KXmc6v.js} +1 -1
  178. package/dist/client/assets/{tabs-DgRLyNv0.js → tabs-2u_8k4RO.js} +1 -1
  179. package/dist/client/assets/{task-status-D2UHrjIr.js → task-status-CRWfjMb2.js} +1 -1
  180. package/dist/client/assets/{textarea-BVmeWwVH.js → textarea-C_bdHrQP.js} +1 -1
  181. package/dist/client/assets/{toggle-group-DsBG4yXK.js → toggle-group-C4fnmDnN.js} +1 -1
  182. package/dist/client/assets/{toolbar-DimPrw2d.js → toolbar-C8PVd7Ds.js} +1 -1
  183. package/dist/client/assets/{tools-list-CRWK46bj.js → tools-list-Cr63qS_c.js} +1 -1
  184. package/dist/client/assets/{tooltip-CRGezvtE.js → tooltip-ByLiX5Mq.js} +1 -1
  185. package/dist/client/assets/{types-DfZ9L9F4.js → types-Durgfewm.js} +1 -1
  186. package/dist/client/assets/{use-ai-providers-Bft4iAI7.js → use-ai-providers-DsKRr79k.js} +1 -1
  187. package/dist/client/assets/{use-automations-BgW6aFoA.js → use-automations-Dr8lwymn.js} +1 -1
  188. package/dist/client/assets/{use-capability-D76L9anx.js → use-capability-xJktXQ3I.js} +1 -1
  189. package/dist/client/assets/{use-collections-Ciodw5T-.js → use-collections-DXI321_l.js} +1 -1
  190. package/dist/client/assets/{use-connection-D5VghmN_.js → use-connection-DDWrr0D8.js} +1 -1
  191. package/dist/client/assets/{use-copy-C6l9b4AS.js → use-copy-B87517Y1.js} +1 -1
  192. package/dist/client/assets/{use-create-virtual-mcp-DQu9pTfE.js → use-create-virtual-mcp-CVaGBSXp.js} +1 -1
  193. package/dist/client/assets/{use-debounced-autosave-Ckz0uq-7.js → use-debounced-autosave-X1JA0Sjb.js} +1 -1
  194. package/dist/client/assets/{use-delete-connection-BuJlJzk2.js → use-delete-connection-BYg0Yl1J.js} +1 -1
  195. package/dist/client/assets/{use-file-configs-DWr7ryUj.js → use-file-configs-acebBZy-.js} +1 -1
  196. package/dist/client/assets/{use-infinite-scroll-ILdTUQK_.js → use-infinite-scroll-vpAXlalO.js} +1 -1
  197. package/dist/client/assets/{use-list-state-M2tYjik0.js → use-list-state-DMUJOpFJ.js} +1 -1
  198. package/dist/client/assets/{use-mcp-client-8Mk4_07F.js → use-mcp-client-B-JRPXnN.js} +1 -1
  199. package/dist/client/assets/{use-mcp-prompts-qMmlGT6D.js → use-mcp-prompts-OczkXrmo.js} +1 -1
  200. package/dist/client/assets/{use-mcp-tools-6tSV8bBT.js → use-mcp-tools-WWdORF6E.js} +1 -1
  201. package/dist/client/assets/{use-members-CmtL-7Xw.js → use-members-DEAGj5M0.js} +1 -1
  202. package/dist/client/assets/{use-navigate-to-agent-GneYXT_v.js → use-navigate-to-agent-j8txYt39.js} +1 -1
  203. package/dist/client/assets/{use-org-auth-client-C03WsUCl.js → use-org-auth-client-ziR2xP7Z.js} +1 -1
  204. package/dist/client/assets/{use-org-sso-DXytk076.js → use-org-sso-DMSjHU5t.js} +1 -1
  205. package/dist/client/assets/{use-organization-roles-BGY8todC.js → use-organization-roles-DvPau1Zi.js} +1 -1
  206. package/dist/client/assets/{use-organization-settings-BxGa6DXL.js → use-organization-settings-Cncb08kX.js} +1 -1
  207. package/dist/client/assets/{use-registry-connections-DPGwglYZ.js → use-registry-connections-bHwMGkYH.js} +1 -1
  208. package/dist/client/assets/{use-secrets-CwGIrVHL.js → use-secrets-6j_GId-n.js} +1 -1
  209. package/dist/client/assets/{use-status-sounds-BRiOIxZe.js → use-status-sounds-jRgdHM6o.js} +1 -1
  210. package/dist/client/assets/{use-view-mode-DHxUj9Og.js → use-view-mode-oY0gTmDF.js} +1 -1
  211. package/dist/client/assets/{use-virtual-mcp-BYEJrKLt.js → use-virtual-mcp-fBHJQJIQ.js} +1 -1
  212. package/dist/client/assets/useInfiniteQuery-toVymGgv.js +1 -0
  213. package/dist/client/assets/{useRouterState-BypT_ylp.js → useRouterState-CQ_dlcxM.js} +1 -1
  214. package/dist/client/assets/useSuspenseInfiniteQuery-BbMvRYcb.js +1 -0
  215. package/dist/client/assets/{user-4ZM9LPlw.js → user-5EdNnZWa.js} +1 -1
  216. package/dist/client/assets/{view-mode-toggle-DglPSQoj.js → view-mode-toggle-Df0p0wvc.js} +1 -1
  217. package/dist/client/assets/{workflow-Bv3R9Ay6.js → workflow-D175Z8ad.js} +1 -1
  218. package/dist/client/assets/workflow-detail-zWNrlggW.js +1 -0
  219. package/dist/client/index.html +2 -2
  220. package/dist/server/cli.js +196 -196
  221. package/dist/server/migrate.js +40 -40
  222. package/dist/server/server.js +155 -155
  223. package/package.json +1 -1
  224. package/dist/client/assets/app-editor-XgVpEUlu.js +0 -1
  225. package/dist/client/assets/page-seo-sheet-D3VNLk-W.js +0 -1
  226. package/dist/client/assets/record-editor-D3YkaDAS.js +0 -1
  227. package/dist/client/assets/registry-DZI6kLp4.js +0 -2
  228. package/dist/client/assets/save-referenced-block-D8z6Kvhe.js +0 -1
  229. package/dist/client/assets/store-registry-Cn9W0z9v.js +0 -2
  230. package/dist/client/assets/useInfiniteQuery-D71LulL4.js +0 -1
  231. package/dist/client/assets/useSuspenseInfiniteQuery-CDkRkXhL.js +0 -1
  232. package/dist/client/assets/workflow-detail-BhI1gxl7.js +0 -1
@@ -1,5 +1,5 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/sections-editor-D-D4fXgu.js","assets/index-DKa2bYTS.js","assets/index-C4D2JWLP.css","assets/ChevronDown-DagjZ4eX.js","assets/ChevronRight-DVtjidio.js","assets/ChevronUp-BMDnNzvq.js","assets/agent-icon-CMmthzuk.js","assets/AlertCircle-CPDzwcNm.js","assets/Tool01-BJXGaU-M.js","assets/SwitchHorizontal01-D-Tt77nJ.js","assets/RefreshCcw01-BEoOvUD1.js","assets/XCircle-7rwkbF3y.js","assets/ArrowUpRight-ShCMNuxq.js","assets/ZapSquare-1g_0m2Au.js","assets/Users03-AoZrK_H4.js","assets/CheckCircle-8aHxGN9L.js","assets/Check-notD5fT5.js","assets/ChevronLeft-BaqaOx9Y.js","assets/DotsVertical-BJhFy0Ao.js","assets/Container-D6z1XWRo.js","assets/Eye-BB6Aus5x.js","assets/ZoomOut-B72QEIIU.js","assets/Globe01-CIsVQmOA.js","assets/FilterLines-DMByO-IA.js","assets/Star01-BlvJ3i4w.js","assets/Palette-GNFXWUwf.js","assets/HardDrive-DuCt5CIe.js","assets/Stars02-De2-tT4k.js","assets/Key01-CngsxG29.js","assets/LayoutLeft-DgM7tZde.js","assets/LinkExternal01-CQF0MYqY.js","assets/Monitor01-CT1u4DKh.js","assets/Sun-BcFWhCSK.js","assets/Play-QmNwPHc_.js","assets/Plus-Dppw3z2O.js","assets/SearchMd-FY1Qclyu.js","assets/Settings02-ocCz49Kz.js","assets/Shield01-BzHglsiw.js","assets/Stars01-DukS22FM.js","assets/Trash01-CZnJ0avm.js","assets/Upload01-76tsCZMd.js","assets/User01-CWOXdoG4.js","assets/Users01-WG_iZnJh.js","assets/XClose-DFcy3zV5.js","assets/X-B0rYwlAH.js","assets/Zap-DkP77k_W.js","assets/scroll-area-C2jindzS.js","assets/select-PwFJPxWI.js","assets/tooltip-CRGezvtE.js","assets/dialog-B3n4osS2.js","assets/input-BjUn5ElR.js","assets/dropdown-menu-C0lExS63.js","assets/sortable.esm-BaLGniPk.js","assets/connection-slug-eyAPH6o3.js","assets/connection-card-HxhqgvOF.js","assets/use-registry-connections-DPGwglYZ.js","assets/use-connection-D5VghmN_.js","assets/use-collections-Ciodw5T-.js","assets/use-mcp-client-8Mk4_07F.js","assets/use-organization-settings-BxGa6DXL.js","assets/useInfiniteQuery-D71LulL4.js","assets/infiniteQueryObserver-CAoHOrzQ.js","assets/extract-connection-data-PFgGg6kx.js","assets/generate-id-B00Lqcz6.js","assets/collections-t21R7Da7.js","assets/card-lBnnILto.js","assets/integration-icon-CxZb-fPL.js","assets/collection-search-DEQMWm_z.js","assets/collection-tabs-BLluwkr_.js","assets/badge-Dwfe01sI.js","assets/drawer-DVtZCj6U.js","assets/form-BDTBUfjP.js","assets/label-kHH3gI2u.js","assets/textarea-BVmeWwVH.js","assets/connection-form-helpers-BMXuAyPa.js","assets/use-infinite-scroll-ILdTUQK_.js","assets/useSuspenseInfiniteQuery-CDkRkXhL.js","assets/schema-form-BdhlzGvI.js","assets/calendar-DUj5Hjlg.js","assets/popover-B-ZF248I.js","assets/switch-AaQYpmii.js","assets/image-field-BKg_4VXm.js","assets/skeleton-Bjc1-vnR.js","assets/tabs-DgRLyNv0.js","assets/use-file-configs-DWr7ryUj.js","assets/unwrap-tool-result-BYXdCQMg.js","assets/page-seo-form-gwUc3t6W.js","assets/command-De_vHwL2.js","assets/index-wz9jNcYo.js","assets/add-section-modal-BwyDPP_M.js","assets/agent-capabilities-xX47CwbD.js","assets/chat-context-sLONPn-0.js","assets/tab-id-ClQkYZph.js","assets/decopilot-sse-pool-D3C-kBei.js","assets/create-sse-subscription-BS5983N4.js","assets/use-virtual-mcp-BYEJrKLt.js","assets/use-ai-providers-Bft4iAI7.js","assets/pair-0yfESYcy.js","assets/format-time-Cy7tTmZp.js","assets/differenceInSeconds-NQ4PDo0z.js","assets/use-copy-C6l9b4AS.js","assets/file-type-icon-CE1JVL_T.js","assets/content-blocks-o63cs2vh.js","assets/types-DfZ9L9F4.js","assets/shell-layout-U6oRxAp4.js","assets/avatar-GhNVlFfA.js","assets/required-auth-layout-1NjGJ1GA.js","assets/useRouterState-BypT_ylp.js","assets/use-org-sso-DXytk076.js","assets/use-navigate-to-agent-GneYXT_v.js","assets/use-mcp-prompts-qMmlGT6D.js","assets/spinner-Cerb4AAl.js","assets/toggle-group-DsBG4yXK.js","assets/connect-desktop-dialog-DT9M25jO.js","assets/agent-icons-kCVtwvlc.js","assets/checkbox-B0Z95T9p.js","assets/ai-providers-logos-DD3qZ33J.js","assets/settings-section-CcsLWjfi.js","assets/index-CP5nxTWj.js","assets/question-004-sINsf4GQ.js","assets/shell-route-loading-Bk2X9n-X.js","assets/sidebar-wL4mjwdl.js","assets/sheet-Dlzq2DLm.js","assets/toolbar-DimPrw2d.js","assets/use-create-virtual-mcp-DQu9pTfE.js","assets/github-repo-picker-CiY30Vug.js","assets/use-mcp-tools-6tSV8bBT.js","assets/alert-dialog-BqYd6k15.js","assets/index-DI-ETavs.js","assets/use-org-auth-client-C03WsUCl.js","assets/hover-card-BuyKR5LS.js","assets/task-status-D2UHrjIr.js","assets/use-status-sounds-BRiOIxZe.js","assets/empty-state-Cigz9ucf.js","assets/resizable-CDnnGLy_.js","assets/use-capability-D76L9anx.js","assets/header-tab-button-P7xz_OdB.js","assets/index-CZFRR26-.js","assets/user-4ZM9LPlw.js","assets/tools-list-CRWK46bj.js","assets/use-debounced-autosave-Ckz0uq-7.js","assets/index-BwI2_EhO.js","assets/search-input-C7EV5zgy.js","assets/use-secrets-CwGIrVHL.js","assets/formatDistanceToNow-Cb2QZZJn.js","assets/accordion-DmyLwYep.js","assets/view-mode-toggle-DglPSQoj.js","assets/select-model-Cj0XuQ9B.js","assets/use-automations-BgW6aFoA.js","assets/monaco-editor-DYGOFuTO.js","assets/automation-runs-NbYM1cjn.js","assets/table-tXZdu4xg.js","assets/use-members-CmtL-7Xw.js","assets/automation-list-row-Bfqyr7I3.js","assets/save-referenced-block-D8z6Kvhe.js","assets/page-seo-sheet-D3VNLk-W.js","assets/file-explorer-DwYs1O3Y.js","assets/app-editor-XgVpEUlu.js","assets/save-status-Bhokzo-6.js","assets/post-editor-CZlHz9jV.js","assets/primitives-yLIBPquV.js","assets/record-editor-D3YkaDAS.js","assets/seo-editor-BTy_Py6L.js","assets/project-app-view-CjNYmwJu.js"])))=>i.map(i=>d[i]);
2
- import{e as W,r as P,c as ce,j as n,l as Ce,q as Re,b as qs,E as Ut,f as es,d as Po,g as Sc,p as Cu,L as ku,n as Gs,K as It,s as ju,o as le,B as se,v as wc,w as Nu,V as Eu,t as Le,x as Cc,y as Tu,z as qr,C as Ai,D as vt,F as Pu,G as Ys,H as kc,I as Ru,J as Du,M as Pa,P as Au,Q as Gr,R as Iu,a as Xs,T as fr,U as xi,W as Et,_ as qt}from"./index-DKa2bYTS.js";import{C as Oe,a as Bu,u as Mu,b as Js,h as Lu,w as Ou,c as jc,d as Ro,s as Bn,T as $u,e as zu,g as Fu,f as Hu}from"./agent-capabilities-xX47CwbD.js";import{g as Do,u as Qe,S as js,a as Nc}from"./use-mcp-client-8Mk4_07F.js";import{u as Mt,a as Wu,b as Uu,c as Ku}from"./use-virtual-mcp-BYEJrKLt.js";import{a as Ns,b as ts,c as Ao,d as Ec,u as Vu,t as qu,e as Gu,f as Yu}from"./chat-context-sLONPn-0.js";import{i as Fi}from"./AlertCircle-CPDzwcNm.js";import{i as Tc}from"./CheckCircle-8aHxGN9L.js";import{n as Ra}from"./ChevronLeft-BaqaOx9Y.js";import{i as Xu,a as Ju}from"./XCircle-7rwkbF3y.js";import{s as ps}from"./XClose-DFcy3zV5.js";import{c as Zu,u as Qu,a as Pc,O as ef,t as Da,G as tf,g as sf,s as rf,C as nf,b as of,d as af}from"./pair-0yfESYcy.js";import{I as Gt}from"./integration-icon-CxZb-fPL.js";import{a as lf}from"./Users03-AoZrK_H4.js";import{t as Es}from"./ChevronDown-DagjZ4eX.js";import{u as Rc}from"./use-ai-providers-Bft4iAI7.js";import{r as cf,u as Io,i as hf}from"./shell-layout-U6oRxAp4.js";import{b as df,a as uf}from"./shell-route-loading-Bk2X9n-X.js";import{u as ff}from"./sidebar-wL4mjwdl.js";import{S as mf,a as pf,b as _f}from"./sheet-Dlzq2DLm.js";import{u as Dc,T as Ee,a as Te,b as Pe,c as Ac}from"./tooltip-CRGezvtE.js";import{i as Ii,a as Yr,b as Ic,c as gf,p as Xr,g as Jr,d as Bo,e as Bc,h as Mn,f as dn,j as Aa,A as Ia,k as vf,l as xf,n as bf,m as yf,o as Sf,t as wf,q as Cf,r as kf,s as jf,u as Zr,v as Nf,w as Ba,x as Ma,y as Ef,z as Tf,B as Pf,C as Rf,D as Mo,E as Cr,F as Lo,G as Mc,H as Lc,I as Df,J as Af,K as If,L as Bf,M as Mf,N as La,O as Lf,P as Of,Q as ji,R as $f,S as Oc,T as $c,U as zf}from"./agent-icon-CMmthzuk.js";import{u as Ff}from"./use-status-sounds-BRiOIxZe.js";import{E as kr}from"./empty-state-Cigz9ucf.js";import{u as Hf,r as Ln,a as Wf,p as zc,f as Oa,b as Fc,c as Hc,d as Wc,e as Uf,F as Kf,i as Vf,g as qf,h as Gf,j as Yf,k as Xf}from"./tab-id-ClQkYZph.js";import{g as Zs,A as Jf}from"./sortable.esm-BaLGniPk.js";import{T as $a,a as On}from"./toolbar-DimPrw2d.js";import{R as Uc,a as Zf,b as Qf}from"./resizable-CDnnGLy_.js";import{i as Hi,n as em}from"./Globe01-CIsVQmOA.js";import{i as Kc}from"./Monitor01-CT1u4DKh.js";import{u as Wi,a as Oo,b as Vc}from"./use-connection-D5VghmN_.js";import{u as Qr,a as tm,b as sm}from"./use-mcp-tools-6tSV8bBT.js";import{u as im}from"./use-capability-D76L9anx.js";import{F as $o,M as zo}from"./file-type-icon-CE1JVL_T.js";import{g as rm,d as qc,a as za,H as Gc,F as nm,b as om,f as am,u as lm,c as cm,e as hm,h as dm}from"./header-tab-button-P7xz_OdB.js";import{i as Yc,a as Fa,b as um}from"./ZoomOut-B72QEIIU.js";import{P as Ts,a as Ps,b as Rs}from"./popover-B-ZF248I.js";import{S as Xc}from"./spinner-Cerb4AAl.js";import{D as Qs,a as ei,b as ti,c as Ze,d as mr,e as fm,f as mm,g as pm}from"./dropdown-menu-C0lExS63.js";import{D as Lt,a as Ot,b as ss,c as is,d as si,e as Fo}from"./dialog-B3n4osS2.js";import{I as Ve}from"./input-BjUn5ElR.js";import{T as ys,a as Ho,b as Ni,c as Wo}from"./tabs-DgRLyNv0.js";import{T as jr}from"./textarea-BVmeWwVH.js";import{a as fs,s as _m}from"./Eye-BB6Aus5x.js";import{t as en}from"./Stars01-DukS22FM.js";import{l as gm,w as vm}from"./index-CZFRR26-.js";import{i as xm}from"./ChevronRight-DVtjidio.js";import{g as bm}from"./generate-id-B00Lqcz6.js";import{g as ym}from"./types-DfZ9L9F4.js";import{U as Jc}from"./user-4ZM9LPlw.js";import{T as Sm,u as Zc}from"./tools-list-CRWK46bj.js";import{u as wm}from"./unwrap-tool-result-BYXdCQMg.js";import{s as Qc,g as Cm}from"./connection-slug-eyAPH6o3.js";import{A as Nr,a as Er,b as Tr,c as Pr,d as Rr,e as Dr,f as Ar,g as Ir}from"./alert-dialog-BqYd6k15.js";import{C as eh,a as $n}from"./card-lBnnILto.js";import{L as kt}from"./label-kHH3gI2u.js";import{S as Pt,a as Rt,b as Dt,c as at,d as At}from"./select-PwFJPxWI.js";import{S as Br}from"./switch-AaQYpmii.js";import{i as Ws}from"./Play-QmNwPHc_.js";import{s as Bt}from"./Plus-Dppw3z2O.js";import{a as km}from"./Settings02-ocCz49Kz.js";import{s as Bi}from"./Trash01-CZnJ0avm.js";import{u as Mr}from"./use-debounced-autosave-Ckz0uq-7.js";import{S as tn}from"./scroll-area-C2jindzS.js";import{i as Uo}from"./SearchMd-FY1Qclyu.js";import{i as jm}from"./Upload01-76tsCZMd.js";import{i as Nm}from"./LayoutLeft-DgM7tZde.js";import{P as Tt}from"./index-BwI2_EhO.js";import{C as sn}from"./checkbox-B0Z95T9p.js";import{S as th}from"./search-input-C7EV5zgy.js";import{C as sh}from"./collection-tabs-BLluwkr_.js";import{u as Em}from"./use-mcp-prompts-qMmlGT6D.js";import{D as Tm,a as Pm,b as Rm}from"./drawer-DVtZCj6U.js";import{i as Ui}from"./Check-notD5fT5.js";import{i as ih}from"./Key01-CngsxG29.js";import{S as xs}from"./skeleton-Bjc1-vnR.js";import{s as Dm}from"./User01-CWOXdoG4.js";import{t as Ko}from"./Users01-WG_iZnJh.js";import{u as Am,a as Im}from"./use-secrets-CwGIrVHL.js";import{G as Bm}from"./github-repo-picker-CiY30Vug.js";import{f as Mm}from"./formatDistanceToNow-Cb2QZZJn.js";import{n as ii}from"./LinkExternal01-CQF0MYqY.js";import{A as Lm,a as Om,b as $m,c as zm}from"./accordion-DmyLwYep.js";import{s as Us}from"./Star01-BlvJ3i4w.js";import{i as rh}from"./Stars02-De2-tT4k.js";import{V as Fm}from"./view-mode-toggle-DglPSQoj.js";import{n as nh}from"./ZapSquare-1g_0m2Au.js";import{i as Vo,a as Hm,b as qo}from"./Tool01-BJXGaU-M.js";import{c as oh,i as Wm}from"./SwitchHorizontal01-D-Tt77nJ.js";import{B as Um}from"./badge-Dwfe01sI.js";import{C as Km,a as Ha,b as Vm,c as qm,d as Gm,e as Ym}from"./command-De_vHwL2.js";import{M as Xm}from"./select-model-Cj0XuQ9B.js";import{u as Ki,a as Jm,b as Zm,c as Qm,d as ep}from"./use-automations-BgW6aFoA.js";import{i as ah}from"./RefreshCcw01-BEoOvUD1.js";import{i as Mi}from"./Zap-DkP77k_W.js";import{M as tp}from"./monaco-editor-DYGOFuTO.js";import{A as sp}from"./automation-runs-NbYM1cjn.js";import{A as ip}from"./automation-list-row-Bfqyr7I3.js";import{i as rp}from"./X-B0rYwlAH.js";function hi(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 np(t){return t?t.replace(/-\d{8}(?:-[a-z0-9]+)*$/i,"").replace(/-/g," "):"—"}function op(t){const e=W.c(4),{items:s}=t;let i;e[0]!==s?(i=s.map(ap),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 ap(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 lp(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 x;e[16]!==l?(x=l.toFixed(1),e[16]=l,e[17]=x):x=e[17];let b;e[18]!==x?(b=n.jsxs("div",{className:"flex items-center gap-1.5",children:[g,n.jsxs("span",{className:"text-xs text-muted-foreground",children:["Assistant ",x,"%"]})]}),e[18]=x,e[19]=b):b=e[19];let v;e[20]!==h||e[21]!==r?(v=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]=v):v=e[22];let y;e[23]!==b||e[24]!==v||e[25]!==_?(y=n.jsxs("div",{className:"flex flex-wrap gap-x-3 gap-y-1",children:[_,b,v]}),e[23]=b,e[24]=v,e[25]=_,e[26]=y):y=e[26];let S;return e[27]!==y||e[28]!==f?(S=n.jsxs("div",{className:"flex flex-col gap-2",children:[f,y]}),e[27]=y,e[28]=f,e[29]=S):S=e[29],S}function cp(t){const e=W.c(11),{agentId:s,isError:i}=t,r=Mt(s),o=r?.title??"Subtask",a=r?.icon??null;let l;e[0]!==a||e[1]!==o?(l=n.jsx(Gt,{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=ce("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 hp(t){const e=W.c(5),{isError:s}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=n.jsx(Gt,{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=ce("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 dp(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(hp,{isError:o}),e[0]=o,e[1]=l):l=e[1];let h;e[2]!==i||e[3]!==o?(h=n.jsx(cp,{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(Ce,{size:12,className:"animate-spin text-muted-foreground"}):o?n.jsx(Xu,{size:12,className:"text-destructive"}):a?n.jsx(Fi,{size:12,className:"text-warning"}):n.jsx(Tc,{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 up(t){const e=W.c(55),{onClose:s,back:i,className:r}=t,[o,a]=P.useState(null),{messages:l}=Ns(),{activeTask:h}=ts(),{selectedModel:c,selectedVirtualMcp:d}=Ao();let u,f,m,p,_,g,x,b;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){b=Symbol.for("react.early_return_sentinel");e:{const S=Zu(l),C=[...l].reverse().find(wp),j=C?.metadata?.usage,T=C?.metadata?.modelLimits?.contextWindow??c?.limits?.contextWindow??null,B=j?.contextTokens??0,I=T&&T>0?(B/T*100).toFixed(1):null,R=l;let k;e[16]!==R?(k=R.filter(Sp).reduce(yp,0),e[16]=R,e[17]=k):k=e[17];const w=k,A=l;let N;e[18]!==A?(N=A.filter(bp).reduce(xp,0),e[18]=A,e[19]=N):N=e[19];const E=N,M=Math.max(0,S.totalTokens-w-E),D=l[0],L=l.at(-1),z=D?.metadata?.created_at??h?.created_at,H=L?.metadata?.created_at??h?.updated_at,F=l.filter(vp),q=l.flatMap(_p),J=c?.modelId?np(c.modelId):"—",V=d?.title??"Decopilot",U=[{label:"Session",value:h?.title??"New chat"},{label:"Messages",value:F.length},{label:"Agent",value:V},{label:"Model",value:J},{label:"Context Limit",value:T?hi(T):"—"},{label:"Session Tokens (billed)",value:S.totalTokens>0?hi(S.totalTokens):"0"},{label:"Usage",value:I!==null?`${I}%`:"—"},{label:"Input Tokens",value:S.inputTokens>0?hi(S.inputTokens):"0"},{label:"Output Tokens",value:S.outputTokens>0?hi(S.outputTokens):"0"},{label:"Reasoning Tokens",value:S.reasoningTokens>0?hi(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(z)},{label:"Last Activity",value:Wa(H)}];if(!h&&F.length===0){let O;e[20]!==r?(O=ce("flex flex-col h-full w-full border-l border-border bg-background",r),e[20]=r,e[21]=O):O=e[21];let ee;e[22]===Symbol.for("react.memo_cache_sentinel")?(ee=n.jsx("span",{className:"text-sm font-medium text-foreground",children:"Context"}),e[22]=ee):ee=e[22];let te;e[23]!==i?(te=i?n.jsx(Ra,{size:14,className:"text-muted-foreground"}):n.jsx(ps,{size:14,className:"text-muted-foreground"}),e[23]=i,e[24]=te):te=e[24];let Y;e[25]!==s||e[26]!==te?(Y=n.jsxs("div",{className:"h-11 px-4 flex items-center justify-between shrink-0 border-b border-border/50",children:[ee,n.jsx("button",{type:"button",onClick:s,className:"flex size-6 items-center justify-center rounded hover:bg-accent transition-colors",children:te})]}),e[25]=s,e[26]=te,e[27]=Y):Y=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]!==O||e[30]!==Y?(ae=n.jsxs("div",{className:O,children:[Y,$]}),e[29]=O,e[30]=Y,e[31]=ae):ae=e[31],b=ae;break e}e[32]!==r?(g=ce("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 K;e[34]===Symbol.for("react.memo_cache_sentinel")?(K=n.jsx("span",{className:"text-sm font-medium text-foreground",children:"Context"}),e[34]=K):K=e[34];let Q;e[35]!==i?(Q=i?n.jsx(Ra,{size:14}):n.jsx(ps,{size:14}),e[35]=i,e[36]=Q):Q=e[36],e[37]!==s||e[38]!==Q?(x=n.jsxs("div",{className:"flex h-11 shrink-0 items-center justify-between border-b border-border/50 px-4",children:[K,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:Q})]}),e[37]=s,e[38]=Q,e[39]=x):x=e[39],u="flex flex-col gap-8 p-6",f=q.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:q.map(pp)})]}),m=n.jsx(op,{items:U});let oe;e[40]===Symbol.for("react.memo_cache_sentinel")?(oe=n.jsx("span",{className:"text-xs text-muted-foreground",children:"Context Breakdown"}),e[40]=oe):oe=e[40],e[41]!==E||e[42]!==M||e[43]!==w?(p=n.jsxs("div",{className:"flex flex-col gap-3",children:[oe,n.jsx(lp,{userTokens:w,assistantTokens:E,otherTokens:M})]}),e[41]=E,e[42]=M,e[43]=w,e[44]=p):p=e[44],_=F.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:F.map(O=>{const ee=O.metadata?.created_at,te=o?.id===O.id;return n.jsxs("div",{className:"rounded-md border border-border/50 overflow-hidden",children:[n.jsxs("button",{type:"button",onClick:()=>a(te?null:O),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:ce("shrink-0 font-medium",O.role==="user"?"text-chart-1":"text-chart-2"),children:O.role}),n.jsx("span",{className:"text-muted-foreground",children:"•"}),n.jsx("span",{className:"truncate text-muted-foreground font-mono",children:O.id})]}),ee&&n.jsx("span",{className:"shrink-0 text-muted-foreground tabular-nums",children:new Date(ee).toLocaleString("en-US",{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit"})})]}),te&&n.jsxs(n.Fragment,{children:[O.role==="assistant"&&(()=>{const Y=O.metadata?._request;if(!Y)return null;const $=Y.systemSections??[],ae=Math.max(1,...$.map(mp)),ue=$.reduce(fp,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:[Y.activeTools??0," / ",Y.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(ue/4).toLocaleString()," ","tok"]})]}),$.map((fe,he)=>{const re=fe.preview.match(/^<([a-z-]+)/i)?.[1]??`section ${he}`,ve=fe.chars/ae*100,ie=Math.round(fe.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:re}),n.jsxs("span",{className:"text-muted-foreground tabular-nums shrink-0",children:["~",ie.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:`${ve}%`}})})]},he)})]})]})})(),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(O,null,2)})]})]},O.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]=x,e[15]=b}else u=e[8],f=e[9],m=e[10],p=e[11],_=e[12],g=e[13],x=e[14],b=e[15];if(b!==Symbol.for("react.early_return_sentinel"))return b;let v;e[45]!==u||e[46]!==f||e[47]!==m||e[48]!==p||e[49]!==_?(v=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]=v):v=e[50];let y;return e[51]!==g||e[52]!==x||e[53]!==v?(y=n.jsxs("div",{className:g,children:[x,v]}),e[51]=g,e[52]=x,e[53]=v,e[54]=y):y=e[54],y}function fp(t,e){return t+e.chars}function mp(t){return t.chars}function pp(t,e){return n.jsx(dp,{part:t},e)}function _p(t){return(t.parts??[]).filter(gp)}function gp(t){return t.type==="tool-subtask"}function vp(t){return t.role!=="system"}function xp(t,e){const s=e.metadata?.usage;return t+(s?.outputTokens??0)}function bp(t){return t.role==="assistant"}function yp(t,e){const s=e.metadata?.usage;return t+(s?.inputTokens??0)}function Sp(t){return t.role==="user"}function wp(t){return t.role==="assistant"&&t.metadata?.usage}function Cp(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 kp(t){const e=W.c(25),{onOpenContextPanel:s}=t,{org:i}=Re(),{selectedVirtualMcp:r}=Ao();let o;e[0]!==i.id?(o=Do(i.id),e[0]=i.id,e[1]=o):o=e[1];const l=r??o,h=Mt(l.id),c=Ec(),{data:d}=qs.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(lf,{size:32}),e[2]=p):p=e[2];let _;e[3]!==l.icon||e[4]!==l.title?(_=n.jsx(Gt,{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 x=l.description??"Ask anything about configuring model providers or using MCP Mesh.";let b;e[8]!==x?(b=n.jsx("div",{className:"text-muted-foreground text-center text-base max-w-md line-clamp-2",children:x}),e[8]=x,e[9]=b):b=e[9];let v;e[10]!==_||e[11]!==g||e[12]!==b?(v=n.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 md:gap-4 text-center",children:[_,g,b]}),e[10]=_,e[11]=g,e[12]=b,e[13]=v):v=e[13];const y=c?.currentBranch??null;let S;e[14]!==h||e[15]!==y?(S=n.jsx(Bu,{virtualMcp:h,currentBranch:y}),e[14]=h,e[15]=y,e[16]=S):S=e[16];let C;e[17]!==s?(C=n.jsx(Oe.Input,{onOpenContextPanel:s}),e[17]=s,e[18]=C):C=e[18];let j;e[19]===Symbol.for("react.memo_cache_sentinel")?(j=n.jsx(Oe.IceBreakers,{}),e[19]=j):j=e[19];let T;return e[20]!==m||e[21]!==C||e[22]!==v||e[23]!==S?(T=n.jsx(Cp,{readOnly:m,identity:v,aboveRow:S,input:C,iceBreakers:j}),e[20]=m,e[21]=C,e[22]=v,e[23]=S,e[24]=T):T=e[24],T}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=ce(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=ce("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(Es,{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(jp)}),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 jp(t){return n.jsx(ef,{file:t},t.key)}function Np(){const t=W.c(13),e=Ec()?.taskId??null,s=Qu();let i;t[0]!==s?(i={enabled:s},t[0]=s,t[1]=i):i=t[1];const{data:r}=Pc(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(Tp),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(Ep),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 Ep(t){return!t}function Tp(t){return!t}function Pp(){const t=W.c(28),{org:e}=Re(),s=Rc(),{isChatEmpty:i}=Ns(),[r,o]=P.useState("chat"),a=Mu(),{selectedVirtualMcp:l}=Ao();let h;t[0]!==e.id?(h=Do(e.id),t[0]=e.id,t[1]=h):h=t[1];const u=Mt((l??h).id),f=Vu(),m=Js(u?.metadata);if(s.length===0&&!(m&&Lu(f))){let R;return t[2]===Symbol.for("react.memo_cache_sentinel")?(R=n.jsx(Oe,{className:"animate-in fade-in-0 duration-200",children:n.jsx(Oe.Main,{className:"flex flex-col items-center",children:n.jsx(Oe.EmptyState,{children:n.jsx(Oe.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&&!Ou(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 x;t[10]!==g?(x=g&&n.jsx(Oe.CreditsEmptyState,{}),t[10]=g,t[11]=x):x=t[11];const b=r!=="chat"?"opacity-0 pointer-events-none":"opacity-100";let v;t[12]!==b?(v=ce("absolute inset-0 flex flex-col transition-opacity duration-100 ease-out",b),t[12]=b,t[13]=v):v=t[13];let y;t[14]!==i?(y=i?n.jsx(Oe.Main,{children:n.jsx(kp,{onOpenContextPanel:()=>o("context")})}):n.jsxs(n.Fragment,{children:[n.jsxs(Oe.Main,{className:"relative flex flex-col overflow-hidden @container",children:[n.jsx(Np,{}),n.jsx("div",{className:"min-h-0 flex-1",children:n.jsx(Oe.Messages,{})})]}),n.jsx(Oe.Footer,{children:n.jsx(Oe.Input,{onOpenContextPanel:()=>o("context")})})]}),t[14]=i,t[15]=y):y=t[15];let S;t[16]!==v||t[17]!==y?(S=n.jsx("div",{className:v,children:y}),t[16]=v,t[17]=y,t[18]=S):S=t[18];const C=r==="context"?"opacity-100":"opacity-0 pointer-events-none";let j;t[19]!==C?(j=ce("absolute inset-0 flex flex-col transition-opacity duration-100 ease-out",C),t[19]=C,t[20]=j):j=t[20];let T;t[21]===Symbol.for("react.memo_cache_sentinel")?(T=n.jsx(up,{back:!0,onClose:()=>o("chat")}),t[21]=T):T=t[21];let B;t[22]!==j?(B=n.jsx("div",{className:j,children:T}),t[22]=j,t[23]=B):B=t[23];let I;return t[24]!==B||t[25]!==x||t[26]!==S?(I=n.jsxs(Oe,{className:"relative overflow-hidden animate-in fade-in-0 duration-200",children:[x,S,B]}),t[24]=B,t[25]=x,t[26]=S,t[27]=I):I=t[27],I}function lh(){const t=W.c(2);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsx(Oe.Skeleton,{}),t[0]=e):e=t[0];let s;return t[1]===Symbol.for("react.memo_cache_sentinel")?(s=n.jsx(Ut,{fallback:e,children:n.jsx(P.Suspense,{fallback:n.jsx(Oe.Skeleton,{}),children:n.jsx(Pp,{})})}),t[1]=s):s=t[1],s}function Rp(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 Dp(t,e){return t===1?!0:t===0?!1:e}function Ap(t,e){const s=es(),i=Po({strict:!1}),r=Sc({strict:!1}),{create:o}=Hf(),{locator:a}=Re(),{virtualMcpId:l,orgSlug:h,isAgentRoute:c}=e,d=Rp({entityMetadata:t,mainParamPresent:i.main!==void 0,mainParamValue:i.main}),u=Dp(i.chat,d.chatOpen),f=d.mainOpen,m=P.useRef(crypto.randomUUID()),p=r.taskId??m.current,_="/$org/$taskId",g=B=>({org:h,taskId:B}),x=c?{virtualmcpid:l}:{},b=(B,I)=>{s({to:_,params:g(p),search:R=>({...R,...B}),replace:I?.replace??!1})},v=(B,I)=>{s({to:_,params:g(B),search:R=>{const k={};return I?k.virtualmcpid=I:c&&(k.virtualmcpid=l),k}})},y=()=>{f?b({main:"0"},{replace:!0}):b({main:Ln(t)},{replace:!0})},S=()=>{b({chat:u?0:1},{replace:!0})},C=()=>{u||b({chat:1},{replace:!0})},j=async()=>{const B=crypto.randomUUID(),I=cf(h,a,p);try{await o({id:B,virtual_mcp_id:l,...I?{branch:I}:{}})}catch{}s({to:_,params:g(B),search:R=>({...x,chat:1})})},T=B=>{b({main:B},{replace:!0})};return{taskId:p,mainOpen:f,chatOpen:u,mainParam:i.main,setTaskId:v,toggleMain:y,toggleChat:S,openChat:C,createNewTask:j,openTab:T}}const Go=45;function ch(t,e=Go){const s=typeof t=="number"?t:Number(t);return!Number.isFinite(s)||s<=0||s>=100?e:s}function Ip(t){return ch(t,Go)}function Bp(){const t=W.c(6);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=ku.decoChatPanelWidth(),t[0]=e):e=t[0];const[s,i]=Cu(e,Ip);let r;t[1]!==s?(r=ch(s,Go),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 Mp(t){try{return JSON.parse(t)}catch{return null}}function Lp(t){if(!t||typeof t!="object")return null;const e=t,s=e.content?.find(o=>o.type==="text")?.text,i=s?Mp(s):null,r=e.structuredContent;return r==null?i:typeof r=="object"&&!Array.isArray(r)&&Object.keys(r).length===0?i??r:r}function Ds(t){const e=Lp(t);return e===null?null:e}function Yo(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 Op(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=Yo(s);return!i||!s?null:{number:i,htmlUrl:s}}const Va=/[\r\n<>]/,$p=/^[^\s@<>]+@[^\s@<>]+\.[^\s@<>]+$/;function Vi(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}:$p.test(s)?{userName:e,userEmail:s}:{userName:e}}function zp(t){return t.split(`
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/sections-editor-BRdCJB8j.js","assets/index-ChYUSQjJ.js","assets/index-CQuY_IDP.css","assets/ChevronDown-DPCmMamP.js","assets/ChevronRight-BPW30xu2.js","assets/ChevronUp-Bj0jQsTk.js","assets/agent-icon-B_ENO9HH.js","assets/AlertCircle-Cie6Yisc.js","assets/Tool01-WQP4RZxz.js","assets/SwitchHorizontal01-Sw4pGPNn.js","assets/RefreshCcw01-C5jOy04q.js","assets/XCircle-CGKRZUbS.js","assets/ArrowUpRight-Bup5q9aR.js","assets/ZapSquare-DVdUXxhF.js","assets/Users03-hkJxAqIG.js","assets/CheckCircle-Uw6Si4Uu.js","assets/Check-CWWWjir3.js","assets/ChevronLeft-BFKiUL-g.js","assets/DotsVertical-BnsTBCnN.js","assets/Container-CPU0lOb2.js","assets/Eye-Dj0PXl1o.js","assets/ZoomOut-0Ur-V1Tn.js","assets/Globe01-D6rc4c2I.js","assets/FilterLines-D8oi1Sof.js","assets/Star01-39vpRLS0.js","assets/Palette-C633yKaN.js","assets/HardDrive-BsP_WnUS.js","assets/Stars02-LHx1LC9_.js","assets/Key01-ZzkGvXus.js","assets/LayoutLeft-BrLgpS4_.js","assets/LinkExternal01-CYjY9tw_.js","assets/Monitor01-Co7esQF_.js","assets/Sun-D5VbC5bQ.js","assets/Play-DOVnYSwF.js","assets/Plus-G5Gw5kPM.js","assets/SearchMd-DM0EjhEJ.js","assets/Settings02-CtCQn3Yf.js","assets/Shield01-DlzHY_dC.js","assets/Stars01-D40cNl8a.js","assets/Trash01-cARQt3ei.js","assets/Upload01-Dmm1X5SO.js","assets/User01-CqHZqKxf.js","assets/Users01-Dsn_tDG5.js","assets/XClose-MKIx3xLp.js","assets/X-D7vVBDXl.js","assets/Zap-jV52NH8a.js","assets/scroll-area-BdohAM0t.js","assets/select-2pE_Mne6.js","assets/tooltip-ByLiX5Mq.js","assets/dialog-qWglm5p2.js","assets/input-Cm-_5NLx.js","assets/dropdown-menu-Vxh4zyXD.js","assets/sortable.esm-Cra7DBkd.js","assets/connection-slug-eyAPH6o3.js","assets/connection-card-DJ5vpD6m.js","assets/use-registry-connections-bHwMGkYH.js","assets/use-connection-DDWrr0D8.js","assets/use-collections-DXI321_l.js","assets/use-mcp-client-B-JRPXnN.js","assets/use-organization-settings-Cncb08kX.js","assets/useInfiniteQuery-toVymGgv.js","assets/infiniteQueryObserver-CwLfraWt.js","assets/extract-connection-data-yJgJfD7f.js","assets/generate-id-1zLHnSNC.js","assets/collections-B9PQucdo.js","assets/card-B4WowcKq.js","assets/integration-icon-CjuSu3xL.js","assets/collection-search-C3AEVd7W.js","assets/collection-tabs-azv2LaTo.js","assets/badge-5MzROStc.js","assets/drawer-C6RzB17v.js","assets/form-gGZaN2er.js","assets/label-CyHrJvd7.js","assets/textarea-C_bdHrQP.js","assets/connection-form-helpers-Ck21v4Z3.js","assets/use-infinite-scroll-vpAXlalO.js","assets/useSuspenseInfiniteQuery-BbMvRYcb.js","assets/schema-form-B08gOdyg.js","assets/calendar-DOA8Nces.js","assets/popover-DmAofN68.js","assets/switch-DgVVL7zp.js","assets/image-field-BAOOv2VL.js","assets/skeleton-DekfpK4t.js","assets/tabs-2u_8k4RO.js","assets/use-file-configs-acebBZy-.js","assets/unwrap-tool-result-BYXdCQMg.js","assets/page-seo-form-Bd0DSnoH.js","assets/command-BSLuC415.js","assets/index-BsdusiDa.js","assets/add-section-modal-CRKAmuUu.js","assets/agent-capabilities-BWvW99VB.js","assets/chat-context-BqvG5V6J.js","assets/tab-id-C7RjxJTr.js","assets/decopilot-sse-pool-koFlJuH3.js","assets/create-sse-subscription-BS5983N4.js","assets/use-virtual-mcp-fBHJQJIQ.js","assets/use-ai-providers-DsKRr79k.js","assets/pair-CrxtZLmo.js","assets/format-time-Cy7tTmZp.js","assets/differenceInSeconds-NQ4PDo0z.js","assets/use-copy-B87517Y1.js","assets/file-type-icon-BilQa1o9.js","assets/content-blocks-o63cs2vh.js","assets/types-Durgfewm.js","assets/shell-layout-DIvP19WX.js","assets/avatar-B3Bw52dv.js","assets/required-auth-layout-MFF8-ZJT.js","assets/useRouterState-CQ_dlcxM.js","assets/use-org-sso-DMSjHU5t.js","assets/use-navigate-to-agent-j8txYt39.js","assets/use-mcp-prompts-OczkXrmo.js","assets/spinner-ukxdHUOu.js","assets/toggle-group-C4fnmDnN.js","assets/connect-desktop-dialog-DNq0ek1i.js","assets/agent-icons-CpkNElG-.js","assets/checkbox-DHuCa6fF.js","assets/ai-providers-logos-DD3qZ33J.js","assets/settings-section-BZqGjpLm.js","assets/index-CXpnZeu8.js","assets/question-004-sINsf4GQ.js","assets/shell-route-loading-C61C46w4.js","assets/sidebar-ujCPJCBV.js","assets/sheet-BhIiqWhI.js","assets/toolbar-C8PVd7Ds.js","assets/use-create-virtual-mcp-CVaGBSXp.js","assets/github-repo-picker-CtaqsXDt.js","assets/use-mcp-tools-WWdORF6E.js","assets/alert-dialog-BGwOQ-hv.js","assets/index-Dk3pxVwF.js","assets/use-org-auth-client-ziR2xP7Z.js","assets/hover-card-BmPYfkmQ.js","assets/task-status-CRWfjMb2.js","assets/use-status-sounds-jRgdHM6o.js","assets/empty-state-vFbdMLGr.js","assets/resizable-Dvc6mjD2.js","assets/use-capability-xJktXQ3I.js","assets/header-tab-button-2KdmhnCN.js","assets/index-C-Ei6mai.js","assets/user-5EdNnZWa.js","assets/tools-list-Cr63qS_c.js","assets/use-debounced-autosave-X1JA0Sjb.js","assets/index-qXKJFTio.js","assets/search-input-BOsI1GRw.js","assets/use-secrets-6j_GId-n.js","assets/formatDistanceToNow-Cb2QZZJn.js","assets/accordion-C0j3DHtl.js","assets/view-mode-toggle-Df0p0wvc.js","assets/select-model-CrWeciHf.js","assets/use-automations-Dr8lwymn.js","assets/monaco-editor-DpalAqoH.js","assets/automation-runs-C92-yFsO.js","assets/table-C2KXmc6v.js","assets/use-members-DEAGj5M0.js","assets/automation-list-row-BNAgjK8x.js","assets/save-referenced-block-DfCtlYLI.js","assets/page-seo-sheet-BY0ZczJ9.js","assets/file-explorer-BJqHY4-p.js","assets/app-editor-n5gUpE-7.js","assets/save-status-BNra3mAM.js","assets/post-editor-M-6yKdac.js","assets/primitives-DypFIPbl.js","assets/record-editor-DOYxf9X2.js","assets/seo-editor-DGLH1irm.js","assets/project-app-view-B86ITaCE.js"])))=>i.map(i=>d[i]);
2
+ import{e as W,r as P,c as ce,j as n,l as Ce,q as Re,b as qs,E as Ut,f as es,d as Po,g as Sc,p as Cu,L as ku,n as Gs,K as It,s as ju,o as le,B as se,v as wc,w as Nu,V as Eu,t as Le,x as Cc,y as Tu,z as qr,C as Ai,D as vt,F as Pu,G as Ys,H as kc,I as Ru,J as Du,M as Pa,P as Au,Q as Gr,R as Iu,a as Xs,T as fr,U as xi,W as Et,_ as qt}from"./index-ChYUSQjJ.js";import{C as Oe,a as Bu,u as Mu,b as Js,h as Lu,w as Ou,c as jc,d as Ro,s as Bn,T as $u,e as zu,g as Fu,f as Hu}from"./agent-capabilities-BWvW99VB.js";import{g as Do,u as Qe,S as js,a as Nc}from"./use-mcp-client-B-JRPXnN.js";import{u as Mt,a as Wu,b as Uu,c as Ku}from"./use-virtual-mcp-fBHJQJIQ.js";import{a as Ns,b as ts,c as Ao,d as Ec,u as Vu,t as qu,e as Gu,f as Yu}from"./chat-context-BqvG5V6J.js";import{i as Fi}from"./AlertCircle-Cie6Yisc.js";import{i as Tc}from"./CheckCircle-Uw6Si4Uu.js";import{n as Ra}from"./ChevronLeft-BFKiUL-g.js";import{i as Xu,a as Ju}from"./XCircle-CGKRZUbS.js";import{s as ps}from"./XClose-MKIx3xLp.js";import{c as Zu,u as Qu,a as Pc,O as ef,t as Da,G as tf,g as sf,s as rf,C as nf,b as of,d as af}from"./pair-CrxtZLmo.js";import{I as Gt}from"./integration-icon-CjuSu3xL.js";import{a as lf}from"./Users03-hkJxAqIG.js";import{t as Es}from"./ChevronDown-DPCmMamP.js";import{u as Rc}from"./use-ai-providers-DsKRr79k.js";import{r as cf,u as Io,i as hf}from"./shell-layout-DIvP19WX.js";import{b as df,a as uf}from"./shell-route-loading-C61C46w4.js";import{u as ff}from"./sidebar-ujCPJCBV.js";import{S as mf,a as pf,b as _f}from"./sheet-BhIiqWhI.js";import{u as Dc,T as Ee,a as Te,b as Pe,c as Ac}from"./tooltip-ByLiX5Mq.js";import{i as Ii,a as Yr,b as Ic,c as gf,p as Xr,g as Jr,d as Bo,e as Bc,h as Mn,f as dn,j as Aa,A as Ia,k as vf,l as xf,n as bf,m as yf,o as Sf,t as wf,q as Cf,r as kf,s as jf,u as Zr,v as Nf,w as Ba,x as Ma,y as Ef,z as Tf,B as Pf,C as Rf,D as Mo,E as Cr,F as Lo,G as Mc,H as Lc,I as Df,J as Af,K as If,L as Bf,M as Mf,N as La,O as Lf,P as Of,Q as ji,R as $f,S as Oc,T as $c,U as zf}from"./agent-icon-B_ENO9HH.js";import{u as Ff}from"./use-status-sounds-jRgdHM6o.js";import{E as kr}from"./empty-state-vFbdMLGr.js";import{u as Hf,r as Ln,a as Wf,p as zc,f as Oa,b as Fc,c as Hc,d as Wc,e as Uf,F as Kf,i as Vf,g as qf,h as Gf,j as Yf,k as Xf}from"./tab-id-C7RjxJTr.js";import{g as Zs,A as Jf}from"./sortable.esm-Cra7DBkd.js";import{T as $a,a as On}from"./toolbar-C8PVd7Ds.js";import{R as Uc,a as Zf,b as Qf}from"./resizable-Dvc6mjD2.js";import{i as Hi,n as em}from"./Globe01-D6rc4c2I.js";import{i as Kc}from"./Monitor01-Co7esQF_.js";import{u as Wi,a as Oo,b as Vc}from"./use-connection-DDWrr0D8.js";import{u as Qr,a as tm,b as sm}from"./use-mcp-tools-WWdORF6E.js";import{u as im}from"./use-capability-xJktXQ3I.js";import{F as $o,M as zo}from"./file-type-icon-BilQa1o9.js";import{g as rm,d as qc,a as za,H as Gc,F as nm,b as om,f as am,u as lm,c as cm,e as hm,h as dm}from"./header-tab-button-2KdmhnCN.js";import{i as Yc,a as Fa,b as um}from"./ZoomOut-0Ur-V1Tn.js";import{P as Ts,a as Ps,b as Rs}from"./popover-DmAofN68.js";import{S as Xc}from"./spinner-ukxdHUOu.js";import{D as Qs,a as ei,b as ti,c as Ze,d as mr,e as fm,f as mm,g as pm}from"./dropdown-menu-Vxh4zyXD.js";import{D as Lt,a as Ot,b as ss,c as is,d as si,e as Fo}from"./dialog-qWglm5p2.js";import{I as Ve}from"./input-Cm-_5NLx.js";import{T as ys,a as Ho,b as Ni,c as Wo}from"./tabs-2u_8k4RO.js";import{T as jr}from"./textarea-C_bdHrQP.js";import{a as fs,s as _m}from"./Eye-Dj0PXl1o.js";import{t as en}from"./Stars01-D40cNl8a.js";import{l as gm,w as vm}from"./index-C-Ei6mai.js";import{i as xm}from"./ChevronRight-BPW30xu2.js";import{g as bm}from"./generate-id-1zLHnSNC.js";import{g as ym}from"./types-Durgfewm.js";import{U as Jc}from"./user-5EdNnZWa.js";import{T as Sm,u as Zc}from"./tools-list-Cr63qS_c.js";import{u as wm}from"./unwrap-tool-result-BYXdCQMg.js";import{s as Qc,g as Cm}from"./connection-slug-eyAPH6o3.js";import{A as Nr,a as Er,b as Tr,c as Pr,d as Rr,e as Dr,f as Ar,g as Ir}from"./alert-dialog-BGwOQ-hv.js";import{C as eh,a as $n}from"./card-B4WowcKq.js";import{L as kt}from"./label-CyHrJvd7.js";import{S as Pt,a as Rt,b as Dt,c as at,d as At}from"./select-2pE_Mne6.js";import{S as Br}from"./switch-DgVVL7zp.js";import{i as Ws}from"./Play-DOVnYSwF.js";import{s as Bt}from"./Plus-G5Gw5kPM.js";import{a as km}from"./Settings02-CtCQn3Yf.js";import{s as Bi}from"./Trash01-cARQt3ei.js";import{u as Mr}from"./use-debounced-autosave-X1JA0Sjb.js";import{S as tn}from"./scroll-area-BdohAM0t.js";import{i as Uo}from"./SearchMd-DM0EjhEJ.js";import{i as jm}from"./Upload01-Dmm1X5SO.js";import{i as Nm}from"./LayoutLeft-BrLgpS4_.js";import{P as Tt}from"./index-qXKJFTio.js";import{C as sn}from"./checkbox-DHuCa6fF.js";import{S as th}from"./search-input-BOsI1GRw.js";import{C as sh}from"./collection-tabs-azv2LaTo.js";import{u as Em}from"./use-mcp-prompts-OczkXrmo.js";import{D as Tm,a as Pm,b as Rm}from"./drawer-C6RzB17v.js";import{i as Ui}from"./Check-CWWWjir3.js";import{i as ih}from"./Key01-ZzkGvXus.js";import{S as xs}from"./skeleton-DekfpK4t.js";import{s as Dm}from"./User01-CqHZqKxf.js";import{t as Ko}from"./Users01-Dsn_tDG5.js";import{u as Am,a as Im}from"./use-secrets-6j_GId-n.js";import{G as Bm}from"./github-repo-picker-CtaqsXDt.js";import{f as Mm}from"./formatDistanceToNow-Cb2QZZJn.js";import{n as ii}from"./LinkExternal01-CYjY9tw_.js";import{A as Lm,a as Om,b as $m,c as zm}from"./accordion-C0j3DHtl.js";import{s as Us}from"./Star01-39vpRLS0.js";import{i as rh}from"./Stars02-LHx1LC9_.js";import{V as Fm}from"./view-mode-toggle-Df0p0wvc.js";import{n as nh}from"./ZapSquare-DVdUXxhF.js";import{i as Vo,a as Hm,b as qo}from"./Tool01-WQP4RZxz.js";import{c as oh,i as Wm}from"./SwitchHorizontal01-Sw4pGPNn.js";import{B as Um}from"./badge-5MzROStc.js";import{C as Km,a as Ha,b as Vm,c as qm,d as Gm,e as Ym}from"./command-BSLuC415.js";import{M as Xm}from"./select-model-CrWeciHf.js";import{u as Ki,a as Jm,b as Zm,c as Qm,d as ep}from"./use-automations-Dr8lwymn.js";import{i as ah}from"./RefreshCcw01-C5jOy04q.js";import{i as Mi}from"./Zap-jV52NH8a.js";import{M as tp}from"./monaco-editor-DpalAqoH.js";import{A as sp}from"./automation-runs-C92-yFsO.js";import{A as ip}from"./automation-list-row-BNAgjK8x.js";import{i as rp}from"./X-D7vVBDXl.js";function hi(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 np(t){return t?t.replace(/-\d{8}(?:-[a-z0-9]+)*$/i,"").replace(/-/g," "):"—"}function op(t){const e=W.c(4),{items:s}=t;let i;e[0]!==s?(i=s.map(ap),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 ap(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 lp(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 x;e[16]!==l?(x=l.toFixed(1),e[16]=l,e[17]=x):x=e[17];let b;e[18]!==x?(b=n.jsxs("div",{className:"flex items-center gap-1.5",children:[g,n.jsxs("span",{className:"text-xs text-muted-foreground",children:["Assistant ",x,"%"]})]}),e[18]=x,e[19]=b):b=e[19];let v;e[20]!==h||e[21]!==r?(v=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]=v):v=e[22];let y;e[23]!==b||e[24]!==v||e[25]!==_?(y=n.jsxs("div",{className:"flex flex-wrap gap-x-3 gap-y-1",children:[_,b,v]}),e[23]=b,e[24]=v,e[25]=_,e[26]=y):y=e[26];let S;return e[27]!==y||e[28]!==f?(S=n.jsxs("div",{className:"flex flex-col gap-2",children:[f,y]}),e[27]=y,e[28]=f,e[29]=S):S=e[29],S}function cp(t){const e=W.c(11),{agentId:s,isError:i}=t,r=Mt(s),o=r?.title??"Subtask",a=r?.icon??null;let l;e[0]!==a||e[1]!==o?(l=n.jsx(Gt,{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=ce("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 hp(t){const e=W.c(5),{isError:s}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=n.jsx(Gt,{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=ce("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 dp(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(hp,{isError:o}),e[0]=o,e[1]=l):l=e[1];let h;e[2]!==i||e[3]!==o?(h=n.jsx(cp,{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(Ce,{size:12,className:"animate-spin text-muted-foreground"}):o?n.jsx(Xu,{size:12,className:"text-destructive"}):a?n.jsx(Fi,{size:12,className:"text-warning"}):n.jsx(Tc,{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 up(t){const e=W.c(55),{onClose:s,back:i,className:r}=t,[o,a]=P.useState(null),{messages:l}=Ns(),{activeTask:h}=ts(),{selectedModel:c,selectedVirtualMcp:d}=Ao();let u,f,m,p,_,g,x,b;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){b=Symbol.for("react.early_return_sentinel");e:{const S=Zu(l),C=[...l].reverse().find(wp),j=C?.metadata?.usage,T=C?.metadata?.modelLimits?.contextWindow??c?.limits?.contextWindow??null,B=j?.contextTokens??0,I=T&&T>0?(B/T*100).toFixed(1):null,R=l;let k;e[16]!==R?(k=R.filter(Sp).reduce(yp,0),e[16]=R,e[17]=k):k=e[17];const w=k,A=l;let N;e[18]!==A?(N=A.filter(bp).reduce(xp,0),e[18]=A,e[19]=N):N=e[19];const E=N,M=Math.max(0,S.totalTokens-w-E),D=l[0],L=l.at(-1),z=D?.metadata?.created_at??h?.created_at,H=L?.metadata?.created_at??h?.updated_at,F=l.filter(vp),q=l.flatMap(_p),J=c?.modelId?np(c.modelId):"—",V=d?.title??"Decopilot",U=[{label:"Session",value:h?.title??"New chat"},{label:"Messages",value:F.length},{label:"Agent",value:V},{label:"Model",value:J},{label:"Context Limit",value:T?hi(T):"—"},{label:"Session Tokens (billed)",value:S.totalTokens>0?hi(S.totalTokens):"0"},{label:"Usage",value:I!==null?`${I}%`:"—"},{label:"Input Tokens",value:S.inputTokens>0?hi(S.inputTokens):"0"},{label:"Output Tokens",value:S.outputTokens>0?hi(S.outputTokens):"0"},{label:"Reasoning Tokens",value:S.reasoningTokens>0?hi(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(z)},{label:"Last Activity",value:Wa(H)}];if(!h&&F.length===0){let O;e[20]!==r?(O=ce("flex flex-col h-full w-full border-l border-border bg-background",r),e[20]=r,e[21]=O):O=e[21];let ee;e[22]===Symbol.for("react.memo_cache_sentinel")?(ee=n.jsx("span",{className:"text-sm font-medium text-foreground",children:"Context"}),e[22]=ee):ee=e[22];let te;e[23]!==i?(te=i?n.jsx(Ra,{size:14,className:"text-muted-foreground"}):n.jsx(ps,{size:14,className:"text-muted-foreground"}),e[23]=i,e[24]=te):te=e[24];let Y;e[25]!==s||e[26]!==te?(Y=n.jsxs("div",{className:"h-11 px-4 flex items-center justify-between shrink-0 border-b border-border/50",children:[ee,n.jsx("button",{type:"button",onClick:s,className:"flex size-6 items-center justify-center rounded hover:bg-accent transition-colors",children:te})]}),e[25]=s,e[26]=te,e[27]=Y):Y=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]!==O||e[30]!==Y?(ae=n.jsxs("div",{className:O,children:[Y,$]}),e[29]=O,e[30]=Y,e[31]=ae):ae=e[31],b=ae;break e}e[32]!==r?(g=ce("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 K;e[34]===Symbol.for("react.memo_cache_sentinel")?(K=n.jsx("span",{className:"text-sm font-medium text-foreground",children:"Context"}),e[34]=K):K=e[34];let Q;e[35]!==i?(Q=i?n.jsx(Ra,{size:14}):n.jsx(ps,{size:14}),e[35]=i,e[36]=Q):Q=e[36],e[37]!==s||e[38]!==Q?(x=n.jsxs("div",{className:"flex h-11 shrink-0 items-center justify-between border-b border-border/50 px-4",children:[K,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:Q})]}),e[37]=s,e[38]=Q,e[39]=x):x=e[39],u="flex flex-col gap-8 p-6",f=q.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:q.map(pp)})]}),m=n.jsx(op,{items:U});let oe;e[40]===Symbol.for("react.memo_cache_sentinel")?(oe=n.jsx("span",{className:"text-xs text-muted-foreground",children:"Context Breakdown"}),e[40]=oe):oe=e[40],e[41]!==E||e[42]!==M||e[43]!==w?(p=n.jsxs("div",{className:"flex flex-col gap-3",children:[oe,n.jsx(lp,{userTokens:w,assistantTokens:E,otherTokens:M})]}),e[41]=E,e[42]=M,e[43]=w,e[44]=p):p=e[44],_=F.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:F.map(O=>{const ee=O.metadata?.created_at,te=o?.id===O.id;return n.jsxs("div",{className:"rounded-md border border-border/50 overflow-hidden",children:[n.jsxs("button",{type:"button",onClick:()=>a(te?null:O),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:ce("shrink-0 font-medium",O.role==="user"?"text-chart-1":"text-chart-2"),children:O.role}),n.jsx("span",{className:"text-muted-foreground",children:"•"}),n.jsx("span",{className:"truncate text-muted-foreground font-mono",children:O.id})]}),ee&&n.jsx("span",{className:"shrink-0 text-muted-foreground tabular-nums",children:new Date(ee).toLocaleString("en-US",{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit"})})]}),te&&n.jsxs(n.Fragment,{children:[O.role==="assistant"&&(()=>{const Y=O.metadata?._request;if(!Y)return null;const $=Y.systemSections??[],ae=Math.max(1,...$.map(mp)),ue=$.reduce(fp,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:[Y.activeTools??0," / ",Y.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(ue/4).toLocaleString()," ","tok"]})]}),$.map((fe,he)=>{const re=fe.preview.match(/^<([a-z-]+)/i)?.[1]??`section ${he}`,ve=fe.chars/ae*100,ie=Math.round(fe.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:re}),n.jsxs("span",{className:"text-muted-foreground tabular-nums shrink-0",children:["~",ie.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:`${ve}%`}})})]},he)})]})]})})(),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(O,null,2)})]})]},O.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]=x,e[15]=b}else u=e[8],f=e[9],m=e[10],p=e[11],_=e[12],g=e[13],x=e[14],b=e[15];if(b!==Symbol.for("react.early_return_sentinel"))return b;let v;e[45]!==u||e[46]!==f||e[47]!==m||e[48]!==p||e[49]!==_?(v=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]=v):v=e[50];let y;return e[51]!==g||e[52]!==x||e[53]!==v?(y=n.jsxs("div",{className:g,children:[x,v]}),e[51]=g,e[52]=x,e[53]=v,e[54]=y):y=e[54],y}function fp(t,e){return t+e.chars}function mp(t){return t.chars}function pp(t,e){return n.jsx(dp,{part:t},e)}function _p(t){return(t.parts??[]).filter(gp)}function gp(t){return t.type==="tool-subtask"}function vp(t){return t.role!=="system"}function xp(t,e){const s=e.metadata?.usage;return t+(s?.outputTokens??0)}function bp(t){return t.role==="assistant"}function yp(t,e){const s=e.metadata?.usage;return t+(s?.inputTokens??0)}function Sp(t){return t.role==="user"}function wp(t){return t.role==="assistant"&&t.metadata?.usage}function Cp(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 kp(t){const e=W.c(25),{onOpenContextPanel:s}=t,{org:i}=Re(),{selectedVirtualMcp:r}=Ao();let o;e[0]!==i.id?(o=Do(i.id),e[0]=i.id,e[1]=o):o=e[1];const l=r??o,h=Mt(l.id),c=Ec(),{data:d}=qs.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(lf,{size:32}),e[2]=p):p=e[2];let _;e[3]!==l.icon||e[4]!==l.title?(_=n.jsx(Gt,{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 x=l.description??"Ask anything about configuring model providers or using MCP Mesh.";let b;e[8]!==x?(b=n.jsx("div",{className:"text-muted-foreground text-center text-base max-w-md line-clamp-2",children:x}),e[8]=x,e[9]=b):b=e[9];let v;e[10]!==_||e[11]!==g||e[12]!==b?(v=n.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 md:gap-4 text-center",children:[_,g,b]}),e[10]=_,e[11]=g,e[12]=b,e[13]=v):v=e[13];const y=c?.currentBranch??null;let S;e[14]!==h||e[15]!==y?(S=n.jsx(Bu,{virtualMcp:h,currentBranch:y}),e[14]=h,e[15]=y,e[16]=S):S=e[16];let C;e[17]!==s?(C=n.jsx(Oe.Input,{onOpenContextPanel:s}),e[17]=s,e[18]=C):C=e[18];let j;e[19]===Symbol.for("react.memo_cache_sentinel")?(j=n.jsx(Oe.IceBreakers,{}),e[19]=j):j=e[19];let T;return e[20]!==m||e[21]!==C||e[22]!==v||e[23]!==S?(T=n.jsx(Cp,{readOnly:m,identity:v,aboveRow:S,input:C,iceBreakers:j}),e[20]=m,e[21]=C,e[22]=v,e[23]=S,e[24]=T):T=e[24],T}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=ce(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=ce("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(Es,{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(jp)}),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 jp(t){return n.jsx(ef,{file:t},t.key)}function Np(){const t=W.c(13),e=Ec()?.taskId??null,s=Qu();let i;t[0]!==s?(i={enabled:s},t[0]=s,t[1]=i):i=t[1];const{data:r}=Pc(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(Tp),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(Ep),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 Ep(t){return!t}function Tp(t){return!t}function Pp(){const t=W.c(28),{org:e}=Re(),s=Rc(),{isChatEmpty:i}=Ns(),[r,o]=P.useState("chat"),a=Mu(),{selectedVirtualMcp:l}=Ao();let h;t[0]!==e.id?(h=Do(e.id),t[0]=e.id,t[1]=h):h=t[1];const u=Mt((l??h).id),f=Vu(),m=Js(u?.metadata);if(s.length===0&&!(m&&Lu(f))){let R;return t[2]===Symbol.for("react.memo_cache_sentinel")?(R=n.jsx(Oe,{className:"animate-in fade-in-0 duration-200",children:n.jsx(Oe.Main,{className:"flex flex-col items-center",children:n.jsx(Oe.EmptyState,{children:n.jsx(Oe.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&&!Ou(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 x;t[10]!==g?(x=g&&n.jsx(Oe.CreditsEmptyState,{}),t[10]=g,t[11]=x):x=t[11];const b=r!=="chat"?"opacity-0 pointer-events-none":"opacity-100";let v;t[12]!==b?(v=ce("absolute inset-0 flex flex-col transition-opacity duration-100 ease-out",b),t[12]=b,t[13]=v):v=t[13];let y;t[14]!==i?(y=i?n.jsx(Oe.Main,{children:n.jsx(kp,{onOpenContextPanel:()=>o("context")})}):n.jsxs(n.Fragment,{children:[n.jsxs(Oe.Main,{className:"relative flex flex-col overflow-hidden @container",children:[n.jsx(Np,{}),n.jsx("div",{className:"min-h-0 flex-1",children:n.jsx(Oe.Messages,{})})]}),n.jsx(Oe.Footer,{children:n.jsx(Oe.Input,{onOpenContextPanel:()=>o("context")})})]}),t[14]=i,t[15]=y):y=t[15];let S;t[16]!==v||t[17]!==y?(S=n.jsx("div",{className:v,children:y}),t[16]=v,t[17]=y,t[18]=S):S=t[18];const C=r==="context"?"opacity-100":"opacity-0 pointer-events-none";let j;t[19]!==C?(j=ce("absolute inset-0 flex flex-col transition-opacity duration-100 ease-out",C),t[19]=C,t[20]=j):j=t[20];let T;t[21]===Symbol.for("react.memo_cache_sentinel")?(T=n.jsx(up,{back:!0,onClose:()=>o("chat")}),t[21]=T):T=t[21];let B;t[22]!==j?(B=n.jsx("div",{className:j,children:T}),t[22]=j,t[23]=B):B=t[23];let I;return t[24]!==B||t[25]!==x||t[26]!==S?(I=n.jsxs(Oe,{className:"relative overflow-hidden animate-in fade-in-0 duration-200",children:[x,S,B]}),t[24]=B,t[25]=x,t[26]=S,t[27]=I):I=t[27],I}function lh(){const t=W.c(2);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsx(Oe.Skeleton,{}),t[0]=e):e=t[0];let s;return t[1]===Symbol.for("react.memo_cache_sentinel")?(s=n.jsx(Ut,{fallback:e,children:n.jsx(P.Suspense,{fallback:n.jsx(Oe.Skeleton,{}),children:n.jsx(Pp,{})})}),t[1]=s):s=t[1],s}function Rp(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 Dp(t,e){return t===1?!0:t===0?!1:e}function Ap(t,e){const s=es(),i=Po({strict:!1}),r=Sc({strict:!1}),{create:o}=Hf(),{locator:a}=Re(),{virtualMcpId:l,orgSlug:h,isAgentRoute:c}=e,d=Rp({entityMetadata:t,mainParamPresent:i.main!==void 0,mainParamValue:i.main}),u=Dp(i.chat,d.chatOpen),f=d.mainOpen,m=P.useRef(crypto.randomUUID()),p=r.taskId??m.current,_="/$org/$taskId",g=B=>({org:h,taskId:B}),x=c?{virtualmcpid:l}:{},b=(B,I)=>{s({to:_,params:g(p),search:R=>({...R,...B}),replace:I?.replace??!1})},v=(B,I)=>{s({to:_,params:g(B),search:R=>{const k={};return I?k.virtualmcpid=I:c&&(k.virtualmcpid=l),k}})},y=()=>{f?b({main:"0"},{replace:!0}):b({main:Ln(t)},{replace:!0})},S=()=>{b({chat:u?0:1},{replace:!0})},C=()=>{u||b({chat:1},{replace:!0})},j=async()=>{const B=crypto.randomUUID(),I=cf(h,a,p);try{await o({id:B,virtual_mcp_id:l,...I?{branch:I}:{}})}catch{}s({to:_,params:g(B),search:R=>({...x,chat:1})})},T=B=>{b({main:B},{replace:!0})};return{taskId:p,mainOpen:f,chatOpen:u,mainParam:i.main,setTaskId:v,toggleMain:y,toggleChat:S,openChat:C,createNewTask:j,openTab:T}}const Go=45;function ch(t,e=Go){const s=typeof t=="number"?t:Number(t);return!Number.isFinite(s)||s<=0||s>=100?e:s}function Ip(t){return ch(t,Go)}function Bp(){const t=W.c(6);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=ku.decoChatPanelWidth(),t[0]=e):e=t[0];const[s,i]=Cu(e,Ip);let r;t[1]!==s?(r=ch(s,Go),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 Mp(t){try{return JSON.parse(t)}catch{return null}}function Lp(t){if(!t||typeof t!="object")return null;const e=t,s=e.content?.find(o=>o.type==="text")?.text,i=s?Mp(s):null,r=e.structuredContent;return r==null?i:typeof r=="object"&&!Array.isArray(r)&&Object.keys(r).length===0?i??r:r}function Ds(t){const e=Lp(t);return e===null?null:e}function Yo(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 Op(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=Yo(s);return!i||!s?null:{number:i,htmlUrl:s}}const Va=/[\r\n<>]/,$p=/^[^\s@<>]+@[^\s@<>]+\.[^\s@<>]+$/;function Vi(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}:$p.test(s)?{userName:e,userEmail:s}:{userName:e}}function zp(t){return t.split(`
3
3
  `).filter(e=>!/^Co-authored-by:\s/i.test(e)).join(`
4
4
  `).trimEnd()}function Fp(t){const e=t.userName.trim(),s=t.userEmail?.trim();return s?`Co-authored-by: ${e} <${s}>`:`Co-authored-by: ${e}`}function hh(t,e){const s=Vi(e);if(!s)return t;const i=zp(t),r=Fp(s);if(i.includes(r))return i;const o=i.trimEnd();return o.length>0?`${o}
5
5
 
@@ -271,7 +271,7 @@ ${ee}`:ee;c.setValue("metadata.instructions",te,{shouldDirty:!0})},V=new Set(d.m
271
271
  8% { opacity: 1; }
272
272
  22% { opacity: 0; }
273
273
  }
274
- `}),e[26]=y):y=e[26];let S;return e[27]!==v||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,v,y]}),e[27]=v,e[28]=d,e[29]=S):S=e[29],S}function ir(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=ce("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 x;return e[6]!==r||e[7]!==f||e[8]!==g?(x=n.jsx("div",{"aria-hidden":f,className:m,style:g,children:r}),e[6]=r,e[7]=f,e[8]=g,e[9]=x):x=e[9],x}function nn(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:ce("size-2.5 rounded-full",wt)}),o=n.jsx("div",{className:ce("size-2.5 rounded-full",wt)}),a=n.jsx("div",{className:ce("size-2.5 rounded-full",wt)}),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:ce("ml-3 h-3.5 max-w-[220px] flex-1 rounded-sm",Ht)}),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 o1(){const t=W.c(2);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsx(nn,{}),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:e1.map(a1)})})]}),t[1]=s):s=t[1],s}function a1(t,e){if(e===Zh)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:ce("relative rounded-md",wt),children:n.jsx("div",{className:"absolute inset-0 rounded-md bg-chart-1/40 opacity-0",style:{animation:`vm-rack-scan ${Qh}s ease-in-out infinite`,animationDelay:`${s}s`}})},e)}function l1(){const t=W.c(5);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsx(nn,{}),t[0]=e):e=t[0];let s;t[1]===Symbol.for("react.memo_cache_sentinel")?(s=n.jsx("div",{className:ce("w-[18%] rounded-md",Ht),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:ce("rounded-md",Ht),style:{animation:"vm-breathe 3s ease-in-out 1.2s infinite"}}),n.jsx("div",{className:ce("rounded-md",Ht),style:{animation:"vm-breathe 3s ease-in-out 1.6s infinite"}})]})]})]})]})]}),t[4]=o):o=t[4],o}function c1(){const t=W.c(2);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsx(nn,{}),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:i1.map(h1)})})]}),t[1]=s):s=t[1],s}function h1(t,e){return n.jsx("div",{className:ce("aspect-square rounded-md",r1[e]?"bg-chart-2/70":wt),style:{animation:`vm-pulse-soft 2.2s ease-in-out ${t}s infinite`}},e)}function d1(){const t=W.c(11);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsx(nn,{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:ce("h-1.5 w-[70%] rounded-sm",wt)}),r=n.jsx("div",{className:ce("h-1.5 w-[55%] rounded-sm",wt)}),o=n.jsx("div",{className:ce("h-1.5 w-[80%] rounded-sm",wt)}),a=n.jsx("div",{className:ce("h-1.5 w-[50%] rounded-sm",wt)}),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:ce("h-4 rounded-md",wt)})})]}),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:ce("h-1.5 w-[55%] rounded-sm",Ht)})]})}),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:ce("h-4 w-10 rounded-full",Ht)}),n.jsx("div",{className:ce("h-4 w-14 rounded-full",Ht)})]}),t[8]=c):c=t[8];let d;t[9]===Symbol.for("react.memo_cache_sentinel")?(d=n.jsxs("div",{className:ce("col-span-3 flex flex-col justify-end gap-1 rounded-md p-2",Ht),children:[n.jsx("div",{className:ce("h-1.5 w-[50%] rounded-sm",wt)}),n.jsx("div",{className:ce("h-1 w-[75%] rounded-sm",wt)})]}),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:ce("rounded-md",Ht)}),n.jsx("div",{className:ce("rounded-md",Ht)})]})]})]})]})]})]}),t[10]=u):u=t[10],u}function Or(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(n1,{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(Nf,{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:Zv("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(Ws,{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(se,{onClick:t.onResume,className:"mt-2",children:[o," Resume"]})]})}),e[7]=t.onResume,e[8]=a):a=e[8],a}const u1=P.lazy(()=>qt(()=>import("./sections-editor-D-D4fXgu.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,150,151,152,153,154])).then(t=>({default:t.SectionsEditor}))),f1=P.lazy(()=>qt(()=>import("./page-seo-sheet-D3VNLk-W.js"),__vite__mapDeps([155,1,2,122,44,46,47,48,16,3,5,86,72,80,77,6,7,8,9,10,11,12,13,14,15,17,4,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,45,78,50,79,73,51,81,49,82,83,84,58,85,60,61,90,91,92,93,94,95,57,96,59,97,98,99,100,101,102,103,104,105,106,107,108,66,109,56,110,71,111,70,67,112,113,114,115,116,117,65,87,88,52,53,54,55,62,63,64,68,69,74,75,76,118,119,120,121,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,150,151,152,153])).then(t=>({default:t.SeoSheet}))),m1=P.lazy(()=>qt(()=>import("./file-explorer-DwYs1O3Y.js"),__vite__mapDeps([156,1,2,137,6,7,8,9,10,11,12,13,14,15,16,3,17,4,5,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,127,91,92,58,93,94,85,95,57,96,59,104,105,49,106,107,108,50,120,121,122,123,82,79,70,124,109,125,56,67,115,126,62,63,64,71,72,111,128,52,53,54,55,60,61,65,66,68,69,73,74,75,76,87,88,129,130,131,98,99,136,51,101,90,97,100,102,103,110,83,112,113,114,116,117,118,119,132,133,134,135,138,139,80,140,141,142,143,144,145,146,147,148,149,150,151,152,153])).then(t=>({default:t.FileExplorer}))),gn=500,p1={mobile:375,tablet:768,desktop:null},vn=["desktop","mobile","tablet"],_1={mobile:"Mobile (375px)",tablet:"Tablet (768px)",desktop:"Desktop"};function g1(t,e){const s=new URL(t,window.location.href);return s.searchParams.set("deviceHint",e),s.href}function v1(){const t=Qi(),{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),x=P.useRef(null),[b,v]=P.useState(!1),[y,S]=P.useState(""),C=P.useRef(null),[j,T]=P.useState(!1),[B,I]=P.useState(),[R,k]=P.useState(null),[w,A]=P.useState(null),[N,E]=P.useState("/"),[M,D]=P.useState(null),[L,z]=P.useState(!1),[H,F]=P.useState(!1),[q,J]=P.useState(null),V=t?.entity?.id??null,{org:U}=Re(),K=Yt(),Q=qh(),oe=Q.vmEntry,O=Q.previewUrl,ee=K.lifecycle.phase,te=ee==="running",Y=V&&e&&te?{orgSlug:U.slug,virtualMcpId:V,branch:e}:null,{data:$}=ea(Y,{fetchEnabled:te}),{data:ae}=ta(Y,{fetchEnabled:te}),ue=V&&e?{orgSlug:U.slug,virtualMcpId:V,branch:e}:null,fe=Hv(ue),he=$?aa($).sort((Z,ge)=>Z.name.localeCompare(ge.name)):[],re=$&&ae?la($,ae):[],ve=Fs,ie=he.filter(Z=>{if(!y)return!0;const ge=y.toLowerCase();return Z.name.toLowerCase().includes(ge)||Z.path.toLowerCase().includes(ge)}),ke=re.filter(Z=>{if(!y)return!0;const ge=y.toLowerCase();return Z.name.toLowerCase().includes(ge)||Z.key.toLowerCase().includes(ge)||Z.resolveType.toLowerCase().includes(ge)}),lt=R?null:y_(he,N,M),Ie=R?R.name:lt?.name,mt=lt?.key??null,os=P.useRef(null),G=P.useRef(null);A_(()=>{const Z=h.current,ge=os.current;!Z||!ge||(Z.src=ge)});const pe=K.status.state==="paused",xe=K.phase,Se=Jh({claimPhase:xe,lifecycle:K.lifecycle}),we=Q.previewState,tt=Q.userStopped,xt=we.kind==="iframe"?g1(w??new URL(N,we.previewUrl).href,r):null,[er,tr]=P.useState(null);if(we.kind==="iframe"&&er!==we.previewUrl){const Z=er!==null;tr(we.previewUrl),Z&&(G.current=null,E("/"),A(null),D(null),k(null))}os.current=xt;const _e=!!V&&!!e&&!K.notFound&&!tt&&!pe&&(xe?.kind==="ready"||ee!=="idle"),je=we.kind!=="iframe"&&(s==="visual"||s==="cms")?"preview":s;P.useEffect(()=>{if(!O)return;let Z;try{Z=new URL(O,window.location.href).origin}catch{return}const ge=rt=>{if(rt.origin===Z){if(rt.data?.type==="visual-editor::element-clicked"){const nt=Uv.safeParse(rt.data.payload);nt.success&&l(nt.data)}else if(rt.data?.type==="cms-editor::section-clicked"){const nt=Vv.safeParse(rt.data.payload);nt.success&&u(nt.data.sectionIndex)}}};return window.addEventListener("message",ge),()=>window.removeEventListener("message",ge)},[O]),P.useEffect(()=>{if(!b)return;const Z=ge=>{C.current?.contains(ge.target)||(v(!1),S(""))};return document.addEventListener("pointerdown",Z),()=>document.removeEventListener("pointerdown",Z)},[b]),P.useEffect(()=>{if(!c)return;const Z=rt=>{const nt=rt.target;nt&&nt!==h.current&&(x.current=nt)},ge=()=>{requestAnimationFrame(()=>{const rt=document.activeElement;(rt===document.body||rt===h.current)&&x.current&&x.current.focus()})};return document.addEventListener("focusin",Z),document.addEventListener("blur",ge,!0),()=>{document.removeEventListener("focusin",Z),document.removeEventListener("blur",ge,!0)}},[c]);const st=()=>{const Z=h.current?.contentWindow;Z&&Z.postMessage({type:"visual-editor::activate",script:Kv},"*")},bt=()=>{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:qv},"*")},mu=()=>{const Z=h.current?.contentWindow;Z&&Z.postMessage({type:"cms-editor::deactivate"},"*")},ci=Z=>{const ge=s;i(Z),l(null),Z!=="code"&&J(null),Z!=="cms"&&u(null),ge==="visual"&&bt(),ge==="cms"&&mu(),Z==="visual"&&st(),Z==="cms"&&it()},pu=()=>{if(!h.current||!xt)return;const Z=h.current;Z.src=xt},_u=()=>{if(!h.current||!xt)return;const Z=xt.includes("?")?"&":"?";h.current.src=`${xt}${Z}_r=${Date.now()}`},gu=()=>{const Z=vn.indexOf(r);o(vn[(Z+1)%vn.length])},vu=()=>{const Z=h.current?.contentWindow?.location?.href??xt??O;Z&&navigator.clipboard.writeText(Z)},xu=(()=>{if(!O)return"No server running";if(R)return R.name;try{const Z=new URL(O),ge=N==="/"?"":N;return`${Z.host}${ge}`}catch{return O}})(),Ta=Z=>{G.current=Z.path,k(null),A(null),D(Z.key),E(Z.path),u(null),z(!1)},bu=Z=>{if(!O||!ae){le.error("Preview metadata not ready yet");return}G.current=null;const ge=Nh(ae),rt=Ov(O,ge,Z.key);k(Z),A(rt),u(null)},yu=async({name:Z,path:ge})=>{if(!V||!e)return;const rt=ra(ge);if(rt){I(rt);return}const nt=ge.trim().startsWith("/")?ge.trim():`/${ge.trim()}`;if(he.some(Nt=>ve(Nt.path)===ve(nt))){I(`A page with path "${nt}" already exists.`);return}I(void 0);try{const Nt=await fe.mutateAsync({name:Z,path:nt});T(!1),le.success(`Page "${Z}" created`),await new Promise(wu=>setTimeout(wu,gn)),Ta({key:Nt.key,name:Nt.name,path:Nt.path}),ci("cms")}catch(Nt){I(Nt instanceof Error?Nt.message:"Failed to create page")}},Su=[{value:"preview",icon:n.jsx(Ba,{size:14}),tooltip:"Interactive"},...we.kind==="iframe"?[{value:"visual",icon:n.jsx(Ma,{size:14}),tooltip:"Visual editor"}]:[],...we.kind==="iframe"&&oa($,ae)?[{value:"cms",icon:n.jsx(Ef,{size:14}),tooltip:"Sections editor"}]:[],{value:"code",icon:n.jsx(Tf,{size:14}),tooltip:"Code editor"}];return n.jsxs("div",{className:"flex flex-col w-full h-full",children:[_e&&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(Fm,{value:je,onValueChange:ci,options:Su,size:"sm",className:"shrink-0 bg-foreground/4.5"})}),we.kind==="iframe"&&n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:ce("flex min-w-0 flex-1 items-center gap-0.5 ml-2",s==="code"&&"hidden"),children:[n.jsxs(Pe,{children:[n.jsx(Ee,{asChild:!0,children:n.jsx(se,{variant:"ghost",size:"icon",onClick:pu,children:n.jsx(Ai,{size:14})})}),n.jsx(Te,{side:"bottom",children:"Refresh"})]}),n.jsxs(Pe,{children:[n.jsx(Ee,{asChild:!0,children:n.jsx(se,{variant:"ghost",size:"icon",onClick:gu,children:n.jsxs("span",{className:"flex items-center justify-center animate-device-icon-pop",children:[r==="mobile"&&n.jsx(Pf,{size:14}),r==="tablet"&&n.jsx(Rf,{size:14}),r==="desktop"&&n.jsx(Ba,{size:14})]},r)})}),n.jsx(Te,{side:"bottom",children:_1[r]})]}),n.jsxs("div",{ref:C,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:()=>v(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(Us,{size:11}),"Global"]}),n.jsx("span",{className:"min-w-0 flex-1 truncate text-left text-[12px] text-foreground/88",children:xu}),Ie&&!R&&n.jsx("span",{className:"shrink-0 text-[12px] text-muted-foreground",children:Ie}),n.jsx(Es,{size:12,className:ce("shrink-0 text-muted-foreground transition-transform",b&&"rotate-180")})]}),b&&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(rh,{size:14,className:"shrink-0 text-muted-foreground","aria-hidden":!0}),n.jsx("input",{type:"text",value:y,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(),v(!1),S(""),I(void 0),T(!0)},children:[n.jsx(Bt,{size:16,className:"shrink-0 text-muted-foreground"}),n.jsx("span",{className:"flex-1 font-medium",children:"Create new page"})]})}),ie.length===0&&ke.length===0?n.jsx("div",{className:"px-4 py-5 text-center text-xs text-muted-foreground",children:he.length===0&&re.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:[ie.length>0&&n.jsx("div",{className:"p-1.5",children:ie.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:ge=>{ge.preventDefault(),v(!1),S(""),Ta(Z)},children:[n.jsx(Mo,{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))}),ke.length>0&&n.jsxs("div",{className:ce("p-1.5",ie.length>0&&"border-t"),children:[n.jsx("div",{className:"px-3 py-2 text-xs font-medium text-muted-foreground",children:"Global components"}),ke.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:ge=>{ge.preventDefault(),v(!1),S(""),bu(Z)},children:[n.jsx(Us,{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:ce("flex shrink-0 items-center gap-0.5",s==="code"&&"hidden"),children:[n.jsxs(Pe,{children:[n.jsx(Ee,{asChild:!0,children:n.jsx(se,{variant:"ghost",size:"icon",onClick:()=>{const Z=xt??we.previewUrl;Z&&window.open(Z,"_blank","noopener")},children:n.jsx(ii,{size:14})})}),n.jsx(Te,{side:"bottom",children:"Open in new tab"})]}),n.jsxs(Qs,{children:[n.jsx(ei,{asChild:!0,children:n.jsx(se,{variant:"ghost",size:"icon",children:n.jsx(Zr,{size:14})})}),n.jsxs(ti,{align:"end",className:"w-44",children:[n.jsx(Ze,{onClick:_u,children:"Hard Reload"}),n.jsx(Ze,{onClick:vu,children:"Copy Current URL"}),$&&ae&&n.jsxs(n.Fragment,{children:[n.jsx(mr,{}),mt&&n.jsxs(Ze,{onClick:()=>{z(!0),ci("cms")},children:[n.jsx(Cr,{size:14}),"Edit SEO"]}),mt&&n.jsxs(Ze,{onClick:()=>{try{J(za(mt)),ci("code")}catch{le.error("Invalid page block key")}},children:[n.jsx(Lo,{size:14}),"View JSON"]}),n.jsxs(Ze,{onClick:()=>F(!0),children:[n.jsx(Cr,{size:14}),"Site SEO"]})]})]})]})]})]})]}),n.jsxs("div",{className:"flex-1 flex overflow-hidden",children:[c&&O&&e&&V&&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(Ce,{size:20,className:"animate-spin text-muted-foreground"})}),children:n.jsx(u1,{orgSlug:U.slug,virtualMcpId:V,branch:e,previewReady:te,previewUrl:O,currentPath:N,activePageBlockKey:mt,activeGlobalBlockKey:R?.key??null,externalSelectedIndex:R?null:d,onSaved:()=>{setTimeout(()=>{const Z=h.current;if(!Z)return;const ge=document.activeElement,rt=Z.tabIndex;Z.tabIndex=-1,Z.style.pointerEvents="none",Z.blur();try{Z.contentWindow?.location.reload()}catch{const Nt=os.current;Nt&&(Z.src=Nt)}const nt=()=>{Z.tabIndex=rt,Z.style.pointerEvents="",ge?.focus(),Z.removeEventListener("load",nt)};Z.addEventListener("load",nt),setTimeout(nt,3e3)},gn)},initialEditSeo:L,onExitSeo:()=>z(!1),onViewJsonFile:Z=>{try{J(za(Z)),ci("code")}catch{le.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 ge=Z.clientX-_.current;m(Math.max(240,Math.min(640,g.current+ge)))},onPointerUp:()=>{p.current=!1}})]}),n.jsxs("div",{className:ce("flex-1 relative overflow-hidden",r!=="desktop"&&we.kind==="iframe"&&s!=="code"&&"flex justify-center bg-muted/30"),children:[we.kind==="starting"&&n.jsx("div",{className:"absolute inset-0 z-30",children:n.jsx(Or,{kind:"starting",progress:Se,claimPhase:xe})}),we.kind==="suspended"&&n.jsx("div",{className:"absolute inset-0 z-30",children:n.jsx(Or,{kind:"suspended",onResume:Q.resume})}),je==="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"]}),je==="visual"&&a&&n.jsx(Xv,{element:a,onDismiss:()=>l(null)}),s==="code"&&_e&&V&&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(Ce,{size:20,className:"animate-spin text-muted-foreground"})}),children:n.jsx(m1,{orgSlug:U.slug,virtualMcpId:V,branch:e,openPath:q})})}),we.kind==="iframe"&&xt&&n.jsx("div",{className:ce("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%":`${p1[r]}px`},children:n.jsx("iframe",{ref:h,src:xt,className:ce("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:oe?.sandboxHandle??null}),!R)try{const Z=h.current?.contentWindow?.location?.pathname;if(!Z)return;const ge=G.current;if(ge!==null){G.current=null,ve(Z)===ve(ge)&&E(Z);return}E(Z)}catch{}s==="visual"&&st(),s==="cms"&&it()}},we.previewUrl)})]})]}),n.jsx(Wv,{open:j,onOpenChange:T,isPending:fe.isPending,error:B,onSubmit:yu}),H&&$&&ae&&n.jsx(P.Suspense,{fallback:null,children:n.jsx(f1,{open:H,onOpenChange:F,orgSlug:U.slug,virtualMcpId:V??"",branch:e??"",decofile:$,meta:ae,onSaved:()=>{setTimeout(()=>{const Z=h.current;if(Z)try{Z.contentWindow?.location.reload()}catch{const ge=os.current;ge&&(Z.src=ge)}},gn)},target:{kind:"site"}})})]})}function x1(t){const e=W.c(2),{virtualMcpId:s}=t,i=Mt(s);if(!Js(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(v1,{}),e[1]=o):o=e[1],o}function b1(t,e){if(!t||!e?.length)return t;const s=Object.fromEntries(Object.entries(t.properties??{}).filter(([i])=>!e.includes(i)));return Object.keys(s).length>0?{...t,properties:s}:t}function y1(t,e,s){return typeof t!="string"?null:b1(Ch(t,e),s)}function ed(t,e,s){if(!e||typeof t!="string")return!1;const i=y1(t,e,s);return!!i&&Object.keys(i.properties??{}).length>0}function S1({orgSlug:t,virtualMcpId:e,branch:s}){const i=Ys();return Xs({mutationFn:async({blockKey:r})=>{const o=qc(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=It.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:It.liveMeta(r)})}})}function on(t,e){return`${t}-${e}`}function ma(t,e){return`site/apps/${t}/${e}.ts`}function pa(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 td(t,e,s){const i=new Set([on(t,e),e].map(o=>o.toLowerCase())),r=ma(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 w1(t,e){const s=t.vendor.alias,i=t.name,r=td(s,i,e);return{id:on(s,i),app:i,vendor:s,title:t.title||t.name,description:t.description,category:t.category??"Other",logo:t.logo||void 0,resolveType:ma(s,i),blockKey:r,installed:r!==null}}function C1(t,e,s){if(t===Ei)return null;const i=pa(t);if(!i)return null;const{vendor:r,app:o}=i,a=td(r,o,s),l=qi(t,e);return{id:on(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 k1(t,e,s){const i=new Map;for(const o of t){const a=w1(o,s);i.set(a.id,a)}const r=e.manifest?.blocks?.apps??{};for(const o of Object.keys(r)){const a=C1(o,e,s);!a||i.has(a.id)||i.set(a.id,a)}for(const o of E1(s,e)){const a=pa(o.resolveType);if(!a)continue;const l=on(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(j1)}function j1(t,e){return t.installed!==e.installed?t.installed?-1:1:t.title.localeCompare(e.title)}function N1(t,e,s){const i=t.manifest?.blocks?.apps??{};for(const r of[ma(e,s),`site/apps/${e}/${s}.tsx`,`${e}/apps/${s}.ts`,`${e}/apps/${s}.tsx`])if(r in i)return!0;return!1}function E1(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"||Ph(i,o))continue;const l=pa(a)??(()=>{const h=i.match(/^([^-]+)-(.+)$/);return h?{vendor:h[1],app:h[2]}:null})();!l||!N1(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 T1(){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 P1(t,e,s){const i=W.c(12),r=s?.enabled??!0;let o;i[0]===Symbol.for("react.memo_cache_sentinel")?(o=It.decoApps(),i[0]=o):o=i[0];let a;i[1]!==r?(a={queryKey:o,queryFn:T1,staleTime:3e5,retry:1,enabled:r},i[1]=r,i[2]=a):a=i[2];const l=Gs(a);let h;i[3]!==e||i[4]!==t||i[5]!==l.data?(h=t&&e?k1(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 R1=new Set(["website/pages/Page.tsx","$live/pages/LivePage.tsx"]);function D1(t){return t.includes("matchers")||t.includes("Match")}function A1(t,e){const s=t.__resolveType;return typeof s!="string"||!s||R1.has(s)?!1:e?h_(e,s):D1(s)}function Gi(t,e,s){if(!t)return!1;const i=t.__resolveType;if(typeof i!="string"||!ia(i)||!Object.hasOwn(e,i))return!1;const r=e[i];return!r||typeof r!="object"||Array.isArray(r)?!1:A1(r,s)}function yC(t,e,s){return Gi(t,e,s)?t?.__resolveType??null:null}function sd(t,e,s){if(!t)return null;const i=t.__resolveType??"";if(!i)return null;if(Gi(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 I1(t,e,s){const i=sd(t,e,s);return i?{__resolveType:i.resolveType,...i.data}:{__resolveType:""}}function SC(t,e,s){if(t)return Gi(t,e,s)?I1(t,e,s):t}function B1(t,e,s,i){if(!t)return"Default";if(Gi(t,e,i)){const r=t.__resolveType??"",o=e[r];return Rh(r,o)}return s(t)}function wC(t,e,s){return{__resolveType:t,...e,name:s}}function CC(t){return{__resolveType:t}}function kC(t,e,s){const i=sd(t,e,s);return i?{resolveType:i.resolveType,formValue:i.data}:{resolveType:"",formValue:{}}}function id(t){const e=t.__resolveType??"";return Qt(e)?t.section??t:t}function $r(t){const r=(Qt(t.__resolveType??"")?t.section:t)?.variants?.[0];return r?.rule?.__resolveType!==xh?null:r?.value??null}function jC(t){const e=id(t);return{__resolveType:u_,variants:[{value:e,rule:{__resolveType:xh}}]}}function NC(t){const e=t.__resolveType??"";if(!e)return null;if(Qt(e))return t.section??null;const s=$r(t);return s?Qt(s.__resolveType??"")?s:{__resolveType:Xa,section:id(s)}:{__resolveType:Xa,section:t}}function rr(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 EC(t){const e=$r(t);if(e)return rr(e);if(Qt(t.__resolveType??"")){const i=t.section;if(!i)return null;const r=$r(i);return rr(r||i)}return rr(t)}function TC(t){return $r(t)}const M1=["website/matchers/always.ts","$live/matchers/MatchAlways.ts"];function rd(t){if(!t)return!1;const e=t.__resolveType??"";return e===""?Object.keys(t).length===0:M1.includes(e)||e.includes("always")}function L1(t){const e=t.variants??[];if(e.length===0)return-1;const s=e.findIndex(i=>rd(i.rule));return s!==-1?s:e.length-1}function PC(t,e,s){const i=s.variants??[];if(i.length===0)return null;const r=L1(s),o=i[r]?.value;if(!o)return null;const a=structuredClone(o);return e.isLazy?{...t,section:a}:a}function RC(t,e){return e.isMultivariate?e.isLazy?t.section??null:t:null}function DC(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 AC(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 O1(t,e){const s=t.__resolveType??"";return Qt(s)?{...t,section:e}:e}function IC(t,e,s){return e.isLazy?{...t,section:s}:s}function BC(t,e,s){const i=[...t.variants??[]],r=i[e];if(!r)return t;const o=r.value??{};return i[e]={...r,value:O1(o,s)},{...t,variants:i}}function MC(t,e,s){const i=[...t.variants??[]];return i[e]?(i[e]={...i[e],rule:s},{...t,variants:i}):t}function LC(t,e){const s=[...t.variants??[]],i=s[e];return i?(s.splice(e+1,0,structuredClone(i)),{...t,variants:s}):t}function OC(t,e){const s=[...t.variants??[]];return s.length<=1?null:(s.splice(e,1),{...t,variants:s})}const $1=new Set(["website/pages/Page.tsx","$live/pages/LivePage.tsx"]);function $C(t){return t.anyOfRefs?.some(e=>e.resolveType!==rn?!1:e.schema?.properties?.variants?.items?.properties?.value?.type==="array")??!1}function nd(t){return!t||typeof t!="object"||Array.isArray(t)?!1:t.__resolveType===rn}function zC(t){if(!nd(t))return null;const e=t.variants;if(!Array.isArray(e))return null;const s=e[0]?.value;return Array.isArray(s)?s:null}function FC(t,e){if(!nd(t))return e;const s=structuredClone(t),i=[...s.variants??[]];return i.length===0?i.push({rule:ad(),value:e}):i[0]={...i[0],value:e},{...s,variants:i}}function z1(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;const e=t;return typeof e.__resolveType=="string"&&$1.has(e.__resolveType)&&typeof e.path=="string"}function od(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 F1(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 HC(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=>B1(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 ad(){return{__resolveType:d_}}function di(t){return{rule:ad(),value:t}}function Hs(t,e){return{...e,__resolveType:rn,variants:t}}function H1(t,e){const s=structuredClone(e);if(Array.isArray(t))return Hs([di(t),di(s)]);if(t&&typeof t=="object"){const i=t;return Array.isArray(i.variants)?Hs([...i.variants,di(s)],i):null}return Hs([di([]),di(s)])}function WC(t){const e=t.variants;return Array.isArray(e)?e.length-1:1}function UC(t,e){if(e.length===0)return Hs([],t);if(e.length===1){const s=e[0],i=s?.rule;if(!rd(i))return Hs(e,t);if(Array.isArray(s?.value))return s.value}return Hs(e,t)}function W1(t,e){for(const[s,i]of Object.entries(t)){if(!z1(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 KC(t,e,s){let i=0;return W1(t,r=>{if(!r)return;(r.__resolveType??"")===e&&Gi(r,t,s)&&i++}),i}function ul(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 U1(t,e){const s=Fs,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 fl(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 K1(t){const e=ua(t.newName),s={...t.source,name:t.newName,path:t.newPath};return{key:e,data:s}}function V1(t,e){return Yh(t,e)}const q1=1e3;function G1(t,e){for(let s=0;s<q1;s++){const i=ua(e);if(!Object.hasOwn(t,i))return i}throw new Error("Could not generate a unique page block key")}const Y1={create:"Create new page",duplicate:"Duplicate page",rename:"Rename page"},X1={create:"Create",duplicate:"Duplicate",rename:"Save"},J1={create:"Creating…",duplicate:"Duplicating…",rename:"Saving…"};function Z1(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,x]=P.useState(null),[b,v]=P.useState(s);s!==b&&(v(s),s&&(m(r),_(o),x(null)));let y;e[0]!==u||e[1]!==d?(y=K=>{!K&&!u&&(x(null),d(!1))},e[0]=u,e[1]=d,e[2]=y):y=e[2];const S=y;let C;e[3]!==u||e[4]!==f||e[5]!==c||e[6]!==p||e[7]!==h?(C=async K=>{K.preventDefault();const Q=f.trim(),oe=p.trim();if(!Q||!oe||u)return;const O=ra(oe);if(O){x(O);return}const ee=h?.({name:Q,path:oe});if(ee){x(ee);return}x(null),await c({name:Q,path:oe})},e[3]=u,e[4]=f,e[5]=c,e[6]=p,e[7]=h,e[8]=C):C=e[8];const j=C,T=g??l,B=Y1[i];let I;e[9]!==B?(I=n.jsx(ss,{children:n.jsx(is,{children:B})}),e[9]=B,e[10]=I):I=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 k;e[12]===Symbol.for("react.memo_cache_sentinel")?(k=K=>m(K.target.value),e[12]=k):k=e[12];let w;e[13]!==u||e[14]!==f?(w=n.jsxs("div",{className:"space-y-1.5",children:[R,n.jsx(Ve,{id:"page-form-name",value:f,onChange:k,placeholder:"My page",autoFocus:!0,disabled:u})]}),e[13]=u,e[14]=f,e[15]=w):w=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 N;e[17]===Symbol.for("react.memo_cache_sentinel")?(N=K=>_(K.target.value),e[17]=N):N=e[17];let E;e[18]!==u||e[19]!==p?(E=n.jsxs("div",{className:"space-y-1.5",children:[A,n.jsx(Ve,{id:"page-form-path",value:p,onChange:N,placeholder:"/example",disabled:u})]}),e[18]=u,e[19]=p,e[20]=E):E=e[20];let M;e[21]!==T?(M=T&&n.jsx("p",{className:"text-xs text-destructive",children:T}),e[21]=T,e[22]=M):M=e[22];let D;e[23]!==E||e[24]!==M||e[25]!==w?(D=n.jsxs("div",{className:"space-y-4 py-4",children:[w,E,M]}),e[23]=E,e[24]=M,e[25]=w,e[26]=D):D=e[26];let L;e[27]!==d?(L=()=>d(!1),e[27]=d,e[28]=L):L=e[28];let z;e[29]!==u||e[30]!==L?(z=n.jsx(se,{type:"button",variant:"outline",onClick:L,disabled:u,children:"Cancel"}),e[29]=u,e[30]=L,e[31]=z):z=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 F;e[36]!==u||e[37]!==i?(F=u?n.jsxs(n.Fragment,{children:[n.jsx(Ce,{size:14,className:"animate-spin"}),J1[i]]}):X1[i],e[36]=u,e[37]=i,e[38]=F):F=e[38];let q;e[39]!==H||e[40]!==F?(q=n.jsx(se,{type:"submit",disabled:H,children:F}),e[39]=H,e[40]=F,e[41]=q):q=e[41];let J;e[42]!==z||e[43]!==q?(J=n.jsxs(si,{children:[z,q]}),e[42]=z,e[43]=q,e[44]=J):J=e[44];let V;e[45]!==j||e[46]!==D||e[47]!==J||e[48]!==I?(V=n.jsx(Ot,{className:"sm:max-w-md",children:n.jsxs("form",{onSubmit:j,children:[I,D,J]})}),e[45]=j,e[46]=D,e[47]=J,e[48]=I,e[49]=V):V=e[49];let U;return e[50]!==S||e[51]!==s||e[52]!==V?(U=n.jsx(Lt,{open:s,onOpenChange:S,children:V}),e[50]=S,e[51]=s,e[52]=V,e[53]=U):U=e[53],U}function Q1(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=E=>{!E&&!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 E=>{E.preventDefault();const M=c.trim();!M||h||await a(M)},e[3]=h,e[4]=c,e[5]=a,e[6]=_):_=e[6];const g=_;let x;e[7]===Symbol.for("react.memo_cache_sentinel")?(x=n.jsxs(ss,{children:[n.jsx(is,{children:"Rename section"}),n.jsx(Fo,{children:"Updates the display name. The internal key stays the same so pages referencing this section keep working."})]}),e[7]=x):x=e[7];let b;e[8]===Symbol.for("react.memo_cache_sentinel")?(b=n.jsx("label",{htmlFor:"section-rename-name",className:"text-xs font-medium text-muted-foreground",children:"Name"}),e[8]=b):b=e[8];let v;e[9]===Symbol.for("react.memo_cache_sentinel")?(v=E=>d(E.target.value),e[9]=v):v=e[9];let y;e[10]!==h||e[11]!==c?(y=n.jsxs("div",{className:"space-y-1.5",children:[b,n.jsx(Ve,{id:"section-rename-name",value:c,onChange:v,autoFocus:!0,disabled:h})]}),e[10]=h,e[11]=c,e[12]=y):y=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 C;e[14]!==i?(C=n.jsxs("div",{className:"space-y-1.5",children:[S,n.jsx(Ve,{value:i,readOnly:!0,disabled:!0,className:"font-mono"})]}),e[14]=i,e[15]=C):C=e[15];let j;e[16]!==y||e[17]!==C?(j=n.jsxs("div",{className:"space-y-4 py-4",children:[y,C]}),e[16]=y,e[17]=C,e[18]=j):j=e[18];let T;e[19]!==l?(T=()=>l(!1),e[19]=l,e[20]=T):T=e[20];let B;e[21]!==h||e[22]!==T?(B=n.jsx(se,{type:"button",variant:"outline",onClick:T,disabled:h,children:"Cancel"}),e[21]=h,e[22]=T,e[23]=B):B=e[23];let I;e[24]!==h||e[25]!==c?(I=!c.trim()||h,e[24]=h,e[25]=c,e[26]=I):I=e[26];let R;e[27]!==h?(R=h?n.jsxs(n.Fragment,{children:[n.jsx(Ce,{size:14,className:"animate-spin"}),"Saving…"]}):"Save",e[27]=h,e[28]=R):R=e[28];let k;e[29]!==I||e[30]!==R?(k=n.jsx(se,{type:"submit",disabled:I,children:R}),e[29]=I,e[30]=R,e[31]=k):k=e[31];let w;e[32]!==B||e[33]!==k?(w=n.jsxs(si,{children:[B,k]}),e[32]=B,e[33]=k,e[34]=w):w=e[34];let A;e[35]!==g||e[36]!==j||e[37]!==w?(A=n.jsx(Ot,{className:"sm:max-w-md",children:n.jsxs("form",{onSubmit:g,children:[x,j,w]})}),e[35]=g,e[36]=j,e[37]=w,e[38]=A):A=e[38];let N;return e[39]!==p||e[40]!==s||e[41]!==A?(N=n.jsx(Lt,{open:s,onOpenChange:p,children:A}),e[39]=p,e[40]=s,e[41]=A,e[42]=N):N=e[42],N}const xn={post:"blog/loaders/Blogpost.ts",author:"blog/loaders/Author.ts",category:"blog/loaders/Category.ts"},ex="blog/sections/blocks/",_a=["posts","authors","categories"],Ti={posts:"post",authors:"author",categories:"category"};function Pi(t){return _a.includes(t)}const ga={posts:"post",authors:"author",categories:"category"},ld={posts:xn.post,authors:xn.author,categories:xn.category},tx=Object.fromEntries(Object.entries(ld).map(([t,e])=>[e,t]));function sx(t){return typeof t=="string"?tx[t]??null:null}function zr(t){return t&&typeof t=="object"&&!Array.isArray(t)?t:null}function Ms(t){return typeof t=="string"?t:""}function ix(t,e){switch(t){case"posts":return{label:Ms(e.title)||"Untitled post",subtitle:Ms(e.slug)};case"authors":return{label:Ms(e.name)||"Unnamed author",subtitle:Ms(e.email)};case"categories":return{label:Ms(e.name)||"Unnamed category",subtitle:Ms(e.slug)};default:{const s=t;throw new Error(`Unhandled blog kind: ${String(s)}`)}}}function cd(t){const e={posts:[],authors:[],categories:[]};for(const[s,i]of Object.entries(t)){const r=zr(i);if(!r)continue;const o=sx(r.__resolveType);if(!o)continue;const a=zr(r[ga[o]])??{},{label:l,subtitle:h}=ix(o,a);e[o].push({key:s,kind:o,label:l,subtitle:h})}for(const s of _a)e[s].sort((i,r)=>i.label.localeCompare(r.label));return e}function rx(t,e){return cd(t)[e]}function VC(t,e){return rx(t,e).map(s=>({key:s.key,payload:hd(zr(t[s.key])??void 0,e)}))}function hd(t,e){return t?zr(t[ga[e]])??{}:{}}function ml(t,e,s){return{name:t,__resolveType:ld[e],[ga[e]]:s}}function dd(t){return`.deco/blocks/${encodeURIComponent(t)}.json`}function Un(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 pl(t,e){const s=`collections/blog/${e}/${Un(12)}`;if(!Object.hasOwn(t,s))return s;throw new Error("Could not generate a unique blog block key")}function nx(t){switch(t){case"posts":return{title:"Untitled post",excerpt:"",slug:`untitled-${Un(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-${Un(8)}`};default:{const e=t;throw new Error(`Unhandled blog kind: ${String(e)}`)}}}function qC(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(ex)||e.has(o))continue;e.add(o);const a=qi(o,t);s.push({resolveType:o,title:a.title??ox(o),description:a.description,icon:a.icon})}return s.sort((r,o)=>r.title.localeCompare(o.title))}function ox(t){return(t.split("/").pop()??t).replace(/\.(tsx?|jsx?)$/,"")}const ax=["blog/sections/blocks/","site/sections/Blog/Post/"];function GC(t){return ax.some(e=>t.startsWith(e))}function ud({orgSlug:t,virtualMcpId:e,branch:s}){return It.decofile(`${t}/${e}/${s}`)}function fd({orgSlug:t,virtualMcpId:e,branch:s},i){return`/api/${t}/sandbox/${encodeURIComponent(e)}/${encodeURIComponent(s)}/${i}`}function lx(t){const e=W.c(11),s=Ys();let i;e[0]!==t?(i=async l=>{const{blockKey:h,data:c}=l,d=await fetch(fd(t,"write"),{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({path:dd(h),content:JSON.stringify(c,null,2)})});if(!d.ok){const u=await d.json().catch(cx);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=ud(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],Xs(a)}function cx(){return{}}function hx(t){const e=Ys();return Xs({mutationFn:async({blockKey:s})=>{const i=await fetch(fd(t,"unlink"),{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({path:dd(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=ud(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 dx(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(Tc,{size:12}):n.jsx(fs,{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(se,{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 x;e[11]!==d?(x=n.jsx(tn,{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]=x):x=e[12];let b;e[13]!==g||e[14]!==x?(b=n.jsxs(Ot,{className:"max-w-2xl p-0 gap-0",children:[g,x]}),e[13]=g,e[14]=x,e[15]=b):b=e[15];let v;return e[16]!==i||e[17]!==s||e[18]!==b?(v=n.jsx(Lt,{open:s,onOpenChange:i,children:b}),e[16]=i,e[17]=s,e[18]=b,e[19]=v):v=e[19],v}const _l=P.lazy(()=>qt(()=>import("./app-editor-XgVpEUlu.js"),__vite__mapDeps([157,1,2,4,46,47,48,16,3,5,154,136,51,18,20,22,21,29,30,82,137,101,49,44,77,6,7,8,9,10,11,12,13,14,15,17,19,23,24,25,26,27,28,31,32,33,34,35,36,37,38,39,40,41,42,43,45,78,50,72,79,73,80,81,83,84,58,85,60,61,158,90,91,92,93,94,95,57,96,59,97,98,99,100,102,103,104,105,106,107,108,66,109,56,110,71,111,70,67,112,113,114,115,116,117,65,87,88,52,53,54,55,62,63,64,68,69,74,75,76,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153])).then(t=>({default:t.AppEditor}))),ux=P.lazy(()=>qt(()=>import("./post-editor-CZlHz9jV.js"),__vite__mapDeps([159,1,2,3,6,7,8,9,10,11,12,13,14,15,16,17,4,5,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,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,49,70,48,71,72,50,47,73,74,75,76,97,98,99,46,100,101,102,103,91,92,93,94,85,95,96,104,105,106,107,108,109,110,111,150,122,151,133,152,129,131,148,115,87,88,79,81,51,82,83,84,77,78,80,160,158,90,112,113,114,116,117,118,119,120,121,123,124,125,126,127,128,130,132,134,135,136,137,138,139,140,141,142,143,144,145,146,147,149,153])).then(t=>({default:t.PostEditor}))),fx=P.lazy(()=>qt(()=>import("./record-editor-D3YkaDAS.js"),__vite__mapDeps([161,1,2,50,72,73,81,8,39,40,7,16,20,18,6,9,10,11,12,13,14,15,3,17,4,5,19,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,41,42,43,44,45,49,51,82,83,84,58,85,60,61,160,158,90,91,92,93,94,95,57,96,59,97,98,99,46,47,48,100,101,102,103,104,105,106,107,108,66,109,56,110,71,111,70,67,112,113,114,115,116,117,65,79,87,88,52,53,54,55,62,63,64,68,69,74,75,76,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,80,140,141,142,143,144,145,146,147,148,149,150,151,152,153])).then(t=>({default:t.RecordEditor}))),mx=P.lazy(()=>qt(()=>import("./sections-editor-D-D4fXgu.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,150,151,152,153,154])).then(t=>({default:t.SectionsEditor}))),px=P.lazy(()=>qt(()=>import("./seo-editor-BTy_Py6L.js"),__vite__mapDeps([162,1,2,4,6,7,8,9,10,11,12,13,14,15,16,3,17,5,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,86,72,80,77,78,50,79,73,51,81,49,82,83,84,58,85,60,61,90,91,92,93,94,95,57,96,59,97,98,99,100,101,102,103,104,105,106,107,108,66,109,56,110,71,111,70,67,112,113,114,115,116,117,65,87,88,52,53,54,55,62,63,64,68,69,74,75,76,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,150,151,152,153])).then(t=>({default:t.SeoEditor}))),_x=P.lazy(()=>qt(()=>import("./add-section-modal-BwyDPP_M.js"),__vite__mapDeps([89,1,2,6,7,8,9,10,11,12,13,14,15,16,3,17,4,5,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,49,50,90,91,92,58,93,94,85,95,57,96,59,97,98,99,46,47,48,100,101,102,103,104,105,106,107,108,66,109,56,110,71,72,111,70,67,83,112,113,114,115,82,116,117,65,79,87,88,60,61,52,53,54,55,62,63,64,68,69,73,74,75,76,118,51,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,80,140,141,142,143,144,145,146,147,148,149,150,151,152,153])).then(t=>({default:t.AddSectionModal}))),Kn="oklch(0.65 0.15 160)";function gx(){const t=W.c(18),e=Qi(),{data:s}=qs.useSession(),{currentBranch:i}=ts(),{org:r}=Re(),o=e?.entity?.id??null,a=s?.user?.id,l=e?.entity?.metadata,h=a&&i?Gr(l?.sandboxMap?.[a]?.[i]):{},c=Object.values(h),u=(c.find(vx)??c[0])?.previewUrl??null,f=Yt(),m=e?.entity?.organization_id??"";let p;t[0]!==r.slug||t[1]!==m?(p={connectionId:js,orgId:m,orgSlug:r.slug},t[0]=r.slug,t[1]=m,t[2]=p):p=t[2];const _=Qe(p),g=Ro(_);let x;t[3]!==i||t[4]!==g||t[5]!==o?(x=()=>{if(!o)return;const C={virtualMcpId:o};i&&(C.branch=i),g.mutate(C)},t[3]=i,t[4]=g,t[5]=o,t[6]=x):x=t[6];const b=x,v=!!o&&!!i&&Bn.isStopped(o,i),y=Uh({previewUrl:u,appPaused:f.status.state==="paused",userStopped:v});if(y.kind!=="iframe"){let C;return t[7]!==y||t[8]!==b||t[9]!==f.lifecycle||t[10]!==f.phase?(C=n.jsx(Cx,{state:y,claimPhase:f.phase,lifecycle:f.lifecycle,onStart:b}),t[7]=y,t[8]=b,t[9]=f.lifecycle,t[10]=f.phase,t[11]=C):C=t[11],C}if(!o||!i){let C;return t[12]===Symbol.for("react.memo_cache_sentinel")?(C=n.jsx(bi,{title:"Waiting for sandbox context…"}),t[12]=C):C=t[12],C}let S;return t[13]!==i||t[14]!==r.slug||t[15]!==u||t[16]!==o?(S=n.jsx(bx,{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 vx(t){return t.sandboxProviderKind!=="user-desktop"}const gl=2e3,xx=15;function vl(t,e,s,i){return typeof e!="string"||s&&(ed(e,s,i)||t.state.dataUpdateCount>=xx)?!1:gl}function bx({orgSlug:t,virtualMcpId:e,branch:s,previewUrl:i}){const r={orgSlug:t,virtualMcpId:e,branch:s},{data:o,isLoading:a}=ea(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{data:x,isLoading:b,isFetching:v}=ta(r,{refetchInterval:G=>{const pe=G.state.data;if(l==="apps"&&c&&c.collection==="apps"){const xe=o?.[c.key];return vl(G,typeof xe?.__resolveType=="string"?xe.__resolveType:void 0,pe)}if(l==="site"&&o){const xe=pe?Wn(o,pe):null,Se=o.site,we=xe?.resolveType??(typeof Se?.__resolveType=="string"?Se.__resolveType:void 0);return vl(G,we,pe,["seo"])}return!1}}),y=(G,pe)=>!ed(G,x,pe)&&(b||v),{catalog:S,isLoading:C}=P1(x??void 0,o??void 0,{enabled:l==="apps"}),j=fa(r),T=S1(r),B=lx(r),I=hx(r),[R,k]=P.useState(null),[w,A]=P.useState(),[N,E]=P.useState(!1),[M,D]=P.useState(null),[L,z]=P.useState(null),[H,F]=P.useState(null);if(a||b)return n.jsx("div",{className:"h-full w-full flex items-center justify-center",children:n.jsx(Ce,{size:20,className:"animate-spin text-muted-foreground"})});if(!o||!x)return n.jsx(bi,{title:"Could not load site data."});const q=aa(o).sort((G,pe)=>G.name.localeCompare(pe.name)),J=la(o,x),V=Wn(o,x),U=cd(o),K=_a.some(G=>U[G].length>0),Q=Pi(l)?U[l]:[];if(!oa(o,x)&&!K)return n.jsx(bi,{icon:Fi,title:"No editable content",description:"This project doesn't expose any Deco pages, sections, or apps."});const oe={pages:q.length,sections:J.length,apps:S.length,posts:U.posts.length,authors:U.authors.length,categories:U.categories.length},O=new Set(q.map(G=>Fs(G.path))),ee=new Set(q.map(G=>G.name)),te=new Set(J.map(G=>G.name)),Y=async G=>{const pe=o[G.key];if(!pe)return;const xe=od(o,G.key),Se=F1(o,G.key,Math.max(0,xe-1)),we=H1(pe.sections,Se);if(we)try{await j.mutateAsync({blockKey:G.key,data:{...pe,sections:we}}),le.success(`Variant added to "${G.name}"`),d({collection:"pages",key:G.key,path:G.path})}catch(tt){le.error(tt instanceof Error?tt.message:"Could not add variant")}},$=()=>{A(void 0),k({mode:"create",sourceKey:null,initialName:"My new page",initialPath:"/example"})},ae=G=>{A(void 0),k({mode:"duplicate",sourceKey:G.key,initialName:ul(ee,G.name),initialPath:U1(O,G.path)})},ue=G=>{A(void 0),k({mode:"rename",sourceKey:G.key,initialName:G.name,initialPath:G.path})},fe=async G=>{if(!R)return;const{mode:pe,sourceKey:xe}=R;try{if(pe==="create"){const Se=V1(G.name,G.path),we=G1(o,G.name);await j.mutateAsync({blockKey:we,data:Se}),le.success(`Created "${G.name}"`),d({collection:"pages",key:we,path:G.path})}else if(pe==="duplicate"&&xe){const Se=o[xe];if(!Se)throw new Error("Source page not found");const{key:we,data:tt}=K1({source:Se,pages:q,newName:G.name,newPath:G.path});await j.mutateAsync({blockKey:we,data:tt}),le.success(`Duplicated as "${G.name}"`),d({collection:"pages",key:we,path:G.path})}else if(pe==="rename"&&xe){const Se=o[xe];if(!Se)throw new Error("Page not found");const we={...Se,name:G.name,path:G.path};await j.mutateAsync({blockKey:xe,data:we}),le.success("Page updated"),c?.collection==="pages"&&c.key===xe&&d({collection:"pages",key:xe,path:G.path})}k(null)}catch(Se){A(Se instanceof Error?Se.message:"Save failed")}},he=({path:G})=>{if(!R)return null;const pe=Fs(G);return(R.mode==="rename"?Fs(R.initialPath):null)!==pe&&O.has(pe)?`A page with path "${G}" already exists.`:null},re=async G=>{const pe=(G.title||G.resolveType.split("/").pop()||"").replace(/\.(tsx?|jsx?)$/,"").replace(/[^A-Za-z0-9_-]/g,""),xe=/^[A-Za-z]/.test(pe)&&pe.length>0?pe:"Section",Se=fl(o,xe),we={__resolveType:G.resolveType,name:Se};try{await j.mutateAsync({blockKey:Se,data:we}),le.success(`Created section "${Se}"`),E(!1),d({collection:"sections",key:Se})}catch(tt){le.error(tt instanceof Error?tt.message:"Could not create section")}},ve=async G=>{const pe=o[G.key];if(!pe){le.error("Section not found.");return}const xe=fl(o,G.key),Se=ul(te,G.name),we={...pe,name:Se};try{await j.mutateAsync({blockKey:xe,data:we}),le.success(`Duplicated "${G.name}"`),d({collection:"sections",key:xe})}catch(tt){le.error(tt instanceof Error?tt.message:"Duplicate failed")}},ie=async G=>{if(!M)return;const pe=o[M];if(!pe){le.error("Section not found.");return}try{await j.mutateAsync({blockKey:M,data:{...pe,name:G}}),le.success("Section renamed"),D(null)}catch(xe){le.error(xe instanceof Error?xe.message:"Rename failed")}},ke=async G=>{const pe=pl(o,G),xe=ml(pe,G,nx(G));try{await B.mutateAsync({blockKey:pe,data:xe}),le.success(`Created ${Ti[G]}`),d({collection:G,key:pe})}catch(Se){le.error(Se instanceof Error?Se.message:"Could not create")}},lt=async G=>{const pe=o[G.key];if(!pe){le.error("Record not found.");return}const xe=pl(o,G.kind),Se=G.kind==="posts"?"title":"name",we={...structuredClone(hd(pe,G.kind)),[Se]:`${G.label} (copy)`};try{await B.mutateAsync({blockKey:xe,data:ml(xe,G.kind,we)}),le.success(`Duplicated "${G.label}"`),d({collection:G.kind,key:xe})}catch(tt){le.error(tt instanceof Error?tt.message:"Duplicate failed")}},Ie=async()=>{if(!L)return;const{kind:G,key:pe,label:xe}=L;try{G==="blog"?await I.mutateAsync({blockKey:pe}):await T.mutateAsync({blockKey:pe}),le.success(`Deleted "${xe}"`),c&&c.key===pe&&d(null),z(null)}catch(Se){le.error(Se instanceof Error?Se.message:"Delete failed")}},mt=T.isPending||I.isPending,os=L?.kind==="blog"?Ti[L.blogKind]:L?.kind??"item";return n.jsxs("div",{className:"flex h-full w-full",children:[n.jsx(yx,{active:l,counts:oe,showBlog:K,onSelect:G=>{h(G),d(null),f(null)}}),l!=="seo"&&l!=="site"&&n.jsx(Sx,{activeCollection:l,pages:q,sections:J,appCatalog:S,appCatalogLoading:C,blogEntries:Q,decofile:o,searchQuery:m,onSearchChange:p,selection:c,onSelect:G=>{d(G),f(null)},previewUrl:i,onCreate:()=>{l==="pages"?$():Pi(l)?ke(l):i?E(!0):le.error("Start the preview dev server to add sections.")},onDuplicatePage:ae,onRenamePage:ue,onAddPageVariant:Y,onDeletePage:G=>z({kind:"page",key:G.key,label:G.name}),onEditPageSeo:G=>{d({collection:"pages",key:G.key,path:G.path}),f(G.key)},onViewPageJson:G=>F(G.key),onDuplicateSection:ve,onRenameSection:G=>D(G.key),onDeleteSection:G=>z({kind:"section",key:G.key,label:G.name}),onDuplicateBlog:lt,onDeleteBlog:G=>z({kind:"blog",blogKind:G.kind,key:G.key,label:G.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(Ce,{size:20,className:"animate-spin text-muted-foreground"})}),children:l==="site"?V?n.jsx(_l,{orgSlug:t,virtualMcpId:e,branch:s,blockKey:V.key,block:o[V.key],decofile:o,meta:x,title:"Site",excludeFields:["seo"],schemaPending:y(V.resolveType,["seo"])},`site:${V.key}`):n.jsx(bi,{title:"Site settings not found",description:"This project doesn't have a site app block (site/apps/site.ts)."}):l==="seo"?n.jsx(px,{orgSlug:t,virtualMcpId:e,branch:s,decofile:o,meta:x,target:{kind:"site"},previewBaseUrl:i}):c?c.collection==="apps"?n.jsx(_l,{orgSlug:t,virtualMcpId:e,branch:s,blockKey:c.key,block:o[c.key],decofile:o,meta:x,schemaPending:y(typeof o[c.key]?.__resolveType=="string"?String(o[c.key].__resolveType):void 0)},`app:${c.key}`):c.collection==="posts"?n.jsx(ux,{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(fx,{orgSlug:t,virtualMcpId:e,branch:s,kind:c.collection,blockKey:c.key,block:o[c.key]},`${c.collection}:${c.key}`):n.jsx(mx,{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(bi,{title:`Select ${Pi(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(Z1,{open:!!R,mode:R.mode,initialName:R.initialName,initialPath:R.initialPath,isPending:j.isPending,error:w,validate:he,onSubmit:fe,onOpenChange:G=>{G||(k(null),A(void 0))}}),M&&n.jsx(Q1,{open:!!M,blockKey:M,initialName:J.find(G=>G.key===M)?.name??M,isPending:j.isPending,onSubmit:ie,onOpenChange:G=>{G||D(null)}}),N&&i&&n.jsx(P.Suspense,{fallback:null,children:n.jsx(_x,{open:N,onOpenChange:E,meta:x,decofile:o,previewBaseUrl:i,onSelect:re})}),H&&n.jsx(dx,{open:!!H,onOpenChange:G=>{G||F(null)},pageKey:H,decofile:o}),n.jsx(Nr,{open:!!L,onOpenChange:G=>{!G&&!mt&&z(null)},children:n.jsxs(Er,{children:[n.jsxs(Tr,{children:[n.jsx(Pr,{children:`Delete ${os}?`}),n.jsx(Rr,{children:L?.kind==="section"?`"${L.label}" will be removed. Pages that still reference it will lose this section.`:L?`"${L.label}" will be removed permanently. This can't be undone.`:null})]}),n.jsxs(Dr,{children:[n.jsx(Ar,{disabled:mt,children:"Cancel"}),n.jsx(Ir,{onClick:G=>{G.preventDefault(),Ie()},disabled:mt,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:mt?n.jsxs(n.Fragment,{children:[n.jsx(Ce,{size:14,className:"animate-spin"}),"Deleting…"]}):"Delete"})]})]})})]})}function yx(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(as,{id:"pages",icon:Mo,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(as,{id:"sections",icon:Us,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(as,{id:"apps",icon:oh,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(nh,{size:13,className:"shrink-0"}),"Blog"]}),n.jsx(as,{id:"posts",icon:Mc,label:"Posts",count:i.posts,active:s==="posts",onSelect:o}),n.jsx(as,{id:"authors",icon:Ko,label:"Authors",count:i.authors,active:s==="authors",onSelect:o}),n.jsx(as,{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(as,{id:"site",icon:Df,label:"Site",active:p,onSelect:o}),e[20]=o,e[21]=p,e[22]=_):_=e[22];const g=s==="seo";let x;e[23]!==o||e[24]!==g?(x=n.jsx(as,{id:"seo",icon:Cr,label:"SEO",active:g,onSelect:o}),e[23]=o,e[24]=g,e[25]=x):x=e[25];let b;return e[26]!==_||e[27]!==x||e[28]!==h||e[29]!==d||e[30]!==f||e[31]!==m?(b=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,_,x]})]}),e[26]=_,e[27]=x,e[28]=h,e[29]=d,e[30]=f,e[31]=m,e[32]=b):b=e[32],b}function as(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=ce("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:ce("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 Sx(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:x,onDeletePage:b,onEditPageSeo:v,onViewPageJson:y,onDuplicateSection:S,onRenameSection:C,onDeleteSection:j,onDuplicateBlog:T,onDeleteBlog:B}=t;let I,R,k,w,A,N;if(e[0]!==s||e[1]!==o||e[2]!==a||e[3]!==l||e[4]!==h||e[5]!==x||e[6]!==p||e[7]!==B||e[8]!==b||e[9]!==j||e[10]!==T||e[11]!==_||e[12]!==S||e[13]!==v||e[14]!==g||e[15]!==C||e[16]!==u||e[17]!==m||e[18]!==y||e[19]!==i||e[20]!==c||e[21]!==d||e[22]!==r||e[23]!==f){const L=d.toLowerCase(),z=i.filter($=>!L||$.name.toLowerCase().includes(L)||$.path.toLowerCase().includes(L)),H=r.filter($=>!L||$.name.toLowerCase().includes(L)||$.key.toLowerCase().includes(L)||$.resolveType.toLowerCase().includes(L)),F=o.filter($=>!L||$.title.toLowerCase().includes(L)||$.app.toLowerCase().includes(L)||$.vendor.toLowerCase().includes(L)||$.category.toLowerCase().includes(L)),q=l.filter($=>!L||$.label.toLowerCase().includes(L)||$.subtitle.toLowerCase().includes(L)),J=`Search ${s}…`,V=Pi(s)?`Create new ${Ti[s]}`:s==="pages"?"Create new page":"Create new section",U=s==="sections"&&!c,K=s!=="apps",Q=U,oe=U?"Start the preview dev server to add sections":void 0;A="w-[300px] shrink-0 border-r flex flex-col min-h-0";let O;e[30]===Symbol.for("react.memo_cache_sentinel")?(O=n.jsx(rh,{size:14,className:"shrink-0 text-muted-foreground","aria-hidden":!0}),e[30]=O):O=e[30];let ee;e[31]!==u?(ee=$=>u($.target.value),e[31]=u,e[32]=ee):ee=e[32];let te;e[33]!==J||e[34]!==d||e[35]!==ee?(te=n.jsxs("div",{className:"flex flex-1 items-center gap-2 pl-1",children:[O,n.jsx("input",{type:"text",value:d,onChange:ee,placeholder:J,"aria-label":J,className:"w-full bg-transparent text-sm outline-none placeholder:text-muted-foreground"})]}),e[33]=J,e[34]=d,e[35]=ee,e[36]=te):te=e[36];let Y;e[37]!==Q||e[38]!==oe||e[39]!==V||e[40]!==p||e[41]!==K?(Y=K&&n.jsxs(Pe,{children:[n.jsx(Ee,{asChild:!0,children:n.jsx(se,{variant:"ghost",size:"icon",onClick:p,disabled:Q,"aria-label":V,"aria-disabled":Q,children:n.jsx(Bt,{size:14})})}),n.jsx(Te,{side:"bottom",children:oe??V})]}),e[37]=Q,e[38]=oe,e[39]=V,e[40]=p,e[41]=K,e[42]=Y):Y=e[42],e[43]!==te||e[44]!==Y?(N=n.jsxs("div",{className:"px-2 h-12 flex items-center gap-1 border-b shrink-0",children:[te,Y]}),e[43]=te,e[44]=Y,e[45]=N):N=e[45],I=tn,w="flex-1 min-h-0 [&_[data-slot=scroll-area-viewport]>div]:!block",R="flex flex-col gap-1 p-1.5",k=s==="pages"?z.length===0?n.jsx(or,{hasItems:i.length>0,emptyLabel:"No pages yet.",emptyHint:'Click "+" to create your first page.'}):z.map($=>{const ae=f?.collection==="pages"&&f.key===$.key,ue=od(h,$.key);return n.jsx(nr,{icon:Mo,title:$.name,subtitle:$.path,active:ae,variantCount:ue,onClick:()=>m({collection:"pages",key:$.key,path:$.path}),menu:n.jsx(bn,{onDuplicate:()=>_($),onRename:()=>g($),onAddVariant:()=>x($),onEditSeo:()=>v($),onViewJson:()=>y($),onDelete:()=>b($)})},$.key)}):s==="sections"?H.length===0?n.jsx(or,{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,ue=$.resolveType.split("/").pop()?.replace(/\.tsx?$/,"");return n.jsx(nr,{icon:Us,title:$.name,subtitle:ue??$.resolveType,active:ae,onClick:()=>m({collection:"sections",key:$.key}),menu:n.jsx(bn,{onDuplicate:()=>S($),onRename:()=>C($),onDelete:()=>j($)})},$.key)}):s==="apps"?a?n.jsx("div",{className:"flex items-center justify-center py-8",children:n.jsx(Ce,{size:18,className:"animate-spin text-muted-foreground"})}):F.length===0?n.jsx(or,{hasItems:o.length>0,emptyLabel:"No apps found.",emptyHint:"Try a different search term."}):F.map($=>{const ae=f?.collection==="apps"&&$.blockKey!==null&&f.key===$.blockKey;return n.jsx(nr,{icon:oh,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){le.message(`${$.title} is not installed on this site.`);return}m({collection:"apps",key:$.blockKey})}},$.id)}):q.length===0?n.jsx(or,{hasItems:l.length>0,emptyLabel:`No ${s} yet.`,emptyHint:`Click "+" to create your first ${Pi(s)?Ti[s]:"item"}.`}):q.map($=>{const ae=f?.collection===$.kind&&f.key===$.key;return n.jsx(nr,{icon:$.kind==="posts"?Mc:$.kind==="authors"?Ko:Lc,title:$.label,subtitle:$.subtitle,active:ae,onClick:()=>m({collection:$.kind,key:$.key}),menu:n.jsx(bn,{onDuplicate:()=>T($),onDelete:()=>B($)})},$.key)}),e[0]=s,e[1]=o,e[2]=a,e[3]=l,e[4]=h,e[5]=x,e[6]=p,e[7]=B,e[8]=b,e[9]=j,e[10]=T,e[11]=_,e[12]=S,e[13]=v,e[14]=g,e[15]=C,e[16]=u,e[17]=m,e[18]=y,e[19]=i,e[20]=c,e[21]=d,e[22]=r,e[23]=f,e[24]=I,e[25]=R,e[26]=k,e[27]=w,e[28]=A,e[29]=N}else I=e[24],R=e[25],k=e[26],w=e[27],A=e[28],N=e[29];let E;e[46]!==R||e[47]!==k?(E=n.jsx("div",{className:R,children:k}),e[46]=R,e[47]=k,e[48]=E):E=e[48];let M;e[49]!==I||e[50]!==w||e[51]!==E?(M=n.jsx(I,{className:w,children:E}),e[49]=I,e[50]=w,e[51]=E,e[52]=M):M=e[52];let D;return e[53]!==A||e[54]!==N||e[55]!==M?(D=n.jsxs("div",{className:A,children:[N,M]}),e[53]=A,e[54]=N,e[55]=M,e[56]=D):D=e[56],D}function nr(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(Pe,{children:[n.jsx(Ee,{asChild:!0,children:n.jsx(s,{size:16,className:"shrink-0",style:{color:Kn}})}),n.jsxs(Te,{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:ce("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=ce("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 x;e[9]!==g?(x=ce("block truncate text-xs",g),e[9]=g,e[10]=x):x=e[10];let b;e[11]!==o||e[12]!==x?(b=n.jsx("span",{className:x,children:o}),e[11]=o,e[12]=x,e[13]=b):b=e[13];let v;e[14]!==_||e[15]!==b?(v=n.jsxs("span",{className:"min-w-0 flex-1",children:[_,b]}),e[14]=_,e[15]=b,e[16]=v):v=e[16];let y;e[17]!==c||e[18]!==f||e[19]!==v||e[20]!==h?(y=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,v,h]}),e[17]=c,e[18]=f,e[19]=v,e[20]=h,e[21]=y):y=e[21];let S;e[22]!==a||e[23]!==d?(S=d&&n.jsx("div",{className:ce("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 C;return e[25]!==S||e[26]!==p||e[27]!==y?(C=n.jsxs("div",{className:p,children:[y,S]}),e[25]=S,e[26]=p,e[27]=y,e[28]=C):C=e[28],C}function bn(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(ei,{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:wx,children:n.jsx(Zr,{size:14})})}),e[0]=h):h=e[0];let c;e[1]!==i?(c=i&&n.jsxs(Ze,{onClick:i,children:[n.jsx(Vo,{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(fs,{size:14}),e[3]=d):d=e[3];let u;e[4]!==s?(u=n.jsxs(Ze,{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(mr,{}),n.jsxs(Ze,{onClick:r,className:"cursor-pointer",style:{color:Kn},children:[n.jsx(Af,{size:14,style:{color:Kn}}),"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(mr,{}),o&&n.jsxs(Ze,{onClick:o,children:[n.jsx(Cr,{size:14}),"Edit SEO"]}),a&&n.jsxs(Ze,{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(mr,{}),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(Ze,{onClick:l,className:"text-destructive focus:text-destructive",children:[_,"Delete"]}),e[13]=l,e[14]=g):g=e[14];let x;return e[15]!==c||e[16]!==u||e[17]!==f||e[18]!==m||e[19]!==g?(x=n.jsxs(Qs,{children:[h,n.jsxs(ti,{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]=x):x=e[20],x}function wx(t){return t.stopPropagation()}function or(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 Cx(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=Jh({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(Or,{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(Or,{kind:"suspended",onResume:o}),e[6]=o,e[7]=a):a=e[7],a}}}function bi(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 kx(t){const e=W.c(2),{virtualMcpId:s}=t,i=Mt(s);if(!Js(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(gx,{}),e[1]=o):o=e[1],o}const yn={fast:{label:"Fast",subtitle:"Quick responses for simple tasks",icon:Ic},smart:{label:"Smart",subtitle:"Balanced quality and speed",icon:en},thinking:{label:"Thinking",subtitle:"Deeper reasoning for hard tasks",icon:Lf}},jx=["fast","smart","thinking"];function Nx(t){const e=W.c(15),{tier:s,onSelect:i}=t,[r,o]=P.useState(!1),a=yn[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=yn[s];let c;e[2]===Symbol.for("react.memo_cache_sentinel")?(c=n.jsx(Es,{size:14,className:"text-muted-foreground"}),e[2]=c):c=e[2];let d;e[3]!==l||e[4]!==h.label?(d=n.jsx(Ps,{asChild:!0,children:n.jsxs(se,{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=jx.map(p=>{const _=yn[p],g=_.icon;return n.jsxs("button",{type:"button",onClick:()=>{i(p),o(!1)},className:ce("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(Ui,{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(Rs,{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(Ts,{open:r,onOpenChange:o,children:[d,f]}),e[11]=r,e[12]=d,e[13]=f,e[14]=m):m=e[14],m}function Ex(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(se,{variant:"outline",size:"sm",disabled:!0,className:"w-fit",children:"Loading models…"}),children:n.jsx(Tx,{override:r,onOverrideChange:o})}):n.jsx(Nx,{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(Br,{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 Tx(t){const e=W.c(10),{override:s,onOverrideChange:i}=t,r=Rc(),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(Xm,{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 md=[{key:"capabilities",heading:"Built-in capabilities",icon:qo,tools:[{name:"web_search",title:"Web search",description:"Look up current information on the web",icon:Hi},{name:"generate_image",title:"Generate image",description:"Create images from a text prompt",icon:Hm},{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:If}]},{key:"files",heading:"Files & code",icon:Fa,tools:[{name:"read",title:"Read File",description:"Read a file from the workspace",icon:Yc},{name:"write",title:"Write File",description:"Create or overwrite a file",icon:Vo},{name:"edit",title:"Edit File",description:"Make targeted edits to an existing file",icon:Bf},{name:"grep",title:"Search Content",description:"Search file contents by pattern",icon:Uo},{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:Mf}]},{key:"context",heading:"Context",icon:La,tools:[{name:"read_resource",title:"Read Resource",description:"Read an MCP resource by URI",icon:La},{name:"read_prompt",title:"Read Prompt",description:"Read an MCP prompt definition",icon:nh}]},{key:"browser",heading:"Browser",icon:Us,tools:[{name:"take_screenshot",title:"Take Screenshot",description:"Capture a screenshot of a web page",icon:Kc},{name:"scrape_url",title:"Scrape URL",description:"Fetch and extract content from a URL",icon:Us},{name:"inspect_page",title:"Inspect Page",description:"Inspect a web page's structure",icon:Lo}]}],Px=md.flatMap(t=>t.tools.map(e=>e.name));function Rx(t){const e=t.replace(/[_-]+/g," ").trim();return e?e.toLowerCase().replace(/\b\w/g,s=>s.toUpperCase()):t}function Dx(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(se,{variant:"outline",size:"sm",disabled:!0,className:"w-fit",children:[n.jsx(qo,{size:14}),"Loading tools…"]}),children:n.jsx(Ax,{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 xl(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(sn,{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(Ym,{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 bl(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(Gt,{icon:s.icon,name:s.title,size:"2xs"}):r?n.jsx(r,{size:14,className:"text-muted-foreground"}):n.jsx(Of,{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=b=>{b.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 x;return e[16]!==c||e[17]!==u||e[18]!==g?(x=n.jsxs("div",{className:"flex items-center gap-2",children:[c,u,g]}),e[16]=c,e[17]=u,e[18]=g,e[19]=x):x=e[19],x}function Ax(t){const e=W.c(70),{agentId:s,value:i,onChange:r}=t,{org:o}=Re(),[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=Qe(h);let d;e[4]!==c?(d={client:c},e[4]=c,e[5]=d):d=e[5];const{data:u,isLoading:f}=sm(d),m=Wi();let p,_,g,x,b,v,y,S,C,j,T,B,I;if(e[6]!==m||e[7]!==u?.tools||e[8]!==f||e[9]!==r||e[10]!==a||e[11]!==i){const N=new Map(m.map(Ox)),E=new Map;for(const he of u?.tools??[]){const re=sf(he._meta)??"__other__",ve=rf(he.name,re==="__other__"?void 0:re),ie=he.title,ke=ie&&ie!==he.name?ie:Rx(ve);E.has(re)||E.set(re,{clientId:re,conn:N.get(re),tools:[]}),E.get(re).tools.push({name:he.name,display:ke,description:he.description})}const M=[...E.values()].sort(Lx),D=(u?.tools??[]).map(Mx),L=[...Px,...D],z=i===null?new Set(L):new Set(i),H=L.every(he=>z.has(he)),F=he=>r(L.every(re=>he.has(re))?null:[...he]),q=he=>{const re=new Set(z);re.has(he)?re.delete(he):re.add(he),F(re)},J=(he,re)=>{const ve=new Set(z);for(const ie of he)re?ve.add(ie):ve.delete(ie);F(ve)};x=Ts,I=a,b=l;let V;e[25]===Symbol.for("react.memo_cache_sentinel")?(V=n.jsx(qo,{size:14,className:"text-muted-foreground"}),e[25]=V):V=e[25];const U=H?"All tools":"Tools",K=!H&&n.jsxs(Um,{variant:"secondary",className:"ml-0.5 h-5 px-1.5 text-[11px] tabular-nums",children:[z.size,"/",L.length]});let Q;e[26]===Symbol.for("react.memo_cache_sentinel")?(Q=n.jsx(Es,{size:14,className:"text-muted-foreground"}),e[26]=Q):Q=e[26],e[27]!==U||e[28]!==K?(v=n.jsx(Ps,{asChild:!0,children:n.jsxs(se,{variant:"outline",size:"sm",className:"w-fit gap-1.5",children:[V,U,K,Q]})}),e[27]=U,e[28]=K,e[29]=v):v=e[29],g=Rs,T="p-0 w-80",B="start",_=Vm,e[30]===Symbol.for("react.memo_cache_sentinel")?(C=n.jsx(qm,{placeholder:"Search tools..."}),e[30]=C):C=e[30];const oe=H?`All ${L.length} tools enabled`:`${z.size} of ${L.length} enabled`;let O;e[31]!==oe?(O=n.jsx("span",{className:"text-xs text-muted-foreground",children:oe}),e[31]=oe,e[32]=O):O=e[32];let ee;e[33]!==r?(ee=()=>r(null),e[33]=r,e[34]=ee):ee=e[34];let te;e[35]!==H||e[36]!==ee?(te=n.jsx("button",{type:"button",onClick:ee,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]=ee,e[37]=te):te=e[37];let Y;e[38]===Symbol.for("react.memo_cache_sentinel")?(Y=n.jsx("span",{className:"text-muted-foreground/30",children:"·"}),e[38]=Y):Y=e[38];let $;e[39]!==r?($=()=>r([]),e[39]=r,e[40]=$):$=e[40];const ae=z.size===0;let ue;e[41]!==$||e[42]!==ae?(ue=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]=ue):ue=e[43];let fe;e[44]!==te||e[45]!==ue?(fe=n.jsxs("div",{className:"flex items-center gap-2",children:[te,Y,ue]}),e[44]=te,e[45]=ue,e[46]=fe):fe=e[46],e[47]!==O||e[48]!==fe?(j=n.jsxs("div",{className:"flex items-center justify-between border-b px-3 py-2",children:[O,fe]}),e[47]=O,e[48]=fe,e[49]=j):j=e[49],p=Gm,y="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(Km,{children:"No tools found"}),md.map(he=>{const re=he.tools.map(Bx),ve=re.filter(ie=>z.has(ie)).length;return n.jsx(Ha,{heading:n.jsx(bl,{label:he.heading,icon:he.icon,on:ve,total:re.length,onToggle:()=>J(re,ve!==re.length)}),children:he.tools.map(ie=>n.jsx(xl,{value:`${ie.title} ${ie.name}`,checked:z.has(ie.name),onToggle:()=>q(ie.name),title:ie.title,description:ie.description,leading:n.jsx(ie.icon,{size:16,className:"text-muted-foreground"})},ie.name))},he.key)}),M.map(he=>{const re=he.tools.map(Ix),ve=re.filter(ie=>z.has(ie)).length;return n.jsx(Ha,{heading:n.jsx(bl,{conn:he.conn,on:ve,total:re.length,onToggle:()=>J(re,ve!==re.length)}),children:he.tools.map(ie=>n.jsx(xl,{value:`${ie.display} ${ie.name} ${he.conn?.title??""}`,checked:z.has(ie.name),onToggle:()=>q(ie.name),title:ie.display,description:ie.description},ie.name))},he.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]=x,e[16]=b,e[17]=v,e[18]=y,e[19]=S,e[20]=C,e[21]=j,e[22]=T,e[23]=B,e[24]=I}else p=e[12],_=e[13],g=e[14],x=e[15],b=e[16],v=e[17],y=e[18],S=e[19],C=e[20],j=e[21],T=e[22],B=e[23],I=e[24];let R;e[50]!==p||e[51]!==y||e[52]!==S?(R=n.jsx(p,{className:y,children:S}),e[50]=p,e[51]=y,e[52]=S,e[53]=R):R=e[53];let k;e[54]!==_||e[55]!==R||e[56]!==C||e[57]!==j?(k=n.jsxs(_,{children:[C,j,R]}),e[54]=_,e[55]=R,e[56]=C,e[57]=j,e[58]=k):k=e[58];let w;e[59]!==g||e[60]!==k||e[61]!==T||e[62]!==B?(w=n.jsx(g,{className:T,align:B,children:k}),e[59]=g,e[60]=k,e[61]=T,e[62]=B,e[63]=w):w=e[63];let A;return e[64]!==x||e[65]!==b||e[66]!==v||e[67]!==w||e[68]!==I?(A=n.jsxs(x,{open:I,onOpenChange:b,children:[v,w]}),e[64]=x,e[65]=b,e[66]=v,e[67]=w,e[68]=I,e[69]=A):A=e[69],A}function Ix(t){return t.name}function Bx(t){return t.name}function Mx(t){return t.name}function Lx(t,e){return(t.conn?.title??t.clientId).localeCompare(e.conn?.title??e.clientId)}function Ox(t){return[t.id,t]}function Ri(t){const e=t.trim().split(/\s+/);return e.length!==5?!1:e.every(s=>/^[\d*/,-]+$/.test(s))}function $x(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 zx(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 Fx(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 Hx(t,e){return e===1?{minutes:"minute",hours:"hour",days:"day",weeks:"week"}[t]??t:t}const Wx=[{label:"5 minutes",cron:"*/5 * * * *"},{label:"Hour",cron:"0 * * * *"},{label:"Day",cron:"0 0 * * *"},{label:"Week",cron:"0 0 * * 1"}];function Ux({automationId:t,open:e,onOpenChange:s,onCustomSelect:i,onEventSelect:r,onWebhookCreated:o}){const{triggerAdd:a}=Ki(),[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}),le.success("Starter added"),d(!1)}catch(p){const _=p instanceof Error?p.message:"Failed to add starter";le.error(_)}},f=async()=>{try{const m=await a.mutateAsync({automation_id:t,type:"webhook"});d(!1),m.webhook?o?.(m.webhook):le.success("Webhook starter added")}catch(m){const p=m instanceof Error?m.message:"Failed to add webhook starter";le.error(p)}};return n.jsxs(Qs,{open:c,onOpenChange:d,children:[n.jsx(ei,{asChild:!0,children:n.jsxs(se,{variant:"outline",size:"sm",children:[n.jsx(Bt,{size:14}),"Add Starter"]})}),n.jsxs(ti,{align:"end",className:"w-[200px]",children:[n.jsxs(fm,{children:[n.jsxs(mm,{className:"gap-2.5",children:[n.jsx(ji,{size:14,className:"text-muted-foreground shrink-0"}),"Every..."]}),n.jsx(pm,{className:"w-[160px]",children:Wx.map(m=>n.jsxs(Ze,{className:"gap-2.5",onSelect:()=>u(m.cron),disabled:a.isPending,children:[n.jsx(ji,{size:14,className:"text-muted-foreground shrink-0"}),"Every ",m.label]},m.cron))})]}),n.jsxs(Ze,{className:"gap-2.5",onSelect:()=>{d(!1),i?.()},children:[n.jsx(ji,{size:14,className:"text-muted-foreground shrink-0"}),"Custom (cron)"]}),n.jsxs(Ze,{className:"gap-2.5",onSelect:()=>{d(!1),r?.()},children:[n.jsx(Mi,{size:14,className:"text-muted-foreground shrink-0"}),"Event"]}),n.jsxs(Ze,{className:"gap-2.5",onSelect:()=>{f()},disabled:a.isPending,children:[n.jsx(Hi,{size:14,className:"text-muted-foreground shrink-0"}),"Webhook"]})]})]})}function pd(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 x;e[0]===Symbol.for("react.memo_cache_sentinel")?(x=async(N,E)=>{try{await navigator.clipboard.writeText(N),u(E),le.success("Copied"),setTimeout(()=>u(null),1500)}catch{le.error("Failed to copy")}},e[0]=x):x=e[0];const b=x;let v;e[1]!==p||e[2]!==o||e[3]!==r?(v=r&&o&&p==="url"?`${r.replace(/\/$/,"")}/${o}`:r??"",e[1]=p,e[2]=o,e[3]=r,e[4]=v):v=e[4];const y=v,S=r&&o?p==="header"?`curl -X POST "${y}" \\
274
+ `}),e[26]=y):y=e[26];let S;return e[27]!==v||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,v,y]}),e[27]=v,e[28]=d,e[29]=S):S=e[29],S}function ir(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=ce("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 x;return e[6]!==r||e[7]!==f||e[8]!==g?(x=n.jsx("div",{"aria-hidden":f,className:m,style:g,children:r}),e[6]=r,e[7]=f,e[8]=g,e[9]=x):x=e[9],x}function nn(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:ce("size-2.5 rounded-full",wt)}),o=n.jsx("div",{className:ce("size-2.5 rounded-full",wt)}),a=n.jsx("div",{className:ce("size-2.5 rounded-full",wt)}),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:ce("ml-3 h-3.5 max-w-[220px] flex-1 rounded-sm",Ht)}),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 o1(){const t=W.c(2);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsx(nn,{}),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:e1.map(a1)})})]}),t[1]=s):s=t[1],s}function a1(t,e){if(e===Zh)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:ce("relative rounded-md",wt),children:n.jsx("div",{className:"absolute inset-0 rounded-md bg-chart-1/40 opacity-0",style:{animation:`vm-rack-scan ${Qh}s ease-in-out infinite`,animationDelay:`${s}s`}})},e)}function l1(){const t=W.c(5);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsx(nn,{}),t[0]=e):e=t[0];let s;t[1]===Symbol.for("react.memo_cache_sentinel")?(s=n.jsx("div",{className:ce("w-[18%] rounded-md",Ht),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:ce("rounded-md",Ht),style:{animation:"vm-breathe 3s ease-in-out 1.2s infinite"}}),n.jsx("div",{className:ce("rounded-md",Ht),style:{animation:"vm-breathe 3s ease-in-out 1.6s infinite"}})]})]})]})]})]}),t[4]=o):o=t[4],o}function c1(){const t=W.c(2);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsx(nn,{}),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:i1.map(h1)})})]}),t[1]=s):s=t[1],s}function h1(t,e){return n.jsx("div",{className:ce("aspect-square rounded-md",r1[e]?"bg-chart-2/70":wt),style:{animation:`vm-pulse-soft 2.2s ease-in-out ${t}s infinite`}},e)}function d1(){const t=W.c(11);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsx(nn,{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:ce("h-1.5 w-[70%] rounded-sm",wt)}),r=n.jsx("div",{className:ce("h-1.5 w-[55%] rounded-sm",wt)}),o=n.jsx("div",{className:ce("h-1.5 w-[80%] rounded-sm",wt)}),a=n.jsx("div",{className:ce("h-1.5 w-[50%] rounded-sm",wt)}),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:ce("h-4 rounded-md",wt)})})]}),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:ce("h-1.5 w-[55%] rounded-sm",Ht)})]})}),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:ce("h-4 w-10 rounded-full",Ht)}),n.jsx("div",{className:ce("h-4 w-14 rounded-full",Ht)})]}),t[8]=c):c=t[8];let d;t[9]===Symbol.for("react.memo_cache_sentinel")?(d=n.jsxs("div",{className:ce("col-span-3 flex flex-col justify-end gap-1 rounded-md p-2",Ht),children:[n.jsx("div",{className:ce("h-1.5 w-[50%] rounded-sm",wt)}),n.jsx("div",{className:ce("h-1 w-[75%] rounded-sm",wt)})]}),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:ce("rounded-md",Ht)}),n.jsx("div",{className:ce("rounded-md",Ht)})]})]})]})]})]})]}),t[10]=u):u=t[10],u}function Or(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(n1,{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(Nf,{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:Zv("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(Ws,{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(se,{onClick:t.onResume,className:"mt-2",children:[o," Resume"]})]})}),e[7]=t.onResume,e[8]=a):a=e[8],a}const u1=P.lazy(()=>qt(()=>import("./sections-editor-BRdCJB8j.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,150,151,152,153,154])).then(t=>({default:t.SectionsEditor}))),f1=P.lazy(()=>qt(()=>import("./page-seo-sheet-BY0ZczJ9.js"),__vite__mapDeps([155,1,2,122,44,46,47,48,16,3,5,86,72,80,77,6,7,8,9,10,11,12,13,14,15,17,4,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,45,78,50,79,73,51,81,49,82,83,84,58,85,60,61,90,91,92,93,94,95,57,96,59,97,98,99,100,101,102,103,104,105,106,107,108,66,109,56,110,71,111,70,67,112,113,114,115,116,117,65,87,88,52,53,54,55,62,63,64,68,69,74,75,76,118,119,120,121,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,150,151,152,153])).then(t=>({default:t.SeoSheet}))),m1=P.lazy(()=>qt(()=>import("./file-explorer-BJqHY4-p.js"),__vite__mapDeps([156,1,2,137,6,7,8,9,10,11,12,13,14,15,16,3,17,4,5,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,127,91,92,58,93,94,85,95,57,96,59,104,105,49,106,107,108,50,120,121,122,123,82,79,70,124,109,125,56,67,115,126,62,63,64,71,72,111,128,52,53,54,55,60,61,65,66,68,69,73,74,75,76,87,88,129,130,131,98,99,136,51,101,90,97,100,102,103,110,83,112,113,114,116,117,118,119,132,133,134,135,138,139,80,140,141,142,143,144,145,146,147,148,149,150,151,152,153])).then(t=>({default:t.FileExplorer}))),gn=500,p1={mobile:375,tablet:768,desktop:null},vn=["desktop","mobile","tablet"],_1={mobile:"Mobile (375px)",tablet:"Tablet (768px)",desktop:"Desktop"};function g1(t,e){const s=new URL(t,window.location.href);return s.searchParams.set("deviceHint",e),s.href}function v1(){const t=Qi(),{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),x=P.useRef(null),[b,v]=P.useState(!1),[y,S]=P.useState(""),C=P.useRef(null),[j,T]=P.useState(!1),[B,I]=P.useState(),[R,k]=P.useState(null),[w,A]=P.useState(null),[N,E]=P.useState("/"),[M,D]=P.useState(null),[L,z]=P.useState(!1),[H,F]=P.useState(!1),[q,J]=P.useState(null),V=t?.entity?.id??null,{org:U}=Re(),K=Yt(),Q=qh(),oe=Q.vmEntry,O=Q.previewUrl,ee=K.lifecycle.phase,te=ee==="running",Y=V&&e&&te?{orgSlug:U.slug,virtualMcpId:V,branch:e}:null,{data:$}=ea(Y,{fetchEnabled:te}),{data:ae}=ta(Y,{fetchEnabled:te}),ue=V&&e?{orgSlug:U.slug,virtualMcpId:V,branch:e}:null,fe=Hv(ue),he=$?aa($).sort((Z,ge)=>Z.name.localeCompare(ge.name)):[],re=$&&ae?la($,ae):[],ve=Fs,ie=he.filter(Z=>{if(!y)return!0;const ge=y.toLowerCase();return Z.name.toLowerCase().includes(ge)||Z.path.toLowerCase().includes(ge)}),ke=re.filter(Z=>{if(!y)return!0;const ge=y.toLowerCase();return Z.name.toLowerCase().includes(ge)||Z.key.toLowerCase().includes(ge)||Z.resolveType.toLowerCase().includes(ge)}),lt=R?null:y_(he,N,M),Ie=R?R.name:lt?.name,mt=lt?.key??null,os=P.useRef(null),G=P.useRef(null);A_(()=>{const Z=h.current,ge=os.current;!Z||!ge||(Z.src=ge)});const pe=K.status.state==="paused",xe=K.phase,Se=Jh({claimPhase:xe,lifecycle:K.lifecycle}),we=Q.previewState,tt=Q.userStopped,xt=we.kind==="iframe"?g1(w??new URL(N,we.previewUrl).href,r):null,[er,tr]=P.useState(null);if(we.kind==="iframe"&&er!==we.previewUrl){const Z=er!==null;tr(we.previewUrl),Z&&(G.current=null,E("/"),A(null),D(null),k(null))}os.current=xt;const _e=!!V&&!!e&&!K.notFound&&!tt&&!pe&&(xe?.kind==="ready"||ee!=="idle"),je=we.kind!=="iframe"&&(s==="visual"||s==="cms")?"preview":s;P.useEffect(()=>{if(!O)return;let Z;try{Z=new URL(O,window.location.href).origin}catch{return}const ge=rt=>{if(rt.origin===Z){if(rt.data?.type==="visual-editor::element-clicked"){const nt=Uv.safeParse(rt.data.payload);nt.success&&l(nt.data)}else if(rt.data?.type==="cms-editor::section-clicked"){const nt=Vv.safeParse(rt.data.payload);nt.success&&u(nt.data.sectionIndex)}}};return window.addEventListener("message",ge),()=>window.removeEventListener("message",ge)},[O]),P.useEffect(()=>{if(!b)return;const Z=ge=>{C.current?.contains(ge.target)||(v(!1),S(""))};return document.addEventListener("pointerdown",Z),()=>document.removeEventListener("pointerdown",Z)},[b]),P.useEffect(()=>{if(!c)return;const Z=rt=>{const nt=rt.target;nt&&nt!==h.current&&(x.current=nt)},ge=()=>{requestAnimationFrame(()=>{const rt=document.activeElement;(rt===document.body||rt===h.current)&&x.current&&x.current.focus()})};return document.addEventListener("focusin",Z),document.addEventListener("blur",ge,!0),()=>{document.removeEventListener("focusin",Z),document.removeEventListener("blur",ge,!0)}},[c]);const st=()=>{const Z=h.current?.contentWindow;Z&&Z.postMessage({type:"visual-editor::activate",script:Kv},"*")},bt=()=>{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:qv},"*")},mu=()=>{const Z=h.current?.contentWindow;Z&&Z.postMessage({type:"cms-editor::deactivate"},"*")},ci=Z=>{const ge=s;i(Z),l(null),Z!=="code"&&J(null),Z!=="cms"&&u(null),ge==="visual"&&bt(),ge==="cms"&&mu(),Z==="visual"&&st(),Z==="cms"&&it()},pu=()=>{if(!h.current||!xt)return;const Z=h.current;Z.src=xt},_u=()=>{if(!h.current||!xt)return;const Z=xt.includes("?")?"&":"?";h.current.src=`${xt}${Z}_r=${Date.now()}`},gu=()=>{const Z=vn.indexOf(r);o(vn[(Z+1)%vn.length])},vu=()=>{const Z=h.current?.contentWindow?.location?.href??xt??O;Z&&navigator.clipboard.writeText(Z)},xu=(()=>{if(!O)return"No server running";if(R)return R.name;try{const Z=new URL(O),ge=N==="/"?"":N;return`${Z.host}${ge}`}catch{return O}})(),Ta=Z=>{G.current=Z.path,k(null),A(null),D(Z.key),E(Z.path),u(null),z(!1)},bu=Z=>{if(!O||!ae){le.error("Preview metadata not ready yet");return}G.current=null;const ge=Nh(ae),rt=Ov(O,ge,Z.key);k(Z),A(rt),u(null)},yu=async({name:Z,path:ge})=>{if(!V||!e)return;const rt=ra(ge);if(rt){I(rt);return}const nt=ge.trim().startsWith("/")?ge.trim():`/${ge.trim()}`;if(he.some(Nt=>ve(Nt.path)===ve(nt))){I(`A page with path "${nt}" already exists.`);return}I(void 0);try{const Nt=await fe.mutateAsync({name:Z,path:nt});T(!1),le.success(`Page "${Z}" created`),await new Promise(wu=>setTimeout(wu,gn)),Ta({key:Nt.key,name:Nt.name,path:Nt.path}),ci("cms")}catch(Nt){I(Nt instanceof Error?Nt.message:"Failed to create page")}},Su=[{value:"preview",icon:n.jsx(Ba,{size:14}),tooltip:"Interactive"},...we.kind==="iframe"?[{value:"visual",icon:n.jsx(Ma,{size:14}),tooltip:"Visual editor"}]:[],...we.kind==="iframe"&&oa($,ae)?[{value:"cms",icon:n.jsx(Ef,{size:14}),tooltip:"Sections editor"}]:[],{value:"code",icon:n.jsx(Tf,{size:14}),tooltip:"Code editor"}];return n.jsxs("div",{className:"flex flex-col w-full h-full",children:[_e&&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(Fm,{value:je,onValueChange:ci,options:Su,size:"sm",className:"shrink-0 bg-foreground/4.5"})}),we.kind==="iframe"&&n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:ce("flex min-w-0 flex-1 items-center gap-0.5 ml-2",s==="code"&&"hidden"),children:[n.jsxs(Pe,{children:[n.jsx(Ee,{asChild:!0,children:n.jsx(se,{variant:"ghost",size:"icon",onClick:pu,children:n.jsx(Ai,{size:14})})}),n.jsx(Te,{side:"bottom",children:"Refresh"})]}),n.jsxs(Pe,{children:[n.jsx(Ee,{asChild:!0,children:n.jsx(se,{variant:"ghost",size:"icon",onClick:gu,children:n.jsxs("span",{className:"flex items-center justify-center animate-device-icon-pop",children:[r==="mobile"&&n.jsx(Pf,{size:14}),r==="tablet"&&n.jsx(Rf,{size:14}),r==="desktop"&&n.jsx(Ba,{size:14})]},r)})}),n.jsx(Te,{side:"bottom",children:_1[r]})]}),n.jsxs("div",{ref:C,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:()=>v(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(Us,{size:11}),"Global"]}),n.jsx("span",{className:"min-w-0 flex-1 truncate text-left text-[12px] text-foreground/88",children:xu}),Ie&&!R&&n.jsx("span",{className:"shrink-0 text-[12px] text-muted-foreground",children:Ie}),n.jsx(Es,{size:12,className:ce("shrink-0 text-muted-foreground transition-transform",b&&"rotate-180")})]}),b&&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(rh,{size:14,className:"shrink-0 text-muted-foreground","aria-hidden":!0}),n.jsx("input",{type:"text",value:y,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(),v(!1),S(""),I(void 0),T(!0)},children:[n.jsx(Bt,{size:16,className:"shrink-0 text-muted-foreground"}),n.jsx("span",{className:"flex-1 font-medium",children:"Create new page"})]})}),ie.length===0&&ke.length===0?n.jsx("div",{className:"px-4 py-5 text-center text-xs text-muted-foreground",children:he.length===0&&re.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:[ie.length>0&&n.jsx("div",{className:"p-1.5",children:ie.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:ge=>{ge.preventDefault(),v(!1),S(""),Ta(Z)},children:[n.jsx(Mo,{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))}),ke.length>0&&n.jsxs("div",{className:ce("p-1.5",ie.length>0&&"border-t"),children:[n.jsx("div",{className:"px-3 py-2 text-xs font-medium text-muted-foreground",children:"Global components"}),ke.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:ge=>{ge.preventDefault(),v(!1),S(""),bu(Z)},children:[n.jsx(Us,{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:ce("flex shrink-0 items-center gap-0.5",s==="code"&&"hidden"),children:[n.jsxs(Pe,{children:[n.jsx(Ee,{asChild:!0,children:n.jsx(se,{variant:"ghost",size:"icon",onClick:()=>{const Z=xt??we.previewUrl;Z&&window.open(Z,"_blank","noopener")},children:n.jsx(ii,{size:14})})}),n.jsx(Te,{side:"bottom",children:"Open in new tab"})]}),n.jsxs(Qs,{children:[n.jsx(ei,{asChild:!0,children:n.jsx(se,{variant:"ghost",size:"icon",children:n.jsx(Zr,{size:14})})}),n.jsxs(ti,{align:"end",className:"w-44",children:[n.jsx(Ze,{onClick:_u,children:"Hard Reload"}),n.jsx(Ze,{onClick:vu,children:"Copy Current URL"}),$&&ae&&n.jsxs(n.Fragment,{children:[n.jsx(mr,{}),mt&&n.jsxs(Ze,{onClick:()=>{z(!0),ci("cms")},children:[n.jsx(Cr,{size:14}),"Edit SEO"]}),mt&&n.jsxs(Ze,{onClick:()=>{try{J(za(mt)),ci("code")}catch{le.error("Invalid page block key")}},children:[n.jsx(Lo,{size:14}),"View JSON"]}),n.jsxs(Ze,{onClick:()=>F(!0),children:[n.jsx(Cr,{size:14}),"Site SEO"]})]})]})]})]})]})]}),n.jsxs("div",{className:"flex-1 flex overflow-hidden",children:[c&&O&&e&&V&&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(Ce,{size:20,className:"animate-spin text-muted-foreground"})}),children:n.jsx(u1,{orgSlug:U.slug,virtualMcpId:V,branch:e,previewReady:te,previewUrl:O,currentPath:N,activePageBlockKey:mt,activeGlobalBlockKey:R?.key??null,externalSelectedIndex:R?null:d,onSaved:()=>{setTimeout(()=>{const Z=h.current;if(!Z)return;const ge=document.activeElement,rt=Z.tabIndex;Z.tabIndex=-1,Z.style.pointerEvents="none",Z.blur();try{Z.contentWindow?.location.reload()}catch{const Nt=os.current;Nt&&(Z.src=Nt)}const nt=()=>{Z.tabIndex=rt,Z.style.pointerEvents="",ge?.focus(),Z.removeEventListener("load",nt)};Z.addEventListener("load",nt),setTimeout(nt,3e3)},gn)},initialEditSeo:L,onExitSeo:()=>z(!1),onViewJsonFile:Z=>{try{J(za(Z)),ci("code")}catch{le.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 ge=Z.clientX-_.current;m(Math.max(240,Math.min(640,g.current+ge)))},onPointerUp:()=>{p.current=!1}})]}),n.jsxs("div",{className:ce("flex-1 relative overflow-hidden",r!=="desktop"&&we.kind==="iframe"&&s!=="code"&&"flex justify-center bg-muted/30"),children:[we.kind==="starting"&&n.jsx("div",{className:"absolute inset-0 z-30",children:n.jsx(Or,{kind:"starting",progress:Se,claimPhase:xe})}),we.kind==="suspended"&&n.jsx("div",{className:"absolute inset-0 z-30",children:n.jsx(Or,{kind:"suspended",onResume:Q.resume})}),je==="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"]}),je==="visual"&&a&&n.jsx(Xv,{element:a,onDismiss:()=>l(null)}),s==="code"&&_e&&V&&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(Ce,{size:20,className:"animate-spin text-muted-foreground"})}),children:n.jsx(m1,{orgSlug:U.slug,virtualMcpId:V,branch:e,openPath:q})})}),we.kind==="iframe"&&xt&&n.jsx("div",{className:ce("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%":`${p1[r]}px`},children:n.jsx("iframe",{ref:h,src:xt,className:ce("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:oe?.sandboxHandle??null}),!R)try{const Z=h.current?.contentWindow?.location?.pathname;if(!Z)return;const ge=G.current;if(ge!==null){G.current=null,ve(Z)===ve(ge)&&E(Z);return}E(Z)}catch{}s==="visual"&&st(),s==="cms"&&it()}},we.previewUrl)})]})]}),n.jsx(Wv,{open:j,onOpenChange:T,isPending:fe.isPending,error:B,onSubmit:yu}),H&&$&&ae&&n.jsx(P.Suspense,{fallback:null,children:n.jsx(f1,{open:H,onOpenChange:F,orgSlug:U.slug,virtualMcpId:V??"",branch:e??"",decofile:$,meta:ae,onSaved:()=>{setTimeout(()=>{const Z=h.current;if(Z)try{Z.contentWindow?.location.reload()}catch{const ge=os.current;ge&&(Z.src=ge)}},gn)},target:{kind:"site"}})})]})}function x1(t){const e=W.c(2),{virtualMcpId:s}=t,i=Mt(s);if(!Js(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(v1,{}),e[1]=o):o=e[1],o}function b1(t,e){if(!t||!e?.length)return t;const s=Object.fromEntries(Object.entries(t.properties??{}).filter(([i])=>!e.includes(i)));return Object.keys(s).length>0?{...t,properties:s}:t}function y1(t,e,s){return typeof t!="string"?null:b1(Ch(t,e),s)}function ed(t,e,s){if(!e||typeof t!="string")return!1;const i=y1(t,e,s);return!!i&&Object.keys(i.properties??{}).length>0}function S1({orgSlug:t,virtualMcpId:e,branch:s}){const i=Ys();return Xs({mutationFn:async({blockKey:r})=>{const o=qc(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=It.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:It.liveMeta(r)})}})}function on(t,e){return`${t}-${e}`}function ma(t,e){return`site/apps/${t}/${e}.ts`}function pa(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 td(t,e,s){const i=new Set([on(t,e),e].map(o=>o.toLowerCase())),r=ma(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 w1(t,e){const s=t.vendor.alias,i=t.name,r=td(s,i,e);return{id:on(s,i),app:i,vendor:s,title:t.title||t.name,description:t.description,category:t.category??"Other",logo:t.logo||void 0,resolveType:ma(s,i),blockKey:r,installed:r!==null}}function C1(t,e,s){if(t===Ei)return null;const i=pa(t);if(!i)return null;const{vendor:r,app:o}=i,a=td(r,o,s),l=qi(t,e);return{id:on(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 k1(t,e,s){const i=new Map;for(const o of t){const a=w1(o,s);i.set(a.id,a)}const r=e.manifest?.blocks?.apps??{};for(const o of Object.keys(r)){const a=C1(o,e,s);!a||i.has(a.id)||i.set(a.id,a)}for(const o of E1(s,e)){const a=pa(o.resolveType);if(!a)continue;const l=on(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(j1)}function j1(t,e){return t.installed!==e.installed?t.installed?-1:1:t.title.localeCompare(e.title)}function N1(t,e,s){const i=t.manifest?.blocks?.apps??{};for(const r of[ma(e,s),`site/apps/${e}/${s}.tsx`,`${e}/apps/${s}.ts`,`${e}/apps/${s}.tsx`])if(r in i)return!0;return!1}function E1(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"||Ph(i,o))continue;const l=pa(a)??(()=>{const h=i.match(/^([^-]+)-(.+)$/);return h?{vendor:h[1],app:h[2]}:null})();!l||!N1(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 T1(){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 P1(t,e,s){const i=W.c(12),r=s?.enabled??!0;let o;i[0]===Symbol.for("react.memo_cache_sentinel")?(o=It.decoApps(),i[0]=o):o=i[0];let a;i[1]!==r?(a={queryKey:o,queryFn:T1,staleTime:3e5,retry:1,enabled:r},i[1]=r,i[2]=a):a=i[2];const l=Gs(a);let h;i[3]!==e||i[4]!==t||i[5]!==l.data?(h=t&&e?k1(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 R1=new Set(["website/pages/Page.tsx","$live/pages/LivePage.tsx"]);function D1(t){return t.includes("matchers")||t.includes("Match")}function A1(t,e){const s=t.__resolveType;return typeof s!="string"||!s||R1.has(s)?!1:e?h_(e,s):D1(s)}function Gi(t,e,s){if(!t)return!1;const i=t.__resolveType;if(typeof i!="string"||!ia(i)||!Object.hasOwn(e,i))return!1;const r=e[i];return!r||typeof r!="object"||Array.isArray(r)?!1:A1(r,s)}function yC(t,e,s){return Gi(t,e,s)?t?.__resolveType??null:null}function sd(t,e,s){if(!t)return null;const i=t.__resolveType??"";if(!i)return null;if(Gi(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 I1(t,e,s){const i=sd(t,e,s);return i?{__resolveType:i.resolveType,...i.data}:{__resolveType:""}}function SC(t,e,s){if(t)return Gi(t,e,s)?I1(t,e,s):t}function B1(t,e,s,i){if(!t)return"Default";if(Gi(t,e,i)){const r=t.__resolveType??"",o=e[r];return Rh(r,o)}return s(t)}function wC(t,e,s){return{__resolveType:t,...e,name:s}}function CC(t){return{__resolveType:t}}function kC(t,e,s){const i=sd(t,e,s);return i?{resolveType:i.resolveType,formValue:i.data}:{resolveType:"",formValue:{}}}function id(t){const e=t.__resolveType??"";return Qt(e)?t.section??t:t}function $r(t){const r=(Qt(t.__resolveType??"")?t.section:t)?.variants?.[0];return r?.rule?.__resolveType!==xh?null:r?.value??null}function jC(t){const e=id(t);return{__resolveType:u_,variants:[{value:e,rule:{__resolveType:xh}}]}}function NC(t){const e=t.__resolveType??"";if(!e)return null;if(Qt(e))return t.section??null;const s=$r(t);return s?Qt(s.__resolveType??"")?s:{__resolveType:Xa,section:id(s)}:{__resolveType:Xa,section:t}}function rr(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 EC(t){const e=$r(t);if(e)return rr(e);if(Qt(t.__resolveType??"")){const i=t.section;if(!i)return null;const r=$r(i);return rr(r||i)}return rr(t)}function TC(t){return $r(t)}const M1=["website/matchers/always.ts","$live/matchers/MatchAlways.ts"];function rd(t){if(!t)return!1;const e=t.__resolveType??"";return e===""?Object.keys(t).length===0:M1.includes(e)||e.includes("always")}function L1(t){const e=t.variants??[];if(e.length===0)return-1;const s=e.findIndex(i=>rd(i.rule));return s!==-1?s:e.length-1}function PC(t,e,s){const i=s.variants??[];if(i.length===0)return null;const r=L1(s),o=i[r]?.value;if(!o)return null;const a=structuredClone(o);return e.isLazy?{...t,section:a}:a}function RC(t,e){return e.isMultivariate?e.isLazy?t.section??null:t:null}function DC(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 AC(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 O1(t,e){const s=t.__resolveType??"";return Qt(s)?{...t,section:e}:e}function IC(t,e,s){return e.isLazy?{...t,section:s}:s}function BC(t,e,s){const i=[...t.variants??[]],r=i[e];if(!r)return t;const o=r.value??{};return i[e]={...r,value:O1(o,s)},{...t,variants:i}}function MC(t,e,s){const i=[...t.variants??[]];return i[e]?(i[e]={...i[e],rule:s},{...t,variants:i}):t}function LC(t,e){const s=[...t.variants??[]],i=s[e];return i?(s.splice(e+1,0,structuredClone(i)),{...t,variants:s}):t}function OC(t,e){const s=[...t.variants??[]];return s.length<=1?null:(s.splice(e,1),{...t,variants:s})}const $1=new Set(["website/pages/Page.tsx","$live/pages/LivePage.tsx"]);function $C(t){return t.anyOfRefs?.some(e=>e.resolveType!==rn?!1:e.schema?.properties?.variants?.items?.properties?.value?.type==="array")??!1}function nd(t){return!t||typeof t!="object"||Array.isArray(t)?!1:t.__resolveType===rn}function zC(t){if(!nd(t))return null;const e=t.variants;if(!Array.isArray(e))return null;const s=e[0]?.value;return Array.isArray(s)?s:null}function FC(t,e){if(!nd(t))return e;const s=structuredClone(t),i=[...s.variants??[]];return i.length===0?i.push({rule:ad(),value:e}):i[0]={...i[0],value:e},{...s,variants:i}}function z1(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;const e=t;return typeof e.__resolveType=="string"&&$1.has(e.__resolveType)&&typeof e.path=="string"}function od(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 F1(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 HC(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=>B1(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 ad(){return{__resolveType:d_}}function di(t){return{rule:ad(),value:t}}function Hs(t,e){return{...e,__resolveType:rn,variants:t}}function H1(t,e){const s=structuredClone(e);if(Array.isArray(t))return Hs([di(t),di(s)]);if(t&&typeof t=="object"){const i=t;return Array.isArray(i.variants)?Hs([...i.variants,di(s)],i):null}return Hs([di([]),di(s)])}function WC(t){const e=t.variants;return Array.isArray(e)?e.length-1:1}function UC(t,e){if(e.length===0)return Hs([],t);if(e.length===1){const s=e[0],i=s?.rule;if(!rd(i))return Hs(e,t);if(Array.isArray(s?.value))return s.value}return Hs(e,t)}function W1(t,e){for(const[s,i]of Object.entries(t)){if(!z1(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 KC(t,e,s){let i=0;return W1(t,r=>{if(!r)return;(r.__resolveType??"")===e&&Gi(r,t,s)&&i++}),i}function ul(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 U1(t,e){const s=Fs,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 fl(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 K1(t){const e=ua(t.newName),s={...t.source,name:t.newName,path:t.newPath};return{key:e,data:s}}function V1(t,e){return Yh(t,e)}const q1=1e3;function G1(t,e){for(let s=0;s<q1;s++){const i=ua(e);if(!Object.hasOwn(t,i))return i}throw new Error("Could not generate a unique page block key")}const Y1={create:"Create new page",duplicate:"Duplicate page",rename:"Rename page"},X1={create:"Create",duplicate:"Duplicate",rename:"Save"},J1={create:"Creating…",duplicate:"Duplicating…",rename:"Saving…"};function Z1(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,x]=P.useState(null),[b,v]=P.useState(s);s!==b&&(v(s),s&&(m(r),_(o),x(null)));let y;e[0]!==u||e[1]!==d?(y=K=>{!K&&!u&&(x(null),d(!1))},e[0]=u,e[1]=d,e[2]=y):y=e[2];const S=y;let C;e[3]!==u||e[4]!==f||e[5]!==c||e[6]!==p||e[7]!==h?(C=async K=>{K.preventDefault();const Q=f.trim(),oe=p.trim();if(!Q||!oe||u)return;const O=ra(oe);if(O){x(O);return}const ee=h?.({name:Q,path:oe});if(ee){x(ee);return}x(null),await c({name:Q,path:oe})},e[3]=u,e[4]=f,e[5]=c,e[6]=p,e[7]=h,e[8]=C):C=e[8];const j=C,T=g??l,B=Y1[i];let I;e[9]!==B?(I=n.jsx(ss,{children:n.jsx(is,{children:B})}),e[9]=B,e[10]=I):I=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 k;e[12]===Symbol.for("react.memo_cache_sentinel")?(k=K=>m(K.target.value),e[12]=k):k=e[12];let w;e[13]!==u||e[14]!==f?(w=n.jsxs("div",{className:"space-y-1.5",children:[R,n.jsx(Ve,{id:"page-form-name",value:f,onChange:k,placeholder:"My page",autoFocus:!0,disabled:u})]}),e[13]=u,e[14]=f,e[15]=w):w=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 N;e[17]===Symbol.for("react.memo_cache_sentinel")?(N=K=>_(K.target.value),e[17]=N):N=e[17];let E;e[18]!==u||e[19]!==p?(E=n.jsxs("div",{className:"space-y-1.5",children:[A,n.jsx(Ve,{id:"page-form-path",value:p,onChange:N,placeholder:"/example",disabled:u})]}),e[18]=u,e[19]=p,e[20]=E):E=e[20];let M;e[21]!==T?(M=T&&n.jsx("p",{className:"text-xs text-destructive",children:T}),e[21]=T,e[22]=M):M=e[22];let D;e[23]!==E||e[24]!==M||e[25]!==w?(D=n.jsxs("div",{className:"space-y-4 py-4",children:[w,E,M]}),e[23]=E,e[24]=M,e[25]=w,e[26]=D):D=e[26];let L;e[27]!==d?(L=()=>d(!1),e[27]=d,e[28]=L):L=e[28];let z;e[29]!==u||e[30]!==L?(z=n.jsx(se,{type:"button",variant:"outline",onClick:L,disabled:u,children:"Cancel"}),e[29]=u,e[30]=L,e[31]=z):z=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 F;e[36]!==u||e[37]!==i?(F=u?n.jsxs(n.Fragment,{children:[n.jsx(Ce,{size:14,className:"animate-spin"}),J1[i]]}):X1[i],e[36]=u,e[37]=i,e[38]=F):F=e[38];let q;e[39]!==H||e[40]!==F?(q=n.jsx(se,{type:"submit",disabled:H,children:F}),e[39]=H,e[40]=F,e[41]=q):q=e[41];let J;e[42]!==z||e[43]!==q?(J=n.jsxs(si,{children:[z,q]}),e[42]=z,e[43]=q,e[44]=J):J=e[44];let V;e[45]!==j||e[46]!==D||e[47]!==J||e[48]!==I?(V=n.jsx(Ot,{className:"sm:max-w-md",children:n.jsxs("form",{onSubmit:j,children:[I,D,J]})}),e[45]=j,e[46]=D,e[47]=J,e[48]=I,e[49]=V):V=e[49];let U;return e[50]!==S||e[51]!==s||e[52]!==V?(U=n.jsx(Lt,{open:s,onOpenChange:S,children:V}),e[50]=S,e[51]=s,e[52]=V,e[53]=U):U=e[53],U}function Q1(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=E=>{!E&&!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 E=>{E.preventDefault();const M=c.trim();!M||h||await a(M)},e[3]=h,e[4]=c,e[5]=a,e[6]=_):_=e[6];const g=_;let x;e[7]===Symbol.for("react.memo_cache_sentinel")?(x=n.jsxs(ss,{children:[n.jsx(is,{children:"Rename section"}),n.jsx(Fo,{children:"Updates the display name. The internal key stays the same so pages referencing this section keep working."})]}),e[7]=x):x=e[7];let b;e[8]===Symbol.for("react.memo_cache_sentinel")?(b=n.jsx("label",{htmlFor:"section-rename-name",className:"text-xs font-medium text-muted-foreground",children:"Name"}),e[8]=b):b=e[8];let v;e[9]===Symbol.for("react.memo_cache_sentinel")?(v=E=>d(E.target.value),e[9]=v):v=e[9];let y;e[10]!==h||e[11]!==c?(y=n.jsxs("div",{className:"space-y-1.5",children:[b,n.jsx(Ve,{id:"section-rename-name",value:c,onChange:v,autoFocus:!0,disabled:h})]}),e[10]=h,e[11]=c,e[12]=y):y=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 C;e[14]!==i?(C=n.jsxs("div",{className:"space-y-1.5",children:[S,n.jsx(Ve,{value:i,readOnly:!0,disabled:!0,className:"font-mono"})]}),e[14]=i,e[15]=C):C=e[15];let j;e[16]!==y||e[17]!==C?(j=n.jsxs("div",{className:"space-y-4 py-4",children:[y,C]}),e[16]=y,e[17]=C,e[18]=j):j=e[18];let T;e[19]!==l?(T=()=>l(!1),e[19]=l,e[20]=T):T=e[20];let B;e[21]!==h||e[22]!==T?(B=n.jsx(se,{type:"button",variant:"outline",onClick:T,disabled:h,children:"Cancel"}),e[21]=h,e[22]=T,e[23]=B):B=e[23];let I;e[24]!==h||e[25]!==c?(I=!c.trim()||h,e[24]=h,e[25]=c,e[26]=I):I=e[26];let R;e[27]!==h?(R=h?n.jsxs(n.Fragment,{children:[n.jsx(Ce,{size:14,className:"animate-spin"}),"Saving…"]}):"Save",e[27]=h,e[28]=R):R=e[28];let k;e[29]!==I||e[30]!==R?(k=n.jsx(se,{type:"submit",disabled:I,children:R}),e[29]=I,e[30]=R,e[31]=k):k=e[31];let w;e[32]!==B||e[33]!==k?(w=n.jsxs(si,{children:[B,k]}),e[32]=B,e[33]=k,e[34]=w):w=e[34];let A;e[35]!==g||e[36]!==j||e[37]!==w?(A=n.jsx(Ot,{className:"sm:max-w-md",children:n.jsxs("form",{onSubmit:g,children:[x,j,w]})}),e[35]=g,e[36]=j,e[37]=w,e[38]=A):A=e[38];let N;return e[39]!==p||e[40]!==s||e[41]!==A?(N=n.jsx(Lt,{open:s,onOpenChange:p,children:A}),e[39]=p,e[40]=s,e[41]=A,e[42]=N):N=e[42],N}const xn={post:"blog/loaders/Blogpost.ts",author:"blog/loaders/Author.ts",category:"blog/loaders/Category.ts"},ex="blog/sections/blocks/",_a=["posts","authors","categories"],Ti={posts:"post",authors:"author",categories:"category"};function Pi(t){return _a.includes(t)}const ga={posts:"post",authors:"author",categories:"category"},ld={posts:xn.post,authors:xn.author,categories:xn.category},tx=Object.fromEntries(Object.entries(ld).map(([t,e])=>[e,t]));function sx(t){return typeof t=="string"?tx[t]??null:null}function zr(t){return t&&typeof t=="object"&&!Array.isArray(t)?t:null}function Ms(t){return typeof t=="string"?t:""}function ix(t,e){switch(t){case"posts":return{label:Ms(e.title)||"Untitled post",subtitle:Ms(e.slug)};case"authors":return{label:Ms(e.name)||"Unnamed author",subtitle:Ms(e.email)};case"categories":return{label:Ms(e.name)||"Unnamed category",subtitle:Ms(e.slug)};default:{const s=t;throw new Error(`Unhandled blog kind: ${String(s)}`)}}}function cd(t){const e={posts:[],authors:[],categories:[]};for(const[s,i]of Object.entries(t)){const r=zr(i);if(!r)continue;const o=sx(r.__resolveType);if(!o)continue;const a=zr(r[ga[o]])??{},{label:l,subtitle:h}=ix(o,a);e[o].push({key:s,kind:o,label:l,subtitle:h})}for(const s of _a)e[s].sort((i,r)=>i.label.localeCompare(r.label));return e}function rx(t,e){return cd(t)[e]}function VC(t,e){return rx(t,e).map(s=>({key:s.key,payload:hd(zr(t[s.key])??void 0,e)}))}function hd(t,e){return t?zr(t[ga[e]])??{}:{}}function ml(t,e,s){return{name:t,__resolveType:ld[e],[ga[e]]:s}}function dd(t){return`.deco/blocks/${encodeURIComponent(t)}.json`}function Un(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 pl(t,e){const s=`collections/blog/${e}/${Un(12)}`;if(!Object.hasOwn(t,s))return s;throw new Error("Could not generate a unique blog block key")}function nx(t){switch(t){case"posts":return{title:"Untitled post",excerpt:"",slug:`untitled-${Un(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-${Un(8)}`};default:{const e=t;throw new Error(`Unhandled blog kind: ${String(e)}`)}}}function qC(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(ex)||e.has(o))continue;e.add(o);const a=qi(o,t);s.push({resolveType:o,title:a.title??ox(o),description:a.description,icon:a.icon})}return s.sort((r,o)=>r.title.localeCompare(o.title))}function ox(t){return(t.split("/").pop()??t).replace(/\.(tsx?|jsx?)$/,"")}const ax=["blog/sections/blocks/","site/sections/Blog/Post/"];function GC(t){return ax.some(e=>t.startsWith(e))}function ud({orgSlug:t,virtualMcpId:e,branch:s}){return It.decofile(`${t}/${e}/${s}`)}function fd({orgSlug:t,virtualMcpId:e,branch:s},i){return`/api/${t}/sandbox/${encodeURIComponent(e)}/${encodeURIComponent(s)}/${i}`}function lx(t){const e=W.c(11),s=Ys();let i;e[0]!==t?(i=async l=>{const{blockKey:h,data:c}=l,d=await fetch(fd(t,"write"),{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({path:dd(h),content:JSON.stringify(c,null,2)})});if(!d.ok){const u=await d.json().catch(cx);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=ud(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],Xs(a)}function cx(){return{}}function hx(t){const e=Ys();return Xs({mutationFn:async({blockKey:s})=>{const i=await fetch(fd(t,"unlink"),{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({path:dd(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=ud(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 dx(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(Tc,{size:12}):n.jsx(fs,{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(se,{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 x;e[11]!==d?(x=n.jsx(tn,{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]=x):x=e[12];let b;e[13]!==g||e[14]!==x?(b=n.jsxs(Ot,{className:"max-w-2xl p-0 gap-0",children:[g,x]}),e[13]=g,e[14]=x,e[15]=b):b=e[15];let v;return e[16]!==i||e[17]!==s||e[18]!==b?(v=n.jsx(Lt,{open:s,onOpenChange:i,children:b}),e[16]=i,e[17]=s,e[18]=b,e[19]=v):v=e[19],v}const _l=P.lazy(()=>qt(()=>import("./app-editor-n5gUpE-7.js"),__vite__mapDeps([157,1,2,4,46,47,48,16,3,5,154,136,51,18,20,22,21,29,30,82,137,101,49,44,77,6,7,8,9,10,11,12,13,14,15,17,19,23,24,25,26,27,28,31,32,33,34,35,36,37,38,39,40,41,42,43,45,78,50,72,79,73,80,81,83,84,58,85,60,61,158,90,91,92,93,94,95,57,96,59,97,98,99,100,102,103,104,105,106,107,108,66,109,56,110,71,111,70,67,112,113,114,115,116,117,65,87,88,52,53,54,55,62,63,64,68,69,74,75,76,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153])).then(t=>({default:t.AppEditor}))),ux=P.lazy(()=>qt(()=>import("./post-editor-M-6yKdac.js"),__vite__mapDeps([159,1,2,3,6,7,8,9,10,11,12,13,14,15,16,17,4,5,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,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,49,70,48,71,72,50,47,73,74,75,76,97,98,99,46,100,101,102,103,91,92,93,94,85,95,96,104,105,106,107,108,109,110,111,150,122,151,133,152,129,131,148,115,87,88,79,81,51,82,83,84,77,78,80,160,158,90,112,113,114,116,117,118,119,120,121,123,124,125,126,127,128,130,132,134,135,136,137,138,139,140,141,142,143,144,145,146,147,149,153])).then(t=>({default:t.PostEditor}))),fx=P.lazy(()=>qt(()=>import("./record-editor-DOYxf9X2.js"),__vite__mapDeps([161,1,2,50,72,73,81,8,39,40,7,16,20,18,6,9,10,11,12,13,14,15,3,17,4,5,19,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,41,42,43,44,45,49,51,82,83,84,58,85,60,61,160,158,90,91,92,93,94,95,57,96,59,97,98,99,46,47,48,100,101,102,103,104,105,106,107,108,66,109,56,110,71,111,70,67,112,113,114,115,116,117,65,79,87,88,52,53,54,55,62,63,64,68,69,74,75,76,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,80,140,141,142,143,144,145,146,147,148,149,150,151,152,153])).then(t=>({default:t.RecordEditor}))),mx=P.lazy(()=>qt(()=>import("./sections-editor-BRdCJB8j.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,150,151,152,153,154])).then(t=>({default:t.SectionsEditor}))),px=P.lazy(()=>qt(()=>import("./seo-editor-DGLH1irm.js"),__vite__mapDeps([162,1,2,4,6,7,8,9,10,11,12,13,14,15,16,3,17,5,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,86,72,80,77,78,50,79,73,51,81,49,82,83,84,58,85,60,61,90,91,92,93,94,95,57,96,59,97,98,99,100,101,102,103,104,105,106,107,108,66,109,56,110,71,111,70,67,112,113,114,115,116,117,65,87,88,52,53,54,55,62,63,64,68,69,74,75,76,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,150,151,152,153])).then(t=>({default:t.SeoEditor}))),_x=P.lazy(()=>qt(()=>import("./add-section-modal-CRKAmuUu.js"),__vite__mapDeps([89,1,2,6,7,8,9,10,11,12,13,14,15,16,3,17,4,5,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,49,50,90,91,92,58,93,94,85,95,57,96,59,97,98,99,46,47,48,100,101,102,103,104,105,106,107,108,66,109,56,110,71,72,111,70,67,83,112,113,114,115,82,116,117,65,79,87,88,60,61,52,53,54,55,62,63,64,68,69,73,74,75,76,118,51,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,80,140,141,142,143,144,145,146,147,148,149,150,151,152,153])).then(t=>({default:t.AddSectionModal}))),Kn="oklch(0.65 0.15 160)";function gx(){const t=W.c(18),e=Qi(),{data:s}=qs.useSession(),{currentBranch:i}=ts(),{org:r}=Re(),o=e?.entity?.id??null,a=s?.user?.id,l=e?.entity?.metadata,h=a&&i?Gr(l?.sandboxMap?.[a]?.[i]):{},c=Object.values(h),u=(c.find(vx)??c[0])?.previewUrl??null,f=Yt(),m=e?.entity?.organization_id??"";let p;t[0]!==r.slug||t[1]!==m?(p={connectionId:js,orgId:m,orgSlug:r.slug},t[0]=r.slug,t[1]=m,t[2]=p):p=t[2];const _=Qe(p),g=Ro(_);let x;t[3]!==i||t[4]!==g||t[5]!==o?(x=()=>{if(!o)return;const C={virtualMcpId:o};i&&(C.branch=i),g.mutate(C)},t[3]=i,t[4]=g,t[5]=o,t[6]=x):x=t[6];const b=x,v=!!o&&!!i&&Bn.isStopped(o,i),y=Uh({previewUrl:u,appPaused:f.status.state==="paused",userStopped:v});if(y.kind!=="iframe"){let C;return t[7]!==y||t[8]!==b||t[9]!==f.lifecycle||t[10]!==f.phase?(C=n.jsx(Cx,{state:y,claimPhase:f.phase,lifecycle:f.lifecycle,onStart:b}),t[7]=y,t[8]=b,t[9]=f.lifecycle,t[10]=f.phase,t[11]=C):C=t[11],C}if(!o||!i){let C;return t[12]===Symbol.for("react.memo_cache_sentinel")?(C=n.jsx(bi,{title:"Waiting for sandbox context…"}),t[12]=C):C=t[12],C}let S;return t[13]!==i||t[14]!==r.slug||t[15]!==u||t[16]!==o?(S=n.jsx(bx,{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 vx(t){return t.sandboxProviderKind!=="user-desktop"}const gl=2e3,xx=15;function vl(t,e,s,i){return typeof e!="string"||s&&(ed(e,s,i)||t.state.dataUpdateCount>=xx)?!1:gl}function bx({orgSlug:t,virtualMcpId:e,branch:s,previewUrl:i}){const r={orgSlug:t,virtualMcpId:e,branch:s},{data:o,isLoading:a}=ea(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{data:x,isLoading:b,isFetching:v}=ta(r,{refetchInterval:G=>{const pe=G.state.data;if(l==="apps"&&c&&c.collection==="apps"){const xe=o?.[c.key];return vl(G,typeof xe?.__resolveType=="string"?xe.__resolveType:void 0,pe)}if(l==="site"&&o){const xe=pe?Wn(o,pe):null,Se=o.site,we=xe?.resolveType??(typeof Se?.__resolveType=="string"?Se.__resolveType:void 0);return vl(G,we,pe,["seo"])}return!1}}),y=(G,pe)=>!ed(G,x,pe)&&(b||v),{catalog:S,isLoading:C}=P1(x??void 0,o??void 0,{enabled:l==="apps"}),j=fa(r),T=S1(r),B=lx(r),I=hx(r),[R,k]=P.useState(null),[w,A]=P.useState(),[N,E]=P.useState(!1),[M,D]=P.useState(null),[L,z]=P.useState(null),[H,F]=P.useState(null);if(a||b)return n.jsx("div",{className:"h-full w-full flex items-center justify-center",children:n.jsx(Ce,{size:20,className:"animate-spin text-muted-foreground"})});if(!o||!x)return n.jsx(bi,{title:"Could not load site data."});const q=aa(o).sort((G,pe)=>G.name.localeCompare(pe.name)),J=la(o,x),V=Wn(o,x),U=cd(o),K=_a.some(G=>U[G].length>0),Q=Pi(l)?U[l]:[];if(!oa(o,x)&&!K)return n.jsx(bi,{icon:Fi,title:"No editable content",description:"This project doesn't expose any Deco pages, sections, or apps."});const oe={pages:q.length,sections:J.length,apps:S.length,posts:U.posts.length,authors:U.authors.length,categories:U.categories.length},O=new Set(q.map(G=>Fs(G.path))),ee=new Set(q.map(G=>G.name)),te=new Set(J.map(G=>G.name)),Y=async G=>{const pe=o[G.key];if(!pe)return;const xe=od(o,G.key),Se=F1(o,G.key,Math.max(0,xe-1)),we=H1(pe.sections,Se);if(we)try{await j.mutateAsync({blockKey:G.key,data:{...pe,sections:we}}),le.success(`Variant added to "${G.name}"`),d({collection:"pages",key:G.key,path:G.path})}catch(tt){le.error(tt instanceof Error?tt.message:"Could not add variant")}},$=()=>{A(void 0),k({mode:"create",sourceKey:null,initialName:"My new page",initialPath:"/example"})},ae=G=>{A(void 0),k({mode:"duplicate",sourceKey:G.key,initialName:ul(ee,G.name),initialPath:U1(O,G.path)})},ue=G=>{A(void 0),k({mode:"rename",sourceKey:G.key,initialName:G.name,initialPath:G.path})},fe=async G=>{if(!R)return;const{mode:pe,sourceKey:xe}=R;try{if(pe==="create"){const Se=V1(G.name,G.path),we=G1(o,G.name);await j.mutateAsync({blockKey:we,data:Se}),le.success(`Created "${G.name}"`),d({collection:"pages",key:we,path:G.path})}else if(pe==="duplicate"&&xe){const Se=o[xe];if(!Se)throw new Error("Source page not found");const{key:we,data:tt}=K1({source:Se,pages:q,newName:G.name,newPath:G.path});await j.mutateAsync({blockKey:we,data:tt}),le.success(`Duplicated as "${G.name}"`),d({collection:"pages",key:we,path:G.path})}else if(pe==="rename"&&xe){const Se=o[xe];if(!Se)throw new Error("Page not found");const we={...Se,name:G.name,path:G.path};await j.mutateAsync({blockKey:xe,data:we}),le.success("Page updated"),c?.collection==="pages"&&c.key===xe&&d({collection:"pages",key:xe,path:G.path})}k(null)}catch(Se){A(Se instanceof Error?Se.message:"Save failed")}},he=({path:G})=>{if(!R)return null;const pe=Fs(G);return(R.mode==="rename"?Fs(R.initialPath):null)!==pe&&O.has(pe)?`A page with path "${G}" already exists.`:null},re=async G=>{const pe=(G.title||G.resolveType.split("/").pop()||"").replace(/\.(tsx?|jsx?)$/,"").replace(/[^A-Za-z0-9_-]/g,""),xe=/^[A-Za-z]/.test(pe)&&pe.length>0?pe:"Section",Se=fl(o,xe),we={__resolveType:G.resolveType,name:Se};try{await j.mutateAsync({blockKey:Se,data:we}),le.success(`Created section "${Se}"`),E(!1),d({collection:"sections",key:Se})}catch(tt){le.error(tt instanceof Error?tt.message:"Could not create section")}},ve=async G=>{const pe=o[G.key];if(!pe){le.error("Section not found.");return}const xe=fl(o,G.key),Se=ul(te,G.name),we={...pe,name:Se};try{await j.mutateAsync({blockKey:xe,data:we}),le.success(`Duplicated "${G.name}"`),d({collection:"sections",key:xe})}catch(tt){le.error(tt instanceof Error?tt.message:"Duplicate failed")}},ie=async G=>{if(!M)return;const pe=o[M];if(!pe){le.error("Section not found.");return}try{await j.mutateAsync({blockKey:M,data:{...pe,name:G}}),le.success("Section renamed"),D(null)}catch(xe){le.error(xe instanceof Error?xe.message:"Rename failed")}},ke=async G=>{const pe=pl(o,G),xe=ml(pe,G,nx(G));try{await B.mutateAsync({blockKey:pe,data:xe}),le.success(`Created ${Ti[G]}`),d({collection:G,key:pe})}catch(Se){le.error(Se instanceof Error?Se.message:"Could not create")}},lt=async G=>{const pe=o[G.key];if(!pe){le.error("Record not found.");return}const xe=pl(o,G.kind),Se=G.kind==="posts"?"title":"name",we={...structuredClone(hd(pe,G.kind)),[Se]:`${G.label} (copy)`};try{await B.mutateAsync({blockKey:xe,data:ml(xe,G.kind,we)}),le.success(`Duplicated "${G.label}"`),d({collection:G.kind,key:xe})}catch(tt){le.error(tt instanceof Error?tt.message:"Duplicate failed")}},Ie=async()=>{if(!L)return;const{kind:G,key:pe,label:xe}=L;try{G==="blog"?await I.mutateAsync({blockKey:pe}):await T.mutateAsync({blockKey:pe}),le.success(`Deleted "${xe}"`),c&&c.key===pe&&d(null),z(null)}catch(Se){le.error(Se instanceof Error?Se.message:"Delete failed")}},mt=T.isPending||I.isPending,os=L?.kind==="blog"?Ti[L.blogKind]:L?.kind??"item";return n.jsxs("div",{className:"flex h-full w-full",children:[n.jsx(yx,{active:l,counts:oe,showBlog:K,onSelect:G=>{h(G),d(null),f(null)}}),l!=="seo"&&l!=="site"&&n.jsx(Sx,{activeCollection:l,pages:q,sections:J,appCatalog:S,appCatalogLoading:C,blogEntries:Q,decofile:o,searchQuery:m,onSearchChange:p,selection:c,onSelect:G=>{d(G),f(null)},previewUrl:i,onCreate:()=>{l==="pages"?$():Pi(l)?ke(l):i?E(!0):le.error("Start the preview dev server to add sections.")},onDuplicatePage:ae,onRenamePage:ue,onAddPageVariant:Y,onDeletePage:G=>z({kind:"page",key:G.key,label:G.name}),onEditPageSeo:G=>{d({collection:"pages",key:G.key,path:G.path}),f(G.key)},onViewPageJson:G=>F(G.key),onDuplicateSection:ve,onRenameSection:G=>D(G.key),onDeleteSection:G=>z({kind:"section",key:G.key,label:G.name}),onDuplicateBlog:lt,onDeleteBlog:G=>z({kind:"blog",blogKind:G.kind,key:G.key,label:G.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(Ce,{size:20,className:"animate-spin text-muted-foreground"})}),children:l==="site"?V?n.jsx(_l,{orgSlug:t,virtualMcpId:e,branch:s,blockKey:V.key,block:o[V.key],decofile:o,meta:x,title:"Site",excludeFields:["seo"],schemaPending:y(V.resolveType,["seo"])},`site:${V.key}`):n.jsx(bi,{title:"Site settings not found",description:"This project doesn't have a site app block (site/apps/site.ts)."}):l==="seo"?n.jsx(px,{orgSlug:t,virtualMcpId:e,branch:s,decofile:o,meta:x,target:{kind:"site"},previewBaseUrl:i}):c?c.collection==="apps"?n.jsx(_l,{orgSlug:t,virtualMcpId:e,branch:s,blockKey:c.key,block:o[c.key],decofile:o,meta:x,schemaPending:y(typeof o[c.key]?.__resolveType=="string"?String(o[c.key].__resolveType):void 0)},`app:${c.key}`):c.collection==="posts"?n.jsx(ux,{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(fx,{orgSlug:t,virtualMcpId:e,branch:s,kind:c.collection,blockKey:c.key,block:o[c.key]},`${c.collection}:${c.key}`):n.jsx(mx,{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(bi,{title:`Select ${Pi(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(Z1,{open:!!R,mode:R.mode,initialName:R.initialName,initialPath:R.initialPath,isPending:j.isPending,error:w,validate:he,onSubmit:fe,onOpenChange:G=>{G||(k(null),A(void 0))}}),M&&n.jsx(Q1,{open:!!M,blockKey:M,initialName:J.find(G=>G.key===M)?.name??M,isPending:j.isPending,onSubmit:ie,onOpenChange:G=>{G||D(null)}}),N&&i&&n.jsx(P.Suspense,{fallback:null,children:n.jsx(_x,{open:N,onOpenChange:E,meta:x,decofile:o,previewBaseUrl:i,onSelect:re})}),H&&n.jsx(dx,{open:!!H,onOpenChange:G=>{G||F(null)},pageKey:H,decofile:o}),n.jsx(Nr,{open:!!L,onOpenChange:G=>{!G&&!mt&&z(null)},children:n.jsxs(Er,{children:[n.jsxs(Tr,{children:[n.jsx(Pr,{children:`Delete ${os}?`}),n.jsx(Rr,{children:L?.kind==="section"?`"${L.label}" will be removed. Pages that still reference it will lose this section.`:L?`"${L.label}" will be removed permanently. This can't be undone.`:null})]}),n.jsxs(Dr,{children:[n.jsx(Ar,{disabled:mt,children:"Cancel"}),n.jsx(Ir,{onClick:G=>{G.preventDefault(),Ie()},disabled:mt,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:mt?n.jsxs(n.Fragment,{children:[n.jsx(Ce,{size:14,className:"animate-spin"}),"Deleting…"]}):"Delete"})]})]})})]})}function yx(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(as,{id:"pages",icon:Mo,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(as,{id:"sections",icon:Us,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(as,{id:"apps",icon:oh,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(nh,{size:13,className:"shrink-0"}),"Blog"]}),n.jsx(as,{id:"posts",icon:Mc,label:"Posts",count:i.posts,active:s==="posts",onSelect:o}),n.jsx(as,{id:"authors",icon:Ko,label:"Authors",count:i.authors,active:s==="authors",onSelect:o}),n.jsx(as,{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(as,{id:"site",icon:Df,label:"Site",active:p,onSelect:o}),e[20]=o,e[21]=p,e[22]=_):_=e[22];const g=s==="seo";let x;e[23]!==o||e[24]!==g?(x=n.jsx(as,{id:"seo",icon:Cr,label:"SEO",active:g,onSelect:o}),e[23]=o,e[24]=g,e[25]=x):x=e[25];let b;return e[26]!==_||e[27]!==x||e[28]!==h||e[29]!==d||e[30]!==f||e[31]!==m?(b=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,_,x]})]}),e[26]=_,e[27]=x,e[28]=h,e[29]=d,e[30]=f,e[31]=m,e[32]=b):b=e[32],b}function as(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=ce("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:ce("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 Sx(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:x,onDeletePage:b,onEditPageSeo:v,onViewPageJson:y,onDuplicateSection:S,onRenameSection:C,onDeleteSection:j,onDuplicateBlog:T,onDeleteBlog:B}=t;let I,R,k,w,A,N;if(e[0]!==s||e[1]!==o||e[2]!==a||e[3]!==l||e[4]!==h||e[5]!==x||e[6]!==p||e[7]!==B||e[8]!==b||e[9]!==j||e[10]!==T||e[11]!==_||e[12]!==S||e[13]!==v||e[14]!==g||e[15]!==C||e[16]!==u||e[17]!==m||e[18]!==y||e[19]!==i||e[20]!==c||e[21]!==d||e[22]!==r||e[23]!==f){const L=d.toLowerCase(),z=i.filter($=>!L||$.name.toLowerCase().includes(L)||$.path.toLowerCase().includes(L)),H=r.filter($=>!L||$.name.toLowerCase().includes(L)||$.key.toLowerCase().includes(L)||$.resolveType.toLowerCase().includes(L)),F=o.filter($=>!L||$.title.toLowerCase().includes(L)||$.app.toLowerCase().includes(L)||$.vendor.toLowerCase().includes(L)||$.category.toLowerCase().includes(L)),q=l.filter($=>!L||$.label.toLowerCase().includes(L)||$.subtitle.toLowerCase().includes(L)),J=`Search ${s}…`,V=Pi(s)?`Create new ${Ti[s]}`:s==="pages"?"Create new page":"Create new section",U=s==="sections"&&!c,K=s!=="apps",Q=U,oe=U?"Start the preview dev server to add sections":void 0;A="w-[300px] shrink-0 border-r flex flex-col min-h-0";let O;e[30]===Symbol.for("react.memo_cache_sentinel")?(O=n.jsx(rh,{size:14,className:"shrink-0 text-muted-foreground","aria-hidden":!0}),e[30]=O):O=e[30];let ee;e[31]!==u?(ee=$=>u($.target.value),e[31]=u,e[32]=ee):ee=e[32];let te;e[33]!==J||e[34]!==d||e[35]!==ee?(te=n.jsxs("div",{className:"flex flex-1 items-center gap-2 pl-1",children:[O,n.jsx("input",{type:"text",value:d,onChange:ee,placeholder:J,"aria-label":J,className:"w-full bg-transparent text-sm outline-none placeholder:text-muted-foreground"})]}),e[33]=J,e[34]=d,e[35]=ee,e[36]=te):te=e[36];let Y;e[37]!==Q||e[38]!==oe||e[39]!==V||e[40]!==p||e[41]!==K?(Y=K&&n.jsxs(Pe,{children:[n.jsx(Ee,{asChild:!0,children:n.jsx(se,{variant:"ghost",size:"icon",onClick:p,disabled:Q,"aria-label":V,"aria-disabled":Q,children:n.jsx(Bt,{size:14})})}),n.jsx(Te,{side:"bottom",children:oe??V})]}),e[37]=Q,e[38]=oe,e[39]=V,e[40]=p,e[41]=K,e[42]=Y):Y=e[42],e[43]!==te||e[44]!==Y?(N=n.jsxs("div",{className:"px-2 h-12 flex items-center gap-1 border-b shrink-0",children:[te,Y]}),e[43]=te,e[44]=Y,e[45]=N):N=e[45],I=tn,w="flex-1 min-h-0 [&_[data-slot=scroll-area-viewport]>div]:!block",R="flex flex-col gap-1 p-1.5",k=s==="pages"?z.length===0?n.jsx(or,{hasItems:i.length>0,emptyLabel:"No pages yet.",emptyHint:'Click "+" to create your first page.'}):z.map($=>{const ae=f?.collection==="pages"&&f.key===$.key,ue=od(h,$.key);return n.jsx(nr,{icon:Mo,title:$.name,subtitle:$.path,active:ae,variantCount:ue,onClick:()=>m({collection:"pages",key:$.key,path:$.path}),menu:n.jsx(bn,{onDuplicate:()=>_($),onRename:()=>g($),onAddVariant:()=>x($),onEditSeo:()=>v($),onViewJson:()=>y($),onDelete:()=>b($)})},$.key)}):s==="sections"?H.length===0?n.jsx(or,{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,ue=$.resolveType.split("/").pop()?.replace(/\.tsx?$/,"");return n.jsx(nr,{icon:Us,title:$.name,subtitle:ue??$.resolveType,active:ae,onClick:()=>m({collection:"sections",key:$.key}),menu:n.jsx(bn,{onDuplicate:()=>S($),onRename:()=>C($),onDelete:()=>j($)})},$.key)}):s==="apps"?a?n.jsx("div",{className:"flex items-center justify-center py-8",children:n.jsx(Ce,{size:18,className:"animate-spin text-muted-foreground"})}):F.length===0?n.jsx(or,{hasItems:o.length>0,emptyLabel:"No apps found.",emptyHint:"Try a different search term."}):F.map($=>{const ae=f?.collection==="apps"&&$.blockKey!==null&&f.key===$.blockKey;return n.jsx(nr,{icon:oh,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){le.message(`${$.title} is not installed on this site.`);return}m({collection:"apps",key:$.blockKey})}},$.id)}):q.length===0?n.jsx(or,{hasItems:l.length>0,emptyLabel:`No ${s} yet.`,emptyHint:`Click "+" to create your first ${Pi(s)?Ti[s]:"item"}.`}):q.map($=>{const ae=f?.collection===$.kind&&f.key===$.key;return n.jsx(nr,{icon:$.kind==="posts"?Mc:$.kind==="authors"?Ko:Lc,title:$.label,subtitle:$.subtitle,active:ae,onClick:()=>m({collection:$.kind,key:$.key}),menu:n.jsx(bn,{onDuplicate:()=>T($),onDelete:()=>B($)})},$.key)}),e[0]=s,e[1]=o,e[2]=a,e[3]=l,e[4]=h,e[5]=x,e[6]=p,e[7]=B,e[8]=b,e[9]=j,e[10]=T,e[11]=_,e[12]=S,e[13]=v,e[14]=g,e[15]=C,e[16]=u,e[17]=m,e[18]=y,e[19]=i,e[20]=c,e[21]=d,e[22]=r,e[23]=f,e[24]=I,e[25]=R,e[26]=k,e[27]=w,e[28]=A,e[29]=N}else I=e[24],R=e[25],k=e[26],w=e[27],A=e[28],N=e[29];let E;e[46]!==R||e[47]!==k?(E=n.jsx("div",{className:R,children:k}),e[46]=R,e[47]=k,e[48]=E):E=e[48];let M;e[49]!==I||e[50]!==w||e[51]!==E?(M=n.jsx(I,{className:w,children:E}),e[49]=I,e[50]=w,e[51]=E,e[52]=M):M=e[52];let D;return e[53]!==A||e[54]!==N||e[55]!==M?(D=n.jsxs("div",{className:A,children:[N,M]}),e[53]=A,e[54]=N,e[55]=M,e[56]=D):D=e[56],D}function nr(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(Pe,{children:[n.jsx(Ee,{asChild:!0,children:n.jsx(s,{size:16,className:"shrink-0",style:{color:Kn}})}),n.jsxs(Te,{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:ce("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=ce("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 x;e[9]!==g?(x=ce("block truncate text-xs",g),e[9]=g,e[10]=x):x=e[10];let b;e[11]!==o||e[12]!==x?(b=n.jsx("span",{className:x,children:o}),e[11]=o,e[12]=x,e[13]=b):b=e[13];let v;e[14]!==_||e[15]!==b?(v=n.jsxs("span",{className:"min-w-0 flex-1",children:[_,b]}),e[14]=_,e[15]=b,e[16]=v):v=e[16];let y;e[17]!==c||e[18]!==f||e[19]!==v||e[20]!==h?(y=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,v,h]}),e[17]=c,e[18]=f,e[19]=v,e[20]=h,e[21]=y):y=e[21];let S;e[22]!==a||e[23]!==d?(S=d&&n.jsx("div",{className:ce("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 C;return e[25]!==S||e[26]!==p||e[27]!==y?(C=n.jsxs("div",{className:p,children:[y,S]}),e[25]=S,e[26]=p,e[27]=y,e[28]=C):C=e[28],C}function bn(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(ei,{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:wx,children:n.jsx(Zr,{size:14})})}),e[0]=h):h=e[0];let c;e[1]!==i?(c=i&&n.jsxs(Ze,{onClick:i,children:[n.jsx(Vo,{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(fs,{size:14}),e[3]=d):d=e[3];let u;e[4]!==s?(u=n.jsxs(Ze,{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(mr,{}),n.jsxs(Ze,{onClick:r,className:"cursor-pointer",style:{color:Kn},children:[n.jsx(Af,{size:14,style:{color:Kn}}),"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(mr,{}),o&&n.jsxs(Ze,{onClick:o,children:[n.jsx(Cr,{size:14}),"Edit SEO"]}),a&&n.jsxs(Ze,{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(mr,{}),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(Ze,{onClick:l,className:"text-destructive focus:text-destructive",children:[_,"Delete"]}),e[13]=l,e[14]=g):g=e[14];let x;return e[15]!==c||e[16]!==u||e[17]!==f||e[18]!==m||e[19]!==g?(x=n.jsxs(Qs,{children:[h,n.jsxs(ti,{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]=x):x=e[20],x}function wx(t){return t.stopPropagation()}function or(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 Cx(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=Jh({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(Or,{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(Or,{kind:"suspended",onResume:o}),e[6]=o,e[7]=a):a=e[7],a}}}function bi(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 kx(t){const e=W.c(2),{virtualMcpId:s}=t,i=Mt(s);if(!Js(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(gx,{}),e[1]=o):o=e[1],o}const yn={fast:{label:"Fast",subtitle:"Quick responses for simple tasks",icon:Ic},smart:{label:"Smart",subtitle:"Balanced quality and speed",icon:en},thinking:{label:"Thinking",subtitle:"Deeper reasoning for hard tasks",icon:Lf}},jx=["fast","smart","thinking"];function Nx(t){const e=W.c(15),{tier:s,onSelect:i}=t,[r,o]=P.useState(!1),a=yn[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=yn[s];let c;e[2]===Symbol.for("react.memo_cache_sentinel")?(c=n.jsx(Es,{size:14,className:"text-muted-foreground"}),e[2]=c):c=e[2];let d;e[3]!==l||e[4]!==h.label?(d=n.jsx(Ps,{asChild:!0,children:n.jsxs(se,{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=jx.map(p=>{const _=yn[p],g=_.icon;return n.jsxs("button",{type:"button",onClick:()=>{i(p),o(!1)},className:ce("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(Ui,{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(Rs,{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(Ts,{open:r,onOpenChange:o,children:[d,f]}),e[11]=r,e[12]=d,e[13]=f,e[14]=m):m=e[14],m}function Ex(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(se,{variant:"outline",size:"sm",disabled:!0,className:"w-fit",children:"Loading models…"}),children:n.jsx(Tx,{override:r,onOverrideChange:o})}):n.jsx(Nx,{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(Br,{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 Tx(t){const e=W.c(10),{override:s,onOverrideChange:i}=t,r=Rc(),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(Xm,{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 md=[{key:"capabilities",heading:"Built-in capabilities",icon:qo,tools:[{name:"web_search",title:"Web search",description:"Look up current information on the web",icon:Hi},{name:"generate_image",title:"Generate image",description:"Create images from a text prompt",icon:Hm},{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:If}]},{key:"files",heading:"Files & code",icon:Fa,tools:[{name:"read",title:"Read File",description:"Read a file from the workspace",icon:Yc},{name:"write",title:"Write File",description:"Create or overwrite a file",icon:Vo},{name:"edit",title:"Edit File",description:"Make targeted edits to an existing file",icon:Bf},{name:"grep",title:"Search Content",description:"Search file contents by pattern",icon:Uo},{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:Mf}]},{key:"context",heading:"Context",icon:La,tools:[{name:"read_resource",title:"Read Resource",description:"Read an MCP resource by URI",icon:La},{name:"read_prompt",title:"Read Prompt",description:"Read an MCP prompt definition",icon:nh}]},{key:"browser",heading:"Browser",icon:Us,tools:[{name:"take_screenshot",title:"Take Screenshot",description:"Capture a screenshot of a web page",icon:Kc},{name:"scrape_url",title:"Scrape URL",description:"Fetch and extract content from a URL",icon:Us},{name:"inspect_page",title:"Inspect Page",description:"Inspect a web page's structure",icon:Lo}]}],Px=md.flatMap(t=>t.tools.map(e=>e.name));function Rx(t){const e=t.replace(/[_-]+/g," ").trim();return e?e.toLowerCase().replace(/\b\w/g,s=>s.toUpperCase()):t}function Dx(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(se,{variant:"outline",size:"sm",disabled:!0,className:"w-fit",children:[n.jsx(qo,{size:14}),"Loading tools…"]}),children:n.jsx(Ax,{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 xl(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(sn,{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(Ym,{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 bl(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(Gt,{icon:s.icon,name:s.title,size:"2xs"}):r?n.jsx(r,{size:14,className:"text-muted-foreground"}):n.jsx(Of,{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=b=>{b.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 x;return e[16]!==c||e[17]!==u||e[18]!==g?(x=n.jsxs("div",{className:"flex items-center gap-2",children:[c,u,g]}),e[16]=c,e[17]=u,e[18]=g,e[19]=x):x=e[19],x}function Ax(t){const e=W.c(70),{agentId:s,value:i,onChange:r}=t,{org:o}=Re(),[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=Qe(h);let d;e[4]!==c?(d={client:c},e[4]=c,e[5]=d):d=e[5];const{data:u,isLoading:f}=sm(d),m=Wi();let p,_,g,x,b,v,y,S,C,j,T,B,I;if(e[6]!==m||e[7]!==u?.tools||e[8]!==f||e[9]!==r||e[10]!==a||e[11]!==i){const N=new Map(m.map(Ox)),E=new Map;for(const he of u?.tools??[]){const re=sf(he._meta)??"__other__",ve=rf(he.name,re==="__other__"?void 0:re),ie=he.title,ke=ie&&ie!==he.name?ie:Rx(ve);E.has(re)||E.set(re,{clientId:re,conn:N.get(re),tools:[]}),E.get(re).tools.push({name:he.name,display:ke,description:he.description})}const M=[...E.values()].sort(Lx),D=(u?.tools??[]).map(Mx),L=[...Px,...D],z=i===null?new Set(L):new Set(i),H=L.every(he=>z.has(he)),F=he=>r(L.every(re=>he.has(re))?null:[...he]),q=he=>{const re=new Set(z);re.has(he)?re.delete(he):re.add(he),F(re)},J=(he,re)=>{const ve=new Set(z);for(const ie of he)re?ve.add(ie):ve.delete(ie);F(ve)};x=Ts,I=a,b=l;let V;e[25]===Symbol.for("react.memo_cache_sentinel")?(V=n.jsx(qo,{size:14,className:"text-muted-foreground"}),e[25]=V):V=e[25];const U=H?"All tools":"Tools",K=!H&&n.jsxs(Um,{variant:"secondary",className:"ml-0.5 h-5 px-1.5 text-[11px] tabular-nums",children:[z.size,"/",L.length]});let Q;e[26]===Symbol.for("react.memo_cache_sentinel")?(Q=n.jsx(Es,{size:14,className:"text-muted-foreground"}),e[26]=Q):Q=e[26],e[27]!==U||e[28]!==K?(v=n.jsx(Ps,{asChild:!0,children:n.jsxs(se,{variant:"outline",size:"sm",className:"w-fit gap-1.5",children:[V,U,K,Q]})}),e[27]=U,e[28]=K,e[29]=v):v=e[29],g=Rs,T="p-0 w-80",B="start",_=Vm,e[30]===Symbol.for("react.memo_cache_sentinel")?(C=n.jsx(qm,{placeholder:"Search tools..."}),e[30]=C):C=e[30];const oe=H?`All ${L.length} tools enabled`:`${z.size} of ${L.length} enabled`;let O;e[31]!==oe?(O=n.jsx("span",{className:"text-xs text-muted-foreground",children:oe}),e[31]=oe,e[32]=O):O=e[32];let ee;e[33]!==r?(ee=()=>r(null),e[33]=r,e[34]=ee):ee=e[34];let te;e[35]!==H||e[36]!==ee?(te=n.jsx("button",{type:"button",onClick:ee,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]=ee,e[37]=te):te=e[37];let Y;e[38]===Symbol.for("react.memo_cache_sentinel")?(Y=n.jsx("span",{className:"text-muted-foreground/30",children:"·"}),e[38]=Y):Y=e[38];let $;e[39]!==r?($=()=>r([]),e[39]=r,e[40]=$):$=e[40];const ae=z.size===0;let ue;e[41]!==$||e[42]!==ae?(ue=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]=ue):ue=e[43];let fe;e[44]!==te||e[45]!==ue?(fe=n.jsxs("div",{className:"flex items-center gap-2",children:[te,Y,ue]}),e[44]=te,e[45]=ue,e[46]=fe):fe=e[46],e[47]!==O||e[48]!==fe?(j=n.jsxs("div",{className:"flex items-center justify-between border-b px-3 py-2",children:[O,fe]}),e[47]=O,e[48]=fe,e[49]=j):j=e[49],p=Gm,y="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(Km,{children:"No tools found"}),md.map(he=>{const re=he.tools.map(Bx),ve=re.filter(ie=>z.has(ie)).length;return n.jsx(Ha,{heading:n.jsx(bl,{label:he.heading,icon:he.icon,on:ve,total:re.length,onToggle:()=>J(re,ve!==re.length)}),children:he.tools.map(ie=>n.jsx(xl,{value:`${ie.title} ${ie.name}`,checked:z.has(ie.name),onToggle:()=>q(ie.name),title:ie.title,description:ie.description,leading:n.jsx(ie.icon,{size:16,className:"text-muted-foreground"})},ie.name))},he.key)}),M.map(he=>{const re=he.tools.map(Ix),ve=re.filter(ie=>z.has(ie)).length;return n.jsx(Ha,{heading:n.jsx(bl,{conn:he.conn,on:ve,total:re.length,onToggle:()=>J(re,ve!==re.length)}),children:he.tools.map(ie=>n.jsx(xl,{value:`${ie.display} ${ie.name} ${he.conn?.title??""}`,checked:z.has(ie.name),onToggle:()=>q(ie.name),title:ie.display,description:ie.description},ie.name))},he.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]=x,e[16]=b,e[17]=v,e[18]=y,e[19]=S,e[20]=C,e[21]=j,e[22]=T,e[23]=B,e[24]=I}else p=e[12],_=e[13],g=e[14],x=e[15],b=e[16],v=e[17],y=e[18],S=e[19],C=e[20],j=e[21],T=e[22],B=e[23],I=e[24];let R;e[50]!==p||e[51]!==y||e[52]!==S?(R=n.jsx(p,{className:y,children:S}),e[50]=p,e[51]=y,e[52]=S,e[53]=R):R=e[53];let k;e[54]!==_||e[55]!==R||e[56]!==C||e[57]!==j?(k=n.jsxs(_,{children:[C,j,R]}),e[54]=_,e[55]=R,e[56]=C,e[57]=j,e[58]=k):k=e[58];let w;e[59]!==g||e[60]!==k||e[61]!==T||e[62]!==B?(w=n.jsx(g,{className:T,align:B,children:k}),e[59]=g,e[60]=k,e[61]=T,e[62]=B,e[63]=w):w=e[63];let A;return e[64]!==x||e[65]!==b||e[66]!==v||e[67]!==w||e[68]!==I?(A=n.jsxs(x,{open:I,onOpenChange:b,children:[v,w]}),e[64]=x,e[65]=b,e[66]=v,e[67]=w,e[68]=I,e[69]=A):A=e[69],A}function Ix(t){return t.name}function Bx(t){return t.name}function Mx(t){return t.name}function Lx(t,e){return(t.conn?.title??t.clientId).localeCompare(e.conn?.title??e.clientId)}function Ox(t){return[t.id,t]}function Ri(t){const e=t.trim().split(/\s+/);return e.length!==5?!1:e.every(s=>/^[\d*/,-]+$/.test(s))}function $x(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 zx(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 Fx(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 Hx(t,e){return e===1?{minutes:"minute",hours:"hour",days:"day",weeks:"week"}[t]??t:t}const Wx=[{label:"5 minutes",cron:"*/5 * * * *"},{label:"Hour",cron:"0 * * * *"},{label:"Day",cron:"0 0 * * *"},{label:"Week",cron:"0 0 * * 1"}];function Ux({automationId:t,open:e,onOpenChange:s,onCustomSelect:i,onEventSelect:r,onWebhookCreated:o}){const{triggerAdd:a}=Ki(),[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}),le.success("Starter added"),d(!1)}catch(p){const _=p instanceof Error?p.message:"Failed to add starter";le.error(_)}},f=async()=>{try{const m=await a.mutateAsync({automation_id:t,type:"webhook"});d(!1),m.webhook?o?.(m.webhook):le.success("Webhook starter added")}catch(m){const p=m instanceof Error?m.message:"Failed to add webhook starter";le.error(p)}};return n.jsxs(Qs,{open:c,onOpenChange:d,children:[n.jsx(ei,{asChild:!0,children:n.jsxs(se,{variant:"outline",size:"sm",children:[n.jsx(Bt,{size:14}),"Add Starter"]})}),n.jsxs(ti,{align:"end",className:"w-[200px]",children:[n.jsxs(fm,{children:[n.jsxs(mm,{className:"gap-2.5",children:[n.jsx(ji,{size:14,className:"text-muted-foreground shrink-0"}),"Every..."]}),n.jsx(pm,{className:"w-[160px]",children:Wx.map(m=>n.jsxs(Ze,{className:"gap-2.5",onSelect:()=>u(m.cron),disabled:a.isPending,children:[n.jsx(ji,{size:14,className:"text-muted-foreground shrink-0"}),"Every ",m.label]},m.cron))})]}),n.jsxs(Ze,{className:"gap-2.5",onSelect:()=>{d(!1),i?.()},children:[n.jsx(ji,{size:14,className:"text-muted-foreground shrink-0"}),"Custom (cron)"]}),n.jsxs(Ze,{className:"gap-2.5",onSelect:()=>{d(!1),r?.()},children:[n.jsx(Mi,{size:14,className:"text-muted-foreground shrink-0"}),"Event"]}),n.jsxs(Ze,{className:"gap-2.5",onSelect:()=>{f()},disabled:a.isPending,children:[n.jsx(Hi,{size:14,className:"text-muted-foreground shrink-0"}),"Webhook"]})]})]})}function pd(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 x;e[0]===Symbol.for("react.memo_cache_sentinel")?(x=async(N,E)=>{try{await navigator.clipboard.writeText(N),u(E),le.success("Copied"),setTimeout(()=>u(null),1500)}catch{le.error("Failed to copy")}},e[0]=x):x=e[0];const b=x;let v;e[1]!==p||e[2]!==o||e[3]!==r?(v=r&&o&&p==="url"?`${r.replace(/\/$/,"")}/${o}`:r??"",e[1]=p,e[2]=o,e[3]=r,e[4]=v):v=e[4];const y=v,S=r&&o?p==="header"?`curl -X POST "${y}" \\
275
275
  -H "Authorization: Bearer ${o}" \\
276
276
  -H "Content-Type: application/json" \\
277
277
  -d '{"hello":"world"}'`:`curl -X POST "${y}" \\
@@ -290,7 +290,7 @@ ${ee}`:ee;c.setValue("metadata.instructions",te,{shouldDirty:!0})},V=new Set(d.m
290
290
  },
291
291
  body: JSON.stringify({ hello: "world" }),
292
292
  });`:"",j=f==="curl"?S:C;let T;e[5]!==h?(T=n.jsx(is,{children:h}),e[5]=h,e[6]=T):T=e[6];let B;e[7]!==c?(B=n.jsx(Fo,{children:c}),e[7]=c,e[8]=B):B=e[8];let I;e[9]!==T||e[10]!==B?(I=n.jsxs(ss,{children:[T,B]}),e[9]=T,e[10]=B,e[11]=I):I=e[11];let R;e[12]!==p||e[13]!==d||e[14]!==y||e[15]!==f||e[16]!==j||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:y}),n.jsxs(se,{size:"sm",variant:"outline",onClick:()=>b(y,"url"),children:[n.jsx(fs,{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(se,{size:"sm",variant:"outline",onClick:()=>b(o,"token"),children:[n.jsx(fs,{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(Wo,{value:f,onValueChange:N=>m(N),children:n.jsxs(Ho,{className:"h-8 p-[2px]",children:[n.jsx(ys,{value:"curl",className:"h-7 px-2.5 text-xs",children:"curl"}),n.jsx(ys,{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(sn,{id:g,checked:p==="url",onCheckedChange:N=>_(N?"url":"header")}),"Token in URL"]})]}),n.jsxs(se,{size:"sm",variant:"outline",onClick:()=>b(j,"example"),children:[n.jsx(fs,{size:13}),d==="example"?"Copied":"Copy"]})]}),n.jsx("div",{className:"rounded-md border overflow-hidden min-w-0",children:n.jsx(tp,{code:j,language:f==="curl"?"shell":"typescript",readOnly:!0,disableDiagnostics:!0,height:180})})]})]}):null,e[12]=p,e[13]=d,e[14]=y,e[15]=f,e[16]=j,e[17]=o,e[18]=g,e[19]=r,e[20]=R):R=e[20];let k;e[21]!==i?(k=n.jsx(si,{children:n.jsx(se,{onClick:()=>i(!1),children:"Done"})}),e[21]=i,e[22]=k):k=e[22];let w;e[23]!==I||e[24]!==R||e[25]!==k?(w=n.jsxs(Ot,{className:"max-w-lg",children:[I,R,k]}),e[23]=I,e[24]=R,e[25]=k,e[26]=w):w=e[26];let A;return e[27]!==i||e[28]!==s||e[29]!==w?(A=n.jsx(Lt,{open:s,onOpenChange:i,children:w}),e[27]=i,e[28]=s,e[29]=w,e[30]=A):A=e[30],A}function Kx(t){const e=W.c(83),{trigger:s,automationId:i,connectionName:r}=t,{triggerAdd:o,triggerRemove:a,triggerRotateToken:l}=Ki(),[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?Fx(s.cron_expression):null,e[0]=s.cron_expression,e[1]=p):p=e[1];const _=p,[g,x]=P.useState(_?.count??1),[b,v]=P.useState(!1),[y,S]=P.useState(s.cron_expression??""),C=a.isPending||o.isPending||l.isPending,j=s.type==="cron",T=s.type==="webhook";let B;e[2]!==i||e[3]!==a||e[4]!==s.id?(B=async()=>{try{await a.mutateAsync({trigger_id:s.id,automation_id:i}),le.success("Starter removed")}catch{le.error("Failed to remove starter")}c(!1)},e[2]=i,e[3]=a,e[4]=s.id,e[5]=B):B=e[5];const I=B;let R;e[6]!==o||e[7]!==i||e[8]!==y||e[9]!==a||e[10]!==s.cron_expression||e[11]!==s.id?(R=async()=>{const re=y.trim();if(!re||!Ri(re)||re===s.cron_expression){v(!1),S(s.cron_expression??"");return}try{await o.mutateAsync({automation_id:i,type:"cron",cron_expression:re}),await a.mutateAsync({trigger_id:s.id,automation_id:i}),v(!1)}catch{le.error("Failed to update starter"),S(s.cron_expression??""),v(!1)}},e[6]=o,e[7]=i,e[8]=y,e[9]=a,e[10]=s.cron_expression,e[11]=s.id,e[12]=R):R=e[12];const k=R;let w;e[13]!==i||e[14]!==l||e[15]!==s.id?(w=async()=>{u(!1);try{const re=await l.mutateAsync({trigger_id:s.id,automation_id:i});m({url:re.url,token:re.token})}catch(re){const ve=re,ie=ve instanceof Error?ve.message:"Failed to rotate token";le.error(ie)}},e[13]=i,e[14]=l,e[15]=s.id,e[16]=w):w=e[16];const A=w;let N;e[17]!==o||e[18]!==i||e[19]!==_||e[20]!==a||e[21]!==s.cron_expression||e[22]!==s.id?(N=async re=>{if(!_)return;const ve=_.unit==="minutes"?5:1,ie=Math.max(ve,re);ie!==re&&x(ie);const ke=zx(ie,_.unit);if(ke!==s.cron_expression)try{await o.mutateAsync({automation_id:i,type:"cron",cron_expression:ke}),await a.mutateAsync({trigger_id:s.id,automation_id:i})}catch{le.error("Failed to update starter"),x(_.count)}},e[17]=o,e[18]=i,e[19]=_,e[20]=a,e[21]=s.cron_expression,e[22]=s.id,e[23]=N):N=e[23];const E=N;let M;e[24]!==j||e[25]!==T?(M=j?n.jsx(ji,{size:14,className:"text-muted-foreground shrink-0"}):T?n.jsx(Hi,{size:14,className:"text-muted-foreground shrink-0"}):n.jsx(Mi,{size:14,className:"text-muted-foreground shrink-0"}),e[24]=j,e[25]=T,e[26]=M):M=e[26];let D;e[27]!==r||e[28]!==g||e[29]!==y||e[30]!==E||e[31]!==k||e[32]!==_||e[33]!==j||e[34]!==b||e[35]!==C||e[36]!==T||e[37]!==s.cron_expression||e[38]!==s.event_type||e[39]!==s.params?(D=_&&j?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:re=>x(parseInt(re.target.value)||1),onBlur:()=>E(g),onKeyDown:re=>{re.key==="Enter"&&re.target.blur(),re.key==="Escape"&&x(_.count)},disabled:C,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:Hx(_.unit,g)})]}):j&&b?n.jsxs(n.Fragment,{children:[n.jsx("input",{type:"text",value:y,onChange:re=>S(re.target.value),onBlur:k,onKeyDown:re=>{re.key==="Enter"&&re.target.blur(),re.key==="Escape"&&(v(!1),S(s.cron_expression??""))},className:"flex-1 text-sm font-mono bg-transparent outline-none",autoFocus:!0}),y&&!Ri(y)&&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:j?$x(s.cron_expression??""):T?"Webhook · POST to fire":`${s.event_type}${r?` · ${r}`:""}`}),!j&&!T&&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(Vx).join(", ")})]}),e[27]=r,e[28]=g,e[29]=y,e[30]=E,e[31]=k,e[32]=_,e[33]=j,e[34]=b,e[35]=C,e[36]=T,e[37]=s.cron_expression,e[38]=s.event_type,e[39]=s.params,e[40]=D):D=e[40];let L;e[41]!==C?(L=C&&n.jsx(Ce,{size:13,className:"animate-spin text-muted-foreground"}),e[41]=C,e[42]=L):L=e[42];let z;e[43]!==_||e[44]!==j||e[45]!==b||e[46]!==s.cron_expression?(z=j&&!_&&!b&&n.jsx(se,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 opacity-0 group-hover:opacity-100 transition-opacity",onClick:()=>{S(s.cron_expression??""),v(!0)},children:n.jsx(Vo,{size:13,className:"text-muted-foreground"})}),e[43]=_,e[44]=j,e[45]=b,e[46]=s.cron_expression,e[47]=z):z=e[47];let H;e[48]!==T?(H=T&&n.jsx(se,{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]=T,e[49]=H):H=e[49];let F;e[50]===Symbol.for("react.memo_cache_sentinel")?(F=n.jsx(se,{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(ps,{size:13,className:"text-muted-foreground"})}),e[50]=F):F=e[50];let q;e[51]!==H||e[52]!==L||e[53]!==z?(q=n.jsxs("div",{className:"ml-auto flex items-center gap-1",children:[L,z,H,F]}),e[51]=H,e[52]=L,e[53]=z,e[54]=q):q=e[54];let J;e[55]!==q||e[56]!==M||e[57]!==D?(J=n.jsxs("div",{className:"flex items-center gap-2.5 px-3 py-2.5 rounded-lg border border-border bg-background group",children:[M,D,q]}),e[55]=q,e[56]=M,e[57]=D,e[58]=J):J=e[58];let V;e[59]===Symbol.for("react.memo_cache_sentinel")?(V=n.jsxs(Tr,{children:[n.jsx(Pr,{children:"Remove Starter"}),n.jsx(Rr,{children:"Are you sure you want to remove this starter?"})]}),e[59]=V):V=e[59];let U;e[60]===Symbol.for("react.memo_cache_sentinel")?(U=n.jsx(Ar,{children:"Cancel"}),e[60]=U):U=e[60];let K;e[61]!==I?(K=n.jsxs(Er,{children:[V,n.jsxs(Dr,{children:[U,n.jsx(Ir,{onClick:I,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Remove"})]})]}),e[61]=I,e[62]=K):K=e[62];let Q;e[63]!==h||e[64]!==K?(Q=n.jsx(Nr,{open:h,onOpenChange:c,children:K}),e[63]=h,e[64]=K,e[65]=Q):Q=e[65];let oe;e[66]===Symbol.for("react.memo_cache_sentinel")?(oe=n.jsxs(Tr,{children:[n.jsx(Pr,{children:"Rotate webhook token"}),n.jsx(Rr,{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]=oe):oe=e[66];let O;e[67]===Symbol.for("react.memo_cache_sentinel")?(O=n.jsx(Ar,{children:"Cancel"}),e[67]=O):O=e[67];let ee;e[68]!==A?(ee=n.jsxs(Er,{children:[oe,n.jsxs(Dr,{children:[O,n.jsx(Ir,{onClick:A,children:"Rotate"})]})]}),e[68]=A,e[69]=ee):ee=e[69];let te;e[70]!==d||e[71]!==ee?(te=n.jsx(Nr,{open:d,onOpenChange:u,children:ee}),e[70]=d,e[71]=ee,e[72]=te):te=e[72];const Y=f!==null;let $;e[73]===Symbol.for("react.memo_cache_sentinel")?($=re=>{re||m(null)},e[73]=$):$=e[73];const ae=f?.url??null,ue=f?.token??null;let fe;e[74]!==Y||e[75]!==ae||e[76]!==ue?(fe=n.jsx(pd,{open:Y,onOpenChange:$,url:ae,token:ue,title:"New webhook token",description:"The previous token has been revoked. Copy the new token now — it will not be shown again."}),e[74]=Y,e[75]=ae,e[76]=ue,e[77]=fe):fe=e[77];let he;return e[78]!==J||e[79]!==Q||e[80]!==te||e[81]!==fe?(he=n.jsxs(n.Fragment,{children:[J,Q,te,fe]}),e[78]=J,e[79]=Q,e[80]=te,e[81]=fe,e[82]=he):he=e[82],he}function Vx(t){const[e,s]=t;return`${e}: ${s}`}const qx=30;function Gx(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 Yx(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=Wi(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}=Ki(),{data:p,isLoading:_}=Jm(a);let g,x,b,v,y,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 T=p?.find(D=>D.type===h);let B;e[17]!==m||e[18]!==s||e[19]!==a||e[20]!==h||e[21]!==i||e[22]!==u?(B=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}),le.success("Event trigger added"),i()}catch{le.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]=B):B=e[23],g=B,x="flex flex-col gap-3 px-3 py-3 rounded-lg border border-border bg-background";let I,R;e[24]===Symbol.for("react.memo_cache_sentinel")?(R=n.jsx(Mi,{size:14,className:"text-muted-foreground shrink-0"}),I=n.jsx("span",{className:"text-sm font-medium",children:"Event trigger"}),e[24]=I,e[25]=R):(I=e[24],R=e[25]);let k;e[26]===Symbol.for("react.memo_cache_sentinel")?(k=n.jsx(ps,{size:13}),e[26]=k):k=e[26],e[27]!==i?(b=n.jsxs("div",{className:"flex items-center gap-2",children:[R,I,n.jsx("button",{type:"button",className:"ml-auto shrink-0 p-0.5 rounded text-muted-foreground hover:text-foreground",onClick:i,children:k})]}),e[27]=i,e[28]=b):b=e[28];const w=a??"";let A;e[29]===Symbol.for("react.memo_cache_sentinel")?(A=D=>{l(D),c(void 0),f({})},e[29]=A):A=e[29];let N;e[30]===Symbol.for("react.memo_cache_sentinel")?(N=n.jsx(Pt,{className:"w-full",children:n.jsx(Rt,{placeholder:"Select connection..."})}),e[30]=N):N=e[30];let E;e[31]!==o?(E=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]=E):E=e[32];let M;e[33]!==E?(M=n.jsx(Dt,{children:E}),e[33]=E,e[34]=M):M=e[34],e[35]!==w||e[36]!==M?(v=n.jsxs(At,{value:w,onValueChange:A,children:[N,M]}),e[35]=w,e[36]=M,e[37]=v):v=e[37],e[38]!==a||e[39]!==h||e[40]!==_||e[41]!==p?(y=a&&n.jsxs(At,{value:h??"",onValueChange:D=>{c(D),f({})},children:[n.jsx(Pt,{className:"w-full",children:_?n.jsxs("span",{className:"flex items-center gap-2 text-muted-foreground",children:[n.jsx(Ce,{size:13,className:"animate-spin"}),"Loading events..."]}):n.jsx(Rt,{placeholder:"Select event type...",children:h??"Select event type..."})}),n.jsx(Dt,{children:p?.map(Jx)})]}),e[38]=a,e[39]=h,e[40]=_,e[41]=p,e[42]=y):y=e[42],S=T?.paramsSchema&&Object.keys(T.paramsSchema).length>0&&n.jsx("div",{className:"flex flex-col gap-2",children:Object.entries(T.paramsSchema).map(D=>{const[L,z]=D;return n.jsxs("div",{className:"flex flex-col gap-1",children:[n.jsxs("label",{className:"text-xs text-muted-foreground",children:[L,z.description&&n.jsxs("span",{className:"text-muted-foreground/60",children:[" ","— ",z.description]})]}),z.enum?n.jsxs(At,{value:u[L]??"",onValueChange:H=>f(F=>({...F,[L]:H})),children:[n.jsx(Pt,{className:"w-full",children:n.jsx(Rt,{placeholder:`Select ${L}...`})}),n.jsx(Dt,{children:z.enum.map(Xx)})]}):n.jsx("input",{type:"text",value:u[L]??"",onChange:H=>f(F=>({...F,[L]:H.target.value})),placeholder:z.description??L,className:"text-sm border border-border rounded-md bg-background px-2 py-1.5 focus:outline-none focus:ring-1 focus:ring-ring"})]},L)})}),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]=x,e[13]=b,e[14]=v,e[15]=y,e[16]=S}else g=e[11],x=e[12],b=e[13],v=e[14],y=e[15],S=e[16];let C;e[43]!==m||e[44]!==a||e[45]!==h||e[46]!==g?(C=a&&h&&n.jsx(se,{size:"sm",onClick:g,disabled:m.isPending,children:m.isPending?n.jsx(Ce,{size:13,className:"animate-spin"}):"Add trigger"}),e[43]=m,e[44]=a,e[45]=h,e[46]=g,e[47]=C):C=e[47];let j;return e[48]!==x||e[49]!==b||e[50]!==v||e[51]!==y||e[52]!==S||e[53]!==C?(j=n.jsxs("div",{className:x,children:[b,v,y,S,C]}),e[48]=x,e[49]=b,e[50]=v,e[51]=y,e[52]=S,e[53]=C,e[54]=j):j=e[54],j}function Xx(t){return n.jsx(at,{value:t,children:t},t)}function Jx(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 Qx({automationId:t,automation:e,onBack:s,onDelete:i}){const r=e.virtual_mcp_id,{org:o}=Re(),{update:a,triggerAdd:l,run:h}=Ki(),c=Wi(),d=new Map(c.map($=>[$.id,$.title])),{openTask:u}=ts(),{setChatOpen:f}=Io(),{sendMessage:m}=Ns(),p=e.messages?.[0]?.metadata?.tiptapDoc??void 0,[_,g]=P.useState(p),[x,b]=P.useState(!1),[v,y]=P.useState(!1),[S,C]=P.useState(!1),[j,T]=P.useState(""),[B,I]=P.useState(!1),[R,k]=P.useState(null),[w,A]=P.useState(!1),[N,E]=P.useState(!1),[M,D]=P.useState(!1),L=async()=>{if(w)return;const ae=Gu(_).filter(ue=>ue.type==="text").map(ue=>ue.text).join(`
293
- `);if(ae.trim()){A(!0);try{ee(),Le("automation_improve_clicked",{automation_id:t,agent_id:r,instructions_length:ae.length}),f(!0),await m({tiptapDoc:Ih({managerAgentId:Nc.AUTOMATION_MANAGER(o.id),managerName:"Automation Manager",kind:"automation",id:t,instructions:ae})})}finally{A(!1)}}},z=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,F=kc({defaultValues:{name:e.name,active:e.active,tier:z,modelOverride:H,tools:e.tools??null,maxAgentSteps:e.maxAgentSteps??null}}),q=F.watch("active"),[J,V]=P.useReducer(Gx,null),U=()=>{J!==null&&(Le("automation_updated",{automation_id:t,agent_id:r,fields:Array.from(J.fields),save_count:J.saveCount,edit_duration_ms:Date.now()-J.start}),V({type:"reset"}))},K=async()=>{const $=F.control._formState.dirtyFields,ae=Object.keys($);if(ae.length===0&&!M)return!0;const ue=F.getValues(),fe=F.control._defaultValues;F.reset(ue,{keepValues:!0});const he=M;D(!1);const re={tier:ue.tier,...ue.modelOverride?{modelId:ue.modelOverride.modelId,credentialId:ue.modelOverride.credentialId,modelTitle:ue.modelOverride.title}:{}},ve={id:t,name:ue.name,active:ue.active,models:re,tools:ue.tools,maxAgentSteps:ue.maxAgentSteps,messages:qu(_),temperature:0};try{await a.mutateAsync(ve)}catch{return F.reset(fe,{keepValues:!0}),he&&D(!0),!1}const ie=[...ae];return he&&ie.push("messages"),V({type:"accumulate",now:Date.now(),fields:ie}),O(),!0},{schedule:Q,flush:oe}=Mr({save:K}),{schedule:O,flush:ee}=Mr({delayMs:3e4,save:async()=>U()});P.useEffect(()=>{const $=F.watch(()=>Q());return()=>$.unsubscribe()},[]);const te=$=>{if(g($),!N){E(!0);return}D(!0),Q()},Y=async()=>{Le("automation_test_clicked",{automation_id:t,agent_id:r});const $=await oe();if(ee(),!!$){if(!_){le.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(se,{variant:"ghost",size:"sm",onClick:s,children:[n.jsx(ah,{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:F.control,name:"name",render:({field:$})=>n.jsx(Ve,{...$,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(se,{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:F.control,name:"active",render:({field:$})=>n.jsx(Br,{checked:$.value,onCheckedChange:ae=>{$.onChange(ae),oe()},className:"cursor-pointer"})}),n.jsx("span",{className:"text-sm text-muted-foreground",children:q?"Active":"Inactive"}),n.jsx("span",{className:"text-muted-foreground/50 text-sm",children:"·"}),n.jsx(Jc,{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(Ux,{automationId:t,open:x,onOpenChange:b,onCustomSelect:()=>{C(!0),I(!1),T("")},onEventSelect:()=>{I(!0),C(!1)},onWebhookCreated:$=>{Le("automation_trigger_added",{automation_id:t,trigger_type:"webhook"}),k($)}})]}),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:()=>b(!0),children:"Add a starter"})," ","to get going."]})}):n.jsx("div",{className:"flex flex-col gap-2",children:e.triggers.map($=>n.jsx(Kx,{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(ji,{size:14,className:"text-muted-foreground shrink-0"}),n.jsx("input",{type:"text",value:j,onChange:$=>T($.target.value),onBlur:async()=>{const $=j.trim();if(!(!$||!Ri($)))try{await l.mutateAsync({automation_id:t,type:"cron",cron_expression:$}),Le("automation_trigger_added",{automation_id:t,trigger_type:"cron"}),le.success("Starter added"),C(!1),T("")}catch{le.error("Failed to add starter")}},onKeyDown:async $=>{const ae=j.trim();$.key==="Enter"&&ae&&Ri(ae)&&$.target.blur(),$.key==="Escape"&&(C(!1),T(""))},placeholder:"0 9 * * 1-5",className:"flex-1 text-sm font-mono bg-transparent outline-none placeholder:text-muted-foreground/40",autoFocus:!0}),j&&!Ri(j)&&n.jsx("span",{className:"text-xs text-muted-foreground/60 shrink-0",children:"invalid"}),l.isPending&&n.jsx(Ce,{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:()=>{C(!1),T("")},children:n.jsx(ps,{size:13})})]}),B&&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(Ce,{size:13,className:"animate-spin text-muted-foreground"}),n.jsx("span",{className:"text-sm text-muted-foreground",children:"Loading connections..."})]}),children:n.jsx(Yx,{automationId:t,onDone:()=>I(!1)})}),n.jsx(pd,{open:R!==null,onOpenChange:$=>{$||k(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(se,{variant:"outline",size:"sm",className:"h-7 gap-1.5 px-2 text-xs",disabled:w||!_,onClick:L,children:[n.jsx(en,{size:13}),"Improve"]})]}),n.jsx($u,{tiptapDoc:_,setTiptapDoc:te,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(zu,{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(Pe,{children:[n.jsx(Ee,{asChild:!0,children:n.jsxs(se,{type:"button",variant:"default",className:"h-8 gap-1.5 rounded-md px-3 text-sm font-medium",onClick:Y,disabled:!r,children:[n.jsx(Wm,{size:16}),"Test"]})}),n.jsx(Te,{children:"Test Automation"})]})})]})})]}),n.jsxs(nf,{open:v,onOpenChange:y,className:"flex flex-col gap-2.5",children:[n.jsxs(of,{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(Es,{size:14,className:"text-muted-foreground/60 transition-transform group-data-[state=open]:rotate-180"})]}),n.jsxs(af,{className:"flex flex-col gap-5 pt-0.5",children:[n.jsx(Ex,{tier:F.watch("tier"),onTierChange:$=>F.setValue("tier",$,{shouldDirty:!0}),override:F.watch("modelOverride"),onOverrideChange:$=>F.setValue("modelOverride",$,{shouldDirty:!0})}),n.jsx(Dx,{agentId:r||null,value:F.watch("tools"),onChange:$=>F.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(Ve,{type:"number",min:1,max:100,className:"w-40",placeholder:`${qx} (default)`,value:F.watch("maxAgentSteps")??"",onChange:$=>{const ae=$.target.value.trim(),ue=ae===""?null:Number(ae);F.setValue("maxAgentSteps",ue===null||Number.isNaN(ue)?null:ue,{shouldDirty:!0})}})]})]})]})]})]})}function Ks(){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(Ce,{size:20,className:"animate-spin text-muted-foreground"})}),t[0]=e):e=t[0],e}const _d=[{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 gd(t){const e=_d.find(i=>i.key===t).ms,s=Date.now();return{startDate:new Date(s-e).toISOString(),endDate:new Date(s).toISOString()}}function eb(t){const e=W.c(12),{automationId:s,triggerIds:i}=t,[r,o]=P.useState("30d"),[a,l]=P.useState(sb);let h;e[0]===Symbol.for("react.memo_cache_sentinel")?(h=p=>{const _=p;o(_),l(gd(_))},e[0]=h):h=e[0];let c;e[1]===Symbol.for("react.memo_cache_sentinel")?(c=n.jsx(Pt,{className:"w-44",children:n.jsx(Rt,{})}),e[1]=c):c=e[1];let d;e[2]===Symbol.for("react.memo_cache_sentinel")?(d=n.jsx(Dt,{children:_d.map(tb)}),e[2]=d):d=e[2];let u;e[3]!==r?(u=n.jsx("div",{className:"flex items-center justify-end",children:n.jsxs(At,{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(sp,{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 tb(t){return n.jsx(at,{value:t.key,children:t.label},t.key)}function sb(){return gd("30d")}function ib(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(Ks,{}),e[2]=o):o=e[2];let a;return e[3]!==r.id?(a=n.jsx(P.Suspense,{fallback:o,children:n.jsx(rb,{id:r.id})}),e[3]=r.id,e[4]=a):a=e[4],a}function rb(t){const e=W.c(24),{id:s}=t,i=es(),{data:r,isLoading:o}=Zm(s),[a,l]=P.useState("settings");let h;e[0]!==i?(h=()=>{i({to:".",search:ob,replace:!0})},e[0]=i,e[1]=h):h=e[1];const c=h;if(o){let y;return e[2]===Symbol.for("react.memo_cache_sentinel")?(y=n.jsx(Ks,{}),e[2]=y):y=e[2],y}if(!r){let y;return e[3]===Symbol.for("react.memo_cache_sentinel")?(y=n.jsx("div",{className:"flex h-full w-full items-center justify-center text-sm text-muted-foreground",children:"Automation not found"}),e[3]=y):y=e[3],y}let d;e[4]!==r.triggers?(d=r.triggers.map(nb),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(ah,{size:14}),e[6]=f):f=e[6];let m;e[7]!==c?(m=n.jsxs(se,{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")?(_=y=>l(y),e[10]=_):_=e[10];let g;e[11]!==a?(g=n.jsx(sh,{tabs:p,activeTab:a,onTabChange:_}),e[11]=a,e[12]=g):g=e[12];let x;e[13]!==m||e[14]!==g?(x=n.jsxs("div",{className:"flex items-center justify-between pb-4 shrink-0",children:[m,g]}),e[13]=m,e[14]=g,e[15]=x):x=e[15];let b;e[16]!==r||e[17]!==s||e[18]!==a||e[19]!==u?(b=a==="settings"?n.jsx(Qx,{automationId:s,automation:r}):n.jsx(eb,{automationId:s,triggerIds:u}),e[16]=r,e[17]=s,e[18]=a,e[19]=u,e[20]=b):b=e[20];let v;return e[21]!==x||e[22]!==b?(v=n.jsx(Tt,{children:n.jsx(Tt.Content,{children:n.jsxs(Tt.Body,{children:[x,b]})})}),e[21]=x,e[22]=b,e[23]=v):v=e[23],v}function nb(t){return t.id}function ob(t){return{...t,main:"automations"}}function ab(t){const e=W.c(20),{virtualMcpId:s}=t,i=es(),{data:r}=Qm(s),o=r===void 0?[]:r,{create:a}=Ki(),[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:k=>({...k,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(ep(s));f(R.id)};let p;e[2]===Symbol.for("react.memo_cache_sentinel")?(p=n.jsx(Bt,{size:14}),e[2]=p):p=e[2];let _;e[3]!==a.isPending||e[4]!==m?(_=n.jsxs(se,{size:"sm",onClick:m,disabled:a.isPending,children:[p,"New automation"]}),e[3]=a.isPending,e[4]=m,e[5]=_):_=e[5];const g=_,x=Tt,b=Tt,v=Tt;let y;e[6]===Symbol.for("react.memo_cache_sentinel")?(y=n.jsx(Tt.Title,{children:"Automations"}),e[6]=y):y=e[6];const S=o.length>0&&n.jsx(th,{value:l,onChange:h,placeholder:"Search automations...",className:"w-full md:w-[375px]"});let C;e[7]!==g||e[8]!==S?(C=n.jsxs("div",{className:"flex flex-col gap-6",children:[y,n.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[S,g]})]}),e[7]=g,e[8]=S,e[9]=C):C=e[9];const j=o.length===0?n.jsx("div",{className:"flex items-center justify-center py-20",children:n.jsx(kr,{image:n.jsx(Mi,{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(kr,{image:n.jsx(Mi,{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(ip,{automation:R,onClick:()=>f(R.id)},R.id))});let T;e[10]!==j||e[11]!==v.Body||e[12]!==C?(T=n.jsxs(v.Body,{children:[C,j]}),e[10]=j,e[11]=v.Body,e[12]=C,e[13]=T):T=e[13];let B;e[14]!==T||e[15]!==b.Content?(B=n.jsx(b.Content,{children:T}),e[14]=T,e[15]=b.Content,e[16]=B):B=e[16];let I;return e[17]!==x||e[18]!==B?(I=n.jsx(x,{children:B}),e[17]=x,e[18]=B,e[19]=I):I=e[19],I}function lb(t){const e=W.c(3),{virtualMcpId:s}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=n.jsx(Ks,{}),e[0]=i):i=e[0];let r;return e[1]!==s?(r=n.jsx(P.Suspense,{fallback:i,children:n.jsx(ab,{virtualMcpId:s})}),e[1]=s,e[2]=r):r=e[2],r}function cb(){const t=W.c(2);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsx(xs,{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(xs,{className:"h-3 w-full"}),n.jsx(xs,{className:"h-3 w-5/6"}),n.jsx(xs,{className:"h-3 w-2/3"})]}),n.jsx(xs,{className:"mt-2 h-8 w-24"})]})}),t[1]=s):s=t[1],s}function hb(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 db(t){const e=W.c(11),{slug:s}=t,i=Yu();let r;e[0]!==i?.messages?(r=i?.messages??[],e[0]=i?.messages,e[1]=r):r=e[1];const o=r;let a;e[2]!==o||e[3]!==s?(a=hb(o,s),e[2]=o,e[3]=s,e[4]=a):a=e[4];const l=a;if(!l){let f;return e[5]===Symbol.for("react.memo_cache_sentinel")?(f=n.jsx("div",{className:"h-full w-full bg-background",children:n.jsx(cb,{})}),e[5]=f):f=e[5],f}const h=l.url,c=String(l.bytes),d=`${s}.html`;let u;return e[6]!==l.url||e[7]!==s||e[8]!==c||e[9]!==d?(u=n.jsx(Gc,{readUrl:h,marker:c,title:d},s),e[6]=l.url,e[7]=s,e[8]=c,e[9]=d,e[10]=u):u=e[10],u}function ub(t){const e=W.c(37),{file:s,onClose:i}=t;let r,o;e[0]!==s.filename?(r=n.jsx($o,{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=am(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(em,{size:14}),e[11]=c):c=e[11];let d;e[12]!==s.downloadUrl||e[13]!==s.filename?(d=n.jsx(Ee,{asChild:!0,children:n.jsx(se,{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(Te,{side:"bottom",children:"Download"}),e[15]=u):u=e[15];let f;e[16]!==d?(f=n.jsxs(Pe,{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(ii,{size:14}),e[20]=p):p=e[20];let _;e[21]!==m?(_=n.jsx(Ee,{asChild:!0,children:n.jsx(se,{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(Te,{side:"bottom",children:"Open in new tab"}),e[23]=g):g=e[23];let x;e[24]!==_?(x=n.jsxs(Pe,{children:[_,g]}),e[24]=_,e[25]=x):x=e[25];let b;e[26]===Symbol.for("react.memo_cache_sentinel")?(b=n.jsx(ps,{size:14}),e[26]=b):b=e[26];let v;e[27]!==i?(v=n.jsx(Ee,{asChild:!0,children:n.jsx(se,{variant:"ghost",size:"icon",onClick:i,children:b})}),e[27]=i,e[28]=v):v=e[28];let y;e[29]===Symbol.for("react.memo_cache_sentinel")?(y=n.jsx(Te,{side:"bottom",children:"Close"}),e[29]=y):y=e[29];let S;e[30]!==v?(S=n.jsxs(Pe,{children:[v,y]}),e[30]=v,e[31]=S):S=e[31];let C;return e[32]!==x||e[33]!==S||e[34]!==h||e[35]!==f?(C=n.jsxs("div",{className:"flex h-9 shrink-0 items-center gap-1 border-b border-border/60 px-2",children:[h,f,x,S]}),e[32]=x,e[33]=S,e[34]=h,e[35]=f,e[36]=C):C=e[36],C}function fb(t){const e=W.c(24),{fileKey:s,taskId:i}=t,r=es(),{data:o,isPending:a}=Pc(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:mb,replace:!0}),e[3]=r,e[4]=c):c=e[4];const d=c;if(!h){if(a){let v;return e[5]===Symbol.for("react.memo_cache_sentinel")?(v=n.jsx("div",{className:"h-full w-full bg-background",children:n.jsx(nm,{})}),e[5]=v):v=e[5],v}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($o,{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 x;e[11]!==d?(x=n.jsx(se,{variant:"ghost",size:"sm",onClick:d,children:"Close"}),e[11]=d,e[12]=x):x=e[12];let b;return e[13]!==_||e[14]!==x?(b=n.jsxs("div",{className:"flex h-full w-full flex-col items-center justify-center gap-2 bg-background",children:[_,g,x]}),e[13]=_,e[14]=x,e[15]=b):b=e[15],b}let u;e[16]!==h||e[17]!==d?(u=n.jsx(ub,{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(om,{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 mb(t){return{...t,main:"0"}}const yl="home";function pb(t){const e=W.c(5),{label:s}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=n.jsx(xs,{className:"aspect-video w-2/3 max-w-xl"}),e[0]=i):i=e[0];let r;e[1]!==s?(r=s&&n.jsx("p",{className:"text-xs text-muted-foreground",children:s}),e[1]=s,e[2]=r):r=e[2];let o;return e[3]!==r?(o=n.jsxs("div",{className:"flex h-full w-full flex-col items-center justify-center gap-3 bg-background",children:[i,r]}),e[3]=r,e[4]=o):o=e[4],o}function _b(t){const e=W.c(12),{path:s}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i={refetchIntervalWhenAbsent:2e3},e[0]=i):i=e[0];const r=lm(yl,s,i),o=cm(yl);let a;e[1]!==s||e[2]!==o?(a=o(s),e[1]=s,e[2]=o,e[3]=a):a=e[3];const l=a;if(r.isPending||!r.data){const d=!r.isPending&&!r.data?"Waiting for the deck to sync…":void 0;let u;return e[4]!==d?(u=n.jsx(pb,{label:d}),e[4]=d,e[5]=u):u=e[5],u}let h;e[6]!==r.data?(h=hm(r.data),e[6]=r.data,e[7]=h):h=e[7];let c;return e[8]!==s||e[9]!==l||e[10]!==h?(c=n.jsx(Gc,{readUrl:l,marker:h,title:s,savePath:s}),e[8]=s,e[9]=l,e[10]=h,e[11]=c):c=e[11],c}const Sl=P.lazy(()=>qt(()=>import("./project-app-view-CjNYmwJu.js"),__vite__mapDeps([163,1,2,97,6,7,8,9,10,11,12,13,14,15,16,3,17,4,5,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,98,99,46,47,48,100,101,49,102,103,58,91,92,93,94,85,95,57,96,59,104,105,106,107,108,66,109,56,110,71,72,50,111,126])).then(t=>({default:t.AppViewContent})));function gb(t){const e=W.c(53),{activeTab:s,virtualMcpId:i,taskId:r,layoutTabs:o,expandedTools:a,automationTabParsed:l}=t;if(Vf(s)){let v;return e[0]!==i?(v=n.jsx(nl,{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(lb,{virtualMcpId:i}),e[4]=i,e[5]=v):v=e[5],v}if(s==="preview"){let v;return e[6]!==i?(v=n.jsx(x1,{virtualMcpId:i}),e[6]=i,e[7]=v):v=e[7],v}if(s==="content"){let v;return e[8]!==i?(v=n.jsx(kx,{virtualMcpId:i}),e[8]=i,e[9]=v):v=e[9],v}if(l){let v;return e[10]!==s?(v=n.jsx(ib,{tabId:s}),e[10]=s,e[11]=v):v=e[11],v}let h;e[12]!==s?(h=qf(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(db,{slug:c.slug}),e[14]=c.slug,e[15]=v):v=e[15],v}let d;e[16]!==s?(d=Hc(s),e[16]=s,e[17]=d):d=e[17];const u=d;if(u){let v;return e[18]!==u.path?(v=n.jsx(_b,{path:u.path},u.path),e[18]=u.path,e[19]=v):v=e[19],v}let f;e[20]!==s?(f=Fc(s),e[20]=s,e[21]=f):f=e[21];const m=f;if(m){let v;return e[22]!==m.key||e[23]!==r?(v=n.jsx(fb,{fileKey:m.key,taskId:r}),e[22]=m.key,e[23]=r,e[24]=v):v=e[24],v}let p;e[25]!==s?(p=Gf(s),e[25]=s,e[26]=p):p=e[26];const _=p;if(_){let v;if(e[27]!==a||e[28]!==_.connectionId||e[29]!==_.toolName){let T;e[31]!==_.connectionId||e[32]!==_.toolName?(T=B=>B.appId===_.connectionId&&B.toolName===_.toolName,e[31]=_.connectionId,e[32]=_.toolName,e[33]=T):T=e[33],v=a.find(T),e[27]=a,e[28]=_.connectionId,e[29]=_.toolName,e[30]=v}else v=e[30];const y=v;let S;e[34]===Symbol.for("react.memo_cache_sentinel")?(S=n.jsx(Ks,{}),e[34]=S):S=e[34];const C=y?.args;let j;return e[35]!==s||e[36]!==_.connectionId||e[37]!==_.toolName||e[38]!==C?(j=n.jsx(P.Suspense,{fallback:S,children:n.jsx(Sl,{connectionId:_.connectionId,toolName:_.toolName,args:C},s)}),e[35]=s,e[36]=_.connectionId,e[37]=_.toolName,e[38]=C,e[39]=j):j=e[39],j}let g;if(e[40]!==s||e[41]!==o){let v;e[43]!==s?(v=y=>y.id===s,e[43]=s,e[44]=v):v=e[44],g=o.find(v),e[40]=s,e[41]=o,e[42]=g}else g=e[42];const x=g;if(x){let v;e[45]===Symbol.for("react.memo_cache_sentinel")?(v=n.jsx(Ks,{}),e[45]=v):v=e[45];let y;return e[46]!==s||e[47]!==x.id||e[48]!==x.view.appId||e[49]!==x.view.args?(y=n.jsx(P.Suspense,{fallback:v,children:n.jsx(Sl,{connectionId:x.view.appId,toolName:x.id,args:x.view.args},s)}),e[46]=s,e[47]=x.id,e[48]=x.view.appId,e[49]=x.view.args,e[50]=y):y=e[50],y}let b;return e[51]!==i?(b=n.jsx(nl,{virtualMcpId:i}),e[51]=i,e[52]=b):b=e[52],b}function vb(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}=Ah(r);let c;e[3]===Symbol.for("react.memo_cache_sentinel")?(c=n.jsx(Ks,{}),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(gb,{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(Ut,{children:d},o),e[11]=o,e[12]=d,e[13]=u):u=e[13],u}const Ss="setup";function xb(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===Ss?t.onToggle():t.onSelectTab(Ss)},e[5]=t,e[6]=r):r=e[6];const o=r,a=t.active===Ss;let l;e[7]!==o||e[8]!==t.open||e[9]!==a?(l=n.jsx(bb,{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(Sb,{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(wb,{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(Cb,{isRunning:t.scriptIsRunning,isKilling:t.scriptIsKilling,onRun:t.onRunActiveScript,onStop:t.onStopActiveScript}):n.jsx(yb,{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 bb(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=ce("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($f,{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 yb(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(Ws,{className:"size-3.5"}),e[0]=h):h=e[0];let c;return e[1]!==i?(c=n.jsxs(se,{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(Ws,{className:"size-3.5"}),e[3]=h):h=e[3];let c;return e[4]!==a?(c=n.jsxs(se,{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(se,{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=ce(c),e[9]=c,e[10]=d):d=e[10];let u;e[11]===Symbol.for("react.memo_cache_sentinel")?(u=n.jsx(Oc,{className:"size-3.5"}),e[11]=u):u=e[11];let f;e[12]!==r||e[13]!==d?(f=n.jsx(Ee,{asChild:!0,children:n.jsxs(se,{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(Te,{children:"Stop sandbox"}),e[15]=m):m=e[15];let p;e[16]!==f?(p=n.jsxs(Pe,{children:[f,m]}),e[16]=f,e[17]=p):p=e[17];let _;e[18]!==o||e[19]!==h?(_=h&&n.jsxs(Qs,{children:[n.jsx(ei,{asChild:!0,children:n.jsx(se,{variant:"outline",size:"sm",className:"rounded-l-none px-1",children:n.jsx(Es,{className:"size-3"})})}),n.jsx(ti,{align:"end",children:n.jsxs(Ze,{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 Sb(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=ce("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=ce("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(rp,{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 wb(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(Pe,{children:[n.jsx(Ee,{asChild:!0,children:n.jsx(Ps,{asChild:!0,children:n.jsx(se,{variant:"ghost",size:"sm","aria-label":"Run script",children:n.jsx(Bt,{className:"size-3.5"})})})}),n.jsx(Te,{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(Rs,{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(Ts,{open:r,onOpenChange:o,children:[a,c]}),e[7]=r,e[8]=c,e[9]=d):d=e[9],d}function Cb(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(se,{variant:"outline",size:"sm",disabled:!0,children:[n.jsx(Ce,{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(Ws,{className:"size-3.5"}),e[1]=d):d=e[1];let u;e[2]!==r?(u=n.jsx(Ee,{asChild:!0,children:n.jsxs(se,{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(Te,{children:"Start process"}),e[4]=f):f=e[4];let m;return e[5]!==u?(m=n.jsxs(Pe,{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(Oc,{className:"size-3.5"}),e[7]=a):a=e[7];let l;e[8]!==o?(l=n.jsx(Ee,{asChild:!0,children:n.jsxs(se,{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(Te,{children:"Stop process"}),e[10]=h):h=e[10];let c;return e[11]!==l?(c=n.jsxs(Pe,{children:[l,h]}),e[11]=l,e[12]=c):c=e[12],c}var vd=Object.defineProperty,kb=Object.getOwnPropertyDescriptor,jb=(t,e)=>{for(var s in e)vd(t,s,{get:e[s],enumerable:!0})},ze=(t,e,s,i)=>{for(var r=i>1?void 0:i?kb(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&&vd(e,s,r),r},de=(t,e)=>(s,i)=>e(s,i,t),wl="Terminal input",Vn={get:()=>wl,set:t=>wl=t},Cl="Too much output to announce, navigate to rows manually to read",qn={get:()=>Cl,set:t=>Cl=t};function Nb(t){return t.replace(/\r?\n/g,"\r")}function Eb(t,e){return e?"\x1B[200~"+t+"\x1B[201~":t}function Tb(t,e){t.clipboardData&&t.clipboardData.setData("text/plain",e.selectionText),t.preventDefault()}function Pb(t,e,s,i){if(t.stopPropagation(),t.clipboardData){let r=t.clipboardData.getData("text/plain");xd(r,e,s,i)}}function xd(t,e,s,i){t=Nb(t),t=Eb(t,s.decPrivateModes.bracketedPasteMode&&i.rawOptions.ignoreBracketedPasteMode!==!0),s.triggerDataEvent(t,!0),e.value=""}function bd(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 kl(t,e,s,i,r){bd(t,e,s),r&&i.rightClickSelect(t),e.value=i.selectionText,e.select()}function ds(t){return t>65535?(t-=65536,String.fromCharCode((t>>10)+55296)+String.fromCharCode(t%1024+56320)):String.fromCharCode(t)}function an(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 Rb=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}},Db=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,x=g-p;for(;c<x;){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}},yd="",us=" ",Yi=class Sd{constructor(){this.fg=0,this.bg=0,this.extended=new Fr}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 Sd;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}},Fr=class wd{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 wd(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},jt=class Cd extends Yi{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new Fr,this.combinedData=""}static fromCharData(e){let s=new Cd;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?ds(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()]}},jl="di$target",Gn="di$dependencies",Sn=new Map;function Ab(t){return t[Gn]||[]}function et(t){if(Sn.has(t))return Sn.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");Ib(e,s,r)};return e._id=t,Sn.set(t,e),e}function Ib(t,e,s){e[jl]===e?e[Gn].push({id:t,index:s}):(e[Gn]=[{id:t,index:s}],e[jl]=e)}var dt=et("BufferService"),kd=et("CoreMouseService"),Is=et("CoreService"),Bb=et("CharsetService"),va=et("InstantiationService"),jd=et("LogService"),ut=et("OptionsService"),Nd=et("OscLinkService"),Mb=et("UnicodeService"),Xi=et("DecorationService"),Yn=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 jt,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):Lb(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)}};Yn=ze([de(0,dt),de(1,ut),de(2,Nd)],Yn);function Lb(t,e){if(confirm(`Do you want to navigate to ${e}?
293
+ `);if(ae.trim()){A(!0);try{ee(),Le("automation_improve_clicked",{automation_id:t,agent_id:r,instructions_length:ae.length}),f(!0),await m({tiptapDoc:Ih({managerAgentId:Nc.AUTOMATION_MANAGER(o.id),managerName:"Automation Manager",kind:"automation",id:t,instructions:ae})})}finally{A(!1)}}},z=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,F=kc({defaultValues:{name:e.name,active:e.active,tier:z,modelOverride:H,tools:e.tools??null,maxAgentSteps:e.maxAgentSteps??null}}),q=F.watch("active"),[J,V]=P.useReducer(Gx,null),U=()=>{J!==null&&(Le("automation_updated",{automation_id:t,agent_id:r,fields:Array.from(J.fields),save_count:J.saveCount,edit_duration_ms:Date.now()-J.start}),V({type:"reset"}))},K=async()=>{const $=F.control._formState.dirtyFields,ae=Object.keys($);if(ae.length===0&&!M)return!0;const ue=F.getValues(),fe=F.control._defaultValues;F.reset(ue,{keepValues:!0});const he=M;D(!1);const re={tier:ue.tier,...ue.modelOverride?{modelId:ue.modelOverride.modelId,credentialId:ue.modelOverride.credentialId,modelTitle:ue.modelOverride.title}:{}},ve={id:t,name:ue.name,active:ue.active,models:re,tools:ue.tools,maxAgentSteps:ue.maxAgentSteps,messages:qu(_),temperature:0};try{await a.mutateAsync(ve)}catch{return F.reset(fe,{keepValues:!0}),he&&D(!0),!1}const ie=[...ae];return he&&ie.push("messages"),V({type:"accumulate",now:Date.now(),fields:ie}),O(),!0},{schedule:Q,flush:oe}=Mr({save:K}),{schedule:O,flush:ee}=Mr({delayMs:3e4,save:async()=>U()});P.useEffect(()=>{const $=F.watch(()=>Q());return()=>$.unsubscribe()},[]);const te=$=>{if(g($),!N){E(!0);return}D(!0),Q()},Y=async()=>{Le("automation_test_clicked",{automation_id:t,agent_id:r});const $=await oe();if(ee(),!!$){if(!_){le.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(se,{variant:"ghost",size:"sm",onClick:s,children:[n.jsx(ah,{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:F.control,name:"name",render:({field:$})=>n.jsx(Ve,{...$,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(se,{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:F.control,name:"active",render:({field:$})=>n.jsx(Br,{checked:$.value,onCheckedChange:ae=>{$.onChange(ae),oe()},className:"cursor-pointer"})}),n.jsx("span",{className:"text-sm text-muted-foreground",children:q?"Active":"Inactive"}),n.jsx("span",{className:"text-muted-foreground/50 text-sm",children:"·"}),n.jsx(Jc,{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(Ux,{automationId:t,open:x,onOpenChange:b,onCustomSelect:()=>{C(!0),I(!1),T("")},onEventSelect:()=>{I(!0),C(!1)},onWebhookCreated:$=>{Le("automation_trigger_added",{automation_id:t,trigger_type:"webhook"}),k($)}})]}),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:()=>b(!0),children:"Add a starter"})," ","to get going."]})}):n.jsx("div",{className:"flex flex-col gap-2",children:e.triggers.map($=>n.jsx(Kx,{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(ji,{size:14,className:"text-muted-foreground shrink-0"}),n.jsx("input",{type:"text",value:j,onChange:$=>T($.target.value),onBlur:async()=>{const $=j.trim();if(!(!$||!Ri($)))try{await l.mutateAsync({automation_id:t,type:"cron",cron_expression:$}),Le("automation_trigger_added",{automation_id:t,trigger_type:"cron"}),le.success("Starter added"),C(!1),T("")}catch{le.error("Failed to add starter")}},onKeyDown:async $=>{const ae=j.trim();$.key==="Enter"&&ae&&Ri(ae)&&$.target.blur(),$.key==="Escape"&&(C(!1),T(""))},placeholder:"0 9 * * 1-5",className:"flex-1 text-sm font-mono bg-transparent outline-none placeholder:text-muted-foreground/40",autoFocus:!0}),j&&!Ri(j)&&n.jsx("span",{className:"text-xs text-muted-foreground/60 shrink-0",children:"invalid"}),l.isPending&&n.jsx(Ce,{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:()=>{C(!1),T("")},children:n.jsx(ps,{size:13})})]}),B&&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(Ce,{size:13,className:"animate-spin text-muted-foreground"}),n.jsx("span",{className:"text-sm text-muted-foreground",children:"Loading connections..."})]}),children:n.jsx(Yx,{automationId:t,onDone:()=>I(!1)})}),n.jsx(pd,{open:R!==null,onOpenChange:$=>{$||k(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(se,{variant:"outline",size:"sm",className:"h-7 gap-1.5 px-2 text-xs",disabled:w||!_,onClick:L,children:[n.jsx(en,{size:13}),"Improve"]})]}),n.jsx($u,{tiptapDoc:_,setTiptapDoc:te,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(zu,{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(Pe,{children:[n.jsx(Ee,{asChild:!0,children:n.jsxs(se,{type:"button",variant:"default",className:"h-8 gap-1.5 rounded-md px-3 text-sm font-medium",onClick:Y,disabled:!r,children:[n.jsx(Wm,{size:16}),"Test"]})}),n.jsx(Te,{children:"Test Automation"})]})})]})})]}),n.jsxs(nf,{open:v,onOpenChange:y,className:"flex flex-col gap-2.5",children:[n.jsxs(of,{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(Es,{size:14,className:"text-muted-foreground/60 transition-transform group-data-[state=open]:rotate-180"})]}),n.jsxs(af,{className:"flex flex-col gap-5 pt-0.5",children:[n.jsx(Ex,{tier:F.watch("tier"),onTierChange:$=>F.setValue("tier",$,{shouldDirty:!0}),override:F.watch("modelOverride"),onOverrideChange:$=>F.setValue("modelOverride",$,{shouldDirty:!0})}),n.jsx(Dx,{agentId:r||null,value:F.watch("tools"),onChange:$=>F.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(Ve,{type:"number",min:1,max:100,className:"w-40",placeholder:`${qx} (default)`,value:F.watch("maxAgentSteps")??"",onChange:$=>{const ae=$.target.value.trim(),ue=ae===""?null:Number(ae);F.setValue("maxAgentSteps",ue===null||Number.isNaN(ue)?null:ue,{shouldDirty:!0})}})]})]})]})]})]})}function Ks(){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(Ce,{size:20,className:"animate-spin text-muted-foreground"})}),t[0]=e):e=t[0],e}const _d=[{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 gd(t){const e=_d.find(i=>i.key===t).ms,s=Date.now();return{startDate:new Date(s-e).toISOString(),endDate:new Date(s).toISOString()}}function eb(t){const e=W.c(12),{automationId:s,triggerIds:i}=t,[r,o]=P.useState("30d"),[a,l]=P.useState(sb);let h;e[0]===Symbol.for("react.memo_cache_sentinel")?(h=p=>{const _=p;o(_),l(gd(_))},e[0]=h):h=e[0];let c;e[1]===Symbol.for("react.memo_cache_sentinel")?(c=n.jsx(Pt,{className:"w-44",children:n.jsx(Rt,{})}),e[1]=c):c=e[1];let d;e[2]===Symbol.for("react.memo_cache_sentinel")?(d=n.jsx(Dt,{children:_d.map(tb)}),e[2]=d):d=e[2];let u;e[3]!==r?(u=n.jsx("div",{className:"flex items-center justify-end",children:n.jsxs(At,{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(sp,{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 tb(t){return n.jsx(at,{value:t.key,children:t.label},t.key)}function sb(){return gd("30d")}function ib(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(Ks,{}),e[2]=o):o=e[2];let a;return e[3]!==r.id?(a=n.jsx(P.Suspense,{fallback:o,children:n.jsx(rb,{id:r.id})}),e[3]=r.id,e[4]=a):a=e[4],a}function rb(t){const e=W.c(24),{id:s}=t,i=es(),{data:r,isLoading:o}=Zm(s),[a,l]=P.useState("settings");let h;e[0]!==i?(h=()=>{i({to:".",search:ob,replace:!0})},e[0]=i,e[1]=h):h=e[1];const c=h;if(o){let y;return e[2]===Symbol.for("react.memo_cache_sentinel")?(y=n.jsx(Ks,{}),e[2]=y):y=e[2],y}if(!r){let y;return e[3]===Symbol.for("react.memo_cache_sentinel")?(y=n.jsx("div",{className:"flex h-full w-full items-center justify-center text-sm text-muted-foreground",children:"Automation not found"}),e[3]=y):y=e[3],y}let d;e[4]!==r.triggers?(d=r.triggers.map(nb),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(ah,{size:14}),e[6]=f):f=e[6];let m;e[7]!==c?(m=n.jsxs(se,{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")?(_=y=>l(y),e[10]=_):_=e[10];let g;e[11]!==a?(g=n.jsx(sh,{tabs:p,activeTab:a,onTabChange:_}),e[11]=a,e[12]=g):g=e[12];let x;e[13]!==m||e[14]!==g?(x=n.jsxs("div",{className:"flex items-center justify-between pb-4 shrink-0",children:[m,g]}),e[13]=m,e[14]=g,e[15]=x):x=e[15];let b;e[16]!==r||e[17]!==s||e[18]!==a||e[19]!==u?(b=a==="settings"?n.jsx(Qx,{automationId:s,automation:r}):n.jsx(eb,{automationId:s,triggerIds:u}),e[16]=r,e[17]=s,e[18]=a,e[19]=u,e[20]=b):b=e[20];let v;return e[21]!==x||e[22]!==b?(v=n.jsx(Tt,{children:n.jsx(Tt.Content,{children:n.jsxs(Tt.Body,{children:[x,b]})})}),e[21]=x,e[22]=b,e[23]=v):v=e[23],v}function nb(t){return t.id}function ob(t){return{...t,main:"automations"}}function ab(t){const e=W.c(20),{virtualMcpId:s}=t,i=es(),{data:r}=Qm(s),o=r===void 0?[]:r,{create:a}=Ki(),[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:k=>({...k,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(ep(s));f(R.id)};let p;e[2]===Symbol.for("react.memo_cache_sentinel")?(p=n.jsx(Bt,{size:14}),e[2]=p):p=e[2];let _;e[3]!==a.isPending||e[4]!==m?(_=n.jsxs(se,{size:"sm",onClick:m,disabled:a.isPending,children:[p,"New automation"]}),e[3]=a.isPending,e[4]=m,e[5]=_):_=e[5];const g=_,x=Tt,b=Tt,v=Tt;let y;e[6]===Symbol.for("react.memo_cache_sentinel")?(y=n.jsx(Tt.Title,{children:"Automations"}),e[6]=y):y=e[6];const S=o.length>0&&n.jsx(th,{value:l,onChange:h,placeholder:"Search automations...",className:"w-full md:w-[375px]"});let C;e[7]!==g||e[8]!==S?(C=n.jsxs("div",{className:"flex flex-col gap-6",children:[y,n.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[S,g]})]}),e[7]=g,e[8]=S,e[9]=C):C=e[9];const j=o.length===0?n.jsx("div",{className:"flex items-center justify-center py-20",children:n.jsx(kr,{image:n.jsx(Mi,{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(kr,{image:n.jsx(Mi,{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(ip,{automation:R,onClick:()=>f(R.id)},R.id))});let T;e[10]!==j||e[11]!==v.Body||e[12]!==C?(T=n.jsxs(v.Body,{children:[C,j]}),e[10]=j,e[11]=v.Body,e[12]=C,e[13]=T):T=e[13];let B;e[14]!==T||e[15]!==b.Content?(B=n.jsx(b.Content,{children:T}),e[14]=T,e[15]=b.Content,e[16]=B):B=e[16];let I;return e[17]!==x||e[18]!==B?(I=n.jsx(x,{children:B}),e[17]=x,e[18]=B,e[19]=I):I=e[19],I}function lb(t){const e=W.c(3),{virtualMcpId:s}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=n.jsx(Ks,{}),e[0]=i):i=e[0];let r;return e[1]!==s?(r=n.jsx(P.Suspense,{fallback:i,children:n.jsx(ab,{virtualMcpId:s})}),e[1]=s,e[2]=r):r=e[2],r}function cb(){const t=W.c(2);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsx(xs,{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(xs,{className:"h-3 w-full"}),n.jsx(xs,{className:"h-3 w-5/6"}),n.jsx(xs,{className:"h-3 w-2/3"})]}),n.jsx(xs,{className:"mt-2 h-8 w-24"})]})}),t[1]=s):s=t[1],s}function hb(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 db(t){const e=W.c(11),{slug:s}=t,i=Yu();let r;e[0]!==i?.messages?(r=i?.messages??[],e[0]=i?.messages,e[1]=r):r=e[1];const o=r;let a;e[2]!==o||e[3]!==s?(a=hb(o,s),e[2]=o,e[3]=s,e[4]=a):a=e[4];const l=a;if(!l){let f;return e[5]===Symbol.for("react.memo_cache_sentinel")?(f=n.jsx("div",{className:"h-full w-full bg-background",children:n.jsx(cb,{})}),e[5]=f):f=e[5],f}const h=l.url,c=String(l.bytes),d=`${s}.html`;let u;return e[6]!==l.url||e[7]!==s||e[8]!==c||e[9]!==d?(u=n.jsx(Gc,{readUrl:h,marker:c,title:d},s),e[6]=l.url,e[7]=s,e[8]=c,e[9]=d,e[10]=u):u=e[10],u}function ub(t){const e=W.c(37),{file:s,onClose:i}=t;let r,o;e[0]!==s.filename?(r=n.jsx($o,{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=am(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(em,{size:14}),e[11]=c):c=e[11];let d;e[12]!==s.downloadUrl||e[13]!==s.filename?(d=n.jsx(Ee,{asChild:!0,children:n.jsx(se,{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(Te,{side:"bottom",children:"Download"}),e[15]=u):u=e[15];let f;e[16]!==d?(f=n.jsxs(Pe,{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(ii,{size:14}),e[20]=p):p=e[20];let _;e[21]!==m?(_=n.jsx(Ee,{asChild:!0,children:n.jsx(se,{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(Te,{side:"bottom",children:"Open in new tab"}),e[23]=g):g=e[23];let x;e[24]!==_?(x=n.jsxs(Pe,{children:[_,g]}),e[24]=_,e[25]=x):x=e[25];let b;e[26]===Symbol.for("react.memo_cache_sentinel")?(b=n.jsx(ps,{size:14}),e[26]=b):b=e[26];let v;e[27]!==i?(v=n.jsx(Ee,{asChild:!0,children:n.jsx(se,{variant:"ghost",size:"icon",onClick:i,children:b})}),e[27]=i,e[28]=v):v=e[28];let y;e[29]===Symbol.for("react.memo_cache_sentinel")?(y=n.jsx(Te,{side:"bottom",children:"Close"}),e[29]=y):y=e[29];let S;e[30]!==v?(S=n.jsxs(Pe,{children:[v,y]}),e[30]=v,e[31]=S):S=e[31];let C;return e[32]!==x||e[33]!==S||e[34]!==h||e[35]!==f?(C=n.jsxs("div",{className:"flex h-9 shrink-0 items-center gap-1 border-b border-border/60 px-2",children:[h,f,x,S]}),e[32]=x,e[33]=S,e[34]=h,e[35]=f,e[36]=C):C=e[36],C}function fb(t){const e=W.c(24),{fileKey:s,taskId:i}=t,r=es(),{data:o,isPending:a}=Pc(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:mb,replace:!0}),e[3]=r,e[4]=c):c=e[4];const d=c;if(!h){if(a){let v;return e[5]===Symbol.for("react.memo_cache_sentinel")?(v=n.jsx("div",{className:"h-full w-full bg-background",children:n.jsx(nm,{})}),e[5]=v):v=e[5],v}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($o,{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 x;e[11]!==d?(x=n.jsx(se,{variant:"ghost",size:"sm",onClick:d,children:"Close"}),e[11]=d,e[12]=x):x=e[12];let b;return e[13]!==_||e[14]!==x?(b=n.jsxs("div",{className:"flex h-full w-full flex-col items-center justify-center gap-2 bg-background",children:[_,g,x]}),e[13]=_,e[14]=x,e[15]=b):b=e[15],b}let u;e[16]!==h||e[17]!==d?(u=n.jsx(ub,{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(om,{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 mb(t){return{...t,main:"0"}}const yl="home";function pb(t){const e=W.c(5),{label:s}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=n.jsx(xs,{className:"aspect-video w-2/3 max-w-xl"}),e[0]=i):i=e[0];let r;e[1]!==s?(r=s&&n.jsx("p",{className:"text-xs text-muted-foreground",children:s}),e[1]=s,e[2]=r):r=e[2];let o;return e[3]!==r?(o=n.jsxs("div",{className:"flex h-full w-full flex-col items-center justify-center gap-3 bg-background",children:[i,r]}),e[3]=r,e[4]=o):o=e[4],o}function _b(t){const e=W.c(12),{path:s}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i={refetchIntervalWhenAbsent:2e3},e[0]=i):i=e[0];const r=lm(yl,s,i),o=cm(yl);let a;e[1]!==s||e[2]!==o?(a=o(s),e[1]=s,e[2]=o,e[3]=a):a=e[3];const l=a;if(r.isPending||!r.data){const d=!r.isPending&&!r.data?"Waiting for the deck to sync…":void 0;let u;return e[4]!==d?(u=n.jsx(pb,{label:d}),e[4]=d,e[5]=u):u=e[5],u}let h;e[6]!==r.data?(h=hm(r.data),e[6]=r.data,e[7]=h):h=e[7];let c;return e[8]!==s||e[9]!==l||e[10]!==h?(c=n.jsx(Gc,{readUrl:l,marker:h,title:s,savePath:s}),e[8]=s,e[9]=l,e[10]=h,e[11]=c):c=e[11],c}const Sl=P.lazy(()=>qt(()=>import("./project-app-view-B86ITaCE.js"),__vite__mapDeps([163,1,2,97,6,7,8,9,10,11,12,13,14,15,16,3,17,4,5,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,98,99,46,47,48,100,101,49,102,103,58,91,92,93,94,85,95,57,96,59,104,105,106,107,108,66,109,56,110,71,72,50,111,126])).then(t=>({default:t.AppViewContent})));function gb(t){const e=W.c(53),{activeTab:s,virtualMcpId:i,taskId:r,layoutTabs:o,expandedTools:a,automationTabParsed:l}=t;if(Vf(s)){let v;return e[0]!==i?(v=n.jsx(nl,{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(lb,{virtualMcpId:i}),e[4]=i,e[5]=v):v=e[5],v}if(s==="preview"){let v;return e[6]!==i?(v=n.jsx(x1,{virtualMcpId:i}),e[6]=i,e[7]=v):v=e[7],v}if(s==="content"){let v;return e[8]!==i?(v=n.jsx(kx,{virtualMcpId:i}),e[8]=i,e[9]=v):v=e[9],v}if(l){let v;return e[10]!==s?(v=n.jsx(ib,{tabId:s}),e[10]=s,e[11]=v):v=e[11],v}let h;e[12]!==s?(h=qf(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(db,{slug:c.slug}),e[14]=c.slug,e[15]=v):v=e[15],v}let d;e[16]!==s?(d=Hc(s),e[16]=s,e[17]=d):d=e[17];const u=d;if(u){let v;return e[18]!==u.path?(v=n.jsx(_b,{path:u.path},u.path),e[18]=u.path,e[19]=v):v=e[19],v}let f;e[20]!==s?(f=Fc(s),e[20]=s,e[21]=f):f=e[21];const m=f;if(m){let v;return e[22]!==m.key||e[23]!==r?(v=n.jsx(fb,{fileKey:m.key,taskId:r}),e[22]=m.key,e[23]=r,e[24]=v):v=e[24],v}let p;e[25]!==s?(p=Gf(s),e[25]=s,e[26]=p):p=e[26];const _=p;if(_){let v;if(e[27]!==a||e[28]!==_.connectionId||e[29]!==_.toolName){let T;e[31]!==_.connectionId||e[32]!==_.toolName?(T=B=>B.appId===_.connectionId&&B.toolName===_.toolName,e[31]=_.connectionId,e[32]=_.toolName,e[33]=T):T=e[33],v=a.find(T),e[27]=a,e[28]=_.connectionId,e[29]=_.toolName,e[30]=v}else v=e[30];const y=v;let S;e[34]===Symbol.for("react.memo_cache_sentinel")?(S=n.jsx(Ks,{}),e[34]=S):S=e[34];const C=y?.args;let j;return e[35]!==s||e[36]!==_.connectionId||e[37]!==_.toolName||e[38]!==C?(j=n.jsx(P.Suspense,{fallback:S,children:n.jsx(Sl,{connectionId:_.connectionId,toolName:_.toolName,args:C},s)}),e[35]=s,e[36]=_.connectionId,e[37]=_.toolName,e[38]=C,e[39]=j):j=e[39],j}let g;if(e[40]!==s||e[41]!==o){let v;e[43]!==s?(v=y=>y.id===s,e[43]=s,e[44]=v):v=e[44],g=o.find(v),e[40]=s,e[41]=o,e[42]=g}else g=e[42];const x=g;if(x){let v;e[45]===Symbol.for("react.memo_cache_sentinel")?(v=n.jsx(Ks,{}),e[45]=v):v=e[45];let y;return e[46]!==s||e[47]!==x.id||e[48]!==x.view.appId||e[49]!==x.view.args?(y=n.jsx(P.Suspense,{fallback:v,children:n.jsx(Sl,{connectionId:x.view.appId,toolName:x.id,args:x.view.args},s)}),e[46]=s,e[47]=x.id,e[48]=x.view.appId,e[49]=x.view.args,e[50]=y):y=e[50],y}let b;return e[51]!==i?(b=n.jsx(nl,{virtualMcpId:i}),e[51]=i,e[52]=b):b=e[52],b}function vb(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}=Ah(r);let c;e[3]===Symbol.for("react.memo_cache_sentinel")?(c=n.jsx(Ks,{}),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(gb,{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(Ut,{children:d},o),e[11]=o,e[12]=d,e[13]=u):u=e[13],u}const Ss="setup";function xb(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===Ss?t.onToggle():t.onSelectTab(Ss)},e[5]=t,e[6]=r):r=e[6];const o=r,a=t.active===Ss;let l;e[7]!==o||e[8]!==t.open||e[9]!==a?(l=n.jsx(bb,{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(Sb,{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(wb,{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(Cb,{isRunning:t.scriptIsRunning,isKilling:t.scriptIsKilling,onRun:t.onRunActiveScript,onStop:t.onStopActiveScript}):n.jsx(yb,{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 bb(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=ce("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($f,{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 yb(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(Ws,{className:"size-3.5"}),e[0]=h):h=e[0];let c;return e[1]!==i?(c=n.jsxs(se,{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(Ws,{className:"size-3.5"}),e[3]=h):h=e[3];let c;return e[4]!==a?(c=n.jsxs(se,{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(se,{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=ce(c),e[9]=c,e[10]=d):d=e[10];let u;e[11]===Symbol.for("react.memo_cache_sentinel")?(u=n.jsx(Oc,{className:"size-3.5"}),e[11]=u):u=e[11];let f;e[12]!==r||e[13]!==d?(f=n.jsx(Ee,{asChild:!0,children:n.jsxs(se,{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(Te,{children:"Stop sandbox"}),e[15]=m):m=e[15];let p;e[16]!==f?(p=n.jsxs(Pe,{children:[f,m]}),e[16]=f,e[17]=p):p=e[17];let _;e[18]!==o||e[19]!==h?(_=h&&n.jsxs(Qs,{children:[n.jsx(ei,{asChild:!0,children:n.jsx(se,{variant:"outline",size:"sm",className:"rounded-l-none px-1",children:n.jsx(Es,{className:"size-3"})})}),n.jsx(ti,{align:"end",children:n.jsxs(Ze,{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 Sb(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=ce("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=ce("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(rp,{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 wb(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(Pe,{children:[n.jsx(Ee,{asChild:!0,children:n.jsx(Ps,{asChild:!0,children:n.jsx(se,{variant:"ghost",size:"sm","aria-label":"Run script",children:n.jsx(Bt,{className:"size-3.5"})})})}),n.jsx(Te,{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(Rs,{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(Ts,{open:r,onOpenChange:o,children:[a,c]}),e[7]=r,e[8]=c,e[9]=d):d=e[9],d}function Cb(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(se,{variant:"outline",size:"sm",disabled:!0,children:[n.jsx(Ce,{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(Ws,{className:"size-3.5"}),e[1]=d):d=e[1];let u;e[2]!==r?(u=n.jsx(Ee,{asChild:!0,children:n.jsxs(se,{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(Te,{children:"Start process"}),e[4]=f):f=e[4];let m;return e[5]!==u?(m=n.jsxs(Pe,{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(Oc,{className:"size-3.5"}),e[7]=a):a=e[7];let l;e[8]!==o?(l=n.jsx(Ee,{asChild:!0,children:n.jsxs(se,{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(Te,{children:"Stop process"}),e[10]=h):h=e[10];let c;return e[11]!==l?(c=n.jsxs(Pe,{children:[l,h]}),e[11]=l,e[12]=c):c=e[12],c}var vd=Object.defineProperty,kb=Object.getOwnPropertyDescriptor,jb=(t,e)=>{for(var s in e)vd(t,s,{get:e[s],enumerable:!0})},ze=(t,e,s,i)=>{for(var r=i>1?void 0:i?kb(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&&vd(e,s,r),r},de=(t,e)=>(s,i)=>e(s,i,t),wl="Terminal input",Vn={get:()=>wl,set:t=>wl=t},Cl="Too much output to announce, navigate to rows manually to read",qn={get:()=>Cl,set:t=>Cl=t};function Nb(t){return t.replace(/\r?\n/g,"\r")}function Eb(t,e){return e?"\x1B[200~"+t+"\x1B[201~":t}function Tb(t,e){t.clipboardData&&t.clipboardData.setData("text/plain",e.selectionText),t.preventDefault()}function Pb(t,e,s,i){if(t.stopPropagation(),t.clipboardData){let r=t.clipboardData.getData("text/plain");xd(r,e,s,i)}}function xd(t,e,s,i){t=Nb(t),t=Eb(t,s.decPrivateModes.bracketedPasteMode&&i.rawOptions.ignoreBracketedPasteMode!==!0),s.triggerDataEvent(t,!0),e.value=""}function bd(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 kl(t,e,s,i,r){bd(t,e,s),r&&i.rightClickSelect(t),e.value=i.selectionText,e.select()}function ds(t){return t>65535?(t-=65536,String.fromCharCode((t>>10)+55296)+String.fromCharCode(t%1024+56320)):String.fromCharCode(t)}function an(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 Rb=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}},Db=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,x=g-p;for(;c<x;){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}},yd="",us=" ",Yi=class Sd{constructor(){this.fg=0,this.bg=0,this.extended=new Fr}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 Sd;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}},Fr=class wd{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 wd(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},jt=class Cd extends Yi{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new Fr,this.combinedData=""}static fromCharData(e){let s=new Cd;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?ds(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()]}},jl="di$target",Gn="di$dependencies",Sn=new Map;function Ab(t){return t[Gn]||[]}function et(t){if(Sn.has(t))return Sn.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");Ib(e,s,r)};return e._id=t,Sn.set(t,e),e}function Ib(t,e,s){e[jl]===e?e[Gn].push({id:t,index:s}):(e[Gn]=[{id:t,index:s}],e[jl]=e)}var dt=et("BufferService"),kd=et("CoreMouseService"),Is=et("CoreService"),Bb=et("CharsetService"),va=et("InstantiationService"),jd=et("LogService"),ut=et("OptionsService"),Nd=et("OscLinkService"),Mb=et("UnicodeService"),Xi=et("DecorationService"),Yn=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 jt,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):Lb(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)}};Yn=ze([de(0,dt),de(1,ut),de(2,Nd)],Yn);function Lb(t,e){if(confirm(`Do you want to navigate to ${e}?
294
294
 
295
295
  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 ln=et("CharSizeService"),rs=et("CoreBrowserService"),xa=et("MouseService"),ns=et("RenderService"),Ob=et("SelectionService"),Ed=et("CharacterJoinerService"),ai=et("ThemeService"),Td=et("LinkProviderService"),$b=class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(t){setTimeout(()=>{throw t.stack?Nl.isErrorNoTelemetry(t)?new Nl(t.message+`
296
296